From eea240d7f2994444d10e29ddf0f0fe43ab009b6f Mon Sep 17 00:00:00 2001 From: zethfoxster Date: Wed, 27 Jul 2016 20:03:25 -0400 Subject: [PATCH] changing some of the logic to the previous fixes, we want to avoid using code that looks for specific card names. currently we have kamiflip as the only defined flip type as it is treated differently from the others. but we have room for more if needed now doublefaced=kamiflip sets the flip type of a card to the kamiflip style cards. since this is defined on cardprimitive level now, we might be able to do something different from the flipping animation. who knows. commented out the forcing token triggers, it bypass targetchooser check. still working on a fix for this coming soon. --- projects/mtg/include/AllAbilities.h | 4 ++-- projects/mtg/include/CardPrimitive.h | 3 +++ projects/mtg/include/GameObserver.h | 1 + projects/mtg/include/MTGDefinitions.h | 3 ++- projects/mtg/src/AllAbilities.cpp | 18 ++++++++++++++---- projects/mtg/src/CardPrimitive.cpp | 13 +++++++++++++ projects/mtg/src/ExtraCost.cpp | 6 ++---- projects/mtg/src/GameObserver.cpp | 14 ++++++++++---- projects/mtg/src/MTGAbility.cpp | 21 +-------------------- projects/mtg/src/MTGDeck.cpp | 12 ++++++++++-- projects/mtg/src/MTGDefinitions.cpp | 3 ++- projects/mtg/src/MTGRules.cpp | 6 ++++-- 12 files changed, 64 insertions(+), 40 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 0b7af43fa..d2f325e5d 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -1370,8 +1370,8 @@ public: { WEventCardSacrifice * e = dynamic_cast (event); if (!e) return 0; - if (e->istoken) - return 1; + //if (e->istoken) + // return 1; MTGCardInstance * check = e->cardAfter; MTGGameZone * oldZone = e->cardAfter->currentZone; check->currentZone = check->previousZone; diff --git a/projects/mtg/include/CardPrimitive.h b/projects/mtg/include/CardPrimitive.h index 8f6041baf..afcfb9604 100644 --- a/projects/mtg/include/CardPrimitive.h +++ b/projects/mtg/include/CardPrimitive.h @@ -69,6 +69,9 @@ public: int toughness; int suspendedTime; int dredgeAmount; + string doubleFaced; + void setdoubleFaced(const string& value); + const string& getdoubleFaced() const; vectortypes; CardPrimitive(); diff --git a/projects/mtg/include/GameObserver.h b/projects/mtg/include/GameObserver.h index 6d451a392..c8a3b8550 100644 --- a/projects/mtg/include/GameObserver.h +++ b/projects/mtg/include/GameObserver.h @@ -125,6 +125,7 @@ class GameObserver{ void enchantmentStatus(); void Affinity(); bool AffinityNeedsUpdate; + bool legendNeedUpdate; void addObserver(MTGAbility * observer); void checkLegendary(MTGCardInstance * card); map cards; diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index c7db25290..cd3137f39 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -256,7 +256,8 @@ class Constants SHACKLER = 134, FLYERSONLY = 135,//can attack only if it has flying TEMPFLASHBACK = 136, - NB_BASIC_ABILITIES = 137, + NOLEGENDRULE =137, + NB_BASIC_ABILITIES = 138, RARITY_S = 'S', //Special Rarity RARITY_M = 'M', //Mythics diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 63de1d89f..f7b052513 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -416,6 +416,12 @@ bool MTGRevealingCards::CheckUserInput(JButton key) { if (this->source->controller() != game->isInterrupting) game->mLayers->stackLayer()->cancelInterruptOffer(ActionStack::DONT_INTERRUPT, false); + //if (game->currentActionPlayer->isAI() && key != JGE_BTN_OK) + //{ + // key = JGE_BTN_NEXT; + // game->Update(0); + //} + } if (JGE_BTN_SEC == key || JGE_BTN_PREV == key || JGE_BTN_NEXT == key || JGE_BTN_MENU == key)//android back button { @@ -432,6 +438,7 @@ bool MTGRevealingCards::CheckUserInput(JButton key) { abilityFirst->removeFromGame(); game->mLayers->stackLayer()->Remove(abilityFirst); + abilityFirst = NULL; } game->Update(0); //remove it from the game, update, and remove it from stack if needed. @@ -723,6 +730,11 @@ bool MTGScryCards::CheckUserInput(JButton key) //in the future we will need a way to find out if the human is pressing the keys and which player. if (this->source->controller() != game->isInterrupting) game->mLayers->stackLayer()->cancelInterruptOffer(ActionStack::DONT_INTERRUPT, false); + //if (game->currentActionPlayer->isAI() && key != JGE_BTN_OK) + //{ + // key = JGE_BTN_NEXT; + // game->Update(0); + //} } if (JGE_BTN_SEC == key || JGE_BTN_PREV == key || JGE_BTN_NEXT == key || JGE_BTN_MENU == key) { @@ -2718,13 +2730,11 @@ int AASacrificeCard::resolve() Player * p = _target->controller(); MTGCardInstance * beforeCard = _target; WEvent * e; - if(!_target->isToken) - e = NEW WEventCardSacrifice(beforeCard,_target); - else - e = NEW WEventCardSacrifice(beforeCard,_target,true); p->game->putInGraveyard(_target); while(_target->next) _target = _target->next; + bool cardIsToken = _target->isToken ? true : false; + e = NEW WEventCardSacrifice(beforeCard, _target, cardIsToken); game->receiveEvent(e); if(andAbility) { diff --git a/projects/mtg/src/CardPrimitive.cpp b/projects/mtg/src/CardPrimitive.cpp index bddc43ed4..30c5c2e5f 100644 --- a/projects/mtg/src/CardPrimitive.cpp +++ b/projects/mtg/src/CardPrimitive.cpp @@ -57,6 +57,7 @@ CardPrimitive::CardPrimitive(CardPrimitive * source) formattedText = source->formattedText; setName(source->name); + setdoubleFaced(source->doubleFaced); power = source->power; toughness = source->toughness; restrictions = source->restrictions ? source->restrictions->clone() : NULL; @@ -319,6 +320,18 @@ void CardPrimitive::addMagicText(string value, string key) magicTexts[key].append(value); } +void CardPrimitive::setdoubleFaced(const string& value) +{ + std::transform(doubleFaced.begin(), doubleFaced.end(), doubleFaced.begin(), ::tolower); + doubleFaced = value; +} + +const string& CardPrimitive::getdoubleFaced() const +{ + return doubleFaced; +} + + void CardPrimitive::setName(const string& value) { name = value; diff --git a/projects/mtg/src/ExtraCost.cpp b/projects/mtg/src/ExtraCost.cpp index 1e2f54874..d1344768b 100644 --- a/projects/mtg/src/ExtraCost.cpp +++ b/projects/mtg/src/ExtraCost.cpp @@ -1289,12 +1289,10 @@ int SacrificeCost::doPay() MTGCardInstance * beforeCard = target; source->storedCard = target->createSnapShot(); WEvent * e; - if(!target->isToken) - e = NEW WEventCardSacrifice(beforeCard,target); - else - e = NEW WEventCardSacrifice(beforeCard,target,true); target->controller()->game->putInGraveyard(target); GameObserver * game = target->owner->getObserver(); + bool cardIsToken = target->isToken ? true : false; + e = NEW WEventCardSacrifice(beforeCard, target, cardIsToken); game->receiveEvent(e); target = NULL; if (tc) diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 9892a118d..b1d451d77 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -54,6 +54,7 @@ void GameObserver::cleanup() gameTurn.clear(); OpenedDisplay = NULL; AffinityNeedsUpdate = false; + legendNeedUpdate = false; } GameObserver::~GameObserver() @@ -898,11 +899,15 @@ void GameObserver::gameStateBasedEffects() //------------------------------ p->nomaxhandsize = (z->hasAbility(Constants::NOMAXHAND)); //legendary - for (int cl = 0; cl < nbcards; cl++) + if (legendNeedUpdate) { - MTGCardInstance * c = z->cards[cl]; - if(!c->isPhased && c->hasType(Subtypes::TYPE_LEGENDARY) && !c->has(Constants::NOLEGEND)) - checkLegendary(c); + for (int cl = 0; cl < nbcards; cl++) + { + MTGCardInstance * c = z->cards[cl]; + if (!c->isPhased && c->hasType(Subtypes::TYPE_LEGENDARY) && !c->has(Constants::NOLEGEND)) + checkLegendary(c); + } + legendNeedUpdate = false; } ///////////////////////////////////////////////// //handle end of turn effects while we're at it.// @@ -1126,6 +1131,7 @@ void GameObserver::Affinity() } } ///we handle trisnisphere seperately because its a desaster. + if(card->getManaCost())//make sure we check, abiliy$!/token dont have a mancost object. if (card->has(Constants::TRINISPHERE)) { for (int jj = card->getManaCost()->getConvertedCost(); jj < 3; jj++) diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index ad0510f6e..99fa8f123 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -3334,26 +3334,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG /*vectorFlipStats = split(splitFlipStat[1],'%');*/ flipStats = splitFlipStat[1]; } - if(flipStats == "Tomoya the Revealer" || - flipStats == "Tok-Tok, Volcano Born" || - flipStats == "Tobita, Master of Winds" || - flipStats == "Stabwhisker the Odious" || - flipStats == "Shidako, Broodmistress" || - flipStats == "Sasaya's Essence" || - flipStats == "Rune-Tail's Essence" || - flipStats == "Nighteyes the Desecrator" || - flipStats == "Kuon's Essence" || - flipStats == "Kenzo the Hardhearted" || - flipStats == "Kaiso, Memory of Loyalty" || - flipStats == "Ichiga, Who Topples Oaks" || - flipStats == "Homura's Essence" || - flipStats == "Scarmaker" || - flipStats == "Goka the Unjust" || - flipStats == "Erayo's Essence" || - flipStats == "Jaraku the Interloper" || - flipStats == "Azamuki, Treachery Incarnate" || - flipStats == "Autumn-Tail, Kitsune Sage" || - flipStats == "Dokai, Weaver of Life" ) + if(card->getdoubleFaced() == "kamiflip") {//old flip cards kamigawa MTGAbility * a = NEW AAFlip(observer, id, card, target,flipStats,true); return a; diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index 86fb175a2..45d71c69d 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -140,8 +140,16 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi } } break; - case 'd'://dredge - if (!primitive) primitive = NEW CardPrimitive(); + case 'd'://double faced card /dredge + if (key == "doublefaced") + { + if (!primitive) primitive = NEW CardPrimitive(); + { + primitive->setdoubleFaced(val); + break; + } + } + else if (!primitive) primitive = NEW CardPrimitive(); { string value = val; std::transform(value.begin(), value.end(), value.begin(), ::tolower); diff --git a/projects/mtg/src/MTGDefinitions.cpp b/projects/mtg/src/MTGDefinitions.cpp index 2d73f2708..9a3e29f1d 100644 --- a/projects/mtg/src/MTGDefinitions.cpp +++ b/projects/mtg/src/MTGDefinitions.cpp @@ -167,7 +167,8 @@ const char* Constants::MTGBasicAbilities[] = { "overload", "shackler", "flyersonly", - "tempflashback" + "tempflashback", + "legendruleremove" }; map Constants::MTGBasicAbilitiesMap; diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 4a210d44a..04cc78dbf 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -3187,7 +3187,7 @@ int MTGLegendRule::canBeInList(MTGCardInstance * card) return 0; if (card->hasType(Subtypes::TYPE_LEGENDARY) && card->controller()->game->inPlay->hasCard(card)) { - if(card->has(Constants::NOLEGEND)||card->controller()->opponent()->inPlay()->hasName("Mirror Gallery")||card->controller()->inPlay()->hasName("Mirror Gallery")) + if(card->has(Constants::NOLEGEND)||card->controller()->opponent()->inPlay()->hasAbility(Constants::NOLEGENDRULE)||card->controller()->inPlay()->hasAbility(Constants::NOLEGENDRULE)) return 0; else return 1; @@ -3233,8 +3233,10 @@ int MTGLegendRule::added(MTGCardInstance * card) return 1; } -int MTGLegendRule::removed(MTGCardInstance *) +int MTGLegendRule::removed(MTGCardInstance * card) { + if (card->has(Constants::NOLEGENDRULE)) + game->legendNeedUpdate = true; return 0; }