From 4e9d4bfaf66a693a4b6535f19383629783f3f8c0 Mon Sep 17 00:00:00 2001 From: zethfoxster Date: Sun, 17 Jul 2016 02:19:58 -0400 Subject: [PATCH 1/3] minor changes to ai --- projects/mtg/src/AIPlayerBaka.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/projects/mtg/src/AIPlayerBaka.cpp b/projects/mtg/src/AIPlayerBaka.cpp index a4d437c08..c7f679fb3 100644 --- a/projects/mtg/src/AIPlayerBaka.cpp +++ b/projects/mtg/src/AIPlayerBaka.cpp @@ -62,8 +62,9 @@ int OrderedAIAction::getEfficiency(AADamager * aad) // I can't remember as I type this in which condition we use one or the other for this function, if you find out please replace this comment int OrderedAIAction::getEfficiency() { - if (efficiency > -1) - return efficiency; + //commented out the below becuase I noticed it prevented ai from updating the given abilities with new eff %. + //if (efficiency > -1) + // return efficiency; if (!ability) return 0; GameObserver * g = owner->getObserver(); @@ -335,6 +336,16 @@ int OrderedAIAction::getEfficiency() } case MTGAbility::MANA_PRODUCER://only way to hit this condition is nested manaabilities, ai skips manaproducers by defualt when finding an ability to use. { + AManaProducer * manamaker = dynamic_cast(a); + GenericActivatedAbility * GAA = dynamic_cast(ability); + AForeach * forMana = dynamic_cast(GAA->ability); + if (manamaker && forMana) + { + int outPut = forMana->checkActivation(); + if (ability->getCost() && outPut > int(ability->getCost()->getConvertedCost() +1) && currentPhase == MTG_PHASE_FIRSTMAIN && ability->source->controller()->game->hand->nb_cards > 1) + efficiency = 90;//might be a bit random, but better than never using them. + } + else efficiency = 0; break; } @@ -635,6 +646,10 @@ int OrderedAIAction::getEfficiency() { efficiency += 55; } + else if (dynamic_cast(a)) + { + efficiency += 55; + } SAFE_DELETE(transAbility); return efficiency; } From 9e73dc9c00e9e123bf5cc0747be5c70a9c824784 Mon Sep 17 00:00:00 2001 From: zethfoxster Date: Sun, 17 Jul 2016 22:24:53 -0400 Subject: [PATCH 2/3] add support for repeater deplete cards. Scalpelexis Sphinx's Tutelage Grindstone normally I aim for much bigger card groups, but this was requested by one of the only 2 active members we have on the forum. I'll have the card code for these cards ready when I code eldrich moon set. to use, use it like any normal depelte except add name color to the front, name deplete:4 targetsZone(player) this will repeat this until the player depletes cards that dont have atleast 2 with the same name. color deplete:2 target(player) this will continue to deplete until the player depletes a set of cards that dont share a color with each other lands not included when checking colors. enjoy. --- projects/mtg/include/AllAbilities.h | 4 +- projects/mtg/src/AllAbilities.cpp | 124 ++++++++++++++++++++++++++-- projects/mtg/src/MTGAbility.cpp | 16 +++- 3 files changed, 133 insertions(+), 11 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 5681d7994..e1d7fb45d 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -6195,8 +6195,10 @@ class AADepleter: public ActivatedAbilityTP public: string nbcardsStr; bool toexile; + bool namerepeat; + bool colorrepeat; AADepleter(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost = NULL, - int who = TargetChooser::UNSET, bool toexile = false); + int who = TargetChooser::UNSET, bool toexile = false, bool colorrepeat = false, bool namerepeat = false); int resolve(); const string getMenuText(); AADepleter * clone() const; diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index e5ced563c..4cf600791 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -1099,8 +1099,8 @@ AADamager * AADamager::clone() const //AADepleter -AADepleter::AADepleter(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost, int who, bool toexile) : - ActivatedAbilityTP(observer, _id, card, _target, _cost, who),nbcardsStr(nbcardsStr),toexile(toexile) +AADepleter::AADepleter(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost, int who, bool toexile, bool colorrepeat, bool namerepeat) : + ActivatedAbilityTP(observer, _id, card, _target, _cost, who),nbcardsStr(nbcardsStr),toexile(toexile), colorrepeat(colorrepeat), namerepeat(namerepeat) { } int AADepleter::resolve() @@ -1110,16 +1110,124 @@ AADepleter::AADepleter(GameObserver* observer, int _id, MTGCardInstance * card, { WParsedInt numCards(nbcardsStr, NULL, source); MTGLibrary * library = player->game->library; - for (int i = 0; i < numCards.getValue(); i++) + if (colorrepeat && library->nb_cards) { - if (library->nb_cards) + bool repeating = false; + do { - if(toexile) - player->game->putInZone(library->cards[library->nb_cards - 1], library, player->game->exile); - else - player->game->putInZone(library->cards[library->nb_cards - 1], library, player->game->graveyard); + repeating = false; + vectorfound; + for (int i = 0; i < numCards.getValue(); i++) + { + if (library->nb_cards) + { + if(library->nb_cards > i) + found.push_back(library->cards[(library->nb_cards - 1) - i]); + } + } + + for (vector::iterator it = found.begin(); it != found.end(); it++) + { + MTGCardInstance * cardFirst = *it; + if (cardFirst->isLand()) + continue; + for (int i = Constants::MTG_COLOR_GREEN; i <= Constants::MTG_COLOR_WHITE; ++i) + { + if (cardFirst->hasColor(i)) + { + for (vector::iterator secondit = found.begin(); secondit != found.end(); secondit++) + { + MTGCardInstance * cardSecond = *secondit; + if (cardSecond->isLand()) + continue; + if (cardSecond->hasColor(i) && cardFirst != cardSecond) + { + repeating = true; + } + } + } + } + } + + do + { + if (found.size()) + { + MTGCardInstance * toMove = found.back(); + if (toMove) + { + if (toexile) + player->game->putInZone(toMove, library, player->game->exile); + else + player->game->putInZone(toMove, library, player->game->graveyard); + found.pop_back(); + } + } + } while (found.size()); + + } while (repeating); + } + else if (namerepeat && library->nb_cards) + { + bool repeating = false; + do + { + repeating = false; + vectorfound; + for (int i = 0; i < numCards.getValue(); i++) + { + if (library->nb_cards) + { + if (library->nb_cards > i) + found.push_back(library->cards[(library->nb_cards - 1) - i]); + } + } + + for (vector::iterator it = found.begin(); it != found.end(); it++) + { + MTGCardInstance * cardFirst = *it; + for (vector::iterator secondit = found.begin(); secondit != found.end(); secondit++) + { + MTGCardInstance * cardSecond = *secondit; + if (cardSecond->name == cardFirst->name && cardFirst != cardSecond) + { + repeating = true; + } + } + + } + + do + { + if (found.size()) + { + MTGCardInstance * toMove = found.back(); + if (toMove) + { + if (toexile) + player->game->putInZone(toMove, library, player->game->exile); + else + player->game->putInZone(toMove, library, player->game->graveyard); + found.pop_back(); + } + } + } while (found.size()); + } while (repeating); + } + else + { + for (int i = 0; i < numCards.getValue(); i++) + { + if (library->nb_cards) + { + if (toexile) + player->game->putInZone(library->cards[library->nb_cards - 1], library, player->game->exile); + else + player->game->putInZone(library->cards[library->nb_cards - 1], library, player->game->graveyard); + } } } + } return 1; } diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 005b028c6..ea7def80b 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -2820,8 +2820,14 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitDeplete = parseBetween(s, "deplete:", " ", false); if (splitDeplete.size()) { + bool namerepeat = false; + bool colorrepeat = false; + if (splitDeplete[0].find("color") != string::npos) + colorrepeat = true; + if (splitDeplete[0].find("name") != string::npos) + namerepeat = true; Targetable * t = spell ? spell->getNextTarget() : NULL; - MTGAbility * a = NEW AADepleter(observer, id, card, t , splitDeplete[1], NULL, who, false); + MTGAbility * a = NEW AADepleter(observer, id, card, t , splitDeplete[1], NULL, who, false, colorrepeat, namerepeat); a->oneShot = 1; return a; } @@ -2830,8 +2836,14 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG vector splitIngest = parseBetween(s, "ingest:", " ", false); if (splitIngest.size()) { + bool namerepeat = false; + bool colorrepeat = false; + if (splitIngest[0].find("coloringest") != string::npos) + colorrepeat = true; + if (splitIngest[0].find("nameingest") != string::npos) + namerepeat = true; Targetable * t = spell ? spell->getNextTarget() : NULL; - MTGAbility * a = NEW AADepleter(observer, id, card, t , splitIngest[1], NULL, who, true); + MTGAbility * a = NEW AADepleter(observer, id, card, t , splitIngest[1], NULL, who, true, colorrepeat, namerepeat); a->oneShot = 1; return a; } From bfaaf7d8936052a5e34b01a4c5cb2b4e70e13855 Mon Sep 17 00:00:00 2001 From: zethfoxster Date: Sun, 17 Jul 2016 22:37:32 -0400 Subject: [PATCH 3/3] travis int order --- projects/mtg/include/AllAbilities.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index e1d7fb45d..bbc45f076 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -6195,8 +6195,8 @@ class AADepleter: public ActivatedAbilityTP public: string nbcardsStr; bool toexile; - bool namerepeat; bool colorrepeat; + bool namerepeat; AADepleter(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost = NULL, int who = TargetChooser::UNSET, bool toexile = false, bool colorrepeat = false, bool namerepeat = false); int resolve();