diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/ai/dark/DarkAI.java b/FightSystem_Core/src/de/steamwar/fightsystem/ai/dark/DarkAI.java index f089d39..1f6c76d 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/ai/dark/DarkAI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/ai/dark/DarkAI.java @@ -23,7 +23,8 @@ public class DarkAI extends AI { super(team, SteamwarUser.get(12172)); } - //63 + //109209 Isegrim + //111476 Underground @Override public SchematicNode chooseSchematic() { SchematicNode node = SchematicNode.getSchematicNode(109209); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/ai/dark/stateMachine/StateMachine.java b/FightSystem_Core/src/de/steamwar/fightsystem/ai/dark/stateMachine/StateMachine.java new file mode 100644 index 0000000..6cb4455 --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/ai/dark/stateMachine/StateMachine.java @@ -0,0 +1,61 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.fightsystem.ai.dark.stateMachine; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.function.Predicate; + +public class StateMachine { + + private ArrayList states = new ArrayList<>(); + private int currStateID = 0; + + public void tick(){ + State state = states.get(currStateID); + boolean result = state.exec.run(); + if(result){ + currStateID = state.successful; + + } + else { + currStateID = state.failed; + } + } + + public void addState(String name, StateRunnable exec, int successful, int failed){ + states.add(new State(name,exec,successful,failed)); + } + + private class State{ + public final String name; + public final StateRunnable exec; + public final int successful; + public final int failed; + + public State (String name,StateRunnable exec, int successful, int failed) { + this.name = name; + this.exec = exec; + this.successful = successful; + this.failed = failed; + } + } +} diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/ai/dark/stateMachine/StateRunnable.java b/FightSystem_Core/src/de/steamwar/fightsystem/ai/dark/stateMachine/StateRunnable.java new file mode 100644 index 0000000..829d949 --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/ai/dark/stateMachine/StateRunnable.java @@ -0,0 +1,24 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.fightsystem.ai.dark.stateMachine; + +public interface StateRunnable { + boolean run(); +}