From a78ff29af3e96e21b5d134ee2ba790facccb28fd Mon Sep 17 00:00:00 2001 From: zorvex09 <30737678+zorvex09@users.noreply.github.com> Date: Sat, 21 Oct 2017 13:53:54 -0500 Subject: [PATCH] Fixed crop quality_chance calculation Based on the Crop.cs source file, the crop quality is determined by first comparing a random double between 0.0 and 1.0 to see if it is less than the gold_chance. If it is not, it then compares a new random double between 0.0 and 1.0 to see if it is less than the silver_chance. Due to how the nested if statements are set up, you need to multiply the silver_chance number by the chance that the crop was not gold. Then the base chance is just 1-(gold_chance + silver_chance). --- scripts/planner.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/planner.js b/scripts/planner.js index 09950d6..e4d0f67 100644 --- a/scripts/planner.js +++ b/scripts/planner.js @@ -894,12 +894,12 @@ function planner_controller($scope){ mult = mult || 0; // Multiplier given by type of fertilizer used (0, 1, or 2) var gold_chance = 0.2 * (self.level / 10) + 0.2 * mult * ((self.level + 2) / 12) + 0.01; - var silver_chance = Math.min(0.75, gold_chance * 2); + var silver_chance = Math.min(0.75, gold_chance * 2) * (1 - gold_chance); var chance = 0; switch (quality){ case 0: - chance = Math.max(0, 1 - (gold_chance + silver_chance)); + chance = 1 - (gold_chance + silver_chance); break; case 1: chance = Math.min(1, silver_chance); @@ -1615,4 +1615,4 @@ function planner_controller($scope){ // Initialization runs last since Function.prototype methods // aren't hoisted init(); -} \ No newline at end of file +}