Add ability to set combat requirements for achievement diaries (#6270)

- Add ability to add combat requirements to diaries
- Add all the current combat requirements

Preview:
When you meet the combat requirement.
![when you have requirement](https://puu.sh/BTHtl/35755b3003.png)
When you don't meet the combat requirement.
![when you don't have requirement](https://puu.sh/BTHtM/ce5c50ef33.png)
This commit is contained in:
William
2018-11-09 23:48:39 +10:30
committed by Tomas Slusny
parent db164db581
commit 75136c86b0
8 changed files with 35 additions and 2 deletions

View File

@@ -36,6 +36,7 @@ import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.ScriptID; import net.runelite.api.ScriptID;
import net.runelite.api.Skill;
import net.runelite.api.events.WidgetLoaded; import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetID; import net.runelite.api.widgets.WidgetID;
@@ -242,7 +243,16 @@ public class DiaryRequirementsPlugin extends Plugin
{ {
RequirementStringBuilder requirementStringBuilder = new RequirementStringBuilder(i); RequirementStringBuilder requirementStringBuilder = new RequirementStringBuilder(i);
int realSkillLevel = client.getRealSkillLevel(i.getSkill()); Skill skill = i.getSkill();
int realSkillLevel;
if (skill == null && i.getCustomRequirement().equals("Combat"))
{
realSkillLevel = client.getLocalPlayer().getCombatLevel();
}
else
{
realSkillLevel = client.getRealSkillLevel(skill);
}
List<Integer> altRealSkillLevels = null; List<Integer> altRealSkillLevels = null;
if (i.getAltRequirements() != null) if (i.getAltRequirements() != null)
{ {

View File

@@ -30,12 +30,22 @@ import net.runelite.api.Skill;
public class Requirement public class Requirement
{ {
private final Skill skill; private final Skill skill;
private final String customRequirement;
private final int levelRequirement; private final int levelRequirement;
private final Requirement[] altRequirements; private final Requirement[] altRequirements;
public Requirement(Skill skill, int levelRequirement, Requirement... altRequirements) public Requirement(Skill skill, int levelRequirement, Requirement... altRequirements)
{ {
this.skill = skill; this.skill = skill;
this.customRequirement = null;
this.levelRequirement = levelRequirement;
this.altRequirements = altRequirements;
}
public Requirement(String customRequirement, int levelRequirement, Requirement... altRequirements)
{
this.skill = null;
this.customRequirement = customRequirement;
this.levelRequirement = levelRequirement; this.levelRequirement = levelRequirement;
this.altRequirements = altRequirements; this.altRequirements = altRequirements;
} }

View File

@@ -48,7 +48,7 @@ class RequirementStringBuilder
StringBuilder requirementStringBuilder = new StringBuilder() StringBuilder requirementStringBuilder = new StringBuilder()
.append(levelRequirement) .append(levelRequirement)
.append(" ") .append(" ")
.append(skill.getName()); .append(skill != null ? skill.getName() : requirement.getCustomRequirement());
for (Requirement i : altRequirements) for (Requirement i : altRequirements)
{ {
requirementStringBuilder.append(" or ") requirementStringBuilder.append(" or ")

View File

@@ -86,6 +86,7 @@ public class KaramjaDiaryRequirement extends GenericDiaryRequirement
add("Collect 5 palm leaves.", add("Collect 5 palm leaves.",
new Requirement(Skill.WOODCUTTING, 15)); new Requirement(Skill.WOODCUTTING, 15));
add("Be assigned a Slayer task by Duradel north of Shilo Village.", add("Be assigned a Slayer task by Duradel north of Shilo Village.",
new Requirement("Combat", 100),
new Requirement(Skill.SLAYER, 50)); new Requirement(Skill.SLAYER, 50));
add("Kill a metal dragon in Brimhaven Dungeon.", add("Kill a metal dragon in Brimhaven Dungeon.",
new Requirement(Skill.AGILITY, 12), new Requirement(Skill.AGILITY, 12),

View File

@@ -63,6 +63,8 @@ public class LumbridgeDiaryRequirement extends GenericDiaryRequirement
new Requirement(Skill.FISHING, 30)); new Requirement(Skill.FISHING, 30));
add("Craft a coif in the Lumbridge cow pen.", add("Craft a coif in the Lumbridge cow pen.",
new Requirement(Skill.CRAFTING, 38)); new Requirement(Skill.CRAFTING, 38));
add("Get a slayer task from Chaeldar.",
new Requirement("Combat", 70));
add("Chop some willow logs in Draynor Village.", add("Chop some willow logs in Draynor Village.",
new Requirement(Skill.WOODCUTTING, 30)); new Requirement(Skill.WOODCUTTING, 30));
add("Pickpocket Martin the Master Gardener.", add("Pickpocket Martin the Master Gardener.",

View File

@@ -38,6 +38,8 @@ public class MorytaniaDiaryRequirement extends GenericDiaryRequirement
new Requirement(Skill.CRAFTING, 15)); new Requirement(Skill.CRAFTING, 15));
add("Cook a thin Snail on the Port Phasmatys range.", add("Cook a thin Snail on the Port Phasmatys range.",
new Requirement(Skill.COOKING, 12)); new Requirement(Skill.COOKING, 12));
add("Get a slayer task from Mazchna.",
new Requirement("Combat", 20));
add("Kill a Banshee in the Slayer Tower.", add("Kill a Banshee in the Slayer Tower.",
new Requirement(Skill.SLAYER, 15)); new Requirement(Skill.SLAYER, 15));
add("Place a Scarecrow in the Morytania flower patch.", add("Place a Scarecrow in the Morytania flower patch.",

View File

@@ -50,6 +50,8 @@ public class VarrockDiaryRequirement extends GenericDiaryRequirement
// MEDIUM // MEDIUM
add("Cast the teleport to Varrock spell.", add("Cast the teleport to Varrock spell.",
new Requirement(Skill.MAGIC, 25)); new Requirement(Skill.MAGIC, 25));
add("Get a Slayer task from Vannaka.",
new Requirement("Combat", 40));
add("Pick a White tree fruit.", add("Pick a White tree fruit.",
new Requirement(Skill.FARMING, 25)); new Requirement(Skill.FARMING, 25));
add("Use the balloon to travel from Varrock.", add("Use the balloon to travel from Varrock.",

View File

@@ -36,6 +36,8 @@ public class WesternDiaryRequirement extends GenericDiaryRequirement
// EASY // EASY
add("Catch a Copper Longtail.", add("Catch a Copper Longtail.",
new Requirement(Skill.HUNTER, 9)); new Requirement(Skill.HUNTER, 9));
add("Complete a novice game of Pest Control.",
new Requirement("Combat", 40));
add("Mine some Iron Ore near Piscatoris.", add("Mine some Iron Ore near Piscatoris.",
new Requirement(Skill.MINING, 15)); new Requirement(Skill.MINING, 15));
add("Fletch an Oak shortbow from the Gnome Stronghold.", add("Fletch an Oak shortbow from the Gnome Stronghold.",
@@ -51,6 +53,8 @@ public class WesternDiaryRequirement extends GenericDiaryRequirement
add("Chop and burn some teak logs on Ape Atoll.", add("Chop and burn some teak logs on Ape Atoll.",
new Requirement(Skill.WOODCUTTING, 35), new Requirement(Skill.WOODCUTTING, 35),
new Requirement(Skill.FIREMAKING, 35)); new Requirement(Skill.FIREMAKING, 35));
add("Complete an intermediate game of Pest Control.",
new Requirement("Combat", 70));
add("Make a Chocolate Bomb at the Grand Tree.", add("Make a Chocolate Bomb at the Grand Tree.",
new Requirement(Skill.COOKING, 42)); new Requirement(Skill.COOKING, 42));
add("Complete a delivery for the Gnome Restaurant.", add("Complete a delivery for the Gnome Restaurant.",
@@ -65,6 +69,8 @@ public class WesternDiaryRequirement extends GenericDiaryRequirement
add("Catch and cook a Monkfish in Piscatoris.", add("Catch and cook a Monkfish in Piscatoris.",
new Requirement(Skill.FISHING, 62), new Requirement(Skill.FISHING, 62),
new Requirement(Skill.COOKING, 62)); new Requirement(Skill.COOKING, 62));
add("Complete a Veteran game of Pest Control.",
new Requirement("Combat", 100));
add("Catch a Dashing Kebbit.", add("Catch a Dashing Kebbit.",
new Requirement(Skill.HUNTER, 69)); new Requirement(Skill.HUNTER, 69));
add("Complete a lap of the Ape Atoll agility course.", add("Complete a lap of the Ape Atoll agility course.",