source: network-game/common/Player.h@ 9557f92

Last change on this file since 9557f92 was c76134b, checked in by dportnoy <dmp1488@…>, 11 years ago

A player respawns at their flag 10 seconds after dying

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[2488852]1#ifndef _PLAYER_H
2#define _PLAYER_H
3
[4c202e0]4#include "Compiler.h"
5
6#if defined WINDOWS
7 #include <winsock2.h>
8 #include <WS2tcpip.h>
9#elif defined LINUX
10 #include <netinet/in.h>
11#endif
12
[2488852]13#include <string>
[ff2133a]14#include <map>
[2488852]15
[edfd1d0]16#include "Common.h"
[a1a3bd5]17#include "WorldMap.h"
[edfd1d0]18
[2488852]19using namespace std;
20
[8e540f4]21class Player {
[2488852]22public:
[07c73fa]23
24 enum PlayerClass {
25 CLASS_NONE,
26 CLASS_WARRIOR,
27 CLASS_RANGER
28 };
29
30 enum AttackType {
31 ATTACK_NONE,
32 ATTACK_MELEE,
33 ATTACK_RANGED
34 };
35
[01d0d00]36 Player();
37 Player(const Player& p);
[59061f6]38 Player(string name, string password);
[01d0d00]39
[8e540f4]40 ~Player();
[2488852]41
[01d0d00]42 void setId(int id);
[59061f6]43 void setAddr(sockaddr_in addr);
[46fa35a]44 void setClass(PlayerClass c);
45
46 void serialize(char* buffer);
47 void deserialize(char* buffer);
[59061f6]48
[5b1e31e]49 bool updateTarget(map<unsigned int, Player>& mapPlayers);
[227baaa]50 bool move(WorldMap *map);
[60017fc]51
[ff2133a]52 void takeFlag(int flag, WorldMap* map);
53 void dropFlag(int flag, WorldMap* map);
[d436ac4]54
[01d0d00]55 int id;
[8e540f4]56 string name;
[59061f6]57 string password;
[8e540f4]58 sockaddr_in addr;
[60017fc]59 FLOAT_POSITION pos;
60 POSITION target;
[8f85180]61 unsigned long long timeLastUpdated;
[8dad966]62 unsigned long long timeAttackStarted;
[c76134b]63 unsigned long long timeDied;
[11d21ee]64 bool isChasing;
[8dad966]65 bool isAttacking;
66 int targetPlayer;
[c76134b]67 bool isDead;
[d436ac4]68
[07c73fa]69 int playerClass;
70 int maxHealth;
71 int health;
72 int attackType;
73 int damage;
[11d21ee]74 int range;
[8dad966]75 unsigned long long attackCooldown;
[d436ac4]76 int team; // 0 is blue, 1 is red
[74b8e79]77 bool hasBlueFlag;
[d436ac4]78 bool hasRedFlag;
[2488852]79};
80
81#endif
Note: See TracBrowser for help on using the repository browser.