本文整理汇总了Python中models.Move.belongs_to方法的典型用法代码示例。如果您正苦于以下问题:Python Move.belongs_to方法的具体用法?Python Move.belongs_to怎么用?Python Move.belongs_to使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Move
的用法示例。
在下文中一共展示了Move.belongs_to方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gameover
# 需要导入模块: from models import Move [as 别名]
# 或者: from models.Move import belongs_to [as 别名]
def gameover(self):
board = [[128, 64, 32, 16], [64, 32, 16, 8], [32, 16, 8, 4], [16, 8, 1, 0]]
boardString = move_logic.serialize_board(board)
allempty = [[3, 3]]
allemptyString = move_logic.serialize_board(allempty)
move = Move(
belongs_to=None,
moveNumber=100,
board=boardString,
allempty=allemptyString,
serverSecret="a04aa4256d3fb3847c9a594975fd26efbdebac31bd17b88b0b39be592567230b",
serverSecretHashed="aa1e27d29a4e17d308534ceb6c2774d9ec4f2b9ef1022a49d66a3770ca424a13",
clientSecret="",
clientSecretHashed="fee9aa280f017fd716c496afe03a6291bf9a0fe80f07a9026efc4257b71fe848",
)
move.save()
game = Game(belongs_to=None, lastMove=move, gameover=False, result=None, gameid="jakasgra")
game.save()
move.belongs_to = game
move.save()
returned = negotiate_second(game, "b7d64a5f92b663560a3f000a947fae7cad549a5c2e396a4828c5151fd5034ce4")
self.assertEqual(returned["valid"], True)
self.assertEqual(returned["gameover"], False)
示例2: newGame
# 需要导入模块: from models import Move [as 别名]
# 或者: from models.Move import belongs_to [as 别名]
def newGame(user):
board = move_logic.create_board(move_logic.size)
board[1][1] = 1
move = Move(
belongs_to = None,
moveNumber = 1,
board = move_logic.serialize_board(board),
serverSecret = "0",
serverSecretHashed = "0",
clientSecret = "0",
clientSecretHashed = "0"
)
move.save()
game = Game(
gameid = rand256hex(),
belongs_to = user,
gameover = False,
lastMove = move
)
game.save()
move.belongs_to = game
move.save()
return game