- Added new code for serialization/deserializaiton of full games including initial game and all the player actions.
- Added an undo menu using this code (beware, it's still very very alpha). - Removed various warning - Cleaned up avatar loading - Added full random lists load/save including the deck shuffling (not sure if I could not replace that with seed load/save) - Moved momir and Co rules configuration out of GameStateDuel - Create a GameType type to avoid mixing int everywhere
This commit is contained in:
@@ -498,6 +498,18 @@ MTGCardInstance * MTGGameZone::hasCard(MTGCardInstance * card)
|
||||
|
||||
}
|
||||
|
||||
size_t MTGGameZone::getIndex(MTGCardInstance * card)
|
||||
{
|
||||
size_t i;
|
||||
for(i = 0; i < cards.size(); i++)
|
||||
{
|
||||
if(cards[i] == card)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
unsigned int MTGGameZone::countByType(const char * value)
|
||||
{
|
||||
int result = 0;
|
||||
@@ -669,7 +681,7 @@ void MTGGameZone::cleanupPhase()
|
||||
|
||||
void MTGGameZone::shuffle()
|
||||
{
|
||||
std::random_shuffle(cards.begin(), cards.end());
|
||||
std::random_shuffle(cards.begin(), cards.end(), MRand );
|
||||
}
|
||||
|
||||
void MTGGameZone::addCard(MTGCardInstance * card)
|
||||
@@ -999,16 +1011,15 @@ ostream& MTGInPlay::toString(ostream& out) const
|
||||
}
|
||||
ostream& operator<<(ostream& out, const MTGGameZone& z)
|
||||
{
|
||||
return z.toString(out);
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& out, const MTGPlayerCards& z)
|
||||
{
|
||||
out << z.library->nb_cards << " ";
|
||||
for (int i = 0; i < z.library->nb_cards; i++)
|
||||
out << z.library->cards[i]->getMTGId() << " ";
|
||||
|
||||
for (int i = 0; i < z.nb_cards; i++)
|
||||
{
|
||||
out << z.cards[i]->getMTGId();
|
||||
if(i < z.nb_cards - 1)
|
||||
out << ",";
|
||||
}
|
||||
return out;
|
||||
|
||||
// return z.toString(out);
|
||||
}
|
||||
|
||||
bool MTGGameZone::parseLine(const string& ss)
|
||||
@@ -1022,6 +1033,7 @@ bool MTGGameZone::parseLine(const string& ss)
|
||||
}
|
||||
cards.clear();
|
||||
cardsMap.clear();
|
||||
nb_cards = 0;
|
||||
|
||||
while(s.size())
|
||||
{
|
||||
@@ -1072,6 +1084,28 @@ bool MTGGameZone::parseLine(const string& ss)
|
||||
return result;
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& out, const MTGPlayerCards& z)
|
||||
{
|
||||
if(z.library->cards.size()) {
|
||||
out << "library=";
|
||||
out << *(z.library) << endl;
|
||||
}
|
||||
if(z.battlefield->cards.size()) {
|
||||
out << "inplay=";
|
||||
out << *(z.battlefield) << endl;
|
||||
}
|
||||
if(z.graveyard->cards.size()) {
|
||||
out << "graveyard=";
|
||||
out << *(z.graveyard) << endl;
|
||||
}
|
||||
if(z.hand->cards.size()) {
|
||||
out << "hand=";
|
||||
out << *(z.hand) << endl;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
bool MTGPlayerCards::parseLine(const string& s)
|
||||
{
|
||||
size_t limiter = s.find("=");
|
||||
|
||||
Reference in New Issue
Block a user