mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 12:11:33 -06:00
KH2: Raise Exception for Misusing DonaldGoofyStatsanity Option (#4710)
Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>
This commit is contained in:
@@ -515,23 +515,38 @@ class KH2Context(CommonContext):
|
|||||||
|
|
||||||
async def give_item(self, item, location):
|
async def give_item(self, item, location):
|
||||||
try:
|
try:
|
||||||
# todo: ripout all the itemtype stuff and just have one dictionary. the only thing that needs to be tracked from the server/local is abilites
|
# sleep so we can get the datapackage and not miss any items that were sent to us while we didnt have our item id dicts
|
||||||
#sleep so we can get the datapackage and not miss any items that were sent to us while we didnt have our item id dicts
|
|
||||||
while not self.lookup_id_to_item:
|
while not self.lookup_id_to_item:
|
||||||
await asyncio.sleep(0.5)
|
await asyncio.sleep(0.5)
|
||||||
itemname = self.lookup_id_to_item[item]
|
itemname = self.lookup_id_to_item[item]
|
||||||
itemdata = self.item_name_to_data[itemname]
|
itemdata = self.item_name_to_data[itemname]
|
||||||
# itemcode = self.kh2_item_name_to_id[itemname]
|
|
||||||
if itemdata.ability:
|
if itemdata.ability:
|
||||||
if location in self.all_weapon_location_id:
|
if location in self.all_weapon_location_id:
|
||||||
return
|
return
|
||||||
|
# growth have reserved ability slots because of how the goa handles them
|
||||||
if itemname in {"High Jump", "Quick Run", "Dodge Roll", "Aerial Dodge", "Glide"}:
|
if itemname in {"High Jump", "Quick Run", "Dodge Roll", "Aerial Dodge", "Glide"}:
|
||||||
self.kh2_seed_save_cache["AmountInvo"]["Growth"][itemname] += 1
|
self.kh2_seed_save_cache["AmountInvo"]["Growth"][itemname] += 1
|
||||||
return
|
return
|
||||||
|
|
||||||
if itemname not in self.kh2_seed_save_cache["AmountInvo"]["Ability"]:
|
if itemname not in self.kh2_seed_save_cache["AmountInvo"]["Ability"]:
|
||||||
self.kh2_seed_save_cache["AmountInvo"]["Ability"][itemname] = []
|
self.kh2_seed_save_cache["AmountInvo"]["Ability"][itemname] = []
|
||||||
# appending the slot that the ability should be in
|
# appending the slot that the ability should be in
|
||||||
|
# abilities have a limit amount of slots.
|
||||||
|
# we start from the back going down to not mess with stuff.
|
||||||
|
# Front of Invo
|
||||||
|
# Sora: Save+24F0+0x54 : 0x2546
|
||||||
|
# Donald: Save+2604+0x54 : 0x2658
|
||||||
|
# Goofy: Save+2718+0x54 : 0x276C
|
||||||
|
# Back of Invo. Sora has 6 ability slots that are reserved
|
||||||
|
# Sora: Save+24F0+0x54+0x92 : 0x25D8
|
||||||
|
# Donald: Save+2604+0x54+0x9C : 0x26F4
|
||||||
|
# Goofy: Save+2718+0x54+0x9C : 0x2808
|
||||||
|
# seed has 2 scans in sora's abilities
|
||||||
|
# recieved second scan
|
||||||
|
# if len(seed_save(Scan:[ability slot 52]) < (2)amount of that ability they should have from slot data
|
||||||
|
# ability_slot = back of inventory that isnt taken
|
||||||
|
# add ability_slot to seed_save(Scan[]) so now its Scan:[ability slot 52,50]
|
||||||
|
# decrease back of inventory since its ability_slot is already taken
|
||||||
if len(self.kh2_seed_save_cache["AmountInvo"]["Ability"][itemname]) < \
|
if len(self.kh2_seed_save_cache["AmountInvo"]["Ability"][itemname]) < \
|
||||||
self.AbilityQuantityDict[itemname]:
|
self.AbilityQuantityDict[itemname]:
|
||||||
if itemname in self.sora_ability_set:
|
if itemname in self.sora_ability_set:
|
||||||
@@ -550,18 +565,21 @@ class KH2Context(CommonContext):
|
|||||||
if ability_slot in self.front_ability_slots:
|
if ability_slot in self.front_ability_slots:
|
||||||
self.front_ability_slots.remove(ability_slot)
|
self.front_ability_slots.remove(ability_slot)
|
||||||
|
|
||||||
|
# if itemdata in {bitmask} all the forms,summons and a few other things are bitmasks
|
||||||
elif itemdata.memaddr in {0x36C4, 0x36C5, 0x36C6, 0x36C0, 0x36CA}:
|
elif itemdata.memaddr in {0x36C4, 0x36C5, 0x36C6, 0x36C0, 0x36CA}:
|
||||||
# if memaddr is in a bitmask location in memory
|
# if memaddr is in a bitmask location in memory
|
||||||
if itemname not in self.kh2_seed_save_cache["AmountInvo"]["Bitmask"]:
|
if itemname not in self.kh2_seed_save_cache["AmountInvo"]["Bitmask"]:
|
||||||
self.kh2_seed_save_cache["AmountInvo"]["Bitmask"].append(itemname)
|
self.kh2_seed_save_cache["AmountInvo"]["Bitmask"].append(itemname)
|
||||||
|
|
||||||
|
# if itemdata in {magic}
|
||||||
elif itemdata.memaddr in {0x3594, 0x3595, 0x3596, 0x3597, 0x35CF, 0x35D0}:
|
elif itemdata.memaddr in {0x3594, 0x3595, 0x3596, 0x3597, 0x35CF, 0x35D0}:
|
||||||
# if memaddr is in magic addresses
|
|
||||||
self.kh2_seed_save_cache["AmountInvo"]["Magic"][itemname] += 1
|
self.kh2_seed_save_cache["AmountInvo"]["Magic"][itemname] += 1
|
||||||
|
|
||||||
|
# equipment is a list instead of dict because you can only have 1 currently
|
||||||
elif itemname in self.all_equipment:
|
elif itemname in self.all_equipment:
|
||||||
self.kh2_seed_save_cache["AmountInvo"]["Equipment"].append(itemname)
|
self.kh2_seed_save_cache["AmountInvo"]["Equipment"].append(itemname)
|
||||||
|
|
||||||
|
# weapons are done differently since you can only have one and has to check it differently
|
||||||
elif itemname in self.all_weapons:
|
elif itemname in self.all_weapons:
|
||||||
if itemname in self.keyblade_set:
|
if itemname in self.keyblade_set:
|
||||||
self.kh2_seed_save_cache["AmountInvo"]["Weapon"]["Sora"].append(itemname)
|
self.kh2_seed_save_cache["AmountInvo"]["Weapon"]["Sora"].append(itemname)
|
||||||
@@ -570,9 +588,11 @@ class KH2Context(CommonContext):
|
|||||||
else:
|
else:
|
||||||
self.kh2_seed_save_cache["AmountInvo"]["Weapon"]["Goofy"].append(itemname)
|
self.kh2_seed_save_cache["AmountInvo"]["Weapon"]["Goofy"].append(itemname)
|
||||||
|
|
||||||
|
# TODO: this can just be removed and put into the else below it
|
||||||
elif itemname in self.stat_increase_set:
|
elif itemname in self.stat_increase_set:
|
||||||
self.kh2_seed_save_cache["AmountInvo"]["StatIncrease"][itemname] += 1
|
self.kh2_seed_save_cache["AmountInvo"]["StatIncrease"][itemname] += 1
|
||||||
else:
|
else:
|
||||||
|
# "normal" items. They have a unique byte reserved for how many they have
|
||||||
if itemname in self.kh2_seed_save_cache["AmountInvo"]["Amount"]:
|
if itemname in self.kh2_seed_save_cache["AmountInvo"]["Amount"]:
|
||||||
self.kh2_seed_save_cache["AmountInvo"]["Amount"][itemname] += 1
|
self.kh2_seed_save_cache["AmountInvo"]["Amount"][itemname] += 1
|
||||||
else:
|
else:
|
||||||
|
@@ -277,9 +277,7 @@ class KH2World(World):
|
|||||||
if self.options.FillerItemsLocal:
|
if self.options.FillerItemsLocal:
|
||||||
for item in filler_items:
|
for item in filler_items:
|
||||||
self.options.local_items.value.add(item)
|
self.options.local_items.value.add(item)
|
||||||
# By imitating remote this doesn't have to be plandoded filler anymore
|
|
||||||
# for location in {LocationName.JunkMedal, LocationName.JunkMedal}:
|
|
||||||
# self.plando_locations[location] = random_stt_item
|
|
||||||
if not self.options.SummonLevelLocationToggle:
|
if not self.options.SummonLevelLocationToggle:
|
||||||
self.total_locations -= 6
|
self.total_locations -= 6
|
||||||
|
|
||||||
@@ -400,6 +398,8 @@ class KH2World(World):
|
|||||||
# plando goofy get bonuses
|
# plando goofy get bonuses
|
||||||
goofy_get_bonus_location_pool = [self.multiworld.get_location(location, self.player) for location in
|
goofy_get_bonus_location_pool = [self.multiworld.get_location(location, self.player) for location in
|
||||||
Goofy_Checks.keys() if Goofy_Checks[location].yml != "Keyblade"]
|
Goofy_Checks.keys() if Goofy_Checks[location].yml != "Keyblade"]
|
||||||
|
if len(goofy_get_bonus_location_pool) > len(self.goofy_get_bonus_abilities):
|
||||||
|
raise Exception(f"Too little abilities to fill goofy get bonus locations for player {self.player_name}.")
|
||||||
for location in goofy_get_bonus_location_pool:
|
for location in goofy_get_bonus_location_pool:
|
||||||
self.random.choice(self.goofy_get_bonus_abilities)
|
self.random.choice(self.goofy_get_bonus_abilities)
|
||||||
random_ability = self.random.choice(self.goofy_get_bonus_abilities)
|
random_ability = self.random.choice(self.goofy_get_bonus_abilities)
|
||||||
@@ -416,11 +416,12 @@ class KH2World(World):
|
|||||||
random_ability = self.random.choice(self.donald_weapon_abilities)
|
random_ability = self.random.choice(self.donald_weapon_abilities)
|
||||||
location.place_locked_item(random_ability)
|
location.place_locked_item(random_ability)
|
||||||
self.donald_weapon_abilities.remove(random_ability)
|
self.donald_weapon_abilities.remove(random_ability)
|
||||||
|
# if option is turned off
|
||||||
if not self.options.DonaldGoofyStatsanity:
|
if not self.options.DonaldGoofyStatsanity:
|
||||||
# plando goofy get bonuses
|
|
||||||
donald_get_bonus_location_pool = [self.multiworld.get_location(location, self.player) for location in
|
donald_get_bonus_location_pool = [self.multiworld.get_location(location, self.player) for location in
|
||||||
Donald_Checks.keys() if Donald_Checks[location].yml != "Keyblade"]
|
Donald_Checks.keys() if Donald_Checks[location].yml != "Keyblade"]
|
||||||
|
if len(donald_get_bonus_location_pool) > len(self.donald_get_bonus_abilities):
|
||||||
|
raise Exception(f"Too little abilities to fill donald get bonus locations for player {self.player_name}.")
|
||||||
for location in donald_get_bonus_location_pool:
|
for location in donald_get_bonus_location_pool:
|
||||||
random_ability = self.random.choice(self.donald_get_bonus_abilities)
|
random_ability = self.random.choice(self.donald_get_bonus_abilities)
|
||||||
location.place_locked_item(random_ability)
|
location.place_locked_item(random_ability)
|
||||||
|
Reference in New Issue
Block a user