Daddy32 -Added one more task type, motivating the player to conserve cards in hand.
This commit is contained in:
@@ -12,7 +12,8 @@
|
|||||||
#define TASK_DELAY 'D'
|
#define TASK_DELAY 'D'
|
||||||
#define TASK_IMMORTAL 'I'
|
#define TASK_IMMORTAL 'I'
|
||||||
#define TASK_MASSIVE_BURIAL 'M'
|
#define TASK_MASSIVE_BURIAL 'M'
|
||||||
#define TASKS_ALL "WSDIM"
|
#define TASK_WISDOM 'O'
|
||||||
|
#define TASKS_ALL "WSDIMO"
|
||||||
|
|
||||||
#define ITEM_SEPARATOR "|"
|
#define ITEM_SEPARATOR "|"
|
||||||
|
|
||||||
@@ -158,6 +159,21 @@ public:
|
|||||||
virtual void randomize();
|
virtual void randomize();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TaskWisdom : public Task {
|
||||||
|
protected:
|
||||||
|
int color;
|
||||||
|
int cardCount;
|
||||||
|
virtual int computeReward();
|
||||||
|
public:
|
||||||
|
TaskWisdom(int _color = 0, int _cardCount = 0);
|
||||||
|
|
||||||
|
virtual string createDesc();
|
||||||
|
virtual string getShortDesc();
|
||||||
|
virtual bool isDone(Player * _p1, Player * _p2, GameApp * _app);
|
||||||
|
virtual void storeCustomAttribs();
|
||||||
|
virtual void restoreCustomAttribs();
|
||||||
|
virtual void randomize();
|
||||||
|
};
|
||||||
/* ------------ Task template ------------
|
/* ------------ Task template ------------
|
||||||
|
|
||||||
class TaskXX : public Task {
|
class TaskXX : public Task {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "../include/Translate.h"
|
#include "../include/Translate.h"
|
||||||
#include "../include/MTGDefinitions.h"
|
#include "../include/MTGDefinitions.h"
|
||||||
#include <JRenderer.h>
|
#include <JRenderer.h>
|
||||||
|
#include <Math.h>
|
||||||
|
|
||||||
vector<string> Task::AIDeckNames;
|
vector<string> Task::AIDeckNames;
|
||||||
|
|
||||||
@@ -215,6 +216,9 @@ Task* Task::createFromStr(string params, bool rand) {
|
|||||||
break;
|
break;
|
||||||
case TASK_MASSIVE_BURIAL:
|
case TASK_MASSIVE_BURIAL:
|
||||||
result = new TaskMassiveBurial();
|
result = new TaskMassiveBurial();
|
||||||
|
break;
|
||||||
|
case TASK_WISDOM:
|
||||||
|
result = new TaskWisdom();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
#if defined (WIN32) || defined (LINUX)
|
#if defined (WIN32) || defined (LINUX)
|
||||||
@@ -729,7 +733,7 @@ string TaskMassiveBurial::getShortDesc(){
|
|||||||
bool TaskMassiveBurial::isDone(Player * _p1, Player * _p2, GameApp * _app) {
|
bool TaskMassiveBurial::isDone(Player * _p1, Player * _p2, GameApp * _app) {
|
||||||
int countColor = 0;
|
int countColor = 0;
|
||||||
vector<MTGCardInstance *> cards = _p2->game->graveyard->cards;
|
vector<MTGCardInstance *> cards = _p2->game->graveyard->cards;
|
||||||
|
|
||||||
for (vector<MTGCardInstance *>::iterator it = cards.begin(); it!=cards.end(); it++){
|
for (vector<MTGCardInstance *>::iterator it = cards.begin(); it!=cards.end(); it++){
|
||||||
if ((*it)->hasColor(color)) {
|
if ((*it)->hasColor(color)) {
|
||||||
countColor++;
|
countColor++;
|
||||||
@@ -759,6 +763,88 @@ void TaskMassiveBurial::randomize() {
|
|||||||
bodyCount = 5 + ((Constants::MTG_COLOR_LAND == color) ? rand()%10 : rand()%20);
|
bodyCount = 5 + ((Constants::MTG_COLOR_LAND == color) ? rand()%10 : rand()%20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------ TaskWisdom ------------ */
|
||||||
|
|
||||||
|
TaskWisdom::TaskWisdom(int _color, int _cardCount) : Task(TASK_WISDOM) {
|
||||||
|
color = _color;
|
||||||
|
cardCount = _cardCount;
|
||||||
|
if ( (0 == color) || (0 == cardCount) ) {
|
||||||
|
randomize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int TaskWisdom::computeReward() {
|
||||||
|
return rand()%150 + pow(cardCount, 1.4) * 50 + (cardCount>7)*200;
|
||||||
|
}
|
||||||
|
|
||||||
|
string TaskWisdom::createDesc() {
|
||||||
|
char buffer[4096];
|
||||||
|
|
||||||
|
sprintf(buffer, _("Win a game with at least %i %s cards in your hand.").c_str(), cardCount, Constants::MTGColorStrings[color]);
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
string TaskWisdom::getShortDesc(){
|
||||||
|
char buffer[4096];
|
||||||
|
switch (color) {
|
||||||
|
case Constants::MTG_COLOR_GREEN:
|
||||||
|
sprintf(buffer, _("Animal herder (%i)").c_str(), cardCount);
|
||||||
|
break;
|
||||||
|
case Constants::MTG_COLOR_BLUE:
|
||||||
|
sprintf(buffer, _("Accumulated knowledge (%i)").c_str(), cardCount);
|
||||||
|
break;
|
||||||
|
case Constants::MTG_COLOR_RED:
|
||||||
|
sprintf(buffer, _("Retained anger (%i)").c_str(), cardCount);
|
||||||
|
break;
|
||||||
|
case Constants::MTG_COLOR_BLACK:
|
||||||
|
sprintf(buffer, _("Necropotence (%i)").c_str(), cardCount);
|
||||||
|
break;
|
||||||
|
case Constants::MTG_COLOR_WHITE:
|
||||||
|
sprintf(buffer, _("Dawn of crusade (%i)").c_str(), cardCount);
|
||||||
|
break;
|
||||||
|
case Constants::MTG_COLOR_LAND:
|
||||||
|
sprintf(buffer, _("Mana reserves (%i)").c_str(), cardCount);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TaskWisdom::isDone(Player * _p1, Player * _p2, GameApp * _app) {
|
||||||
|
GameObserver * g = GameObserver::GetInstance();
|
||||||
|
int countColor = 0;
|
||||||
|
vector<MTGCardInstance *> cards = _p1->game->hand->cards;
|
||||||
|
|
||||||
|
for (vector<MTGCardInstance *>::iterator it = cards.begin(); it!=cards.end(); it++){
|
||||||
|
if ((*it)->hasColor(color)) {
|
||||||
|
countColor++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (!_p1->isAI()) && (_p2->isAI()) && (g->gameOver != _p1) // Human player wins
|
||||||
|
&& (countColor >= cardCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskWisdom::storeCustomAttribs() {
|
||||||
|
char buff[256];
|
||||||
|
sprintf(buff, "%i", color);
|
||||||
|
persistentAttribs.push_back(buff);
|
||||||
|
|
||||||
|
sprintf(buff, "%i", cardCount);
|
||||||
|
persistentAttribs.push_back(buff);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskWisdom::restoreCustomAttribs() {
|
||||||
|
color = atoi(persistentAttribs[COMMON_ATTRIBS_COUNT].c_str());
|
||||||
|
cardCount = atoi(persistentAttribs[COMMON_ATTRIBS_COUNT+1].c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaskWisdom::randomize() {
|
||||||
|
Task::randomize();
|
||||||
|
color = rand()%(Constants::MTG_NB_COLORS - 1) + 1;
|
||||||
|
cardCount = 2 + ((Constants::MTG_COLOR_LAND == color) ? rand()%5 : rand()%11);
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------ Task template ------------
|
/* ------------ Task template ------------
|
||||||
|
|
||||||
TaskXX::TaskXX() : Task(TASK_XX) {
|
TaskXX::TaskXX() : Task(TASK_XX) {
|
||||||
|
|||||||
Reference in New Issue
Block a user