J :
* Add some pretty printers to help debugging.
This commit is contained in:
@@ -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