From cf0f9d43fa1ac48e5c89c4d44c416cae6fe1ae78 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 26 Oct 2015 06:50:19 +0800 Subject: [PATCH] exile zone player only, todo opponent and ability activation for exile --- projects/mtg/bin/Res/sets/primitives/mtg.txt | 5 ++- projects/mtg/include/GuiAvatars.h | 2 + projects/mtg/include/GuiStatic.h | 10 +++++ projects/mtg/include/PlayGuiObject.h | 1 + projects/mtg/src/GameObserver.cpp | 2 + projects/mtg/src/GuiAvatars.cpp | 18 +++++--- projects/mtg/src/GuiStatic.cpp | 46 ++++++++++++++++++++ 7 files changed, 76 insertions(+), 8 deletions(-) diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index 936610a2d..4489f959d 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -19622,8 +19622,8 @@ toughness=4 [/card] [card] name=Cranial Archive -auto={2}{E}:name(shuffle graveyard) target(player) donothing && moveto(ownerlibrary) and!(shuffle)! all(*|targetedpersonsgraveyard) -text={2}, Exile Cranial Archive: Target player shuffles his or her graveyard into his or her library. +auto={2}{E}:name(shuffle graveyard) target(player) donothing && moveto(ownerlibrary) and!(shuffle && draw:1 controller)! all(*|targetedpersonsgraveyard) +text={2}, Exile Cranial Archive: Target player shuffles his or her graveyard into his or her library. Draw a card. mana={2} type=Artifact [/card] @@ -74363,6 +74363,7 @@ type=Sorcery [/card] [card] name=Preyseizer Dragon +abilities=flying auto=may target(other creature|mybattlefield) sacrifice && counter(1/1,2) all(this) auto=@combat(attacking) source(this)::target(creature,player) dynamicability text=Flying -- Devour 2 (As this enters the battlefield, you may sacrifice any number of creatures. This creature enters the battlefield with twice that many +1/+1 counters on it.) -- Whenever Preyseizer Dragon attacks, it deals damage to target creature or player equal to the number of +1/+1 counters on Preyseizer Dragon. diff --git a/projects/mtg/include/GuiAvatars.h b/projects/mtg/include/GuiAvatars.h index 2baf6822c..36622051b 100644 --- a/projects/mtg/include/GuiAvatars.h +++ b/projects/mtg/include/GuiAvatars.h @@ -7,6 +7,7 @@ struct GuiAvatar; class GuiGraveyard; class GuiLibrary; class GuiOpponentHand; +class GuiExile; class GuiAvatars: public GuiLayer { protected: @@ -14,6 +15,7 @@ protected: GuiGraveyard* selfGraveyard, *opponentGraveyard; GuiLibrary* selfLibrary, *opponentLibrary; GuiOpponentHand *opponentHand; + GuiExile* selfExile, *opponentExile; GuiAvatar* active; public: diff --git a/projects/mtg/include/GuiStatic.h b/projects/mtg/include/GuiStatic.h index 9fb352a7a..513d7848b 100644 --- a/projects/mtg/include/GuiStatic.h +++ b/projects/mtg/include/GuiStatic.h @@ -88,4 +88,14 @@ public: virtual ostream& toString(ostream& out) const; }; +class GuiExile: public GuiGameZone +{ +public: + Player * player; + GuiExile(float _x, float _y, bool hasFocus, Player * player, GuiAvatars* parent); + int receiveEventPlus(WEvent*); + int receiveEventMinus(WEvent*); + virtual ostream& toString(ostream& out) const; +}; + #endif // _GUISTATIC_H_ diff --git a/projects/mtg/include/PlayGuiObject.h b/projects/mtg/include/PlayGuiObject.h index c09d1a4c8..2f4dbcf67 100644 --- a/projects/mtg/include/PlayGuiObject.h +++ b/projects/mtg/include/PlayGuiObject.h @@ -10,6 +10,7 @@ #define GUI_GRAVEYARD 3 #define GUI_LIBRARY 4 #define GUI_OPPONENTHAND 5 +#define GUI_EXILE 6 #include #include "WEvent.h" diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 4a0d6300b..3aba8dd97 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -1134,6 +1134,8 @@ void GameObserver::ButtonPressed(PlayGuiObject * target) } else if (GuiGraveyard* graveyard = dynamic_cast(target)) graveyard->toggleDisplay(); + else if (GuiExile* exile = dynamic_cast(target)) + exile->toggleDisplay(); //opponenthand else if (GuiOpponentHand* opponentHand = dynamic_cast(target)) if (opponentHand->showCards) diff --git a/projects/mtg/src/GuiAvatars.cpp b/projects/mtg/src/GuiAvatars.cpp index e364bae3c..6b5e922a7 100644 --- a/projects/mtg/src/GuiAvatars.cpp +++ b/projects/mtg/src/GuiAvatars.cpp @@ -14,6 +14,7 @@ GuiAvatars::GuiAvatars(DuelLayers* duelLayers) : self->zoom = 0.9f; Add(selfGraveyard = NEW GuiGraveyard(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 1, false, mpDuelLayers->getRenderedPlayer(), this)); Add(selfLibrary = NEW GuiLibrary(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 5 + GuiGameZone::Height + 5, false, mpDuelLayers->getRenderedPlayer(), this)); + Add(selfExile = NEW GuiExile(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 + 20, SCREEN_HEIGHT - GuiAvatar::Height, false, mpDuelLayers->getRenderedPlayer(), this)); Add(opponent = NEW GuiAvatar(0, 0, false, mpDuelLayers->getRenderedPlayerOpponent(), GuiAvatar::TOP_LEFT, this)); opponent->zoom = 0.9f; @@ -28,12 +29,13 @@ GuiAvatars::GuiAvatars(DuelLayers* duelLayers) : observer->getCardSelector()->Add(self); observer->getCardSelector()->Add(selfGraveyard); + observer->getCardSelector()->Add(selfExile); observer->getCardSelector()->Add(selfLibrary); observer->getCardSelector()->Add(opponent); observer->getCardSelector()->Add(opponentGraveyard); observer->getCardSelector()->Add(opponentLibrary); observer->getCardSelector()->Add(opponentHand); - selfGraveyard->alpha = selfLibrary->alpha = opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 0; + selfGraveyard->alpha = selfExile->alpha = selfLibrary->alpha = opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 0; } float GuiAvatars::LeftBoundarySelf() @@ -56,9 +58,9 @@ void GuiAvatars::Activate(PlayGuiObject* c) active = opponent; opponent->zoom = 1.2f; } - else if ((selfGraveyard == c) || (selfLibrary == c) || (self == c)) + else if ((selfGraveyard == c) || (selfExile == c) || (selfLibrary == c) || (self == c)) { - selfGraveyard->alpha = selfLibrary->alpha = 128.0f; + selfGraveyard->alpha = selfExile->alpha = selfLibrary->alpha = 128.0f; self->zoom = 1.0f; active = self; } @@ -75,9 +77,9 @@ void GuiAvatars::Deactivate(PlayGuiObject* c) opponent->zoom = 0.9f; active = NULL; } - else if ((selfGraveyard == c) || (selfLibrary == c) || (self == c)) + else if ((selfGraveyard == c) || (selfExile == c) || (selfLibrary == c) || (self == c)) { - selfGraveyard->alpha = selfLibrary->alpha = 0; + selfGraveyard->alpha = selfExile->alpha = selfLibrary->alpha = 0; self->zoom = 0.5f; active = NULL; } @@ -85,12 +87,13 @@ void GuiAvatars::Deactivate(PlayGuiObject* c) int GuiAvatars::receiveEventPlus(WEvent* e) { - return selfGraveyard->receiveEventPlus(e) | opponentGraveyard->receiveEventPlus(e) | opponentHand->receiveEventPlus(e); + return selfGraveyard->receiveEventPlus(e) | selfExile->receiveEventPlus(e) | opponentGraveyard->receiveEventPlus(e) | opponentHand->receiveEventPlus(e); } int GuiAvatars::receiveEventMinus(WEvent* e) { selfGraveyard->receiveEventMinus(e); + selfExile->receiveEventMinus(e); opponentGraveyard->receiveEventMinus(e); opponentHand->receiveEventMinus(e); return 1; @@ -104,6 +107,8 @@ bool GuiAvatars::CheckUserInput(JButton key) return true; if (selfGraveyard->CheckUserInput(key)) return true; + if (selfExile->CheckUserInput(key)) + return true; if (opponentGraveyard->CheckUserInput(key)) return true; if (opponentHand->CheckUserInput(key)) @@ -120,6 +125,7 @@ void GuiAvatars::Update(float dt) self->Update(dt); opponent->Update(dt); selfGraveyard->Update(dt); + selfExile->Update(dt); opponentHand->Update(dt); opponentGraveyard->Update(dt); selfLibrary->Update(dt); diff --git a/projects/mtg/src/GuiStatic.cpp b/projects/mtg/src/GuiStatic.cpp index 28e00ec2d..c7eb7e795 100644 --- a/projects/mtg/src/GuiStatic.cpp +++ b/projects/mtg/src/GuiStatic.cpp @@ -298,6 +298,52 @@ ostream& GuiGraveyard::toString(ostream& out) const return out << "GuiGraveyard :::"; } +GuiExile::GuiExile(float x, float y, bool hasFocus, Player * player, GuiAvatars* parent) : + GuiGameZone(x, y, hasFocus, player->game->exile, parent), player(player) +{ + type = GUI_EXILE; +} + +int GuiExile::receiveEventPlus(WEvent* e) +{ + if (WEventZoneChange* event = dynamic_cast(e)) + if (event->to == zone) + { + CardView* t; + if (event->card->view) + t = NEW CardView(CardView::nullZone, event->card, *(event->card->view)); + else + t = NEW CardView(CardView::nullZone, event->card, x, y); + t->x = x + Width / 2; + t->y = y + Height / 2; + t->zoom = 0.6f; + t->alpha = 0; + cards.push_back(t); + return 1; + } + return 0; +} + +int GuiExile::receiveEventMinus(WEvent* e) +{ + if (WEventZoneChange* event = dynamic_cast(e)) + if (event->from == zone) + for (vector::iterator it = cards.begin(); it != cards.end(); ++it) + if (event->card->previous == (*it)->card) + { + CardView* cv = *it; + cards.erase(it); + zone->owner->getObserver()->mTrash->trash(cv); + return 1; + } + return 0; +} + +ostream& GuiExile::toString(ostream& out) const +{ + return out << "GuiExile :::"; +} + //opponenthand begins GuiOpponentHand::GuiOpponentHand(float x, float y, bool hasFocus, Player * player, GuiAvatars* parent) : GuiGameZone(x, y, hasFocus, player->game->hand, parent), player(player)