diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 5c84d17ab..2a80f218e 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -11944,9 +11944,10 @@ type=Sorcery [/card] [card] name=Blood Tribute +target=opponent +auto=life:-halfdownopponentlifetotal targetedplayer +auto=alternative life:opponentlifetotal controller text=Kicker - Tap an untapped Vampire you control. (You may tap a Vampire you control in addition to any other costs as you cast this spell.) -- Target opponent loses half his or her life, rounded up. If Blood Tribute was kicked, you gain life equal to the life lost this way. -auto=life:-halfdownopponentlifetotal opponent -auto=life:opponentlifetotal controller mana={4}{B}{B} other={4}{b}{b}{t(vampire|mybattlefield)} name(Pay Kicker) type=Sorcery @@ -23970,7 +23971,7 @@ type=Instant name=Crypt of Agadeem auto=tap(noevent) auto={T}:Add{B} -auto={2}{T}:foreach(creature[black]|mygraveyard) Add{B} +auto={2}{T}:name(foreach add black mana) foreach(creature[black]|mygraveyard) Add{B} text=Crypt of Agadeem enters the battlefield tapped. -- {T}: Add {B} to your mana pool. -- {2}, {T}: Add {B} to your mana pool for each black creature card in your graveyard. type=Land [/card] @@ -46940,8 +46941,8 @@ toughness=1 [/card] [card] name=Goblin Goon -auto=@each my attackers:if type(creature|opponentbattlefield)~morethan~type(creature|mybattlefield) then transforms((,cantattack)) ueot -auto=@each my blockers:if type(creature|opponentbattlefield)~morethan~type(creature|mybattlefield) then transforms((,cantblock)) ueot +auto=while(restriction{lessorequalcreatures}) cantattack +auto=while(restriction{lessorequalcreatures}) cantblock text=Goblin Goon can't attack unless you control more creatures than defending player. -- Goblin Goon can't block unless you control more creatures than attacking player. mana={3}{R} type=Creature @@ -60999,7 +61000,7 @@ toughness=2 [/card] [card] name=Keeper of the Flame -auto={R}{T}:if compare(lifetotal)~lessthan~compare(opponentlifetotal) then damage:2 opponent +auto={R}{T}:damage:2 opponent restriction{compare(lifetotal)~lessthan~compare(opponentlifetotal)} text={R}, {T}: Choose target opponent who had more life than you did as you activated this ability. Keeper of the Flame deals 2 damage to him or her. mana={R}{R} type=Creature @@ -61009,7 +61010,7 @@ toughness=2 [/card] [card] name=Keeper of the Light -auto={W}{T}:if compare(lifetotal)~lessthan~compare(opponentlifetotal) then life:3 controller +auto={W}{T}:life:3 controller restriction{compare(lifetotal)~lessthan~compare(opponentlifetotal)} text={W}, {T}: Choose target opponent who had more life than you did as you activated this ability. You gain 3 life. mana={W}{W} type=Creature @@ -67744,8 +67745,8 @@ subtype=Aura [card] name=Lurker abilities=shroud -auto=@combat(attacking) source(this):name(loses shroud) -shroud ueot -auto=@combat(blocking) source(this):name(loses shroud) -shroud ueot +auto=while(restriction{didblock}) transforms((,newability[-shroud])) ueot +auto=while(restriction{didattack}) transforms((,newability[-shroud])) ueot text=Lurker can't be the target of spells unless it attacked or blocked this turn. mana={2}{G} type=Creature @@ -73930,8 +73931,8 @@ toughness=3 [/card] [card] name=Mogg Toady -auto=@each my attackers:if type(creature|opponentbattlefield)~morethan~type(creature|mybattlefield) then transforms((,cantattack)) ueot -auto=@each my blockers:if type(creature|opponentbattlefield)~morethan~type(creature|mybattlefield) then transforms((,cantblock)) ueot +auto=while(restriction{lessorequalcreatures}) cantattack +auto=while(restriction{lessorequalcreatures}) cantblock text=Mogg Toady can't attack unless you control more creatures than defending player. -- Mogg Toady can't block unless you control more creatures than attacking player. mana={1}{R} type=Creature @@ -74460,8 +74461,8 @@ type=Sorcery [/card] [card] name=Monstrous Hound -auto=@each my attackers:if type(land|opponentbattlefield)~morethan~type(land|mybattlefield) then transforms((,cantattack)) ueot -auto=@each my blockers:if type(land|opponentbattlefield)~morethan~type(land|mybattlefield) then transforms((,cantblock)) ueot +auto=while(restriction{lessorequallands}) cantattack +auto=while(restriction{lessorequallands}) cantblock text=Monstrous Hound can't attack unless you control more lands than defending player. -- Monstrous Hound can't block unless you control more lands than attacking player. mana={3}{R} type=Creature @@ -89051,7 +89052,7 @@ type=Instant [/card] [card] name=Rackling -auto=@each opponent upkeep:damage:0 && if type(*|opponenthand)~equalto~2 then damage:1 opponent && if type(*|opponenthand)~equalto~1 then damage:2 opponent && if type(*|opponenthand)~equalto~0 then damage:3 opponent +auto=@each opponent upkeep:damage:3minustype:*:opponenthandminusend opponent text=At the beginning of each opponent's upkeep, Rackling deals X damage to that player, where X is 3 minus the number of cards in his or her hand. mana={4} type=Artifact Creature @@ -111831,8 +111832,8 @@ toughness=3 [/card] [card] name=Storm World -auto=@each opponent upkeep:damage:0 && if type(*|opponenthand)~equalto~3 then damage:1 opponent && if type(*|opponenthand)~equalto~2 then damage:2 opponent && if type(*|opponenthand)~equalto~1 then damage:3 opponent && if type(*|opponenthand)~equalto~0 then damage:4 opponent -auto=@each my upkeep:damage:0 && if type(*|myhand)~equalto~3 then damage:1 controller && if type(*|myhand)~equalto~2 then damage:2 controller && if type(*|myhand)~equalto~1 then damage:3 controller && if type(*|myhand)~equalto~0 then damage:4 controller +auto=@each opponent upkeep:damage:4minustype:*:opponenthandminusend opponent +auto=@each my upkeep:damage:damage:4minustype:*:opponenthandminusend opponent auto=@movedTo(other enchantment[world]|battlefield):sacrifice all(this) text=At the beginning of each player's upkeep, Storm World deals X damage to that player, where X is 4 minus the number of cards in his or her hand. mana={R} @@ -117417,7 +117418,7 @@ toughness=5 [card] name=The Rack auto=name(choose opponent) notatarget(opponent) deplete:0 -auto=@each targetedplayer upkeep:damage:0 && if type(*|targetedpersonshand)~equalto~2 then damage:1 targetedplayer && if type(*|targetedpersonshand)~equalto~1 then damage:2 targetedplayer && if type(*|targetedpersonshand)~equalto~0 then damage:3 targetedplayer +auto=@each targetedplayer upkeep:damage:3minustype:*:targetedpersonshandminusend targetedplayer text=As The Rack enters the battlefield, choose an opponent. -- At the beginning of the chosen player's upkeep, The Rack deals X damage to that player, where X is 3 minus the number of cards in his or her hand. mana={1} type=Artifact @@ -130601,7 +130602,7 @@ type=Sorcery [/card] [card] name=Wheel of Torture -auto=@each opponent upkeep:damage:0 && if type(*|opponenthand)~equalto~2 then damage:1 opponent && if type(*|opponenthand)~equalto~1 then damage:2 opponent && if type(*|opponenthand)~equalto~0 then damage:3 opponent +auto=@each opponent upkeep:damage:3minustype:*:opponenthandminusend opponent text=At the beginning of each opponent's upkeep, Wheel of Torture deals X damage to that player, where X is 3 minus the number of cards in his or her hand. type=Artifact mana={3} diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 453d544ff..bd11ac26c 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -781,53 +781,53 @@ private: } else if (s == "olandg") { - intValue = countManaProducedby(Constants::MTG_COLOR_GREEN, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_GREEN, target, target->controller()->opponent()); } else if (s == "olandu") { - intValue = countManaProducedby(Constants::MTG_COLOR_BLUE, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_BLUE, target, target->controller()->opponent()); } else if (s == "olandr") { - intValue = countManaProducedby(Constants::MTG_COLOR_RED, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_RED, target, target->controller()->opponent()); } else if (s == "olandb") { - intValue = countManaProducedby(Constants::MTG_COLOR_BLACK, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_BLACK, target, target->controller()->opponent()); } else if (s == "olandw") { - intValue = countManaProducedby(Constants::MTG_COLOR_WHITE, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_WHITE, target, target->controller()->opponent()); } else if (s == "olandc") { - intValue = countManaProducedby(Constants::MTG_COLOR_ARTIFACT, target->controller()->opponent()) + - countManaProducedby(Constants::MTG_COLOR_WASTE, target->controller()->opponent()); + intValue = countManaProducedby(Constants::MTG_COLOR_ARTIFACT, target, target->controller()->opponent()) + + countManaProducedby(Constants::MTG_COLOR_WASTE, target, target->controller()->opponent()); } else if (s == "plandg") { - intValue = countManaProducedby(Constants::MTG_COLOR_GREEN, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_GREEN, target, target->controller()); } else if (s == "plandu") { - intValue = countManaProducedby(Constants::MTG_COLOR_BLUE, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_BLUE, target, target->controller()); } else if (s == "plandr") { - intValue = countManaProducedby(Constants::MTG_COLOR_RED, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_RED, target, target->controller()); } else if (s == "plandb") { - intValue = countManaProducedby(Constants::MTG_COLOR_BLACK, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_BLACK, target, target->controller()); } else if (s == "plandw") { - intValue = countManaProducedby(Constants::MTG_COLOR_WHITE, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_WHITE, target, target->controller()); } else if (s == "plandc") { - intValue = countManaProducedby(Constants::MTG_COLOR_ARTIFACT, target->controller()) + - countManaProducedby(Constants::MTG_COLOR_WASTE, target->controller()); + intValue = countManaProducedby(Constants::MTG_COLOR_ARTIFACT, target, target->controller()) + + countManaProducedby(Constants::MTG_COLOR_WASTE, target, target->controller()); } else if (s == "cantargetmycre")// can target my creature { @@ -1122,7 +1122,7 @@ public: return count; } - /*int countManaProducedby(int color, MTGCardInstance * target, Player * player) + int countManaProducedby(int color, MTGCardInstance * target, Player * player) { int count = 0; for (size_t i = 0; i < target->getObserver()->mLayers->actionLayer()->manaObjects.size(); i++) @@ -1134,27 +1134,6 @@ public: count += 1; } return count; - }*/ - - int countManaProducedby(int color, Player * player) - { - int count = 0; - for (int i = 0; i < player->game->battlefield->nb_cards; i++) - { - if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceC && (color == Constants::MTG_COLOR_ARTIFACT || color == Constants::MTG_COLOR_WASTE)) - count += 1; - if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceG && color == Constants::MTG_COLOR_GREEN) - count += 1; - if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceU && color == Constants::MTG_COLOR_BLUE) - count += 1; - if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceR && color == Constants::MTG_COLOR_RED) - count += 1; - if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceB && color == Constants::MTG_COLOR_BLACK) - count += 1; - if(((MTGCardInstance *)player->game->battlefield->cards[i])->isLand() && ((MTGCardInstance *)player->game->battlefield->cards[i])->canproduceW && color == Constants::MTG_COLOR_WHITE) - count += 1; - } - return count; } WParsedInt(int value = 0) diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 8c64487de..c4af0024c 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -48,6 +48,7 @@ public: vectorparentCards; vectorchildrenCards; vectorcardsAbilities; + vectorcardsAbilitiesFilter; int setAttacker(int value); int setDefenser(MTGCardInstance * c); diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index fbc671f99..05f8f7344 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -710,26 +710,6 @@ void GameObserver::gameStateBasedEffects() card->myPair->myPair = NULL; card->myPair = NULL; } - ///set basic land mana objects canproduce - for (size_t gg = 0; gg < mLayers->actionLayer()->manaObjects.size(); gg++) - { - MTGAbility * aa = ((MTGAbility *) mLayers->actionLayer()->manaObjects[gg]); - //AManaProducer * amp = dynamic_cast (aa); - - if (dynamic_cast (aa) && (dynamic_cast (aa))->source->isLand() && (dynamic_cast (aa))->source == card) - { - if (card->hasType("forest") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_GREEN)) - card->canproduceG = 1; - if (card->hasType("island") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_BLUE)) - card->canproduceU = 1; - if (card->hasType("mountain") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_RED)) - card->canproduceR = 1; - if (card->hasType("swamp") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_BLACK)) - card->canproduceB = 1; - if (card->hasType("plains") && ((AManaProducer*)aa)->output->hasColor(Constants::MTG_COLOR_WHITE)) - card->canproduceW = 1; - } - } ///clear imprints if(isInPlay(card) && card->imprintedCards.size()) { diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index f0a4446b3..76b289166 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -581,6 +581,22 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe return 0; } + check = restriction[i].find("lessorequalcreatures"); + if(check != string::npos) + { + bool condition = (card->controller()->opponent()->inPlay()->countByType("creature") >= card->controller()->inPlay()->countByType("creature")); + if(!condition) + return 0; + } + + check = restriction[i].find("lessorequallands"); + if(check != string::npos) + { + bool condition = (card->controller()->opponent()->inPlay()->countByType("land") >= card->controller()->inPlay()->countByType("land")); + if(!condition) + return 0; + } + check = restriction[i].find("outnumbered");//opponent controls atleast 4 or more creatures than you if(check != string::npos) { @@ -596,6 +612,13 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe return 0; } + check = restriction[i].find("didblock"); + if(check != string::npos) + { + if(!card->didblocked) + return 0; + } + check = restriction[i].find("didattack"); if(check != string::npos) { @@ -687,6 +710,21 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe { restriction.push_back("type(creature|mybattlefield)~lessthan~type(creature|opponentbattlefield)"); } + check = restriction[i].find("control less lands"); + if(check != string::npos) + { + restriction.push_back("type(land|mybattlefield)~lessthan~type(land|opponentbattlefield)"); + } + check = restriction[i].find("control more creatures"); + if(check != string::npos) + { + restriction.push_back("type(creature|mybattlefield)~morethan~type(creature|opponentbattlefield)"); + } + check = restriction[i].find("control more lands"); + if(check != string::npos) + { + restriction.push_back("type(land|mybattlefield)~morethan~type(land|opponentbattlefield)"); + } check = restriction[i].find("paid("); if(check != string::npos) diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index 1f0e7962d..3357e42a8 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -141,14 +141,16 @@ void MTGCardInstance::copy(MTGCardInstance * card) int castMethodBackUP = this->castMethod; mtgid = source->getId(); MTGCardInstance * oldStored = this->storedSourceCard; - /*if(!isPhased) + //test copy filtered + cardsAbilitiesFilter.clear(); + for(unsigned int i = 0;i < card->cardsAbilities.size();i++) { - Spell * spell = NEW Spell(observer, this); - observer = card->observer; - AbilityFactory af(observer); - af.addAbilities(observer->mLayers->actionLayer()->getMaxId(), spell); - delete spell; - }*/ + MTGAbility * a = dynamic_cast(card->cardsAbilities[i]); + if(a && a->source == card) + { + cardsAbilitiesFilter.push_back(a); + } + } if(observer->players[1]->playMode == Player::MODE_TEST_SUITE) mtgid = backupid; // there must be a way to get the token id... @@ -297,6 +299,7 @@ void MTGCardInstance::initMTGCI() exileEffects = false; currentZone = NULL; cardsAbilities = vector(); + cardsAbilitiesFilter = vector(); data = this; //an MTGCardInstance point to itself for data, allows to update it without killing the underlying database item if (observer && basicAbilities[(int)Constants::CHANGELING])