Ejemplo n.º 1
0
GameData::GameData(const GameData &src)
{
    this->m_field = new PlayingField(*(src.GetField()));
    this->m_history = new HistorySave(*(src.GetHistory()));
    this->m_player1 = new Player(*(src.GetPlayer1()));
    this->m_player2 = new Player(*(src.GetPlayer2()));
    this->m_currentPlayer = src.GetCurrentPlayer()->GetColor() == this->m_player1->GetColor() ? this->m_player1 : this->m_player2;
}
Ejemplo n.º 2
0
string GameData::Serialize(const GameData& data)
{
    stringstream s;

    int current = 0;
    if(data.GetCurrentPlayer() == data.GetPlayer1())
    {
        current = 1;
    }
    else
    {
        current = 2;
    }

    s << PlayingField::Serialize(*data.GetField()) << delimiter << Player::Serialize(*data.GetPlayer1()) << delimiter << Player::Serialize(*data.GetPlayer2())
      << delimiter << current << delimiter << HistorySave::Serialize(*data.GetHistory());


    return s.str();
}