summaryrefslogtreecommitdiff
path: root/move.cpp
diff options
context:
space:
mode:
authorJohn Fultz <jfultz@wolfram.com>2016-07-03 02:54:38 -0500
committerJohn Fultz <jfultz@wolfram.com>2016-07-03 02:54:38 -0500
commitda2f20720facda706be06b5813ab20057d5b4de9 (patch)
treee2d266054b384d7d5a5fd38c19bf18d1f952ed61 /move.cpp
parent0cda99549250c87ab9c9b20044767a7615e279c6 (diff)
Fix problems with "ex n" where n is a number.
Found a crash where you enter "ex 4" twice, and it would crash. This led me to look up how this was implemented, and it wasn't very robust. It also didn't save properly in the GCG. So I created a new move type which I called a BlindExchange and implemented it throughout the system.
Diffstat (limited to 'move.cpp')
-rw-r--r--move.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/move.cpp b/move.cpp
index eaaf8b6..7f77dc5 100644
--- a/move.cpp
+++ b/move.cpp
@@ -48,6 +48,10 @@ bool operator==(const Move &move1, const Move &move2)
ret = (Quackle::String::alphabetize(move1.tiles()) == Quackle::String::alphabetize(move2.tiles()));
break;
+ case Quackle::Move::BlindExchange:
+ ret = (move1.tiles().length() == move2.tiles().length());
+ break;
+
case Quackle::Move::Pass:
case Quackle::Move::Nonmove:
case Quackle::Move::TimePenalty:
@@ -124,6 +128,7 @@ UVString Move::xml() const
break;
case Exchange:
+ case BlindExchange:
actionString = MARK_UV("exchange");
includeTiles = true;
break;
@@ -180,10 +185,12 @@ UVString Move::toString() const
{
UVOStringStream ss;
- if (action == Quackle::Move::Pass)
- ss << "- ";
- else if (action == Quackle::Move::Exchange)
- ss << "-" << QUACKLE_ALPHABET_PARAMETERS->userVisible(m_tiles);
+ if (action == Quackle::Move::Pass)
+ ss << "- ";
+ else if (action == Quackle::Move::Exchange)
+ ss << "-" << QUACKLE_ALPHABET_PARAMETERS->userVisible(m_tiles);
+ else if (action == Quackle::Move::BlindExchange)
+ ss << "-" << m_tiles.length();
else if (action == Quackle::Move::Nonmove)
ss << "nonmove";
else if (action == Quackle::Move::TimePenalty)
@@ -290,11 +297,11 @@ Move Move::createChallengedPhoney(int zeroIndexedRow, int zeroIndexedColumn, boo
return move;
}
-Move Move::createExchangeMove(LetterString tilesToExchange)
+Move Move::createExchangeMove(LetterString tilesToExchange, bool isBlind)
{
Move move;
- move.action = Move::Exchange;
+ move.action = isBlind ? Move::BlindExchange : Move::Exchange;
move.setTiles(tilesToExchange);
move.score = 0;