|
| 1 | +#ifndef MINER_H |
| 2 | +#define MINER_H |
| 3 | +//------------------------------------------------------------------------ |
| 4 | +// |
| 5 | +// Name: Miner.h |
| 6 | +// |
| 7 | +// Desc: A class defining a goldminer. |
| 8 | +// |
| 9 | +// Author: Mat Buckland 2002 ([email protected]) |
| 10 | +// |
| 11 | +//------------------------------------------------------------------------ |
| 12 | +#include <string> |
| 13 | +#include <cassert> |
| 14 | + |
| 15 | +#include "BaseGameEntity.h" |
| 16 | +#include "Locations.h" |
| 17 | + |
| 18 | + |
| 19 | +class State; |
| 20 | + |
| 21 | +//the amount of gold a miner must have before he feels comfortable |
| 22 | +const int ComfortLevel = 5; |
| 23 | +//the amount of nuggets a miner can carry |
| 24 | +const int MaxNuggets = 3; |
| 25 | +//above this value a miner is thirsty |
| 26 | +const int ThirstLevel = 5; |
| 27 | +//above this value a miner is sleepy |
| 28 | +const int TirednessThreshold = 5; |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +class Miner : public BaseGameEntity |
| 33 | +{ |
| 34 | +private: |
| 35 | + |
| 36 | + State* m_pCurrentState; |
| 37 | + |
| 38 | + location_type m_Location; |
| 39 | + |
| 40 | + //how many nuggets the miner has in his pockets |
| 41 | + int m_iGoldCarried; |
| 42 | + |
| 43 | + int m_iMoneyInBank; |
| 44 | + |
| 45 | + //the higher the value, the thirstier the miner |
| 46 | + int m_iThirst; |
| 47 | + |
| 48 | + //the higher the value, the more tired the miner |
| 49 | + int m_iFatigue; |
| 50 | + |
| 51 | +public: |
| 52 | + |
| 53 | + Miner(int id); |
| 54 | + |
| 55 | + //this must be implemented |
| 56 | + void Update(); |
| 57 | + |
| 58 | + //this method changes the current state to the new state. It first |
| 59 | + //calls the Exit() method of the current state, then assigns the |
| 60 | + //new state to m_pCurrentState and finally calls the Entry() |
| 61 | + //method of the new state. |
| 62 | + void ChangeState(State* new_state); |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + location_type Location()const{return m_Location;} |
| 67 | + void ChangeLocation(const location_type loc){m_Location=loc;} |
| 68 | + |
| 69 | + int GoldCarried()const{return m_iGoldCarried;} |
| 70 | + void SetGoldCarried(const int val){m_iGoldCarried = val;} |
| 71 | + void AddToGoldCarried(const int val); |
| 72 | + bool PocketsFull()const{return m_iGoldCarried >= MaxNuggets;} |
| 73 | + |
| 74 | + bool Fatigued()const; |
| 75 | + void DecreaseFatigue(){m_iFatigue -= 1;} |
| 76 | + void IncreaseFatigue(){m_iFatigue += 1;} |
| 77 | + |
| 78 | + int Wealth()const{return m_iMoneyInBank;} |
| 79 | + void SetWealth(const int val){m_iMoneyInBank = val;} |
| 80 | + void AddToWealth(const int val); |
| 81 | + |
| 82 | + bool Thirsty()const; |
| 83 | + void BuyAndDrinkAWhiskey(){m_iThirst = 0; m_iMoneyInBank-=2;} |
| 84 | + |
| 85 | +}; |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | +#endif |
0 commit comments