edited some print calls and added so time delays
also code clean up
This commit is contained in:
parent
a70f219824
commit
40a7be152c
20
quartett.py
20
quartett.py
|
@ -9,7 +9,7 @@ import copy
|
||||||
import time
|
import time
|
||||||
import clean_input
|
import clean_input
|
||||||
|
|
||||||
total_time = 1
|
total_time = 1.5
|
||||||
|
|
||||||
|
|
||||||
def central_function():
|
def central_function():
|
||||||
|
@ -20,6 +20,9 @@ def central_function():
|
||||||
|
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
print("Wilkommen bei Quartett! ")
|
||||||
|
print("Sie können gegen 1-7 Spieler spielen.")
|
||||||
|
print("Sie können das Spiel bei jeder Eingabe mit 'q' beenden oder mit 'r' neustarten.\n")
|
||||||
|
|
||||||
switch = True
|
switch = True
|
||||||
|
|
||||||
|
@ -78,10 +81,10 @@ def round(card_stack, players_with_cards, players, active, complete_card_stack,
|
||||||
pretty_print_deck(players_with_cards, active)
|
pretty_print_deck(players_with_cards, active)
|
||||||
print('Folgende Spieler stehen zur Verfügung:')
|
print('Folgende Spieler stehen zur Verfügung:')
|
||||||
print(players_without_active)
|
print(players_without_active)
|
||||||
# chosen_player enthält den index in der players liste
|
|
||||||
|
# chosen_player has the index of player list
|
||||||
chosen_player = players.index(clean_input.io_str(
|
chosen_player = players.index(clean_input.io_str(
|
||||||
'Welchen Spieler möchtest du befragen? ', players_without_active))
|
'Welchen Spieler möchtest du nach einer Karte fragen? ', players_without_active))
|
||||||
# print("chosen player", chosen_player)
|
|
||||||
player_request = clean_input.io_card_selection('Welche Karte möchtest du haben? ')
|
player_request = clean_input.io_card_selection('Welche Karte möchtest du haben? ')
|
||||||
|
|
||||||
if player_request in players_with_cards[chosen_player]['cards_on_hand']:
|
if player_request in players_with_cards[chosen_player]['cards_on_hand']:
|
||||||
|
@ -131,6 +134,8 @@ def round(card_stack, players_with_cards, players, active, complete_card_stack,
|
||||||
f"{players[active]} fragt {players[chosen_player]} nach "
|
f"{players[active]} fragt {players[chosen_player]} nach "
|
||||||
f"der Karte {player_request['number']}{player_request['letter']}.")
|
f"der Karte {player_request['number']}{player_request['letter']}.")
|
||||||
|
|
||||||
|
time.sleep(total_time)
|
||||||
|
|
||||||
if player_request in players_with_cards[chosen_player]['cards_on_hand']:
|
if player_request in players_with_cards[chosen_player]['cards_on_hand']:
|
||||||
steal(active, chosen_player, players_with_cards, player_request)
|
steal(active, chosen_player, players_with_cards, player_request)
|
||||||
drop_cards(players_with_cards, all_quartets, active)
|
drop_cards(players_with_cards, all_quartets, active)
|
||||||
|
@ -174,6 +179,7 @@ def pretty_print_deck(players_with_cards, player):
|
||||||
|
|
||||||
if player == 0:
|
if player == 0:
|
||||||
print("Dein Deck: ", pretty_deck)
|
print("Dein Deck: ", pretty_deck)
|
||||||
|
time.sleep(total_time)
|
||||||
|
|
||||||
|
|
||||||
def steal(active, chosen_player, players_with_cards, player_request):
|
def steal(active, chosen_player, players_with_cards, player_request):
|
||||||
|
@ -283,10 +289,12 @@ def initialize():
|
||||||
complete_card_stack = copy.copy(card_stack)
|
complete_card_stack = copy.copy(card_stack)
|
||||||
|
|
||||||
# determine number of players
|
# determine number of players
|
||||||
number_of_players = clean_input.io_int("Gegen wie viele Spieler wollen Sie spielen?")
|
number_of_players = clean_input.io_int(
|
||||||
|
"Gegen wie viele Spieler wollen Sie spielen (als Ganzzahl)?")
|
||||||
while number_of_players < 1 or number_of_players > 7:
|
while number_of_players < 1 or number_of_players > 7:
|
||||||
print("Fehler! Sie dürfen lediglich gegen 1-7 Spieler spielen.")
|
print("Fehler! Sie dürfen lediglich gegen 1-7 Spieler spielen.")
|
||||||
number_of_players = clean_input.io_int("Gegen wie viele Spieler wollen Sie spielen?")
|
number_of_players = clean_input.io_int(
|
||||||
|
"Gegen wie viele Spieler wollen Sie spielen (als Ganzzahl)?")
|
||||||
number_of_players += 1 # Add also human player.
|
number_of_players += 1 # Add also human player.
|
||||||
|
|
||||||
for i in range(number_of_players):
|
for i in range(number_of_players):
|
||||||
|
|
Loading…
Reference in New Issue