forked from baharkholdisabeti/cc3k-villain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGround.h
86 lines (72 loc) · 2.48 KB
/
Ground.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef GROUND_H
#define GROUND_H
#include "Info.h"
#include "Tile.h"
#include <iostream>
#include "Observer.h"
#include <memory>
class Player;
class Enemy;
class Potion;
class Gold;
class TextDisplay;
class Floor;
class Ground: public Tile, public Observer{
private:
int chamber;
std::shared_ptr<Player> player;
std::shared_ptr<Enemy> enemy;
std::shared_ptr<Ground> playerNearEnemy; // holds the tile next to the enemy that holds a player
// if there is one
std::shared_ptr<Potion> potion;
std::shared_ptr<Gold> gold;
std::vector<std::shared_ptr<Ground> > neighbours;
std::shared_ptr<TextDisplay> td;
// helper function for moveEnemy()
std::string randomMove();
// helper functions for move
std::string onAttack( Ground & tile );
std::string usePotion( Ground & tile );
std::string collectGold( Ground & tile );
std::string passageWayHelper(Ground & tile);
std::string doorHelper(Ground & tile);
std::string enemyHelper(Ground & tile);
std::string playerHelper(Ground & tile);
std::string move(Ground & tile); // move contents of tile to this Tile // make it error if it doesn't work
public:
Ground(int r, int c, State t, int room = -1, std::shared_ptr<Enemy> e = nullptr , std::shared_ptr<Potion> po = nullptr, std::shared_ptr<Gold> g = nullptr, std::shared_ptr<Player> pl = nullptr);
virtual ~Ground();
void empty(); // empty this tile of contents, set type to 1
bool getIsStair();
// Subject overrides
void attach(std::shared_ptr<Ground> g);
void attach(std::shared_ptr<TextDisplay> td);
Info getInfo() const;
// Observer overrides
virtual void notify() override;
virtual void notify( std::shared_ptr<Ground> whoNotified ) override;
// setters
void setPlayer( std::shared_ptr<Player> p);
void setEnemy( std::shared_ptr<Enemy> e);
void setPotion( std::shared_ptr<Potion> p);
void setGold( std::shared_ptr<Gold> g);
void setDragonGold( std::shared_ptr<Gold> g);
void setStair( bool b );
//getter
std::vector<std::shared_ptr<Ground> > getNeighbours();
// moves enemy if there's an enemy on this tile
// called in Floor
std::string movePlayer(int dir) override;
std::string moveEnemy() override;
// getters
std::shared_ptr<Enemy> getEnemy(){
return enemy;
}
std::shared_ptr<Gold> getGold(){
return gold;
}
int getChamber(){ return chamber;}
virtual void clear() override;
friend class Floor;
};
#endif