source: network-game/common/Player.h@ 373089e

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

The server compiles

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