PixelWars/src/dude.h
2016-06-04 19:22:29 +02:00

53 lines
1.5 KiB
C++

#ifndef DUDE_H
#define DUDE_H
#include "behavior.h"
class Dude : public Info
{
private:
Action m_action; // action containing output com data
Com m_com_data; // input com data
Coord m_pos;
char m_memory[DUDE_MEMORY_SIZE];
Map *p_map;
int m_team;
bool m_dead;
bool m_success;
bool m_receivedComData;
PixelType m_inventory;
PixelType m_under;
int m_underResCount;
public:
Dude(const Coord &_pos, Map *_map, const int &_team);
//general use functions
void update(BehaviorFunction func);
void debugOutput(char *outputString, DebugBehaviorFunction func);
const Action& getAction() { return m_action; }
int getTeam(){ return m_team; }
//life-related function
bool isAlive() { return !m_dead; }
void perish() { m_dead = true; }
//movement-related function
const Coord& getPos() { return m_pos; }
void move(Dir d);
//function inherited from Info
virtual bool getSuccess() const { return m_success; }
virtual PixelType getInventory() const { return m_inventory; }
virtual const Com* getCom() const { return m_receivedComData ? &m_com_data : nullptr; }
virtual PixelType getNear(Dir d) const;
virtual int getInfo(Dir d) const;
// setter for the variable returned by functions of Info
void setSuccess(bool success) { m_success = success; }
void setInventory(PixelType item) { m_inventory = item; }
void receiveComData(Dir dir, const char *data);
};
#endif // DUDE_H