diff options
Diffstat (limited to 'imago/sgfParser/astNode.py')
-rw-r--r-- | imago/sgfParser/astNode.py | 119 |
1 files changed, 60 insertions, 59 deletions
diff --git a/imago/sgfParser/astNode.py b/imago/sgfParser/astNode.py index 41629ce..5071483 100644 --- a/imago/sgfParser/astNode.py +++ b/imago/sgfParser/astNode.py @@ -1,4 +1,4 @@ -from imago.gameLogic.gameData import GameData +#from imago.gameLogic.gameData import GameData from imago.gameLogic.gameMove import GameMove from imago.gameLogic.gameBoard import GameBoard from imago.data.enums import Player @@ -22,64 +22,6 @@ class ASTNode: children = children[0].children children.append(move) - def toGameTree(self): - """Converts this node and its subtree into a GameTree""" - gameData = GameData() - for prop in self.props: - if prop.name == "GM": # Type of game, 1 is Go - if prop.value != 1: - print("ERROR") # TODO: Error handling - if prop.name == "SZ": # Size of board. [19] for squared, [10:12] for rect. - gameData.size = prop.value - if prop.name == "AN": # Annotator - gameData.annotator = prop.value - if prop.name == "BR": # Rank of black player - gameData.blackRank = prop.value - if prop.name == "WR": # Rank of white player - gameData.whiteRank = prop.value - if prop.name == "PB": # Name of black player - gameData.blackName = prop.value - if prop.name == "PW": # Name of white player - gameData.whiteName = prop.value - if prop.name == "BT": # Name of black team - gameData.blackTeam = prop.value - if prop.name == "WT": # Name of white team - gameData.whiteTeam = prop.value - if prop.name == "CP": # Copyright information - gameData.copyright = prop.value - if prop.name == "DT": # Date - gameData.date = prop.value - if prop.name == "EV": # Event information - gameData.event = prop.value - if prop.name == "GN": # Game nae - gameData.name = prop.value - if prop.name == "GC": # Extra game comment - gameData.gameComment = prop.value - if prop.name == "ON": # Description of opening played - gameData.openingInfo = prop.value - if prop.name == "OT": # Overtime method - gameData.overtimeInfo = prop.value - if prop.name == "PC": # Place where the game took place - gameData.place = prop.value - if prop.name == "RE": # Result of the game - gameData.result = prop.value - if prop.name == "RO": # Round number and type - gameData.roundInfo = prop.value - if prop.name == "RU": # Rules used for the game - gameData.rules = prop.value - if prop.name == "SO": # Source of the game - gameData.source = prop.source - if prop.name == "TM": # Time limit in seconds - gameData.timeInfo = prop.source - if prop.name == "US": # User or program which entered the game - gameData.user = prop.source - - firstMoves = [] - for child in self.children: - firstMoves.append(child.toGameMoveTree(size)) - - return GameTree(firstMoves, gameData) - def toGameMoveTree(self, previousMove=None): if previousMove is None: # Game root node @@ -138,6 +80,65 @@ def textToCoords(text): # Poner en PropertyMove, subclase de Property row = ord(text[1]) - ord('a') return [row, col] + # Obsolete method of storing properties + #def toGameTree(self): + # """Converts this node and its subtree into a GameTree""" + # gameData = GameData() + # for prop in self.props: + # if prop.name == "GM": # Type of game, 1 is Go + # if prop.value != 1: + # print("ERROR") # TODO: Error handling + # if prop.name == "SZ": # Size of board, [19] for squared, [10:12] for rect. + # gameData.size = prop.value + # if prop.name == "AN": # Annotator + # gameData.annotator = prop.value + # if prop.name == "BR": # Rank of black player + # gameData.blackRank = prop.value + # if prop.name == "WR": # Rank of white player + # gameData.whiteRank = prop.value + # if prop.name == "PB": # Name of black player + # gameData.blackName = prop.value + # if prop.name == "PW": # Name of white player + # gameData.whiteName = prop.value + # if prop.name == "BT": # Name of black team + # gameData.blackTeam = prop.value + # if prop.name == "WT": # Name of white team + # gameData.whiteTeam = prop.value + # if prop.name == "CP": # Copyright information + # gameData.copyright = prop.value + # if prop.name == "DT": # Date + # gameData.date = prop.value + # if prop.name == "EV": # Event information + # gameData.event = prop.value + # if prop.name == "GN": # Game nae + # gameData.name = prop.value + # if prop.name == "GC": # Extra game comment + # gameData.gameComment = prop.value + # if prop.name == "ON": # Description of opening played + # gameData.openingInfo = prop.value + # if prop.name == "OT": # Overtime method + # gameData.overtimeInfo = prop.value + # if prop.name == "PC": # Place where the game took place + # gameData.place = prop.value + # if prop.name == "RE": # Result of the game + # gameData.result = prop.value + # if prop.name == "RO": # Round number and type + # gameData.roundInfo = prop.value + # if prop.name == "RU": # Rules used for the game + # gameData.rules = prop.value + # if prop.name == "SO": # Source of the game + # gameData.source = prop.source + # if prop.name == "TM": # Time limit in seconds + # gameData.timeInfo = prop.source + # if prop.name == "US": # User or program which entered the game + # gameData.user = prop.source + # + # firstMoves = [] + # for child in self.children: + # firstMoves.append(child.toGameMoveTree()) + # + # return GameTree(firstMoves, gameData) + class Property: """Property of a Node""" |