当前位置: 首页>>代码示例>>Python>>正文


Python Board.placeBoard方法代码示例

本文整理汇总了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
开发者ID:azwaradli,项目名称:Gomoku-Game,代码行数:52,代码来源:Game.py


注:本文中的Board.placeBoard方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。