source: network-game/common/Player.h@ 64a1f4e

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

The playerClass instance variable of the Player class is now an enum instead of an int

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[2488852]1#ifndef _PLAYER_H
2#define _PLAYER_H
3
4#include <string>
[ff2133a]5#include <map>
[2488852]6
[e6c26b8]7#include "Compiler.h"
[373089e]8
[e6c26b8]9#if defined WINDOWS
10 #include <winsock2.h>
11#elif defined LINUX
[373089e]12 #include <netinet/in.h>
13#endif
14
[a1a3bd5]15#include "WorldMap.h"
[edfd1d0]16
[2488852]17using namespace std;
18
[f41a7f9]19//forward declaration
20class Game;
21
[8e540f4]22class Player {
[5b92307]23private:
24 unsigned int id;
25 unsigned int targetPlayer;
26
[2488852]27public:
[07c73fa]28
29 enum PlayerClass {
30 CLASS_NONE,
31 CLASS_WARRIOR,
32 CLASS_RANGER
33 };
34
35 enum AttackType {
36 ATTACK_NONE,
37 ATTACK_MELEE,
38 ATTACK_RANGED
39 };
40
[01d0d00]41 Player();
42 Player(const Player& p);
[59061f6]43 Player(string name, string password);
[01d0d00]44
[8e540f4]45 ~Player();
[2488852]46
[5b92307]47 unsigned int getId();
48 unsigned int getTargetPlayer();
49
[9ba9b96]50 void setId(unsigned int id);
[5b92307]51 void setTargetPlayer(unsigned int id);
[59061f6]52 void setAddr(sockaddr_in addr);
[46fa35a]53 void setClass(PlayerClass c);
54
55 void serialize(char* buffer);
56 void deserialize(char* buffer);
[59061f6]57
[5b92307]58 bool updateTarget(map<unsigned int, Player*>& players);
[227baaa]59 bool move(WorldMap *map);
[6054f1e]60 void takeDamage(int damage);
[60017fc]61
[9ba9b96]62 void takeFlag(unsigned int flag, WorldMap* map);
63 void dropFlag(unsigned int flag, WorldMap* map);
[d436ac4]64
[8e540f4]65 string name;
[59061f6]66 string password;
[8e540f4]67 sockaddr_in addr;
[60017fc]68 FLOAT_POSITION pos;
69 POSITION target;
[8f85180]70 unsigned long long timeLastUpdated;
[8dad966]71 unsigned long long timeAttackStarted;
[c76134b]72 unsigned long long timeDied;
[11d21ee]73 bool isChasing;
[8dad966]74 bool isAttacking;
[c76134b]75 bool isDead;
[d436ac4]76
[c991530]77 PlayerClass playerClass;
[07c73fa]78 int maxHealth;
79 int health;
80 int attackType;
81 int damage;
[11d21ee]82 int range;
[8dad966]83 unsigned long long attackCooldown;
[d436ac4]84 int team; // 0 is blue, 1 is red
[74b8e79]85 bool hasBlueFlag;
[d436ac4]86 bool hasRedFlag;
[f41a7f9]87
88 Game* currentGame;
[2488852]89};
90
91#endif
Note: See TracBrowser for help on using the repository browser.