Exemplo n.º 1
0
def handle_game(ubet):
    if not ubet in G.valid:
        app.put_console("wrong bet: '{}', must be 'r', 'p' or 's'".format(ubet))
        return
    cbet = random.choice(G.valid)
    if cbet == ubet:
        result = "that's a draw"
    elif cbet + ubet in G.firstwin:
        result = "I win"
        G.cpoints += 1
        write_status()
    else:
        result = "you win"
        G.upoints += 1
        write_status()
    msg = "Your bet was '{}', my bet was '{}':  {}"
    app.put_console(msg.format(ubet, cbet, result))

    if G.cpoints >= 10:
        app.put_message("\nGame over, I have won")
        game_end()
        return
    if G.upoints >= 10:
        app.put_message("\nGame over, You have won")
        game_end()
        return
Exemplo n.º 2
0
def init_handler():
    app.put_console("~clr~")
    app.put_console(
        """Welcome to the Rock-Paper-Scissor game

You play against me, who first gets 10 points is the winner.
You enter your bet: 'r', 'p' or 's', I make my own bet.
Rock wins agains Scissor, Scissor wins against Paper,
Paper wins against Rock, two equal bets are a draw.
So lets start (you can enter 'x' to end the game at any time

Your first bet, please
"""
    )
    app.put_message("~clr~")
    app.put_message("Status of the game:\n")

    G.state = "g"
    G.rounds = 10  # maximum 10 rounds
    G.upoints = 0
    G.cpoints = 0

    write_status()
Exemplo n.º 3
0
def command_handler(text):
    guess = check_input(text)
    gui.put_console("input: {}".format(guess))
Exemplo n.º 4
0
def command_handler(text):
    print("imp_received text: {}".format(text))
    app.put_console("console text")
    app.put_message("message text")
Exemplo n.º 5
0
def init_handler(text):
    print("imp_init_handler: {}".format(text))
    app.put_console('~clr~')
    app.put_console('Welcome to the Kivy world')

    app.put_message('~clr~')
Exemplo n.º 6
0
def game_end():
    G.state = "x"
    app.put_console("\nDo you want to play again? (y/n)")