Daddy32: Tasks Mode
Gives the user the opportunity to earn some credits for performing various tasks.
Known bugs removed, tested stability-wise, not so much game-wise.
Lots of to-dos and ideas still remaining, better balance between task difficulty and their rewards needed - please comment.
Usage:
Enter shop, open menu, select 'See available tasks'.
All tasks in the list are active, until they expire ('Days left'; day passes after each duel (won, lost or quited)).
You can finish any of the tasks and get bonus. For particular task, the bonus gets a bit smaller every day (until expiration).
This commit is contained in:
@@ -41,7 +41,9 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
|
||||
showMsg = (WRand() % 5);
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
if (!g->turn) return;
|
||||
PlayerData * playerdata = NEW PlayerData(app->collection);
|
||||
if (!p1->isAI() && p2->isAI() && p1!= g->gameOver){
|
||||
gameLength = time(0) - g->startedAt;
|
||||
value = 400;
|
||||
if (app->gameType != GAME_TYPE_CLASSIC) value = 200;
|
||||
int difficulty = options[Options::DIFFICULTY].number;
|
||||
@@ -79,6 +81,20 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
|
||||
}
|
||||
|
||||
GameOptionAward * goa = NULL;
|
||||
// <Tasks handling>
|
||||
vector<Task*> finishedTasks;
|
||||
playerdata->taskList->getDoneTasks(_p1, _p2, _app, &finishedTasks);
|
||||
|
||||
char buffer[512];
|
||||
|
||||
for (vector<Task*>::iterator it = finishedTasks.begin(); it!=finishedTasks.end(); it++) {
|
||||
sprintf(buffer, _("Task: %s").c_str(), (*it)->getShortDesc().c_str());
|
||||
CreditBonus * b = NEW CreditBonus((*it)->getReward(), buffer);
|
||||
bonus.push_back(b);
|
||||
playerdata->taskList->removeTask(*it);
|
||||
}
|
||||
// </Tasks handling>
|
||||
|
||||
if (unlocked == -1){
|
||||
unlocked = isDifficultyUnlocked();
|
||||
if (unlocked){
|
||||
@@ -132,13 +148,19 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
|
||||
|
||||
|
||||
|
||||
PlayerData * playerdata = NEW PlayerData(app->collection);
|
||||
playerdata->credits+= value;
|
||||
playerdata->credits += value;
|
||||
playerdata->taskList->passOneDay();
|
||||
if (playerdata->taskList->getTaskCount() < 6) {
|
||||
playerdata->taskList->addRandomTask();
|
||||
playerdata->taskList->addRandomTask();
|
||||
}
|
||||
playerdata->save();
|
||||
SAFE_DELETE(playerdata);
|
||||
|
||||
}else{
|
||||
unlocked = 0;
|
||||
unlocked = 0;
|
||||
playerdata->taskList->passOneDay();
|
||||
playerdata->taskList->save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,6 +204,7 @@ void Credits::Render(){
|
||||
}
|
||||
|
||||
float y = 130;
|
||||
|
||||
if (showMsg == 1) y = 50;
|
||||
vector<CreditBonus *>:: iterator it;
|
||||
for ( it=bonus.begin() ; it < bonus.end(); ++it){
|
||||
@@ -191,6 +214,17 @@ void Credits::Render(){
|
||||
f2->DrawString(buffer, 10, y);
|
||||
y+=15;
|
||||
|
||||
//!!
|
||||
if (g->gameOver != p1) {
|
||||
sprintf(buffer, _("Game length: %i seconds").c_str(), this->gameLength);
|
||||
f->DrawString(buffer, 10, y);
|
||||
y += 10;
|
||||
sprintf(buffer, _("Credits per minute: %i").c_str(), (int)(60*value/this->gameLength));
|
||||
f->DrawString(buffer, 10, y);
|
||||
y += 10;
|
||||
showMsg = 0;
|
||||
}
|
||||
|
||||
if (showMsg == 1){
|
||||
f2->DrawString(_("Please support this project!").c_str() ,10,y+15);
|
||||
f->DrawString(_("Wagic is free, open source, and developed on the little free time I have").c_str() ,10,y+30);
|
||||
|
||||
Reference in New Issue
Block a user