[gnome-games] Make default game use the AI chosen from the previous game (Robert Ancell, Bug #446950)



commit b749cd0fabf77cf73f4a57c799ba8636cb718d71
Author: Robert Ancell <robert ancell gmail com>
Date:   Tue Sep 8 12:46:36 2009 +1000

    Make default game use the AI chosen from the previous game (Robert Ancell, Bug #446950)

 glchess/src/lib/main.py |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/glchess/src/lib/main.py b/glchess/src/lib/main.py
index 1b38828..baa9fe8 100644
--- a/glchess/src/lib/main.py
+++ b/glchess/src/lib/main.py
@@ -669,13 +669,20 @@ class Application:
 
         # Start default game if no game present
         if self.__game is None and len(self.__aiProfiles) > 0:
+            # Try the previously used AIs first, then any other AI on easy mode
+            possibleAIs = [(config.get('new_game_dialog/black/type'),
+                            config.get('new_game_dialog/black/difficulty')),
+                           (config.get('new_game_dialog/white/type'),
+                            config.get('new_game_dialog/white/difficulty'))]
             for p in profiles:
-                if self.__aiProfiles.has_key(p.name):
-                    aiName = p.name
+                possibleAIs.append((p.name, 'easy'))
+            
+            for (name, difficulty) in possibleAIs:
+                if self.__aiProfiles.has_key(name):
+                    black = (name, difficulty)
                     break
-            black = (aiName, 'easy')
             # Translators: Name of a human versus AI game. The %s is replaced with the name of the AI player
-            gameName = _('Human versus %s') % aiName
+            gameName = _('Human versus %s') % black[0]
             # Translators: Name of white player in a default game
             whiteName =  _('White')
             # Translators: Name of black player in a default game            



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