Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Represents the various outfits a {@link Player} object can wield during the
- * {@link Skilling} {@link Activity}, giving bonuses in the {@link Skill} they
- * are training
- *
- * @author Jh_Angel
- * @author Kaleem
- * @version 1.1
- *
- */
- public enum SkillingOutfit {
- CONSTRUCTION(21446, 21447, 21448, 21450, 21449),
- COOKING(25180, 25181, 25182, 25183, 25184),
- CRAFTING(25185, 25186, 25187, 215188, 21589),
- FIREMAKING(new int[] { 13660, 13659 }, 0.05, 0.02),
- FISHING(true, 24427, 24428, 24429, 24430),
- HERBLORE(25190, 25191, 25192, 25193, 25194),
- MINING(20789, 20791, 20790, 20788, 20787),
- RUNECRAFTING(true, 21517, 21516, 21518, 21519),
- SMITHING(25195, 25196, 25197, 25198, 25199),
- THIEVING(true, 21480, 21481, 21482, 21483),
- WOODCUTTING(true, 10941, 10939, 10940, 10933);
- /**
- * Constructs a {@link SkillingOutfit} object
- *
- * @param other
- * Flags whether or not the {@link SkillingOutfit} is different
- * to others, causing the {@link #componentBonus} to be lower
- * @param components
- * The {@link Item} components, done as a {@link Integer} array
- * to allow easier input
- */
- SkillingOutfit(boolean other, int... components) {
- this(components, 0.05, 0.01);
- }
- /**
- * Constructs a {@link SkillingOutfit} object, defaulting at
- * {@link #componentBonus 0.06}
- *
- * @param components
- * The {@link Item} components, done as a {@link Integer} array
- * to allow easier input
- */
- SkillingOutfit(int... components) {
- this(components, 0.06, 0.01);
- }
- /**
- * Constructs a {@link SkillingOutfit} object
- *
- * @param components
- * The {@link Item} components, done as a {@link Integer} array
- * to allow easier input
- * @param componentBonus
- * The {@link #componentBonus} of the {@link SkillingOutfit}
- * @param defaultBonus
- * The {@link #defaultBonus} of the {@link SkillingOutfit}
- */
- SkillingOutfit(int[] components, double componentBonus, double defaultBonus) {
- Preconditions.checkArgument(Skill.get(name()).isPresent(),
- "Name of enumeration must correspond to a Skill");
- /*
- * Preconditions.checkArgument(components.length == 5,
- * "Component must compose of 5 items");
- */
- skill = Skill.get(name()).get();
- for (int i = 0; i < components.length; i++) {
- this.components[i] = new Item(i);
- }
- this.componentBonus = componentBonus;
- this.defaultBonus = defaultBonus;
- }
- /**
- * Grabs the final modifier of a {@link Player} training a certain
- * {@link Skill}
- *
- * @param player
- * The {@link Player} object
- * @param skill
- * The {@link Skill} the {@link Player} is training
- * @return A {@link double} representing the modifier
- */
- public static double get(Player player, Skill skill) {
- double bonus = 1; // * Settings.MODIFIER;
- Optional<SkillingOutfit> outfit = get(skill.name());
- if (outfit.isPresent()) {
- Item[] components = outfit.get().components;
- if (player.equipment().containsAll(components)) {
- bonus = bonus * outfit.get().componentBonus;
- } else if (player.equipment().contains(components, 1)) {
- bonus = bonus * outfit.get().defaultBonus;
- }
- }
- return bonus;
- }
- /**
- * Gets a {@link Optional} based off input string
- *
- * @param string
- * The input string
- * @return {@link Optional} consisting of an {@link SkillingOutfit} object
- */
- public static Optional<SkillingOutfit> get(String string) {
- Predicate<SkillingOutfit> outfit = (SkillingOutfit s) -> s.name()
- .toLowerCase().equals(string);
- return Arrays.stream(values()).filter(outfit).findFirst();
- }
- /**
- * The {@link Item} components that form a set
- */
- private Item[] components = new Item[5];
- /**
- * The {@link Skill} required for the {@link #componentBonus} to take effect
- */
- private Skill skill;
- /**
- * The modifier given once the {@link Player} is wielding all the
- * {@link #components} in their {@link Player#equipment()}
- */
- private double componentBonus;
- /**
- * The modifier given if the {@link Player} is not wielding all the
- * {@link #components} in their {@link Player#equipment()}
- */
- private double defaultBonus;
- public Item[] getComponents() {
- return components;
- }
- public Skill getSkill() {
- return skill;
- }
- public double getComponentBonus() {
- return componentBonus;
- }
- public double getDefaultBonus() {
- return defaultBonus;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment