當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。