-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.cpp
More file actions
117 lines (99 loc) · 2.04 KB
/
Player.cpp
File metadata and controls
117 lines (99 loc) · 2.04 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
#include"Player.h"
player::player()
{
player_id = 0;
username = nullptr;
at_level = 0;
high_score = 0;
player_rank = 0;
current_money = 0;
current_xp = 0;
}
player::player(int p_id, const char* name, int& level, int& h_score, int& pRank, int& cmoney, int& xp)
{
username = new char[20];
int i = 0;
for (; name[i] != '\0'; i++)
{
username[i] = name[i];
}
username[i] = '\0';
player_id = p_id;
at_level = level;
high_score = h_score;
player_rank = pRank;
current_money = cmoney;
current_xp = xp;
}
player::player(const player& Obj)
{
player_id = Obj.player_id;
username = new char[20];
int i = 0;
for (; Obj.username[i] != '\0'; i++)
{
username[i] = Obj.username[i];
}
username[i] = '\0';
at_level = Obj.at_level;
high_score = Obj.high_score;
player_rank = Obj.player_rank;
current_money = Obj.current_money;
current_xp = Obj.current_xp;
}
void player::updatePlayer_level()
{
int level_target = (player_rank + 1) * ((player_rank + 1) * 1000);
if (current_xp >= level_target)
{
player_rank++;
cout << "Player Rank Increase new rank is: " << player_rank << endl;
}
}
void player::updateCurrent_xp(int& xp)
{
current_xp = current_xp + xp;
}
void player::updateAt_level(int& level)
{
at_level = level;
}
void player::updateHigh_score(int& score)
{
if (score > high_score)
{
high_score = score;
}
}
void player::updateCurrent_money(int& money)
{
current_money = current_money + money;
}
void player::UpdateAttributes(int& level, int& h_score, int& pRank, int& cmoney, int& xp)
{
at_level = level;
high_score = h_score;
player_rank = pRank;
current_money = cmoney;
current_xp = xp;
}
char* player::getUserName()
{
return username;
}
int player::getCurrent_xp()
{
return current_xp;
}
int player::getCurrent_rank()
{
return player_rank;
}
int player::getPlayerRank()
{
return player_rank;
}
int player::getAt_level()
{
return at_level;
}