From dd054c4963166fd28208ef3ea9d0316cdc42ed07 Mon Sep 17 00:00:00 2001 From: "jean.chalard" Date: Sat, 23 May 2009 08:34:50 +0000 Subject: [PATCH] J : * ostream printing of JGui objects. --- projects/mtg/include/ActionStack.h | 5 + projects/mtg/include/AllAbilities.h | 703 +++++++++++++++++++++- projects/mtg/include/CardDisplay.h | 4 + projects/mtg/include/CardGui.h | 1 + projects/mtg/include/Damage.h | 2 + projects/mtg/include/GameStateMenu.h | 1 + projects/mtg/include/MTGAbility.h | 18 +- projects/mtg/include/MTGGamePhase.h | 1 + projects/mtg/include/MTGRules.h | 22 +- projects/mtg/include/ManaCost.h | 2 + projects/mtg/include/MenuItem.h | 2 + projects/mtg/include/OptionItem.h | 1 + projects/mtg/include/PlayGuiObject.h | 4 + projects/mtg/include/ShopItem.h | 1 + projects/mtg/include/SimpleMenuItem.h | 1 + projects/mtg/include/TextScroller.h | 5 +- projects/mtg/src/ActionStack.cpp | 179 +++--- projects/mtg/src/CardDisplay.cpp | 10 + projects/mtg/src/CardGui.cpp | 6 +- projects/mtg/src/Damage.cpp | 10 + projects/mtg/src/GameStateMenu.cpp | 31 + projects/mtg/src/MTGAbility.cpp | 56 ++ projects/mtg/src/MTGGamePhase.cpp | 5 + projects/mtg/src/MTGGuiPlay.cpp | 836 +++++++++++++------------- projects/mtg/src/MTGRules.cpp | 26 +- projects/mtg/src/ManaCost.cpp | 7 +- projects/mtg/src/MenuItem.cpp | 15 + projects/mtg/src/OptionItem.cpp | 11 + projects/mtg/src/PlayGuiObject.cpp | 23 + projects/mtg/src/ShopItem.cpp | 17 + projects/mtg/src/SimpleMenuItem.cpp | 11 + projects/mtg/src/TextScroller.cpp | 17 +- 32 files changed, 1505 insertions(+), 528 deletions(-) diff --git a/projects/mtg/include/ActionStack.h b/projects/mtg/include/ActionStack.h index 905a70144..51010c208 100644 --- a/projects/mtg/include/ActionStack.h +++ b/projects/mtg/include/ActionStack.h @@ -62,6 +62,7 @@ class NextGamePhase: public Interruptible { public: int resolve(); void Render(); + virtual ostream& toString(ostream& out) const; NextGamePhase(int id); }; @@ -75,6 +76,7 @@ class Spell: public Interruptible, public TargetsList { ~Spell(); int resolve(); void Render(); + virtual ostream& toString(ostream& out) const; }; class StackAbility: public Interruptible { @@ -82,6 +84,7 @@ class StackAbility: public Interruptible { MTGAbility * ability; int resolve(); void Render(); + virtual ostream& toString(ostream& out) const; StackAbility(int id, MTGAbility * _ability); }; @@ -91,6 +94,7 @@ class PutInGraveyard: public Interruptible { int removeFromGame; int resolve(); void Render(); + virtual ostream& toString(ostream& out) const; PutInGraveyard(int id, MTGCardInstance * _card); }; @@ -101,6 +105,7 @@ class DrawAction: public Interruptible { Player * player; int resolve(); void Render(); + virtual ostream& toString(ostream& out) const; DrawAction(int id, Player * _player, int _nbcards); }; diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 527d3cd8f..abb5d371d 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -68,10 +68,20 @@ public: game->addObserver(ability); return ability->reactToTargetClick(object); } - + ~MayAbility(){ if (deleteAbility) SAFE_DELETE(ability); } + + virtual ostream& toString(ostream& out) const + { + out << "MayAbility ::: triggered : " << triggered + << " ; ability : " << ability + << " ; deleteAbility : " << deleteAbility + << " ("; + return MTGAbility::toString(out) << ")"; + } + }; @@ -117,6 +127,13 @@ public: delete events[i]; } } + virtual ostream& toString(ostream& out) const + { + out << "MultiAbility ::: abilities : ?" // << abilities + << " ; events : ?" // << events + << " ("; + return ActivatedAbility::toString(out) << ")"; + } }; @@ -143,6 +160,13 @@ class ADrawer:public ActivatedAbility{ OutputDebugString("Deleting ADrawer\n"); } + virtual ostream& toString(ostream& out) const + { + out << "ADrawer ::: nbcards : " << nbcards + << " ("; + return ActivatedAbility::toString(out) << ")"; + } + }; // Gives/Takes Life to controller of source @@ -157,14 +181,17 @@ class ALifeGiver:public ActivatedAbility{ return 1; } - - const char * getMenuText(){ if (life < 0) return "Lose life"; return "Gain life"; } - + virtual ostream& toString(ostream& out) const + { + out << "ALifeGiver ::: life : " << life + << " ("; + return ActivatedAbility::toString(out) << ")"; + } }; class ATokenCreator:public ActivatedAbility{ @@ -225,12 +252,24 @@ public: source->controller()->game->stack->addCard(myToken); Spell * spell = NEW Spell(myToken); - + spell->resolve(); delete spell; return 1; } + virtual ostream& toString(ostream& out) const + { + out << "ATokenCreator ::: abilities : ?" // << abilities + << " ; types : ?" // << types + << " ; colors : ?" // << colors + << " ; power : " << power + << " ; toughness : " << toughness + << " ; name : " << name + << " ("; + return ActivatedAbility::toString(out) << ")"; + } + }; //Moves Cards from a zone to another @@ -256,7 +295,7 @@ public: if (destZone == g->players[i]->game->inPlay){ MTGCardInstance * copy = g->players[i]->game->putInZone(_target, fromZone, g->players[i]->game->stack); Spell * spell = NEW Spell(copy); - + spell->resolve(); delete spell; return 1; @@ -271,8 +310,15 @@ public: int resolve(){ MTGCardInstance * _target = tc->getNextCardTarget(); - return moveTarget(_target,destinationZone, source); + return moveTarget(_target,destinationZone, source); } + virtual ostream& toString(ostream& out) const + { + out << "AZoneMover ::: destinationZone : " << destinationZone + << " ("; + return TargetAbility::toString(out) << ")"; + } + }; @@ -299,18 +345,24 @@ public: if (destZone == game->players[i]->game->inPlay){ MTGCardInstance * copy = game->players[i]->game->putInZone(_target, fromZone, game->players[i]->game->stack); Spell * spell = NEW Spell(copy); - + spell->resolve(); delete spell; return 1; } - } + } p->game->putInZone(_target,fromZone,destZone); } return 1; } return 0; } + virtual ostream& toString(ostream& out) const + { + out << "AZoneSelfMover ::: destinationZone : " << destinationZone + << " ("; + return ActivatedAbility::toString(out) << ")"; + } }; @@ -333,6 +385,11 @@ class ACopier:public TargetAbility{ const char * getMenuText(){ return "Copy"; } + virtual ostream& toString(ostream& out) const + { + out << "ACopier ::: ("; + return TargetAbility::toString(out) << ")"; + } }; @@ -343,7 +400,7 @@ class AAllDestroyer:public ActivatedAbility{ int bury; AAllDestroyer(int _id, MTGCardInstance * _source, TargetChooser * _tc, int _bury = 0, ManaCost * _cost=NULL,int doTap =1):ActivatedAbility(_id,_source,_cost,0,doTap),bury(_bury){ tc = _tc; - + } int resolve(){ @@ -356,6 +413,13 @@ class AAllDestroyer:public ActivatedAbility{ return "Destroy All..."; } + virtual ostream& toString(ostream& out) const + { + out << "AAllDestroyer ::: bury : " << bury + << " ("; + return ActivatedAbility::toString(out) << ")"; + } + }; //Destroyer. TargetAbility @@ -383,6 +447,12 @@ class ADestroyer:public TargetAbility{ return "Destroy"; } + virtual ostream& toString(ostream& out) const + { + out << "ADestroyer ::: bury : " << bury + << " ("; + return TargetAbility::toString(out) << ")"; + } }; //Destroyer. TargetAbility @@ -394,6 +464,12 @@ class ABurier:public ADestroyer{ const char * getMenuText(){ return "Bury"; } + + virtual ostream& toString(ostream& out) const + { + out << "ABurier ::: ("; + return ADestroyer::toString(out) << ")"; + } }; @@ -422,6 +498,15 @@ class ABasicAbilityModifier:public MTGAbility{ return 0; } } + + virtual ostream& toString(ostream& out) const + { + out << "ABasicAbilityModifier ::: modifier : " << modifier + << " ; ability : " << ability + << " ; value_before_modification : " << value_before_modification + << " ("; + return MTGAbility::toString(out) << ")"; + } }; //Modifies an ability until end of turn. Needs a target @@ -467,6 +552,16 @@ class ABasicAbilityModifierUntilEOT:public TargetAbility{ return Constants::MTGBasicAbilities[ability]; } + virtual ostream& toString(ostream& out) const + { + out << "ABasicAbilityModifierUntilEOT ::: mTargets : " << mTargets + << " ; nbTargets : " << nbTargets + << " ; modifier : " << modifier + << " ; stateBeforeActivation : " << stateBeforeActivation + << " ; ability : " << ability + << " ("; + return TargetAbility::toString(out) << ")"; + } }; @@ -484,6 +579,13 @@ class AInstantBasicAbilityModifierUntilEOT: public InstantAbility{ ((MTGCardInstance *)target)->basicAbilities[ability] = stateBeforeActivation; return 1; } + virtual ostream& toString(ostream& out) const + { + out << "ABasicAbilityModifierUntilEOT ::: stateBeforeActivation : " << stateBeforeActivation + << " ability : " << ability + << " ("; + return InstantAbility::toString(out) << ")"; + } }; @@ -517,6 +619,15 @@ class ABasicAbilityAuraModifierUntilEOT: public ActivatedAbility{ return Constants::MTGBasicAbilities[ability]; } + virtual ostream& toString(ostream& out) const + { + out << "ABasicAbilityAuraModifierUntilEOT ::: stateBeforeActivation : " << stateBeforeActivation + << " ; ability : " << ability + << " ; value : " << value + << " ("; + return ActivatedAbility::toString(out) << ")"; + } + }; @@ -559,6 +670,17 @@ class ASpellCastLife:public MTGAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "ASpellCastLife ::: trigger : ? " // << trigger + << " ; cost : " << cost + << " ; life : " << life + << " ; lastUsedOn : " << lastUsedOn + << " ; lastChecked : " << lastChecked + << " ("; + return MTGAbility::toString(out) << ")"; + } + }; //Allows to untap at any moment for an amount of mana @@ -584,6 +706,14 @@ class AUnBlocker:public MTGAbility{ _card->untap(); return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AUnBlocker ::: cost : " << cost + << " ("; + return MTGAbility::toString(out) << ")"; + } + }; //Allows to untap target card once per turn for a manaCost @@ -611,6 +741,15 @@ class AUntaperOnceDuringTurn:public AUnBlocker{ untappedThisTurn = 1; return AUnBlocker::reactToClick(card); } + + virtual ostream& toString(ostream& out) const + { + out << "AUntaperOnceDuringTurn ::: untappedThisTurn : " << untappedThisTurn + << " ; onlyPlayerTurn : " << onlyPlayerTurn + << " ("; + return AUnBlocker::toString(out) << ")"; + } + }; //Alteration of Power and Toughness (enchantments) @@ -627,6 +766,13 @@ class APowerToughnessModifier: public MTGAbility{ ((MTGCardInstance *)target)->addToToughness(-toughness); return 1; } + virtual ostream& toString(ostream& out) const + { + out << "APowerToughnessModifier ::: power : " << power + << " ; toughness : " << toughness + << " ("; + return MTGAbility::toString(out) << ")"; + } }; // Permanent life alteration evry turn of the target's controller. Useful only for unstable mutation currently @@ -643,6 +789,14 @@ class APowerToughnessModifierRegularCounter:public MTGAbility{ ((MTGCardInstance *)target)->addToToughness(toughness); } } + virtual ostream& toString(ostream& out) const + { + out << "APowerToughnessModifierRegularCounter ::: power : " << power + << " ; toughness : " << toughness + << " ; phase : " << phase + << " ("; + return MTGAbility::toString(out) << ")"; + } }; @@ -687,6 +841,16 @@ class ATargetterPowerToughnessModifierUntilEOT: public TargetAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "ATargetterPowerToughnessModifierUntilEOT ::: mTargets : " << mTargets + << " ; nbTargets : " << nbTargets + << " ; power : " << power + << " ; toughness : " << toughness + << " ("; + return TargetAbility::toString(out) << ")"; + } + }; @@ -728,6 +892,15 @@ class APowerToughnessModifierUntilEndOfTurn: public ActivatedAbility{ counters++; return 1; } + virtual ostream& toString(ostream& out) const + { + out << "APowerToughnessModifierUntilEndOfTurn ::: power : " << power + << " ; toughness : " << toughness + << " ; counters : " << counters + << " ; maxcounters : " << maxcounters + << " ("; + return ActivatedAbility::toString(out) << ")"; + } }; @@ -750,7 +923,16 @@ class AInstantPowerToughnessModifierUntilEOT: public InstantAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "APowerToughnessModifierUntilEndOfTurn ::: power : " << power + << " ; toughness : " << toughness + << " ("; + return InstantAbility::toString(out) << ")"; + } }; + + //Untap Blockers with simple Mana Mechanism class AUntapManaBlocker: public Blocker{ public: @@ -759,6 +941,11 @@ class AUntapManaBlocker: public Blocker{ AUntapManaBlocker(int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost):Blocker(id, card,_target, _cost){ } + virtual ostream& toString(ostream& out) const + { + out << "AUntapManaBlocker ::: ("; + return Blocker::toString(out) << ")"; + } }; /* Spell Counters (Enchantment) for a mana cost */ @@ -777,6 +964,11 @@ class ASpellCounterEnchantment:public TargetAbility{ } return 0; } + virtual ostream& toString(ostream& out) const + { + out << "ASpellCounterEnchantment ::: ("; + return TargetAbility::toString(out) << ")"; + } }; @@ -794,6 +986,11 @@ class ACircleOfProtection: public TargetAbility{ game->mLayers->stackLayer()->Fizzle(damage); return 1; } + virtual ostream& toString(ostream& out) const + { + out << "ACircleOfProtection ::: ("; + return TargetAbility::toString(out) << ")"; + } }; //Basic regeneration mechanism for a Mana cost @@ -824,6 +1021,11 @@ class AStandardRegenerate:public ActivatedAbility{ return "Regenerate"; } + virtual ostream& toString(ostream& out) const + { + out << "AStandardRegenerate ::: ("; + return ActivatedAbility::toString(out) << ")"; + } }; /*Gives protection to a target */ @@ -852,6 +1054,12 @@ class AProtectionFrom:public MTGAbility{ delete(cd); } + virtual ostream& toString(ostream& out) const + { + out << "AProtectionFrom ::: cd : " << cd + << " ("; + return MTGAbility::toString(out) << ")"; + } }; //Aura Enchantments that provide controller of target life or damages at a given phase of their turn @@ -874,6 +1082,14 @@ class ARegularLifeModifierAura:public MTGAbility{ } } } + virtual ostream& toString(ostream& out) const + { + out << "ARegularLifeModifierAura ::: life : " << life + << " ; phase : " << phase + << " ; onlyIfTargetTapped : " << onlyIfTargetTapped + << " ("; + return MTGAbility::toString(out) << ")"; + } }; @@ -916,6 +1132,13 @@ class AExalted:public ListMaintainerAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "AExalted ::: power : " << power + << " ; toughness : " << toughness + << " ("; + return ListMaintainerAbility::toString(out) << ")"; + } }; @@ -953,6 +1176,13 @@ class AExaltedAbility:public ListMaintainerAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "AExaltedAbility ::: ability : " << ability + << " ; luckyWinner : " << luckyWinner + << " ("; + return ListMaintainerAbility::toString(out) << ")"; + } }; @@ -983,6 +1213,14 @@ class AConvertLandToCreatures:public ListMaintainerAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "AConvertLandToCreatures ::: power : " << power + << " ; toughness : " << toughness + << " ; type : " << type + << " ("; + return ListMaintainerAbility::toString(out) << ")"; + } }; //Lords (Merfolk lord...) give power and toughness to OTHER creatures of their type, they can give them special abilities, regeneration @@ -1037,6 +1275,17 @@ class ALord:public ListMaintainerAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "ALord ::: power : " << power + << " ; toughness : " << toughness + << " ; ability : " << ability + << " ; modifier : " << modifier + << " ; regenCost : " << regenCost + << " ; includeSelf : " << includeSelf + << " ("; + return ListMaintainerAbility::toString(out) << ")"; + } }; @@ -1050,6 +1299,11 @@ public: if (newPhase == Constants::MTG_PHASE_AFTER_EOT) return 1; return 0; } + virtual ostream& toString(ostream& out) const + { + out << "ALordUEOT ::: ("; + return ALord::toString(out) << ")"; + } }; //Foreach (plague rats...) @@ -1085,6 +1339,15 @@ class AForeach:public ListMaintainerAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "AForeach ::: power : " << power + << " ; toughness : " << toughness + << " ; includeSelf : " << includeSelf + << " ("; + return ListMaintainerAbility::toString(out) << ")"; + } + }; @@ -1106,7 +1369,12 @@ class ADamager:public TargetAbility{ return "Damage target"; } - + virtual ostream& toString(ostream& out) const + { + out << "ADamager ::: damage : " << damage + << " ("; + return TargetAbility::toString(out) << ")"; + } }; /* Can tap a target for a cost */ @@ -1128,6 +1396,12 @@ class ATapper:public TargetAbility{ return "Tap target"; } + virtual ostream& toString(ostream& out) const + { + out << "ATapper ::: damage : " << damage + << " ("; + return TargetAbility::toString(out) << ")"; + } }; //Ability to untap a target @@ -1148,6 +1422,11 @@ class AUntaper:public TargetAbility{ return "Untap target"; } + virtual ostream& toString(ostream& out) const + { + out << "AUntaper ::: ("; + return TargetAbility::toString(out) << ")"; + } }; @@ -1191,6 +1470,16 @@ class ALifeZoneLink:public MTGAbility{ } } } + virtual ostream& toString(ostream& out) const + { + out << "ALifeZoneLink ::: phase : " << phase + << " ; condition : " << condition + << " ; life : " << life + << " ; controller : " << controller + << " ; nbcards : " << nbcards + << " ("; + return MTGAbility::toString(out) << ")"; + } }; //Creatures that cannot attack if opponent has not a given type of land, and die if controller has not this type of land @@ -1215,6 +1504,12 @@ class AStrongLandLinkCreature: public MTGAbility{ player->game->putInGraveyard(source); } } + virtual ostream& toString(ostream& out) const + { + out << "AStrongLandLinkCreature ::: land : " << land + << " ("; + return MTGAbility::toString(out) << ")"; + } }; //Steal control of a target @@ -1234,6 +1529,13 @@ class AControlStealAura: public MTGAbility{ } return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AControlStealAura ::: originalController : " << originalController + << " ("; + return MTGAbility::toString(out) << ")"; + } }; @@ -1258,6 +1560,12 @@ class ATakeControlAura:public MTGAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "ATakeControlAura ::: previousController : " << previousController + << " ("; + return MTGAbility::toString(out) << ")"; + } }; //Creatures that kill their blockers @@ -1295,6 +1603,14 @@ class AOldSchoolDeathtouch:public MTGAbility{ return MTGAbility::testDestroy(); } } + + virtual ostream& toString(ostream& out) const + { + out << "AOldSchoolDeathtouch ::: opponents : " << opponents + << " ; nbOpponents : " << nbOpponents + << " ("; + return MTGAbility::toString(out) << ")"; + } }; @@ -1315,6 +1631,12 @@ class AConvertToCreatureAura:public MTGAbility{ _target->removeType("creature"); return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AConvertToCreatureAura ::: ("; + return MTGAbility::toString(out) << ")"; + } }; /* @@ -1327,6 +1649,7 @@ class AAladdinsLamp: public TargetAbility{ CardDisplay cd; int nbcards; int init; + AAladdinsLamp(int _id, MTGCardInstance * card):TargetAbility(_id,card){ cost = NEW ManaCost(); cost->x(); @@ -1375,7 +1698,14 @@ class AAladdinsLamp: public TargetAbility{ int resolve(){return 1;}; - + virtual ostream& toString(ostream& out) const + { + out << "AAladdinsLamp ::: cd : " << cd + << " ; nbcards : " << nbcards + << " ; init : " << init + << " ("; + return TargetAbility::toString(out) << ")"; + } }; @@ -1408,6 +1738,13 @@ class AAnkhOfMishra: public ListMaintainerAbility{ int removed(MTGCardInstance * card){ return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AAnkhOfMishra ::: init : " << init + << " ("; + return ListMaintainerAbility::toString(out) << ")"; + } }; @@ -1448,6 +1785,14 @@ class AArmageddonClock:public MTGAbility{ counters --; return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AArmageddonClock ::: counters : " << counters + << " ; cost : " << cost + << " ("; + return MTGAbility::toString(out) << ")"; + } }; @@ -1467,6 +1812,13 @@ class ABlackVise: public MTGAbility{ if ( nbcards > 4) game->mLayers->stackLayer()->addDamage(source,game->currentPlayer, nbcards - 4); } } + + virtual ostream& toString(ostream& out) const + { + out << "ABlackVise ::: nbcards : " << nbcards + << " ("; + return MTGAbility::toString(out) << ")"; + } }; @@ -1496,6 +1848,12 @@ class AChannel:public ActivatedAbility{ currentPhase = newPhase; return 0; } + + virtual ostream& toString(ostream& out) const + { + out << "AChannel ::: ("; + return ActivatedAbility::toString(out) << ")"; + } }; @@ -1536,6 +1894,14 @@ class AClockworkBeast:public MTGAbility{ ((MTGCardInstance *)target)->tapped = 1; return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AClockworkBeast ::: counters : " << counters + << " ; cost : " << cost + << " ("; + return MTGAbility::toString(out) << ")"; + } }; //1102: Conservator @@ -1603,6 +1969,13 @@ class AConservator: public MTGAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "AConservator ::: canprevent : " << canprevent + << " ; cost : " << cost + << " ("; + return MTGAbility::toString(out) << ")"; + } }; @@ -1632,6 +2005,12 @@ class ACreatureBond:public MTGAbility{ return 0; } + virtual ostream& toString(ostream& out) const + { + out << "ACreatureBond ::: resolved : " << resolved + << " ("; + return MTGAbility::toString(out) << ")"; + } }; //1105: Dingus Egg @@ -1653,6 +2032,12 @@ class ADingusEgg: public ListMaintainerAbility{ game->mLayers->stackLayer()->addDamage(source,card->controller(), 2); return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "ADingusEgg ::: ("; + return ListMaintainerAbility::toString(out) << ")"; + } }; @@ -1685,7 +2070,11 @@ class ADisruptingScepter:public TargetAbility{ return 1; } - + virtual ostream& toString(ostream& out) const + { + out << "ADisruptingScepter ::: ("; + return TargetAbility::toString(out) << ")"; + } }; @@ -1703,6 +2092,11 @@ class AEbonyHorse:public TargetAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "AEbonyHorse ::: ("; + return TargetAbility::toString(out) << ")"; + } }; //1345 Farmstead @@ -1736,6 +2130,12 @@ class AFarmstead:public ActivatedAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "AFarmstead ::: usedThisTurn : " << usedThisTurn + << " ("; + return ActivatedAbility::toString(out) << ")"; + } }; //1110 Glasses of Urza @@ -1786,6 +2186,13 @@ class AGlassesOfUrza:public MTGAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "AGlassesOfUrza ::: display : " << display + << " ; isActive : " << isActive + << " ("; + return MTGAbility::toString(out) << ")"; + } }; //1112 Howling Mine @@ -1798,6 +2205,12 @@ class AHowlingMine:public MTGAbility{ game->mLayers->stackLayer()->addDraw(game->currentPlayer); } } + + virtual ostream& toString(ostream& out) const + { + out << "AHowlingMine ::: ("; + return MTGAbility::toString(out) << ")"; + } }; //1119 Jayemdae Tome @@ -1812,6 +2225,12 @@ class AJayemdaeTome:public ActivatedAbility{ game->mLayers->stackLayer()->addDraw(source->controller()); return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AJayemdaeTome ::: ("; + return ActivatedAbility::toString(out) << ")"; + } }; @@ -1853,6 +2272,14 @@ class ALivingArtifact:public MTGAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "ALivingArtifact ::: usedThisTurn : " << usedThisTurn + << " ; counters : " << counters + << " ; latest : " << latest + << " ("; + return MTGAbility::toString(out) << ")"; + } }; //Lord of the Pit @@ -1889,6 +2316,12 @@ class ALordOfThePit: public TargetAbility{ return 0; } + virtual ostream& toString(ostream& out) const + { + out << "ALordOfThePit ::: paidThisTurn : " << paidThisTurn + << " ("; + return TargetAbility::toString(out) << ")"; + } }; //1143 Animate Dead class AAnimateDead:public MTGAbility{ @@ -1901,7 +2334,7 @@ class AAnimateDead:public MTGAbility{ MTGCardInstance * copy = source->controller()->game->putInZone(card, _target->controller()->game->graveyard, source->controller()->game->stack); Spell * spell = NEW Spell(copy); //af.addAbilities(game->mLayers->actionLayer()->getMaxId(), spell); - + spell->resolve(); target = spell->source; card = spell->source; @@ -1916,6 +2349,12 @@ class AAnimateDead:public MTGAbility{ card->controller()->game->putInZone(card, card->controller()->game->inPlay,card->owner->game->graveyard); return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AAnimateDead ::: ("; + return MTGAbility::toString(out) << ")"; + } }; @@ -1946,6 +2385,14 @@ class AErgRaiders:public MTGAbility{ } } + + virtual ostream& toString(ostream& out) const + { + out << "AErgRaiders ::: init : " << init + << " ; dealDamage : " << dealDamage + << " ("; + return MTGAbility::toString(out) << ")"; + } }; //Fastbond @@ -1980,6 +2427,14 @@ class AFastbond:public TriggeredAbility{ game->mLayers->stackLayer()->addDamage(source, source->controller(), 1); return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AFastbond ::: alreadyPlayedALand : " << alreadyPlayedALand + << " ; previous : " << previous + << " ("; + return TriggeredAbility::toString(out) << ")"; + } }; @@ -2029,6 +2484,12 @@ class AHypnoticSpecter:public MTGAbility{ } + virtual ostream& toString(ostream& out) const + { + out << "AHypnoticSpecter ::: nbdamagesthisturn : " << nbdamagesthisturn + << " ("; + return MTGAbility::toString(out) << ")"; + } }; //1117 Jandor's Ring @@ -2049,6 +2510,11 @@ class AJandorsRing:public ActivatedAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "AJandorsRing ::: ("; + return ActivatedAbility::toString(out) << ")"; + } }; @@ -2117,7 +2583,12 @@ class AKudzu: public TargetAbility{ return 0; } - + virtual ostream& toString(ostream& out) const + { + out << "AKudzu ::: previouslyTapped : " << previouslyTapped + << " ("; + return TargetAbility::toString(out) << ")"; + } }; //Millstone @@ -2138,6 +2609,11 @@ class AMillstone:public TargetAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "AMillstone ::: ("; + return TargetAbility::toString(out) << ")"; + } }; @@ -2167,6 +2643,11 @@ class APestilence: public ActivatedAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "APestilence ::: ("; + return ActivatedAbility::toString(out) << ")"; + } }; @@ -2215,6 +2696,14 @@ class APowerLeak:public TriggeredAbility{ game->mLayers->stackLayer()->addDamage(source,_target->controller(), damagesToDealThisTurn); return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "APowerLeak ::: damagesToDealThisTurn : " << damagesToDealThisTurn + << " ; cost : " << cost + << " ("; + return TriggeredAbility::toString(out) << ")"; + } }; //Power Surge @@ -2248,6 +2737,13 @@ class APowerSurge:public TriggeredAbility{ totalLands = 0; return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "APowerSurge ::: totalLands : " << totalLands + << " ("; + return TriggeredAbility::toString(out) << ")"; + } }; //1175 Royal Assassin @@ -2266,6 +2762,11 @@ class ARoyalAssassin:public TargetAbility{ return 0; } + virtual ostream& toString(ostream& out) const + { + out << "ARoyalAssassin ::: ("; + return TargetAbility::toString(out) << ")"; + } }; @@ -2286,6 +2787,11 @@ class ASacrifice:public InstantAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "ASacrifice ::: ("; + return InstantAbility::toString(out) << ")"; + } }; //1178 Scavenging Ghoul @@ -2315,6 +2821,12 @@ class AScavengingGhoul:public MTGAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "AScavengingGhoul ::: counters : " << counters + << " ("; + return MTGAbility::toString(out) << ")"; + } }; //1218 Psychic Venom @@ -2333,6 +2845,13 @@ class APsychicVenom:public MTGAbility{ } tapped = newState; } + + virtual ostream& toString(ostream& out) const + { + out << "APsychicVenom ::: tapped : " << tapped + << " ("; + return MTGAbility::toString(out) << ")"; + } }; @@ -2347,6 +2866,12 @@ class ASerendibEfreet:public MTGAbility{ game->mLayers->stackLayer()->addDamage(source,game->currentPlayer,1); } } + + virtual ostream& toString(ostream& out) const + { + out << "ASerendibEfreet ::: ("; + return MTGAbility::toString(out) << ")"; + } }; @@ -2385,6 +2910,12 @@ class AAspectOfWolf:public ListMaintainerAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "AAspectOfWolf ::: color : " << color + << " ("; + return ListMaintainerAbility::toString(out) << ")"; + } }; //1276 Wanderlust, 1148 Cursed Lands @@ -2403,6 +2934,12 @@ class AWanderlust:public TriggeredAbility{ game->mLayers->stackLayer()->addDamage(source,((MTGCardInstance *) target)->controller(),1); return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AWanderlust ::: ("; + return TriggeredAbility::toString(out) << ")"; + } }; @@ -2420,6 +2957,11 @@ class ADragonWhelp: public APowerToughnessModifierUntilEndOfTurn{ APowerToughnessModifierUntilEndOfTurn::Update(dt); } + virtual ostream& toString(ostream& out) const + { + out << "ADragonWhelp ::: ("; + return APowerToughnessModifierUntilEndOfTurn::toString(out) << ")"; + } }; //1288 EarthBind @@ -2428,6 +2970,12 @@ class AEarthbind:public ABasicAbilityModifier{ AEarthbind(int _id, MTGCardInstance * _source, MTGCardInstance * _target):ABasicAbilityModifier(_id,_source,_target,Constants::FLYING,0){ if (value_before_modification) game->mLayers->stackLayer()->addDamage(source,target,2); } + + virtual ostream& toString(ostream& out) const + { + out << "AEarthbind ::: ("; + return ABasicAbilityModifier::toString(out) << ")"; + } }; //1291 Fireball @@ -2443,6 +2991,12 @@ class AFireball:public InstantAbility{ _target = spell->getNextDamageableTarget(_target); } } + + virtual ostream& toString(ostream& out) const + { + out << "AFireball ::: ("; + return InstantAbility::toString(out) << ")"; + } }; //1245 ForceOfNature @@ -2473,6 +3027,13 @@ class AForceOfNature:public ActivatedAbility{ dealDamageThisTurn = 0; return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AForceOfNature ::: dealDamageThisTurn : " << dealDamageThisTurn + << " ("; + return ActivatedAbility::toString(out) << ")"; + } }; @@ -2490,6 +3051,11 @@ class AOrcishArtillery: public ADamager{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "AOrcishArtillery ::: ("; + return ADamager::toString(out) << ")"; + } }; @@ -2528,6 +3094,13 @@ class AIslandSanctuary:public MTGAbility{ initThisTurn = 1; return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AIslandSanctuary ::: initThisTurn : " << initThisTurn + << " ("; + return MTGAbility::toString(out) << ")"; + } }; //1352 Karma @@ -2550,6 +3123,12 @@ class AKarma: public TriggeredAbility{ if (totaldamage) game->mLayers->stackLayer()->addDamage(source,game->currentPlayer, totaldamage); return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AKarma ::: ("; + return TriggeredAbility::toString(out) << ")"; + } }; @@ -2576,6 +3155,14 @@ class ASoulNet:public ActivatedAbility{ source->controller()->life++; return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "ASoulNet ::: latest : " << latest + << " ; newDead : " << newDead + << " ("; + return ActivatedAbility::toString(out) << ")"; + } }; @@ -2622,6 +3209,13 @@ class AStasis:public ActivatedAbility{ } return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AStasis ::: paidThisTurn : " << paidThisTurn + << " ("; + return ActivatedAbility::toString(out) << ")"; + } }; @@ -2648,6 +3242,12 @@ class ADeplete:public TargetAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "ADeplete ::: nbcards : " << nbcards + << " ("; + return TargetAbility::toString(out) << ")"; + } }; @@ -2669,6 +3269,13 @@ class ADiscard:public TargetAbility{ const char * getMenuText(){ return "Discard"; } + + virtual ostream& toString(ostream& out) const + { + out << "ADiscard ::: nbcards : " << nbcards + << " ("; + return TargetAbility::toString(out) << ")"; + } }; // Generic Karma @@ -2693,6 +3300,13 @@ class ADamageForTypeControlled: public TriggeredAbility{ if (totaldamage) game->mLayers->stackLayer()->addDamage(source,game->currentPlayer, totaldamage); return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "ADamageForTypeControlled ::: type : " << type + << " ("; + return TriggeredAbility::toString(out) << ")"; + } }; //ShieldOfTheAge @@ -2708,6 +3322,12 @@ class AShieldOfTheAge: public TargetAbility{ game->mLayers->stackLayer()->Fizzle(damage); return 1; } + + virtual ostream& toString(ostream& out) const + { + out << "AShieldOfTheAge ::: ("; + return TargetAbility::toString(out) << ")"; + } }; // People of the Woods @@ -2731,6 +3351,11 @@ class APeopleOfTheWoods:public ListMaintainerAbility{ return 1; } + virtual ostream& toString(ostream& out) const + { + out << "APeopleOfTheWoods ::: ("; + return ListMaintainerAbility::toString(out) << ")"; + } }; //Abomination Kill blocking creature if white or green @@ -2767,6 +3392,14 @@ class AAbomination :public MTGAbility{ return MTGAbility::testDestroy(); } } + + virtual ostream& toString(ostream& out) const + { + out << "AAbomination ::: opponents : " << opponents + << " ; nbOpponents : " << nbOpponents + << " ("; + return MTGAbility::toString(out) << ")"; + } }; // GiveLifeForTappedType @@ -2798,6 +3431,14 @@ class AGiveLifeForTappedType:public MTGAbility{ } nbtypestapped = newcount; } + + virtual ostream& toString(ostream& out) const + { + out << "AGiveLifeForTappedType ::: type : " << type + << " ; nbtypestapped : " << nbtypestapped + << " ("; + return MTGAbility::toString(out) << ")"; + } }; //Minion of Leshrac @@ -2835,6 +3476,12 @@ class AMinionofLeshrac: public TargetAbility{ return 0; } + virtual ostream& toString(ostream& out) const + { + out << "AMinionofLeshrac ::: paidThisTurn : " << paidThisTurn + << " ("; + return TargetAbility::toString(out) << ")"; + } }; @@ -2884,8 +3531,18 @@ class AKirdApe:public ListMaintainerAbility{ } return 0; } - + + virtual ostream& toString(ostream& out) const + { + out << "AKirdApe ::: power : " << power + << " ; toughness : " << toughness + << " ; ability : " << ability + << " ; modifier : " << modifier + << " ; includeSelf : " << includeSelf + << " ("; + return ListMaintainerAbility::toString(out) << ")"; + } }; //Rampage ability @@ -2896,6 +3553,7 @@ class ARampageAbility:public MTGAbility{ int PowerModifier; int ToughnessModifier; int MaxOpponent; + ARampageAbility(int _id, MTGCardInstance * _source,int _PowerModifier, int _ToughnessModifier, int _MaxOpponent):MTGAbility(_id, _source){ PowerModifier = _PowerModifier; ToughnessModifier = _ToughnessModifier; @@ -2914,7 +3572,7 @@ class ARampageAbility:public MTGAbility{ if (nbOpponents > MaxOpponent){ source->power+= PowerModifier; source->addToToughness(ToughnessModifier); - + } } } @@ -2925,6 +3583,17 @@ class ARampageAbility:public MTGAbility{ } } } + + virtual ostream& toString(ostream& out) const + { + out << "ARampageAbility ::: opponents : " << opponents + << " ; nbOpponents : " << nbOpponents + << " ; PowerModifier : " << PowerModifier + << " ; ToughnessModifier : " << ToughnessModifier + << " ; MaxOpponent : " << MaxOpponent + << " ("; + return MTGAbility::toString(out) << ")"; + } }; #endif diff --git a/projects/mtg/include/CardDisplay.h b/projects/mtg/include/CardDisplay.h index 8c4e90fa1..45a4b2184 100644 --- a/projects/mtg/include/CardDisplay.h +++ b/projects/mtg/include/CardDisplay.h @@ -20,6 +20,7 @@ class CardDisplay:public PlayGuiObjectController{ bool CheckUserInput(u32 key); void Render(); void init(MTGGameZone * zone); + virtual ostream& toString(ostream& out) const; }; @@ -29,4 +30,7 @@ class DefaultTargetDisplay:CardDisplay{ DefaultTargetDisplay(int id, GameObserver* _game, int _x, int _y, JGuiListener * _listener, int _nb_displayed_items ); ~DefaultTargetDisplay(); }; + +std::ostream& operator<<(std::ostream& out, const CardDisplay& m); + #endif diff --git a/projects/mtg/include/CardGui.h b/projects/mtg/include/CardGui.h index fa8a3439f..672b8f66c 100644 --- a/projects/mtg/include/CardGui.h +++ b/projects/mtg/include/CardGui.h @@ -20,6 +20,7 @@ class CardGui: public PlayGuiObject{ CardGui(int id, MTGCardInstance * _card, float desiredHeight, float _x=0, float _y=0, bool hasFocus = false); virtual void Render(); virtual void Update(float dt); + virtual ostream& toString(ostream& out) const; void RenderBig(float x=-1, float y = -1, int alternate = 0); static void alternateRender(MTGCard * card, JQuad ** manaIcons, float x, float y, float rotation= 0, float scale=1); diff --git a/projects/mtg/include/Damage.h b/projects/mtg/include/Damage.h index 41f1e9253..c20b97ce1 100644 --- a/projects/mtg/include/Damage.h +++ b/projects/mtg/include/Damage.h @@ -36,6 +36,7 @@ class Damage: public Interruptible { Damage(int id, MTGCardInstance* _source, Damageable * _target); Damage(int id, MTGCardInstance* _source, Damageable * _target, int _damage); int resolve(); + virtual ostream& toString(ostream& out) const; }; @@ -49,6 +50,7 @@ class DamageStack :public GuiLayer, public Interruptible{ void Render(); int CombatDamages();//Deprecated ? int CombatDamages(int strike); + virtual ostream& toString(ostream& out) const; DamageStack(int id, GameObserver* _game); }; diff --git a/projects/mtg/include/GameStateMenu.h b/projects/mtg/include/GameStateMenu.h index 64ed07939..624230053 100644 --- a/projects/mtg/include/GameStateMenu.h +++ b/projects/mtg/include/GameStateMenu.h @@ -54,6 +54,7 @@ class GameStateMenu: public GameState, public JGuiListener int nextCardSet(); // Retrieves the next set subfolder automatically void createUsersFirstDeck(int setId); + virtual ostream& toString(ostream& out) const; }; #endif diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index 50cc9c652..2e09c43d6 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -25,8 +25,8 @@ using std::map; //Two stupid variables used to give a hint to the AI: // Should I cast a spell on an enemy or friendly unit ? -#define BAKA_EFFECT_GOOD 1 -#define BAKA_EFFECT_BAD -1 +#define BAKA_EFFECT_GOOD 1 +#define BAKA_EFFECT_BAD -1 #define BAKA_EFFECT_DONTKNOW 0 #define COUNT_POWER 1 @@ -38,7 +38,7 @@ using std::map; class MTGAbility: public ActionElement{ protected: char menuText[25]; - + GameObserver * game; public: int forceDestroy; @@ -58,6 +58,7 @@ class MTGAbility: public ActionElement{ virtual int fireAbility(); virtual int stillInUse(MTGCardInstance * card){if (card==source) return 1; return 0;}; virtual int resolve(){return 0;}; + virtual ostream& toString(ostream& out) const; /*Poor man's casting */ /* Todo replace that crap with dynamic casting */ @@ -70,7 +71,6 @@ class MTGAbility: public ActionElement{ PUT_INTO_PLAY = 5, MOMIR = 6, MTG_BLOCK_RULE = 7, - }; }; @@ -83,6 +83,7 @@ class TriggeredAbility:public MTGAbility{ virtual void Render(){}; virtual int trigger()=0; virtual int resolve() = 0; + virtual ostream& toString(ostream& out) const; }; @@ -95,6 +96,7 @@ class ActivatedAbility:public MTGAbility{ virtual int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); virtual int reactToTargetClick(Targetable * object); virtual int resolve() = 0; + virtual ostream& toString(ostream& out) const; }; class TargetAbility:public ActivatedAbility{ @@ -105,6 +107,7 @@ class TargetAbility:public ActivatedAbility{ virtual int reactToClick(MTGCardInstance * card); virtual int reactToTargetClick(Targetable * object); virtual void Render(); + virtual ostream& toString(ostream& out) const; }; class InstantAbility:public MTGAbility{ @@ -115,6 +118,7 @@ class InstantAbility:public MTGAbility{ InstantAbility(int _id, MTGCardInstance * source); InstantAbility(int _id, MTGCardInstance * source,Damageable * _target); virtual int resolve(){return 0;}; + virtual ostream& toString(ostream& out) const; }; /* State based effects. This class works ONLY for InPlay and needs to be extended for other areas of the game !!! */ @@ -129,6 +133,7 @@ class ListMaintainerAbility:public MTGAbility{ virtual int added(MTGCardInstance * card) = 0; virtual int removed(MTGCardInstance * card) = 0; virtual int destroy(); + virtual ostream& toString(ostream& out) const; }; /* An attempt to globalize triggered abilities as much as possible */ @@ -234,7 +239,7 @@ class AbilityFactory{ class AManaProducer: public MTGAbility{ protected: - + ManaCost * cost; ManaCost * output; string menutext; @@ -255,9 +260,10 @@ class AManaProducer: public MTGAbility{ const char * getMenuText(); int testDestroy(); ~AManaProducer(); + virtual ostream& toString(ostream& out) const; }; #include "MTGCardInstance.h" #endif - + diff --git a/projects/mtg/include/MTGGamePhase.h b/projects/mtg/include/MTGGamePhase.h index 9e59a1c58..9cf5c4530 100644 --- a/projects/mtg/include/MTGGamePhase.h +++ b/projects/mtg/include/MTGGamePhase.h @@ -18,6 +18,7 @@ class MTGGamePhase: public ActionElement { virtual void Render(); virtual void Update(float dt); bool CheckUserInput(u32 key); + virtual ostream& toString(ostream& out) const; }; diff --git a/projects/mtg/include/MTGRules.h b/projects/mtg/include/MTGRules.h index 7c0aecfda..0c6caed8a 100644 --- a/projects/mtg/include/MTGRules.h +++ b/projects/mtg/include/MTGRules.h @@ -13,9 +13,9 @@ class MTGPutInPlayRule:public MTGAbility{ int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); int testDestroy(); + virtual ostream& toString(ostream& out) const; MTGPutInPlayRule(int _id); const char * getMenuText(){return "Put into play";} - }; class MTGAttackRule:public MTGAbility{ @@ -23,10 +23,10 @@ class MTGAttackRule:public MTGAbility{ int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); int testDestroy(); + virtual ostream& toString(ostream& out) const; MTGAttackRule(int _id); const char * getMenuText(){return "Attacker";} void Update(float dt); - }; class MTGBlockRule:public MTGAbility{ @@ -34,6 +34,7 @@ class MTGBlockRule:public MTGAbility{ int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int reactToClick(MTGCardInstance * card); int testDestroy(); + virtual ostream& toString(ostream& out) const; MTGBlockRule(int _id); const char * getMenuText(){return "Blocker";} }; @@ -78,8 +79,12 @@ OutputDebugString("Receive5\n"); return 0; } + virtual ostream& toString(ostream& out) const + { + out << "MTGPersistRule ::: ("; + return MTGAbility::toString(out) << ")"; + } int testDestroy(){return 0;} - }; @@ -119,6 +124,11 @@ class MTGLegendRule:public ListMaintainerAbility{ int removed(MTGCardInstance * card){return 0;} int testDestroy(){return 0;} + + virtual ostream& toString(ostream& out) const + { + return out << "MTGLegendRule :::"; + } }; @@ -143,6 +153,7 @@ public: int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card, int id); const char * getMenuText(){return "Momir";} + virtual ostream& toString(ostream& out) const; }; @@ -166,6 +177,11 @@ class MTGLifelinkRule:public MTGAbility{ int testDestroy(){return 0;} + virtual ostream& toString(ostream& out) const + { + out << "MTGLifelinkRule ::: ("; + return MTGAbility::toString(out) << ")"; + } }; diff --git a/projects/mtg/include/ManaCost.h b/projects/mtg/include/ManaCost.h index 02b5a8c94..c4f823cba 100644 --- a/projects/mtg/include/ManaCost.h +++ b/projects/mtg/include/ManaCost.h @@ -64,4 +64,6 @@ class ManaCost{ #endif }; +std::ostream& operator<<(std::ostream& out, const ManaCost& m); + #endif diff --git a/projects/mtg/include/MenuItem.h b/projects/mtg/include/MenuItem.h index 474a7a9b0..caad523c3 100644 --- a/projects/mtg/include/MenuItem.h +++ b/projects/mtg/include/MenuItem.h @@ -39,6 +39,8 @@ class MenuItem: public JGuiObject virtual void Entering(); virtual bool Leaving(u32 key); virtual bool ButtonPressed(); + + virtual ostream& toString(ostream& out) const; }; #endif diff --git a/projects/mtg/include/OptionItem.h b/projects/mtg/include/OptionItem.h index 2ed4a20de..509c95a94 100644 --- a/projects/mtg/include/OptionItem.h +++ b/projects/mtg/include/OptionItem.h @@ -22,6 +22,7 @@ class OptionItem:public JGuiObject{ virtual bool Leaving(); void setData(); virtual void updateValue(){value+=increment; if (value>maxValue) value=0;}; + virtual ostream& toString(ostream& out) const; }; class OptionsList{ diff --git a/projects/mtg/include/PlayGuiObject.h b/projects/mtg/include/PlayGuiObject.h index 67f1ed5a0..40e97c39b 100644 --- a/projects/mtg/include/PlayGuiObject.h +++ b/projects/mtg/include/PlayGuiObject.h @@ -47,6 +47,7 @@ class GuiAvatar: public PlayGuiObject{ Player * player; virtual void Render(); GuiAvatar(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * _player); + virtual ostream& toString(ostream& out) const; }; class GuiGameZone: public PlayGuiObject{ @@ -62,16 +63,19 @@ class GuiGameZone: public PlayGuiObject{ ~GuiGameZone(); virtual void ButtonPressed(int controllerId, int controlId); void toggleDisplay(); + virtual ostream& toString(ostream& out) const; }; class GuiGraveyard: public GuiGameZone{ public: GuiGraveyard(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * player); + virtual ostream& toString(ostream& out) const; }; class GuiLibrary: public GuiGameZone{ public: GuiLibrary(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * player); + virtual ostream& toString(ostream& out) const; }; diff --git a/projects/mtg/include/ShopItem.h b/projects/mtg/include/ShopItem.h index 1c7fa9cb3..52500e199 100644 --- a/projects/mtg/include/ShopItem.h +++ b/projects/mtg/include/ShopItem.h @@ -46,6 +46,7 @@ class ShopItem:public JGuiObject{ virtual bool ButtonPressed(); const char * getText(); + virtual ostream& toString(ostream& out) const; }; class ShopItems:public JGuiController,public JGuiListener{ diff --git a/projects/mtg/include/SimpleMenuItem.h b/projects/mtg/include/SimpleMenuItem.h index fdba3118b..7da901824 100644 --- a/projects/mtg/include/SimpleMenuItem.h +++ b/projects/mtg/include/SimpleMenuItem.h @@ -40,6 +40,7 @@ class SimpleMenuItem: public JGuiObject virtual void Entering(); virtual bool Leaving(u32 key); virtual bool ButtonPressed(); + virtual ostream& toString(ostream& out) const; }; #endif diff --git a/projects/mtg/include/TextScroller.h b/projects/mtg/include/TextScroller.h index 2d9ae95c9..f3c8f6fc5 100644 --- a/projects/mtg/include/TextScroller.h +++ b/projects/mtg/include/TextScroller.h @@ -19,7 +19,7 @@ private: float start; int timer; vector strings; - int currentId; + unsigned int currentId; int mRandom; public: void Add(string text); @@ -28,6 +28,7 @@ public: TextScroller(JLBFont * font, float x, float y, float width, float speed = 30); void Render(); void Update(float dt); + virtual ostream& toString(ostream& out) const; }; -#endif \ No newline at end of file +#endif diff --git a/projects/mtg/src/ActionStack.cpp b/projects/mtg/src/ActionStack.cpp index 316e4aa07..d09400328 100644 --- a/projects/mtg/src/ActionStack.cpp +++ b/projects/mtg/src/ActionStack.cpp @@ -7,8 +7,8 @@ #include "../include/GameObserver.h" #include "../include/Damage.h" #include "../include/ManaCost.h" -#include "../include/GameOptions.h" -// WALDORF - added to support drawing big cards during interrupts +#include "../include/GameOptions.h" +// WALDORF - added to support drawing big cards during interrupts #include "../include/CardGui.h" #include "../include/Translate.h" @@ -38,6 +38,11 @@ NextGamePhase::NextGamePhase(int id): Interruptible(id){ type = ACTION_NEXTGAMEPHASE; } +ostream& NextGamePhase::toString(ostream& out) const +{ + out << "NextGamePhase ::: "; + return out; +} /* Ability */ int StackAbility::resolve(){ @@ -64,6 +69,11 @@ StackAbility::StackAbility(int id,MTGAbility * _ability): Interruptible(id),abil type=ACTION_ABILITY; } +ostream& StackAbility::toString(ostream& out) const +{ + out << "StackAbility ::: ability : " << ability; + return out; +} /* Spell Cast */ @@ -121,36 +131,36 @@ void Spell::Render(){ }else{ // } - // WALDORF - added these lines to render a big card as well as the small one - // in the interrupt window. A big card will be rendered no matter whether - // the user has been using big cards or not. However, I do take into which - // kind of big card they like. - // The card will be rendered in the same place as the GuiHand - // card. It doesn't attempt to hide the GUIHand card, it - // just overwrites it. - // I stole the render code from RenderBig() in CardGUI.cpp - - quad = source->getQuad(); - if (quad){ - quad->SetColor(ARGB(220,255,255,255)); - float scale = 257.f / quad->mHeight; - renderer->RenderQuad(quad, 10 , 20 , 0.0f,scale,scale); - } - else - { - MTGCard * mtgcard = source->model; - JLBFont * font = GameApp::CommonRes->GetJLBFont("graphics/magic"); - CardGui::alternateRender(mtgcard, NULL, 10 + 90 , 20 + 130, 0.0f,0.9f); - - quad = source->getThumb(); - if (quad){ - float scale = 250 / quad->mHeight; - quad->SetColor(ARGB(40,255,255,255)); - renderer->RenderQuad(quad, 20, 20, 0.0f, scale, scale); - } - } - - // WALDORF - end + // WALDORF - added these lines to render a big card as well as the small one + // in the interrupt window. A big card will be rendered no matter whether + // the user has been using big cards or not. However, I do take into which + // kind of big card they like. + // The card will be rendered in the same place as the GuiHand + // card. It doesn't attempt to hide the GUIHand card, it + // just overwrites it. + // I stole the render code from RenderBig() in CardGUI.cpp + + quad = source->getQuad(); + if (quad){ + quad->SetColor(ARGB(220,255,255,255)); + float scale = 257.f / quad->mHeight; + renderer->RenderQuad(quad, 10 , 20 , 0.0f,scale,scale); + } + else + { + MTGCard * mtgcard = source->model; + JLBFont * font = GameApp::CommonRes->GetJLBFont("graphics/magic"); + CardGui::alternateRender(mtgcard, NULL, 10 + 90 , 20 + 130, 0.0f,0.9f); + + quad = source->getThumb(); + if (quad){ + float scale = 250 / quad->mHeight; + quad->SetColor(ARGB(40,255,255,255)); + renderer->RenderQuad(quad, 20, 20, 0.0f, scale, scale); + } + } + + // WALDORF - end Damageable * target = getNextDamageableTarget(); @@ -167,6 +177,12 @@ void Spell::Render(){ } } +ostream& Spell::toString(ostream& out) const +{ + out << "Spell ::: cost : " << cost; + return out; +} + /* Put a card in graveyard */ @@ -206,6 +222,11 @@ void PutInGraveyard::Render(){ } } +ostream& PutInGraveyard::toString(ostream& out) const +{ + out << "PutInGraveyard ::: removeFromGame : " << removeFromGame; + return out; +} /* Draw a Card */ DrawAction::DrawAction(int id, Player * _player, int _nbcards):Interruptible(id), nbcards(_nbcards), player(_player){ @@ -229,6 +250,12 @@ void DrawAction::Render(){ mFont->DrawString(buffer, x + 20 , y, JGETEXT_LEFT); } +ostream& DrawAction::toString(ostream& out) const +{ + out << "DrawAction ::: nbcards : " << nbcards << " ; player : " << player; + return out; +} + /* The Action Stack itself */ int ActionStack::addPutInGraveyard(MTGCardInstance * card){ PutInGraveyard * death = NEW PutInGraveyard(mCount,card); @@ -445,11 +472,11 @@ void ActionStack::unpackDamageStacks(){ } void ActionStack::repackDamageStacks(){ - std::vector::iterator iter = mObjects.begin() ; - - while( iter != mObjects.end() ){ - Interruptible * action = ((Interruptible *) *iter); - int found = 0; + std::vector::iterator iter = mObjects.begin() ; + + while( iter != mObjects.end() ){ + Interruptible * action = ((Interruptible *) *iter); + int found = 0; if (action->type == ACTION_DAMAGE){ Damage * damage = (Damage *) action; for (int j = 0; j < mCount; j++){ @@ -467,8 +494,8 @@ void ActionStack::repackDamageStacks(){ } } } - } - if (!found) ++iter; + } + if (!found) ++iter; } /* @@ -562,13 +589,13 @@ void ActionStack::Update(float dt){ GuiLayer::Update(dt); } if (askIfWishesToInterrupt){ - // WALDORF - added code to use a game option setting to determine how - // long the Interrupt timer should be. If it is set to zero (0), the - // game will wait for ever for the user to make a selection. - if (GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue() > 0) - { - if (timer < 0) timer = GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue(); - timer -= dt; + // WALDORF - added code to use a game option setting to determine how + // long the Interrupt timer should be. If it is set to zero (0), the + // game will wait for ever for the user to make a selection. + if (GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue() > 0) + { + if (timer < 0) timer = GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue(); + timer -= dt; if (timer < 0) cancelInterruptOffer(); } } @@ -686,17 +713,17 @@ int ActionStack::CombatDamages(int strike){ //Cleans history of last turn int ActionStack::garbageCollect(){ -std::vector::iterator iter = mObjects.begin() ; - -while( iter != mObjects.end() ){ - Interruptible * current = ((Interruptible *) *iter); - if (current->state != NOT_RESOLVED){ - iter = mObjects.erase( iter ) ; +std::vector::iterator iter = mObjects.begin() ; + +while( iter != mObjects.end() ){ + Interruptible * current = ((Interruptible *) *iter); + if (current->state != NOT_RESOLVED){ + iter = mObjects.erase( iter ) ; mCount--; - SAFE_DELETE(current); - }else { - ++iter ; - } + SAFE_DELETE(current); + }else { + ++iter ; + } } return 1; } @@ -756,26 +783,26 @@ void ActionStack::Render(){ } char buffer[200]; - // WALDORF - changed "interrupt ?" to "Interrupt?". Don't display count down - // seconds if the user disables auto progressing interrupts by setting the seconds - // value to zero in Options. - if (GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue() == 0) - sprintf(buffer, _("Interrupt?").c_str()); - else - sprintf(buffer, "%s %i", _("Interrupt?").c_str(),static_cast(timer)); - - //WALDORF - removed all the unnecessary math. just display the prompt at the - // top of the box. - //mFont->DrawString(buffer, x0 + 5 , currenty - 40 - ((Interruptible *)mObjects[mCount-1])->mHeight); - mFont->DrawString(buffer, x0 + 5, y0); - - - if (mCount > 1) sprintf(buffer, _("X Interrupt - 0 No - [] No to All").c_str()); - else sprintf(buffer, _("X Interrupt - 0 No").c_str()); - - // WALDORF - puts the button legend right under the prompt. the stack - // will be displayed below it now. no more need to do wierd currY math. - //mFont->DrawString(buffer, x0 + 5 , currenty); + // WALDORF - changed "interrupt ?" to "Interrupt?". Don't display count down + // seconds if the user disables auto progressing interrupts by setting the seconds + // value to zero in Options. + if (GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue() == 0) + sprintf(buffer, _("Interrupt?").c_str()); + else + sprintf(buffer, "%s %i", _("Interrupt?").c_str(),static_cast(timer)); + + //WALDORF - removed all the unnecessary math. just display the prompt at the + // top of the box. + //mFont->DrawString(buffer, x0 + 5 , currenty - 40 - ((Interruptible *)mObjects[mCount-1])->mHeight); + mFont->DrawString(buffer, x0 + 5, y0); + + + if (mCount > 1) sprintf(buffer, _("X Interrupt - 0 No - [] No to All").c_str()); + else sprintf(buffer, _("X Interrupt - 0 No").c_str()); + + // WALDORF - puts the button legend right under the prompt. the stack + // will be displayed below it now. no more need to do wierd currY math. + //mFont->DrawString(buffer, x0 + 5 , currenty); mFont->DrawString(buffer, x0 + 5, y0 + 14); }else if (mode == ACTIONSTACK_TARGET && modal){ for (int i=0;iGetJLBFont(Constants::MENU_FONT); break; } } + +ostream& GameStateMenu::toString(ostream& out) const +{ + return out << "GameStateMenu ::: scroller : " << scroller + << " ; scrollerSet : " << scrollerSet + << " ; mGuiController : " << mGuiController + << " ; subMenuController : " << subMenuController + << " ; gameTypeMenu : " << gameTypeMenu + << " ; hasChosenGameType : " << hasChosenGameType + << " ; mIcons : " << mIcons + << " ; mIconsTexture : " << mIconsTexture + << " ; bgTexture : " << bgTexture + << " ; movingWTexture : " << movingWTexture + << " ; mBg : " << mBg + << " ; mMovingW : " << mMovingW + << " ; splashTex : " << splashTex + << " ; splashQuad : " << splashQuad + << " ; mCreditsYPos : " << mCreditsYPos + << " ; currentState : " << currentState + << " ; mVolume : " << mVolume + << " ; nbcardsStr : " << nbcardsStr + << " ; mDip : " << mDip + << " ; mDit : " << mDit + << " ; mCurrentSetName : " << mCurrentSetName + << " ; mCurrentSetFileName : " << mCurrentSetFileName + << " ; mReadConf : " << mReadConf + << " ; timeIndex : " << timeIndex + << " ; angleMultiplier : " << angleMultiplier + << " ; angleW : " << angleW + << " ; yW : " << yW; +} diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index ad6d98339..1ecdf8eca 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -1926,6 +1926,17 @@ int MTGAbility::fireAbility(){ return 1; } +ostream& MTGAbility::toString(ostream& out) const +{ + return out << "MTGAbility ::: menuText : " << menuText + << " ; game : " << game + << " ; forceDestroy : " << forceDestroy + << " ; cost : " << cost + << " ; target : " << target + << " ; aType : " << aType + << " ; source : " << source; +} + // ActivatedAbility::ActivatedAbility(int id, MTGCardInstance * card, ManaCost * _cost, int _playerturnonly,int tap):MTGAbility(id,card), playerturnonly(_playerturnonly), needsTapping(tap){ @@ -1989,6 +2000,13 @@ int ActivatedAbility::reactToTargetClick(Targetable * object){ } +ostream& ActivatedAbility::toString(ostream& out) const +{ + out << "ActivatedAbility ::: playerturnonly : " << playerturnonly + << " ; needsTapping : " << needsTapping + << " ("; + return MTGAbility::toString(out) << ")"; +} //The whole targetAbility mechanism is messed up, mainly because of its interactions with @@ -2057,6 +2075,11 @@ void TargetAbility::Render(){ //TODO ? } +ostream& TargetAbility::toString(ostream& out) const +{ + out << "TargetAbility ::: ("; + return ActivatedAbility::toString(out) << ")"; +} // @@ -2072,6 +2095,11 @@ void TriggeredAbility::Update(float dt){ if (trigger()) fireAbility(); } +ostream& TriggeredAbility::toString(ostream& out) const +{ + out << "TriggeredAbility ::: ("; + return MTGAbility::toString(out) << ")"; +} // @@ -2110,6 +2138,13 @@ int InstantAbility::testDestroy(){ } +ostream& InstantAbility::toString(ostream& out) const +{ + out << "InstantAbility ::: init : " << init + << " ("; + return MTGAbility::toString(out) << ")"; +} + void ListMaintainerAbility::Update(float dt){ map::iterator it=cards.begin(); @@ -2167,6 +2202,12 @@ int ListMaintainerAbility::destroy(){ return 1; } +ostream& ListMaintainerAbility::toString(ostream& out) const +{ + out << "ListMaintainerAbility ::: ("; + return MTGAbility::toString(out) << ")"; +} + /* An attempt to globalize triggered abilities as much as possible */ @@ -2461,3 +2502,18 @@ other solutions need to be provided for abilities that add mana (ex: mana flare) } int AManaProducer::currentlyTapping = 0; + +ostream& AManaProducer::toString(ostream& out) const +{ + out << "AManaProducer ::: cost : " << cost + << " ; output : " << output + << " ; menutext : " << menutext + << " ; x0,y0 : " << x0 << "," << y0 + << " ; x1,y1 : " << x1 << "," << y1 + << " ; x,y : " << x << "," << y + << " ; animation : " << animation + << " ; controller : " << controller + << " ; tap : " << tap + << " ("; + return MTGAbility::toString(out) << ")"; +} diff --git a/projects/mtg/src/MTGGamePhase.cpp b/projects/mtg/src/MTGGamePhase.cpp index 9dc77a62a..67b134358 100644 --- a/projects/mtg/src/MTGGamePhase.cpp +++ b/projects/mtg/src/MTGGamePhase.cpp @@ -53,3 +53,8 @@ bool MTGGamePhase::CheckUserInput(u32 key){ } return false; } + +ostream& MTGGamePhase::toString(ostream& out) const +{ + return out << "MTGGamePhase ::: animation " << animation << " ; currentState : " << currentState; +} diff --git a/projects/mtg/src/MTGGuiPlay.cpp b/projects/mtg/src/MTGGuiPlay.cpp index 66c9a0321..a1980d13f 100644 --- a/projects/mtg/src/MTGGuiPlay.cpp +++ b/projects/mtg/src/MTGGuiPlay.cpp @@ -1,427 +1,427 @@ -/* This class handles the display on the main game screen : - cards in play, graveyard, library, games phases, Players avatars -*/ - -#include "../include/config.h" -#include "../include/MTGGuiPlay.h" -#include "../include/MTGCardInstance.h" -#include "../include/CardGui.h" -#include "../include/CardDisplay.h" -#include "../include/Translate.h" - -#define ZX_MAIN 100 -#define ZY_MAIN 22 -#define ZH_CREATURES 50 -#define Z_CARDWIDTH 30 -#define Z_CARDHEIGHT 40 -#define Z_MAIN_NBCARDS 7 -#define Z_SPELLS_NBCARDS 3 -#define ZX_SPELL 450 -#define ZY_SPELL 22 - - - - -MTGGuiPlay::MTGGuiPlay(int id, GameObserver * _game):PlayGuiObjectController(id, _game){ - currentPlayer = NULL; - offset = 0; - - - mPhaseBarTexture = GameApp::CommonRes->GetTexture("graphics/phasebar.png"); - for (int i=0; i < 12; i++){ - phaseIcons[2*i] = NEW JQuad(mPhaseBarTexture, i*28, 0, 28, 28); - phaseIcons[2*i + 1] = NEW JQuad(mPhaseBarTexture, i*28, 28, 28, 28); - } - mGlitter = NEW JQuad(mPhaseBarTexture, 392, 0, 5, 5); - mGlitter->SetHotSpot(2.5,2.5); - mGlitterAlpha = -1; - mFont= GameApp::CommonRes->GetJLBFont("graphics/simon"); - - //load all the icon images +/* This class handles the display on the main game screen : + cards in play, graveyard, library, games phases, Players avatars +*/ + +#include "../include/config.h" +#include "../include/MTGGuiPlay.h" +#include "../include/MTGCardInstance.h" +#include "../include/CardGui.h" +#include "../include/CardDisplay.h" +#include "../include/Translate.h" + +#define ZX_MAIN 100 +#define ZY_MAIN 22 +#define ZH_CREATURES 50 +#define Z_CARDWIDTH 30 +#define Z_CARDHEIGHT 40 +#define Z_MAIN_NBCARDS 7 +#define Z_SPELLS_NBCARDS 3 +#define ZX_SPELL 450 +#define ZY_SPELL 22 + + + + +MTGGuiPlay::MTGGuiPlay(int id, GameObserver * _game):PlayGuiObjectController(id, _game){ + currentPlayer = NULL; + offset = 0; + + + mPhaseBarTexture = GameApp::CommonRes->GetTexture("graphics/phasebar.png"); + for (int i=0; i < 12; i++){ + phaseIcons[2*i] = NEW JQuad(mPhaseBarTexture, i*28, 0, 28, 28); + phaseIcons[2*i + 1] = NEW JQuad(mPhaseBarTexture, i*28, 28, 28, 28); + } + mGlitter = NEW JQuad(mPhaseBarTexture, 392, 0, 5, 5); + mGlitter->SetHotSpot(2.5,2.5); + mGlitterAlpha = -1; + mFont= GameApp::CommonRes->GetJLBFont("graphics/simon"); + + //load all the icon images mIcons[Constants::MTG_COLOR_ARTIFACT] = GameApp::CommonRes->GetQuad("c_artifact"); mIcons[Constants::MTG_COLOR_LAND] = GameApp::CommonRes->GetQuad("c_land"); mIcons[Constants::MTG_COLOR_WHITE] = GameApp::CommonRes->GetQuad("c_white"); mIcons[Constants::MTG_COLOR_RED] = GameApp::CommonRes->GetQuad("c_red"); mIcons[Constants::MTG_COLOR_BLACK] = GameApp::CommonRes->GetQuad("c_black"); mIcons[Constants::MTG_COLOR_BLUE] = GameApp::CommonRes->GetQuad("c_blue"); - mIcons[Constants::MTG_COLOR_GREEN] = GameApp::CommonRes->GetQuad("c_green"); - for (int i=0; i < 7; i++){ - mIcons[i]->SetHotSpot(16,16); - } - - mBgTex = GameApp::CommonRes->GetTexture("graphics/background.png"); - if (mBgTex) mBg = NEW JQuad(mBgTex, 0, 0, 480, 272); - else { - mBg = NULL; - GameApp::systemError = "error Loading Texture mBgTex in MTGGuiPlay intialization"; - } - - mBgTex2 = GameApp::CommonRes->GetTexture("graphics/back.jpg"); - if (mBgTex2){ - mBg2 = NEW JQuad(mBgTex2, 0, 0, 480, 255); - for (int i= 0; i < 4; i++){ - alphaBg[i] = 255; - } - }else{ - mBg2 = NULL; - GameApp::systemError = "error Loading Texture mBgTex2 in MTGGuiPlay intialization"; - } - alphaBg[0] = 0; - AddPlayersGuiInfo(); -} - - -CardGui * MTGGuiPlay::getByCard(MTGCardInstance * card){ - for (int i = offset; i < mCount; i++){ - CardGui * cardg = (CardGui *)mObjects[i]; - if(cardg && cardg->card == card){ - return cardg; - } - } - return NULL; - -} - -void MTGGuiPlay::initCardsDisplay(){ - for (int i = 0; i < SCREEN_WIDTH/5; i++){ - for(int j=0; j < SCREEN_HEIGHT/5; j++){ - cardsGrid[i][j] = NULL; - } - } - cards_x_limit = 12; - nb_creatures = 0; - nb_lands = 0; - nb_spells = 0; -} - - -void MTGGuiPlay::adjustCardPosition(CardGui * cardg){ - int x5 = cardg->x / 5; - int y5 = cardg->y / 5; - - while (cardsGrid[x5][y5] && x5 x = x5 * 5; - cardg->y = y5 * 5; - cardsGrid[x5][y5] = cardg->card; -} - -void MTGGuiPlay::setCardPosition(CardGui * cardg, int player, int playerTurn, int spellMode){ - MTGCardInstance * card = cardg->card; - if (card->target) - return; - if (spellMode && (card->isACreature() || card->hasType("land"))) return; - if (!spellMode && !card->isACreature() && !card->hasType("land")) return; - if (card->isACreature()){ - int x_offset = nb_creatures % cards_x_limit; - int y_offset = nb_creatures / cards_x_limit; - cardg->x= ZX_MAIN + (Z_CARDWIDTH * x_offset); - cardg->y=ZY_MAIN + ZH_CREATURES + (Z_CARDHEIGHT * y_offset) + 100 * (1-player); - nb_creatures++; - - if (playerTurn){ - if (card->isAttacker()){ - cardg->y=122 + 30 * (1-player); - } - }else{ - if (card->isDefenser()){ - CardGui * targetg = getByCard(card->isDefenser()); - if (targetg) cardg->x = targetg->x; - cardg->y=122 + 30 * (1-player); - } - } - - }else if(card->hasType("land")){ - int x_offset = nb_lands % cards_x_limit; - int y_offset = nb_lands/ cards_x_limit; - cardg->x=ZX_MAIN + (Z_CARDWIDTH * x_offset); - cardg->y=ZY_MAIN + (Z_CARDHEIGHT * y_offset) + 200 * (1-player); - nb_lands++; - }else{ - int y_offset = nb_spells % Z_SPELLS_NBCARDS; - int x_offset = nb_spells/ Z_SPELLS_NBCARDS; - cardg->x=ZX_SPELL - (Z_CARDWIDTH * x_offset); - cardg->y=ZY_SPELL + (Z_CARDHEIGHT * y_offset) + 125 * (1-player); - nb_spells++; - cards_x_limit = 12 - (nb_spells + 2)/ Z_SPELLS_NBCARDS; - } - adjustCardPosition(cardg); -} - - -void MTGGuiPlay::setTargettingCardPosition(CardGui * cardg, int player, int playerTurn){ - MTGCardInstance * card = cardg->card; - MTGCardInstance * target = card->target; - if (!target) - return; - CardGui * targetg = getByCard(target); - if (targetg){ - cardg->y=targetg->y + 5; - cardg->x=targetg->x + 5; - } - adjustCardPosition(cardg); - return; -} - -void MTGGuiPlay::forceUpdateCards(){ - GameObserver * game = GameObserver::GetInstance(); - Player * player = game->players[0]; - int player0Mode =(game->currentPlayer == player); - int nb_cards = player->game->inPlay->nb_cards; - resetObjects(); - AddPlayersGuiInfo(); - offset = mCount; - - bool hasFocus = player0Mode; - offset = 6; - - Player * opponent = game->players[1]; - int opponent_cards = opponent ->game->inPlay->nb_cards; - - for (int i = 0;igame->inPlay->cards[i],40, i*35 + 10, 200, hasFocus); - Add(object); - hasFocus = false; - } - hasFocus = !player0Mode; - for (int i = 0;igame->inPlay->cards[i],40, i*35 + 10, 10, hasFocus); - Add(object); - hasFocus = false; - } - - currentPlayer = game->currentPlayer; -} - -void MTGGuiPlay::updateCards(){ - GameObserver * game = GameObserver::GetInstance(); - Player * player = game->players[0]; - int player0Mode =(game->currentPlayer == player); - int nb_cards = player->game->inPlay->nb_cards; - MTGCardInstance * attackers[MAX_ATTACKERS]; - for (int i = 0; i players[1]; - int opponent_cards = opponent ->game->inPlay->nb_cards; - if (mCount - offset != (nb_cards+opponent_cards) || game->currentPlayer != currentPlayer ){ //if the number of cards has changed, then an update occured (is this test engouh ?) - forceUpdateCards(); - } - - - //This is just so that we display the cards of the current player first, so that blockers are correctly positionned - for (int j= 0; j < 2; j++){ - initCardsDisplay(); - if (j != player0Mode){ - for (int i =0; iplayers[0])); - Add(NEW GuiAvatar(-2,50,2,30,false,GameObserver::GetInstance()->players[1])); - - Add(NEW GuiGraveyard(-3,30,40,150,false, GameObserver::GetInstance()->players[0])); - Add(NEW GuiLibrary(-4,30,40,180,false, GameObserver::GetInstance()->players[0])); - - - Add(NEW GuiGraveyard(-5,30,40,30,false, GameObserver::GetInstance()->players[1])); - Add(NEW GuiLibrary(-6,30,40,60,false, GameObserver::GetInstance()->players[1])); - } -} - -void MTGGuiPlay::Update(float dt){ - updateCards(); - PlayGuiObjectController::Update(dt); -} - - - -bool MTGGuiPlay::CheckUserInput(u32 key){ - for (int i = 2; i<6;i++){ - GuiGameZone * zone = (GuiGameZone *)mObjects[i]; - if (zone->showCards){ - return zone->cd->CheckUserInput(key); - } - } - return PlayGuiObjectController::CheckUserInput(key); -} - - -void MTGGuiPlay::RenderPlayerInfo(int playerid){ - JRenderer * r = JRenderer::GetInstance(); - Player * player = GameObserver::GetInstance()->players[playerid]; - - //Avatar - GuiAvatar * avatar = (GuiAvatar *)mObjects[3*playerid]; - avatar->Render(); - - - - //Mana - ManaCost * cost = player->getManaPool(); - int nbicons = 0; - for (int j=0; j<6;j++){ - int value = cost->getCost(j); - for (int i=0; iRenderQuad(mIcons[j],x,y,0,0.5, 0.5); - nbicons++; - } - } -} - - -void MTGGuiPlay::RenderPhaseBar(){ - GameObserver * game = GameObserver::GetInstance(); - JRenderer * renderer = JRenderer::GetInstance(); - int currentPhase = game->getCurrentGamePhase(); - for (int i=0; i < 12; i++){ - int index = 2*i + 1 ; - if (i==currentPhase-1){ - index-=1; - } - renderer->RenderQuad(phaseIcons[index], 200 + 14*i,0,0,0.5,0.5); - } - if (game->currentlyActing()->isAI()){ - mFont->SetColor(ARGB(255,128,128,128)); - }else{ - mFont->SetColor(ARGB(255,255,255,255)); - } - mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); - mFont->DrawString(_(Constants::MTGPhaseNames[currentPhase]).c_str(), 375, 2); -} - -void MTGGuiPlay::Render(){ - LOG("Start MTGGuiPlay Render\n"); - JRenderer * renderer = JRenderer::GetInstance(); - - //alphaBg[1] = 255; - //alphaBg[2]= 255; - //alphaBg[3] = 255; - //mBg2->SetColor(ARGB(alphaBg[0], alphaBg[1],alphaBg[2],alphaBg[3])); - renderer->RenderQuad(mBg2,0,17); - - if (game->currentGamePhase >= Constants::MTG_PHASE_COMBATBEGIN && game->currentGamePhase < Constants::MTG_PHASE_COMBATEND){ - if (alphaBg[0] < 50){ - alphaBg[3]-=12; - alphaBg[2]-=12; - alphaBg[0]+=3; - } - alphaBg[1] = 255; - - }else{ - if (alphaBg[0]){ - alphaBg[0]-=3; - alphaBg[3]+=12; - alphaBg[2]+=12; - } - alphaBg[1] = 255; - } - renderer->FillRect(0,0,480,272,ARGB(alphaBg[0], alphaBg[1],alphaBg[2],alphaBg[3])); - - renderer->RenderQuad(mBg,0,0); - - for (int i=0;iRender(); - } - } - - RenderPhaseBar(); - RenderPlayerInfo(0); - RenderPlayerInfo(1); - - int opponentHand = game->players[1]->game->hand->nb_cards; - char buffer[10]; - sprintf(buffer,"%i",opponentHand); + mIcons[Constants::MTG_COLOR_GREEN] = GameApp::CommonRes->GetQuad("c_green"); + for (int i=0; i < 7; i++){ + mIcons[i]->SetHotSpot(16,16); + } + + mBgTex = GameApp::CommonRes->GetTexture("graphics/background.png"); + if (mBgTex) mBg = NEW JQuad(mBgTex, 0, 0, 480, 272); + else { + mBg = NULL; + GameApp::systemError = "error Loading Texture mBgTex in MTGGuiPlay intialization"; + } + + mBgTex2 = GameApp::CommonRes->GetTexture("graphics/back.jpg"); + if (mBgTex2){ + mBg2 = NEW JQuad(mBgTex2, 0, 0, 480, 255); + for (int i= 0; i < 4; i++){ + alphaBg[i] = 255; + } + }else{ + mBg2 = NULL; + GameApp::systemError = "error Loading Texture mBgTex2 in MTGGuiPlay intialization"; + } + alphaBg[0] = 0; + AddPlayersGuiInfo(); +} + + +CardGui * MTGGuiPlay::getByCard(MTGCardInstance * card){ + for (int i = offset; i < mCount; i++){ + CardGui * cardg = (CardGui *)mObjects[i]; + if(cardg && cardg->card == card){ + return cardg; + } + } + return NULL; + +} + +void MTGGuiPlay::initCardsDisplay(){ + for (int i = 0; i < SCREEN_WIDTH/5; i++){ + for(int j=0; j < SCREEN_HEIGHT/5; j++){ + cardsGrid[i][j] = NULL; + } + } + cards_x_limit = 12; + nb_creatures = 0; + nb_lands = 0; + nb_spells = 0; +} + + +void MTGGuiPlay::adjustCardPosition(CardGui * cardg){ + int x5 = cardg->x / 5; + int y5 = cardg->y / 5; + + while (cardsGrid[x5][y5] && x5 x = x5 * 5; + cardg->y = y5 * 5; + cardsGrid[x5][y5] = cardg->card; +} + +void MTGGuiPlay::setCardPosition(CardGui * cardg, int player, int playerTurn, int spellMode){ + MTGCardInstance * card = cardg->card; + if (card->target) + return; + if (spellMode && (card->isACreature() || card->hasType("land"))) return; + if (!spellMode && !card->isACreature() && !card->hasType("land")) return; + if (card->isACreature()){ + int x_offset = nb_creatures % cards_x_limit; + int y_offset = nb_creatures / cards_x_limit; + cardg->x= ZX_MAIN + (Z_CARDWIDTH * x_offset); + cardg->y=ZY_MAIN + ZH_CREATURES + (Z_CARDHEIGHT * y_offset) + 100 * (1-player); + nb_creatures++; + + if (playerTurn){ + if (card->isAttacker()){ + cardg->y=122 + 30 * (1-player); + } + }else{ + if (card->isDefenser()){ + CardGui * targetg = getByCard(card->isDefenser()); + if (targetg) cardg->x = targetg->x; + cardg->y=122 + 30 * (1-player); + } + } + + }else if(card->hasType("land")){ + int x_offset = nb_lands % cards_x_limit; + int y_offset = nb_lands/ cards_x_limit; + cardg->x=ZX_MAIN + (Z_CARDWIDTH * x_offset); + cardg->y=ZY_MAIN + (Z_CARDHEIGHT * y_offset) + 200 * (1-player); + nb_lands++; + }else{ + int y_offset = nb_spells % Z_SPELLS_NBCARDS; + int x_offset = nb_spells/ Z_SPELLS_NBCARDS; + cardg->x=ZX_SPELL - (Z_CARDWIDTH * x_offset); + cardg->y=ZY_SPELL + (Z_CARDHEIGHT * y_offset) + 125 * (1-player); + nb_spells++; + cards_x_limit = 12 - (nb_spells + 2)/ Z_SPELLS_NBCARDS; + } + adjustCardPosition(cardg); +} + + +void MTGGuiPlay::setTargettingCardPosition(CardGui * cardg, int player, int playerTurn){ + MTGCardInstance * card = cardg->card; + MTGCardInstance * target = card->target; + if (!target) + return; + CardGui * targetg = getByCard(target); + if (targetg){ + cardg->y=targetg->y + 5; + cardg->x=targetg->x + 5; + } + adjustCardPosition(cardg); + return; +} + +void MTGGuiPlay::forceUpdateCards(){ + GameObserver * game = GameObserver::GetInstance(); + Player * player = game->players[0]; + int player0Mode =(game->currentPlayer == player); + int nb_cards = player->game->inPlay->nb_cards; + resetObjects(); + AddPlayersGuiInfo(); + offset = mCount; + + bool hasFocus = player0Mode; + offset = 6; + + Player * opponent = game->players[1]; + int opponent_cards = opponent ->game->inPlay->nb_cards; + + for (int i = 0;igame->inPlay->cards[i],40, i*35 + 10, 200, hasFocus); + Add(object); + hasFocus = false; + } + hasFocus = !player0Mode; + for (int i = 0;igame->inPlay->cards[i],40, i*35 + 10, 10, hasFocus); + Add(object); + hasFocus = false; + } + + currentPlayer = game->currentPlayer; +} + +void MTGGuiPlay::updateCards(){ + GameObserver * game = GameObserver::GetInstance(); + Player * player = game->players[0]; + int player0Mode =(game->currentPlayer == player); + int nb_cards = player->game->inPlay->nb_cards; + MTGCardInstance * attackers[MAX_ATTACKERS]; + for (int i = 0; i players[1]; + int opponent_cards = opponent ->game->inPlay->nb_cards; + if (mCount - offset != (nb_cards+opponent_cards) || game->currentPlayer != currentPlayer ){ //if the number of cards has changed, then an update occured (is this test engouh ?) + forceUpdateCards(); + } + + + //This is just so that we display the cards of the current player first, so that blockers are correctly positionned + for (int j= 0; j < 2; j++){ + initCardsDisplay(); + if (j != player0Mode){ + for (int i =0; iplayers[0])); + Add(NEW GuiAvatar(-2,50,2,30,false,GameObserver::GetInstance()->players[1])); + + Add(NEW GuiGraveyard(-3,30,40,150,false, GameObserver::GetInstance()->players[0])); + Add(NEW GuiLibrary(-4,30,40,180,false, GameObserver::GetInstance()->players[0])); + + + Add(NEW GuiGraveyard(-5,30,40,30,false, GameObserver::GetInstance()->players[1])); + Add(NEW GuiLibrary(-6,30,40,60,false, GameObserver::GetInstance()->players[1])); + } +} + +void MTGGuiPlay::Update(float dt){ + updateCards(); + PlayGuiObjectController::Update(dt); +} + + + +bool MTGGuiPlay::CheckUserInput(u32 key){ + for (int i = 2; i<6;i++){ + GuiGameZone * zone = (GuiGameZone *)mObjects[i]; + if (zone->showCards){ + return zone->cd->CheckUserInput(key); + } + } + return PlayGuiObjectController::CheckUserInput(key); +} + + +void MTGGuiPlay::RenderPlayerInfo(int playerid){ + JRenderer * r = JRenderer::GetInstance(); + Player * player = GameObserver::GetInstance()->players[playerid]; + + //Avatar + GuiAvatar * avatar = (GuiAvatar *)mObjects[3*playerid]; + avatar->Render(); + + + + //Mana + ManaCost * cost = player->getManaPool(); + int nbicons = 0; + for (int j=0; j<6;j++){ + int value = cost->getCost(j); + for (int i=0; iRenderQuad(mIcons[j],x,y,0,0.5, 0.5); + nbicons++; + } + } +} + + +void MTGGuiPlay::RenderPhaseBar(){ + GameObserver * game = GameObserver::GetInstance(); + JRenderer * renderer = JRenderer::GetInstance(); + int currentPhase = game->getCurrentGamePhase(); + for (int i=0; i < 12; i++){ + int index = 2*i + 1 ; + if (i==currentPhase-1){ + index-=1; + } + renderer->RenderQuad(phaseIcons[index], 200 + 14*i,0,0,0.5,0.5); + } + if (game->currentlyActing()->isAI()){ + mFont->SetColor(ARGB(255,128,128,128)); + }else{ + mFont->SetColor(ARGB(255,255,255,255)); + } + mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); + mFont->DrawString(_(Constants::MTGPhaseNames[currentPhase]).c_str(), 375, 2); +} + +void MTGGuiPlay::Render(){ + LOG("Start MTGGuiPlay Render\n"); + JRenderer * renderer = JRenderer::GetInstance(); + + //alphaBg[1] = 255; + //alphaBg[2]= 255; + //alphaBg[3] = 255; + //mBg2->SetColor(ARGB(alphaBg[0], alphaBg[1],alphaBg[2],alphaBg[3])); + renderer->RenderQuad(mBg2,0,17); + + if (game->currentGamePhase >= Constants::MTG_PHASE_COMBATBEGIN && game->currentGamePhase < Constants::MTG_PHASE_COMBATEND){ + if (alphaBg[0] < 50){ + alphaBg[3]-=12; + alphaBg[2]-=12; + alphaBg[0]+=3; + } + alphaBg[1] = 255; + + }else{ + if (alphaBg[0]){ + alphaBg[0]-=3; + alphaBg[3]+=12; + alphaBg[2]+=12; + } + alphaBg[1] = 255; + } + renderer->FillRect(0,0,480,272,ARGB(alphaBg[0], alphaBg[1],alphaBg[2],alphaBg[3])); + + renderer->RenderQuad(mBg,0,0); + + for (int i=0;iRender(); + } + } + + RenderPhaseBar(); + RenderPlayerInfo(0); + RenderPlayerInfo(1); + + int opponentHand = game->players[1]->game->hand->nb_cards; + char buffer[10]; + sprintf(buffer,"%i",opponentHand); mFont->SetColor(ARGB(128,0,0,0)); mFont->DrawString(buffer, 56, 20); mFont->SetColor(ARGB(255,255,255,255)); - mFont->DrawString(buffer, 54, 18); - - if (mGlitterAlpha < 0){ - mGlitterAlpha = 510; - int position = rand() % 2; - if (position){ - mGlitterX = 65 + rand() % (420); - mGlitterY = 17 + rand() % (5); - }else{ - mGlitterX = 65 + rand() % (5); - mGlitterY = 15 + rand() % (250); - } - } - mGlitter->SetColor(ARGB((255-abs(255-mGlitterAlpha)),240,240,255)); - renderer->RenderQuad(mGlitter,mGlitterX,mGlitterY, (float)(mGlitterAlpha)/(float)255, 1.2*float(mGlitterAlpha)/float(255),1.2*float(mGlitterAlpha)/float(255)); - mGlitterAlpha-=10; - - if (mCount && mObjects[mCurr] != NULL){ - mObjects[mCurr]->Render(); - if (hasFocus && mCurr >= offset && showBigCards && !game->currentlyActing()->isAI() ){ - //For some reason RenderBig crashes when the testsuite is playing, so we add a "isAI()" test...which was supposed to be there at some point anyways... - CardGui * cardg = ((CardGui *)mObjects[mCurr]); - cardg->RenderBig(-1,-1,showBigCards-1); - } - } - LOG("End MTGGuiPlay Render\n"); -} - -MTGGuiPlay::~MTGGuiPlay(){ - LOG("==Destroying MTGGuiPlay=="); - delete mBg; - //delete mBgTex; - - delete mGlitter; - for (int i=0; i < 12; i++){ - delete phaseIcons[2*i] ; - delete phaseIcons[2*i + 1]; - } - //delete mPhaseBarTexture; - - SAFE_DELETE(mBg2); - //SAFE_DELETE(mBgTex2); - - LOG("==Destroying MTGGuiPlay Successful=="); - -} + mFont->DrawString(buffer, 54, 18); + + if (mGlitterAlpha < 0){ + mGlitterAlpha = 510; + int position = rand() % 2; + if (position){ + mGlitterX = 65 + rand() % (420); + mGlitterY = 17 + rand() % (5); + }else{ + mGlitterX = 65 + rand() % (5); + mGlitterY = 15 + rand() % (250); + } + } + mGlitter->SetColor(ARGB((255-abs(255-mGlitterAlpha)),240,240,255)); + renderer->RenderQuad(mGlitter,mGlitterX,mGlitterY, (float)(mGlitterAlpha)/(float)255, 1.2*float(mGlitterAlpha)/float(255),1.2*float(mGlitterAlpha)/float(255)); + mGlitterAlpha-=10; + + if (mCount && mObjects[mCurr] != NULL){ + mObjects[mCurr]->Render(); + if (hasFocus && mCurr >= offset && showBigCards && !game->currentlyActing()->isAI() ){ + //For some reason RenderBig crashes when the testsuite is playing, so we add a "isAI()" test...which was supposed to be there at some point anyways... + CardGui * cardg = ((CardGui *)mObjects[mCurr]); + cardg->RenderBig(-1,-1,showBigCards-1); + } + } + LOG("End MTGGuiPlay Render\n"); +} + +MTGGuiPlay::~MTGGuiPlay(){ + LOG("==Destroying MTGGuiPlay=="); + delete mBg; + //delete mBgTex; + + delete mGlitter; + for (int i=0; i < 12; i++){ + delete phaseIcons[2*i] ; + delete phaseIcons[2*i + 1]; + } + //delete mPhaseBarTexture; + + SAFE_DELETE(mBg2); + //SAFE_DELETE(mBgTex2); + + LOG("==Destroying MTGGuiPlay Successful=="); + +} diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 5c1c319b1..9bf44c09e 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -77,6 +77,13 @@ int MTGPutInPlayRule::testDestroy(){ return 0; } +ostream& MTGPutInPlayRule::toString(ostream& out) const +{ + out << "MTGPutInPlayRule ::: ("; + return MTGAbility::toString(out) << ")"; +} + + MTGAttackRule::MTGAttackRule(int _id):MTGAbility(_id,NULL){ aType=MTGAbility::MTG_ATTACK_RULE; } @@ -112,7 +119,11 @@ int MTGAttackRule::testDestroy(){ return 0; } - +ostream& MTGAttackRule::toString(ostream& out) const +{ + out << "MTGAttackRule ::: ("; + return MTGAbility::toString(out) << ")"; +} MTGBlockRule::MTGBlockRule(int _id):MTGAbility(_id,NULL){ aType=MTGAbility::MTG_BLOCK_RULE; @@ -149,6 +160,11 @@ int MTGBlockRule::testDestroy(){ return 0; } +ostream& MTGBlockRule::toString(ostream& out) const +{ + out << "MTGBlockRule ::: ("; + return MTGAbility::toString(out) << ")"; +} // // * Momir @@ -259,4 +275,10 @@ void MTGMomirRule::Render(){ mFont->SetScale(2 - (float)textAlpha/130); mFont->SetColor(ARGB(textAlpha,255,255,255)); mFont->DrawString(text.c_str(),SCREEN_WIDTH/2,SCREEN_HEIGHT/2,JGETEXT_CENTER); -} \ No newline at end of file +} + +ostream& MTGMomirRule::toString(ostream& out) const +{ + out << "MTGMomirRule ::: pool : " << pool << " ; initialized : " << initialized << " ; textAlpha : " << textAlpha << " ; text " << text << " ; alreadyplayed : " << alreadyplayed << " ; collection : " << collection << "("; + return MTGAbility::toString(out) << ")"; +} diff --git a/projects/mtg/src/ManaCost.cpp b/projects/mtg/src/ManaCost.cpp index 32cd30bb6..202c6b006 100644 --- a/projects/mtg/src/ManaCost.cpp +++ b/projects/mtg/src/ManaCost.cpp @@ -400,4 +400,9 @@ void ManaCost::Dump(){ OutputDebugString("\n=============\n"); } -#endif \ No newline at end of file +#endif + +ostream& operator<<(ostream& out, const ManaCost& m) +{ + return out << "(manacost)"; +} diff --git a/projects/mtg/src/MenuItem.cpp b/projects/mtg/src/MenuItem.cpp index 338115e16..f2073fdac 100644 --- a/projects/mtg/src/MenuItem.cpp +++ b/projects/mtg/src/MenuItem.cpp @@ -103,3 +103,18 @@ bool MenuItem::ButtonPressed() MenuItem::~MenuItem(){ if (mParticleSys) delete mParticleSys; } + +ostream& MenuItem::toString(ostream& out) const +{ + return out << "MenuItem ::: mHasFocus : " << mHasFocus + << " ; mFont : " << mFont + << " ; mText : " << mText + << " ; mX,mY : " << mX << "," << mY + << " ; updatedSinceLastRender : " << updatedSinceLastRender + << " ; lastDt : " << lastDt + << " ; mScale : " << mScale + << " ; mTargetScale : " << mTargetScale + << " ; onQuad : " << onQuad + << " ; offQuad : " << offQuad + << " ; mParticleSys : " << mParticleSys; +} diff --git a/projects/mtg/src/OptionItem.cpp b/projects/mtg/src/OptionItem.cpp index 9c6f44045..9642cb6d3 100644 --- a/projects/mtg/src/OptionItem.cpp +++ b/projects/mtg/src/OptionItem.cpp @@ -121,3 +121,14 @@ void OptionsList::Update(float dt){ options[i]->Update(dt); } } + +ostream& OptionItem::toString(ostream& out) const +{ + return out << "OptionItem ::: displayValue : " << displayValue + << " ; id : " << id + << " ; value : " << value + << " ; hasFocus : " << hasFocus + << " ; maxValue : " << maxValue + << " ; increment : " << increment + << " ; x,y : " << x << "," << y; +} diff --git a/projects/mtg/src/PlayGuiObject.cpp b/projects/mtg/src/PlayGuiObject.cpp index 89b1f453e..95f972d00 100644 --- a/projects/mtg/src/PlayGuiObject.cpp +++ b/projects/mtg/src/PlayGuiObject.cpp @@ -88,6 +88,13 @@ void GuiAvatar::Render(){ mFont->DrawString(buffer, x+1,y+38); } +ostream& GuiAvatar::toString(ostream& out) const +{ + return out << "GuiAvatar ::: avatarRed : " << avatarRed + << " ; currentLife : " << currentLife + << " ; player : " << player; +} + void GuiGameZone::toggleDisplay(){ if (showCards){ @@ -140,12 +147,28 @@ GuiGameZone::~GuiGameZone(){ if(cd) delete cd; } +ostream& GuiGameZone::toString(ostream& out) const +{ + return out << "GuiGameZone ::: zone : " << zone + << " ; cd : " << cd + << " ; showCards : " << showCards; +} + GuiGraveyard::GuiGraveyard(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * player):GuiGameZone(id, desiredHeight, _x, _y, hasFocus,player->game->graveyard){ type= GUI_GRAVEYARD; } +ostream& GuiGraveyard::toString(ostream& out) const +{ + return out << "GuiGraveyard :::"; +} GuiLibrary::GuiLibrary(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * player):GuiGameZone(id, desiredHeight, _x, _y, hasFocus,player->game->library){ type = GUI_LIBRARY; } + +ostream& GuiLibrary::toString(ostream& out) const +{ + return out << "GuiLibrary :::"; +} diff --git a/projects/mtg/src/ShopItem.cpp b/projects/mtg/src/ShopItem.cpp index 3e4f41955..80f69fcf6 100644 --- a/projects/mtg/src/ShopItem.cpp +++ b/projects/mtg/src/ShopItem.cpp @@ -304,3 +304,20 @@ ShopItems::~ShopItems(){ safeDeleteDisplay(); SAFE_DELETE(myCollection); } + +ostream& ShopItem::toString(ostream& out) const +{ + return out << "ShopItem ::: mHasFocus : " << mHasFocus + << " ; mFont : " << mFont + << " ; mText : " << mText + << " ; mX,mY : " << mX << "," << mY + << " ; quad : " << quad + << " ; thumb : " << thumb + << " ; mScale : " << mScale + << " ; mTargetScale : " << mTargetScale + << " ; mDDW : " << mDDW + << " ; nameCount : " << nameCount + << " ; quantity : " << quantity + << " ; card : " << card + << " ; price : " << price; +} diff --git a/projects/mtg/src/SimpleMenuItem.cpp b/projects/mtg/src/SimpleMenuItem.cpp index ae0edc6a3..67c12996e 100644 --- a/projects/mtg/src/SimpleMenuItem.cpp +++ b/projects/mtg/src/SimpleMenuItem.cpp @@ -78,3 +78,14 @@ bool SimpleMenuItem::hasFocus() { return mHasFocus; } + +ostream& SimpleMenuItem::toString(ostream& out) const +{ + return out << "SimpleMenuItem ::: mHasFocus : " << mHasFocus + << " ; parent : " << parent + << " ; mFont : " << mFont + << " ; mText : " << mText + << " ; mScale : " << mScale + << " ; mTargetScale : " << mTargetScale + << " ; mX,mY : " << mX << "," << mY; +} diff --git a/projects/mtg/src/TextScroller.cpp b/projects/mtg/src/TextScroller.cpp index 7d3e2fd19..dc4599049 100644 --- a/projects/mtg/src/TextScroller.cpp +++ b/projects/mtg/src/TextScroller.cpp @@ -48,4 +48,19 @@ void TextScroller::Update(float dt){ void TextScroller::Render(){ mFont->DrawString(mText.c_str(),mX,mY,JGETEXT_LEFT,start,mWidth); -} \ No newline at end of file +} + +ostream& TextScroller::toString(ostream& out) const +{ + return out << "TextScroller ::: mText : " << mText + << " ; tempText : " << tempText + << " ; mFont : " << mFont + << " ; mWidth : " << mWidth + << " ; mSpeed : " << mSpeed + << " ; mX,mY : " << mX << "," << mY + << " ; start : " << start + << " ; timer : " << timer + << " ; strings : ?" // << strings + << " ; currentId : " << currentId + << " ; mRandom : " << mRandom; +}