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 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