def get_new_formations(areaname, supplement=True):
    from randomizer import get_namelocdict
    namelocdict = get_namelocdict()
    setids = set([])
    for key in namelocdict:
        if type(key) is str and areaname in key:
            setids |= set(namelocdict[key])

    fsets = [fs for fs in get_fsets() if fs.setid in setids]
    formations = set([])
    for fs in fsets:
        formations |= set(fs.formations)

    if supplement:
        lowest = min(formations, key=lambda f: f.rank()).rank()
        highest = max(formations, key=lambda f: f.rank()).rank()
        supplemental = [
            f for f in get_formations() if not f.has_boss
            and lowest < f.rank() <= highest and not f.battle_event
        ]
        supplemental = sorted(supplemental, key=lambda f: f.rank())
        formations |= {f for f in supplemental if f.ambusher or f.inescapable}
        supplemental = supplemental[len(supplemental) // 2:]
        formations |= set(supplemental)

    return sorted(formations, key=lambda f: f.formid)
Ejemplo n.º 2
0
def get_new_formations(areaname, supplement=True):
    from randomizer import get_namelocdict
    namelocdict = get_namelocdict()
    setids = set([])
    for key in namelocdict:
        if type(key) is str and areaname in key:
            setids |= set(namelocdict[key])

    fsets = [fs for fs in get_fsets() if fs.setid in setids]
    formations = set([])
    for fs in fsets:
        formations |= set(fs.formations)

    if supplement:
        lowest = min(formations, key=lambda f: f.rank()).rank()
        highest = max(formations, key=lambda f: f.rank()).rank()
        supplemental = [f for f in get_formations() if
                        not f.has_boss and lowest < f.rank() <= highest and
                        not f.battle_event]
        supplemental = sorted(supplemental, key=lambda f: f.rank())
        formations |= set([f for f in supplemental if
                           f.ambusher or f.inescapable])
        supplemental = supplemental[len(supplemental)/2:]
        formations |= set(supplemental)

    return sorted(formations, key=lambda f: f.formid)