The Messenger: actually implement `get_filler_item_name` (#2070)

This commit is contained in:
Aaron Wagener 2023-08-01 12:43:10 -05:00 committed by GitHub
parent 1d6a2bff4f
commit 6befc91773
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 10 deletions

View File

@ -1,5 +1,5 @@
import logging import logging
from typing import Dict, Any, Optional from typing import Dict, Any, List, Optional
from BaseClasses import Tutorial, ItemClassification, CollectionState, Item, MultiWorld from BaseClasses import Tutorial, ItemClassification, CollectionState, Item, MultiWorld
from worlds.AutoWorld import World, WebWorld from worlds.AutoWorld import World, WebWorld
@ -71,6 +71,7 @@ class MessengerWorld(World):
total_shards: int total_shards: int
shop_prices: Dict[str, int] shop_prices: Dict[str, int]
figurine_prices: Dict[str, int] figurine_prices: Dict[str, int]
_filler_items: List[str]
def __init__(self, multiworld: MultiWorld, player: int): def __init__(self, multiworld: MultiWorld, player: int):
super().__init__(multiworld, player) super().__init__(multiworld, player)
@ -130,14 +131,13 @@ class MessengerWorld(World):
itempool += seals itempool += seals
remaining_fill = len(self.multiworld.get_unfilled_locations(self.player)) - len(itempool) 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 if remaining_fill < 10:
itempool += [self.create_item(filler_item) self._filler_items = self.random.choices(
for filler_item in list(FILLER)[2:],
self.random.choices( weights=list(FILLER.values())[2:],
list(filler_pool), k=remaining_fill
weights=list(filler_pool.values()), )
k=remaining_fill itempool += [self.create_filler() for _ in range(remaining_fill)]
)]
self.multiworld.itempool += itempool self.multiworld.itempool += itempool
@ -167,7 +167,13 @@ class MessengerWorld(World):
} }
def get_filler_item_name(self) -> str: 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: def create_item(self, name: str) -> MessengerItem:
item_id: Optional[int] = self.item_name_to_id.get(name, None) item_id: Optional[int] = self.item_name_to_id.get(name, None)