improved actions and conditions code,

added TrainLength condition,
added FreeStartBlock action
This commit is contained in:
Stephan Richter
2020-11-01 17:35:42 +01:00
parent a89d522ea2
commit d40ea949be
14 changed files with 264 additions and 148 deletions

View File

@@ -151,19 +151,6 @@ public class Train implements Constants {
} else cars.add(car);
return this;
}
private static Object create(HashMap<String, String> params, Plan plan) {
Locomotive loco = (Locomotive) Locomotive.get(params.get(Train.LOCO_ID));
if (loco == null) return t("unknown locomotive: {}",params.get(ID));
Train train = new Train(loco).plan(plan);
if (params.containsKey(NAME)) train.name(params.get(NAME));
return train;
}
private Train name(String newName) {
this.name = newName;
return this;
}
public void add(Car car) {
if (car == null) return;
@@ -189,6 +176,14 @@ public class Train implements Constants {
this.block = block;
}
private static Object create(HashMap<String, String> params, Plan plan) {
Locomotive loco = (Locomotive) Locomotive.get(params.get(Train.LOCO_ID));
if (loco == null) return t("unknown locomotive: {}",params.get(ID));
Train train = new Train(loco).plan(plan);
if (params.containsKey(NAME)) train.name(params.get(NAME));
return train;
}
public static Train get(int id) {
return trains.get(id);
}
@@ -321,6 +316,11 @@ public class Train implements Constants {
return result;
}
private Train name(String newName) {
this.name = newName;
return this;
}
private Train plan(Plan plan) {
this.plan = plan;
return this;