mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
The Messenger: Add Shop Rando (#1834)
* add shop shuffle options and items * add logic for the shop slots * write cost tests * start on shop item logic * make strike and second wind early items * some cleanup * remove 5 shards * double cost requirement for really expensive items and raise the rates * add test for shop shuffle with minimum other locations * put power seal in front of shards * rename locations and items * update rules, regions, and shop * update tests and misc fixes * minor cleanup * implement money wrench and figurines * clean out now unneeded info from slot_data * docs update and fix a failure when not shuffling shops * remove shop shuffle option * Finish out shop rules * make seals generation easier to read and fix tests * rule adjustments * oop * adjust the prices to be a bit more generous * add max price to slot data for tracker * update the hard rules a bit * remove unnecessary test * update data_version * bump version and remove info for fixed issues * remove now unneeded assert * review updates * minor bug fix * add a test for minimum locations shop costing * minor optimizations and cleanup * remove whitespace
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
from typing import Set, TYPE_CHECKING, Optional, Dict
|
||||
|
||||
from BaseClasses import Region, Location, Item, ItemClassification, Entrance
|
||||
from .Constants import SEALS, NOTES, PROG_ITEMS, PHOBEKINS, USEFUL_ITEMS
|
||||
from BaseClasses import Region, Location, Item, ItemClassification, Entrance, CollectionState
|
||||
from .Constants import NOTES, PROG_ITEMS, PHOBEKINS, USEFUL_ITEMS
|
||||
from .Options import Goal
|
||||
from .Regions import REGIONS, MEGA_SHARDS
|
||||
from .Regions import REGIONS, SEALS, MEGA_SHARDS
|
||||
from .Shop import SHOP_ITEMS, PROG_SHOP_ITEMS, USEFUL_SHOP_ITEMS, FIGURINES
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import MessengerWorld
|
||||
@@ -20,14 +21,21 @@ class MessengerRegion(Region):
|
||||
def add_locations(self, name_to_id: Dict[str, int]) -> None:
|
||||
for loc in REGIONS[self.name]:
|
||||
self.locations.append(MessengerLocation(loc, self, name_to_id.get(loc, None)))
|
||||
if self.name == "The Shop" and self.multiworld.goal[self.player] > Goal.option_open_music_box:
|
||||
self.locations.append(MessengerLocation("Shop Chest", self, name_to_id.get("Shop Chest", None)))
|
||||
# putting some dumb special case for searing crags and ToT so i can split them into 2 regions
|
||||
if self.multiworld.shuffle_seals[self.player] and self.name not in {"Searing Crags", "Tower HQ", "Cloud Ruins"}:
|
||||
self.locations += [MessengerLocation(seal_loc, self, name_to_id.get(seal_loc, None))
|
||||
for seal_loc in SEALS if seal_loc.startswith(self.name.split(" ")[0])]
|
||||
if self.name == "The Shop":
|
||||
if self.multiworld.goal[self.player] > Goal.option_open_music_box:
|
||||
self.locations.append(MessengerLocation("Shop Chest", self, None))
|
||||
self.locations += [MessengerShopLocation(f"The Shop - {shop_loc}", self,
|
||||
name_to_id[f"The Shop - {shop_loc}"])
|
||||
for shop_loc in SHOP_ITEMS]
|
||||
self.locations += [MessengerShopLocation(figurine, self, name_to_id[figurine])
|
||||
for figurine in FIGURINES]
|
||||
elif self.name == "Tower HQ":
|
||||
self.locations.append(MessengerLocation("Money Wrench", self, name_to_id["Money Wrench"]))
|
||||
if self.multiworld.shuffle_seals[self.player] and self.name in SEALS:
|
||||
self.locations += [MessengerLocation(seal_loc, self, name_to_id[seal_loc])
|
||||
for seal_loc in SEALS[self.name]]
|
||||
if self.multiworld.shuffle_shards[self.player] and self.name in MEGA_SHARDS:
|
||||
self.locations += [MessengerLocation(shard, self, name_to_id.get(shard, None))
|
||||
self.locations += [MessengerLocation(shard, self, name_to_id[shard])
|
||||
for shard in MEGA_SHARDS[self.name]]
|
||||
|
||||
def add_exits(self, exits: Set[str]) -> None:
|
||||
@@ -46,13 +54,33 @@ class MessengerLocation(Location):
|
||||
self.place_locked_item(MessengerItem(name, parent.player, None))
|
||||
|
||||
|
||||
class MessengerShopLocation(MessengerLocation):
|
||||
def cost(self) -> int:
|
||||
name = self.name.replace("The Shop - ", "") # TODO use `remove_prefix` when 3.8 finally gets dropped
|
||||
world: MessengerWorld = self.parent_region.multiworld.worlds[self.player]
|
||||
return world.shop_prices.get(name, world.figurine_prices.get(name))
|
||||
|
||||
def can_afford(self, state: CollectionState) -> bool:
|
||||
world: MessengerWorld = state.multiworld.worlds[self.player]
|
||||
cost = self.cost() * 2
|
||||
if cost >= 1000:
|
||||
cost *= 2
|
||||
can_afford = state.has("Shards", self.player, min(cost, world.total_shards))
|
||||
if "Figurine" in self.name:
|
||||
return state.has("Money Wrench", self.player) and can_afford
|
||||
return can_afford
|
||||
|
||||
|
||||
class MessengerItem(Item):
|
||||
game = "The Messenger"
|
||||
|
||||
def __init__(self, name: str, player: int, item_id: Optional[int] = None, override_progression: bool = False) -> None:
|
||||
if name in {*NOTES, *PROG_ITEMS, *PHOBEKINS} or item_id is None or override_progression:
|
||||
def __init__(self, name: str, player: int, item_id: Optional[int] = None, override_progression: bool = False,
|
||||
count: int = 0) -> None:
|
||||
if count:
|
||||
item_class = ItemClassification.progression_skip_balancing
|
||||
elif item_id is None or override_progression or name in {*NOTES, *PROG_ITEMS, *PHOBEKINS, *PROG_SHOP_ITEMS}:
|
||||
item_class = ItemClassification.progression
|
||||
elif name in USEFUL_ITEMS:
|
||||
elif name in {*USEFUL_ITEMS, *USEFUL_SHOP_ITEMS}:
|
||||
item_class = ItemClassification.useful
|
||||
else:
|
||||
item_class = ItemClassification.filler
|
||||
|
Reference in New Issue
Block a user