source: network-game/common/Player.h@ 0693e25

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

Each player now holds a reference to their current game

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