mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-11-17 07:48:27 +01:00
Implement (de)serialization of the MasterMoveCmd class
This commit is contained in:
parent
744e90e6ca
commit
1bc9c2f0f1
3 changed files with 24 additions and 0 deletions
|
@ -36,6 +36,8 @@ class MasterMoveCmd: public Command
|
||||||
MasterMoveCmd(Duplicate &ioDuplicate,
|
MasterMoveCmd(Duplicate &ioDuplicate,
|
||||||
const Move &iMove);
|
const Move &iMove);
|
||||||
|
|
||||||
|
const Move &getMove() const { return m_newMove; }
|
||||||
|
|
||||||
virtual wstring toString() const;
|
virtual wstring toString() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "player_rack_cmd.h"
|
#include "player_rack_cmd.h"
|
||||||
#include "player_move_cmd.h"
|
#include "player_move_cmd.h"
|
||||||
#include "player_points_cmd.h"
|
#include "player_points_cmd.h"
|
||||||
|
#include "master_move_cmd.h"
|
||||||
#include "navigation.h"
|
#include "navigation.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -301,6 +302,18 @@ void XmlReader::endElement(const string& namespaceURI,
|
||||||
LOG_DEBUG("rack: " << lfw(pldrack.toString()));
|
LOG_DEBUG("rack: " << lfw(pldrack.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (tag == "MasterMove")
|
||||||
|
{
|
||||||
|
const Move &move = buildMove(*m_game, m_attributes, false);
|
||||||
|
Duplicate *duplicateGame = dynamic_cast<Duplicate*>(m_game);
|
||||||
|
if (duplicateGame == NULL)
|
||||||
|
{
|
||||||
|
throw LoadGameException("The MasterMove tag should only be present for duplicate games");
|
||||||
|
}
|
||||||
|
MasterMoveCmd *cmd = new MasterMoveCmd(*duplicateGame, move);
|
||||||
|
m_game->accessNavigation().addAndExecute(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
else if (tag == "PlayerMove")
|
else if (tag == "PlayerMove")
|
||||||
{
|
{
|
||||||
const Move &move = buildMove(*m_game, m_attributes, /*XXX:true*/false);
|
const Move &move = buildMove(*m_game, m_attributes, /*XXX:true*/false);
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "player_rack_cmd.h"
|
#include "player_rack_cmd.h"
|
||||||
#include "player_move_cmd.h"
|
#include "player_move_cmd.h"
|
||||||
#include "player_points_cmd.h"
|
#include "player_points_cmd.h"
|
||||||
|
#include "master_move_cmd.h"
|
||||||
#include "mark_played_cmd.h"
|
#include "mark_played_cmd.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -195,6 +196,14 @@ void XmlWriter::write(const Game &iGame, const string &iFileName)
|
||||||
writeMove(out, moveCmd->getMove(), "GameMove", id);
|
writeMove(out, moveCmd->getMove(), "GameMove", id);
|
||||||
out << endl;
|
out << endl;
|
||||||
}
|
}
|
||||||
|
else if (dynamic_cast<const MasterMoveCmd*>(cmd))
|
||||||
|
{
|
||||||
|
const MasterMoveCmd *moveCmd = static_cast<const MasterMoveCmd*>(cmd);
|
||||||
|
out << indent;
|
||||||
|
writeMove(out, moveCmd->getMove(), "MasterMove", -1);
|
||||||
|
out << endl;
|
||||||
|
|
||||||
|
}
|
||||||
else if (dynamic_cast<const MarkPlayedCmd*>(cmd))
|
else if (dynamic_cast<const MarkPlayedCmd*>(cmd))
|
||||||
{
|
{
|
||||||
// Ignore this command, as it is an implementation detail
|
// Ignore this command, as it is an implementation detail
|
||||||
|
|
Loading…
Reference in a new issue