コード例 #1
0
ファイル: play.py プロジェクト: Anavros/taskomatic
def task_menu(party, hotseat, card):
    (task, points) = card

    options = [
        'yes',
        'no',
        'mercy',
        'transfer name',  # TODO: touch up
    ]
    while True:
        #malt.serve()
        #malt.serve("### TASK ###")
        #malt.line("#")
        malt.serve("{}: {}.".format(hotseat, task))
        response = malt.fill(options)

        if response == 'yes':
            malt.serve("You accept the task and have earned {} points.".format(points))
            party.score(hotseat, points)
            break

        elif response == 'no':
            if hotseat.immunities > 0:
                if malt.confirm("Would you like to consume an immunity token? "):
                    hotseat.immunities -= 1
                    malt.serve("You do not lose any points.")
                    break
            malt.serve("You reject the task, losing {} points.".format(points))
            party.score(hotseat, -points)
            break

        elif response == 'mercy':
            malt.serve("You will not lose points, but will be presented another task.")
            return # don't rotate so the same player gets another

        elif response == 'transfer':
            recipient = response.name
            if hotseat == recipient:
                malt.serve("Naughty, naughty. You can't transfer a task to yourself.")
                continue
            try:
                party.score(recipient, points*2)
            except ValueError:
                malt.serve("{} is not a registered player.".format(recipient))
            else:
                malt.serve("You send the task to {}, who earns {} points.".format(
                    recipient, points*2))
                break

        elif response == 'back':
            malt.serve("You postpone the choice for later.")
            hotseat.stored_task = (task, points)
            return

    progress_game(party)
コード例 #2
0
ファイル: shop.py プロジェクト: Anavros/taskomatic
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