source: network-game/common/Player.h@ 5b92307

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

id and targetPlayer are now both private members of the Player class and have getters and setters to access them

  • Property mode set to 100644
File size: 1.6 KB
Line 
1#ifndef _PLAYER_H
2#define _PLAYER_H
3
4#include <string>
5#include <map>
6
7#include "Compiler.h"
8
9#if defined WINDOWS
10 #include <winsock2.h>
11#elif defined LINUX
12 #include <netinet/in.h>
13#endif
14
15#include "WorldMap.h"
16
17using namespace std;
18
19//forward declaration
20class Game;
21
22class Player {
23private:
24 unsigned int id;
25 unsigned int targetPlayer;
26
27public:
28
29 enum PlayerClass {
30 CLASS_NONE,
31 CLASS_WARRIOR,
32 CLASS_RANGER
33 };
34
35 enum AttackType {
36 ATTACK_NONE,
37 ATTACK_MELEE,
38 ATTACK_RANGED
39 };
40
41 Player();
42 Player(const Player& p);
43 Player(string name, string password);
44
45 ~Player();
46
47 unsigned int getId();
48 unsigned int getTargetPlayer();
49
50 void setId(unsigned int id);
51 void setTargetPlayer(unsigned int id);
52 void setAddr(sockaddr_in addr);
53 void setClass(PlayerClass c);
54
55 void serialize(char* buffer);
56 void deserialize(char* buffer);
57
58 bool updateTarget(map<unsigned int, Player*>& players);
59 bool move(WorldMap *map);
60 void takeDamage(int damage);
61
62 void takeFlag(unsigned int flag, WorldMap* map);
63 void dropFlag(unsigned int flag, WorldMap* map);
64
65 string name;
66 string password;
67 sockaddr_in addr;
68 FLOAT_POSITION pos;
69 POSITION target;
70 unsigned long long timeLastUpdated;
71 unsigned long long timeAttackStarted;
72 unsigned long long timeDied;
73 bool isChasing;
74 bool isAttacking;
75 bool isDead;
76
77 int playerClass;
78 int maxHealth;
79 int health;
80 int attackType;
81 int damage;
82 int range;
83 unsigned long long attackCooldown;
84 int team; // 0 is blue, 1 is red
85 bool hasBlueFlag;
86 bool hasRedFlag;
87
88 Game* currentGame;
89};
90
91#endif
Note: See TracBrowser for help on using the repository browser.