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
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 {
[2488852]23public:
[07c73fa]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
[01d0d00]37 Player();
38 Player(const Player& p);
[59061f6]39 Player(string name, string password);
[01d0d00]40
[8e540f4]41 ~Player();
[2488852]42
[01d0d00]43 void setId(int id);
[59061f6]44 void setAddr(sockaddr_in addr);
[46fa35a]45 void setClass(PlayerClass c);
46
47 void serialize(char* buffer);
48 void deserialize(char* buffer);
[59061f6]49
[e6c26b8]50 bool updateTarget(map<unsigned int, Player*>& mapPlayers);
[227baaa]51 bool move(WorldMap *map);
[6054f1e]52 void takeDamage(int damage);
[60017fc]53
[ff2133a]54 void takeFlag(int flag, WorldMap* map);
55 void dropFlag(int flag, WorldMap* map);
[d436ac4]56
[01d0d00]57 int id;
[8e540f4]58 string name;
[59061f6]59 string password;
[8e540f4]60 sockaddr_in addr;
[60017fc]61 FLOAT_POSITION pos;
62 POSITION target;
[8f85180]63 unsigned long long timeLastUpdated;
[8dad966]64 unsigned long long timeAttackStarted;
[c76134b]65 unsigned long long timeDied;
[11d21ee]66 bool isChasing;
[8dad966]67 bool isAttacking;
68 int targetPlayer;
[c76134b]69 bool isDead;
[d436ac4]70
[07c73fa]71 int playerClass;
72 int maxHealth;
73 int health;
74 int attackType;
75 int damage;
[11d21ee]76 int range;
[8dad966]77 unsigned long long attackCooldown;
[d436ac4]78 int team; // 0 is blue, 1 is red
[74b8e79]79 bool hasBlueFlag;
[d436ac4]80 bool hasRedFlag;
[f41a7f9]81
82 Game* currentGame;
[2488852]83};
84
85#endif
Note: See TracBrowser for help on using the repository browser.