本文整理汇总了Python中Board.getPlayer2方法的典型用法代码示例。如果您正苦于以下问题:Python Board.getPlayer2方法的具体用法?Python Board.getPlayer2怎么用?Python Board.getPlayer2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Board
的用法示例。
在下文中一共展示了Board.getPlayer2方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Board
# 需要导入模块: import Board [as 别名]
# 或者: from Board import getPlayer2 [as 别名]
convx = width / 1600.0
convy = height/ 800.0
nameFont = font.Font(None, 30)
handFont = font.Font(None, 15)
selected = None
square = None
display.flip()
breaker = True
board = Board()
setBoard(board)
spots = board.getSpots()
hands = board.getHands()
player1 = board.getPlayer1()
player2 = board.getPlayer2()
twice = 0
state = None
x = 0
selecting = True
gen = Generator(screen, board, player1)
cardList = gen.getCards()
cardList = [CH_YETI(), FL_JUG(), RIV_CROC(), MUR_RAID(), ABU_SRG(), LNC_CAR(), IRN_OWL(), ELF_ARC(),
GRM_MUR(), NOV_ENG(), LOT_HRD(), GLD_FOT()]
deck1Cards = []
deck2Cards = []
示例2: set_new_game_id
# 需要导入模块: import Board [as 别名]
# 或者: from Board import getPlayer2 [as 别名]
#.........这里部分代码省略.........
break
elif result == "quit": # Quit was hit, so end the game
return
else: # Must be a game id
# TODO
# First start a new game. This will create window that we can adjust
# Then call the load function, passing in the game id that was entered and
# the player that logged in using the start_screen
break
# TODO: Save the game (should be one line)
while True:
self.result = self.board.take_turn(self.current_player)
if self.result == "pass" and self.prev_result == "pass":
break # Show result
if self.result == "quit":
return
if self.result == "submit":
self.board.refill(self.current_player)
self.board.update_screen()
elif self.result == "refresh":
# TODO: Call the load function with the correct player being shown for this screen
continue # A refresh was issued, that does not constitute a turn, so continue
#TODO: Change players to the other player
#TODO: Save the same
self.prev_result = self.result
def save(self):
outfile = open("games/"+str(self.game_id),"wb")
game_state = {};
game_state['db'] = self.db
game_state['players'] = self.players
game_state['board'] = self.board
game_state['prev_result'] = self.prev_result
game_state['current_player'] = self.current_player
game_state['game_id'] = self.game_id
outfile.write(pickle.dumps(game_state))
outfile.close()
def load(self,game_id,player):
self.game_id = game_id
infile = open("games/"+str(game_id),'rb')
game_state_pickled = infile.read()
infile.close()
game_state = pickle.loads(game_state_pickled)
# Make sure there is a spot for this player or they are already part of the game
joined = False
for i in range(len(game_state['players'])):
if player.getName() == game_state['players'][i].getName():
joined = True
player = game_state['players'][i] # Set to the actual player
else:
player2 = game_state['players'][i] # Other player
if not joined and len(game_state['players']) == 2: # Cannot join
return False
# Now load up the game
self.board.undraw()
self.players = game_state['players']
if not joined:
self.players.append(player)
self.db = game_state['db']
self.prev_result = game_state['prev_result']
self.game_id = game_id
self.current_player = game_state['current_player']
self.board.setPlayer1(player)
if len(self.players) == 1:
self.board.setPlayer2(self.board.getPlayer2()) # Get generic player 2
elif self.players[0] != player:
self.board.setPlayer2(self.players[0])
else:
self.board.setPlayer2(self.players[1])
self.board.current_score = game_state['board'].current_score
self.board.markers = game_state['board'].getMarkers()
self.board.tiles_list = game_state['board'].getTilesList()
# Go through each marker and if it has a tile, adjust the tile to point to the marker
markers = self.board.getMarkers()
for i in range(len(markers)):
for j in range(len(markers[i])):
markers[i][j].draw(self.board.win)
if markers[i][j].getTile() != None:
tile = markers[i][j].getTile()
tile.setMarker(markers[i][j])
tile.draw(self.board.win)
for tile in self.board.tiles_list:
tile.draw(self.board.win)
for player in self.players:
for tile in player.getTiles():
tile.draw(self.board.win)
if not joined:
self.board.refill(player)
self.board.setGameID(game_id)
self.board.update_screen()