Skip to content

Commit

Permalink
Astral Gate: Priority can now be configured for each portal
Browse files Browse the repository at this point in the history
  • Loading branch information
dm94 committed Aug 17, 2023
1 parent e7083f8 commit 46aa523
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/main/java/com/deeme/lang/strings_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ astral.ship_to_choose.desc=PLUS options only work for some users
astral.choose_portal.desc=It will choose the portal and item that he thinks is the most appropriate.
astral.min_cpus=Minimum number of CPUs
astral.min_cpus.desc=It will not open any more astrals if it is below this number.
astral.portal_table=Portal Types
astral.portal_table.priority=Priority
astral.portal_table.priority.desc=Lower value = higher priority
astral.portal_table.ignore_limit=Ignore Limit
astral.portal_table.ignore_limit.desc=It will enter the portal even if you have the maximum of those items.
ambulance.ship_type=Type of ship
ambulance.ship_type.desc=Also works with the plus versions
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/deeme/modules/astral/AstralConfig.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.deeme.modules.astral;

import java.util.HashMap;
import java.util.Map;

import com.deeme.behaviours.bestrocket.RocketSupplier;
import com.deemetool.gui.suppliers.LaserSupplier;
import com.deemetool.modules.astral.PortalInfo;

import eu.darkbot.api.config.annotations.Configuration;
import eu.darkbot.api.config.annotations.Dropdown;
import eu.darkbot.api.config.annotations.Number;
import eu.darkbot.api.config.annotations.Option;
import eu.darkbot.api.config.annotations.Table;

@Configuration("astral")
public class AstralConfig {
Expand Down Expand Up @@ -39,4 +44,6 @@ public class AstralConfig {

@Option("astral.auto_choose")
public boolean autoChoose = false;

public @Option @Table Map<String, PortalInfo> portalInfos = new HashMap<>();
}
27 changes: 26 additions & 1 deletion src/main/java/com/deeme/modules/astral/AstralGate.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.deeme.types.VerifierChecker;
import com.deeme.types.backpage.Utils;
import com.deemetool.modules.astral.AstralPlus;
import com.deemetool.modules.astral.PortalInfo;
import com.github.manolo8.darkbot.config.NpcExtraFlag;
import com.github.manolo8.darkbot.core.itf.NpcExtraProvider;

Expand All @@ -18,6 +19,7 @@
import eu.darkbot.api.game.entities.Npc;
import eu.darkbot.api.game.entities.Portal;
import eu.darkbot.api.game.enums.EntityEffect;
import eu.darkbot.api.game.enums.PortalType;
import eu.darkbot.api.game.items.Item;
import eu.darkbot.api.game.items.ItemCategory;
import eu.darkbot.api.game.items.ItemFlag;
Expand Down Expand Up @@ -48,6 +50,8 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JButton;
import javax.swing.JOptionPane;
Expand Down Expand Up @@ -160,6 +164,7 @@ public AstralGate(PluginAPI api, AuthAPI auth, SafetyFinder safety) {
@Override
public void setConfig(ConfigSetting<AstralConfig> arg0) {
this.astralConfig = arg0.getValue();
fillPortalInfo();
}

@Override
Expand Down Expand Up @@ -220,6 +225,26 @@ public void onTickStopped() {
}
}

private void fillPortalInfo() {
if (astralConfig.portalInfos.size() > 0) {
return;
}
Map<String, PortalInfo> defaultPortals = new HashMap<>();
defaultPortals.put(PortalType.ROUGE_LITE_HP_RECOVER.name(), new PortalInfo(0));
defaultPortals.put(PortalType.ROUGE_LITE_AMMUNITION.name(), new PortalInfo(1));
defaultPortals.put(PortalType.ROUGE_LITE_MODULE.name(), new PortalInfo(2));
defaultPortals.put(PortalType.ROUGE_LITE_GENERATOR.name(), new PortalInfo(3));
defaultPortals.put(PortalType.ROUGE_LITE_WEAPON.name(), new PortalInfo(4));
defaultPortals.put(PortalType.ROUGE_LITE_RESOURCE.name(), new PortalInfo(5));
defaultPortals.put(PortalType.ROUGE_LITE_AMMUNITION_BRUTAL.name(), new PortalInfo(6));
defaultPortals.put(PortalType.ROUGE_LITE_MODULE_BRUTAL.name(), new PortalInfo(7));
defaultPortals.put(PortalType.ROUGE_LITE_GENERATOR_BRUTAL.name(), new PortalInfo(8));
defaultPortals.put(PortalType.ROUGE_LITE_WEAPON_BRUTAL.name(), new PortalInfo(9));
defaultPortals.put(PortalType.ROUGE_LITE_RESOURCE_BRUTAL.name(), new PortalInfo(10));

astralConfig.portalInfos.putAll(defaultPortals);
}

private void waveLogic() {
nextWaveCheck = System.currentTimeMillis() + waitTime;
waveHasBeenAwaited = false;
Expand All @@ -244,7 +269,7 @@ private void preparingWaveLogic() {

goToTheMiddle();

if (astralConfig.autoChoose && astralPlus.autoChoose()) {
if (astralConfig.autoChoose && astralPlus.autoChoose(astralConfig.portalInfos)) {
this.currentStatus = State.CHOOSING_BEST_OPTION;
} else if (!portals.isEmpty() || astralPlus.hasOptionsToChoose()) {
stopBot(State.WAITING_HUMAN);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "DmPlugin",
"author": "Dm94Dani",
"version": "2.0.3 beta 2",
"version": "2.0.3 beta 3",
"minVersion": "1.127",
"supportedVersion": "1.127",
"basePackage": "com.deeme",
Expand Down

0 comments on commit 46aa523

Please sign in to comment.