-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathidlestate.cpp
More file actions
39 lines (34 loc) · 955 Bytes
/
idlestate.cpp
File metadata and controls
39 lines (34 loc) · 955 Bytes
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
#include "idlestate.h"
IdleState::IdleState(){
choices[CONTINUE_OPTION] = "Keep sitting.";
choices[LEAVE_OPTION] = "Get up and keep walking.";
}
void IdleState::printOptions(){
wprintw(Display::text_win, "You are sitting at the side of the road\n");
for(auto i=choices.begin(); i!=choices.end(); i++){
wprintw(Display::text_win, "%c. %s\n", i->first, i->second.c_str());
}
}
IdleState::~IdleState(){}
void IdleState::handleInput(int choice, std::stack<GameState*>& states, Player& p, World& w){
GameState* next = nullptr;
GameState* old = nullptr;
switch(choice){
case CONTINUE_OPTION:
old = states.top();
states.pop();
delete old;
p.heal(5);
wprintw(Display::text_win, "You recover 5 hp...\n");
next = new IdleState();
states.push(next);
break;
case LEAVE_OPTION:
old = states.top();
states.pop();
delete old;
break;
default:
break;
}
}