source: network-game/common/Player.h@ 2ee386d

Last change on this file since 2ee386d 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
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 unsigned long long timeDied;
64 bool isChasing;
65 bool isAttacking;
66 int targetPlayer;
67 bool isDead;
68
69 int playerClass;
70 int maxHealth;
71 int health;
72 int attackType;
73 int damage;
74 int range;
75 unsigned long long attackCooldown;
76 int team; // 0 is blue, 1 is red
77 bool hasBlueFlag;
78 bool hasRedFlag;
79};
80
81#endif
Note: See TracBrowser for help on using the repository browser.