コード例 #1
0
ファイル: blackjack.py プロジェクト: bfrentz/Blackjack
def main():
    print("\n\t\tWelcome to the Blackjack table!\n")

    names = []
    money = []
    number = games.askNumber("How many people are playing? (1 - 7): ",
                             low=1,
                             high=8)
    for i in range(number):
        name = input("Enter player name: ")
        cash = input("How much money do they have? ")
        names.append(name)
        money.append(cash)

    print()

    # initialize game
    game = bjGame(names, money)

    again = None
    while again != "n":
        game.play()
        again = games.askYesNo("\nDo you want to play again? (y/n): ")
        if again == "y":
            game.reshuffle()
            print("\nShuffling the deck.\n\n")

    print(
        "\nThanks for playing! We hope you'll visit the virtual casino again soon!\n"
    )
コード例 #2
0
ファイル: war.py プロジェクト: lyubomirShoylev/pythonBook
def main():
    print("\t\tWelcome to War, the simple one-card many-player game!\n")

    names = []
    number = games.askNumber("How many players? (1 - 7):", low=1, high=8)
    for i in range(number):
        name = input("Enter player name: ").capitalize()
        names.append(name)

    print()

    game = WarGame(names)
    again = None
    while again != "n":
        game.play()
        again = games.askYesNo("\nDo you want to play again?: ")
コード例 #3
0
# Simple Game
# Demonstrates importing modules

import games, random

print("Welcome to the world's simplest game!\n")

again = None

while again != "n":
    players = []
    num = games.askNumber("How many players? (2 - 5): ", 2, 5)

    for i in range(num):
        name = input("Player name: ")
        score = random.randrange(100) + 1
        player = games.Player(name, score)
        players.append(player)
    
    print("\nHere are the game results:")
    for player in players:
        print(player)
    
    again = games.askYesNo("\nDo you want to play again? (y/n): ")

input("\n\nPress the enter key to exit.")