mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Minecraft rewrite (#1493)
* Minecraft: rewrite to modern AP standards * Fix gitignore to not try to ignore the entire minecraft world * minecraft: clean up MC-specific tests * minecraft: use pkgutil instead of open * minecraft: ship as apworld * mc: update region to new api * Increase upper limit on advancement and egg shard goals * mc: reduce egg shard count by 5 for structure compasses * Minecraft: add more tests Ensures data loading works; tests beatability with various options at their max setting; new tests for 1.19 advancements * test improvements * mc: typing and imports cleanup * parens * mc: condense filler item code and override get_filler_item_name
This commit is contained in:
52
worlds/minecraft/ItemPool.py
Normal file
52
worlds/minecraft/ItemPool.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from math import ceil
|
||||
from typing import List
|
||||
|
||||
from BaseClasses import MultiWorld, Item
|
||||
from worlds.AutoWorld import World
|
||||
|
||||
from . import Constants
|
||||
|
||||
def get_junk_item_names(rand, k: int) -> str:
|
||||
junk_weights = Constants.item_info["junk_weights"]
|
||||
junk = rand.choices(
|
||||
list(junk_weights.keys()),
|
||||
weights=list(junk_weights.values()),
|
||||
k=k)
|
||||
return junk
|
||||
|
||||
def build_item_pool(mc_world: World) -> List[Item]:
|
||||
multiworld = mc_world.multiworld
|
||||
player = mc_world.player
|
||||
|
||||
itempool = []
|
||||
total_location_count = len(multiworld.get_unfilled_locations(player))
|
||||
|
||||
required_pool = Constants.item_info["required_pool"]
|
||||
junk_weights = Constants.item_info["junk_weights"]
|
||||
|
||||
# Add required progression items
|
||||
for item_name, num in required_pool.items():
|
||||
itempool += [mc_world.create_item(item_name) for _ in range(num)]
|
||||
|
||||
# Add structure compasses
|
||||
if multiworld.structure_compasses[player]:
|
||||
compasses = [name for name in mc_world.item_name_to_id if "Structure Compass" in name]
|
||||
for item_name in compasses:
|
||||
itempool.append(mc_world.create_item(item_name))
|
||||
|
||||
# Dragon egg shards
|
||||
if multiworld.egg_shards_required[player] > 0:
|
||||
num = multiworld.egg_shards_available[player]
|
||||
itempool += [mc_world.create_item("Dragon Egg Shard") for _ in range(num)]
|
||||
|
||||
# Bee traps
|
||||
bee_trap_percentage = multiworld.bee_traps[player] * 0.01
|
||||
if bee_trap_percentage > 0:
|
||||
bee_trap_qty = ceil(bee_trap_percentage * (total_location_count - len(itempool)))
|
||||
itempool += [mc_world.create_item("Bee Trap") for _ in range(bee_trap_qty)]
|
||||
|
||||
# Fill remaining itempool with randomly generated junk
|
||||
junk = get_junk_item_names(multiworld.random, total_location_count - len(itempool))
|
||||
itempool += [mc_world.create_item(name) for name in junk]
|
||||
|
||||
return itempool
|
Reference in New Issue
Block a user