Skip to content

Commit

Permalink
feat: hasQuest condition (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
dm94 authored Jun 20, 2024
1 parent c94e6f0 commit 6bc09c5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.github.manolo8.darkbot.config.actions.conditions;

import com.github.manolo8.darkbot.Main;
import com.github.manolo8.darkbot.config.actions.Condition;
import com.github.manolo8.darkbot.config.actions.Parser;
import com.github.manolo8.darkbot.config.actions.SyntaxException;
import com.github.manolo8.darkbot.config.actions.ValueData;
import com.github.manolo8.darkbot.config.actions.parser.ParseUtil;

import eu.darkbot.api.managers.QuestAPI;

import org.jetbrains.annotations.NotNull;

@ValueData(name = "has-quest", description = "True if it has quests", example = "hasQuest()")
public class HasQuestCondition implements Condition, Parser {
private QuestAPI questApi;

@Override
public @NotNull Result get(Main main) {
if (questApi == null) {
this.questApi = main.pluginAPI.getAPI(QuestAPI.class);
}

return Result.fromBoolean(this.questApi.getDisplayedQuest() != null);
}

@Override
public String toString() {
return "hasQuest()";
}

@Override
public String parse(String str) throws SyntaxException {
String[] params = str.split("\\)", 2);
return ParseUtil.separate(params, getClass(), ")");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.github.manolo8.darkbot.config.actions.conditions.EqualCondition;
import com.github.manolo8.darkbot.config.actions.conditions.HasEffectCondition;
import com.github.manolo8.darkbot.config.actions.conditions.HasFormationCondition;
import com.github.manolo8.darkbot.config.actions.conditions.HasQuestCondition;
import com.github.manolo8.darkbot.config.actions.conditions.NoneCondition;
import com.github.manolo8.darkbot.config.actions.conditions.NumericalCondition;
import com.github.manolo8.darkbot.config.actions.conditions.OneCondition;
Expand Down Expand Up @@ -58,6 +59,8 @@ public class Values {
// Stateful conditions
AfterCondition.class,
UntilCondition.class,
// Special conditions
HasQuestCondition.class,
// Values
DistanceValue.class,
ShipLocationValue.class,
Expand Down

0 comments on commit 6bc09c5

Please sign in to comment.