diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index 04ce7056b..c677d2a69 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -10,16 +10,22 @@ #include "CardSelector.h" #include "ManaCost.h" -class OtherAbilitiesEventReceiver: public MTGAbility +class PermanentAbility: public MTGAbility +{ +public: + int testDestroy() {return 0;}; + PermanentAbility(GameObserver* observer, int _id); +}; + +class OtherAbilitiesEventReceiver: public PermanentAbility { public: - int testDestroy(); int receiveEvent(WEvent * event); OtherAbilitiesEventReceiver(GameObserver* observer, int _id); OtherAbilitiesEventReceiver * clone() const; }; -class MTGEventBonus: public MTGAbility +class MTGEventBonus: public PermanentAbility { public: int textAlpha; @@ -55,19 +61,17 @@ public: int receiveEvent(WEvent * event); void grantAward(string awardName,int amount); - int testDestroy(); void Update(float dt); void Render(); MTGEventBonus(GameObserver* observer, int _id); virtual MTGEventBonus * clone() const; }; -class MTGPutInPlayRule: public MTGAbility +class MTGPutInPlayRule: public PermanentAbility { public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); - int testDestroy(); virtual ostream& toString(ostream& out) const; MTGPutInPlayRule(GameObserver* observer, int _id); const char * getMenuText() @@ -82,7 +86,6 @@ class MTGKickerRule: public MTGPutInPlayRule public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); - int testDestroy(); virtual ostream& toString(ostream& out) const; MTGKickerRule(GameObserver* observer, int _id); const char * getMenuText() @@ -92,7 +95,7 @@ public: virtual MTGKickerRule * clone() const; }; -class MTGAlternativeCostRule: public MTGAbility +class MTGAlternativeCostRule: public PermanentAbility { protected: int isReactingToClick(MTGCardInstance * card, ManaCost * mana, ManaCost *alternateManaCost); @@ -101,8 +104,6 @@ protected: public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); - - int testDestroy(); virtual ostream& toString(ostream& out) const; MTGAlternativeCostRule(GameObserver* observer, int _id); const char * getMenuText() @@ -119,7 +120,6 @@ class MTGBuyBackRule: public MTGAlternativeCostRule public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); - int testDestroy(); virtual ostream& toString(ostream& out) const; MTGBuyBackRule(GameObserver* observer, int _id); const char * getMenuText() @@ -135,7 +135,6 @@ public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); - int testDestroy(); virtual ostream& toString(ostream& out) const; MTGFlashBackRule(GameObserver* observer, int _id); const char * getMenuText() @@ -150,7 +149,6 @@ class MTGRetraceRule: public MTGAlternativeCostRule public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); - int testDestroy(); virtual ostream& toString(ostream& out) const; MTGRetraceRule(GameObserver* observer, int _id); const char * getMenuText() @@ -160,13 +158,12 @@ public: virtual MTGRetraceRule * clone() const; }; -class MTGMorphCostRule: public MTGAbility +class MTGMorphCostRule: public PermanentAbility { public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); - int testDestroy(); virtual ostream& toString(ostream& out) const; MTGMorphCostRule(GameObserver* observer, int _id); const char * getMenuText() @@ -182,7 +179,6 @@ public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int receiveEvent(WEvent *e); int reactToClick(MTGCardInstance * card); - int testDestroy(); string suspendmenu; virtual ostream& toString(ostream& out) const; MTGSuspendRule(GameObserver* observer, int _id); @@ -198,7 +194,7 @@ public: virtual MTGSuspendRule * clone() const; }; -class MTGAttackRule: public MTGAbility, public Limitor +class MTGAttackRule: public PermanentAbility, public Limitor { public: @@ -206,7 +202,6 @@ public: virtual bool greyout(Target*); int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); - int testDestroy(); virtual ostream& toString(ostream& out) const; MTGAttackRule(GameObserver* observer, int _id); const char * getMenuText() @@ -218,22 +213,20 @@ public: }; /* handles combat trigger send recieve events*/ -class MTGCombatTriggersRule: public MTGAbility +class MTGCombatTriggersRule: public PermanentAbility { public: MTGCombatTriggersRule(GameObserver* observer, int _id); int receiveEvent(WEvent * event); virtual ostream& toString(ostream& out) const; - int testDestroy(); virtual MTGCombatTriggersRule * clone() const; }; -class MTGBlockRule: public MTGAbility +class MTGBlockRule: public PermanentAbility { public: int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); - int testDestroy(); virtual ostream& toString(ostream& out) const; MTGBlockRule(GameObserver* observer, int _id); const char * getMenuText() @@ -244,43 +237,39 @@ public: }; /* Persist Rule */ -class MTGPersistRule: public MTGAbility +class MTGPersistRule: public PermanentAbility { public: MTGPersistRule(GameObserver* observer, int _id); int receiveEvent(WEvent * event); virtual ostream& toString(ostream& out) const; - int testDestroy(); virtual MTGPersistRule * clone() const; }; /* vampire Rule */ -class MTGVampireRule: public MTGAbility +class MTGVampireRule: public PermanentAbility { public: MTGVampireRule(GameObserver* observer, int _id); map > victems; int receiveEvent(WEvent * event); virtual ostream& toString(ostream& out) const; - int testDestroy(); virtual MTGVampireRule * clone() const; }; //unearths destruction if leaves play effect -class MTGUnearthRule: public MTGAbility +class MTGUnearthRule: public PermanentAbility { public: MTGUnearthRule(GameObserver* observer, int _id); int receiveEvent(WEvent * event); virtual ostream& toString(ostream& out) const; - int testDestroy(); virtual MTGUnearthRule * clone() const; }; -class MTGTokensCleanup: public MTGAbility +class MTGTokensCleanup: public PermanentAbility { public: vector list; MTGTokensCleanup(GameObserver* observer, int _id); int receiveEvent(WEvent * event); - int testDestroy(); virtual MTGTokensCleanup * clone() const; }; @@ -313,7 +302,7 @@ public: virtual MTGPlaneWalkerRule * clone() const; }; -class MTGMomirRule: public MTGAbility +class MTGMomirRule: public PermanentAbility { private: int genRandomCreatureId(int convertedCost); @@ -327,7 +316,6 @@ public: int alreadyplayed; MTGAllCards * collection; MTGCardInstance * genCreature(int id); - int testDestroy(); void Update(float dt); void Render(); MTGMomirRule(GameObserver* observer, int _id, MTGAllCards * _collection); @@ -343,7 +331,7 @@ public: }; //stone hewer gaint avatar mode -class MTGStoneHewerRule: public MTGAbility +class MTGStoneHewerRule: public PermanentAbility { private: int genRandomEquipId(int convertedCost); @@ -352,8 +340,7 @@ private: public: MTGAllCards * collection; MTGCardInstance * genEquip(int id); - int testDestroy(); - MTGStoneHewerRule(GameObserver* observer, int _id, MTGAllCards * _collection); + MTGStoneHewerRule(GameObserver* observer, int _id, MTGAllCards * _collection); int receiveEvent(WEvent * event); const char * getMenuText() { @@ -363,11 +350,10 @@ public: virtual MTGStoneHewerRule * clone() const; }; //Hermit Druid avatar mode -class MTGHermitRule: public MTGAbility +class MTGHermitRule: public PermanentAbility { public: - int testDestroy(); - MTGHermitRule(GameObserver* observer, int _id); + MTGHermitRule(GameObserver* observer, int _id); int receiveEvent(WEvent * event); const char * getMenuText() { @@ -377,29 +363,26 @@ public: }; // /* LifeLink */ -class MTGLifelinkRule: public MTGAbility +class MTGLifelinkRule: public PermanentAbility { public: MTGLifelinkRule(GameObserver* observer, int _id); int receiveEvent(WEvent * event); - int testDestroy(); - virtual ostream& toString(ostream& out) const; virtual MTGLifelinkRule * clone() const; }; /* Deathtouch */ -class MTGDeathtouchRule: public MTGAbility +class MTGDeathtouchRule: public PermanentAbility { public: MTGDeathtouchRule(GameObserver* observer, int _id); int receiveEvent(WEvent * event); - int testDestroy(); const char * getMenuText() { return "Deathtouch"; @@ -409,13 +392,12 @@ public: }; /* handling parentchild */ -class ParentChildRule: public MTGAbility +class ParentChildRule: public PermanentAbility { public: ParentChildRule(GameObserver* observer, int _id); int receiveEvent(WEvent * event); virtual ostream& toString(ostream& out) const; - int testDestroy(); virtual ParentChildRule * clone() const; }; /* HUD Display */ @@ -434,7 +416,7 @@ public: ; }; -class HUDDisplay: public MTGAbility +class HUDDisplay: public PermanentAbility { private: list events; @@ -444,7 +426,6 @@ private: float maxWidth; int addEvent(string s); public: - int testDestroy(); int receiveEvent(WEvent * event); void Update(float dt); void Render(); diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index d032f1ace..3cc55c12d 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -7,8 +7,12 @@ #include "Credits.h" #include "AllAbilities.h" +PermanentAbility::PermanentAbility(GameObserver* observer, int _id) : MTGAbility(observer, _id,NULL) +{ +} + MTGEventBonus::MTGEventBonus(GameObserver* observer, int _id) : -MTGAbility(observer, _id,NULL) +PermanentAbility(observer, _id) { textAlpha = 0; text = ""; @@ -245,11 +249,6 @@ void MTGEventBonus::grantAward(string awardName,int amount) Credits::addCreditBonus(amount); } -int MTGEventBonus::testDestroy() -{ - return 0; -} - void MTGEventBonus::Update(float dt) { if (textAlpha) @@ -278,7 +277,7 @@ MTGEventBonus * MTGEventBonus::clone() const // MTGPutInPlayRule::MTGPutInPlayRule(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { aType = MTGAbility::PUT_INTO_PLAY; } @@ -459,12 +458,6 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card) return 1; } -//The Put into play rule is never destroyed -int MTGPutInPlayRule::testDestroy() -{ - return 0; -} - ostream& MTGPutInPlayRule::toString(ostream& out) const { out << "MTGPutInPlayRule ::: ("; @@ -597,11 +590,6 @@ int MTGKickerRule::reactToClick(MTGCardInstance * card) return 1; } -int MTGKickerRule::testDestroy() -{ - return 0; -} - ostream& MTGKickerRule::toString(ostream& out) const { out << "MTGKickerRule ::: ("; @@ -625,7 +613,7 @@ MTGKickerRule * MTGKickerRule::clone() const //------------------------------------------------------------------------- MTGAlternativeCostRule::MTGAlternativeCostRule(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { aType = MTGAbility::ALTERNATIVE_COST; } @@ -757,13 +745,6 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter return 1; } - -//The Put into play rule is never destroyed -int MTGAlternativeCostRule::testDestroy() -{ - return 0; -} - ostream& MTGAlternativeCostRule::toString(ostream& out) const { out << "MTGAlternativeCostRule ::: ("; @@ -810,12 +791,6 @@ int MTGBuyBackRule::reactToClick(MTGCardInstance * card) } -//The Put into play rule is never destroyed -int MTGBuyBackRule::testDestroy() -{ - return 0; -} - ostream& MTGBuyBackRule::toString(ostream& out) const { out << "MTGBuyBackRule ::: ("; @@ -858,12 +833,6 @@ int MTGFlashBackRule::reactToClick(MTGCardInstance * card) } -//The Put into play rule is never destroyed -int MTGFlashBackRule::testDestroy() -{ - return 0; -} - ostream& MTGFlashBackRule::toString(ostream& out) const { out << "MTGFlashBackRule ::: ("; @@ -910,13 +879,6 @@ int MTGRetraceRule::reactToClick(MTGCardInstance * card) return MTGAlternativeCostRule::reactToClick(card, alternateCost, ManaCost::MANA_PAID_WITH_RETRACE); } - -//The Put into play rule is never destroyed -int MTGRetraceRule::testDestroy() -{ - return 0; -} - ostream& MTGRetraceRule::toString(ostream& out) const { out << "MTGRetraceRule ::: ("; @@ -1027,13 +989,6 @@ int MTGSuspendRule::reactToClick(MTGCardInstance * card) return 1; } - -//The Put into play rule is never destroyed -int MTGSuspendRule::testDestroy() -{ - return 0; -} - ostream& MTGSuspendRule::toString(ostream& out) const { out << "MTGSuspendRule ::: ("; @@ -1052,7 +1007,7 @@ MTGSuspendRule * MTGSuspendRule::clone() const MTGMorphCostRule::MTGMorphCostRule(GameObserver* observer, int _id) : - MTGAbility(observer, _id, NULL) + PermanentAbility(observer, _id) { aType = MTGAbility::MORPH_COST; } @@ -1155,12 +1110,6 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card) return 1; } -//The morph rule is never destroyed -int MTGMorphCostRule::testDestroy() -{ - return 0; -} - ostream& MTGMorphCostRule::toString(ostream& out) const { out << "MTGMorphCostRule ::: ("; @@ -1196,7 +1145,7 @@ bool MTGAttackRule::greyout(Target* t) } MTGAttackRule::MTGAttackRule(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { aType = MTGAbility::MTG_ATTACK_RULE; } @@ -1258,12 +1207,6 @@ int MTGAttackRule::reactToClick(MTGCardInstance * card) return 1; } -//The Attack rule is never destroyed -int MTGAttackRule::testDestroy() -{ - return 0; -} - ostream& MTGAttackRule::toString(ostream& out) const { out << "MTGAttackRule ::: ("; @@ -1277,7 +1220,7 @@ MTGAttackRule * MTGAttackRule::clone() const //this rules handles returning cards to combat triggers for activations. MTGCombatTriggersRule::MTGCombatTriggersRule(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { aType = MTGAbility::MTG_COMBATTRIGGERS_RULE; } @@ -1376,12 +1319,6 @@ int MTGCombatTriggersRule::receiveEvent(WEvent *e) return 0; } -//trigger rules are never distroyed -int MTGCombatTriggersRule::testDestroy() -{ - return 0; -} - ostream& MTGCombatTriggersRule::toString(ostream& out) const { out << "MTGCombatTriggersRule ::: ("; @@ -1395,7 +1332,7 @@ MTGCombatTriggersRule * MTGCombatTriggersRule::clone() const ///------------ OtherAbilitiesEventReceiver::OtherAbilitiesEventReceiver(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { } @@ -1418,18 +1355,13 @@ int OtherAbilitiesEventReceiver::receiveEvent(WEvent *e) return 0; } -int OtherAbilitiesEventReceiver::testDestroy() -{ - return 0; -} - OtherAbilitiesEventReceiver * OtherAbilitiesEventReceiver::clone() const { return NEW OtherAbilitiesEventReceiver(*this); } MTGBlockRule::MTGBlockRule(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { aType = MTGAbility::MTG_BLOCK_RULE; } @@ -1466,12 +1398,6 @@ int MTGBlockRule::reactToClick(MTGCardInstance * card) return 1; } -//The Block rule is never destroyed -int MTGBlockRule::testDestroy() -{ - return 0; -} - ostream& MTGBlockRule::toString(ostream& out) const { out << "MTGBlockRule ::: ("; @@ -1494,7 +1420,7 @@ int MTGMomirRule::initialized = 0; vector MTGMomirRule::pool[20]; MTGMomirRule::MTGMomirRule(GameObserver* observer, int _id, MTGAllCards * _collection) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { collection = _collection; if (!initialized) @@ -1595,12 +1521,6 @@ int MTGMomirRule::genRandomCreatureId(int convertedCost) return pool[convertedCost][start]; } -//The Momir rule is never destroyed -int MTGMomirRule::testDestroy() -{ - return 0; -} - void MTGMomirRule::Update(float dt) { if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_UNTAP) @@ -1649,7 +1569,7 @@ int MTGStoneHewerRule::initialized = 0; vector MTGStoneHewerRule::pool[20]; MTGStoneHewerRule::MTGStoneHewerRule(GameObserver* observer, int _id, MTGAllCards * _collection) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { collection = _collection; if (!initialized) @@ -1728,12 +1648,6 @@ int MTGStoneHewerRule::genRandomEquipId(int convertedCost) return pool[convertedCost][start]; } -//The StoneHewer is never destroyed -int MTGStoneHewerRule::testDestroy() -{ - return 0; -} - ostream& MTGStoneHewerRule::toString(ostream& out) const { out << "MTGStoneHewerRule ::: pool : " << pool << " ; initialized : " << initialized @@ -1749,7 +1663,7 @@ MTGStoneHewerRule * MTGStoneHewerRule::clone() const //------------------ //Hermit druid mode places a random land from your deck into play during each of your upkeeps MTGHermitRule::MTGHermitRule(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { } @@ -1780,12 +1694,6 @@ int MTGHermitRule::receiveEvent(WEvent * event) return 0; } -//The hermit is never destroyed -int MTGHermitRule::testDestroy() -{ - return 0; -} - MTGHermitRule * MTGHermitRule::clone() const { return NEW MTGHermitRule(*this); @@ -1793,10 +1701,6 @@ MTGHermitRule * MTGHermitRule::clone() const //-------------------- //HUDDisplay -int HUDDisplay::testDestroy() -{ - return 0; -} void HUDDisplay::Update(float dt) { @@ -1886,7 +1790,7 @@ void HUDDisplay::Render() } } HUDDisplay::HUDDisplay(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { timestamp = 0; popdelay = 2; @@ -1912,7 +1816,7 @@ HUDDisplay * HUDDisplay::clone() const /* Persist */ MTGPersistRule::MTGPersistRule(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { } ; @@ -1962,10 +1866,7 @@ ostream& MTGPersistRule::toString(ostream& out) const out << "MTGPersistRule ::: ("; return MTGAbility::toString(out) << ")"; } -int MTGPersistRule::testDestroy() -{ - return 0; -} + MTGPersistRule * MTGPersistRule::clone() const { return NEW MTGPersistRule(*this); @@ -1975,7 +1876,7 @@ MTGPersistRule * MTGPersistRule::clone() const //handled seperately as a rule since we only want one object to send out events that a card was "vampired". //otherwise vampire event is sent per instance of @vampired on the battlefield, multipling the results. MTGVampireRule::MTGVampireRule(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { } ; @@ -2038,10 +1939,7 @@ ostream& MTGVampireRule::toString(ostream& out) const out << "MTGVampireRule ::: ("; return MTGAbility::toString(out) << ")"; } -int MTGVampireRule::testDestroy() -{ - return 0; -} + MTGVampireRule * MTGVampireRule::clone() const { return NEW MTGVampireRule(*this); @@ -2050,7 +1948,7 @@ MTGVampireRule * MTGVampireRule::clone() const //unearth rule---------------------------------- //if the card leaves play, exile it instead. MTGUnearthRule::MTGUnearthRule(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { } ; @@ -2100,17 +1998,14 @@ ostream& MTGUnearthRule::toString(ostream& out) const out << "MTGUnearthRule ::: ("; return MTGAbility::toString(out) << ")"; } -int MTGUnearthRule::testDestroy() -{ - return 0; -} + MTGUnearthRule * MTGUnearthRule::clone() const { return NEW MTGUnearthRule(*this); } //token clean up MTGTokensCleanup::MTGTokensCleanup(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { } @@ -2131,11 +2026,6 @@ int MTGTokensCleanup::receiveEvent(WEvent * e) return 0; } -int MTGTokensCleanup::testDestroy() -{ - return 0; -} - MTGTokensCleanup * MTGTokensCleanup::clone() const { return NEW MTGTokensCleanup(*this); @@ -2257,7 +2147,7 @@ MTGPlaneWalkerRule * MTGPlaneWalkerRule::clone() const /* Lifelink */ MTGLifelinkRule::MTGLifelinkRule(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { } ; @@ -2278,11 +2168,6 @@ int MTGLifelinkRule::receiveEvent(WEvent * event) return 0; } -int MTGLifelinkRule::testDestroy() -{ - return 0; -} - ostream& MTGLifelinkRule::toString(ostream& out) const { out << "MTGLifelinkRule ::: ("; @@ -2295,7 +2180,7 @@ MTGLifelinkRule * MTGLifelinkRule::clone() const /* Deathtouch */ MTGDeathtouchRule::MTGDeathtouchRule(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { } ; @@ -2327,11 +2212,6 @@ int MTGDeathtouchRule::receiveEvent(WEvent * event) return 0; } -int MTGDeathtouchRule::testDestroy() -{ - return 0; -} - MTGDeathtouchRule * MTGDeathtouchRule::clone() const { return NEW MTGDeathtouchRule(*this); @@ -2339,7 +2219,7 @@ MTGDeathtouchRule * MTGDeathtouchRule::clone() const // //kai mod ParentChildRule::ParentChildRule(GameObserver* observer, int _id) : -MTGAbility(observer, _id, NULL) +PermanentAbility(observer, _id) { } ; @@ -2398,10 +2278,7 @@ ostream& ParentChildRule::toString(ostream& out) const out << "ParentChildRule ::: ("; return MTGAbility::toString(out) << ")"; } -int ParentChildRule::testDestroy() -{ - return 0; -} + ParentChildRule * ParentChildRule::clone() const { return NEW ParentChildRule(*this);