-
Notifications
You must be signed in to change notification settings - Fork 28
/
Originator.cpp
40 lines (32 loc) · 893 Bytes
/
Originator.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
//
// Created by Pavel Akhtyamov on 2019-04-23.
//
#include <iostream>
#include "Originator.h"
#include "PasswordMemento.h"
namespace memento {
void Originator::IncreaseLevel() {
++state_.level;
state_.progress += DEFAULT_PROGRESS_LEVEL;
}
void Originator::StartNewGame() {
state_ = {
.place = "Start",
.level = 1,
.progress = 0,
.save_name = ""
};
}
Memento * Originator::Save(std::string save_name) {
return new PasswordMemento(state_);
}
void Originator::Restore(Memento *memento) {
state_ = memento->GetState();
}
void Originator::ShowCurrentProgress() {
std::cout << "Place: " << state_.place << std::endl;
std::cout << "Level: " << state_.level << std::endl;
// https://stackoverflow.com/questions/19562103/uint8-t-cant-be-printed-with-cout
std::cout << "Progress: " << unsigned(state_.progress) << std::endl;
}
} // namespace memento