- Moved the card collection out of the GameApp class to clean up the dependencies

- Added method to build a card collection independently of the GUI to ease my unitary test application
- Added part of some network GUI I'm working on, it's #ifdef out, I'm only committing this part to ease later merges
- Added the beginning of a serialization code of the Player and related classes used for network support
- various other minor cleanup
This commit is contained in:
Xawotihs
2011-02-06 11:35:40 +00:00
parent 91a2cb9c90
commit b7b584113b
26 changed files with 268 additions and 137 deletions
+47 -7
View File
@@ -14,13 +14,18 @@
//Players Game
//------------------------------
MTGPlayerCards::MTGPlayerCards()
{
init();
}
MTGPlayerCards::MTGPlayerCards(int * idList, int idListSize)
{
init();
int i;
for (i = 0; i < idListSize; i++)
{
MTGCard * card = GameApp::collection->getCardById(idList[i]);
MTGCard * card = MTGCollection()->getCardById(idList[i]);
if (card)
{
MTGCardInstance * newCard = NEW MTGCardInstance(card, this);
@@ -845,29 +850,64 @@ ostream& MTGGameZone::toString(ostream& out) const
}
ostream& MTGLibrary::toString(ostream& out) const
{
return out << "Library " << *owner;
return out << "Library " << owner->getDisplayName();
}
ostream& MTGGraveyard::toString(ostream& out) const
{
return out << "Graveyard " << *owner;
return out << "Graveyard " << owner->getDisplayName();
}
ostream& MTGHand::toString(ostream& out) const
{
return out << "Hand " << *owner;
return out << "Hand " << owner->getDisplayName();
}
ostream& MTGRemovedFromGame::toString(ostream& out) const
{
return out << "RemovedFromGame " << *owner;
return out << "RemovedFromGame " << owner->getDisplayName();
}
ostream& MTGStack::toString(ostream& out) const
{
return out << "Stack " << *owner;
return out << "Stack " << owner->getDisplayName();
}
ostream& MTGInPlay::toString(ostream& out) const
{
return out << "InPlay " << *owner;
return out << "InPlay " << owner->getDisplayName();
}
ostream& operator<<(ostream& out, const MTGGameZone& z)
{
return z.toString(out);
}
ostream& operator<<(ostream& out, const MTGPlayerCards& z)
{
out << z.library->nb_cards << endl;
for (int i = 0; i < z.library->nb_cards; i++)
out << z.library->cards[i]->getMTGId() << " ";
out << endl;
return out;
}
istream& operator>>(istream& in, MTGPlayerCards& z)
{
int nb, mtgid;
in >> nb;
for (int i = 0; i < z.library->nb_cards; i++)
{
SAFE_DELETE( z.library->cards[i] );
}
z.library->cards.clear();
z.library->cardsMap.clear();
for (int i = 0; i < nb; i++)
{
in >> mtgid;
MTGCard * card = MTGCollection()->getCardById(mtgid);
if (card)
{
MTGCardInstance * newCard = NEW MTGCardInstance(card, &z);
z.library->addCard(newCard);
}
}
return in;
}