Last change
on this file since 7fa452f was 7fa452f, checked in by Dmitry Portnoy <dmp1488@…>, 10 years ago |
Change the player team variable so that 0 means no team, 1 means blue team, and 2 means red team (before, -1 meant no team, 0 meant blue team, and 1 meant red team)
|
-
Property mode
set to
100644
|
File size:
1.8 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 | #elif defined MAC
|
---|
14 | #include <netinet/in.h>
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | #include "WorldMap.h"
|
---|
18 |
|
---|
19 | using namespace std;
|
---|
20 |
|
---|
21 | //forward declaration
|
---|
22 | class Game;
|
---|
23 |
|
---|
24 | class Player {
|
---|
25 | private:
|
---|
26 | unsigned int id;
|
---|
27 | unsigned int targetPlayer;
|
---|
28 |
|
---|
29 | public:
|
---|
30 |
|
---|
31 | enum PlayerClass {
|
---|
32 | CLASS_NONE,
|
---|
33 | CLASS_WARRIOR,
|
---|
34 | CLASS_RANGER
|
---|
35 | };
|
---|
36 |
|
---|
37 | enum AttackType {
|
---|
38 | ATTACK_NONE,
|
---|
39 | ATTACK_MELEE,
|
---|
40 | ATTACK_RANGED
|
---|
41 | };
|
---|
42 |
|
---|
43 | Player();
|
---|
44 | Player(const Player& p);
|
---|
45 | Player(string name, string password);
|
---|
46 |
|
---|
47 | ~Player();
|
---|
48 |
|
---|
49 | unsigned int getId();
|
---|
50 | unsigned int getTargetPlayer();
|
---|
51 |
|
---|
52 | void setId(unsigned int id);
|
---|
53 | void setTargetPlayer(unsigned int id);
|
---|
54 | void setAddr(sockaddr_in addr);
|
---|
55 | void setClass(PlayerClass c);
|
---|
56 |
|
---|
57 | void serialize(char* buffer);
|
---|
58 | void deserialize(char* buffer);
|
---|
59 |
|
---|
60 | bool updateTarget(map<unsigned int, Player*>& players);
|
---|
61 | bool move(WorldMap *map);
|
---|
62 | void takeDamage(int damage);
|
---|
63 |
|
---|
64 | void takeFlag(unsigned int flag, WorldMap* map);
|
---|
65 | void dropFlag(unsigned int flag, WorldMap* map);
|
---|
66 |
|
---|
67 | string name;
|
---|
68 | string password;
|
---|
69 | sockaddr_in addr;
|
---|
70 | FLOAT_POSITION pos;
|
---|
71 | POSITION target;
|
---|
72 | unsigned long long timeLastUpdated;
|
---|
73 | unsigned long long timeAttackStarted;
|
---|
74 | unsigned long long timeDied;
|
---|
75 | bool isChasing;
|
---|
76 | bool isAttacking;
|
---|
77 | bool isDead;
|
---|
78 |
|
---|
79 | PlayerClass playerClass;
|
---|
80 | int maxHealth;
|
---|
81 | int health;
|
---|
82 | int attackType;
|
---|
83 | int damage;
|
---|
84 | int range;
|
---|
85 | unsigned long long attackCooldown;
|
---|
86 | int team; // 0 is none, 1 is blue, 2 is red
|
---|
87 | bool hasBlueFlag;
|
---|
88 | bool hasRedFlag;
|
---|
89 |
|
---|
90 | // permanent attributes
|
---|
91 | unsigned int level;
|
---|
92 | unsigned int experience;
|
---|
93 | unsigned int honor;
|
---|
94 | unsigned int wins;
|
---|
95 | unsigned int losses;
|
---|
96 |
|
---|
97 | Game* currentGame;
|
---|
98 | };
|
---|
99 |
|
---|
100 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.