コード例 #1
0
 def test_player_class_get_dict_player(self):
     player = Player("Gosho")
     player_dict = player.get_dict_player()
     self.assertEqual(
         player_dict,
         {"Gosho": {
             "cards": [],
             "announcements": [],
             "points": 0
         }})
コード例 #2
0
 def test_team_class_get_dict_team(self):
     team = Team("Severozapada", [Player("Petar"), Player("Yoanna")])
     res = team.get_dict_team()
     expected = {
         "Severozapada": [{
             "Petar": {
                 "cards": [],
                 "announcements": [],
                 "points": 0
             }
         }, {
             "Yoanna": {
                 "cards": [],
                 "announcements": [],
                 "points": 0
             }
         }]
     }
     self.assertEqual(res, expected)
コード例 #3
0
def main():
    first_team_name = input("Team 1 name: ")
    second_team_name = input("Team 2 name: ")

    firts_team_players = input(f'"{first_team_name}" players: ').split(",")
    second_team_players = input(f'"{second_team_name}" players: ').split(",")

    player1_first_team = firts_team_players[0]
    player2_first_team = firts_team_players[1]

    player1_second_team = second_team_players[0]
    player2_second_team = second_team_players[1]

    player_one = Player(player1_first_team)
    player_two = Player(player2_first_team)
    player_three = Player(player1_second_team)
    player_four = Player(player2_second_team)

    first_team = Team(first_team_name, [player_one, player_two])
    second_team = Team(second_team_name, [player_three, player_four])

    score = [0, 0]
    count_games = 1

    json_file = open("data.json", "w")
    json_file.close()
    json_file = open("data.json", "a")
    file = create_file_result([first_team, second_team])

    while score[0] < 2 and score[1] < 2:
        game = Game(count_games, [first_team, second_team], score)
        game.play_game(file.name)
        json.dump(game.get_dict_game(), json_file, indent=4)
        score = game.update_score()
        write_end_of_file(score, file.name)
        count_games += 1

    json_file.close()
    file.close()
コード例 #4
0
 def test_round_class_get_dict_round(self):
     first_team = Team("Severozapada", [Player("Petar"), Player("Yoanna")])
     second_team = Team("Ne_moga_da_izmislq_dr_ime",
                        [Player("Metar"), Player("Ivana")])
     round_1 = Round([first_team, second_team], 1)
     res = round_1.get_dict_round()
     expected = {
         "round 1": [{
             "Severozapada": [{
                 "Petar": {
                     "cards": [],
                     "announcements": [],
                     "points": 0
                 }
             }, {
                 "Yoanna": {
                     "cards": [],
                     "announcements": [],
                     "points": 0
                 }
             }]
         }, {
             "Ne_moga_da_izmislq_dr_ime": [{
                 "Metar": {
                     "cards": [],
                     "announcements": [],
                     "points": 0
                 }
             }, {
                 "Ivana": {
                     "cards": [],
                     "announcements": [],
                     "points": 0
                 }
             }]
         }]
     }
     self.assertEqual(res, expected)
コード例 #5
0
 def test_player_class(self):
     player = Player("Gosho")
     self.assertEqual(str(player), "Gosho->[]")
コード例 #6
0
 def test_team_class_update_score(self):
     team = Team("Severozapada", [Player("Petar"), Player("Yoanna")])
     team.score += 50
     self.assertTrue(team.score == 50)
コード例 #7
0
 def test_team_class(self):
     team = Team("Severozapada", [Player("Petar"), Player("Yoanna")])
     self.assertEqual(str(team), "Severozapada")