def test3(self): """ Comprobar que el juego se termina correctamente cuando el ratón es encerrado en una esquina """ game = Game(cat_user=self.users[0]) game.full_clean() game.mouse_user = self.users[1] game.cat2 = 54 game.mouse = 63 game.save() self.assertEqual(game.status, GameStatus.FINISHED)
def test5(self): """ Comprobar que el juego no se termina cuando el ratón tiene aún una salida""" game = Game(cat_user=self.users[0]) game.full_clean() game.mouse_user = self.users[1] game.cat1 = 38 game.cat2 = 52 game.cat3 = 54 game.mouse = 45 game.save() self.assertEqual(game.status, GameStatus.ACTIVE)
def test7(self): """ Comprobar que el juego no se termina cuando el ratón ha superado a la mitad de los gatos""" game = Game(cat_user=self.users[0]) game.full_clean() game.mouse_user = self.users[1] game.cat1 = 34 game.cat2 = 38 game.cat3 = 52 game.cat4 = 54 game.mouse = 45 game.save() self.assertEqual(game.status, GameStatus.ACTIVE)
def test6(self): """ Comprobar que el juego se termina correctamente cuando el ratón está completamente rodeado""" game = Game(cat_user=self.users[0]) game.full_clean() game.mouse_user = self.users[1] game.cat1 = 36 game.cat2 = 38 game.cat3 = 52 game.cat4 = 54 game.mouse = 45 game.save() self.assertEqual(game.status, GameStatus.FINISHED)
def test8(self): """ Comprobar que el juego se termina correctamente cuando el ratón ha superado a los gatos""" game = Game(cat_user=self.users[0]) game.full_clean() game.mouse_user = self.users[1] game.cat1 = 36 game.cat2 = 38 game.cat3 = 52 game.cat4 = 54 game.mouse = 20 game.save() self.assertEqual(game.status, GameStatus.FINISHED)
def test0(self): """ Validación de la actualización del juego al ganar el gato""" game = Game(cat_user=self.user1) game.save() game.cat1 = 41 game.cat2 = 50 game.mouse = 48 game.mouse_user = self.user2 game.save() move = Move(origin=50, target=57, player=self.user1, game=game) move.save() self.assertEqual(game.status, GameStatus.FINISHED)
def test1(self): """ Validación de la actualización del juego al ganar el raton""" game = Game(cat_user=self.user1) game.save() game.cat1 = 57 game.cat2 = 59 game.cat3 = 61 game.cat4 = 63 game.mouse = 18 game.mouse_user = self.user2 game.cat_turn = False game.save() move = Move(origin=18, target=11, player=self.user2, game=game) move.save() self.assertEqual(game.status, GameStatus.FINISHED)
# Create a game for the user with id 10 game = Game(cat_user=user10) game.save() # Look for every games with only one user game_aux = Game.objects.filter(mouse_user=None) for g in game_aux: if g.id < game.id: game = g print(g) # User11 is the mouse in the game with smaller id game.mouse_user = user11 game.save() # Move cat2 from position 2 to 11 game.cat2 = 11 game.save() # Announce it print("We moved cat2 to 11 position") print(game) # Move mouse from position 59 to 52 game.mouse = 52 game.save() # Announce it print("We moved mouse from position 59 to 52") print(game) print("That's all folks :)")