mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 07:10:42 -08:00
Simplify Python Code
print_with_tab / print_with_whitespace is trivial with Python string formatting and was mostly used in only 2 lines.
This commit is contained in:
@@ -242,7 +242,7 @@ class Game:
|
||||
players.append(Player.new(PlayerType.Player, i))
|
||||
|
||||
if get_char_from_user_input("Do you want instructions", ["y", "n"]) == "y":
|
||||
instructions()
|
||||
print_instructions()
|
||||
print()
|
||||
|
||||
return Game(players=players, decks=Decks.new(), games_played=0)
|
||||
@@ -284,7 +284,7 @@ class Game:
|
||||
# turn loop, ends when player finishes their turn
|
||||
while True:
|
||||
clear()
|
||||
welcome()
|
||||
print_welcome_screen()
|
||||
print(f"\n\t\t\tGame {game}")
|
||||
print(scores)
|
||||
print(player_hands_message)
|
||||
@@ -407,7 +407,7 @@ STARTING_BALANCE: int = 100
|
||||
def main() -> None:
|
||||
game: Game
|
||||
|
||||
welcome()
|
||||
print_welcome_screen()
|
||||
|
||||
# create game
|
||||
game = Game.new(
|
||||
@@ -421,9 +421,7 @@ def main() -> None:
|
||||
char = get_char_from_user_input("Play Again?", ["y", "n"])
|
||||
|
||||
|
||||
def welcome() -> None:
|
||||
"""prints the welcome screen"""
|
||||
# welcome message
|
||||
def print_welcome_screen() -> None:
|
||||
print(
|
||||
"""
|
||||
BLACK JACK
|
||||
@@ -432,8 +430,7 @@ def welcome() -> None:
|
||||
)
|
||||
|
||||
|
||||
def instructions() -> None:
|
||||
"""prints the instructions"""
|
||||
def print_instructions() -> None:
|
||||
print(
|
||||
"""
|
||||
THIS IS THE GAME OF 21. AS MANY AS 7 PLAYERS MAY PLAY THE
|
||||
|
||||
Reference in New Issue
Block a user