Skip to content

Commit

Permalink
The Messenger: actually implement get_filler_item_name (Archipelago…
Browse files Browse the repository at this point in the history
  • Loading branch information
alwaysintreble authored Aug 1, 2023
1 parent 1d6a2bf commit 6befc91
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions worlds/messenger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Dict, Any, Optional
from typing import Dict, Any, List, Optional

from BaseClasses import Tutorial, ItemClassification, CollectionState, Item, MultiWorld
from worlds.AutoWorld import World, WebWorld
Expand Down Expand Up @@ -71,6 +71,7 @@ class MessengerWorld(World):
total_shards: int
shop_prices: Dict[str, int]
figurine_prices: Dict[str, int]
_filler_items: List[str]

def __init__(self, multiworld: MultiWorld, player: int):
super().__init__(multiworld, player)
Expand Down Expand Up @@ -130,14 +131,13 @@ def create_items(self) -> None:
itempool += seals

remaining_fill = len(self.multiworld.get_unfilled_locations(self.player)) - len(itempool)
filler_pool = dict(list(FILLER.items())[2:]) if remaining_fill < 10 else FILLER
itempool += [self.create_item(filler_item)
for filler_item in
self.random.choices(
list(filler_pool),
weights=list(filler_pool.values()),
k=remaining_fill
)]
if remaining_fill < 10:
self._filler_items = self.random.choices(
list(FILLER)[2:],
weights=list(FILLER.values())[2:],
k=remaining_fill
)
itempool += [self.create_filler() for _ in range(remaining_fill)]

self.multiworld.itempool += itempool

Expand Down Expand Up @@ -167,7 +167,13 @@ def fill_slot_data(self) -> Dict[str, Any]:
}

def get_filler_item_name(self) -> str:
return "Time Shard"
if not getattr(self, "_filler_items", None):
self._filler_items = [name for name in self.random.choices(
list(FILLER),
weights=list(FILLER.values()),
k=20
)]
return self._filler_items.pop(0)

def create_item(self, name: str) -> MessengerItem:
item_id: Optional[int] = self.item_name_to_id.get(name, None)
Expand Down

0 comments on commit 6befc91

Please sign in to comment.