From 29ac95362d6111ce028889db63be6831cf9a55ef Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 31 Aug 2015 19:06:51 +0800 Subject: [PATCH 1/6] multicolor correction not multicolored is single colored or monocolored not colorless... colorless has no color... --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 2 +- projects/mtg/src/CardGui.cpp | 1 + projects/mtg/src/TargetChooser.cpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 753b0fd67..261522a02 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -35578,7 +35578,7 @@ toughness=3 [/card] [card] name=Furnace Celebration -auto=@sacrificed(other *|mybattlefield):pay({2}) damage:2 target(creature,player) +auto=@sacrificed(other *|mybattlefield):ability$!name(pay 2 for damage) pay[[{2}]] name(pay 2 for damage) damage:2 target(creature,player)!$ controller mana={1}{R}{R} type=Enchantment text=Whenever you sacrifice another permanent, you may pay {2}. If you do, Furnace Celebration deals 2 damage to target creature or player. diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index 0b5b9d44a..681e1b559 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -1242,6 +1242,7 @@ bool CardGui::FilterCard(MTGCard * _card,string filter) if (minus) { cd.setisMultiColored(-1); + cd.SetExclusionColor(0);//not multicolored is monocolored not colorless, use iscolorless attribute } else { diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index e69f29702..8724235c3 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -503,6 +503,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta if (minus) { cd->setisMultiColored(-1); + cd->SetExclusionColor(0);//not multicolored is monocolored not colorless, use iscolorless attribute } else { From b2b54b7c5b9674e32faf4057646b14aa9e3bb692 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 31 Aug 2015 22:03:41 +0800 Subject: [PATCH 2/6] attribute -multicolor will return single colored cards use iscolorless to find colorless... :) --- projects/mtg/src/CardGui.cpp | 2 ++ projects/mtg/src/TargetChooser.cpp | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index 681e1b559..de5efb003 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -1243,6 +1243,8 @@ bool CardGui::FilterCard(MTGCard * _card,string filter) { cd.setisMultiColored(-1); cd.SetExclusionColor(0);//not multicolored is monocolored not colorless, use iscolorless attribute + cd.SetExclusionColor(6);//restriction... green, red, blue, black or white colored only + cd.mode = CardDescriptor::CD_OR; } else { diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index 8724235c3..fd12b317a 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -503,7 +503,9 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta if (minus) { cd->setisMultiColored(-1); - cd->SetExclusionColor(0);//not multicolored is monocolored not colorless, use iscolorless attribute + cd->SetExclusionColor(0);//not multicolored is monocolored not colorless, use iscolorless attribute + cd->SetExclusionColor(6);//restriction... green, red, blue, black or white colored only + cd->mode = CardDescriptor::CD_OR; } else { From 9fb460c17698ecc78ffe7b88eebe304661b484ac Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 3 Sep 2015 07:01:45 +0800 Subject: [PATCH 3/6] life state check on trigger life state check when players gain or lose life bugs\exquisite_blood_i953.txt will stop looping as long as the conditions are met on the check --- projects/mtg/src/MTGAbility.cpp | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index d38ce37b0..a6c81c6eb 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -4961,6 +4961,44 @@ int TriggeredAbility::receiveEvent(WEvent * e) resolve(); return 1; } + if(dynamic_cast(e)) + { + //check life state... basic prevention for infinite loop of bugs\exquisite_blood_i953.txt test.. + //exquisite blood and sanguine bond in play will stop looping as long as the triggered player + //met this condition... taken from gamestatebasecheck... + WEventLife * lifecheck = dynamic_cast(e); + if ((lifecheck->player->life <= 0)||(lifecheck->player->poisonCount >= 10)) + { + int cantlosers = 0; + MTGGameZone * z = lifecheck->player->game->inPlay; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j) + { + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::CANTLOSE) || (c->has(Constants::CANTLIFELOSE) && lifecheck->player->poisonCount < 10)) + { + cantlosers++; + } + } + MTGGameZone * k = lifecheck->player->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) + { + //lifecheck->player->getObserver()->setLoser(lifecheck->player); + return 0; + } + } + fireAbility(); + return 1; + } WEventZoneChange * stackCheck = dynamic_cast(e); if(stackCheck && (stackCheck->to == game->currentPlayer->game->stack||stackCheck->to == game->currentPlayer->opponent()->game->stack)) { From fd02e9ab2241b0425161d57786272b02aeb67ab8 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 3 Sep 2015 20:07:31 +0800 Subject: [PATCH 4/6] Rename projects/mtg/bin/Res/test/bugs/exquisite_blood_i953.txt to projects/mtg/bin/Res/test/exquisite_blood_i953.txt --- projects/mtg/bin/Res/test/{bugs => }/exquisite_blood_i953.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename projects/mtg/bin/Res/test/{bugs => }/exquisite_blood_i953.txt (100%) diff --git a/projects/mtg/bin/Res/test/bugs/exquisite_blood_i953.txt b/projects/mtg/bin/Res/test/exquisite_blood_i953.txt similarity index 100% rename from projects/mtg/bin/Res/test/bugs/exquisite_blood_i953.txt rename to projects/mtg/bin/Res/test/exquisite_blood_i953.txt From 886eaa400264992d43d086fa23b46dd1ee108afb Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 3 Sep 2015 20:10:19 +0800 Subject: [PATCH 5/6] Update _tests.txt --- projects/mtg/bin/Res/test/_tests.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index 8898324a5..598704221 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -313,6 +313,7 @@ executioners_swing.txt executioners_swing2.txt executioners_swing3.txt explore.txt +exquisite_blood_i953.txt Faceless_Butcher.txt fading.txt fangren_pathcutter.txt From 42d0480f77ce1883a8b5aa8a40102a08298b9ea7 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Thu, 3 Sep 2015 20:11:47 +0800 Subject: [PATCH 6/6] refactored lifestate check --- projects/mtg/include/Player.h | 1 + projects/mtg/src/GameObserver.cpp | 29 +---------------- projects/mtg/src/MTGAbility.cpp | 52 +++++++++++-------------------- projects/mtg/src/Player.cpp | 34 ++++++++++++++++++++ 4 files changed, 55 insertions(+), 61 deletions(-) diff --git a/projects/mtg/include/Player.h b/projects/mtg/include/Player.h index 66d66acd1..589e8766a 100644 --- a/projects/mtg/include/Player.h +++ b/projects/mtg/include/Player.h @@ -69,6 +69,7 @@ public: ManaPool * getManaPool(); void takeMulligan(); void serumMulligan(); + bool DeadLifeState(); ManaCost * doesntEmpty; ManaCost * poolDoesntEmpty; void cleanupPhase(); diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 2f77f9d36..b82960119 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -727,34 +727,7 @@ void GameObserver::gameStateBasedEffects() /////////////////////////////////////////////////////////// //life checks/poison checks also checks cant win or lose.// /////////////////////////////////////////////////////////// - if (players[i]->life <= 0 || players[i]->poisonCount >= 10) - { - int cantlosers = 0; - MTGGameZone * z = players[i]->game->inPlay; - int nbcards = z->nb_cards; - for (int j = 0; j < nbcards; ++j) - { - MTGCardInstance * c = z->cards[j]; - if (c->has(Constants::CANTLOSE) || (c->has(Constants::CANTLIFELOSE) && players[i]->poisonCount < 10)) - { - 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) - { - setLoser(players[i]); - } - } + players[i]->DeadLifeState();//refactored } ////////////////////////////////////////////////////// //-------------card based states effects------------// diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index a6c81c6eb..e8d6c34ed 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -4963,39 +4963,25 @@ int TriggeredAbility::receiveEvent(WEvent * e) } if(dynamic_cast(e)) { - //check life state... basic prevention for infinite loop of bugs\exquisite_blood_i953.txt test.. - //exquisite blood and sanguine bond in play will stop looping as long as the triggered player - //met this condition... taken from gamestatebasecheck... - WEventLife * lifecheck = dynamic_cast(e); - if ((lifecheck->player->life <= 0)||(lifecheck->player->poisonCount >= 10)) - { - int cantlosers = 0; - MTGGameZone * z = lifecheck->player->game->inPlay; - int nbcards = z->nb_cards; - for (int j = 0; j < nbcards; ++j) - { - MTGCardInstance * c = z->cards[j]; - if (c->has(Constants::CANTLOSE) || (c->has(Constants::CANTLIFELOSE) && lifecheck->player->poisonCount < 10)) - { - cantlosers++; - } - } - MTGGameZone * k = lifecheck->player->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) - { - //lifecheck->player->getObserver()->setLoser(lifecheck->player); - return 0; - } - } + //check life state on life triger + WEventLife * lifecheck = dynamic_cast(e); + if (lifecheck->player->DeadLifeState()) + { + return 0; + } + fireAbility(); + return 1; + } + if(dynamic_cast(e)) + { + //check life state on damage trigger + WEventDamage * lifecheck = dynamic_cast(e); + if (lifecheck->damage->target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER) + { + Player * triggerPlayer = (Player *) lifecheck->damage->target; + if(triggerPlayer->DeadLifeState()) + return 0; + } fireAbility(); return 1; } diff --git a/projects/mtg/src/Player.cpp b/projects/mtg/src/Player.cpp index 6cbb98dbd..2003d0b83 100644 --- a/projects/mtg/src/Player.cpp +++ b/projects/mtg/src/Player.cpp @@ -233,6 +233,40 @@ void Player::serumMulligan() //Draw hand no penalty } +bool Player::DeadLifeState() +{ + if ((life <= 0)||(poisonCount >= 10)) + { + int cantlosers = 0; + MTGGameZone * z = game->inPlay; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j) + { + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::CANTLOSE) || (c->has(Constants::CANTLIFELOSE) && poisonCount < 10)) + { + cantlosers++; + } + } + MTGGameZone * k = 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) + { + getObserver()->setLoser(this); + return true; + } + } + return false; +} + //Cleanup phase at the end of a turn void Player::cleanupPhase() {