KH2: Init Cleanup and Keyblade Fix (#1713)
This commit is contained in:
parent
d85c13ef0e
commit
3d8bc0bb67
|
@ -33,6 +33,7 @@ class KH2World(World):
|
||||||
game: str = "Kingdom Hearts 2"
|
game: str = "Kingdom Hearts 2"
|
||||||
web = KingdomHearts2Web()
|
web = KingdomHearts2Web()
|
||||||
data_version = 1
|
data_version = 1
|
||||||
|
required_client_version = (0, 4, 0)
|
||||||
option_definitions = KH2_Options
|
option_definitions = KH2_Options
|
||||||
item_name_to_id = {name: data.code for name, data in item_dictionary_table.items()}
|
item_name_to_id = {name: data.code for name, data in item_dictionary_table.items()}
|
||||||
location_name_to_id = {item_name: data.code for item_name, data in all_locations.items() if data.code}
|
location_name_to_id = {item_name: data.code for item_name, data in all_locations.items() if data.code}
|
||||||
|
@ -40,6 +41,7 @@ class KH2World(World):
|
||||||
|
|
||||||
def __init__(self, multiworld: "MultiWorld", player: int):
|
def __init__(self, multiworld: "MultiWorld", player: int):
|
||||||
super().__init__(multiworld, player)
|
super().__init__(multiworld, player)
|
||||||
|
self.valid_abilities = None
|
||||||
self.visitlocking_dict = None
|
self.visitlocking_dict = None
|
||||||
self.plando_locations = None
|
self.plando_locations = None
|
||||||
self.luckyemblemamount = None
|
self.luckyemblemamount = None
|
||||||
|
@ -81,8 +83,6 @@ class KH2World(World):
|
||||||
return created_item
|
return created_item
|
||||||
|
|
||||||
def create_items(self) -> None:
|
def create_items(self) -> None:
|
||||||
itempool: typing.List[Item] = []
|
|
||||||
|
|
||||||
self.visitlocking_dict = Progression_Dicts["AllVisitLocking"].copy()
|
self.visitlocking_dict = Progression_Dicts["AllVisitLocking"].copy()
|
||||||
if self.multiworld.Schmovement[self.player] != "level_0":
|
if self.multiworld.Schmovement[self.player] != "level_0":
|
||||||
for _ in range(self.multiworld.Schmovement[self.player].value):
|
for _ in range(self.multiworld.Schmovement[self.player].value):
|
||||||
|
@ -128,9 +128,7 @@ class KH2World(World):
|
||||||
self.visitlocking_dict.pop(item)
|
self.visitlocking_dict.pop(item)
|
||||||
self.multiworld.push_precollected(self.create_item(item))
|
self.multiworld.push_precollected(self.create_item(item))
|
||||||
|
|
||||||
for item in item_dictionary_table:
|
itempool = [self.create_item(item) for item, data in self.item_quantity_dict.items() for _ in range(data)]
|
||||||
data = self.item_quantity_dict[item]
|
|
||||||
itempool += [self.create_item(item) for _ in range(data)]
|
|
||||||
|
|
||||||
# Creating filler for unfilled locations
|
# Creating filler for unfilled locations
|
||||||
itempool += [self.create_filler()
|
itempool += [self.create_filler()
|
||||||
|
@ -139,14 +137,12 @@ class KH2World(World):
|
||||||
|
|
||||||
def generate_early(self) -> None:
|
def generate_early(self) -> None:
|
||||||
# Item Quantity dict because Abilities can be a problem for KH2's Software.
|
# Item Quantity dict because Abilities can be a problem for KH2's Software.
|
||||||
for item, data in item_dictionary_table.items():
|
self.item_quantity_dict = {item: data.quantity for item, data in item_dictionary_table.items()}
|
||||||
self.item_quantity_dict[item] = data.quantity
|
|
||||||
# Dictionary to mark locations with their plandoed item
|
# Dictionary to mark locations with their plandoed item
|
||||||
# Example. Final Xemnas: Victory
|
# Example. Final Xemnas: Victory
|
||||||
self.plando_locations = dict()
|
self.plando_locations = dict()
|
||||||
self.hitlist = []
|
self.hitlist = []
|
||||||
self.starting_invo_verify()
|
self.starting_invo_verify()
|
||||||
|
|
||||||
# Option to turn off Promise Charm Item
|
# Option to turn off Promise Charm Item
|
||||||
if not self.multiworld.Promise_Charm[self.player]:
|
if not self.multiworld.Promise_Charm[self.player]:
|
||||||
self.item_quantity_dict[ItemName.PromiseCharm] = 0
|
self.item_quantity_dict[ItemName.PromiseCharm] = 0
|
||||||
|
@ -243,43 +239,64 @@ class KH2World(World):
|
||||||
|
|
||||||
def keyblade_fill(self):
|
def keyblade_fill(self):
|
||||||
if self.multiworld.KeybladeAbilities[self.player] == "support":
|
if self.multiworld.KeybladeAbilities[self.player] == "support":
|
||||||
self.sora_keyblade_ability_pool.extend(SupportAbility_Table.keys())
|
self.sora_keyblade_ability_pool = {
|
||||||
|
**{item: data for item, data in self.item_quantity_dict.items() if item in SupportAbility_Table},
|
||||||
|
**{ItemName.NegativeCombo: 1, ItemName.AirComboPlus: 1, ItemName.ComboPlus: 1,
|
||||||
|
ItemName.FinishingPlus: 1}}
|
||||||
|
|
||||||
elif self.multiworld.KeybladeAbilities[self.player] == "action":
|
elif self.multiworld.KeybladeAbilities[self.player] == "action":
|
||||||
self.sora_keyblade_ability_pool.extend(ActionAbility_Table.keys())
|
self.sora_keyblade_ability_pool = {item: data for item, data in self.item_quantity_dict.items() if item in ActionAbility_Table}
|
||||||
|
# there are too little action abilities so 2 random support abilities are placed
|
||||||
|
for _ in range(3):
|
||||||
|
randomSupportAbility = self.multiworld.per_slot_randoms[self.player].choice(list(SupportAbility_Table.keys()))
|
||||||
|
while randomSupportAbility in self.sora_keyblade_ability_pool:
|
||||||
|
randomSupportAbility = self.multiworld.per_slot_randoms[self.player].choice(
|
||||||
|
list(SupportAbility_Table.keys()))
|
||||||
|
self.sora_keyblade_ability_pool[randomSupportAbility] = 1
|
||||||
else:
|
else:
|
||||||
# both action and support on keyblades.
|
# both action and support on keyblades.
|
||||||
# TODO: make option to just exclude scom
|
# TODO: make option to just exclude scom
|
||||||
self.sora_keyblade_ability_pool.extend(ActionAbility_Table.keys())
|
self.sora_keyblade_ability_pool = {
|
||||||
self.sora_keyblade_ability_pool.extend(SupportAbility_Table.keys())
|
**{item: data for item, data in self.item_quantity_dict.items() if item in SupportAbility_Table},
|
||||||
|
**{item: data for item, data in self.item_quantity_dict.items() if item in ActionAbility_Table},
|
||||||
|
**{ItemName.NegativeCombo: 1, ItemName.AirComboPlus: 1, ItemName.ComboPlus: 1, ItemName.FinishingPlus: 1}}
|
||||||
|
|
||||||
for ability in self.multiworld.BlacklistKeyblade[self.player].value:
|
for ability in self.multiworld.BlacklistKeyblade[self.player].value:
|
||||||
if ability in self.sora_keyblade_ability_pool:
|
if ability in self.sora_keyblade_ability_pool:
|
||||||
self.sora_keyblade_ability_pool.remove(ability)
|
self.sora_keyblade_ability_pool.pop(ability)
|
||||||
|
|
||||||
while len(self.sora_keyblade_ability_pool) < len(self.keyblade_slot_copy):
|
# magic number for amount of keyblades
|
||||||
self.sora_keyblade_ability_pool.append(
|
if sum(self.sora_keyblade_ability_pool.values()) < 28:
|
||||||
self.multiworld.per_slot_randoms[self.player].choice(list(SupportAbility_Table.keys())))
|
raise Exception(f"{self.multiworld.get_file_safe_player_name(self.player)} has too little Keyblade Abilities in the Keyblade Pool")
|
||||||
|
|
||||||
|
self.valid_abilities = list(self.sora_keyblade_ability_pool.keys())
|
||||||
# Kingdom Key cannot have No Experience so plandoed here instead of checking 26 times if its kingdom key
|
# Kingdom Key cannot have No Experience so plandoed here instead of checking 26 times if its kingdom key
|
||||||
random_ability = self.multiworld.per_slot_randoms[self.player].choice(self.sora_keyblade_ability_pool)
|
random_ability = self.multiworld.per_slot_randoms[self.player].choice(self.valid_abilities)
|
||||||
while random_ability == ItemName.NoExperience:
|
while random_ability == ItemName.NoExperience:
|
||||||
random_ability = self.multiworld.per_slot_randoms[self.player].choice(self.sora_keyblade_ability_pool)
|
random_ability = self.multiworld.per_slot_randoms[self.player].choice(self.validAbilitys)
|
||||||
self.plando_locations[LocationName.KingdomKeySlot] = random_ability
|
self.plando_locations[LocationName.KingdomKeySlot] = random_ability
|
||||||
self.item_quantity_dict[random_ability] -= 1
|
self.item_quantity_dict[random_ability] -= 1
|
||||||
self.sora_keyblade_ability_pool.remove(random_ability)
|
self.sora_keyblade_ability_pool[random_ability] -= 1
|
||||||
|
if self.sora_keyblade_ability_pool[random_ability] == 0:
|
||||||
|
self.valid_abilities.remove(random_ability)
|
||||||
|
self.sora_keyblade_ability_pool.pop(random_ability)
|
||||||
|
|
||||||
# plando keyblades because they can only have abilities
|
# plando keyblades because they can only have abilities
|
||||||
for keyblade in self.keyblade_slot_copy:
|
for keyblade in self.keyblade_slot_copy:
|
||||||
random_ability = self.multiworld.per_slot_randoms[self.player].choice(self.sora_keyblade_ability_pool)
|
random_ability = self.multiworld.per_slot_randoms[self.player].choice(self.valid_abilities)
|
||||||
self.plando_locations[keyblade] = random_ability
|
self.plando_locations[keyblade] = random_ability
|
||||||
self.item_quantity_dict[random_ability] -= 1
|
self.item_quantity_dict[random_ability] -= 1
|
||||||
self.sora_keyblade_ability_pool.remove(random_ability)
|
self.sora_keyblade_ability_pool[random_ability] -= 1
|
||||||
|
if self.sora_keyblade_ability_pool[random_ability] == 0:
|
||||||
|
self.valid_abilities.remove(random_ability)
|
||||||
|
self.sora_keyblade_ability_pool.pop(random_ability)
|
||||||
self.totalLocations -= 1
|
self.totalLocations -= 1
|
||||||
|
|
||||||
def starting_invo_verify(self):
|
def starting_invo_verify(self):
|
||||||
for item, value in self.multiworld.start_inventory[self.player].value.items():
|
for item, value in self.multiworld.start_inventory[self.player].value.items():
|
||||||
if item in ActionAbility_Table \
|
if item in ActionAbility_Table \
|
||||||
or item in SupportAbility_Table or exclusionItem_table["StatUps"]:
|
or item in SupportAbility_Table or exclusionItem_table["StatUps"] \
|
||||||
|
or item in DonaldAbility_Table or item in GoofyAbility_Table:
|
||||||
# cannot have more than the quantity for abilties
|
# cannot have more than the quantity for abilties
|
||||||
if value > item_dictionary_table[item].quantity:
|
if value > item_dictionary_table[item].quantity:
|
||||||
logging.info(
|
logging.info(
|
||||||
|
|
Loading…
Reference in New Issue