Update Minecraft to use exclusion_rules for its exclusion pools
This commit is contained in:
parent
7493b7f35e
commit
9e5e43fcd5
|
@ -114,27 +114,27 @@ advancement_table = {
|
||||||
|
|
||||||
exclusion_table = {
|
exclusion_table = {
|
||||||
"hard": {
|
"hard": {
|
||||||
"Very Very Frightening": "50 XP",
|
"Very Very Frightening",
|
||||||
"Two by Two": "100 XP",
|
"Two by Two",
|
||||||
"Two Birds, One Arrow": "50 XP",
|
"Two Birds, One Arrow",
|
||||||
"Arbalistic": "100 XP",
|
"Arbalistic",
|
||||||
"Monsters Hunted": "100 XP",
|
"Monsters Hunted",
|
||||||
"Beaconator": "50 XP",
|
"Beaconator",
|
||||||
"A Balanced Diet": "100 XP",
|
"A Balanced Diet",
|
||||||
"Uneasy Alliance": "100 XP",
|
"Uneasy Alliance",
|
||||||
"Cover Me in Debris": "100 XP",
|
"Cover Me in Debris",
|
||||||
"A Complete Catalogue": "50 XP",
|
"A Complete Catalogue",
|
||||||
"Overpowered": "50 XP"
|
"Overpowered",
|
||||||
},
|
},
|
||||||
"insane": {
|
"insane": {
|
||||||
"How Did We Get Here?": "500 XP",
|
"How Did We Get Here?",
|
||||||
"Adventuring Time": "500 XP"
|
"Adventuring Time",
|
||||||
},
|
},
|
||||||
"postgame": {
|
"postgame": {
|
||||||
"The Next Generation": "50 XP",
|
"The Next Generation",
|
||||||
"The End... Again...": "50 XP",
|
"The End... Again...",
|
||||||
"You Need a Mint": "50 XP",
|
"You Need a Mint",
|
||||||
"Monsters Hunted": "100 XP"
|
"Monsters Hunted",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,13 @@ from BaseClasses import MultiWorld
|
||||||
|
|
||||||
def set_rules(world: MultiWorld, player: int):
|
def set_rules(world: MultiWorld, player: int):
|
||||||
def reachable_locations(state):
|
def reachable_locations(state):
|
||||||
postgame_advancements = set(exclusion_table['postgame'].keys())
|
postgame_advancements = exclusion_table['postgame'].copy()
|
||||||
postgame_advancements.add('Free the End')
|
postgame_advancements.add('Free the End')
|
||||||
for event in events_table.keys():
|
for event in events_table.keys():
|
||||||
postgame_advancements.add(event)
|
postgame_advancements.add(event)
|
||||||
return [location for location in world.get_locations() if
|
return [location for location in world.get_locations() if
|
||||||
(player is None or location.player == player) and
|
location.player == player and
|
||||||
(location.name not in postgame_advancements) and
|
location.name not in postgame_advancements and
|
||||||
location.can_reach(state)]
|
location.can_reach(state)]
|
||||||
|
|
||||||
# 92 total advancements. Goal is to complete X advancements and then Free the End.
|
# 92 total advancements. Goal is to complete X advancements and then Free the End.
|
||||||
|
|
|
@ -5,6 +5,7 @@ from .Items import MinecraftItem, item_table, item_frequencies
|
||||||
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
|
from .Regions import mc_regions, link_minecraft_structures
|
||||||
from .Rules import set_rules
|
from .Rules import set_rules
|
||||||
|
from worlds.generic.Rules import exclusion_rules
|
||||||
|
|
||||||
from BaseClasses import Region, Entrance, Item
|
from BaseClasses import Region, Entrance, Item
|
||||||
from .Options import minecraft_options
|
from .Options import minecraft_options
|
||||||
|
@ -22,6 +23,7 @@ class MinecraftWorld(World):
|
||||||
item_name_to_id = {name: data.code for name, data in item_table.items()}
|
item_name_to_id = {name: data.code for name, data in item_table.items()}
|
||||||
location_name_to_id = {name: data.id for name, data in advancement_table.items()}
|
location_name_to_id = {name: data.id for name, data in advancement_table.items()}
|
||||||
|
|
||||||
|
|
||||||
def _get_mc_data(self):
|
def _get_mc_data(self):
|
||||||
exits = ["Overworld Structure 1", "Overworld Structure 2", "Nether Structure 1", "Nether Structure 2",
|
exits = ["Overworld Structure 1", "Overworld Structure 2", "Nether Structure 1", "Nether Structure 2",
|
||||||
"The End Structure"]
|
"The End Structure"]
|
||||||
|
@ -35,35 +37,39 @@ class MinecraftWorld(World):
|
||||||
'structures': {exit: self.world.get_entrance(exit, self.player).connected_region.name for exit in exits}
|
'structures': {exit: self.world.get_entrance(exit, self.player).connected_region.name for exit in exits}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def generate_basic(self):
|
def generate_basic(self):
|
||||||
link_minecraft_structures(self.world, self.player)
|
link_minecraft_structures(self.world, self.player)
|
||||||
|
|
||||||
pool = []
|
# Generate item pool
|
||||||
|
itempool = []
|
||||||
pool_counts = item_frequencies.copy()
|
pool_counts = item_frequencies.copy()
|
||||||
if getattr(self.world, "bee_traps")[self.player]:
|
if getattr(self.world, "bee_traps")[self.player]: # replace Rotten Flesh by bee traps
|
||||||
pool_counts.update({"Rotten Flesh": 0, "Bee Trap (Minecraft)": 4})
|
pool_counts.update({"Rotten Flesh": 0, "Bee Trap (Minecraft)": 4})
|
||||||
for item_name in item_table:
|
for item_name in item_table:
|
||||||
for count in range(pool_counts.get(item_name, 1)):
|
for count in range(pool_counts.get(item_name, 1)):
|
||||||
pool.append(self.create_item(item_name))
|
itempool.append(self.create_item(item_name))
|
||||||
|
|
||||||
prefill_pool = {}
|
# Choose locations to automatically exclude based on settings
|
||||||
prefill_pool.update(events_table)
|
exclusion_pool = set()
|
||||||
exclusion_pools = ['hard', 'insane', 'postgame']
|
exclusion_types = ['hard', 'insane', 'postgame']
|
||||||
for key in exclusion_pools:
|
for key in exclusion_types:
|
||||||
if not getattr(self.world, f"include_{key}_advancements")[self.player]:
|
if not getattr(self.world, f"include_{key}_advancements")[self.player]:
|
||||||
prefill_pool.update(exclusion_table[key])
|
exclusion_pool.update(exclusion_table[key])
|
||||||
|
exclusion_rules(self.world, self.player, exclusion_pool)
|
||||||
|
|
||||||
for loc_name, item_name in prefill_pool.items():
|
# Prefill the Ender Dragon with the completion condition
|
||||||
location = self.world.get_location(loc_name, self.player)
|
completion = self.create_item("Victory")
|
||||||
item = self.create_item(item_name)
|
self.world.get_location("Ender Dragon", self.player).place_locked_item(completion)
|
||||||
location.place_locked_item(item)
|
itempool.remove(completion)
|
||||||
pool.remove(item)
|
|
||||||
|
self.world.itempool += itempool
|
||||||
|
|
||||||
self.world.itempool += pool
|
|
||||||
|
|
||||||
def set_rules(self):
|
def set_rules(self):
|
||||||
set_rules(self.world, self.player)
|
set_rules(self.world, self.player)
|
||||||
|
|
||||||
|
|
||||||
def create_regions(self):
|
def create_regions(self):
|
||||||
def MCRegion(region_name: str, exits=[]):
|
def MCRegion(region_name: str, exits=[]):
|
||||||
ret = Region(region_name, None, region_name, self.player)
|
ret = Region(region_name, None, region_name, self.player)
|
||||||
|
@ -77,6 +83,7 @@ class MinecraftWorld(World):
|
||||||
|
|
||||||
self.world.regions += [MCRegion(*r) for r in mc_regions]
|
self.world.regions += [MCRegion(*r) for r in mc_regions]
|
||||||
|
|
||||||
|
|
||||||
def generate_output(self):
|
def generate_output(self):
|
||||||
import json
|
import json
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
|
@ -87,6 +94,7 @@ class MinecraftWorld(World):
|
||||||
with open(output_path(filename), 'wb') as f:
|
with open(output_path(filename), 'wb') as f:
|
||||||
f.write(b64encode(bytes(json.dumps(data), 'utf-8')))
|
f.write(b64encode(bytes(json.dumps(data), 'utf-8')))
|
||||||
|
|
||||||
|
|
||||||
def fill_slot_data(self):
|
def fill_slot_data(self):
|
||||||
slot_data = self._get_mc_data()
|
slot_data = self._get_mc_data()
|
||||||
for option_name in minecraft_options:
|
for option_name in minecraft_options:
|
||||||
|
@ -94,6 +102,7 @@ class MinecraftWorld(World):
|
||||||
slot_data[option_name] = int(option.value)
|
slot_data[option_name] = int(option.value)
|
||||||
return slot_data
|
return slot_data
|
||||||
|
|
||||||
|
|
||||||
def create_item(self, name: str) -> Item:
|
def create_item(self, name: str) -> Item:
|
||||||
item_data = item_table[name]
|
item_data = item_table[name]
|
||||||
return MinecraftItem(name, item_data.progression, item_data.code, self.player)
|
return MinecraftItem(name, item_data.progression, item_data.code, self.player)
|
Loading…
Reference in New Issue