-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer_information.h
35 lines (32 loc) · 947 Bytes
/
player_information.h
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
#pragma once
struct PlayerInformation{
int score;
int chain_number;
int max_chain_number;
int obstacle_number_taken;
PlayerInformation() {
this->score = 0;
this->chain_number = 0;
this->max_chain_number = 0;
this->obstacle_number_taken = 0;
}
std::string Serialize() {
std::ostringstream data;
data << score << ' ';
data << chain_number << ' ';
data << max_chain_number << ' ';
data << obstacle_number_taken;
return data.str();
}
void Deserialize(std::string data) {
std::string buf;
std::stringstream ss(data);
std::vector<std::string> tokens;
while (ss >> buf)
tokens.push_back(buf);
score = std::stoi(tokens[0]);
chain_number = std::stoi(tokens[1]);
max_chain_number = std::stoi(tokens[2]);
obstacle_number_taken = std::stoi(tokens[3]);
}
};