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

Last change on this file since 1d0ede1 was 5b1e31e, checked in by dportnoy <dmp1488@…>, 11 years ago

Fix some bugs related to player attack and movement

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