コード例 #1
0
    def __saveable__(self):
        """ Returns a saveable representation of the game. """
        d = {}

        d['players'] = map(saveable, self.players)
        d['map'] = saveable(self.map)
        d['turn'] = self.turn
        d['playerIndex'] = self.playerIndex
        d['currentPlayer'] = saveable(self.currentPlayer)

        return d
コード例 #2
0
    def save(self, filename):
        d = saveable(self)

        with open(filename, 'w') as f:
            json.dump(d, f)

        print 'Game saved.'
コード例 #3
0
ファイル: Map.py プロジェクト: Odingod/Vuoropohjainen-peli
    def __saveable__(self):
        d = {}

        d['tiles'] = map(lambda x: map(saveable, x), self.tiles)
        d['metrics'] = saveable(self.metrics)
        d['units'] = map(saveable, self.units)

        return d
コード例 #4
0
    def __saveable__(self):
        d = Hexagon.__saveable__(self)

        d['terrain'] = saveable(self.terrain)
        d['units'] = map(saveable, self.units)
        # No need to save unitImages, can be loaded from self.units.
        
        return d
コード例 #5
0
ファイル: Map.py プロジェクト: Temppa/Vuoropohjainen-peli
    def __saveable__(self):
        d = {}

        d["tiles"] = map(lambda x: map(saveable, x), self.tiles)
        d["metrics"] = saveable(self.metrics)
        d["units"] = map(saveable, self.units)

        return d
コード例 #6
0
ファイル: Units.py プロジェクト: Temppa/Vuoropohjainen-peli
    def __saveable__(self):
        d = {}

        d['id'] = self.id
        d['moves'] = self.moves
        d['hp'] = self.hp
        d['owner'] = saveable(self.owner)

        return d