Exemplo n.º 1
0
def perk_menu(party):
    # NOTE: may change in the future
    base_cost = util.points_value(2)
    hot = party.hotseat()
    options = [
        'curse',
        'shuffle',
        'protection',
        'skip',
        'immunity',
    ]
    while True:
        response = malt.fill(options)

        if response == 'curse':
            malt.serve("Make an opponent's next turn extra hard.")
            cost = base_cost*5

            if malt.confirm("Purchase for {} points? ".format(cost)):
                name = malt.freefill("Which player would you like to affect? ")
                if not party.verify(name):
                    malt.serve("{} is not a registered player.".format(name))
                    malt.serve("Your cost has been refunded.")
                    continue
                elif name == hot:
                    malt.serve("You may not curse yourself.")
                    malt.serve("Your cost has been refunded.")
                    continue
                else:
                    p = party.lookup(name)
                    if not p.cursed:
                        if debit(hot, cost):
                            p.cursed = True
                            malt.serve("{}'s next task will be extra spicy.".format(p))
                            return
                    else:
                        malt.serve("{} has already been cursed.")
                        malt.serve("Your cost has been refunded.")
                        continue

        elif response == 'shuffle':
            malt.serve("Shuffle the turn order for everyone in the party.")
            # for 2p games, as 50% chance to give double turn
            cost = base_cost*20

            if malt.confirm("Purchase for {} points? ".format(cost)):
                if debit(hot, cost):
                    party.to_shuffle = True
                    malt.serve("Shuffled turn orders.")
                    return

        elif response == 'protection':
            malt.serve("Automatically skip your next turn.")
            cost = base_cost*20

            if malt.confirm("Purchase for {} points? ".format(cost)):
                if debit(hot, cost):
                    hot.pending_protection = True
                    malt.serve("Your next turn will be skipped.")
                    return

        elif response == 'skip':
            malt.serve("Skip this turn.")
            cost = base_cost*100

            if malt.confirm("Purchase for {} points? ".format(cost)):
                if debit(hot, cost):
                    hot.protected = True
                    return
            
        elif response == 'immunity':
            malt.serve("Reject any one task at no cost.")
            malt.serve("More than one can be purchased at a time.")
            cost = base_cost*50

            if malt.confirm("Purchase for {} points? ".format(cost)):
                if debit(hot, cost):
                    hot.immunities += 1
                    malt.serve("You have {} immunity tokens.".format(hot.immunities))
                    return

        elif response == 'back':
            break
Exemplo n.º 2
0
def main_menu(args):
    """Run the main interactive menu.

    In this menu, party can be added to or removed from the game, and both
    the normal gameplay loop and the special debug loop can be accessed.
    """
    try:
        deck = setup_deck(args)
        party = setup_party(args)
    except SystemExit:
        print("Aborting startup.")
        return

    # Immediately enter debug mode if --debug is given.
    if args.debug:
        malt.serve("entering debug mode...")
        with malt.indent():
            debug.debug_menu(deck, party, args)

    options = [
        'start',
        'mercy',
        'daily',
        'debug',
        'add name',
        'remove name',
        'save game_file',
        'resume game_file',
        'export deck_file',
        'autosave toggle',
    ]
    while True:
        response = malt.fill(options)

        if response == 'start':
            if len(party.players) < 2:
                malt.serve("Please register at least two players to begin the game.")
                continue
            # check if the users want to set a losing punishment
            with malt.indent():
                play.game_menu(deck, party)

        elif response == 'debug':
            malt.serve("Entering debug mode.")
            with malt.indent():
                debug.debug_menu(deck, party, args)

        elif response == 'add':
            name = response.name
            if name in party.names():
                malt.serve("{} is already registered!".format(name))
            else:
                malt.serve("Registering {} as a new player.".format(name))
                party.add(name)

        elif response == 'remove':
            name = response.name
            if name in party.names():
                malt.serve("Removing {} from the game.".format(name))
                party.kick(name)
            else:
                malt.serve("{} is not a registered player!".format(name))

        elif response == 'save':
            path = response.game_file
            disk.yaml_dump(path, party)

        elif response == 'resume':
            path = response.game_file
            new_party = disk.yaml_load(path)
            if new_party is not None:
                party = new_party

        elif response == 'export':
            path = response.deck_file
            disk.yaml_dump(path, deck)

        elif response == 'autosave':
            toggle = response.toggle
            if toggle == 'on':
                filename = malt.freefill("filename: ")
                if disk.yaml_dump(filename, party):
                    party.autosave = True
                    party.save_location = filename
                    malt.serve("Enabled autosave.")
                else:
                    malt.serve("Cancelled autosave.")

            elif toggle == 'off':
                party.autosave = False
                malt.serve("Disabled autosave.")
            elif toggle == 'check':
                malt.serve("Autosave is currently {}.".format(
                    'on' if party.autosave else 'off'))
            else:
                malt.serve("The only options for autosave are on, off, and check.")

        elif response == 'back':
            break