/
Room.cpp
86 lines (84 loc) · 2.01 KB
/
Room.cpp
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
////////////////////
/// C++ Object-oriented Programming
/// Adventure Game 6
/// Reference answer
/// anssi.grohn@pkamk.fi
////////////////////
#include "MoveCommand.h"
#include "Room.h"
#include "Game.h"
#include "IRenderer.h"
#include <cstdlib>
////////////////////////////////////////////////////////////////////////////////
Room::Room()
{
rooms[0] = NULL;
rooms[1] = NULL;
rooms[2] = NULL;
rooms[3] = NULL;
}
////////////////////////////////////////////////////////////////////////////////
Room::~Room()
{
}
////////////////////////////////////////////////////////////////////////////////
void
Room::SetNextRoom( Direction d, Room * pRoom )
{
rooms[d] = pRoom;
}
////////////////////////////////////////////////////////////////////////////////
Room *
Room::GetNextRoom( Direction d )
{
return rooms[d];
}
////////////////////////////////////////////////////////////////////////////////
void
Room::SetDescription( const std::string & desc )
{
description = desc;
}
////////////////////////////////////////////////////////////////////////////////
const std::string &
Room::GetDescription() const
{
return description;
}
/////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Room *
Room::OnMoveCommand( MoveCommand *pCommand )
{
return GetNextRoom( pCommand->GetDirection() );
}
////////////////////////////////////////////////////////////////////////////////
void
Room::OnAttack( AttackCommand *pCommand )
{
// NO enemy , NO attack possibility
GetGame()->GetRenderer()->Render("Attack what? There's nothing there!\n");
}
////////////////////////////////////////////////////////////////////////////////
void
Room::SetGame( Game * pGame )
{
game = pGame;
}
////////////////////////////////////////////////////////////////////////////////
Game *
Room::GetGame() const
{
return game;
}
////////////////////////////////////////////////////////////////////////////////
void
Room::SetID(int ID)
{
Id = ID;
}
int
Room::GetID()
{
return Id;
}