66 lines
1.1 KiB
C++
66 lines
1.1 KiB
C++
|
#include "GameAccount.h"
|
|||
|
#include "Level.h"
|
|||
|
#include <Windows.h>
|
|||
|
#include <time.h>
|
|||
|
#define random(x) (rand()%x)
|
|||
|
|
|||
|
GameAccount::GameAccount(){
|
|||
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>100<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PRIMARY\n");
|
|||
|
score = 100;
|
|||
|
name = "none";
|
|||
|
setLevel(new Primary(this));
|
|||
|
}
|
|||
|
|
|||
|
GameAccount::GameAccount(string iName){
|
|||
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>100<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PRIMARY\n");
|
|||
|
score = 100;
|
|||
|
name = iName;
|
|||
|
setLevel(new Primary(this));
|
|||
|
}
|
|||
|
|
|||
|
void GameAccount::setLevel(Level* iLevel){
|
|||
|
this->level = iLevel;
|
|||
|
}
|
|||
|
|
|||
|
string GameAccount::getName(){
|
|||
|
return name;
|
|||
|
}
|
|||
|
|
|||
|
void GameAccount::playCard(){
|
|||
|
this->level->playCard();
|
|||
|
|
|||
|
Sleep(100);
|
|||
|
srand((int)time(0));
|
|||
|
int res = random(2);
|
|||
|
if (res % 2 == 0){
|
|||
|
this->win();
|
|||
|
}
|
|||
|
else{
|
|||
|
this->lose();
|
|||
|
}
|
|||
|
|
|||
|
this->level->upgradeLevel();
|
|||
|
}
|
|||
|
|
|||
|
void GameAccount::win(){
|
|||
|
if (this->getScore() < 200){
|
|||
|
setScore(getScore() + 50);
|
|||
|
}
|
|||
|
else{
|
|||
|
setScore(getScore() + 100);
|
|||
|
}
|
|||
|
printf("\n\tʤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>»<EFBFBD><EFBFBD><EFBFBD>Ϊ %d\n", score);
|
|||
|
}
|
|||
|
|
|||
|
void GameAccount::lose(){
|
|||
|
setScore(getScore() + 30);
|
|||
|
printf("\n\t<EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>»<EFBFBD><EFBFBD><EFBFBD>Ϊ %d\n", score);
|
|||
|
}
|
|||
|
|
|||
|
int GameAccount::getScore(){
|
|||
|
return this->score;
|
|||
|
}
|
|||
|
|
|||
|
void GameAccount::setScore(int iScore){
|
|||
|
this->score = iScore;
|
|||
|
}
|