source: network-game/common/Player.h@ 1f6233e

Last change on this file since 1f6233e was 6054f1e, checked in by dportnoy <dmp1488@…>, 11 years ago

Moved damagePlayer to the Player class

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