Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Messenger: Use fill hook to help prevent early swap entering and failures #2467

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion worlds/messenger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from typing import Any, Dict, List, Optional

from BaseClasses import CollectionState, Item, ItemClassification, Tutorial
from BaseClasses import CollectionState, Item, ItemClassification, Location, MultiWorld, Tutorial
from worlds.AutoWorld import WebWorld, World
from .constants import ALL_ITEMS, ALWAYS_LOCATIONS, BOSS_LOCATIONS, FILLER, NOTES, PHOBEKINS
from .options import Goal, Logic, MessengerOptions, NotesNeeded, PowerSeals
Expand Down Expand Up @@ -147,6 +147,26 @@ def set_rules(self) -> None:
else:
MessengerOOBRules(self).set_messenger_rules()

@classmethod
def stage_fill_hook(cls, multiworld: MultiWorld, prog_items: List[Item], useful_items: List[Item],
filler_items: List[Item], locations: List[Location]) -> None:
# it's possible for both items to get placed near the end of the itempool causing swap to be entered early
# as more than half of the player's locations become unavailable immediately.
# Please don't copy this nightmare
players = multiworld.get_game_players(cls.game)
total_items = len(prog_items)
items = {}
for index in range(int((total_items * .9)), total_items):
item = prog_items[index]
if item.player in players and item.name in {"Wingsuit", "Rope Dart"}:
items.setdefault(item.player, []).append((index, item))
for player, item_pairs in items.items():
if len(item_pairs) > 1:
item_to_move = multiworld.random.choice(item_pairs)
new_index = multiworld.random.randrange(0, int((total_items * .1)))
prog_items.pop(item_to_move[0])
prog_items.insert(new_index, item_to_move[1])

def fill_slot_data(self) -> Dict[str, Any]:
shop_prices = {SHOP_ITEMS[item].internal_name: price for item, price in self.shop_prices.items()}
figure_prices = {FIGURINES[item].internal_name: price for item, price in self.figurine_prices.items()}
Expand Down
Loading