J :
* Add some pretty printers to help debugging.
This commit is contained in:
@@ -62,7 +62,7 @@ class AIPlayer: public Player{
|
||||
AIStats * getStats();
|
||||
public:
|
||||
void End(){};
|
||||
virtual int displayStack(){return 0;};
|
||||
virtual int displayStack() {return 0;};
|
||||
AIStats * stats;
|
||||
ManaCost * getPotentialMana();
|
||||
AIPlayer(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
|
||||
|
||||
@@ -57,7 +57,7 @@ class Interruptible: public PlayGuiObject, public Targetable{
|
||||
virtual void Render(){};
|
||||
int typeAsTarget(){return TARGET_STACKACTION;};
|
||||
Interruptible(bool hasFocus = false):PlayGuiObject(40,x,y,hasFocus){state=NOT_RESOLVED;display=0;source=NULL;};
|
||||
virtual const string getDisplayName(){return "stack object";};
|
||||
virtual const string getDisplayName() const {return "stack object";};
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
virtual void Dump();
|
||||
#endif
|
||||
@@ -82,7 +82,7 @@ class Spell: public Interruptible {
|
||||
~Spell();
|
||||
int resolve();
|
||||
void Render();
|
||||
const string getDisplayName();
|
||||
const string getDisplayName() const;
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGCardInstance * getNextCardTarget(MTGCardInstance * previous = 0);
|
||||
Player * getNextPlayerTarget(Player * previous = 0);
|
||||
|
||||
@@ -68,10 +68,10 @@ class GuiHandSelf : public GuiHand
|
||||
virtual int receiveEventPlus(WEvent* e);
|
||||
virtual int receiveEventMinus(WEvent* e);
|
||||
|
||||
void Repos();
|
||||
bool CheckUserInput(u32 key);
|
||||
virtual void Render();
|
||||
void Update(float dt);
|
||||
void Repos();
|
||||
float LeftBoundary();
|
||||
|
||||
HandLimitor* limitor;
|
||||
|
||||
@@ -59,7 +59,7 @@ class MTGCardInstance: public MTGCard, public Damageable {
|
||||
Player * owner;
|
||||
Counters * counters;
|
||||
int typeAsTarget(){return TARGET_CARD;}
|
||||
const string getDisplayName();
|
||||
const string getDisplayName() const;
|
||||
MTGCardInstance * target;
|
||||
void addType(int type);
|
||||
|
||||
@@ -124,9 +124,11 @@ class MTGCardInstance: public MTGCard, public Damageable {
|
||||
int isInPlay();
|
||||
void resetAllDamage();
|
||||
JSample * getSample();
|
||||
|
||||
ostream& toString(ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
ostream& operator<<(ostream&, const MTGCardInstance&);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -86,6 +86,8 @@ class MTGGameZone {
|
||||
static int zoneStringToId(string zoneName);
|
||||
static MTGGameZone *intToZone(int zoneId, MTGCardInstance * source = NULL,MTGCardInstance * target = NULL);
|
||||
bool needShuffle;
|
||||
|
||||
virtual ostream& toString(ostream&) const;
|
||||
};
|
||||
|
||||
class MTGLibrary: public MTGGameZone {
|
||||
@@ -93,23 +95,28 @@ class MTGLibrary: public MTGGameZone {
|
||||
// MTGLibrary();
|
||||
void shuffleTopToBottom(int nbcards);
|
||||
MTGCardInstance * draw();
|
||||
virtual ostream& toString(ostream&) const;
|
||||
};
|
||||
|
||||
class MTGGraveyard: public MTGGameZone {
|
||||
public:
|
||||
// MTGGraveyard();
|
||||
virtual ostream& toString(ostream&) const;
|
||||
};
|
||||
|
||||
class MTGHand: public MTGGameZone {
|
||||
public:
|
||||
virtual ostream& toString(ostream&) const;
|
||||
};
|
||||
|
||||
class MTGRemovedFromGame: public MTGGameZone {
|
||||
public:
|
||||
virtual ostream& toString(ostream&) const;
|
||||
};
|
||||
|
||||
class MTGStack: public MTGGameZone {
|
||||
public:
|
||||
virtual ostream& toString(ostream&) const;
|
||||
};
|
||||
|
||||
class MTGInPlay: public MTGGameZone {
|
||||
@@ -120,6 +127,7 @@ class MTGInPlay: public MTGGameZone {
|
||||
MTGCardInstance * getNextDefenser(MTGCardInstance * previous, MTGCardInstance * attacker);
|
||||
int nbDefensers( MTGCardInstance * attacker);
|
||||
int nbPartners(MTGCardInstance * attacker);
|
||||
virtual ostream& toString(ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -153,8 +161,8 @@ class MTGPlayerCards {
|
||||
MTGCardInstance * putInZone(MTGCardInstance * card, MTGGameZone * from, MTGGameZone * to);
|
||||
MTGCardInstance * putInPlay(MTGCardInstance * card);
|
||||
int isInPlay(MTGCardInstance * card);
|
||||
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream&, const MTGGameZone&);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,7 +17,7 @@ class Player: public Damageable{
|
||||
public:
|
||||
virtual void End();
|
||||
int typeAsTarget(){return TARGET_PLAYER;}
|
||||
const string getDisplayName();
|
||||
const string getDisplayName() const;
|
||||
virtual int displayStack(){return 1;}
|
||||
JTexture * mAvatarTex;
|
||||
JQuad * mAvatar;
|
||||
@@ -45,7 +45,6 @@ class HumanPlayer: public Player{
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
ostream& operator<<(ostream&, const Player&);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
class Targetable{
|
||||
public:
|
||||
virtual int typeAsTarget() = 0;
|
||||
virtual const string getDisplayName() = 0;
|
||||
virtual const string getDisplayName() const = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef _WEVENT_H_
|
||||
#define _WEVENT_H_
|
||||
|
||||
#include <iostream>
|
||||
#include "PhaseRing.h"
|
||||
|
||||
class MTGCardInstance;
|
||||
@@ -21,6 +22,7 @@ public:
|
||||
int type; //Deprecated, use dynamic casting instead
|
||||
WEvent(int type = NOT_SPECIFIED);
|
||||
virtual ~WEvent() {};
|
||||
virtual std::ostream& toString(std::ostream& out) const;
|
||||
};
|
||||
|
||||
struct WEventZoneChange : public WEvent {
|
||||
@@ -29,6 +31,7 @@ struct WEventZoneChange : public WEvent {
|
||||
MTGGameZone * to;
|
||||
WEventZoneChange(MTGCardInstance * card, MTGGameZone * from, MTGGameZone *to);
|
||||
virtual ~WEventZoneChange() {};
|
||||
virtual std::ostream& toString(std::ostream& out) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -116,4 +119,6 @@ struct WEventEmptyManaPool : public WEvent {
|
||||
WEventEmptyManaPool(ManaPool * source);
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream&, const WEvent&);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -115,7 +115,7 @@ Spell::Spell(int id, MTGCardInstance * _source, TargetChooser * tc, ManaCost * _
|
||||
}
|
||||
|
||||
|
||||
const string Spell::getDisplayName(){
|
||||
const string Spell::getDisplayName() const {
|
||||
return source->getName();
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ void DuelLayers::Render(){
|
||||
int DuelLayers::receiveEvent(WEvent * e){
|
||||
|
||||
#if 1
|
||||
#define PRINT_IF(type) { type *foo = dynamic_cast<type*>(e); if (foo) cout << "Is a " << #type << endl; }
|
||||
#define PRINT_IF(type) { type *foo = dynamic_cast<type*>(e); if (foo) cout << "Is a " #type " " << *foo << endl; }
|
||||
cout << "Received event " << e << " ";
|
||||
PRINT_IF(WEventZoneChange);
|
||||
PRINT_IF(WEventDamage);
|
||||
|
||||
@@ -331,11 +331,8 @@ int GuiCombat::receiveEventMinus(WEvent* e)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if (WEventPhaseChange* event = dynamic_cast<WEventPhaseChange*>(e))
|
||||
{
|
||||
event = event;
|
||||
step = BLOCKERS;
|
||||
}
|
||||
else if (dynamic_cast<WEventPhaseChange*>(e))
|
||||
step = BLOCKERS;
|
||||
else if (WEventCombatStepChange* event = dynamic_cast<WEventCombatStepChange*>(e))
|
||||
switch (event->step)
|
||||
{
|
||||
|
||||
@@ -108,7 +108,7 @@ void MTGCardInstance::initMTGCI(){
|
||||
}
|
||||
|
||||
|
||||
const string MTGCardInstance::getDisplayName(){
|
||||
const string MTGCardInstance::getDisplayName() const {
|
||||
return getName();
|
||||
}
|
||||
|
||||
@@ -635,3 +635,13 @@ int MTGCardInstance::stepPower(CombatStep step)
|
||||
if (has(Constants::FIRSTSTRIKE)) return 0; else return MAX(0, power);
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& MTGCardInstance::toString(std::ostream& out) const
|
||||
{
|
||||
return out << name;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const MTGCardInstance& c)
|
||||
{
|
||||
return c.toString(out);
|
||||
}
|
||||
|
||||
@@ -575,3 +575,15 @@ int MTGGameZone::zoneStringToId(string zoneName){
|
||||
MTGGameZone * MTGGameZone::stringToZone(string zoneName, MTGCardInstance * source,MTGCardInstance * target){
|
||||
return intToZone(zoneStringToId(zoneName), source,target);
|
||||
}
|
||||
|
||||
ostream& MTGGameZone::toString(ostream& out) const { return out << "Unknown zone"; }
|
||||
ostream& MTGLibrary::toString(ostream& out) const { return out << "Library " << *owner; }
|
||||
ostream& MTGGraveyard::toString(ostream& out) const { return out << "Graveyard " << *owner; }
|
||||
ostream& MTGHand::toString(ostream& out) const { return out << "Hand " << *owner; }
|
||||
ostream& MTGRemovedFromGame::toString(ostream& out) const { return out << "RemovedFromGame " << *owner; }
|
||||
ostream& MTGStack::toString(ostream& out) const { return out << "Stack " << *owner; }
|
||||
ostream& MTGInPlay::toString(ostream& out) const { return out << "InPlay " << *owner; }
|
||||
ostream& operator<<(ostream& out, const MTGGameZone& z)
|
||||
{
|
||||
return z.toString(out);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ Player::~Player(){
|
||||
SAFE_DELETE(mAvatar);
|
||||
}
|
||||
|
||||
const string Player::getDisplayName(){
|
||||
const string Player::getDisplayName() const {
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
if (this == g->players[0]) return "Player 1";
|
||||
return "Player 2";
|
||||
@@ -75,3 +75,8 @@ void Player::cleanupPhase(){
|
||||
game->inPlay->cleanupPhase();
|
||||
game->graveyard->cleanupPhase();
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& out, const Player& p)
|
||||
{
|
||||
return out << p.getDisplayName();
|
||||
}
|
||||
|
||||
@@ -27,3 +27,16 @@ WEventConsumeMana::WEventConsumeMana(int color, ManaPool * source) : WEvent(), c
|
||||
WEventEmptyManaPool::WEventEmptyManaPool(ManaPool * source) : WEvent(), source(source){}
|
||||
|
||||
WEventCombatStepChange::WEventCombatStepChange(CombatStep step) : WEvent(), step(step) {};
|
||||
|
||||
std::ostream& WEvent::toString(std::ostream& out) const
|
||||
{
|
||||
return out << "EVENT";
|
||||
}
|
||||
std::ostream& WEventZoneChange::toString(std::ostream& out) const
|
||||
{
|
||||
return out << "EVENT " << *card << " : " << *from << " → " << *to;
|
||||
}
|
||||
std::ostream& operator<<(std::ostream& out, const WEvent& m)
|
||||
{
|
||||
return m.toString(out);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user