[gnome-chess] Add castling text for human move descriptions



commit 064973fea7f80f54e446228cb0ea65d53578f82f
Author: Michael Catanzaro <mike catanzaro gmail com>
Date:   Sat Jun 29 10:35:16 2013 -0500

    Add castling text for human move descriptions
    
    E.g. history will now show "White king castles kingside" instead of
    "white king moves from e1 to g1"

 src/gnome-chess.vala |   46 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 32 insertions(+), 14 deletions(-)
---
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 8a45034..3294ed1 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -750,20 +750,38 @@ public class Application : Gtk.Application
         switch (scene.move_format)
         {
         case "human":
-            int index;
-            if (move.victim == null)
-                index = 0;
-            else
-                index = move.victim.type + 1;
-            index += move.piece.type * 6;
-            if (move.piece.player.color == Color.BLACK)
-                index += 36;
-
-            // FIXME: Use castling text e.g. "White castles kingside" (do for next release, we are in a 
string freeze)
-
-            var start = "%c%d".printf ('a' + move.f0, move.r0 + 1);
-            var end = "%c%d".printf ('a' + move.f1, move.r1 + 1);
-            move_text = _(human_descriptions[index]).printf (start, end);
+            if (move.moved_rook == null)
+            {
+                int index;
+                if (move.victim == null)
+                    index = 0;
+                else
+                    index = move.victim.type + 1;
+                index += move.piece.type * 6;
+                if (move.piece.player.color == Color.BLACK)
+                    index += 36;
+
+                var start = "%c%d".printf ('a' + move.f0, move.r0 + 1);
+                var end = "%c%d".printf ('a' + move.f1, move.r1 + 1);
+                move_text = _(human_descriptions[index]).printf (start, end);
+            }
+            else if (move.f0 < move.f1 && move.r0 == 0)
+            {
+                move_text = _("White king castles kingside");
+            }
+            else if (move.f1 < move.f0 && move.r0 == 0)
+            {
+                move_text = _("White king castles queenside");
+            }
+            else if (move.f0 < move.f1 && move.r0 == 7)
+            {
+                move_text = _("Black king castles kingside");
+            }
+            else if (move.f1 < move.f0 && move.r0 == 7)
+            {
+                move_text = _("Black king castles queenside");
+            }
+            else assert_not_reached ();
             break;
 
         case "san":


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]