Untitled
unknown
python
2 years ago
2.0 kB
3
Indexable
Never
""" Combo Breaker Card Game 1 - The game consist 30 cards, 0-9 numbers and Red, Green and Blue color 2 - Each player gets 3 cards 3 - Each game consist of some number of players, and winners are determined by who has the best Combo: 3.1 Color Combo (3 same color) [3 points] 3.2 Value Combo (3 same value) [2 points] 3.3 Pair Combo (2 same value + random) [1 point] 3.4 etc not important [0 points] 4. Write the library required to play this game. Don't worry about UI or getters / setters / constructors or implementing methods, just draw out what ou need and who will call what. """ class Card: value = None color = None def __init__(self, value, color): self.value = value self.color = color #import random player_1 = [] player_2 = [] player_3 = [] player_4 = [] Scoreboard = [] # Player_1 should win via Color Combo player_1.append(Card(0, "Blue")) player_1.append(Card(7, "Blue")) player_1.append(Card(4, "Blue")) # Player_2 should be 2nd via Value Combo player_2.append(Card(3, "Red")) player_2.append(Card(3, "Green")) player_2.append(Card(3, "Blue")) # Player_3 should be 3rd via Pair Combo player_3.append(Card(3, "Red")) player_3.append(Card(3, "Green")) player_3.append(Card(4, "Blue")) # Player_4 should be last via no Combo player_4.append(Card(1, "Red")) player_4.append(Card(3, "Green")) player_4.append(Card(4, "Blue")) def Score(player): if player[0].color == player[1].color == player[2].color: return 3 # color combo elif player[0].value == player[1].value == player[2].value: return 2 # value combo elif player[0].value == player[1].value or player[0].value == player[2].value or player[1].value == player[2].value: return 1 # pair combo else: return 0 # no combo Scoreboard.append(Score(player_1)) Scoreboard.append(Score(player_2)) Scoreboard.append(Score(player_3)) Scoreboard.append(Score(player_4)) print("Wygrał gracz numer: ", Scoreboard.index(max(Scoreboard))+1, " z ilością punktów: ", max(Scoreboard))