about summary refs log tree commit diff stats
path: root/tools/datapacker/CMakeLists.txt
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2025-09-27 17:14:40 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2025-09-27 17:14:40 -0400
commitb0f474bee1c8e1111f7542bf4985136d9aedf340 (patch)
treeef2aa34bad532ffb2a45d90893dbcd4c378a0dfb /tools/datapacker/CMakeLists.txt
parentfeb89a44ddf5f93bc476ca29cd02257aea47dc06 (diff)
downloadlingo2-archipelago-b0f474bee1c8e1111f7542bf4985136d9aedf340.tar.gz
lingo2-archipelago-b0f474bee1c8e1111f7542bf4985136d9aedf340.tar.bz2
lingo2-archipelago-b0f474bee1c8e1111f7542bf4985136d9aedf340.zip
Treat local letters as items for tracker
Local letters are now synced with datastorage, so they transfer to other computers like regular items would, and the tracker also now waits until you collect local letters before showing what they give you in logic.
Diffstat (limited to 'tools/datapacker/CMakeLists.txt')
0 files changed, 0 insertions, 0 deletions
#dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { 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, Region
from .player_logic import AccessRequirements

if TYPE_CHECKING:
    from . import Lingo2World


def lingo2_can_satisfy_requirements(state: CollectionState, reqs: AccessRequirements, regions: list[Region],
                                    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

    if not all(state.can_reach(region) for region in regions):
        return False

    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

    if reqs.complete_at is not None:
        completed = 0
        checked = 0
        for possibility in reqs.possibilities:
            checked += 1
            if lingo2_can_satisfy_requirements(state, possibility, [], world):
                completed += 1
                if completed >= reqs.complete_at:
                    break
            elif len(reqs.possibilities) - checked + completed < reqs.complete_at:
                # There aren't enough remaining possibilities for the check to pass.
                return False
        if completed < reqs.complete_at:
            return False

    return True

def make_location_lambda(reqs: AccessRequirements, world: "Lingo2World",
                         regions: dict[str, Region]) -> Callable[[CollectionState], bool]:
    # Replace required rooms with regions for the top level requirement, which saves looking up the regions during rule
    # checking.
    required_regions = [regions[room_name] for room_name in reqs.rooms]
    new_reqs = reqs.copy()
    new_reqs.rooms.clear()
    return lambda state: lingo2_can_satisfy_requirements(state, new_reqs, required_regions, world)