def test_player_init(self): p = Player("Pall", 3, 3, 3, 3) self.assertEqual(p.name, "Pall") self.assertEqual(p._Player__sprint, 3) self.assertEqual(p._Player__passing, 3) self.assertEqual(p._Player__dribble, 3) self.assertEqual(p._Player__shooting, 3)
def test_assigning_player_in_the_same_guild(self): guild = Guild("GGXrd") player = Player("Pesho", 90, 90) guild.assign_player(player) message = guild.assign_player(player) expected = "Player Pesho is already in the guild." self.assertEqual(message, expected)
def test_player_init(self): p = Player("Pall", 3, 3, 3, 3, 3) self.assertEqual(p.name, "Pall") self.assertEqual(p.endurance, 3) self.assertEqual(p.sprint, 3) self.assertEqual(p.passing, 3) self.assertEqual(p.dribble, 3) self.assertEqual(p.shooting, 3)
def assign_player(self, player: Player): if player in self.list_of_players: return f'Player {player.name} is already in the guild.' if not player.guild == 'Unaffiliated': return f'Player {player.name} is in another guild.' self.list_of_players.append(player) player.guild = self.name return f'Welcome player {player.name} to the guild {player.guild}'
def assign_player(self, player: Player): if player in self.list_of_players: return f"Player {player.name} is already in the guild." if player.guild != "Unaffiliated": return f"Player {player.name} is in another guild." self.list_of_players.append(player) player.guild = self.name return f"Welcome player {player.name} to the guild {self.name}"
def assign_player(self, player: Player): if player in self.guild: return f'Player {player.name} is already in the guild.' if player.guild == 'Unaffiliated': self.guild.append(player) player.guild = self.name return f'Welcome player {player.name} to the guild {self.name}' return f'Player {player.name} is in another guild.'
def assign_player(self, player: Player): if not player.guild == self.name and not player.guild == 'Unaffiliated': return f"Player {player.name} is in another guild." filtered_players = [p for p in self.players if p == player] if filtered_players: return f"Player {player.name} is already in the guild." self.players.append(player) player.guild = self.name return f"Welcome player {player.name} to the guild {self.name}"
def assign_player(self, player: Player): if player.guild == self.name: return f"Player {player.name} is already in the guild." if player.guild != "Unaffiliated" and player.guild != self.name: return f"Player {player.name} is in another guild." player.guild = self.name self.players.append(player) return f"Welcome player {player.name} to the guild {self.name}"
def assign_player(self, player: Player) -> str: if player.guild == self.name: return f'Player {player.name} is already in the guild.' if player.guild != Player.NO_GUILD: return f'Player {player.name} is in another guild.' player.guild = self.name self.players.append(player) return f'Welcome player {player.name} to the guild {self.name}'
def assign_player(self, player: Player): if player.guild == 'Unaffiliated': player.guild = self.name self.player_list.append(player) return f'Welcome player {player.name} to the guild {self.name}' elif player.guild == self.name: return f'Player {player.name} is already in the guild.' else: return f'Player {player.name} is in another guild.'
def assign_player(self, player: Player): if player.guild in [ x.guild for x in self.players if player.name == x.name ]: return f"Player {player.name} is already in the guild." if player.guild != "Unaffiliated": return f"Player {player.name} is in another guild." player.guild = f"{self.name}" self.players.append(player) return f"Welcome player {player.name} to the guild {self.name}"
def assign_player(self, player: player.Player) -> str: player_guild = player.guild player_name = player.name if player_guild == self.name: return f"Player {player_name} is already in the guild." if player_guild != "Unaffiliated" and player_guild != self.name: return f"Player {player_name} is in another guild." player.guild = self.name self.player_list.append(player) return f"Welcome player {player_name} to the guild {self.name}"
if player.guild == 'Unaffiliated': player.guild = self.name self.player_list.append(player) return f'Welcome player {player.name} to the guild {self.name}' elif player.guild == self.name: return f'Player {player.name} is already in the guild.' else: return f'Player {player.name} is in another guild.' def kick_player(self, player: str): if player not in self.player_list: return f'Player {player} is not in the guild.' else: player.guild = 'Unaffiliated' self.player_list.remove(player) return f'Player {player} has been removed from the guild.' def guild_info(self): result = f'Guild: {self.name}\n' for p in self.player_list: result += f'{p.player_info()}\n' return result player = Player("George", 50, 100) print(player.add_skill("Shield Break", 20)) print(player.player_info()) guild = Guild("UGT") print(guild.assign_player(player)) print(guild.guild_info())
from project.deck import Deck, RANKS from project.hand import Hand from project.player import Player d = Deck() d.shuffle() half1, half2 = d.cut_on_half() comp = Player('comp', Hand(half1)) name = input('Type your name plaes: ') user = Player(name, Hand(half2)) total_rounds = 0 war_count = 0 while user.check_available_cards() and comp.check_available_cards(): total_rounds += 1 print('Time for a new round') print('here are the current status') print(f'{user.name} has the count: {len(user.hand.cards)}') print(f'{comp.name} has the count: {len(comp.hand.cards)}') print() table_cards = [] c_card = comp.play_card() p_card = user.play_card() table_cards.append(c_card) table_cards.append(p_card)
def test_adding_skill_should_work(self): player = Player("Pesho", 90, 90) message = player.add_skill("A", 3) expected = "Skill A added to the collection of the player Pesho" self.assertEqual(message, expected)
from project.controller import Controller from project.player import Player from project.supply.drink import Drink from project.supply.food import Food if __name__ == '__main__': controller = Controller() apple = Food("apple", 22) cheese = Food("cheese") juice = Drink("orange juice") water = Drink("water") first_player = Player('Peter', 15) second_player = Player('Lilly', 12, 94) print( controller.add_supply(cheese, apple, cheese, apple, juice, water, water)) print(controller.add_player(first_player, second_player)) print(controller.duel("Peter", "Lilly")) print(controller.add_player(first_player)) print(controller.sustain("Lilly", "Drink")) first_player.stamina = 0 print(controller.duel("Peter", "Lilly")) controller.next_day() print(first_player.stamina) print(second_player.stamina)
def test_adding_existing_skill_should_not_work(self): player = Player("Pesho", 90, 90) player.add_skill("A", 3) message = player.add_skill("A", 3) expected = "Skill already added" self.assertEqual(message, expected)
from project.player import Player from project.guild import Guild player = Player("name", 10, 10) player1 = Player("name1", 10, 10) player2 = Player("name2", 10, 20) player1.add_skill("fire", 20) player1.add_skill("ice", 200) player.add_skill("earth", 200) player.add_skill("marce", 200) guild = Guild("UGT") print(guild.assign_player(player)) # print(guild.assign_player(player1)) # print(guild.assign_player(player2)) print(guild.guild_info())
def test_info(self): player = Player("Pesho", 90, 90) player.add_skill("A", 3) message = player.player_info().strip() expected = "Name: Pesho\nGuild: Unaffiliated\nHP: 90\nMP: 90\n===A - 3" self.assertEqual(message, expected)
def test_team_add_fail(self): t = Team("Best", 10) p = Player("Pall", 3, 3, 3, 3, 3) t.add_player(p) self.assertEqual(t.add_player(p), "Player Pall has already joined")
def test_team_remove_successful(self): t = Team("Best", 10) p = Player("Pall", 3, 3, 3, 3, 3) t.add_player(p) exp = t.remove_player("Pall") self.assertEqual(exp, p)
def test_player_str(self): p = Player("Pall", 3, 3, 3, 3, 3) result = str(p) expected = "Player: Pall\nEndurance: 3\nSprint: 3\nDribble: 3\nPassing: 3\nShooting: 3\n" self.assertEqual(expected, result)
def test_team_add_successful(self): t = Team("Best", 10) p = Player("Pall", 3, 3, 3, 3, 3) self.assertEqual(t.add_player(p), "Player Pall joined team Best")
def test_assign_working(self): guild = Guild("GGXrd") player = Player("Pesho", 90, 90) message = guild.assign_player(player) expected = "Welcome player Pesho to the guild GGXrd" self.assertEqual(message, expected)
def test_player_init(self): player = Player("Pesho", 90, 90) result = player.player_info().strip() expected = "Name: Pesho\nGuild: Unaffiliated\nHP: 90\nMP: 90" self.assertEqual(result, expected)
from project.guild import Guild from project.player import Player player = Player("George", 50, 100) player2 = Player("Geor", 5, 10) print(player.add_skill("Shield Break", 20)) print(player2.add_skill("Break", 255)) print(player2.add_skill("Breakfast", 35)) print(player.player_info()) guild = Guild("UGT") print(guild.assign_player(player)) print(guild.assign_player(player2)) print(guild.guild_info()) # from project.player import Player # from project.guild import Guild # # import unittest # # # class PlayerTest(unittest.TestCase): # # def test_player_init(self): # player = Player("Pesho", 90, 90) # expected = "Name: Pesho\nGuild: Unaffiliated\nHP: 90\nMP: 90\n" # self.assertEqual(player.player_info(), expected) # # def test_adding_skill_should_work(self): # player = Player("Pesho", 90, 90) # message = player.add_skill("A", 3) # expected = "Skill A added to the collection of the player Pesho"
def guild_info(self): result = f"Guild: {self.name}\n" for player in self._players: if player.guild == self.name: result += Player.player_info(player) return result
def test_team_remove_fail(self): t = Team("Best", 10) p = Player("Pall", 3, 3, 3, 3, 3) result = "Player Pall not found" exp = t.remove_player("Pall") self.assertEqual(exp, result)
from project.player import Player from project.team import Team p = Player("Pall", 1, 3, 5, 7) print("Player name:", p.name) print("Points sprint:", p._Player__sprint) print("Points dribble:", p._Player__dribble) print("Points passing:", p._Player__passing) print("Points shooting:", p._Player__shooting) print("\ncalling the __str__ method") print(p) print("\nAbout the team") t = Team("Best", 10) print("Team name:", t._Team__name) print("Teams points:", t._Team__rating) print("Teams players:", len(t._Team__players)) print(t.add_player(p)) print(t.add_player(p)) print("Teams players:", len(t._Team__players)) print(t.remove_player("Pall")) print(t.remove_player("Pall"))
from project.player import Player from project.guild import Guild player_1 = Player("P1", 100, 100) player_2 = Player("P2", 100, 100) player_3 = Player("P2", 100, 100) print(player_1.add_skill("S1", 50)) print(player_1.add_skill("S1", 50)) print(player_1.add_skill("S1", 60)) print(player_1.add_skill("S2", 60)) print(player_1.player_info()) guild1 = Guild("G1") guild2 = Guild("G2") print(guild1.assign_player(player_1)) print(guild1.assign_player(player_1)) print(guild1.assign_player(player_2)) print(guild2.assign_player(player_1)) print(guild1.assign_player(player_3)) print(guild1.kick_player("P1")) print(guild1.kick_player("P1")) print(guild1.guild_info()) player = Player("George", 50, 100) print(player.add_skill("Shield Break", 20)) print(player.player_info()) guild = Guild("UGT") print(guild.assign_player(player))