本文整理汇总了Python中games.models.Game._create_game方法的典型用法代码示例。如果您正苦于以下问题:Python Game._create_game方法的具体用法?Python Game._create_game怎么用?Python Game._create_game使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类games.models.Game
的用法示例。
在下文中一共展示了Game._create_game方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_game_already_in_game
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_create_game_already_in_game(self):
first_game = Game._create_game(self.alice)
second_game = Game._create_game(self.alice)
self.assertEquals(first_game.turn, None)
self.assertEquals(first_game.player1, self.alice)
self.assertEquals(first_game.player2, None)
self.assertEquals(first_game.winner, None)
self.assertEquals(Game.current_game(self.alice), second_game)
self.assertEquals(second_game.turn, None)
self.assertEquals(second_game.player1, self.alice)
self.assertEquals(second_game.player2, None)
self.assertEquals(second_game.winner, None)
示例2: test_winning_move_diagonal_upper_left
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_winning_move_diagonal_upper_left(self):
"""
000A000
00AB000
0AAA000
ABBB000
BAAA000
ABBB00B
"""
game = Game._create_game(self.alice)
game.join(self.bob)
game.move(self.alice, 0)
game.move(self.bob, 0)
game.move(self.alice, 0)
game.move(self.bob, 1)
game.move(self.alice, 1)
game.move(self.bob, 1)
game.move(self.alice, 1)
game.move(self.bob, 2)
game.move(self.alice, 2)
game.move(self.bob, 2)
game.move(self.alice, 2)
game.move(self.bob, 6)
game.move(self.alice, 2)
game.move(self.bob, 3)
game.move(self.alice, 3)
game.move(self.bob, 3)
game.move(self.alice, 3)
game.move(self.bob, 3)
self.assertEqual(game.winner, None)
game.move(self.alice, 3)
self.assertEqual(game.winner, self.alice)
示例3: test_winning_move_diagonal_upper_right
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_winning_move_diagonal_upper_right(self):
"""
000A000
000BA00
000AAA0
000BBBA
000AAAB
B00BBBA
"""
game = Game._create_game(self.alice)
game.join(self.bob)
game.move(self.alice, 6)
game.move(self.bob, 6)
game.move(self.alice, 6)
game.move(self.bob, 5)
game.move(self.alice, 5)
game.move(self.bob, 5)
game.move(self.alice, 5)
game.move(self.bob, 4)
game.move(self.alice, 4)
game.move(self.bob, 4)
game.move(self.alice, 4)
game.move(self.bob, 0)
game.move(self.alice, 4)
game.move(self.bob, 3)
game.move(self.alice, 3)
game.move(self.bob, 3)
game.move(self.alice, 3)
game.move(self.bob, 3)
self.assertEqual(game.winner, None)
game.move(self.alice, 3)
self.assertEqual(game.winner, self.alice)
示例4: test_stalemate
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_stalemate(self):
"""
BBBABBB
AAABAAA
BBBABBB
AAABAAA
BBBABBB
AAABAAA
"""
game = Game._create_game(self.alice)
game.join(self.bob)
for _ in range(3):
game.move(self.alice, 0)
game.move(self.bob, 0)
game.move(self.alice, 1)
game.move(self.bob, 1)
game.move(self.alice, 2)
game.move(self.bob, 2)
game.move(self.alice, 4)
game.move(self.bob, 3)
game.move(self.alice, 3)
game.move(self.bob, 4)
game.move(self.alice, 5)
game.move(self.bob, 5)
game.move(self.alice, 6)
game.move(self.bob, 6)
self.assertEqual(game.stalemate, True)
self.assertEqual(game.winner, None)
示例5: test_move_taking_turns
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_move_taking_turns(self):
game = Game._create_game(self.alice)
game.join(self.bob)
self.assertEquals(game.turn, self.alice)
game.move(self.alice, 0)
self.assertEquals(game.turn, self.bob)
game.move(self.bob, 1)
self.assertEquals(game.turn, self.alice)
示例6: test_get_with_token
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_get_with_token(self):
game = Game._create_game(self.alice)
game.join(self.bob)
column = Column.objects.get(game=game, index=0)
slot = Slot.objects.get(column=column, index=Game.row_count - 1)
slot.player = self.alice
slot.save()
self.assertEquals(game.get_board()[Game.row_count - 1][0], self.alice)
示例7: test_create_game
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_create_game(self):
game = Game._create_game(self.alice)
self.assertEquals(game.turn, None)
self.assertEquals(game.player1, self.alice)
self.assertEquals(game.player2, None)
self.assertEquals(game.winner, None)
self.assertEquals(Column.objects.filter(game=game).count(), Game.column_count)
for col in Column.objects.filter(game=game):
self.assertEquals(Slot.objects.filter(column=col).count(), Game.row_count)
示例8: test_move_full_column
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_move_full_column(self):
game = Game._create_game(self.alice)
game.join(self.bob)
game.move(self.alice, 0)
game.move(self.bob, 0)
game.move(self.alice, 0)
game.move(self.bob, 0)
game.move(self.alice, 0)
game.move(self.bob, 0)
self.assertRaises(IllegalMove, game.move, self.alice, 0)
示例9: test_winning_move_horizontal
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_winning_move_horizontal(self):
game = Game._create_game(self.alice)
game.join(self.bob)
game.move(self.alice, 0)
game.move(self.bob, 0)
game.move(self.alice, 1)
game.move(self.bob, 1)
game.move(self.alice, 2)
game.move(self.bob, 2)
game.move(self.alice, 3)
self.assertEqual(game.winner, self.alice)
示例10: test_move_stacking_tokens
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_move_stacking_tokens(self):
game = Game._create_game(self.alice)
game.join(self.bob)
game.move(self.alice, 0)
game.move(self.bob, 0)
game.move(self.alice, 0)
board = game.get_board()
self.assertEquals(board[Game.row_count - 1][0], self.alice)
self.assertEquals(board[4][0], self.bob)
self.assertEquals(board[3][0], self.alice)
self.assertEquals(game.winner, None)
self.assertEquals(game.stalemate, False)
示例11: test_move
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_move(self):
game = Game._create_game(self.alice)
game.join(self.bob)
game.move(self.alice, 0)
self.assertEquals(game.get_board()[Game.row_count - 1][0], self.alice)
示例12: test_get_board_empty
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_get_board_empty(self):
game = Game._create_game(self.alice)
game.join(self.bob)
for row in game.get_board():
for col in row:
self.assertEquals(col, None)
示例13: test_move_one_player
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_move_one_player(self):
game = Game._create_game(self.alice)
self.assertRaises(IllegalMove, game.move, self.alice, 0)
示例14: test_join_full_game
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_join_full_game(self):
game = Game._create_game(self.alice)
game.join(self.bob)
self.assertRaises(GameFull, game.join, self.casey)
示例15: test_join_game
# 需要导入模块: from games.models import Game [as 别名]
# 或者: from games.models.Game import _create_game [as 别名]
def test_join_game(self):
game = Game._create_game(self.alice)
game.join(self.bob)
self.assertEquals(game.turn, self.alice)
self.assertEquals(game.player1, self.alice)
self.assertEquals(game.player2, self.bob)