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