summaryrefslogtreecommitdiff
path: root/game.h
diff options
context:
space:
mode:
authorJohn Fultz <jfultz@wolfram.com>2016-08-02 04:08:43 -0500
committerJohn Fultz <jfultz@wolfram.com>2016-08-02 06:37:15 -0500
commitdbcb13d3c87133117bc54023c162ad0a202efa1d (patch)
tree955715420b4584b73baa676c1b4b5fe4febb3c48 /game.h
parenta3aa3602d173939a2b616bb78a5a739eb9761d9b (diff)
Fixes to allow bad endgames to be loaded from GCGs.
Not perfect, but it now does a decent job of not corrupting GCGs when it loads one where players have messed up tile counts/drawing in the end-game. It also tries to annotate these for the player and in any GCG file that's round-tripped. Also, a lot of C++11-izing of ranged iterators.
Diffstat (limited to 'game.h')
-rw-r--r--game.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/game.h b/game.h
index 7ef60fd..c022848 100644
--- a/game.h
+++ b/game.h
@@ -270,9 +270,9 @@ public:
// and found is set to false.
PlayerList::const_iterator nextPlayerOfType(Player::PlayerType type, bool &found) const;
- // Returns the player with id specified, or the current player
+ // Returns the player with the abbreviated name specified, or the current player
// if not found.
- PlayerList::const_iterator playerWithId(int id, bool &found) const;
+ PlayerList::const_iterator playerWithAbbreviatedName(const UVString &abbreviatedName, bool &found) const;
const PlayerList &players() const;
@@ -296,7 +296,7 @@ public:
bool gameOver() const;
// the move made will
- // be set to the proper UnusedTileBonus move.
+ // be set to the proper UnusedTilesBonus move.
// The score of the bonus is *not* added to score of current player,
// therefor this method is quite misnamed.
void adjustScoresToFinishGame();
@@ -356,6 +356,8 @@ public:
void setCommittedMove(const Move &move);
const Move &committedMove() const;
+ void setTileBonus(const UVString &player, const LetterString &allegedTiles, int allegedTileBonus);
+
// saves the current candidate as the committedMove.
void prepareForCommit();
@@ -536,6 +538,17 @@ inline bool GamePosition::gameOver() const
inline void GamePosition::setMoveMade(const Move &move)
{
m_moveMade = move;
+ if (m_gameOver && move.action != Quackle::Move::UnusedTilesBonus && move.action != Quackle::Move::UnusedTilesBonusError)
+ {
+ m_gameOver = false; // apparently the game isn't over...somebody's force-feeding us bad plays
+ --m_turnNumber;
+ m_moveMade.action = Quackle::Move::PlaceError;
+ m_explanatoryNote = "Quackle says: Tiles were drawn out of order, leading to extra turns";
+ if (++m_currentPlayer == m_players.end())
+ {
+ m_currentPlayer = m_players.begin();
+ }
+ }
}
inline const Move &GamePosition::moveMade() const