summaryrefslogtreecommitdiff
path: root/rack.cpp
diff options
context:
space:
mode:
authorJohn Fultz <jfultz@wolfram.com>2016-07-07 11:32:02 -0500
committerJohn Fultz <jfultz@wolfram.com>2016-07-07 11:44:45 -0500
commite1592dfbc6972dda664d7e1a3c208a9921691149 (patch)
tree0307551e3d0fac2702c5e7c0fb488bba02f97cb6 /rack.cpp
parent3d46663b8d7221ee84c656715d18cfbdc28a0e85 (diff)
Fix problems entering games with unknown racks.
If you're entering games with unknown racks, Quackle can get confused about which player has how many tiles in the end game. This is because the racks may have been set to have less than 7 tiles, and some of the tiles "in the bag" may actually belong on another player's rack. Fixed this by... * Adding a mechanism which tracks the actual count of tiles in the bag and on the rack in GamePosition. This count is independent of what's actually on the rack. * If the game is about to end because the bag and rack are empty, check to see if the rack *should* have been empty. If not, pull tiles from another player's rack. This code might fail for games of more than two players. * If the game should be ending because the bag and rack are empty, but the rack isn't actually empty, then dump the files to another player's rack. Once again, this code doesn't take into account >2 players.
Diffstat (limited to 'rack.cpp')
-rw-r--r--rack.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/rack.cpp b/rack.cpp
index 900763f..967514c 100644
--- a/rack.cpp
+++ b/rack.cpp
@@ -76,6 +76,15 @@ bool Rack::unload(const LetterString &used)
return ret;
}
+void Rack::load(const LetterString &tiles)
+{
+ for (LetterString::const_iterator it = tiles.begin(); it != tiles.end(); ++it)
+ {
+ if (it != QUACKLE_NULL_MARK)
+ m_tiles += *it;
+ }
+}
+
bool Rack::contains(const LetterString &used) const
{
return Rack(*this).unload(used);