diff --git a/projects/mtg/include/AIPlayer.h b/projects/mtg/include/AIPlayer.h index e86c47fad..93401813c 100644 --- a/projects/mtg/include/AIPlayer.h +++ b/projects/mtg/include/AIPlayer.h @@ -24,6 +24,7 @@ protected: static int currentId; public: MTGAbility * ability; + NestedAbility * nability; Player * player; int id; MTGCardInstance * click; diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 6420d2f76..e7304b9c4 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -2327,7 +2327,7 @@ public: int canBeInList(MTGCardInstance * card){ int size = 0; size = (int)cards.size(); - if(includeSelf && maxi && card == source && size < maxi) + if(includeSelf && maxi && card == source && size > maxi) { removed(card); } @@ -2368,7 +2368,7 @@ public: int _added(Damageable * d){ int size =(int)cards.size(); if (maxi && size < maxi) return 0; - if (maxi && size >= maxi) return removeAbilityFromGame(); + if (maxi && size > maxi) return removeAbilityFromGame(); if (maxi) return 0; if (size <= mini) return 0; return addAbilityToGame(); @@ -2385,7 +2385,7 @@ public: int removed(MTGCardInstance * card){ size_t size = cards.size(); - if (maxi && (int)size < maxi) return addAbilityToGame(); + if (maxi && (int)size <= maxi) return addAbilityToGame(); if (mini && (int)size > mini) return 0; if (mini && (int)size <= mini) return removeAbilityFromGame(); if (!mini && !maxi && size !=0) return 0; @@ -2502,7 +2502,9 @@ public: tc->targetter = NULL; includeSelf = _includeSelf; ability->target = _target; - } + aType = MTGAbility::FOREACH; + naType = ability->aType; + } int canBeInList(MTGCardInstance * card){ if ( (includeSelf || card!=source) && tc->canTarget(card)) return 1; @@ -2638,6 +2640,7 @@ public: ability->source = source; ability->target = target; SAFE_DELETE(tc); + aType = FOREACH; } int removeFromGame(){ @@ -3494,6 +3497,7 @@ public: listtypes; listcolors; WParsedPT * wppt; + string menu; ABecomes(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, WParsedPT * wppt, string sabilities):MTGAbility(id,source,target),wppt(wppt){ //TODO this is a copy/past of other code that's all around the place, everything should be in a dedicated parser class; @@ -3512,6 +3516,7 @@ public: } string s = stypes; + menu = stypes; while (s.size()){ size_t found = s.find(" "); if (found != string::npos){ @@ -3561,6 +3566,12 @@ public: return 1; } + const char * getMenuText(){ + string s = menu; + sprintf(menuText, "Becomes %s",s.c_str()); + return menuText; + } + ABecomes * clone() const{ ABecomes * a = NEW ABecomes(*this); a->wppt = NEW WParsedPT(*(a->wppt)); diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index 40739b6ae..3b6139559 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -56,6 +56,7 @@ class MTGAbility: public ActionElement{ Targetable * target; int aType; + int naType; MTGCardInstance * source; MTGAbility(int id, MTGCardInstance * card); MTGAbility(int id, MTGCardInstance * _source, Targetable * _target); @@ -93,6 +94,7 @@ class MTGAbility: public ActionElement{ STANDARD_PREVENT = 13, STANDARD_EQUIP = 14, STANDARD_LEVELUP = 15, + FOREACH = 16, }; diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index 899d41fd4..2a8edbb3a 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -121,7 +121,7 @@ ManaCost * AIPlayer::getPotentialMana(MTGCardInstance * target){ used[card] = true; } } - } + } return result; } @@ -163,8 +163,7 @@ int AIAction::getEfficiency(){ } if (!((AIPlayer *)p)->canHandleCost(ability)) return 0; - - switch (a->aType){ + switch (a->aType){ case MTGAbility::DAMAGER: { AADamager * aad = (AADamager *) a; @@ -258,7 +257,7 @@ int AIAction::getEfficiency(){ efficiency = 0; break; default: - if (target){ + if (target){ AbilityFactory af; int suggestion = af.abilityEfficiency(a, p, MODE_ABILITY); if ((suggestion == BAKA_EFFECT_BAD && p==target->controller()) ||(suggestion == BAKA_EFFECT_GOOD && p!=target->controller())){ @@ -317,7 +316,6 @@ int AIPlayer::selectAbility(){ MTGAbility * a = ((MTGAbility *)g->mLayers->actionLayer()->mObjects[i]); //Skip mana abilities for performance if (dynamic_cast(a)) continue; - //Make sure we can use the ability for (int j=0; j < game->inPlay->nb_cards; j++){ MTGCardInstance * card = game->inPlay->cards[j]; diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 7df350cbe..a2bc34247 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1663,6 +1663,7 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, Targ if (dynamic_cast(a)) return BAKA_EFFECT_GOOD; if (dynamic_cast(a)) return BAKA_EFFECT_BAD; if (dynamic_cast(a)) return BAKA_EFFECT_GOOD; + if (dynamic_cast(a)) return BAKA_EFFECT_GOOD; if (AInstantPowerToughnessModifierUntilEOT * abi = dynamic_cast(a)) return (abi->wppt->power.getValue()>=0 && abi->wppt->toughness.getValue()>=0) ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD; if (APowerToughnessModifier * abi = dynamic_cast(a)) return (abi->wppt->power.getValue()>=0 && abi->wppt->toughness.getValue()>=0) ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD; if (APowerToughnessModifierUntilEndOfTurn * abi = dynamic_cast(a)) return abilityEfficiency(abi->ability, p, mode,tc);