bugfixes, reimplemented train simulator

This commit is contained in:
Stephan Richter
2021-04-04 13:26:42 +02:00
parent 6f529887f1
commit 61ae9c727c
5 changed files with 52 additions and 1 deletions

View File

@@ -66,6 +66,20 @@ public abstract class Bridge extends Tile {
return super.load(json);
}
@Override
public boolean lockFor(Context context, boolean downgrade) {
if (lockingTrain() == context.train()) return true;
if (!super.lockFor(context, downgrade)) return false;
return isSet(counterpart) ? counterpart.lockFor(context, downgrade) : true;
}
@Override
public boolean reserveFor(Context context) {
if (reservingTrain() == context.train()) return true;
if (!super.reserveFor(context)) return false;
return isSet(counterpart) ? counterpart.reserveFor(context) : true;
}
@Override
public boolean setTrain(Train newTrain) {
if (occupyingTrain() == newTrain) return true;

View File

@@ -434,6 +434,10 @@ public abstract class Tile extends BaseClass implements Comparable<Tile> {
plan.place(this);
return true;
}
protected Train reservingTrain() {
return reservingTrain;
}
public TreeSet<Route> routes() {
return routes;