本文整理汇总了Python中Board.placeBoard方法的典型用法代码示例。如果您正苦于以下问题:Python Board.placeBoard方法的具体用法?Python Board.placeBoard怎么用?Python Board.placeBoard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Board
的用法示例。
在下文中一共展示了Board.placeBoard方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: import Board [as 别名]
# 或者: from Board import placeBoard [as 别名]
class Game(object):
def __init__(self, r_id):
super(Game, self).__init__()
self.roomId = r_id
self.board = Board() # board for a game
self.playerList = [] # player enlisted in game
self.turn = 0 # player turn
self.isStarted = False
self.gameWinner = -1
def isGameStarted(self):
return self.isStarted
def startGame(self):
# pre-condition: player signed to the game are more than 3
self.isStarted = True
def endGame(self):
self.isStarted = False
def getWinner(self):
return self.gameWinner
def setWinner(self, _player):
self.gameWinner = _player
def getPlayerList(self):
return self.playerList
def addPlayerToGame(self, _player):
self.playerList.append(_player)
def deletePlayerFromGame(self, _player):
self.playerList.remove(_player)
def placePlayerPawn(self, x, y, _player):
if self.board.isCellEmpty(x, y):
self.board.placeBoard(x, y, _player.getPawn())
if self.board.fiveRows(x, y, _player.getPawn()):
self.endGame()
self.setWinner(_player.getPlayerId())
else:
turn = (turn + 1) % len(playerList)
return True
else:
return False
def getTurn(self):
return self.turn