From e1592dfbc6972dda664d7e1a3c208a9921691149 Mon Sep 17 00:00:00 2001 From: John Fultz Date: Thu, 7 Jul 2016 11:32:02 -0500 Subject: 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. --- rack.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'rack.h') diff --git a/rack.h b/rack.h index 7bc7df8..a175c29 100644 --- a/rack.h +++ b/rack.h @@ -57,6 +57,8 @@ public: // in this rack and unloaded bool unload(const LetterString &used); + void load(const LetterString &tiles); + // same as above but nonmutating bool contains(const LetterString &used) const; @@ -99,7 +101,7 @@ inline bool Rack::empty() const } const Quackle::Rack operator-(const Quackle::Rack &rack, const Quackle::Move &move); -const Quackle::Rack operator-(const Quackle::Rack &rack1, const Quackle::Rack &rack); +const Quackle::Rack operator-(const Quackle::Rack &rack1, const Quackle::Rack &rack2); UVOStream &operator<<(UVOStream &o, const Quackle::Rack &rack); -- cgit v1.2.3