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


Python Game._create_game方法代码示例

本文整理汇总了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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:14,代码来源:tests.py

示例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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:34,代码来源:tests.py

示例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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:34,代码来源:tests.py

示例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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:30,代码来源:tests.py

示例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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:10,代码来源:tests.py

示例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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:10,代码来源:tests.py

示例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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:11,代码来源:tests.py

示例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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:12,代码来源:tests.py

示例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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:13,代码来源:tests.py

示例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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:14,代码来源:tests.py

示例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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:7,代码来源:tests.py

示例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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:8,代码来源:tests.py

示例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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:5,代码来源:tests.py

示例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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:6,代码来源:tests.py

示例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)
开发者ID:SeMorgana,项目名称:ConnectWithFriends,代码行数:8,代码来源:tests.py


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