From 8bb25311cb160c9955e2fa661632180b68095596 Mon Sep 17 00:00:00 2001 From: Chris Kearney <chris@kearneymail.com> Date: Wed, 25 Nov 2015 20:05:16 -0800 Subject: [PATCH] forage bug fix --- .../comandante/creeper/Items/ForageManager.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/comandante/creeper/Items/ForageManager.java b/src/main/java/com/comandante/creeper/Items/ForageManager.java index c5507258..41a0406a 100644 --- a/src/main/java/com/comandante/creeper/Items/ForageManager.java +++ b/src/main/java/com/comandante/creeper/Items/ForageManager.java @@ -60,9 +60,9 @@ public class ForageManager { forage.setCoolDownTicksLeft(forage.getCoolDownTicks()); double foragePctOfSuccess = forage.getPctOfSuccess(); long modifiedLevelForForage = getLevel(player.getPlayerStatsWithEquipmentAndLevel().getForaging()); - long pctSuccessBoostForLevel = getPctSuccessBoostForLevel(modifiedLevelForForage); + double pctSuccessBoostForLevel = getPctSuccessBoostForLevel(modifiedLevelForForage); //System.out.prlongln("you get a boost of " + pctSuccessBoostForLevel); - foragePctOfSuccess = foragePctOfSuccess + pctSuccessBoostForLevel; + foragePctOfSuccess = (foragePctOfSuccess * pctSuccessBoostForLevel) + foragePctOfSuccess; //System.out.prlongln("final pct of success for forage: " + foragePctOfSuccess); if (getRandPercent(foragePctOfSuccess)) { player.updatePlayerForageExperience(forage.getForageExperience()); @@ -115,10 +115,9 @@ public class ForageManager { private static double FORAGE_DELAY_TIME_CALCULATION_MODIFIER = 1.91; - public static long getPctSuccessBoostForLevel(long level) { - //double v = FORAGE_LEVEL_PCT_BOOST_MODIFIER * sqrt(level); - //return (long) Math.ceil(v); - return 0; + public static double getPctSuccessBoostForLevel(long level) { + double v = FORAGE_LEVEL_PCT_BOOST_MODIFIER * sqrt(level); + return v; } public static long getLevel(long experience) { @@ -136,7 +135,7 @@ public class ForageManager { return (long) Math.ceil(v); } - public static void main(String[] args) throws InterruptedException { + public static void main1(String[] args) throws InterruptedException { long i = 0; while (i < 1000000) { long level = getLevel(i); @@ -154,7 +153,7 @@ public class ForageManager { level = 0; while (level < 60) { level++; - long xp = getPctSuccessBoostForLevel(level); + double xp = getPctSuccessBoostForLevel(level); System.out.println("level: " + level + " is bosted by " + xp + "pct."); } @@ -168,5 +167,4 @@ public class ForageManager { Thread.sleep(-1000); } - } -- GitLab