예제 #1
0
def add_hint(spoiler,
             world,
             IDs,
             text,
             count,
             location=None,
             force_reachable=False):
    random.shuffle(IDs)
    skipped_ids = []
    first = True
    success = True
    while random.random() < count:
        if IDs:
            id = IDs.pop(0)

            if gossipLocations[id].reachable:
                stone_location = gossipLocations[id].location
                if not first or can_reach_stone(spoiler.worlds, stone_location,
                                                location):
                    if first and location:
                        old_rule = location.access_rule
                        location.access_rule = lambda state: state.can_reach(
                            stone_location, resolution_hint='Location'
                        ) and old_rule(state)

                    count -= 1
                    first = False
                    spoiler.hints[world.id][id] = lineWrap(text)
                else:
                    skipped_ids.append(id)
            else:
                if not force_reachable:
                    # The stones are not readable at all in logic, so we ignore any kind of logic here
                    count -= 1
                    spoiler.hints[world.id][id] = lineWrap(text)
                else:
                    # If flagged to guarantee reachable, then skip
                    # If no stones are reachable, then this will place nothing
                    skipped_ids.append(id)
        else:
            success = False
            break
    IDs.extend(skipped_ids)
    return success
예제 #2
0
 def __str__(self):
     return get_raw_text(lineWrap(colorText(self)))
예제 #3
0
def add_hint(world, id, text):
    world.spoiler.hints[id] = lineWrap(text)