diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index a20781c0b4..12aee0a545 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -101,6 +101,8 @@ public interface Client extends GameEngine int[] getWidgetPositionsX(); int[] getWidgetPositionsY(); + + int getEnergy(); String[] getPlayerOptions(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Builders.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Builders.java new file mode 100644 index 0000000000..1c32a57692 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Builders.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import net.runelite.client.plugins.itemstats.delta.DeltaCalculator; +import net.runelite.client.plugins.itemstats.delta.DeltaPercentage; +import net.runelite.client.plugins.itemstats.stats.Stat; + +public class Builders +{ + public static Food food(int diff) + { + return food((max) -> diff); + } + + public static Food food(DeltaCalculator p) + { + return new Food(p); + } + + public static Effect combo(int primaries, SingleEffect... effect) + { + return new Combo(primaries, effect); + } + + public static Effect combo(SingleEffect... effect) + { + return new Combo(effect); + } + + public static SimpleStatBoost boost(Stat stat, int boost) + { + return boost(stat, (max) -> boost); + } + + public static SimpleStatBoost boost(Stat stat, DeltaCalculator p) + { + return new SimpleStatBoost(stat, true, p); + } + + public static SimpleStatBoost heal(Stat stat, int boost) + { + return heal(stat, (max) -> boost); + } + + public static SimpleStatBoost heal(Stat stat, DeltaCalculator p) + { + return new SimpleStatBoost(stat, false, p); + } + + public static SimpleStatBoost dec(Stat stat, int boost) + { + return heal(stat, -boost); + } + + public static DeltaPercentage perc(double perc, int delta) + { + return new DeltaPercentage(perc, delta); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Combo.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Combo.java new file mode 100644 index 0000000000..9749f1a17b --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Combo.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import net.runelite.api.Client; + +public class Combo implements Effect +{ + private final SingleEffect[] calcs; + private final int numPrimaries; + + public Combo(SingleEffect[] calcs) + { + this(1, calcs); + } + + public Combo(int numPrimaries, SingleEffect[] calcs) + { + this.numPrimaries = numPrimaries; + this.calcs = calcs; + } + + @Override + public StatsChanges calculate(Client client) + { + StatsChanges out = new StatsChanges(calcs.length); + StatChange[] statChanges = out.getStatChanges(); + for (int i = 0; i < calcs.length; i++) + { + statChanges[i] = calcs[i].effect(client); + } + Positivity positivity = Positivity.NO_CHANGE; + for (int i = 0; i < numPrimaries; i++) + { + if (positivity.ordinal() < statChanges[i].getPositivity().ordinal()) + { + positivity = statChanges[i].getPositivity(); + } + } + out.setPositivity(positivity); + return out; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Effect.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Effect.java new file mode 100644 index 0000000000..d937405ed9 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Effect.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import net.runelite.api.Client; + +public interface Effect +{ + StatsChanges calculate(Client client); +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Food.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Food.java new file mode 100644 index 0000000000..ff3f3fb702 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Food.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import net.runelite.client.plugins.itemstats.delta.DeltaCalculator; +import net.runelite.api.Client; + +public class Food extends FoodBase +{ + private final DeltaCalculator p; + + public Food(DeltaCalculator p) + { + this.p = p; + } + + @Override + public int heals(Client client) + { + return p.calculateDelta(getStat().getMaximum(client)); + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/FoodBase.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/FoodBase.java new file mode 100644 index 0000000000..83409af0ce --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/FoodBase.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import net.runelite.client.plugins.itemstats.stats.Stats; + +public abstract class FoodBase extends StatBoost +{ + public FoodBase() + { + super(Stats.HITPOINTS, false); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatChanges.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatChanges.java new file mode 100644 index 0000000000..794a36276e --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatChanges.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import com.google.inject.Singleton; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import lombok.extern.slf4j.Slf4j; +import static net.runelite.api.ItemID.*; +import net.runelite.client.plugins.itemstats.potions.SuperRestore; +import static net.runelite.client.plugins.itemstats.Builders.*; +import static net.runelite.client.plugins.itemstats.stats.Stats.*; +import net.runelite.client.plugins.itemstats.food.Anglerfish; +import net.runelite.client.plugins.itemstats.potions.PrayerPotion; + +@Singleton +@Slf4j +public class ItemStatChanges +{ + + public ItemStatChanges() + { + init(); + } + + final void init() + { + add(food(-5), POISON_KARAMBWAN); + add(food(1), POTATO, ONION, CABBAGE, POT_OF_CREAM, CHOPPED_ONION); + add(food(2), TOMATO, BANANA, ORANGE, PINEAPPLE_CHUNKS, PINEAPPLE_RING, SPICY_SAUCE, CHEESE); + add(food(3), SHRIMPS, COOKED_MEAT, COOKED_CHICKEN, ROE, CAVIAR, CHOCOLATE_BAR); + add(food(4), SARDINE, CAKE, _23_CAKE, SLICE_OF_CAKE); + add(food(5), BREAD, HERRING, CHOCOLATE_CAKE, _23_CHOCOLATE_CAKE, CHOCOLATE_SLICE, COOKED_RABBIT, CHILLI_CON_CARNE, + FRIED_MUSHROOMS, FRIED_ONIONS, REDBERRY_PIE, HALF_A_REDBERRY_PIE); + add(food(6), CHOCICE, MACKEREL, MEAT_PIE, HALF_A_MEAT_PIE); + add(food(7), TROUT, COD, PLAIN_PIZZA, _12_PLAIN_PIZZA, APPLE_PIE, HALF_AN_APPLE_PIE, ROAST_RABBIT, BAKED_POTATO, + PREMADE_CH_CRUNCH, CHOCCHIP_CRUNCHIES, PREMADE_SY_CRUNCH, SPICY_CRUNCHIES); + add(food(8), PIKE, ROAST_BEAST_MEAT, MEAT_PIZZA, _12_MEAT_PIZZA, PREMADE_WM_CRUN, WORM_CRUNCHIES, PREMADE_TD_CRUNCH, + TOAD_CRUNCHIES, EGG_AND_TOMATO); + add(food(9), PREMADE_P_PUNCH, PINEAPPLE_PUNCH, PREMADE_FR_BLAST, FRUIT_BLAST, SALMON, ANCHOVY_PIZZA, + _12_ANCHOVY_PIZZA); + add(food(10), TUNA, COOKED_SWEETCORN, CRAB_MEAT, CHOPPED_TUNA, COOKED_CHOMPY); + add(food(11), JUG_OF_WINE, RAINBOW_FISH, STEW, PINEAPPLE_PIZZA, _12_PINEAPPLE_PIZZA, COOKED_FISHCAKE, + PREMADE_VEG_BATTA, VEGETABLE_BATTA, PREMADE_WM_BATTA, WORM_BATTA, PREMADE_TD_BATTA, TOAD_BATTA, PREMADE_CT_BATTA, + CHEESETOM_BATTA, MUSHROOM__ONION); + add(food(12), LOBSTER, PREMADE_WORM_HOLE, WORM_HOLE, PREMADE_VEG_BALL, VEG_BALL); + add(food(13), BASS, TUNA_AND_CORN); + add(food(14), POTATO_WITH_BUTTER, CHILLI_POTATO, SWORDFISH); + add(food(15), PREMADE_TTL, TANGLED_TOADS_LEGS, PREMADE_CHOC_BOMB, CHOCOLATE_BOMB); + add(food(16), MONKFISH, POTATO_WITH_CHEESE, EGG_POTATO); + add(food(18), COOKED_KARAMBWAN); + add(food(19), CURRY, UGTHANKI_KEBAB); + add(food(20), MUSHROOM_POTATO, SHARK); + add(food(21), SEA_TURTLE); + add(food(22), MANTA_RAY, DARK_CRAB, TUNA_POTATO); + add(new Anglerfish(), ANGLERFISH); + add(food(maxHP -> (int) Math.ceil(maxHP * .06)), STRAWBERRY); + add(food(maxHP -> (int) Math.ceil(maxHP * .05)), WATERMELON_SLICE); + add(food(perc(.1, 0)), COOKED_SLIMY_EEL); + add(food(perc(.1, 1)), SWEETCORN, SWEETCORN_7088); + add(combo(food(1), boost(DEFENCE, perc(.02, 1))), CABBAGE_1967); + add(combo(2, food(4), heal(RUN_ENERGY, 5)), PAPAYA_FRUIT); + + // Alcoholic Gnome Cocktails + add(combo(2, food(5), boost(STRENGTH, 6), heal(ATTACK, -4)), PREMADE_WIZ_BLZD, WIZARD_BLIZZARD); + add(combo(2, food(5), boost(STRENGTH, 4), heal(ATTACK, -3)), PREMADE_SGG, SHORT_GREEN_GUY); + add(combo(2, food(5), boost(STRENGTH, 7), heal(ATTACK, -4)), PREMADE_DR_DRAGON, DRUNK_DRAGON); + add(combo(2, food(5), boost(STRENGTH, 7), heal(ATTACK, -4)), PREMADE_CHOC_SDY, CHOC_SATURDAY); + + // Sq'irk Juice + add(heal(RUN_ENERGY, 5), WINTER_SQIRKJUICE); + add(combo(heal(RUN_ENERGY, 10), boost(THIEVING, 1)), SPRING_SQIRKJUICE); + add(combo(heal(RUN_ENERGY, 15), boost(THIEVING, 2)), AUTUMN_SQIRKJUICE); + add(combo(heal(RUN_ENERGY, 20), boost(THIEVING, 3)), SUMMER_SQIRKJUICE); + + // Combat potions + add(boost(ATTACK, perc(.10, 3)), ATTACK_POTION1, ATTACK_POTION2, ATTACK_POTION3, ATTACK_POTION4); + add(boost(STRENGTH, perc(.10, 3)), STRENGTH_POTION1, STRENGTH_POTION2, STRENGTH_POTION3, STRENGTH_POTION4); + add(boost(DEFENCE, perc(.10, 3)), DEFENCE_POTION1, DEFENCE_POTION2, DEFENCE_POTION3, DEFENCE_POTION4); + add(boost(MAGIC, 4), MAGIC_POTION1, MAGIC_POTION2, MAGIC_POTION3, MAGIC_POTION4); + add(boost(RANGED, perc(.10, 3)), RANGING_POTION1, RANGING_POTION2, RANGING_POTION3, RANGING_POTION4); + add(combo(2, boost(ATTACK, perc(.10, 3)), boost(STRENGTH, perc(.10, 3))), COMBAT_POTION1, COMBAT_POTION2, COMBAT_POTION3, COMBAT_POTION4); + add(boost(ATTACK, perc(.15, 5)), SUPER_ATTACK1, SUPER_ATTACK2, SUPER_ATTACK3, SUPER_ATTACK4); + add(boost(STRENGTH, perc(.15, 5)), SUPER_STRENGTH1, SUPER_STRENGTH2, SUPER_STRENGTH3, SUPER_STRENGTH4); + add(boost(DEFENCE, perc(.15, 5)), SUPER_DEFENCE1, SUPER_DEFENCE2, SUPER_DEFENCE3, SUPER_DEFENCE4); + add(boost(MAGIC, 3), MAGIC_ESSENCE1, MAGIC_ESSENCE2, MAGIC_ESSENCE3, MAGIC_ESSENCE4); + add(combo(3, boost(ATTACK, perc(.15, 5)), boost(STRENGTH, perc(.15, 5)), boost(DEFENCE, perc(.15, 5))), SUPER_COMBAT_POTION1, SUPER_COMBAT_POTION2, SUPER_COMBAT_POTION3, SUPER_COMBAT_POTION4); + add(combo(3, boost(ATTACK, perc(.20, 2)), boost(STRENGTH, perc(.12, 2)), heal(PRAYER, perc(.10, 0)), heal(DEFENCE, perc(.10, -2)), heal(HITPOINTS, perc(.12, 0))), ZAMORAK_BREW1, ZAMORAK_BREW2, ZAMORAK_BREW3, ZAMORAK_BREW4); + add(combo(2, boost(HITPOINTS, perc(.15, 2)), boost(DEFENCE, perc(.20, 2)), heal(ATTACK, perc(.10, -2)), heal(RANGED, perc(.10, -2)), heal(MAGIC, perc(.10, -2))), SARADOMIN_BREW1, SARADOMIN_BREW2, SARADOMIN_BREW3, SARADOMIN_BREW4); + add(boost(RANGED, perc(.15, 5)), SUPER_RANGING_1, SUPER_RANGING_2, SUPER_RANGING_3, SUPER_RANGING_4); + add(boost(MAGIC, perc(.15, 5)), SUPER_MAGIC_POTION_1, SUPER_MAGIC_POTION_2, SUPER_MAGIC_POTION_3, SUPER_MAGIC_POTION_4); + add(combo(5, boost(ATTACK, perc(.15, 5)), boost(STRENGTH, perc(.15, 5)), boost(DEFENCE, perc(.15, 5)), boost(RANGED, perc(.15, 5)), boost(MAGIC, perc(.15, 5)), heal(HITPOINTS, -50)), OVERLOAD_1, OVERLOAD_2, OVERLOAD_3, OVERLOAD_4); + + // Recovery potions + add(combo(5, heal(ATTACK, perc(.30, 10)), heal(STRENGTH, perc(.30, 10)), heal(DEFENCE, perc(.30, 10)), heal(RANGED, perc(.30, 10)), heal(MAGIC, perc(.30, 10))), RESTORE_POTION1, RESTORE_POTION2, RESTORE_POTION3, RESTORE_POTION4); + add(heal(RUN_ENERGY, 10), ENERGY_POTION1, ENERGY_POTION2, ENERGY_POTION3, ENERGY_POTION4); + add(new PrayerPotion(7), PRAYER_POTION1, PRAYER_POTION2, PRAYER_POTION3, PRAYER_POTION4); + add(heal(RUN_ENERGY, 20), SUPER_ENERGY1, SUPER_ENERGY2, SUPER_ENERGY3, SUPER_ENERGY4); + add(new SuperRestore(8), SUPER_RESTORE1, SUPER_RESTORE2, SUPER_RESTORE3, SUPER_RESTORE4); + add(new SuperRestore(9), SANFEW_SERUM1, SANFEW_SERUM2, SANFEW_SERUM3, SANFEW_SERUM4); + add(heal(RUN_ENERGY, 20), STAMINA_POTION1, STAMINA_POTION2, STAMINA_POTION3, STAMINA_POTION4); + + // Skill potions + add(boost(AGILITY, 3), AGILITY_POTION1, AGILITY_POTION2, AGILITY_POTION3, AGILITY_POTION4); + add(boost(FISHING, 3), FISHING_POTION1, FISHING_POTION2, FISHING_POTION3, FISHING_POTION4); + add(boost(HUNTER, 3), HUNTER_POTION1, HUNTER_POTION2, HUNTER_POTION3, HUNTER_POTION4); + add(combo(2, boost(HITPOINTS, 5), heal(RUN_ENERGY, 5)), GUTHIX_REST1, GUTHIX_REST2, GUTHIX_REST3, GUTHIX_REST4); + + // Misc run energy + add(heal(RUN_ENERGY, 10), WHITE_TREE_FRUIT); + add(heal(RUN_ENERGY, 30), STRANGE_FRUIT, BANDAGES); + add(heal(RUN_ENERGY, 50), MINT_CAKE, GOUT_TUBER); + + // Pies + add(combo(2, heal(HITPOINTS, 6), boost(FARMING, 3)), GARDEN_PIE, HALF_A_GARDEN_PIE); + add(combo(2, heal(HITPOINTS, 6), boost(FISHING, 3)), FISH_PIE, HALF_A_FISH_PIE); + add(combo(2, heal(HITPOINTS, 7), boost(HERBLORE, 4)), BOTANICAL_PIE, HALF_A_BOTANICAL_PIE); + add(combo(2, heal(HITPOINTS, 8), boost(CRAFTING, 4)), MUSHROOM_PIE, HALF_A_MUSHROOM_PIE); + add(combo(2, heal(HITPOINTS, 8), boost(FISHING, 5)), ADMIRAL_PIE, HALF_AN_ADMIRAL_PIE); + add(combo(2, heal(HITPOINTS, 11), boost(SLAYER, 5), boost(RANGED, 4)), WILD_PIE, HALF_A_WILD_PIE); + add(combo(2, heal(HITPOINTS, 11), boost(AGILITY, 5), heal(RUN_ENERGY, 10)), SUMMER_PIE, HALF_A_SUMMER_PIE); + + // Other + add(boost(MAGIC, perc(.10, 1)), IMBUED_HEART); + + log.debug("{} items; {} behaviours loaded", effects.size(), new HashSet(effects.values()).size()); + } + + private final Map effects = new HashMap<>(); + + private void add(Effect effect, int... items) + { + assert items.length > 0; + for (int item : items) + { + Effect prev = effects.put(item, effect); + assert prev == null : "Item already added"; + } + } + + public Effect get(int id) + { + return effects.get(id); + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatConfig.java new file mode 100644 index 0000000000..cf2e11c056 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatConfig.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2018 Abex + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import java.awt.Color; +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup( + keyName = "itemstat", + name = "Item Stats", + description = "Show stat changes on items" +) +public interface ItemStatConfig extends Config +{ + @ConfigItem( + keyName = "tooltipMode", + name = "Tooltip mode", + description = "How to show tooltip values" + ) + default TooltipMode tooltipMode() + { + return TooltipMode.BOTH; + } + + @ConfigItem( + keyName = "colorBetterUncapped", + name = "Better (Uncapped)", + description = "Color to show when the stat change is fully consumed", + position = 10 + ) + default Color colorBetterUncapped() + { + return new Color(0x33EE33); + } + + @ConfigItem( + keyName = "colorBetterSomecapped", + name = "Better (Some capped)", + description = "Color to show when some stat changes are capped, but some ar not", + position = 11 + ) + default Color colorBetterSomeCapped() + { + return new Color(0x9CEE33); + } + + + @ConfigItem( + keyName = "colorBetterCapped", + name = "Better (Capped)", + description = "Color to show when the stat change is positive, but not fully consumed", + position = 12 + ) + default Color colorBetterCapped() + { + return new Color(0xEEEE33); + } + @ConfigItem( + keyName = "colorNoChange", + name = "No change", + description = "Color to show when there is no change", + position = 13 + ) + default Color colorNoChange() + { + return new Color(0xEEEEEE); + } + + @ConfigItem( + keyName = "colorWorse", + name = "Worse", + description = "Color to show when the stat goes down", + position = 14 + ) + default Color colorWorse() + { + return new Color(0xEE3333); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatOverlay.java new file mode 100644 index 0000000000..7863d3a9fb --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatOverlay.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2018 Abex + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import com.google.inject.Inject; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.Point; +import net.runelite.api.Client; +import net.runelite.api.queries.InventoryWidgetItemQuery; +import net.runelite.api.widgets.WidgetItem; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.tooltip.Tooltip; +import net.runelite.client.ui.overlay.tooltip.TooltipManager; +import net.runelite.client.util.QueryRunner; + +public class ItemStatOverlay extends Overlay +{ + @Inject + private QueryRunner queryRunner; + + @Inject + private Client client; + + @Inject + private TooltipManager tooltipManager; + + @Inject + private ItemStatChanges statChanges; + + @Inject + private ItemStatConfig config; + + @Override + public Dimension render(Graphics2D graphics, Point parent) + { + TooltipMode tooltipMode = config.tooltipMode(); + if (tooltipMode == TooltipMode.OFF) + { + return null; + } + WidgetItem[] inventory = queryRunner.runQuery(new InventoryWidgetItemQuery()); + Point mousePos = new Point(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY()); + for (WidgetItem item : inventory) + { + if (item.getCanvasBounds().contains(mousePos)) + { + Effect change = statChanges.get(item.getId()); + if (change != null) + { + StringBuilder b = new StringBuilder(); + StatsChanges statsChanges = change.calculate(client); + for (StatChange c : statsChanges.getStatChanges()) + { + b.append(""); + if (tooltipMode.isRelative()) + { + b.append(c.getRelative()); + } + if (tooltipMode == TooltipMode.BOTH) + { + b.append(" ("); + } + if (tooltipMode.isAbsolute()) + { + b.append(c.getAbsolute()); + } + if (tooltipMode == TooltipMode.BOTH) + { + b.append(")"); + } + b.append(" ").append(c.getStat().getName()); + b.append("
"); + } + tooltipManager.add(new Tooltip(b.toString())); + } + } + } + return null; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatPlugin.java new file mode 100644 index 0000000000..0ceab99e3b --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatPlugin.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018 Abex + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import com.google.inject.Binder; +import com.google.inject.Inject; +import com.google.inject.Provides; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.itemstats.stats.Stats; +import net.runelite.client.ui.overlay.Overlay; + +@PluginDescriptor( + name = "Item stat plugin" +) +public class ItemStatPlugin extends Plugin +{ + @Inject + private ItemStatOverlay overlay; + + @Override + public void configure(Binder binder) + { + binder.bind(Stats.class); + binder.bind(ItemStatChanges.class); + binder.bind(ItemStatOverlay.class); + } + + @Provides + ItemStatConfig getConfig(ConfigManager configManager) + { + return configManager.getConfig(ItemStatConfig.class); + } + + @Override + public Overlay getOverlay() + { + return overlay; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Positivity.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Positivity.java new file mode 100644 index 0000000000..d1da3c8176 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Positivity.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2018 Abex + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import java.awt.Color; + +/** + * Positivity represents how positive or negative a stat change is. This is + * turned into the color shown to the user in the toolip. + */ +public enum Positivity +{ + /** + * The stat is lower than it was before. + */ + WORSE, + /** + * There is no change, ie: The stat is already capped. + */ + NO_CHANGE, + /** + * The stat change goes over the cap, but does not net 0 + */ + BETTER_CAPPED, + /** + * Some stat changes were fully consumed, some were not. This should NOT + * be returned by a single stat change. This should only be used by a + * StatChangeCalculator + */ + BETTER_SOMECAPPED, + /** + * The stat change is fully consumed. NB: a boost that hits the cap, but + * does not go over it is still considered BETTER_UNCAPPED + */ + BETTER_UNCAPPED; + + public static Color getColor(ItemStatConfig config, Positivity positivity) + { + switch (positivity) + { + case BETTER_UNCAPPED: + return config.colorBetterUncapped(); + case BETTER_SOMECAPPED: + return config.colorBetterSomeCapped(); + case BETTER_CAPPED: + return config.colorBetterCapped(); + case NO_CHANGE: + return config.colorNoChange(); + case WORSE: + return config.colorWorse(); + default: + return Color.WHITE; + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/SimpleStatBoost.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/SimpleStatBoost.java new file mode 100644 index 0000000000..3aa6d02442 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/SimpleStatBoost.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import net.runelite.client.plugins.itemstats.delta.DeltaCalculator; +import net.runelite.client.plugins.itemstats.stats.Stat; +import net.runelite.api.Client; + +public class SimpleStatBoost extends StatBoost +{ + private final DeltaCalculator deltaCalculator; + + public SimpleStatBoost(Stat stat, boolean boost, DeltaCalculator deltaCalculator) + { + super(stat, boost); + this.deltaCalculator = deltaCalculator; + } + + @Override + public int heals(Client client) + { + int max = getStat().getMaximum(client); + return deltaCalculator.calculateDelta(max); + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/SingleEffect.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/SingleEffect.java new file mode 100644 index 0000000000..31059ac1b9 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/SingleEffect.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import net.runelite.api.Client; + +public abstract class SingleEffect implements Effect +{ + @Override + public final StatsChanges calculate(Client client) + { + StatsChanges c = new StatsChanges(1); + StatChange[] statChanges = c.getStatChanges(); + statChanges[0] = effect(client); + c.setPositivity(statChanges[0].getPositivity()); + return c; + } + + public abstract StatChange effect(Client client); +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/StatBoost.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/StatBoost.java new file mode 100644 index 0000000000..5badc47830 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/StatBoost.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import lombok.Getter; +import lombok.Setter; +import net.runelite.client.plugins.itemstats.stats.Stat; +import net.runelite.api.Client; + +public abstract class StatBoost extends SingleEffect +{ + @Getter + @Setter + private Stat stat; + @Getter + @Setter + private boolean boost; + + public StatBoost(Stat stat, boolean boost) + { + this.stat = stat; + this.boost = boost; + } + + public abstract int heals(Client client); + + @Override + public StatChange effect(Client client) + { + int value = stat.getValue(client); + int max = stat.getMaximum(client); + + boolean hitCap = false; + + int calcedDelta = heals(client); + if (boost && calcedDelta > 0) + { + max += calcedDelta; + } + if (value > max) + { + max = value; + } + int newValue = value + calcedDelta; + if (newValue > max) + { + newValue = max; + hitCap = true; + } + if (newValue < 0) + { + newValue = 0; + } + int delta = newValue - value; + StatChange out = new StatChange(); + out.setStat(stat); + if (delta > 0) + { + out.setPositivity(hitCap ? Positivity.BETTER_CAPPED : Positivity.BETTER_UNCAPPED); + } + else if (delta == 0) + { + out.setPositivity(Positivity.NO_CHANGE); + } + else + { + out.setPositivity(Positivity.WORSE); + } + out.setAbsolute(Integer.toString(newValue)); + out.setRelative(String.format("%+d", delta)); + return out; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/StatChange.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/StatChange.java new file mode 100644 index 0000000000..ab46421c16 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/StatChange.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import lombok.Data; +import net.runelite.client.plugins.itemstats.stats.Stat; + +/** + * A single stat change + */ +@Data +public class StatChange +{ + private Stat stat; + private String relative; + private String absolute; + private Positivity positivity; +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/StatsChanges.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/StatsChanges.java new file mode 100644 index 0000000000..55ebb7206e --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/StatsChanges.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import lombok.Getter; +import lombok.Setter; + +public class StatsChanges +{ + /** + * How positive the entire set of stat changes is + * + * @see Positivity + */ + @Getter + @Setter + private Positivity positivity; + @Getter + @Setter + private StatChange[] statChanges; + + public StatsChanges(int len) + { + this.statChanges = new StatChange[len]; + this.positivity = Positivity.NO_CHANGE; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/TooltipMode.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/TooltipMode.java new file mode 100644 index 0000000000..b7303e655f --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/TooltipMode.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018 Abex + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import lombok.AllArgsConstructor; + +@AllArgsConstructor +public enum TooltipMode +{ + OFF("Off", 0x0), + RELATIVE("Relative", 0x1), + ABSOLUTE("Absolute", 0x2), + BOTH("Both", 0x3); + + private final String display; + private final int value; + + public boolean isRelative() + { + return (value & 0x01) != 0; + } + + public boolean isAbsolute() + { + return (value & 0x02) != 0; + } + + @Override + public String toString() + { + return display; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/delta/DeltaCalculator.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/delta/DeltaCalculator.java new file mode 100644 index 0000000000..0174af327e --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/delta/DeltaCalculator.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats.delta; + +@FunctionalInterface +public interface DeltaCalculator +{ + int calculateDelta(int max); +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/delta/DeltaPercentage.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/delta/DeltaPercentage.java new file mode 100644 index 0000000000..f1f9df4573 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/delta/DeltaPercentage.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats.delta; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +public class DeltaPercentage implements DeltaCalculator +{ + private final double perc; + private final int delta; + + @Override + public int calculateDelta(int max) + { + return (((int) (max * perc)) * (delta >= 0 ? 1 : -1)) + delta; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/food/Anglerfish.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/food/Anglerfish.java new file mode 100644 index 0000000000..01e44eff8a --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/food/Anglerfish.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats.food; + +import net.runelite.api.Client; +import net.runelite.client.plugins.itemstats.FoodBase; + +public class Anglerfish extends FoodBase +{ + public Anglerfish() + { + setBoost(true); + } + + @Override + public int heals(Client client) + { + int maxHP = getStat().getMaximum(client); + + int C; + if (maxHP <= 24) + { + C = 2; + } + else if (maxHP <= 49) + { + C = 4; + } + else if (maxHP <= 74) + { + C = 6; + } + else if (maxHP <= 92) + { + C = 8; + } + else + { + C = 13; + } + return (maxHP / 10) + C; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/potions/PrayerPotion.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/potions/PrayerPotion.java new file mode 100644 index 0000000000..a8637bc121 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/potions/PrayerPotion.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats.potions; + +import net.runelite.api.Client; +import net.runelite.client.plugins.itemstats.StatBoost; +import static net.runelite.client.plugins.itemstats.stats.Stats.PRAYER; + +public class PrayerPotion extends StatBoost +{ + private final int delta; + + public PrayerPotion(int delta) + { + super(PRAYER, false); + this.delta = delta; + } + + @Override + public int heals(Client client) + { + int max = getStat().getMaximum(client); + double perc = .25; + return (((int) (max * perc)) * (delta >= 0 ? 1 : -1)) + delta; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/potions/SuperRestore.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/potions/SuperRestore.java new file mode 100644 index 0000000000..ebada829c5 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/potions/SuperRestore.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats.potions; + +import java.util.Comparator; +import java.util.stream.Stream; +import lombok.RequiredArgsConstructor; +import net.runelite.api.Client; +import static net.runelite.client.plugins.itemstats.Builders.perc; +import net.runelite.client.plugins.itemstats.Effect; +import net.runelite.client.plugins.itemstats.SimpleStatBoost; +import net.runelite.client.plugins.itemstats.stats.Stat; +import net.runelite.client.plugins.itemstats.StatChange; +import static net.runelite.client.plugins.itemstats.stats.Stats.*; +import net.runelite.client.plugins.itemstats.StatsChanges; + +@RequiredArgsConstructor +public class SuperRestore implements Effect +{ + private static final Stat[] superRestoreStats = new Stat[] + { + ATTACK, DEFENCE, STRENGTH, RANGED, MAGIC, COOKING, + WOODCUTTING, FLETCHING, FISHING, FIREMAKING, CRAFTING, SMITHING, MINING, + HERBLORE, AGILITY, THIEVING, SLAYER, FARMING, RUNECRAFT, HUNTER, + CONSTRUCTION + }; + + private final int delta; + + @Override + public StatsChanges calculate(Client client) + { + StatsChanges changes = new StatsChanges(0); + + SimpleStatBoost calc = new SimpleStatBoost(null, false, perc(.25, delta)); + PrayerPotion prayer = new PrayerPotion(delta); + changes.setStatChanges(Stream.concat( + Stream.of(prayer.effect(client)), + Stream.of(superRestoreStats) + .filter(stat -> stat.getValue(client) < stat.getMaximum(client)) + .map(stat -> + { + calc.setStat(stat); + return calc.calculate(client); + }) + ) + .toArray(StatChange[]::new)); + changes.setPositivity(Stream.of(changes.getStatChanges()).map(sc -> sc.getPositivity()).max(Comparator.comparing(Enum::ordinal)).get()); + return changes; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/stats/EnergyStat.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/stats/EnergyStat.java new file mode 100644 index 0000000000..43f0d8f91d --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/stats/EnergyStat.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats.stats; + +import net.runelite.api.Client; + +public class EnergyStat extends Stat +{ + public EnergyStat(String name) + { + super(name); + } + + @Override + public int getValue(Client client) + { + return client.getEnergy(); + } + + @Override + public int getMaximum(Client client) + { + return 100; + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/stats/SkillStat.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/stats/SkillStat.java new file mode 100644 index 0000000000..a833a6b29b --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/stats/SkillStat.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats.stats; + +import net.runelite.api.Client; +import net.runelite.api.Skill; + +public class SkillStat extends Stat +{ + private final Skill skill; + + public SkillStat(Skill skill) + { + super(skill.getName()); + this.skill = skill; + } + + @Override + public int getValue(Client client) + { + return client.getBoostedSkillLevel(this.skill); + } + + @Override + public int getMaximum(Client client) + { + return client.getRealSkillLevel(this.skill); + } + +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/stats/Stat.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/stats/Stat.java new file mode 100644 index 0000000000..7fb3547d5e --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/stats/Stat.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018 Abex + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats.stats; + +import net.runelite.api.Client; +import net.runelite.api.Skill; + +/** + * Abstract stat of a player. + * This includes {@link Skill}s and other player variables, such as RUN_ENERGY. + * @see Stats + */ +public abstract class Stat +{ + private final String name; + + Stat(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + + public abstract int getValue(Client client); + + public abstract int getMaximum(Client client); +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/stats/Stats.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/stats/Stats.java new file mode 100644 index 0000000000..fb10ec2119 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/stats/Stats.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats.stats; + +import net.runelite.api.Client; +import net.runelite.api.Skill; + +public class Stats +{ + public static final Stat ATTACK, DEFENCE, STRENGTH, HITPOINTS, RANGED, PRAYER, MAGIC, COOKING, WOODCUTTING, FLETCHING; + public static final Stat FISHING, FIREMAKING, CRAFTING, SMITHING, MINING, HERBLORE, AGILITY, THIEVING, SLAYER, FARMING; + public static final Stat RUNECRAFT, HUNTER, CONSTRUCTION, RUN_ENERGY; + + static + { + ATTACK = new SkillStat(Skill.ATTACK); + DEFENCE = new SkillStat(Skill.DEFENCE); + STRENGTH = new SkillStat(Skill.STRENGTH); + HITPOINTS = new SkillStat(Skill.HITPOINTS); + RANGED = new SkillStat(Skill.RANGED); + PRAYER = new SkillStat(Skill.PRAYER); + MAGIC = new SkillStat(Skill.MAGIC); + COOKING = new SkillStat(Skill.COOKING); + WOODCUTTING = new SkillStat(Skill.WOODCUTTING); + FLETCHING = new SkillStat(Skill.FLETCHING); + FISHING = new SkillStat(Skill.FISHING); + FIREMAKING = new SkillStat(Skill.FIREMAKING); + CRAFTING = new SkillStat(Skill.CRAFTING); + SMITHING = new SkillStat(Skill.SMITHING); + MINING = new SkillStat(Skill.MINING); + HERBLORE = new SkillStat(Skill.HERBLORE); + AGILITY = new SkillStat(Skill.AGILITY); + THIEVING = new SkillStat(Skill.THIEVING); + SLAYER = new SkillStat(Skill.SLAYER); + FARMING = new SkillStat(Skill.FARMING); + RUNECRAFT = new SkillStat(Skill.RUNECRAFT); + HUNTER = new SkillStat(Skill.HUNTER); + CONSTRUCTION = new SkillStat(Skill.CONSTRUCTION); + RUN_ENERGY = new Stat("Run Energy") + { + @Override + public int getValue(Client client) + { + return client.getEnergy(); + } + + @Override + public int getMaximum(Client client) + { + return 100; + } + }; + } +} diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/itemstats/ItemStatChangesTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/itemstats/ItemStatChangesTest.java new file mode 100644 index 0000000000..2b4b6239e6 --- /dev/null +++ b/runelite-client/src/test/java/net/runelite/client/plugins/itemstats/ItemStatChangesTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016-2018, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.itemstats; + +import org.junit.Test; + +public class ItemStatChangesTest +{ + @Test + public void testInit() + { + new ItemStatChanges(); + } + +} diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java index ef27c10987..06f89c20b7 100644 --- a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java @@ -84,6 +84,7 @@ public interface RSClient extends RSGameEngine, Client int[] getWidgetSettings(); @Import("energy") + @Override int getEnergy(); @Import("weight")