added support for no max hand size, added nonstatic lifetotal checks, added a check for how many equips a card has, added a fix for a typo in affinityswamp.

This commit is contained in:
omegablast2002@yahoo.com
2010-09-17 17:37:18 +00:00
parent 341c48eb61
commit 65673ca0b2
13 changed files with 159 additions and 13 deletions

View File

@@ -55,6 +55,8 @@ public:
intValue = computeX(spell,card); intValue = computeX(spell,card);
}else if (s == "xx" || s == "XX"){ }else if (s == "xx" || s == "XX"){
intValue = computeXX(spell,card); intValue = computeXX(spell,card);
}else if (s == "equips"){
intValue = target->equipment;
}else if (s == "manacost"){ }else if (s == "manacost"){
intValue = target->getManaCost()->getConvertedCost(); intValue = target->getManaCost()->getConvertedCost();
}else if (s == "lifetotal"){ }else if (s == "lifetotal"){
@@ -792,10 +794,19 @@ class AAWinGame:public ActivatedAbilityTP{
int cantlosers = 0; int cantlosers = 0;
MTGGameZone * z = ((Player *)_target)->opponent()->game->inPlay; MTGGameZone * z = ((Player *)_target)->opponent()->game->inPlay;
int nbcards = z->nb_cards; int nbcards = z->nb_cards;
for (int i = 0; i < nbcards; ++i){
for (int i = 0; i < nbcards; i++){
MTGCardInstance * c = z->cards[i]; MTGCardInstance * c = z->cards[i];
if (c->has(Constants::CANTLOSE)){ if (c->has(Constants::CANTLOSE)){
cantlosers++; cantlosers++;
}
}
MTGGameZone * k = ((Player *)_target)->game->inPlay;
int onbcards = k->nb_cards;
for (int m = 0; m < onbcards; ++m){
MTGCardInstance * e = k->cards[m];
if (e->has(Constants::CANTWIN)){
cantlosers++;
} }
} }
if(cantlosers < 1){ if(cantlosers < 1){
@@ -1190,7 +1201,7 @@ class ABasicAbilityAuraModifierUntilEOT: public ActivatedAbility{
} }
}; };
//equipment
class AEquip:public TargetAbility{ class AEquip:public TargetAbility{
public: public:
vector<MTGAbility *> currentAbilities; vector<MTGAbility *> currentAbilities;
@@ -1199,6 +1210,7 @@ public:
} }
int unequip(){ int unequip(){
if(source->target){source->target->equipment -= 1;}
source->target = NULL; source->target = NULL;
for (size_t i = 0; i < currentAbilities.size(); ++i){ for (size_t i = 0; i < currentAbilities.size(); ++i){
MTGAbility * a = currentAbilities[i]; MTGAbility * a = currentAbilities[i];
@@ -1215,6 +1227,7 @@ public:
int equip(MTGCardInstance * equipped){ int equip(MTGCardInstance * equipped){
source->target = equipped; source->target = equipped;
source->target->equipment += 1;
AbilityFactory af; AbilityFactory af;
af.getAbilities(&currentAbilities,NULL,source); af.getAbilities(&currentAbilities,NULL,source);
for (size_t i = 0; i < currentAbilities.size(); ++i){ for (size_t i = 0; i < currentAbilities.size(); ++i){
@@ -1233,7 +1246,6 @@ public:
if (mTarget == source) return 0; if (mTarget == source) return 0;
unequip(); unequip();
equip(mTarget); equip(mTarget);
return 1; return 1;
} }

View File

@@ -49,6 +49,7 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
int flashedback; int flashedback;
int paymenttype; int paymenttype;
int frozen; int frozen;
int equipment;
int reduxamount; int reduxamount;
int regenerateTokens; int regenerateTokens;
int isToken; int isToken;

View File

@@ -131,9 +131,10 @@ class Constants
AFFINITYMOUNTAIN = 73, AFFINITYMOUNTAIN = 73,
AFFINITYSWAMP = 74, AFFINITYSWAMP = 74,
AFFINITYGREENCREATURES = 75, AFFINITYGREENCREATURES = 75,
CANTWIN = 76,
NOMAXHAND = 77,
NB_BASIC_ABILITIES = 78,
NB_BASIC_ABILITIES = 76,
RARITY_S = 'S', //Special Rarity RARITY_S = 'S', //Special Rarity

View File

@@ -22,6 +22,7 @@ class Player: public Damageable{
JTexture * mAvatarTex; JTexture * mAvatarTex;
JQuad * mAvatar; JQuad * mAvatar;
int canPutLandsIntoPlay; int canPutLandsIntoPlay;
int nomaxhandsize;
int castedspellsthisturn; int castedspellsthisturn;
int onlyonecast; int onlyonecast;
int castcount; int castcount;

View File

@@ -41,6 +41,27 @@ class ThisCounterAny:public ThisDescriptor{
ThisCounterAny(int nb); ThisCounterAny(int nb);
}; };
class ThisControllerlife:public ThisDescriptor{
public:
virtual int match(MTGCardInstance * card);
ThisControllerlife(int life);
};
class ThisOpponentlife:public ThisDescriptor{
public:
virtual int match(MTGCardInstance * card);
ThisOpponentlife(int olife);
};
class ThisEquip:public ThisDescriptor{
public:
virtual int match(MTGCardInstance * card);
ThisEquip(int equipment);
};
class ThisPower:public ThisDescriptor{ class ThisPower:public ThisDescriptor{
public: public:
virtual int match(MTGCardInstance * card); virtual int match(MTGCardInstance * card);

View File

@@ -137,7 +137,7 @@ void GameObserver::nextGamePhase(){
if (currentGamePhase == Constants::MTG_PHASE_AFTER_EOT){ if (currentGamePhase == Constants::MTG_PHASE_AFTER_EOT){
//Auto Hand cleaning, in case the player didn't do it himself //Auto Hand cleaning, in case the player didn't do it himself
while(currentPlayer->game->hand->nb_cards > 7) while(currentPlayer->game->hand->nb_cards > 7 && currentPlayer->nomaxhandsize < 1)
currentPlayer->game->putInGraveyard(currentPlayer->game->hand->cards[0]); currentPlayer->game->putInGraveyard(currentPlayer->game->hand->cards[0]);
mLayers->actionLayer()->Update(0); mLayers->actionLayer()->Update(0);
return nextGamePhase(); return nextGamePhase();
@@ -358,6 +358,14 @@ void GameObserver::stateEffects()
MTGCardInstance * c = z->cards[j]; MTGCardInstance * c = z->cards[j];
if (c->has(Constants::CANTLOSE) || c->has(Constants::CANTLIFELOSE)){ if (c->has(Constants::CANTLOSE) || c->has(Constants::CANTLIFELOSE)){
cantlosers++; cantlosers++;
}
}
MTGGameZone * k = players[i]->opponent()->game->inPlay;
int onbcards = k->nb_cards;
for (int m = 0; m < onbcards; ++m){
MTGCardInstance * e = k->cards[m];
if (e->has(Constants::CANTWIN)){
cantlosers++;
} }
} }
if(cantlosers < 1){ if(cantlosers < 1){
@@ -549,7 +557,7 @@ void GameObserver::cardClick (MTGCardInstance * card, Targetable * object){
if (!card) return; if (!card) return;
//Current player's hand //Current player's hand
if (currentPlayer->game->hand->hasCard(card) && currentGamePhase == Constants::MTG_PHASE_CLEANUP && currentPlayer->game->hand->nb_cards > 7){ if (currentPlayer->game->hand->hasCard(card) && currentGamePhase == Constants::MTG_PHASE_CLEANUP && currentPlayer->game->hand->nb_cards > 7 && currentPlayer->nomaxhandsize < 1){
currentPlayer->game->putInGraveyard(card); currentPlayer->game->putInGraveyard(card);
}else if (reaction){ }else if (reaction){
if (reaction == 1){ if (reaction == 1){

View File

@@ -186,7 +186,8 @@ void GameStateOptions::Render()
"", "",
"Dev Team: Abrasax, almosthumane, Daddy32, Dr.Solomat" "Dev Team: Abrasax, almosthumane, Daddy32, Dr.Solomat"
"J, Jeck, Leungclj, linshier, Salmelo, Superhiro", "J, Jeck, Leungclj, linshier, Salmelo, Superhiro",
"Psyringe, Wololo, Yeshua, Zethfox", "Psyringe, Wololo, Yeshua, Zethfox,",
"Special thanks to Mnguyen(mico) for the awesome menu improvements,",
"", "",
"Music by Celestial Aeon Project, http://www.jamendo.com", "Music by Celestial Aeon Project, http://www.jamendo.com",
"", "",

View File

@@ -99,6 +99,7 @@ void MTGCardInstance::initMTGCI(){
tapped = 0; tapped = 0;
untapping = 0; untapping = 0;
frozen = 0; frozen = 0;
equipment = NULL;
boughtback = 0; boughtback = 0;
flashedback = 0; flashedback = 0;
paymenttype = 0; paymenttype = 0;

View File

@@ -84,6 +84,8 @@ const char* Constants::MTGBasicAbilities[] = {
"affinitymountains", "affinitymountains",
"affinityswamps", "affinityswamps",
"affinitygreencreatures", "affinitygreencreatures",
"cantwin",
"nomaxhand",
}; };

View File

@@ -87,7 +87,15 @@ void MTGPlayerCards::drawFromLibrary(){
if (c->has(Constants::CANTLOSE) || c->has(Constants::CANTMILLLOSE)){ if (c->has(Constants::CANTLOSE) || c->has(Constants::CANTMILLLOSE)){
cantlosers++; cantlosers++;
} }
} }
MTGGameZone * k = library->owner->opponent()->game->inPlay;
int onbcards = k->nb_cards;
for (int m = 0; m < onbcards; ++m){
MTGCardInstance * e = k->cards[m];
if (e->has(Constants::CANTWIN)){
cantlosers++;
}
}
if(cantlosers < 1){ if(cantlosers < 1){
GameObserver::GetInstance()->gameOver = library->owner;} GameObserver::GetInstance()->gameOver = library->owner;}
return; return;

View File

@@ -1091,7 +1091,7 @@ HUDDisplay::~HUDDisplay(){
WEventZoneChange * e = (WEventZoneChange *) event; WEventZoneChange * e = (WEventZoneChange *) event;
MTGCardInstance * card = e->card->previous; MTGCardInstance * card = e->card->previous;
if(card){ if(card){
if (card->basicAbilities[Constants::BOTHCANTCAST] || card->basicAbilities[Constants::BOTHNOCREATURE] || card->basicAbilities[Constants::CANTCAST] || card->basicAbilities[Constants::CANTCASTCREATURE] || card->basicAbilities[Constants::CANTCASTTWO] || card->basicAbilities[Constants::ONLYONEBOTH]){ if (card->basicAbilities[Constants::BOTHCANTCAST] || card->basicAbilities[Constants::BOTHNOCREATURE] || card->basicAbilities[Constants::CANTCAST] || card->basicAbilities[Constants::CANTCASTCREATURE] || card->basicAbilities[Constants::CANTCASTTWO] || card->basicAbilities[Constants::ONLYONEBOTH] || card->basicAbilities[Constants::NOMAXHAND] ){
int ok = 0; int ok = 0;
@@ -1109,6 +1109,21 @@ HUDDisplay::~HUDDisplay(){
MTGGameZone * y = card->controller()->opponent()->game->inPlay; MTGGameZone * y = card->controller()->opponent()->game->inPlay;
int nbcards = z->nb_cards; int nbcards = z->nb_cards;
int onbcards = y->nb_cards; int onbcards = y->nb_cards;
//handsize modifier
//check my battlefield and opponents
for (int j = 0; j < nbcards; ++j){
MTGCardInstance * c = z->cards[j];
if (c->has(Constants::NOMAXHAND)){
card->controller()->nomaxhandsize = 1;
}
} //any on other side?
for (int j = 0; j < onbcards; ++j){
MTGCardInstance * c = y->cards[j];
if (c->has(Constants::NOMAXHAND)){
card->controller()->opponent()->nomaxhandsize = 1;
}
}
//--------------both cant cast-----------------
//check my battlefield and opponents //check my battlefield and opponents
for (int j = 0; j < nbcards; ++j){ for (int j = 0; j < nbcards; ++j){
MTGCardInstance * c = z->cards[j]; MTGCardInstance * c = z->cards[j];
@@ -1235,7 +1250,7 @@ HUDDisplay::~HUDDisplay(){
if (event->type == WEvent::CHANGE_ZONE){ if (event->type == WEvent::CHANGE_ZONE){
WEventZoneChange * e = (WEventZoneChange *) event; WEventZoneChange * e = (WEventZoneChange *) event;
MTGCardInstance * card = e->card->previous; MTGCardInstance * card = e->card->previous;
if (card && (card->basicAbilities[Constants::BOTHCANTCAST] || card->basicAbilities[Constants::BOTHNOCREATURE] || card->basicAbilities[Constants::CANTCAST] || card->basicAbilities[Constants::CANTCASTCREATURE] || card->basicAbilities[Constants::CANTCASTTWO] || card->basicAbilities[Constants::ONLYONEBOTH])){ if (card && (card->basicAbilities[Constants::BOTHCANTCAST] || card->basicAbilities[Constants::BOTHNOCREATURE] || card->basicAbilities[Constants::CANTCAST] || card->basicAbilities[Constants::CANTCASTCREATURE] || card->basicAbilities[Constants::CANTCASTTWO] || card->basicAbilities[Constants::ONLYONEBOTH]|| card->basicAbilities[Constants::NOMAXHAND])){
int ok = 0; int ok = 0;
for (int i = 0; i < 2 ; i++){ for (int i = 0; i < 2 ; i++){
Player * p = game->players[i]; Player * p = game->players[i];
@@ -1247,6 +1262,8 @@ HUDDisplay::~HUDDisplay(){
if (e->to == p->game->graveyard || e->to == p->game->hand || e->to == p->game->library || e->to == p->game->exile){//if it goes ANYWHERE but inplay. if (e->to == p->game->graveyard || e->to == p->game->hand || e->to == p->game->library || e->to == p->game->exile){//if it goes ANYWHERE but inplay.
//check happens---------- //check happens----------
//reset restrictions //reset restrictions
p->nomaxhandsize = 0;
p->opponent()->nomaxhandsize = 0;
p->onlyonecast = 0; p->onlyonecast = 0;
p->opponent()->onlyonecast = 0; p->opponent()->onlyonecast = 0;
p->castrestrictedspell = 0;//0 means no restrictions apply. p->castrestrictedspell = 0;//0 means no restrictions apply.
@@ -1258,6 +1275,21 @@ HUDDisplay::~HUDDisplay(){
MTGGameZone * y = card->controller()->opponent()->game->inPlay; MTGGameZone * y = card->controller()->opponent()->game->inPlay;
int nbcards = z->nb_cards; int nbcards = z->nb_cards;
int onbcards = y->nb_cards; int onbcards = y->nb_cards;
//no max hand size
for (int j = 0; j < nbcards; ++j){
MTGCardInstance * c = z->cards[j];
if (c->has(Constants::NOMAXHAND)){
p->nomaxhandsize = 1;
}
} //any on other side?
for (int j = 0; j < onbcards; ++j){
MTGCardInstance * c = y->cards[j];
if (c->has(Constants::NOMAXHAND)){
p->opponent()->nomaxhandsize = 1;
}
}
//check my battlefield and opponents //check my battlefield and opponents
for (int j = 0; j < nbcards; ++j){ for (int j = 0; j < nbcards; ++j){
MTGCardInstance * c = z->cards[j]; MTGCardInstance * c = z->cards[j];
@@ -1705,7 +1737,7 @@ HUDDisplay::~HUDDisplay(){
for (int j = 0; j < nbcards; ++j){ for (int j = 0; j < nbcards; ++j){
MTGCardInstance * c = z->cards[j]; MTGCardInstance * c = z->cards[j];
if (c->has(Constants::AFFINITYSWAMP)){ if (c->has(Constants::AFFINITYSWAMP)){
if(c->reduxamount > 0){ c->reduxamount -+ 1;} if(c->reduxamount > 0){ c->reduxamount -= 1;}
else{ else{
c->getManaCost()->add(0,1); c->getManaCost()->add(0,1);
} }

View File

@@ -12,6 +12,7 @@ Player::Player(MTGPlayerCards * deck, string file, string fileSmall) : Damageabl
game->setOwner(this); game->setOwner(this);
manaPool = NEW ManaPool(this); manaPool = NEW ManaPool(this);
canPutLandsIntoPlay = 1; canPutLandsIntoPlay = 1;
nomaxhandsize = 0;
castedspellsthisturn = 0; castedspellsthisturn = 0;
castrestrictedspell = 0; castrestrictedspell = 0;
castrestrictedcreature = 0; castrestrictedcreature = 0;

View File

@@ -126,7 +126,40 @@ ThisDescriptor * ThisDescriptorFactory::createThisDescriptor(string s){
return NULL; return NULL;
} }
//power //equips
found = s.find("equip");
if (found != string::npos) {
ThisEquip * td = NEW ThisEquip(criterion);
if (td) {
td->comparisonMode = mode;
return td;
}
return NULL;
}
//controller life
found = s.find("opponentlife");
if (found != string::npos) {
ThisOpponentlife * td = NEW ThisOpponentlife(criterion);
if (td) {
td->comparisonMode = mode;
return td;
}
return NULL;
}
//controller life
found = s.find("controllerlife");
if (found != string::npos) {
ThisControllerlife * td = NEW ThisControllerlife(criterion);
if (td) {
td->comparisonMode = mode;
return td;
}
return NULL;
}
//power
found = s.find("power"); found = s.find("power");
if (found != string::npos) { if (found != string::npos) {
ThisPower * td = NEW ThisPower(criterion); ThisPower * td = NEW ThisPower(criterion);
@@ -198,6 +231,22 @@ ThisCounter::~ThisCounter() {
SAFE_DELETE(counter); SAFE_DELETE(counter);
} }
ThisOpponentlife::ThisOpponentlife(int olife){
comparisonCriterion = olife;
}
int ThisOpponentlife::match(MTGCardInstance * card){
return matchValue(card->controller()->opponent()->life);
}
ThisControllerlife::ThisControllerlife(int life){
comparisonCriterion = life;
}
int ThisControllerlife::match(MTGCardInstance * card){
return matchValue(card->controller()->life);
}
ThisPower::ThisPower(int power){ ThisPower::ThisPower(int power){
comparisonCriterion = power; comparisonCriterion = power;
} }
@@ -206,6 +255,14 @@ int ThisPower::match(MTGCardInstance * card){
return matchValue(card->power); return matchValue(card->power);
} }
ThisEquip::ThisEquip(int equipment){
comparisonCriterion = equipment;
}
int ThisEquip::match(MTGCardInstance * card){
return matchValue(card->equipment);
}
ThisToughness::ThisToughness(int toughness){ ThisToughness::ThisToughness(int toughness){
comparisonCriterion = toughness; comparisonCriterion = toughness;
} }