diff --git a/DroidFish/res/values/strings.xml b/DroidFish/res/values/strings.xml index 9e3567a..8732c90 100644 --- a/DroidFish/res/values/strings.xml +++ b/DroidFish/res/values/strings.xml @@ -707,11 +707,13 @@ you are not actively using the program.\ sound speech_en speech_de + speech_es Off Play sound English Speech German Speech - + Spanish Speech + diff --git a/DroidFish/src/org/petero/droidfish/Speech.java b/DroidFish/src/org/petero/droidfish/Speech.java index 39bfa5c..287c989 100644 --- a/DroidFish/src/org/petero/droidfish/Speech.java +++ b/DroidFish/src/org/petero/droidfish/Speech.java @@ -39,6 +39,7 @@ public class Speech { public enum Language { EN, // English DE, // German + ES, // Spanish NONE; // Not supported public static Language fromString(String langStr) { @@ -46,6 +47,8 @@ public class Speech { return EN; if ("de".equals(langStr)) return DE; + if ("es".equals(langStr)) + return ES; return NONE; } } @@ -223,6 +226,8 @@ public class Speech { return Locale.US; case DE: return Locale.GERMANY; + case ES: + return new Locale("es", "ES"); case NONE: return null; } @@ -248,7 +253,7 @@ public class Speech { case Piece.WBISHOP: return "Bishop"; case Piece.WKNIGHT: return "Knight"; default: return ""; - } + } case DE: switch (piece) { case Piece.WKING: return "König"; @@ -257,7 +262,16 @@ public class Speech { case Piece.WBISHOP: return "Läufer"; case Piece.WKNIGHT: return "Springer"; default: return ""; - } + } + case ES: + switch (piece) { + case Piece.WKING: return "Rey"; + case Piece.WQUEEN: return "Dama"; + case Piece.WROOK: return "Torre"; + case Piece.WBISHOP: return "Alfil"; + case Piece.WKNIGHT: return "Caballo"; + default: return ""; + } case NONE: return ""; } @@ -272,6 +286,8 @@ public class Speech { return from; case DE: return from; + case ES: + return from; case NONE: return ""; } @@ -288,6 +304,8 @@ public class Speech { return to.startsWith("e") ? "take" : "takes"; case DE: return "schlägt"; + case ES: + return "captura"; case NONE: return ""; } @@ -300,6 +318,8 @@ public class Speech { return kingSide ? "Short castle" : "Long castle"; case DE: return kingSide ? "Kleine Rochade" : "Große Rochade"; + case ES: + return kingSide ? "Enroque corto" : "Enroque largo"; case NONE: return ""; } @@ -312,6 +332,8 @@ public class Speech { return ""; case DE: return "en passant"; + case ES: + return "al paso"; case NONE: return ""; } @@ -325,6 +347,8 @@ public class Speech { return pn; case DE: return "Umwandlung zu " + pn; + case ES: + return pn; case NONE: return ""; } @@ -337,6 +361,8 @@ public class Speech { return "check!"; case DE: return "Schach!"; + case ES: + return ",jaque!"; case NONE: return ""; } @@ -349,6 +375,8 @@ public class Speech { return "check mate!"; case DE: return "Schach matt!"; + case ES: + return ",mate!"; case NONE: return ""; } diff --git a/DroidFishTest/src/org/petero/droidfish/gamelogic/SpeechTest.java b/DroidFishTest/src/org/petero/droidfish/gamelogic/SpeechTest.java index c4303c5..58827a8 100644 --- a/DroidFishTest/src/org/petero/droidfish/gamelogic/SpeechTest.java +++ b/DroidFishTest/src/org/petero/droidfish/gamelogic/SpeechTest.java @@ -43,165 +43,168 @@ public class SpeechTest extends TestCase { } public void testEnglish() { - String[] lang = {"en", "de"}; + String[] lang = {"en", "de", "es"}; { Game game = new Game(null, new TimeControlData()); Pair res = game.processString("e4"); - assertEquals(new String[]{"e4", "e4"}, + assertEquals(new String[]{"e4", "e4", "e4"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("d5"); - assertEquals(new String[]{"d5", "d5"}, + assertEquals(new String[]{"d5", "d5", "d5"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("exd5"); - assertEquals(new String[]{"e takes d5", "e schlägt d5"}, + assertEquals(new String[]{"e takes d5", "e schlägt d5", "e captura d5"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("Qxd5"); - assertEquals(new String[]{"Queen takes d5", "Dame schlägt d5"}, + assertEquals(new String[]{"Queen takes d5", "Dame schlägt d5", "Dama captura d5"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("Ne2"); - assertEquals(new String[]{"Knight e2", "Springer e2"}, + assertEquals(new String[]{"Knight e2", "Springer e2", "Caballo e2"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("Nf6"); - assertEquals(new String[]{"Knight f6", "Springer f6"}, + assertEquals(new String[]{"Knight f6", "Springer f6", "Caballo f6"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("Nbc3"); - assertEquals(new String[]{"Knight b c3", "Springer b c3"}, + assertEquals(new String[]{"Knight b c3", "Springer b c3", "Caballo b c3"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("e5"); - assertEquals(new String[]{"e5", "e5"}, + assertEquals(new String[]{"e5", "e5", "e5"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("b4"); - assertEquals(new String[]{"b4", "b4"}, + assertEquals(new String[]{"b4", "b4", "b4"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("a5"); - assertEquals(new String[]{"a5", "a5"}, + assertEquals(new String[]{"a5", "a5", "a5"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("a3"); - assertEquals(new String[]{"a3", "a3"}, + assertEquals(new String[]{"a3", "a3", "a3"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("axb4"); - assertEquals(new String[]{"ae takes b4", "a schlägt b4"}, + assertEquals(new String[]{"ae takes b4", "a schlägt b4", "a captura b4"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("axb4"); - assertEquals(new String[]{"ae takes b4", "a schlägt b4"}, + assertEquals(new String[]{"ae takes b4", "a schlägt b4", "a captura b4"}, moveToText(game.prevPos(), res.second, lang)); } { Game game = new Game(null, new TimeControlData()); Pair res = game.processString("d4"); - assertEquals(new String[]{"d4", "d4"}, + assertEquals(new String[]{"d4", "d4", "d4"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("e5"); - assertEquals(new String[]{"e5", "e5"}, moveToText(game.prevPos(), res.second, lang)); + assertEquals(new String[]{"e5", "e5", "e5"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("dxe5"); - assertEquals(new String[]{"d take e5", "d schlägt e5"}, moveToText(game.prevPos(), res.second, lang)); + assertEquals(new String[]{"d take e5", "d schlägt e5", "d captura e5"}, + moveToText(game.prevPos(), res.second, lang)); res = game.processString("f6"); - assertEquals(new String[]{"f6", "f6"}, moveToText(game.prevPos(), res.second, lang)); + assertEquals(new String[]{"f6", "f6", "f6"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("exf6"); - assertEquals(new String[]{"e takes f6", "e schlägt f6"}, moveToText(game.prevPos(), res.second, lang)); + assertEquals(new String[]{"e takes f6", "e schlägt f6", "e captura f6"}, + moveToText(game.prevPos(), res.second, lang)); res = game.processString("Bb4"); - assertEquals(new String[]{"Bishop b4 check!", "Läufer b4 Schach!"}, + assertEquals(new String[]{"Bishop b4 check!", "Läufer b4 Schach!", "Alfil b4 ,jaque!"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("c3"); - assertEquals(new String[]{"c3", "c3"}, + assertEquals(new String[]{"c3", "c3", "c3"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("Ne7"); - assertEquals(new String[]{"Knight e7", "Springer e7"}, + assertEquals(new String[]{"Knight e7", "Springer e7", "Caballo e7"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("cxb4"); - assertEquals(new String[]{"c takes b4", "c schlägt b4"}, + assertEquals(new String[]{"c takes b4", "c schlägt b4", "c captura b4"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("O-O"); - assertEquals(new String[]{"Short castle", "Kleine Rochade"}, + assertEquals(new String[]{"Short castle", "Kleine Rochade", "Enroque corto"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("fxg7"); - assertEquals(new String[]{"f takes g7", "f schlägt g7"}, + assertEquals(new String[]{"f takes g7", "f schlägt g7", "f captura g7"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("h6"); - assertEquals(new String[]{"h6", "h6"}, + assertEquals(new String[]{"h6", "h6", "h6"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("gxf8Q+"); - assertEquals(new String[]{"g takes f8 Queen check!", "g schlägt f8 Umwandlung zu Dame Schach!"}, + assertEquals(new String[]{"g takes f8 Queen check!", "g schlägt f8 Umwandlung zu Dame Schach!", + "g captura f8 Dama ,jaque!"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("Kxf8"); - assertEquals(new String[]{"King takes f8", "König schlägt f8"}, + assertEquals(new String[]{"King takes f8", "König schlägt f8", "Rey captura f8"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("b5"); - assertEquals(new String[]{"b5", "b5"}, + assertEquals(new String[]{"b5", "b5", "b5"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("a5"); - assertEquals(new String[]{"a5", "a5"}, + assertEquals(new String[]{"a5", "a5", "a5"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("bxa6"); - assertEquals(new String[]{"b takes a6", "b schlägt a6 en passant"}, + assertEquals(new String[]{"b takes a6", "b schlägt a6 en passant", "b captura a6 al paso"}, moveToText(game.prevPos(), res.second, lang)); } { Game game = new Game(null, new TimeControlData()); Pair res = game.processString("f4"); - assertEquals(new String[]{"f4", "f4"}, + assertEquals(new String[]{"f4", "f4", "f4"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("e5"); - assertEquals(new String[]{"e5", "e5"}, + assertEquals(new String[]{"e5", "e5", "e5"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("g4"); - assertEquals(new String[]{"g4", "g4"}, + assertEquals(new String[]{"g4", "g4", "g4"}, moveToText(game.prevPos(), res.second, lang)); res = game.processString("Qh4"); - assertEquals(new String[]{"Queen h4 check mate!", "Dame h4 Schach matt!"}, + assertEquals(new String[]{"Queen h4 check mate!", "Dame h4 Schach matt!", "Dama h4 ,mate!"}, moveToText(game.prevPos(), res.second, lang)); } { Game game = new Game(null, new TimeControlData()); playMoves(game, "d4 d5 Nc3 Nc6 Bf4 Bf5 Qd2 Qd7"); Pair res = game.processString("O-O-O"); - assertEquals(new String[]{"Long castle", "Große Rochade"}, + assertEquals(new String[]{"Long castle", "Große Rochade", "Enroque largo"}, moveToText(game.prevPos(), res.second, lang)); playMoves(game, "Nxd4 Nxd5 Qxd5 Qxd4 Qxd4 Nf3 Qxd1 Kxd1"); res = game.processString("O-O-O"); - assertEquals(new String[]{"Long castle check!", "Große Rochade Schach!"}, + assertEquals(new String[]{"Long castle check!", "Große Rochade Schach!", "Enroque largo ,jaque!"}, moveToText(game.prevPos(), res.second, lang)); playMoves(game, "Kc1"); res = game.processString("Rd7"); - assertEquals(new String[]{"Rook d7", "Turm d7"}, + assertEquals(new String[]{"Rook d7", "Turm d7", "Torre d7"}, moveToText(game.prevPos(), res.second, lang)); } { Game game = new Game(null, new TimeControlData()); playMoves(game, "e4 e5 h3 Bb4 Ne2 Bc3"); Pair res = game.processString("Nexc3"); - assertEquals(new String[]{"Knight e takes c3", "Springer e schlägt c3"}, + assertEquals(new String[]{"Knight e takes c3", "Springer e schlägt c3", "Caballo e captura c3"}, moveToText(game.prevPos(), res.second, lang)); } }