about summary refs log tree commit diff stats
path: root/data/maps/the_jubilant/metadata.txtpb
blob: 4af18742173d451d940061ab44c563c540e04e5a (plain) (blame)
1
2
3
4
5
display_name: "The Jubilant"
worldport_entrance {
  room: "Main Area"
  name: "GREAT"
}
99 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
from collections.abc import Callable
from typing import TYPE_CHECKING

from BaseClasses import CollectionState
from .player_logic import AccessRequirements

if TYPE_CHECKING:
    from . import Lingo2World


def lingo2_can_satisfy_requirements(state: CollectionState, reqs: AccessRequirements, world: "Lingo2World") -> bool:
    if not all(state.has(item, world.player) for item in reqs.items):
        return False

    if not all(state.has(item, world.player, amount) for item, amount in reqs.progressives.items()):
        return False

    if not all(state.can_reach_region(region_name, world.player) for region_name in reqs.rooms):
        return False

    # TODO: symbols

    for letter_key, letter_level in reqs.letters.items():
        if not state.has(letter_key, world.player, letter_level):
            return False

    if reqs.cyans:
        if not any(state.has(letter, world.player, amount)
                   for letter, amount in world.player_logic.double_letter_amount.items()):
            return False

    if len(reqs.or_logic) > 0:
        if not all(any(lingo2_can_satisfy_requirements(state, sub_reqs, world) for sub_reqs in subjunction)
                   for subjunction in reqs.or_logic):
            return False

    return True

def make_location_lambda(reqs: AccessRequirements, world: "Lingo2World") -> Callable[[CollectionState], bool]:
    return lambda state: lingo2_can_satisfy_requirements(state, reqs, world)