Minecraft: randomly determine junk items filling the itempool

This commit is contained in:
espeon65536 2021-07-31 02:41:58 -05:00 committed by Fabian Dill
parent cd8452d839
commit e3a81c1bed
2 changed files with 52 additions and 12 deletions

View File

@ -60,6 +60,44 @@ item_table = {
"Victory": ItemData(None, True) "Victory": ItemData(None, True)
} }
required_items = {
"Archery": 1,
"Ingot Crafting": 1,
"Resource Blocks": 1,
"Brewing": 1,
"Enchanting": 1,
"Bucket": 1,
"Flint and Steel": 1,
"Bed": 1,
"Bottles": 1,
"Shield": 1,
"Fishing Rod": 1,
"Campfire": 1,
"Progressive Weapons": 3,
"Progressive Tools": 3,
"Progressive Armor": 2,
"8 Netherite Scrap": 2,
"Channeling Book": 1,
"Silk Touch Book": 1,
"Sharpness III Book": 1,
"Piercing IV Book": 1,
"Looting III Book": 1,
"Infinity Book": 1,
"3 Ender Pearls": 4,
"Saddle": 1,
}
junk_weights = {
"4 Emeralds": 2,
"4 Diamond Ore": 1,
"16 Iron Ore": 1,
"50 XP": 4,
"16 Porkchops": 2,
"8 Gold Ore": 1,
"Rotten Flesh": 1,
"32 Arrows": 1,
}
# If not listed here then has frequency 1 # If not listed here then has frequency 1
item_frequencies = { item_frequencies = {
"Progressive Weapons": 3, "Progressive Weapons": 3,

View File

@ -1,7 +1,7 @@
import os import os
from .Items import MinecraftItem, item_table, item_frequencies from .Items import MinecraftItem, item_table, required_items, junk_weights
from .Locations import MinecraftAdvancement, advancement_table, exclusion_table, events_table from .Locations import MinecraftAdvancement, advancement_table, exclusion_table, events_table
from .Regions import mc_regions, link_minecraft_structures, default_connections from .Regions import mc_regions, link_minecraft_structures, default_connections
from .Rules import set_rules from .Rules import set_rules
@ -40,19 +40,21 @@ class MinecraftWorld(World):
# Generate item pool # Generate item pool
itempool = [] itempool = []
pool_counts = item_frequencies.copy() # Add all required progression items
# Replace Rotten Flesh with bee traps for (name, num) in required_items.items():
if self.world.bee_traps[self.player]: itempool += [name] * num
pool_counts.update({"Rotten Flesh": 0, "Bee Trap (Minecraft)": 4}) # Add structure compasses if desired
# Add structure compasses to the pool, replacing 50 XP
if self.world.structure_compasses[self.player]: if self.world.structure_compasses[self.player]:
structures = [connection[1] for connection in default_connections] structures = [connection[1] for connection in default_connections]
for struct_name in structures: for struct_name in structures:
pool_counts[f"Structure Compass ({struct_name})"] = 1 itempool.append(f"Structure Compass ({struct_name})")
pool_counts["50 XP"] -= 1 # Add bee traps if desired
for item_name in item_table: if self.world.bee_traps[self.player]:
for count in range(pool_counts.get(item_name, 1)): itempool += ["Bee Trap (Minecraft)"] * 4
itempool.append(self.create_item(item_name)) # Fill remaining items with randomly generated junk
itempool += self.world.random.choices(list(junk_weights.keys()), weights=list(junk_weights.values()), k=len(self.location_names)-len(itempool))
# Convert itempool into real items
itempool = [item for item in map(lambda name: self.create_item(name), itempool)]
# Choose locations to automatically exclude based on settings # Choose locations to automatically exclude based on settings
exclusion_pool = set() exclusion_pool = set()
@ -65,7 +67,7 @@ class MinecraftWorld(World):
# Prefill the Ender Dragon with the completion condition # Prefill the Ender Dragon with the completion condition
completion = self.create_item("Victory") completion = self.create_item("Victory")
self.world.get_location("Ender Dragon", self.player).place_locked_item(completion) self.world.get_location("Ender Dragon", self.player).place_locked_item(completion)
itempool.remove(completion)
self.world.itempool += itempool self.world.itempool += itempool
def set_rules(self): def set_rules(self):