source: network-game/common/Player.h@ 7c52498

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

Fix some bugs related to player attack and movement

  • Property mode set to 100644
File size: 1.4 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
21class Player {
22public:
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
36 Player();
37 Player(const Player& p);
38 Player(string name, string password);
39
40 ~Player();
41
42 void setId(int id);
43 void setAddr(sockaddr_in addr);
44 void setClass(PlayerClass c);
45
46 void serialize(char* buffer);
47 void deserialize(char* buffer);
48
49 bool updateTarget(map<unsigned int, Player>& mapPlayers);
50 bool move(WorldMap *map);
51
52 void takeFlag(int flag, WorldMap* map);
53 void dropFlag(int flag, WorldMap* map);
54
55 int id;
56 string name;
57 string password;
58 sockaddr_in addr;
59 FLOAT_POSITION pos;
60 POSITION target;
61 unsigned long long timeLastUpdated;
62 unsigned long long timeAttackStarted;
63 bool isChasing;
64 bool isAttacking;
65 int targetPlayer;
66
67 int playerClass;
68 int maxHealth;
69 int health;
70 int attackType;
71 int damage;
72 int range;
73 unsigned long long attackCooldown;
74 int team; // 0 is blue, 1 is red
75 bool hasBlueFlag;
76 bool hasRedFlag;
77};
78
79#endif
Note: See TracBrowser for help on using the repository browser.