Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
PoryGone committed Mar 3, 2024
1 parent a8de69e commit e858844
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 107 deletions.
4 changes: 2 additions & 2 deletions worlds/celeste64/Items.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Callable, Dict, NamedTuple, Optional
from typing import Dict, NamedTuple, Optional

from BaseClasses import Item, ItemClassification, MultiWorld
from BaseClasses import Item, ItemClassification
from .Names import ItemName


Expand Down
4 changes: 2 additions & 2 deletions worlds/celeste64/Locations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Callable, Dict, NamedTuple, Optional
from typing import Dict, NamedTuple, Optional

from BaseClasses import Location, MultiWorld
from BaseClasses import Location
from .Names import LocationName


Expand Down
3 changes: 1 addition & 2 deletions worlds/celeste64/Options.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from dataclasses import dataclass
from typing import Dict

from Options import Choice, Option, Toggle, Range, DeathLink, PerGameCommonOptions
from Options import Range, DeathLink, PerGameCommonOptions


class StrawberriesRequired(Range):
Expand Down
186 changes: 91 additions & 95 deletions worlds/celeste64/Rules.py
Original file line number Diff line number Diff line change
@@ -1,108 +1,104 @@
from typing import Callable
from worlds.generic.Rules import set_rule

from BaseClasses import CollectionState, MultiWorld
from . import Celeste64World
from .Names import ItemName, LocationName
from worlds.AutoWorld import World
from worlds.generic.Rules import add_rule, set_rule, CollectionRule



def set_rules(world: World):

add_rule(world.multiworld.get_location(LocationName.strawberry_4,world.player),
lambda state: state.has(ItemName.traffic_block, world.player) and
state.has(ItemName.breakables, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_5,world.player),
lambda state: state.has(ItemName.breakables, world.player)) # Questionable
add_rule(world.multiworld.get_location(LocationName.strawberry_6,world.player),
def set_rules(world: Celeste64World):
set_rule(world.multiworld.get_location(LocationName.strawberry_4, world.player),
lambda state: state.has_all({ItemName.traffic_block,
ItemName.breakables}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_5, world.player),
lambda state: state.has(ItemName.breakables, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_6, world.player),
lambda state: state.has(ItemName.dash_refill, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_8,world.player),
set_rule(world.multiworld.get_location(LocationName.strawberry_8, world.player),
lambda state: state.has(ItemName.traffic_block, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_9,world.player),
set_rule(world.multiworld.get_location(LocationName.strawberry_9, world.player),
lambda state: state.has(ItemName.dash_refill, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_11,world.player),
set_rule(world.multiworld.get_location(LocationName.strawberry_11, world.player),
lambda state: state.has(ItemName.dash_refill, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_12,world.player),
lambda state: state.has(ItemName.dash_refill, world.player) or
state.has(ItemName.double_dash_refill, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_13,world.player),
lambda state: state.has(ItemName.dash_refill, world.player) and
state.has(ItemName.breakables, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_14,world.player),
lambda state: state.has(ItemName.dash_refill, world.player) and
state.has(ItemName.feather, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_15,world.player),
lambda state: state.has(ItemName.dash_refill, world.player) and
state.has(ItemName.feather, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_16,world.player),
lambda state: state.has(ItemName.dash_refill, world.player) and
state.has(ItemName.feather, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_17,world.player),
lambda state: state.has(ItemName.dash_refill, world.player) and
state.has(ItemName.double_dash_refill, world.player) and
state.has(ItemName.feather, world.player) and
state.has(ItemName.traffic_block, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_18,world.player),
set_rule(world.multiworld.get_location(LocationName.strawberry_12, world.player),
lambda state: state.has_all({ItemName.dash_refill,
ItemName.double_dash_refill}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_13, world.player),
lambda state: state.has_all({ItemName.dash_refill,
ItemName.breakables}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_14, world.player),
lambda state: state.has_all({ItemName.dash_refill,
ItemName.feather}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_15, world.player),
lambda state: state.has_all({ItemName.dash_refill,
ItemName.feather}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_16, world.player),
lambda state: state.has_all({ItemName.dash_refill,
ItemName.feather}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_17, world.player),
lambda state: state.has_all({ItemName.dash_refill,
ItemName.double_dash_refill,
ItemName.feather,
ItemName.traffic_block}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_18, world.player),
lambda state: state.has(ItemName.double_dash_refill, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_19,world.player),
lambda state: state.has(ItemName.double_dash_refill, world.player) and
state.has(ItemName.spring, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_20,world.player),
lambda state: state.has(ItemName.dash_refill, world.player) and
state.has(ItemName.feather, world.player) and
state.has(ItemName.breakables, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_19, world.player),
lambda state: state.has_all({ItemName.double_dash_refill,
ItemName.spring}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_20, world.player),
lambda state: state.has_all({ItemName.dash_refill,
ItemName.feather,
ItemName.breakables}, world.player))

add_rule(world.multiworld.get_location(LocationName.strawberry_21,world.player),
lambda state: state.has(ItemName.cassette, world.player) and
state.has(ItemName.traffic_block, world.player) and
state.has(ItemName.breakables, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_22,world.player),
lambda state: state.has(ItemName.cassette, world.player) and
state.has(ItemName.dash_refill, world.player) and
state.has(ItemName.breakables, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_23,world.player),
lambda state: state.has(ItemName.cassette, world.player) and
state.has(ItemName.dash_refill, world.player) and
state.has(ItemName.coin, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_24,world.player),
lambda state: state.has(ItemName.cassette, world.player) and
state.has(ItemName.traffic_block, world.player) and
state.has(ItemName.dash_refill, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_25,world.player),
lambda state: state.has(ItemName.cassette, world.player) and
state.has(ItemName.dash_refill, world.player) and
state.has(ItemName.double_dash_refill, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_26,world.player),
lambda state: state.has(ItemName.cassette, world.player) and
state.has(ItemName.dash_refill, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_27,world.player),
lambda state: state.has(ItemName.cassette, world.player) and
state.has(ItemName.feather, world.player) and
state.has(ItemName.coin, world.player) and
state.has(ItemName.dash_refill, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_28,world.player),
lambda state: state.has(ItemName.cassette, world.player) and
state.has(ItemName.feather, world.player) and
state.has(ItemName.coin, world.player) and
state.has(ItemName.dash_refill, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_29,world.player),
lambda state: state.has(ItemName.cassette, world.player) and
state.has(ItemName.feather, world.player) and
state.has(ItemName.coin, world.player) and
state.has(ItemName.dash_refill, world.player))
add_rule(world.multiworld.get_location(LocationName.strawberry_30,world.player),
lambda state: state.has(ItemName.cassette, world.player) and
state.has(ItemName.feather, world.player) and
state.has(ItemName.traffic_block, world.player) and
state.has(ItemName.spring, world.player) and
state.has(ItemName.breakables, world.player) and
state.has(ItemName.dash_refill, world.player) and
state.has(ItemName.double_dash_refill, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_21, world.player),
lambda state: state.has_all({ItemName.cassette,
ItemName.traffic_block,
ItemName.breakables}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_22, world.player),
lambda state: state.has_all({ItemName.cassette,
ItemName.dash_refill,
ItemName.breakables}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_23, world.player),
lambda state: state.has_all({ItemName.cassette,
ItemName.dash_refill,
ItemName.coin}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_24, world.player),
lambda state: state.has_all({ItemName.cassette,
ItemName.traffic_block,
ItemName.dash_refill}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_25, world.player),
lambda state: state.has_all({ItemName.cassette,
ItemName.dash_refill,
ItemName.double_dash_refill}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_26, world.player),
lambda state: state.has_all({ItemName.cassette,
ItemName.dash_refill}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_27, world.player),
lambda state: state.has_all({ItemName.cassette,
ItemName.feather,
ItemName.coin,
ItemName.dash_refill}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_28, world.player),
lambda state: state.has_all({ItemName.cassette,
ItemName.feather,
ItemName.coin,
ItemName.dash_refill}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_29, world.player),
lambda state: state.has_all({ItemName.cassette,
ItemName.feather,
ItemName.coin,
ItemName.dash_refill}, world.player))
set_rule(world.multiworld.get_location(LocationName.strawberry_30, world.player),
lambda state: state.has_all({ItemName.cassette,
ItemName.feather,
ItemName.traffic_block,
ItemName.spring,
ItemName.breakables,
ItemName.dash_refill,
ItemName.double_dash_refill}, world.player))

# Completion condition.
world.multiworld.completion_condition[world.player] = lambda state: (state.has(ItemName.strawberry,world.player,world.options.strawberries_required.value) and
state.has(ItemName.feather, world.player) and
state.has(ItemName.traffic_block, world.player) and
state.has(ItemName.breakables, world.player) and
state.has(ItemName.dash_refill, world.player) and
state.has(ItemName.double_dash_refill, world.player))
state.has_all({ItemName.feather,
ItemName.traffic_block,
ItemName.breakables,
ItemName.dash_refill,
ItemName.double_dash_refill}, world.player))
22 changes: 16 additions & 6 deletions worlds/celeste64/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from typing import List

from BaseClasses import Region, Tutorial
from BaseClasses import ItemClassification, Region, Tutorial
from worlds.AutoWorld import WebWorld, World
from .Items import Celeste64Item, item_data_table, item_table
from .Locations import Celeste64Location, location_data_table, location_table
from .Names import ItemName, LocationName
from .Names import ItemName
from .Options import Celeste64Options
from .Regions import region_data_table
from .Rules import set_rules


class Celeste64WebWorld(WebWorld):
Expand Down Expand Up @@ -39,11 +37,21 @@ class Celeste64World(World):


def create_item(self, name: str) -> Celeste64Item:
# Potentially don't make all strawberries Progression
return Celeste64Item(name, item_data_table[name].type, item_data_table[name].code, self.player)
# Only make required amount of strawberries be Progression
if name == ItemName.strawberry:
classification: ItemClassification = ItemClassification.filler
if self.prog_strawberries < self.options.strawberries_required.value:
classification = ItemClassification.progression
self.prog_strawberries += 1

return Celeste64Item(name, classification, item_data_table[name].code, self.player)
else:
return Celeste64Item(name, item_data_table[name].type, item_data_table[name].code, self.player)

def create_items(self) -> None:
item_pool: List[Celeste64Item] = []
self.prog_strawberries: int = 0

for name, item in item_data_table.items():
item_pool.append(self.create_item(name))

Expand All @@ -54,6 +62,7 @@ def create_items(self) -> None:


def create_regions(self) -> None:
from .Regions import region_data_table
# Create regions.
for region_name in region_data_table.keys():
region = Region(region_name, self.player, self.multiworld)
Expand All @@ -74,6 +83,7 @@ def get_filler_item_name(self) -> str:


def set_rules(self) -> None:
from .Rules import set_rules
set_rules(self)


Expand Down

0 comments on commit e858844

Please sign in to comment.