-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogress.cpp
More file actions
158 lines (139 loc) · 4.7 KB
/
progress.cpp
File metadata and controls
158 lines (139 loc) · 4.7 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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include "progress.h"
Progress progress;
// store the state of the game to the file
void Progress::save_progress(Player player) {
ofstream fout("2113_Gp15_mini_game_saving.txt", ofstream::trunc);
fout << this->scn_num << endl;
fout << this->map_code << endl;
fout << this->event_num << endl;
fout << this->can_enterMonster << endl;
fout << this->can_enterCastle << endl;
fout << this->first_time_entering_castle << endl;
fout << this->first_time_entering_store << endl;
fout << this->talked_to_oldman << endl;
fout << this->talked_to_robert << endl;
fout << this->talked_to_cooper << endl;
fout << this->saw_key << endl;
fout << this->saw_treasure << endl;
fout << this->saw_monster << endl;
fout << this->monster_noticed << endl;
fout << this->monster_killed << endl;
fout << this->dragonnpc_killed << endl;
fout << this->dragon_killed << endl;
fout << this->get_treasure1 << endl;
fout << this->get_treasure2 << endl;
fout << this->get_treasure3 << endl;
fout << this->all_treasure << endl;
fout << this->key_take_count << endl;
fout << this->hero_know_fact << endl;
fout << this->hero_killed_all << endl;
fout << this->finish_intro << endl;
fout << this->first_time_entering_village << endl;
fout << this->first_time_entering_forest << endl;
fout << this->first_time_entering_back_village << endl;
fout << this->get_certificate << endl;
fout << this->talked_to_monster << endl;
fout << this->talked_to_dragon << endl;
fout << this->girl_know_fact << endl;
fout << this->girl_rewind << endl;
fout << player.x << endl;
fout << player.y << endl;
fout << player.color << endl;
fout << this->ending_num << endl;
//fout << << endl;
fout.close();
}
// check if the file exists, if it does, return true
bool Progress::checking_loading() {
ifstream fin("2113_Gp15_mini_game_saving.txt");
if (!fin) {
return 0;
}
fin.close();
return 1;
}
// load the state of the game from the file
void Progress::load_progress(Player &player) {
ifstream fin("2113_Gp15_mini_game_saving.txt");
fin >> this->scn_num;
fin >> this->map_code;
fin >> this->event_num;
fin >> this->can_enterMonster;
fin >> this->can_enterCastle;
fin >> this->first_time_entering_castle;
fin >> this->first_time_entering_store;
fin >> this->talked_to_oldman;
fin >> this->talked_to_robert;
fin >> this->talked_to_cooper;
fin >> this->saw_key;
fin >> this->saw_treasure;
fin >> this->saw_monster;
fin >> this->monster_noticed;
fin >> this->monster_killed;
fin >> this->dragonnpc_killed;
fin >> this->dragon_killed;
fin >> this->get_treasure1;
fin >> this->get_treasure2;
fin >> this->get_treasure3;
fin >> this->all_treasure;
fin >> this->key_take_count;
fin >> this->hero_know_fact;
fin >> this->hero_killed_all;
fin >> this->finish_intro;
fin >> this->first_time_entering_village;
fin >> this->first_time_entering_forest;
fin >> this->first_time_entering_back_village;
fin >> this->get_certificate;
fin >> this->talked_to_monster;
fin >> this->talked_to_dragon;
fin >> this->girl_know_fact;
fin >> this->girl_rewind;
fin >> player.x;
fin >> player.y;
fin >> player.color;
fin >> this->ending_num;
fin.close();
}
// reset the progress, but keep the file for player to choose another character but able to keep the progress
void Progress::reset_progress() {
this->scn_num = 0;
this->map_code = 0;
this->event_num = 0;
// for hero
this->can_enterMonster = 1;
this->can_enterCastle = 1;
this->first_time_entering_castle = 1;
this->first_time_entering_store = 1;
this->talked_to_oldman = 0;
this->talked_to_robert = 0;
this->talked_to_cooper = 0;
this->saw_key = 0;
this->saw_treasure = 0;
this->saw_monster = 0;
this->monster_noticed = 0;
this->monster_killed = 0;
this->dragonnpc_killed = 0;
this->dragon_killed = 0;
this->get_treasure1 = 0;
this->get_treasure2 = 0;
this->get_treasure3 = 0;
this->all_treasure = 0;
this->key_take_count = 0;
this->finish_intro = 0;
this->first_time_entering_village = 1;
this->first_time_entering_forest = 1;
this->first_time_entering_back_village = 1;
this->get_certificate = 0;
this->talked_to_monster = 0;
this->talked_to_dragon = 0;
}
// delete the file and reset the progress
void Progress::delete_progress() {
remove("2113_Gp15_mini_game_saving.txt");
this->reset_progress();
this->hero_know_fact = 0;
this->hero_killed_all = 0;
this->girl_know_fact = 0;
this->girl_rewind = 0;
this->ending_num = 0;
}