Skip to content

Commit

Permalink
Fixes SkyTemple#27: Floor editing: GCM works with 0 entries now
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed Sep 18, 2020
1 parent 2f0c0ce commit d79a04b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions skytemple/module/dungeon/controller/floor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d79a04b

Please sign in to comment.