mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2024-11-27 06:10:28 +01:00
DroidFish: Avoid crash if asked to speak a null move.
This commit is contained in:
parent
45a8bee002
commit
f1e62c5263
|
@ -145,7 +145,7 @@ public class Speech {
|
|||
|
||||
/** Convert move "move" in position "pos" to a sentence that can be spoken. */
|
||||
public static String moveToText(Position pos, Move move, Language lang) {
|
||||
if (move == null)
|
||||
if (move == null || move.from == move.to)
|
||||
return "";
|
||||
|
||||
String moveStr = TextIO.moveToString(pos, move, false, false);
|
||||
|
|
|
@ -206,6 +206,8 @@ public class SpeechTest extends TestCase {
|
|||
Pair<Boolean,Move> res = game.processString("Nexc3");
|
||||
assertEquals(new String[]{"Knight e takes, c3", "Springer e schlägt c3", "Caballo e captura c3"},
|
||||
moveToText(game.prevPos(), res.second, lang));
|
||||
assertEquals(new String[]{"", "", ""},
|
||||
moveToText(game.prevPos(), new Move(0, 0, 0), lang));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user