mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-13 01:22:41 +01:00
DroidFish: Avoid crash if asked to speak a null move.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user