bugfix: conditions not respecting inversion
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.srsoftware</groupId>
|
||||
<artifactId>web4rail</artifactId>
|
||||
<version>0.9.10</version>
|
||||
<version>0.9.11</version>
|
||||
<name>Web4Rail</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Java Model Railway Control</description>
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ConditionalAction extends Action {
|
||||
@Override
|
||||
public boolean fire(Context context) throws IOException {
|
||||
for (Condition condition : conditions) {
|
||||
if (condition.fulfilledBy(context) != condition.inverted) return actions.fire(context);
|
||||
if (condition.fulfilledBy(context)) return actions.fire(context);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ public abstract class Condition implements Constants {
|
||||
private static final String INVERTED = "inverted";
|
||||
private static final String PREFIX = Condition.class.getPackageName();
|
||||
private static HashMap<Integer, Condition> conditions = new HashMap<Integer, Condition>();
|
||||
public abstract boolean fulfilledBy(Context context);
|
||||
public boolean inverted = false;
|
||||
protected int id;
|
||||
|
||||
@@ -70,6 +69,8 @@ public abstract class Condition implements Constants {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract boolean fulfilledBy(Context context);
|
||||
|
||||
public int id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class TrainHasTag extends Condition {
|
||||
@Override
|
||||
public boolean fulfilledBy(Context context) {
|
||||
if (tag == null) return true;
|
||||
return context.train.tags().contains(tag);
|
||||
return context.train.tags().contains(tag) != inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,7 @@ public class TrainLength extends Condition {
|
||||
|
||||
@Override
|
||||
public boolean fulfilledBy(Context context) {
|
||||
return context.train.length() < maxLength;
|
||||
return (context.train.length() < maxLength) != inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@ public class TrainSelect extends Condition {
|
||||
|
||||
@Override
|
||||
public boolean fulfilledBy(Context context) {
|
||||
return context.train == train;
|
||||
return (context.train == train) != inverted;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ import de.srsoftware.web4rail.tags.Select;
|
||||
import de.srsoftware.web4rail.tiles.Block;
|
||||
import de.srsoftware.web4rail.tiles.Signal;
|
||||
|
||||
public class Train implements Comparable,Constants {
|
||||
public class Train implements Comparable<Train>,Constants {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Train.class);
|
||||
|
||||
private static final HashMap<Integer, Train> trains = new HashMap<>();
|
||||
@@ -516,7 +516,7 @@ public class Train implements Comparable,Constants {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
public int compareTo(Train o) {
|
||||
return name().compareTo(o.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user