Daddy32 - Tasks

Reward tweaks, fixes, spelling fix, one minor task subtype added, removed debug options.
This commit is contained in:
d32.wagic
2009-12-14 14:52:25 +00:00
parent 346d415d7a
commit 697926fcb3
3 changed files with 25 additions and 27 deletions
+1 -22
View File
@@ -57,7 +57,6 @@ enum
SUBMENUITEM_CLASSIC, SUBMENUITEM_CLASSIC,
SUBMENUITEM_RANDOM1, SUBMENUITEM_RANDOM1,
SUBMENUITEM_RANDOM2, SUBMENUITEM_RANDOM2,
SUBMENUITEM_QUICK_TEST, //!!
}; };
@@ -569,9 +568,8 @@ JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel"); subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
#ifdef TESTSUITE #ifdef TESTSUITE
subMenuController->Add(SUBMENUITEM_TESTSUITE, "Test Suite"); subMenuController->Add(SUBMENUITEM_TESTSUITE, "Test Suite");
#endif
subMenuController->Add(SUBMENUITEM_QUICK_TEST, "Quick test"); //!!
currentState = MENU_STATE_MAJOR_SUBMENU | MENU_STATE_MINOR_NONE; currentState = MENU_STATE_MAJOR_SUBMENU | MENU_STATE_MINOR_NONE;
#endif
} }
break; break;
case MENUITEM_DECKEDITOR: case MENUITEM_DECKEDITOR:
@@ -644,30 +642,11 @@ JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING; currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
break; break;
#endif #endif
case SUBMENUITEM_QUICK_TEST: //!!
subMenuController->Close();
runTest();
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_SUBMENU_CLOSING;
break;
} }
break; break;
} }
} }
void GameStateMenu::runTest() { //!!
/*TaskList *tlist = new TaskList();
TaskWinAgainst *t1 = new TaskWinAgainst((rand()%10)+1);
TaskWinAgainst *t2 = new TaskWinAgainst((rand()%10)+1);
t1->setExpiration((rand()%5)+1);
t2->setExpiration((rand()%5)+1);
tlist->passOneDay();
tlist->addTask(t1);
tlist->addTask(t2);
tlist->save();
SAFE_DELETE(tlist);
//SAFE_DELETE(t);*/
}
ostream& GameStateMenu::toString(ostream& out) const ostream& GameStateMenu::toString(ostream& out) const
{ {
return out << "GameStateMenu ::: scroller : " << scroller return out << "GameStateMenu ::: scroller : " << scroller
+2
View File
@@ -157,6 +157,7 @@ void GameStateShop::Update(float dt)
mStage = STAGE_SHOP_SHOP; mStage = STAGE_SHOP_SHOP;
return; return;
} }
#ifdef TESTSUITE
if ((mEngine->GetButtonClick(PSP_CTRL_SQUARE)) && (taskList)) { if ((mEngine->GetButtonClick(PSP_CTRL_SQUARE)) && (taskList)) {
taskList->passOneDay(); taskList->passOneDay();
if (taskList->getTaskCount() < 6) { if (taskList->getTaskCount() < 6) {
@@ -165,6 +166,7 @@ void GameStateShop::Update(float dt)
} }
taskList->save(); taskList->save();
} }
#endif
} else { } else {
if (mEngine->GetButtonClick(PSP_CTRL_SQUARE)){ if (mEngine->GetButtonClick(PSP_CTRL_SQUARE)){
load(); load();
+22 -5
View File
@@ -224,6 +224,9 @@ Task* Task::createFromStr(string params, bool rand) {
} }
if (!result) { if (!result) {
#if defined (WIN32) || defined (LINUX)
OutputDebugString("\nTask::createFromStr: Failed to create task\n");
#endif
return NULL; return NULL;
} }
@@ -256,13 +259,16 @@ int TaskList::save(string _fileName) {
fileName = _fileName; fileName = _fileName;
} }
if (fileName == "") { if (fileName == "") {
#if defined (WIN32) || defined (LINUX)
OutputDebugString("\nTaskList::save: No filename specified\n");
#endif
return -1; return -1;
} }
std::ofstream file(fileName.c_str()); std::ofstream file(fileName.c_str());
if (file){ if (file){
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
OutputDebugString("\nsaving\n"); OutputDebugString("\nsaving tasks\n");
#endif #endif
file << "# Format: <Type>|<Expiration>|<Accepted>|<Opponent>|<Reward>|<Description>[|Additional attributes]\n"; file << "# Format: <Type>|<Expiration>|<Accepted>|<Opponent>|<Reward>|<Description>[|Additional attributes]\n";
@@ -282,6 +288,9 @@ int TaskList::load(string _fileName) {
fileName = _fileName; fileName = _fileName;
} }
if (fileName == "") { if (fileName == "") {
#if defined (WIN32) || defined (LINUX)
OutputDebugString("\nTaskList::load: No filename specified\n");
#endif
return -1; return -1;
} }
@@ -307,6 +316,9 @@ int TaskList::load(string _fileName) {
} }
file.close(); file.close();
} else { } else {
#if defined (WIN32) || defined (LINUX)
OutputDebugString("\nTaskList::load: Failed to open file\n");
#endif
return -1; return -1;
} }
@@ -380,7 +392,7 @@ void TaskList::Render() {
posY += 20; posY += 20;
if (0 == tasks.size()) { if (0 == tasks.size()) {
f->DrawString(_("These are no tasks that need to be done. Come again tomorrow.").c_str(), posX, posY); f->DrawString(_("There are no tasks that need to be done. Come again tomorrow.").c_str(), posX, posY);
posY += 20; posY += 20;
return; return;
} }
@@ -473,12 +485,15 @@ TaskSlaughter::TaskSlaughter(int _opponent, int _targetLife) : TaskWinAgainst(_o
} }
int TaskSlaughter::computeReward() { int TaskSlaughter::computeReward() {
return 2*TaskWinAgainst::computeReward() - targetLife*9; return 2*TaskWinAgainst::computeReward() - 9*targetLife*(targetLife<-50 ? 2 : 1);
} }
void TaskSlaughter::randomize() { void TaskSlaughter::randomize() {
Task::randomize(); Task::randomize();
targetLife = -15 - rand()%10; targetLife = -15 - rand()%10;
if (!(rand()%7)) {
targetLife *= 5;
}
} }
string TaskSlaughter::createDesc() { string TaskSlaughter::createDesc() {
@@ -526,7 +541,7 @@ TaskDelay::TaskDelay(int _opponent, int _turn) : TaskWinAgainst(_opponent) {
} }
int TaskDelay::computeReward() { int TaskDelay::computeReward() {
return TaskWinAgainst::computeReward() + (afterTurn ? turn*30 : (17-turn)*(17-turn)*24); return TaskWinAgainst::computeReward() + (afterTurn ? turn*30 : (17-turn)*(17-turn)*20);
} }
void TaskDelay::randomize() { void TaskDelay::randomize() {
@@ -778,8 +793,10 @@ string TaskXX::getShortDesc(){
} }
bool TaskXX::isDone(Player * _p1, Player * _p2, GameApp * _app) { bool TaskXX::isDone(Player * _p1, Player * _p2, GameApp * _app) {
GameObserver * g = GameObserver::GetInstance();
// TODO: Implement // TODO: Implement
return TRUE; return (!_p1->isAI()) && (_p2->isAI()) && (g->gameOver != _p1) // Human player wins
&& ;
} }
void TaskXX::storeCustomAttribs() { void TaskXX::storeCustomAttribs() {