about summary refs log tree commit diff stats
path: root/.clang-format
blob: f6cb8ad931f5442a5e2276ed66ba7b5a733b82c6 (plain) (blame)
1
BasedOnStyle: Google
color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* 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.can_reach_region(region_name, world.player) for region_name in reqs.rooms):
        return False

    # TODO: symbols, letters

    for disjunction in reqs.or_logic:
        if not any(lingo2_can_satisfy_requirements(state, sub_reqs, world) for sub_reqs in disjunction):
            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)