-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtravelstate.cpp
More file actions
46 lines (34 loc) · 1.11 KB
/
travelstate.cpp
File metadata and controls
46 lines (34 loc) · 1.11 KB
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
#include "travelstate.h"
TravelState::TravelState(WorldLocation* l, int d) : loc(l), dir(d) {
// TODO: validate the type and direction
// TODO: set options based on roadlocation
combatProbability = 20;
direction = Util::getDirName(dir);
hasCrossroad = false;
newDirection = "";
//choices[CONTINUE_OPTION] = "Keep walking " + direction + ".";
choices[SIT_OPTION] = "Sit and rest.";
loc->addOptions(choices);
}
void TravelState::printOptions(){
wprintw(Display::text_win, "You are walking %s\n", direction.c_str());
wprintw(Display::text_win, "\n");
for(auto i = choices.begin(); i!=choices.end(); i++){
wprintw(Display::text_win, "%c. %s\n", i->first, i->second.c_str());
}
refresh();
}
TravelState::~TravelState(){};
void TravelState::handleInput(int choice, std::stack<GameState*>& states, Player& p, World& w){
GameState* nextState = nullptr;
switch (choice){
case SIT_OPTION:
nextState = new IdleState();
states.push(nextState);
break;
default:
// See if the location can handle it
loc->handleInput(choice, states, p, w);
break;
};
}