Exemple #1
0
def new_task(hotseat, deck, party):
    """Generate and fill in a new task with respect to the current player.

    Modify the task in place by the perks (if any) the player has active.
    """
    # Find a good task.
    target = util.target_rating(hotseat.points, hotseat.mod)
    (task, rating) = taskgen.random_task(deck, target)
    points = util.points_value(hotseat.mod)

    # Fill out the cosmetics.
    support = random.choice([n for n in party.names() if n != hotseat])
    task = util.insert_cosmetics(task, support)

    # TODO: apply modifiers, streak, etc
    return (task, points)
Exemple #2
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
Exemple #3
0
def debug_menu(deck, party, args):
    """Offer options for viewing and tweaking internal variables."""

    options = [
        'batch n:int',
        #'level n:int',
        'progress difficulty',
        'np difficulty',
        'dump level',
        'intensity level:int',
        'args',
    ]
    while 1:
        response = malt.fill(options)

        if response == 'batch':
            for i in range(response.n):
                (text, value) = taskgen.random_task(deck)
                print('[{}] '.format(i), end='')
                display((text, value))

        # Print out all tasks at a certain level.
        elif response == 'level':
            level = response.n
            nested = taskgen.all_combinations(deck.base, deck.subs)
            # remove all out-of-level tasks
            nested = [[(t, v) for (t, v) in base if v==level] for base in nested]
            # clean up empty lists
            nested = [base for base in nested if len(base) > 0]
            # sort tasks alphabetically
            nested = sorted(nested, key=lambda x: x[0][0:5])
            for base in nested:
                # sort variations by point value
                base = sorted(base, key=lambda x: x[1])
                print("========================================")
                for variation in base:
                    display(variation)
                print("")

        elif response == 'progress':
            try:
                mod = util.rating_value(response.difficulty)
            except ValueError:
                malt.serve("Invalid difficulty.")
                continue

            points = 0
            turn_num = 0
            while turn_num < 20:
                turn_num += 1
                target = util.target_rating(points, mod)
                (text, rating) = taskgen.random_task(deck, target)
                print("({}) {}".format(rating, text))
                points += util.points_value(mod)

        elif response == 'np':
            # Take arguments.
            try:
                mod = util.rating_value(response.difficulty)
            except ValueError:
                malt.serve("Invalid difficulty.")
                continue
            #end = response.turns

            points = 0
            turn_num = 0
            while turn_num < 20:
                turn_num += 1
                target = util.target_rating(points, mod)
                print("[{}] (Level {})".format(util.format_number(points), target))
                points += util.points_value(mod)

        # Dump every possible complete task.
        elif response == 'dump':
            nested = taskgen.all_combinations(deck.base, deck.subs)
            if response.level == 'all':
                pass
            else:
                try:
                    rating = util.rating_value(response.level)
                    # remove all out-of-level tasks
                    nested = [
                        [(t, v) for (t, v) in base if v==rating] for base in nested]
                    # clean up empty lists
                    nested = [base for base in nested if len(base) > 0]
                except ValueError:
                    malt.serve("Invalid difficulty.")
                    continue
            # sort tasks alphabetically by the first five characters
            nested = sorted(nested, key=lambda x: x[0][0:5])
            for base in nested:
                # sort variations by point value
                base = sorted(base, key=lambda x: x[1])
                print("========================================")
                for variation in base:
                    display(variation)
                #print("")

        # Set the intensity level.
        elif response == 'intensity':
            malt.serve("setting flag -{}".format('x'*response.level))
            party.intensity = response.level

        elif response == 'args':
            malt.serve(args)

        elif response == 'back': break