From d79a04b071a9beae357b75a832a3499db0fd1e61 Mon Sep 17 00:00:00 2001 From: Parakoopa Date: Thu, 17 Sep 2020 19:56:39 +0200 Subject: [PATCH] Fixes #27: Floor editing: GCM works with 0 entries now --- skytemple/module/dungeon/controller/floor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/skytemple/module/dungeon/controller/floor.py b/skytemple/module/dungeon/controller/floor.py index 69e55bf3d..8ce4f3797 100644 --- a/skytemple/module/dungeon/controller/floor.py +++ b/skytemple/module/dungeon/controller/floor.py @@ -984,8 +984,11 @@ def _calculate_relative_weights(self, list_of_weights: List[int]) -> List[int]: lower_bound = list_of_weights[j - 1] j -= 1 weights.append(higher_bound - lower_bound) - weights_lcm = reduce(gcd, (w for w in weights if w != 0)) - return [int(w / weights_lcm) for w in weights] + weights_nonzero = [w for w in weights if w != 0] + weights_gcd = 1 + if len(weights_nonzero) > 0: + weights_gcd = reduce(gcd, weights_nonzero) + return [int(w / weights_gcd) for w in weights] def _recalculate_spawn_chances(self, store_name, weight_idx, chance_idx): store: Gtk.ListStore = self.builder.get_object(store_name)