edited some print calls and added so time delays

also code clean up
This commit is contained in:
Steinadler 2021-01-15 15:07:18 +01:00
parent a70f219824
commit 40a7be152c
1 changed files with 14 additions and 6 deletions

View File

@ -9,7 +9,7 @@ import copy
import time
import clean_input
total_time = 1
total_time = 1.5
def central_function():
@ -20,6 +20,9 @@ def central_function():
: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
@ -78,10 +81,10 @@ def round(card_stack, players_with_cards, players, active, complete_card_stack,
pretty_print_deck(players_with_cards, active)
print('Folgende Spieler stehen zur Verfügung:')
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(
'Welchen Spieler möchtest du befragen? ', players_without_active))
# print("chosen player", chosen_player)
'Welchen Spieler möchtest du nach einer Karte fragen? ', players_without_active))
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']:
@ -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"der Karte {player_request['number']}{player_request['letter']}.")
time.sleep(total_time)
if player_request in players_with_cards[chosen_player]['cards_on_hand']:
steal(active, chosen_player, players_with_cards, player_request)
drop_cards(players_with_cards, all_quartets, active)
@ -174,6 +179,7 @@ def pretty_print_deck(players_with_cards, player):
if player == 0:
print("Dein Deck: ", pretty_deck)
time.sleep(total_time)
def steal(active, chosen_player, players_with_cards, player_request):
@ -283,10 +289,12 @@ def initialize():
complete_card_stack = copy.copy(card_stack)
# 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:
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.
for i in range(number_of_players):