source: network-game/common/Player.h@ 0065962

Last change on this file since 0065962 was 48801af, checked in by Dmitry Portnoy <dmp1488@…>, 10 years ago

Use an enum for the player's team

  • Property mode set to 100644
File size: 1.9 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>
[34bd549]13#elif defined MAC
14 #include <netinet/in.h>
[373089e]15#endif
16
[a1a3bd5]17#include "WorldMap.h"
[edfd1d0]18
[2488852]19using namespace std;
20
[f41a7f9]21//forward declaration
22class Game;
23
[8e540f4]24class Player {
[5b92307]25private:
26 unsigned int id;
27 unsigned int targetPlayer;
28
[2488852]29public:
[07c73fa]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
[48801af]43 enum PlayerTeam {
44 TEAM_NONE,
45 TEAM_BLUE,
46 TEAM_RED
47 };
48
[01d0d00]49 Player();
50 Player(const Player& p);
[59061f6]51 Player(string name, string password);
[01d0d00]52
[8e540f4]53 ~Player();
[2488852]54
[5b92307]55 unsigned int getId();
56 unsigned int getTargetPlayer();
57
[9ba9b96]58 void setId(unsigned int id);
[5b92307]59 void setTargetPlayer(unsigned int id);
[59061f6]60 void setAddr(sockaddr_in addr);
[46fa35a]61 void setClass(PlayerClass c);
62
63 void serialize(char* buffer);
64 void deserialize(char* buffer);
[59061f6]65
[5b92307]66 bool updateTarget(map<unsigned int, Player*>& players);
[227baaa]67 bool move(WorldMap *map);
[6054f1e]68 void takeDamage(int damage);
[60017fc]69
[9ba9b96]70 void takeFlag(unsigned int flag, WorldMap* map);
71 void dropFlag(unsigned int flag, WorldMap* map);
[d436ac4]72
[8e540f4]73 string name;
[59061f6]74 string password;
[8e540f4]75 sockaddr_in addr;
[60017fc]76 FLOAT_POSITION pos;
77 POSITION target;
[8f85180]78 unsigned long long timeLastUpdated;
[8dad966]79 unsigned long long timeAttackStarted;
[c76134b]80 unsigned long long timeDied;
[11d21ee]81 bool isChasing;
[8dad966]82 bool isAttacking;
[c76134b]83 bool isDead;
[d436ac4]84
[c991530]85 PlayerClass playerClass;
[07c73fa]86 int maxHealth;
87 int health;
88 int attackType;
89 int damage;
[11d21ee]90 int range;
[8dad966]91 unsigned long long attackCooldown;
[48801af]92 PlayerTeam team;
[74b8e79]93 bool hasBlueFlag;
[d436ac4]94 bool hasRedFlag;
[f41a7f9]95
[53643ca]96 // permanent attributes
97 unsigned int level;
98 unsigned int experience;
99 unsigned int honor;
100 unsigned int wins;
101 unsigned int losses;
102
[f41a7f9]103 Game* currentGame;
[2488852]104};
105
106#endif
Note: See TracBrowser for help on using the repository browser.