From 32d0fa1446476fdd4bf3ac593f66c82727270866 Mon Sep 17 00:00:00 2001 From: Fenhl Date: Fri, 16 Feb 2024 15:59:08 +0000 Subject: [PATCH 1/2] Add a better error message for the incompatibility between Scarce/Minimal and high heart win conditions --- World.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/World.py b/World.py index cd7aaa009..4f67effac 100644 --- a/World.py +++ b/World.py @@ -2,6 +2,7 @@ import copy import json import logging +import math import os import random from collections import OrderedDict, defaultdict @@ -55,6 +56,24 @@ def __init__(self, world_id: int, settings: Settings, resolve_randomized_setting self.settings: Settings = settings self.distribution: WorldDistribution = settings.distribution.world_dists[world_id] + # errors for setting incompatibilities not yet caught by the GUI, see also https://github.com/OoTRandomizer/OoT-Randomizer/issues/1827 + required_hearts = 0 + if settings.lacs_condition == 'hearts': + required_hearts = max(required_hearts, settings.lacs_hearts) + if settings.bridge == 'hearts': + required_hearts = max(required_hearts, settings.bridge_hearts) + if settings.shuffle_ganon_bosskey == 'hearts': + required_hearts = max(required_hearts, settings.ganon_bosskey_hearts) + available_hearts = { + 'ludicrous': 20, + 'plentiful': 20, + 'balanced': 20, + 'scarce': settings.starting_hearts + 9 - math.ceil((settings.starting_hearts - 3) / 2), + 'minimal': settings.starting_hearts, + }[settings.item_pool_value] + if required_hearts < available_hearts: + raise ValueError("Not enough heart pieces/containers in item pool for win conditions. Decrease the number of required hearts or increase the item pool.") + # rename a few attributes... self.keysanity: bool = settings.shuffle_smallkeys in ('keysanity', 'remove', 'any_dungeon', 'overworld', 'regional') self.shuffle_silver_rupees = settings.shuffle_silver_rupees != 'vanilla' From 42f8906f85a6bd2494d8ffb0c9b7c1e4d4cd12f9 Mon Sep 17 00:00:00 2001 From: Fenhl Date: Fri, 16 Feb 2024 16:26:15 +0000 Subject: [PATCH 2/2] Fix inverted condition and improve error message --- World.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/World.py b/World.py index 4f67effac..ccb0fa43b 100644 --- a/World.py +++ b/World.py @@ -71,8 +71,8 @@ def __init__(self, world_id: int, settings: Settings, resolve_randomized_setting 'scarce': settings.starting_hearts + 9 - math.ceil((settings.starting_hearts - 3) / 2), 'minimal': settings.starting_hearts, }[settings.item_pool_value] - if required_hearts < available_hearts: - raise ValueError("Not enough heart pieces/containers in item pool for win conditions. Decrease the number of required hearts or increase the item pool.") + if required_hearts > available_hearts: + raise ValueError(f"Not enough heart pieces/containers in item pool for win conditions ({available_hearts} available but {required_hearts} required). Decrease the number of required hearts or increase the item pool.") # rename a few attributes... self.keysanity: bool = settings.shuffle_smallkeys in ('keysanity', 'remove', 'any_dungeon', 'overworld', 'regional')