Dieser Commit ist enthalten in:
Ursprung
dd97e9710c
Commit
074e2793a3
@ -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);
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<State> 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.ai.dark.stateMachine;
|
||||
|
||||
public interface StateRunnable {
|
||||
boolean run();
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren