[gnome-games] Standardise Python class format



commit da144b6ddaa8fcbb8dce3c4d5dec766b836999b5
Author: Robert Ancell <robert ancell gmail com>
Date:   Tue May 19 16:19:08 2009 +0200

    Standardise Python class format
---
 glchess/src/lib/ai.py                          |    8 ++-
 glchess/src/lib/cecp.py                        |    9 +--
 glchess/src/lib/chess/board.py                 |   23 ++----
 glchess/src/lib/chess/pgn.py                   |    2 -
 glchess/src/lib/display.py                     |   52 ++++----------
 glchess/src/lib/game.py                        |   57 +++++-----------
 glchess/src/lib/ggz/client.py                  |   67 ++++++++----------
 glchess/src/lib/ggz/protocol.py                |   22 ++++--
 glchess/src/lib/gtkui/chessview.py             |   21 ++----
 glchess/src/lib/gtkui/dialogs.py               |    9 ++-
 glchess/src/lib/gtkui/gtkui.py                 |   63 ++++++-----------
 glchess/src/lib/gtkui/network.py               |    2 +
 glchess/src/lib/main.py                        |   52 +++-----------
 glchess/src/lib/network.py                     |    3 +
 glchess/src/lib/player.py                      |    1 -
 glchess/src/lib/scene/human.py                 |   11 +--
 glchess/src/lib/scene/opengl/builtin_models.py |   39 +++-------
 glchess/src/lib/scene/opengl/opengl.py         |   90 ++++++++----------------
 glchess/src/lib/scene/opengl/texture.py        |   25 +++----
 glchess/src/lib/uci.py                         |   21 ++----
 20 files changed, 207 insertions(+), 370 deletions(-)

diff --git a/glchess/src/lib/ai.py b/glchess/src/lib/ai.py
index af536cb..e2411ac 100644
--- a/glchess/src/lib/ai.py
+++ b/glchess/src/lib/ai.py
@@ -22,17 +22,20 @@ UCI  = 'UCI'
 class Option:
     """
     """
+
     value = ''
 
 class Level:
     """
     """
+
     def __init__(self):
         self.options = []
 
 class Profile:
     """
-    """   
+    """
+
     def __init__(self):
         self.name = ''
         self.protocol = ''
@@ -159,6 +162,7 @@ def loadProfiles():
 class CECPConnection(cecp.Connection):
     """
     """
+
     def __init__(self, player):
         """
         """
@@ -186,6 +190,7 @@ class CECPConnection(cecp.Connection):
 class UCIConnection(uci.StateMachine):
     """
     """
+
     def __init__(self, player):
         """
         """
@@ -216,6 +221,7 @@ signal.signal(signal.SIGCHLD, _cDied)
 class Player(game.ChessPlayer):
     """
     """
+
     def __init__(self, name, profile, level = 'normal'):
         """Constructor for an AI player.
         
diff --git a/glchess/src/lib/cecp.py b/glchess/src/lib/cecp.py
index 33c6f87..d7e3717 100644
--- a/glchess/src/lib/cecp.py
+++ b/glchess/src/lib/cecp.py
@@ -4,13 +4,7 @@ __license__ = 'GNU General Public License Version 2'
 __copyright__ = 'Copyright 2005-2006  Robert Ancell'
 
 class CECPProtocol:
-    """CECP protocol en/decoder.
-    
-    
-    """
-    
-    # Data being accumulated to be parsed
-    __buffer = ''
+    """CECP protocol en/decoder."""
     
     NEWLINE             = '\n'
     MOVE_PREFIXS        = ['My move is: ', 'my move is ', 'move ']
@@ -21,6 +15,7 @@ class CECPProtocol:
     def __init__(self):
         """
         """
+        self.__buffer = '' # Data being accumulated to be parsed
         # Go to simple interface mode
         self.onOutgoingData('xboard\n')
         
diff --git a/glchess/src/lib/chess/board.py b/glchess/src/lib/chess/board.py
index f3197cd..f227916 100644
--- a/glchess/src/lib/chess/board.py
+++ b/glchess/src/lib/chess/board.py
@@ -95,12 +95,6 @@ KING   = 'K'
 class ChessPiece:
     """An object representing a chess piece"""
     
-    # The colour of the piece
-    __colour = None
-    
-    # The type of the piece (pawn, knight ...) 
-    __type = None
-    
     def __init__(self, colour, type):
         """Constructor for a chess piece.
         
@@ -134,22 +128,18 @@ class ChessPiece:
 class ChessPlayerState:
     """
     """
-    # Flags to show if still able to castle
-    canShortCastle = True
-    canLongCastle  = True
-    
-    # Flag to show if this player is in check
-    inCheck        = False
     
     def __init__(self, state = None):
         """
         """
-        if state is None:
-            return
+        self.canShortCastle = True
+        self.canLongCastle  = True
+        self.inCheck        = False
 
         # Copy the exisiting state
-        self.canShortCastle = state.canShortCastle
-        self.canLongCastle = state.canLongCastle
+        if state is not None:
+            self.canShortCastle = state.canShortCastle
+            self.canLongCastle = state.canLongCastle
         
     def __eq__(self, state):
         """Compare two states are equal"""
@@ -780,6 +770,7 @@ class ChessBoard:
     
     This class contains a chess board and all its previous states.
     """
+
     def __init__(self, initialState = None):
         """Constructor for a chess board"""
         self.__inCallback = False
diff --git a/glchess/src/lib/chess/pgn.py b/glchess/src/lib/chess/pgn.py
index a9d6b89..c8719bd 100644
--- a/glchess/src/lib/chess/pgn.py
+++ b/glchess/src/lib/chess/pgn.py
@@ -483,8 +483,6 @@ class PGNGame:
 class PGN:
     """
     """
-    
-    __games = None
 
     def __init__(self, fileName = None, maxGames = None):
         """Create a PGN reader/writer.
diff --git a/glchess/src/lib/display.py b/glchess/src/lib/display.py
index 72d3d7b..3e9481d 100644
--- a/glchess/src/lib/display.py
+++ b/glchess/src/lib/display.py
@@ -15,7 +15,7 @@ import chess.board
 
 class MovePlayer(game.ChessPlayer):
     """This class provides a pseudo-player to watch for piece movements"""
-    
+
     def __init__(self, view):
         """Constructor for a move player.
         
@@ -46,14 +46,12 @@ class MovePlayer(game.ChessPlayer):
 class CairoPiece(scene.ChessPieceFeedback):
     """
     """
-    
-    model = None
-    
-    location = ''
-    
+
     def __init__(self, scene, piece):
         self.scene = scene
         self.piece = piece
+        self.model = None
+        self.location = ''
 
     def onDeleted(self):
         """Called by scene.ChessPieceFeedback"""
@@ -66,16 +64,6 @@ class CairoPiece(scene.ChessPieceFeedback):
 class SceneCairo(scene.SceneFeedback, scene.human.SceneHumanInput):
     """
     """
-    controller = None
-    
-    # The game this scene is rendering
-    game = None
-    
-    # TODO
-    pieces       = None
-    
-    # FIXME: Abort when scenes changed
-    waitingPiece = None
 
     def __init__(self, view):
         """
@@ -84,6 +72,7 @@ class SceneCairo(scene.SceneFeedback, scene.human.SceneHumanInput):
         self.controller = scene.cairo.Scene(self)
         self.game = view.game
         self.pieces = {}
+        self.waitingPiece = None
         scene.human.SceneHumanInput.__init__(self)
         
     def getPieces(self):
@@ -148,14 +137,12 @@ class SceneCairo(scene.SceneFeedback, scene.human.SceneHumanInput):
 class OpenGLPiece(scene.ChessPieceFeedback):
     """
     """
-    
-    model = None
-    
-    location = ''
-    
+
     def __init__(self, scene, piece):
         self.scene = scene
         self.piece = piece
+        self.model = None
+        self.location = ''
 
     def onDeleted(self):
         """Called by scene.ChessPieceFeedback"""
@@ -167,15 +154,7 @@ class OpenGLPiece(scene.ChessPieceFeedback):
 
 class SceneOpenGL(scene.SceneFeedback, scene.human.SceneHumanInput):
     """
-    """
-    # The game this scene is rendering
-    game          = None
-    
-    # TODO
-    pieces        = None
-    
-    # FIXME: Abort when scenes changed
-    waitingPiece = None
+    """   
 
     def __init__(self, view):
         """Constructor for a glChess scene.
@@ -185,6 +164,7 @@ class SceneOpenGL(scene.SceneFeedback, scene.human.SceneHumanInput):
         self.view = view
         self.game = view.game
         self.pieces = {}
+        self.waitingPiece = None
 
         # Call parent constructors
         self.controller = scene.opengl.Scene(self)
@@ -251,10 +231,8 @@ class SceneOpenGL(scene.SceneFeedback, scene.human.SceneHumanInput):
 
 class Splashscreen(ui.ViewFeedback):
     """
-    """    
-    application = None
-    scene       = None
-    
+    """
+
     def __init__(self, application):
         """Constructor.
         
@@ -332,9 +310,7 @@ class Splashscreen(ui.ViewFeedback):
 class View(ui.ViewFeedback):
     """
     """
-    # The controller object for this view
-    controller  = None
-    
+
     def __init__(self, game):
         """Constructor.
         
@@ -353,6 +329,8 @@ class View(ui.ViewFeedback):
         self.highlightParams = (None, None, None, None)
         self.changedHighlight = True
         
+        self.controller  = None
+        
         # Use a Cairo scene by default - it will be replaced by an OpenGL one if that is the requested view
         # I wanted to remove this but then scene is None and there are a number of issues...
         # This should be cleaned up
diff --git a/glchess/src/lib/game.py b/glchess/src/lib/game.py
index 32f61de..9b50726 100644
--- a/glchess/src/lib/game.py
+++ b/glchess/src/lib/game.py
@@ -30,6 +30,7 @@ RULE_ABANDONMENT           = 'ABANDONMENT'
 class ChessMove:
     """
     """
+
     # The move number (game starts at 0)
     number     = 0
     
@@ -68,21 +69,15 @@ class ChessMove:
 class ChessPlayer:
     """
     """
-    # The name of the player
-    __name = None
-    
-    # The game this player is in
-    __game = None
 
-    # Flag to show if this player is able to move
-    __readyToMove = False
-    
     def __init__(self, name):
         """Constructor for a chess player.
 
         'name' is the name of the player.
         """
         self.__name = str(name)
+        self.__game = None
+        self.__readyToMove = False
         self.isAlive = True
 
     # Methods to extend
@@ -217,9 +212,6 @@ class ChessGameBoard(chess.board.ChessBoard):
     """
     """
     
-    # Reference to the game
-    __game = None
-    
     def __init__(self, game):
         """
         """
@@ -289,37 +281,24 @@ class ChessGameSANConverter(chess.san.SANConverter):
 class ChessGame:
     """
     """    
-    # The players and spectators in the game
-    __players = None
-    __whitePlayer = None
-    __blackPlayer = None
-    __spectators = None
-    
-    # The board to move on
-    board = None
-    
-    # The game state (started and player to move)
-    __started = False
-    __currentPlayer = None
-    
-    __moves = None
-    
-    __inCallback = False
-    __queuedCalls = None
-    
-    result  = RESULT_IN_PROGRESS
-    rule    = None
-    
-    whiteTimer = None
-    blackTimer = None
-    
+
     def __init__(self):
         """Game constructor"""
         self.__players = []
         self.__spectators = []
-        self.board = ChessGameBoard(self)
+        self.__whitePlayer = None
+        self.__blackPlayer = None
+        self.__currentPlayer = None
         self.__moves = []
+        self.__inCallback = False
         self.__queuedCalls = []
+        self.board = ChessGameBoard(self)
+
+        self.__started = False
+        self.result  = RESULT_IN_PROGRESS
+        self.rule    = None    
+        self.whiteTimer = None
+        self.blackTimer = None
         
     def getAlivePieces(self, moveNumber = -1):
         """Get the alive pieces on the board.
@@ -811,12 +790,10 @@ if __name__ == '__main__':
     g = p.getGame(0)
 
     class PGNPlayer(ChessPlayer):
-        __moveNumber = 1
-        
-        __isWhite = True
-        
+
         def __init__(self, isWhite):
             self.__isWhite = isWhite
+            self.__moveNumber = 1
         
         def readyToMove(self):
             if self.__isWhite:
diff --git a/glchess/src/lib/ggz/client.py b/glchess/src/lib/ggz/client.py
index 84673fe..e037318 100644
--- a/glchess/src/lib/ggz/client.py
+++ b/glchess/src/lib/ggz/client.py
@@ -114,63 +114,56 @@ class ClientFeedback:
         pass
 
 class Game:
-    id = ''
     
-    name = ''
-    version = ''
-    
-    protocol_engine = ''
-    protocol_version = ''
-    
-    nPlayers = 0
-    
-    author = ''
-    url = ''
+    def __init__(self):
+        self.id = ''
+        self.name = ''
+        self.version = ''
+        self.protocol_engine = ''
+        self.protocol_version = ''
+        self.nPlayers = 0
+        self.author = ''
+        self.url = ''
 
 class Room:
-    id = ''
-    
-    game = None
     
-    nPlayers = 0
+    def __init__(self):
+        self.id = ''
+        self.game = None    
+        self.nPlayers = 0
 
 class Table:
-    id = ''
-    
-    room = ''
-    
-    game = None
-    
-    status = ''
-    
-    description = ''
     
     def __init__(self, nSeats):
+        self.id = ''
+        self.room = ''
+        self.game = None
+        self.status = ''
+        self.description = ''
         self.seats = []
         for i in xrange(nSeats):
             seat = Seat()
             self.seats.append(seat)
 
 class Seat:
-    type = ''
     
-    user = ''
+    def __init__(self):
+        self.type = ''
+        self.user = ''
 
 class Player:
-    name = ''
-    
-    type = ''
-    
-    table = None
-    
-    perms = 0
     
-    lag = 0
-    
-    room = None
-    lastRoom = None
+    def __init__(self):
+        self.name = ''
+        self.type = ''
+        self.table = None
+        self.perms = 0
+        self.lag = 0
+        self.room = None
+        self.lastRoom = None
     
 class MainChannel(ChannelFeedback, protocol.ParserFeedback):
+
     def __init__(self, client):
         self.client = client
         self.decoder = protocol.Decoder(self)
diff --git a/glchess/src/lib/ggz/protocol.py b/glchess/src/lib/ggz/protocol.py
index 9a3e838..c269152 100644
--- a/glchess/src/lib/ggz/protocol.py
+++ b/glchess/src/lib/ggz/protocol.py
@@ -20,6 +20,7 @@ import xml.sax.handler
 "</UPDATE>"
 
 class ParserFeedback:
+
     def onResult(self, action, code):
         pass
     
@@ -68,9 +69,10 @@ class ParserFeedback:
 class GGZParser:
     """
     """
-    parent = None
-
-    parser = None
+    
+    def __init__(self):
+        self.parent = None
+        self.parser = None
     
     def startElement(self, name, attributes):
         if self.parser is not None:
@@ -132,6 +134,7 @@ class GameParser(GGZParser):
     """
     
     def __init__(self):
+        GGZParser.__init__(self)
         self.bots = []
     
     def start_desc(self, attributes):
@@ -235,6 +238,7 @@ class PlayerParser(GGZParser):
 class TableSeatParser(GGZParser):
     
     def __init__(self):
+        GGZParser.__init__(self)
         self.label = ''
 
     def handle_data(self, data):
@@ -246,6 +250,7 @@ class TableSeatParser(GGZParser):
 class TableParser(GGZParser):
     
     def __init__(self):
+        GGZParser.__init__(self)
         self.seats = []
         self.description = ''
 
@@ -265,6 +270,7 @@ class TableParser(GGZParser):
 class GameListParser(GGZParser):
     
     def __init__(self):
+        GGZParser.__init__(self)
         self.games = []
     
     def start_game(self, attributes):
@@ -282,6 +288,7 @@ class GameListParser(GGZParser):
 class TableListParser(GGZParser):
     
     def __init__(self):
+        GGZParser.__init__(self)
         self.tables = []
     
     def start_table(self, attributes):
@@ -305,6 +312,7 @@ class TableListParser(GGZParser):
 class PlayerListParser(GGZParser):
     
     def __init__(self):
+        GGZParser.__init__(self)
         self.players = []
     
     def start_player(self, attributes):
@@ -328,6 +336,7 @@ class PlayerListParser(GGZParser):
 class RoomListParser(GGZParser):
     
     def __init__(self):
+        GGZParser.__init__(self)
         self.rooms = []
         
     def start_room(self, attributes):
@@ -362,6 +371,7 @@ class ServerParser(GGZParser):
 class MOTDParser(GGZParser):
     
     def __init__(self):
+        GGZParser.__init__(self)
         self.motd = ''
     
     def handle_data(self, data):
@@ -373,9 +383,6 @@ class MOTDParser(GGZParser):
 
 class RoomUpdateParser(GGZParser):
     
-    def __init__(self):
-        pass
-    
     def start_room(self, attributes):
         self.push(RoomParser(), attributes)
         
@@ -436,6 +443,7 @@ class PlayerUpdateParser(GGZParser):
 class TableUpdateParser(GGZParser):   
 
     def __init__(self):
+        GGZParser.__init__(self)
         self.table = None
     
     def start_table(self, attributes):
@@ -523,6 +531,7 @@ class TableUpdateParser(GGZParser):
 class ChatParser(GGZParser):
     
     def __init__(self):
+        GGZParser.__init__(self)
         self.text = ''
     
     def handle_data(self, data):
@@ -615,6 +624,7 @@ class SessionParser(GGZParser):
 class BaseParser(GGZParser):
     
     def __init__(self, decoder):
+        GGZParser.__init__(self)
         self.decoder = decoder
 
     def start_session(self, attributes):
diff --git a/glchess/src/lib/gtkui/chessview.py b/glchess/src/lib/gtkui/chessview.py
index 353409c..580f81c 100644
--- a/glchess/src/lib/gtkui/chessview.py
+++ b/glchess/src/lib/gtkui/chessview.py
@@ -45,24 +45,18 @@ __all__ = ['GtkView']
 
 class GtkViewArea(gtk.DrawingArea):
     """Custom widget to render an OpenGL scene"""
-    # The view this widget is rendering
-    view = None
-
-    # Pixmaps to use for double buffering
-    pixmap = None
-    dynamicPixmap = None
-    
-    # Flag to show if this scene is to be rendered using OpenGL
-    renderGL = False
-    
-    # TODO...
-    __glDrawable = None
     
     def __init__(self, view):
         """
         """
         gtk.DrawingArea.__init__(self)
-        
+
+        # Pixmaps to use for double buffering
+        self.pixmap = None
+        self.dynamicPixmap = None
+
+        self.renderGL = False # Flag to show if this scene is to be rendered using OpenGL
+        self.__glDrawable = None
         self.view = view
 
         # Allow notification of button presses
@@ -221,6 +215,7 @@ class GtkViewArea(gtk.DrawingArea):
 class GtkView(glchess.ui.ViewController):
     """
     """
+
     def __init__(self, ui, feedback, moveFormat = 'human', showComments = False):
         """Constructor for a view.
         
diff --git a/glchess/src/lib/gtkui/dialogs.py b/glchess/src/lib/gtkui/dialogs.py
index f6010da..6568889 100644
--- a/glchess/src/lib/gtkui/dialogs.py
+++ b/glchess/src/lib/gtkui/dialogs.py
@@ -14,7 +14,6 @@ import gtkui
 import glchess.ui
 
 class GtkServerList:
-    __gui = None
 
     def __init__(self, gui):
         self.__gui = gui
@@ -74,7 +73,8 @@ class GtkServerList:
 
 class GtkNewGameDialog:
     """
-    """    
+    """
+
     def __init__(self, mainUI, aiModel, game = None):
         """Constructor for a new game dialog.
         
@@ -410,7 +410,8 @@ class GtkNewGameDialog:
 
 class GtkLoadGameDialog:
     """
-    """    
+    """
+
     def __init__(self, mainUI):
         """
         """
@@ -485,6 +486,7 @@ class GtkLoadGameDialog:
 class GtkSaveGameDialog:
     """
     """
+
     def __init__(self, mainUI, view, path = None):
         """
         """
@@ -567,6 +569,7 @@ class GtkSaveGameDialog:
 class GtkPreferencesDialog:
     """
     """
+
     def __init__(self, mainUI):
         """Constructor for the preferences dialog.
         
diff --git a/glchess/src/lib/gtkui/gtkui.py b/glchess/src/lib/gtkui/gtkui.py
index d1b523d..9353003 100644
--- a/glchess/src/lib/gtkui/gtkui.py
+++ b/glchess/src/lib/gtkui/gtkui.py
@@ -151,44 +151,6 @@ class GLibTimer(glchess.ui.Timer):
 class GtkUI(glchess.ui.UI):
     """
     """
-    # The Gtk+ GUI
-    _gui               = None
-    
-    # The time stored for animation
-    __lastTime         = None
-    __animationTimer   = None
-    
-    # The Gtk+ list model of the available player types
-    __playerModel      = None
-
-    # The about dialog open
-    __aboutDialog      = None
-
-    # Dictionary of save game dialogs keyed by view
-    __saveGameDialogs  = None
-
-    __renderGL         = False
-    openGLInfoPrinted  = False
-
-    # TODO
-    __joinGameDialogs  = None
-    __networkGames     = None
-    
-    __defaultWhiteAI   = None
-    __defaultBlackAI   = None
-
-    __attentionCounter = 0
-
-    whiteTimeString    = 'â??'
-    blackTimeString    = 'â??'
-    
-    # The window width and height when unmaximised and not fullscreen
-    width              = None
-    height             = None
-    isFullscreen       = False
-    isMaximised        = False
-    
-    view               = None
 
     def __init__(self, feedback):
         """Constructor for a GTK+ glChess GUI"""
@@ -197,8 +159,29 @@ class GtkUI(glchess.ui.UI):
         self.__networkGames = {}
         self.newGameDialog = None
         self.loadGameDialog = None
+        self.__aboutDialog = None
         self.__saveGameDialogs = {}
         self.__joinGameDialogs = []
+
+        # The time stored for animation
+        self.__lastTime         = None
+        self.__animationTimer   = None
+    
+        self.__renderGL         = False
+        self.openGLInfoPrinted  = False
+
+        self.__attentionCounter = 0
+
+        self.whiteTimeString    = 'â??'
+        self.blackTimeString    = 'â??'
+    
+        # Theo window width and height when unmaximised and not fullscreen
+        self.width              = None
+        self.height             = None
+        self.isFullscreen       = False
+        self.isMaximised        = False
+    
+        self.view               = None
         
         # Set the message panel to the tooltip style
         # (copied from Gedit)
@@ -308,10 +291,6 @@ class GtkUI(glchess.ui.UI):
         """
         iter = self.__playerModel.append()
         self.__playerModel.set(iter, 0, name, 1, 'stock_notebook', 2, name)
-        
-        # Get the human to play against this AI
-        if self.__defaultBlackAI is None:
-            self.__defaultBlackAI = name
 
     def setView(self, title, feedback, isPlayable = True):
         """Extends ui.UI"""
diff --git a/glchess/src/lib/gtkui/network.py b/glchess/src/lib/gtkui/network.py
index f4c7336..cbf3381 100644
--- a/glchess/src/lib/gtkui/network.py
+++ b/glchess/src/lib/gtkui/network.py
@@ -11,6 +11,7 @@ import glchess.ui
 _ = gettext.gettext
 
 class GtkNetworkAddDialog:
+
     def __init__(self, networkDialog, parent):
         self.__networkDialog = networkDialog
 
@@ -94,6 +95,7 @@ class GtkNetworkAddDialog:
 class GtkNetworkGameDialog(glchess.ui.NetworkController):
     """
     """
+
     def __init__(self, mainUI, feedback):
         """Constructor for a new game dialog.
         
diff --git a/glchess/src/lib/main.py b/glchess/src/lib/main.py
index da14606..cc0415a 100644
--- a/glchess/src/lib/main.py
+++ b/glchess/src/lib/main.py
@@ -57,20 +57,9 @@ class PlayerTimer(ui.TimerFeedback):
 class ChessGame(game.ChessGame):
     """
     """
-    # The view watching this scene
-    view           = None
-    
-    # The players in the game
-    __movePlayer   = None
-    __aiPlayers    = None
 
     # Mapping between piece names and promotion types
     __promotionMapping = {'queen': chess.board.QUEEN, 'knight': chess.board.KNIGHT, 'bishop': chess.board.BISHOP, 'rook': chess.board.ROOK}
-    
-    # TEMP
-    duration = 0
-    wT = None
-    bT = None
 
     def __init__(self, application, name):
         """Constructor for a chess game.
@@ -82,11 +71,17 @@ class ChessGame(game.ChessGame):
         self.name = name
         self.__aiPlayers = []
         
+        # TEMP
+        self.duration = 0
+        self.wT = None
+        self.bT = None
+        
         self.fileName    = None
         self.inHistory   = False
         self.needsSaving = False
         
         # Call parent constructor
+        self.view = None
         game.ChessGame.__init__(self)
 
         self.view = display.View(self)
@@ -320,13 +315,8 @@ class ChessGame(game.ChessGame):
         
 class UI(ui.UIFeedback):
     """
-    """    
-    application = None
-    
-    splashscreen = None
-    
-    controller = None
-    
+    """
+
     def __init__(self, application):
         """
         """
@@ -417,32 +407,14 @@ class UI(ui.UIFeedback):
 class Application:
     """
     """
-    # The glChess UI
-    ui = None
-    
-    # The AI types
-    __aiProfiles = None
-    
-    # Objects with IO keyed by file descriptor
-    ioHandlers = None
-    
-    # Network connections keyed by file descriptor
-    networkConnections = None
-    
-    # The network game detector
-    __detector = None
 
-    # The game in progress
-    __game = None
-    
     def __init__(self):
         """Constructor for glChess application"""
-        self.__aiProfiles = {}
-        self.ioHandlers = {}
-        self.networkConnections = {}
+        self.__aiProfiles = {}       # The AI types
+        self.ioHandlers = {}         # Objects with IO keyed by file descriptor
+        self.networkConnections = {} # Network connections keyed by file descriptor
+        self.__game = None # The game in progress
        
-        self.__detector = None#GameDetector(self)
-
         self.ui = UI(self)
         
         self.history = history.GameHistory()
diff --git a/glchess/src/lib/network.py b/glchess/src/lib/network.py
index 2e86e6f..f67a9b9 100644
--- a/glchess/src/lib/network.py
+++ b/glchess/src/lib/network.py
@@ -13,10 +13,12 @@ from defaults import *
 _ = gettext.gettext
 
 class GGZServer:
+
     def __init__(self, name):
         self.name = name
 
 class GGZLine:
+
     TYPE_BLANK   = 'BLANK'
     TYPE_COMMENT = 'COMMENT'
     TYPE_SECTION = 'SECTION'
@@ -190,6 +192,7 @@ class GGZConfig:
             print 'Failed to save GGZ config: %s' % e.message
 
 class GGZChannel(ggz.Channel):
+    
     def __init__(self, ui, feedback):
         self.buffer = ''
         self.ui = ui
diff --git a/glchess/src/lib/player.py b/glchess/src/lib/player.py
index a08ead2..59555f3 100644
--- a/glchess/src/lib/player.py
+++ b/glchess/src/lib/player.py
@@ -52,7 +52,6 @@ class MovePlayer(game.ChessPlayer):
 class HumanPlayer(game.ChessPlayer):
     """
     """    
-    __game = None
     
     def __init__(self, chessGame, name):
         """Constructor.
diff --git a/glchess/src/lib/scene/human.py b/glchess/src/lib/scene/human.py
index c36d5ca..f54a215 100644
--- a/glchess/src/lib/scene/human.py
+++ b/glchess/src/lib/scene/human.py
@@ -11,17 +11,12 @@ import glchess.scene
 class SceneHumanInput:
     """
     """
-    # Flag to control if human input is enabled
-    __inputEnabled = True
-
-    # The selected square to move from
-    __startSquare = None
-    
-    __showHints       = True
     
     def __init__(self):
         """Constructor for a scene with human selectable components"""
-        pass
+        self.__inputEnabled = True # Flag to control if human input is enabled
+        self.__startSquare  = None # The selected square to move from
+        self.__showHints    = True
     
     # Methods to extend
     
diff --git a/glchess/src/lib/scene/opengl/builtin_models.py b/glchess/src/lib/scene/opengl/builtin_models.py
index 4c4d950..56560c8 100644
--- a/glchess/src/lib/scene/opengl/builtin_models.py
+++ b/glchess/src/lib/scene/opengl/builtin_models.py
@@ -26,29 +26,7 @@ BLACK_SHININESS = 64.0
 
 class BuiltinSet(glchess.scene.ChessSet):
     """
-    """
-    # The models
-    __pawn   = None
-    __rook   = None
-    __knight = None
-    __bishop = None
-    __queen  = None
-    __king   = None
-    
-    # A dictionary of models indexed by name
-    __modelsByName = None
-    
-    # The rotation in degrees of pieces in the set (i.e. 0.0 for white and 180.0 for black)
-    __rotation = 0.0
-    
-    __stateColours = None
-    __defaultState = None
-    
-    # The display lists for each model
-    __displayLists = None
-    
-    # The model texture
-    __texture = None
+    """    
     
     def __init__(self, textureFileName, ambient, diffuse, specular, shininess):
         self.__pawn = Pawn()
@@ -65,6 +43,9 @@ class BuiltinSet(glchess.scene.ChessSet):
                                'king': self.__king}
         self.__displayLists = {}
         self.__stateColours = {}
+        self.__defaultState = None
+        # The rotation in degrees of pieces in the set (i.e. 0.0 for white and 180.0 for black)
+        self.__rotation = 0.0
         self.__texture = texture.Texture(textureFileName, ambient = ambient, diffuse = diffuse,
                                          specular = specular, shininess = shininess)
 
@@ -146,7 +127,8 @@ class SimpleModel:
     """
     """
     
-    pos = None
+    def __init__(self):
+        self.pos = None
     
     def start(self):
         pass
@@ -373,6 +355,7 @@ class Rook(SimpleModel):
     __revolveCoords = [(3.8, 0.0), (3.8, 2.0), (2.6, 5.0), (2.0, 10.2), (2.8, 10.2), (2.8, 13.6), (2.2, 13.6), (2.2, 13.0), (0.0, 13.0)]
                        
     def __init__(self):
+        SimpleModel.__init__(self)
         self.pos = (0.0, 0.0, 0.0)
         pass
 
@@ -383,8 +366,6 @@ class Knight(SimpleModel):
     """
     """
     
-    __maxHeight = 0.0
-    
     # The co-ordinates of the revolution that makes the model
     __revolveCoords = [(4.1, 0.0), (4.1, 2.0), (2.0, 3.6), (2.0, 4.8), (2.6, 5.8)]
     
@@ -445,6 +426,7 @@ class Knight(SimpleModel):
                (30, (68, 0, 3, 69)), (30, (24, 46, 68, 69)))
 
     def __init__(self):
+        SimpleModel.__init__(self)
         self.pos = (0.0, 0.0, 0.0)
         self.__maxHeight = 0.0
         for v in self.__verticies:
@@ -466,6 +448,7 @@ class Bishop(SimpleModel):
                        (1.7, 12.2), (2.2, 13.2), (2.2, 14.8), (1.0, 16.0), (0.8, 17.0), (1.2, 17.7), (0.8, 18.4), (0.0, 18.4)]
 
     def __init__(self):
+        SimpleModel.__init__(self)
         self.pos = (0.0, 0.0, 0.0)
         pass
 
@@ -483,6 +466,7 @@ class Queen(SimpleModel):
                        (0.95, 20.8), (0.7, 20.8), (0.9, 21.4), (0.7, 22.0), (0.0, 22.0)]
                        
     def __init__(self):
+        SimpleModel.__init__(self)
         self.pos = (0.0, 0.0, 0.0)
         pass
 
@@ -493,8 +477,6 @@ class King(SimpleModel):
     """
     """
     
-    __maxHeight = 0.0
-    
     # The co-ordinates of the revolution that makes the model
     
     __revolveCoords = [(5.0, 0.0), (5.0, 2.0), (3.5, 3.0), (3.5, 4.6), (2.0, 7.6), (1.4, 12.6), (3.0, 12.6),
@@ -515,6 +497,7 @@ class King(SimpleModel):
                (4, (18, 7, 6, 19)), (4, (21, 10, 9, 22)), (4, (14, 3, 2, 15))]
 
     def __init__(self):
+        SimpleModel.__init__(self)
         self.pos = (0.0, 0.0, 0.0)
         self.__maxHeight = 0.0
         for v in self.__verticies:
diff --git a/glchess/src/lib/scene/opengl/opengl.py b/glchess/src/lib/scene/opengl/opengl.py
index fdf0a1b..994699c 100644
--- a/glchess/src/lib/scene/opengl/opengl.py
+++ b/glchess/src/lib/scene/opengl/opengl.py
@@ -78,24 +78,6 @@ def accPerspective(fovy, aspect,
 class ChessPiece(glchess.scene.ChessPiece):
     """
     """    
-    scene     = None
-    
-    # The piece to render
-    chessSet  = None
-    name      = None
-    
-    # The algebraic square location
-    location  = ''
-    
-    # The OpenGL co-ordinate location
-    pos       = None
-    targetPos = None
-    
-    # Is the piece moving?
-    moving    = False
-    
-    # Delete once moved?
-    delete    = False
     
     def __init__(self, scene, chessSet, name, location, feedback):
         """
@@ -106,6 +88,9 @@ class ChessPiece(glchess.scene.ChessPiece):
         self.name = name
         self.location = location
         self.pos = self.scene._coordToLocation(location)
+        self.targetPos = None  # Position moving to
+        self.moving    = False # Is the piece moving?
+        self.delete    = False # Delete once moved?
 
     def move(self, coord, delete, animate = True):
         """Extends glchess.scene.ChessPiece"""
@@ -186,58 +171,43 @@ class ChessPiece(glchess.scene.ChessPiece):
 class Scene(glchess.scene.Scene):
     """
     """
-    # The viewport dimensions
-    viewportWidth    = 0
-    viewportHeight   = 0
-    viewportAspect   = 1.0
-    
-    animating        = False
-    
-    # Loading screen properties
-    throbberEnabled  = False
-    throbberAngle    = 0.0
-    
-    # The scene light position
-    lightPos         = None
-
-    # The board angle in degrees
-    boardAngle       = 0.0
-    oldBoardAngle    = 0.0
-    targetBoardAngle = 0.0
-    
-    # OpenGL display list for the board and a flag to regenerate it
-    boardList        = None
-    regenerateBoard  = False
-    
-    # Texture objects for the board
-    whiteTexture     = None
-    blackTexture     = None
-
-    # ...
-    pieces           = None
-    chessSets        = None
-    piecesMoving     = False
-    
-    # Dictionary of co-ordinates to highlight
-    highlights       = None
-    
-    _animationQueue  = []
-    
-    jitters = ((0.0, 0.0),)
-
-    showNumbering = False
-    numberingTexture = None
 
     def __init__(self, feedback):
         """Constructor for an OpenGL scene"""
         self.feedback = feedback
-        self.lightPos = [100.0, 100.0, 100.0, 1.0]
+        self.lightPos = [100.0, 100.0, 100.0, 1.0] # The scene light position
         self.pieces = []
         self.highlights = {}
         self._animationQueue = []
+        self.animating = False
+        self.piecesMoving = False
+
+        # The viewport dimensions
+        self.viewportWidth    = 0
+        self.viewportHeight   = 0
+        self.viewportAspect   = 1.0
+    
+        # Loading screen properties
+        self.throbberEnabled  = False
+        self.throbberAngle    = 0.0
+    
+        # The board angle in degrees
+        self.boardAngle       = 0.0
+        self.oldBoardAngle    = 0.0
+        self.targetBoardAngle = 0.0
+    
+        # OpenGL display list for the board and a flag to regenerate it
+        self.boardList        = None
+        self.regenerateBoard  = False
+    
+        self.jitters = ((0.0, 0.0),)
+
+        self.showNumbering = False
+        self.numberingTexture = None
         
         self.chessSets = {'white': builtin_models.WhiteBuiltinSet(), 'black': builtin_models.BlackBuiltinSet()}
         
+        # Texture objects for the board
         self.whiteTexture = texture.Texture(os.path.join(TEXTURE_DIR, 'board.png'),
                                             ambient = BOARD_AMBIENT, diffuse = BOARD_DIFFUSE,
                                             specular = BOARD_SPECULAR, shininess = BOARD_SHININESS)
diff --git a/glchess/src/lib/scene/opengl/texture.py b/glchess/src/lib/scene/opengl/texture.py
index 91d9091..5a3242f 100644
--- a/glchess/src/lib/scene/opengl/texture.py
+++ b/glchess/src/lib/scene/opengl/texture.py
@@ -7,21 +7,6 @@ import array
 class Texture:
     """
     """
-    # Texture data
-    __data   = None
-    __format = GL_RGB
-    __width  = None
-    __height = None
-    
-    # Material properties
-    __ambient   = None
-    __diffuse   = None
-    __specular  = None
-    __emission  = None
-    __shininess = None
-
-    # OpenGL texture ID
-    __texture = None
     
     def __init__(self, fileName,
                  ambient  = (0.2, 0.2, 0.2, 1.0),
@@ -41,6 +26,16 @@ class Texture:
         self.__specular = specular
         self.__emission = emission
         self.__shininess = shininess
+
+        # Texture data
+        self.__data   = None
+        self.__format = GL_RGB
+        self.__width  = None
+        self.__height = None
+
+        # OpenGL texture ID
+        self.__texture = None
+
         try:
             self.__loadPIL(fileName)
         except ImportError:
diff --git a/glchess/src/lib/uci.py b/glchess/src/lib/uci.py
index 9b8b6a3..657a019 100644
--- a/glchess/src/lib/uci.py
+++ b/glchess/src/lib/uci.py
@@ -7,25 +7,18 @@ class StateMachine:
     STATE_IDLE = 'IDLE'
     STATE_CONNECTING = 'CONNECTING'
     
-    options = None
-    
-    __positionCommand = 'position startpos'
-    __haveMoves = False
-    
-    buffer = ''
-    
-    __readyToConfigure = False
-    __options          = None
-    
-    __ready            = False
-    __inCallback       = False
-    __queuedCommands   = None
-    
     def __init__(self):
         """
         """
         self.options = {}
         self.__queuedCommands = []
+        self.buffer = ''
+        self.__haveMoves = False
+        self.__readyToConfigure = False    
+        self.__ready            = False
+        self.__inCallback       = False
+        self.__queuedCommands   = None
+        self.__positionCommand = 'position startpos'
         
     def logText(self, text, style):
         """



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