forked from FengJungle/DesignPattern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLevel.cpp
More file actions
158 lines (123 loc) · 2.91 KB
/
Level.cpp
File metadata and controls
158 lines (123 loc) · 2.91 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 "Level.h"
/*********** Level *************/
Level::Level(){
}
void Level::playCard(){
this->play();
this->doubleScore();
this->changeCards();
this->peekCards();
}
void Level::play(){
printf("\t使用基本技能,");
}
void Level::setGameAccount(GameAccount* iGameAccount){
this->gameAccount = iGameAccount;
}
GameAccount* Level::getGameAccount(){
return gameAccount;
}
/*********** Primary *************/
Primary::Primary(){
}
Primary::Primary(GameAccount* iGameAccount){
this->setGameAccount(iGameAccount);
}
Primary::Primary(Level* level){
getGameAccount()->setLevel(level);
}
void Primary::doubleScore(){
return;
}
void Primary::changeCards(){
return;
}
void Primary::peekCards(){
return;
}
void Primary::upgradeLevel(){
if (this->getGameAccount()->getScore() > 150){
this->getGameAccount()->setLevel(new Secondary(this));
printf("\t升级! 级别:SECONDARY\n\n");
}
else{
printf("\n");
}
}
/*********** Secondary *************/
Secondary::Secondary(){
}
Secondary::Secondary(Level* level){
this->setGameAccount(level->getGameAccount());
getGameAccount()->setLevel(level);
}
void Secondary::doubleScore(){
printf("使用胜利双倍积分技能");
}
void Secondary::changeCards(){
return;
}
void Secondary::peekCards(){
return;
}
void Secondary::upgradeLevel(){
if (this->getGameAccount()->getScore() < 150){
this->getGameAccount()->setLevel(new Primary(this));
printf("\t降级! 级别:PRIMARY\n\n");
}
else if (this->getGameAccount()->getScore() > 200){
this->getGameAccount()->setLevel(new Professional(this));
printf("\t升级! 级别:PROFESSIONAL\n\n");
}
}
/*********** Professional *************/
Professional::Professional(){
}
Professional::Professional(Level* level){
this->setGameAccount(level->getGameAccount());
getGameAccount()->setLevel(level);
}
void Professional::doubleScore(){
printf("使用胜利双倍积分技能,");
}
void Professional::changeCards(){
printf("使用换牌技能");
}
void Professional::peekCards(){
return;
}
void Professional::upgradeLevel(){
if (this->getGameAccount()->getScore() < 200){
this->getGameAccount()->setLevel(new Secondary(this));
printf("\t降级! 级别:SECONDARY\n\n");
}
else if (this->getGameAccount()->getScore() > 250){
this->getGameAccount()->setLevel(new Final(this));
printf("\t升级! 级别:FINAL\n\n");
}
}
/*********** Final *************/
Final::Final(){
}
Final::Final(Level* level){
this->setGameAccount(level->getGameAccount());
getGameAccount()->setLevel(level);
}
void Final::doubleScore(){
printf("使用胜利双倍积分技能,");
}
void Final::changeCards(){
printf("使用换牌技能,");
}
void Final::peekCards(){
printf("使用偷看卡牌技能");
}
void Final::upgradeLevel(){
if (this->getGameAccount()->getScore() < 250){
this->getGameAccount()->setLevel(new Professional(this));
printf("\t降级! 级别:PROFESSIONAL\n\n");
}
else{
printf("\t%s 已经是最高级\n\n", this->getGameAccount()->getName().c_str());
}
}