diff --git a/projects/mtg/include/GuiPlay.h b/projects/mtg/include/GuiPlay.h index 7b725a765..209f15791 100644 --- a/projects/mtg/include/GuiPlay.h +++ b/projects/mtg/include/GuiPlay.h @@ -67,6 +67,7 @@ protected: class Lands: public HorzStack {}; class Creatures: public HorzStack {}; + class Planeswalker: public HorzStack {}; class Spells: public VertStack {}; protected: @@ -75,6 +76,7 @@ protected: BattleField battleField; Lands selfLands, opponentLands; Spells selfSpells, opponentSpells; + Planeswalker selfPlaneswalker,opponentPlaneswalker; iterator end_spells; vector cards; diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index 039b5b495..76d651af6 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -217,6 +217,17 @@ public: virtual ostream& toString(ostream& out) const; virtual MTGLegendRule * clone() const; }; +class MTGPlaneWalkerRule: public ListMaintainerAbility +{ +public: + MTGPlaneWalkerRule(int _id); + int canBeInList(MTGCardInstance * card); + int added(MTGCardInstance * card); + int removed(MTGCardInstance * card); + int testDestroy(); + virtual ostream& toString(ostream& out) const; + virtual MTGPlaneWalkerRule * clone() const; +}; class MTGMomirRule: public MTGAbility { diff --git a/projects/mtg/src/DuelLayers.cpp b/projects/mtg/src/DuelLayers.cpp index a89cefbea..bf08210ad 100644 --- a/projects/mtg/src/DuelLayers.cpp +++ b/projects/mtg/src/DuelLayers.cpp @@ -32,6 +32,7 @@ void DuelLayers::init() action->Add(NEW MTGBlockRule(-1)); action->Add(NEW MTGCombatTriggersRule(-1)); action->Add(NEW MTGLegendRule(-1)); + action->Add(NEW MTGPlaneWalkerRule(-1)); action->Add(NEW MTGTokensCleanup(-1)); // needs to be before persist action->Add(NEW MTGPersistRule(-1)); action->Add(NEW MTGAffinityRule(-1)); diff --git a/projects/mtg/src/GuiPlay.cpp b/projects/mtg/src/GuiPlay.cpp index 768edb8a3..e4db77af7 100644 --- a/projects/mtg/src/GuiPlay.cpp +++ b/projects/mtg/src/GuiPlay.cpp @@ -173,22 +173,25 @@ GuiPlay::~GuiPlay() bool isSpell(CardView* c) { - return c->card->isSpell() && !c->card->isCreature(); + return c->card->isSpell() && !c->card->isCreature() && !c->card->hasType("Planeswalker"); } void GuiPlay::Replace() { unsigned opponentSpellsN = 0, selfSpellsN = 0, opponentLandsN = 0, opponentCreaturesN = 0, battleFieldAttackersN = 0, - battleFieldBlockersN = 0, selfCreaturesN = 0, selfLandsN = 0; + battleFieldBlockersN = 0, selfCreaturesN = 0, selfLandsN = 0, selfPlaneswalkern = 0,opponentPlaneswalkern = 0; end_spells = stable_partition(cards.begin(), cards.end(), &isSpell); for (iterator it = cards.begin(); it != end_spells; ++it) if (!(*it)->card->target) { - if (game->players[0] == (*it)->card->controller()) - ++selfSpellsN; - else - ++opponentSpellsN; + if(!(*it)->card->hasSubtype("aura") && !(*it)->card->hasType("Planeswalker")) + { + if (game->players[0] == (*it)->card->controller()) + ++selfSpellsN; + else + ++opponentSpellsN; + } } for (iterator it = end_spells; it != cards.end(); ++it) { @@ -203,13 +206,20 @@ void GuiPlay::Replace() else ++opponentCreaturesN; } - else if ((*it)->card->isLand()) + else if ((*it)->card->isLand() || (*it)->card->hasType("Planeswalker")) { if (game->players[0] == (*it)->card->controller()) ++selfLandsN; else ++opponentLandsN; } + //else if ((*it)->card->hasType("Planeswalker")) + //{ + // if (game->players[0] == (*it)->card->controller()) + // ++selfPlaneswalkern; + // else + // ++opponentPlaneswalkern; + //} } opponentSpells.reset(opponentSpellsN, 18, 60); @@ -218,17 +228,19 @@ void GuiPlay::Replace() for (iterator it = cards.begin(); it != end_spells; ++it) if (!(*it)->card->target) { - if (game->players[0] == (*it)->card->controller()) - selfSpells.Enstack(*it); - else - opponentSpells.Enstack(*it); + if(!(*it)->card->hasSubtype("aura") && !(*it)->card->hasType("Planeswalker")) + { + if (game->players[0] == (*it)->card->controller()) + selfSpells.Enstack(*it); + else + opponentSpells.Enstack(*it); + } } - float x = 24 + opponentSpells.nextX(); //seperated the varible X into 2 different varibles. There are 2 players here!! //we should not be using a single varible to determine the positioning of cards!! float myx = 24 + selfSpells.nextX(); - opponentLands.reset(opponentLandsN, x, 50); + opponentLands.reset(opponentLandsN,55 + x, 50); opponentCreatures.reset(opponentCreaturesN, x, 95); battleField.reset(x, 145);//what does this varible do? i can comment it out with no reprocussions...is this being double handled? selfCreatures.reset(selfCreaturesN, myx, 195); @@ -254,6 +266,18 @@ void GuiPlay::Replace() else opponentLands.Enstack(*it); } + + } + //rerun the iter reattaching planes walkers to the back of the lands. + for (iterator it = end_spells; it != cards.end(); ++it) + { + if ((*it)->card->hasType("Planeswalker")) + { + if (game->players[0] == (*it)->card->controller()) + selfLands.Enstack(*it); + else + opponentLands.Enstack(*it); + } } } @@ -276,7 +300,7 @@ void GuiPlay::Render() else opponentCreatures.Render(*it, cards.begin(), end_spells); } - else + else if(!(*it)->card->hasSubtype("Planeswalker")) { if (!(*it)->card->target) { @@ -286,6 +310,16 @@ void GuiPlay::Render() opponentSpells.Render(*it, cards.begin(), end_spells); } } + else + { + if (!(*it)->card->target) + { + if (game->players[0] == (*it)->card->controller()) + selfPlaneswalker.Render(*it, cards.begin(), end_spells); + else + opponentPlaneswalker.Render(*it, cards.begin(), end_spells); + } + } } void GuiPlay::Update(float dt) diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index 9b07e7129..53558e155 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -219,7 +219,7 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi break; case 'r': //retrace/rarity - if('s' == key[2])//restrictions + if('s' == key[2] && 't' == key[3])//restrictions { if (!primitive) primitive = NEW CardPrimitive(); string value = val; @@ -273,7 +273,7 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi } } } - else if ('e' == key[1]) + else if ('e' == key[1] && 't' == key[2]) { //retrace if (!primitive) primitive = NEW CardPrimitive(); if (ManaCost * cost = primitive->getManaCost()) @@ -283,13 +283,12 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi cost->Retrace = ManaCost::parseManaCost(value); } } - else + else if (s.find("rar") != string::npos) {//rarity if (!card) card = NEW MTGCard(); card->setRarity(val[0]); } break; - case 's': //subtype if (!primitive) primitive = NEW CardPrimitive(); while (true) diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 083dc7e09..287c9accd 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -1852,6 +1852,65 @@ MTGLegendRule * MTGLegendRule::clone() const return a; } +/* PlaneWalker Rule */ +MTGPlaneWalkerRule::MTGPlaneWalkerRule(int _id) : +ListMaintainerAbility(_id) +{ +} +; + +int MTGPlaneWalkerRule::canBeInList(MTGCardInstance * card) +{ + if(card->isPhased) + return 0; + if (card->hasType("Planeswalker") && game->isInPlay(card)) + { + return 1; + } + return 0; +} + +int MTGPlaneWalkerRule::added(MTGCardInstance * card) +{ + map::iterator it; + int destroy = 0; + for (it = cards.begin(); it != cards.end(); it++) + { + MTGCardInstance * comparison = (*it).first; + if (comparison != card && comparison->types == card->types) + { + comparison->controller()->game->putInGraveyard(comparison); + destroy = 1; + } + } + if (destroy) + { + card->owner->game->putInGraveyard(card); + } + return 1; +} + +int MTGPlaneWalkerRule::removed(MTGCardInstance * card) +{ + return 0; +} + +int MTGPlaneWalkerRule::testDestroy() +{ + return 0; +} + +ostream& MTGPlaneWalkerRule::toString(ostream& out) const +{ + return out << "MTGLegendRule :::"; +} +MTGPlaneWalkerRule * MTGPlaneWalkerRule::clone() const +{ + MTGPlaneWalkerRule * a = NEW MTGPlaneWalkerRule(*this); + a->isClone = 1; + return a; +} + /* Lifelink */ MTGLifelinkRule::MTGLifelinkRule(int _id) : MTGAbility(_id, NULL)