|
|
@ -72,6 +72,8 @@ public class Train extends BaseClass implements Comparable<Train> { |
|
|
|
|
|
|
|
|
|
|
|
private static final String DESTINATION = "destination"; |
|
|
|
private static final String DESTINATION = "destination"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String ACTION_REVERSE = "reverse"; |
|
|
|
|
|
|
|
|
|
|
|
private HashSet<String> tags = new HashSet<String>(); |
|
|
|
private HashSet<String> tags = new HashSet<String>(); |
|
|
|
private boolean f1,f2,f3,f4; |
|
|
|
private boolean f1,f2,f3,f4; |
|
|
|
|
|
|
|
|
|
|
@ -157,6 +159,8 @@ public class Train extends BaseClass implements Comparable<Train> { |
|
|
|
return train.properties(); |
|
|
|
return train.properties(); |
|
|
|
case ACTION_QUIT: |
|
|
|
case ACTION_QUIT: |
|
|
|
return train.quitAutopilot(); |
|
|
|
return train.quitAutopilot(); |
|
|
|
|
|
|
|
case ACTION_REVERSE: |
|
|
|
|
|
|
|
return train.reverse(); |
|
|
|
case ACTION_SLOWER10: |
|
|
|
case ACTION_SLOWER10: |
|
|
|
return train.slower(10); |
|
|
|
return train.slower(10); |
|
|
|
case ACTION_START: |
|
|
|
case ACTION_START: |
|
|
@ -501,7 +505,10 @@ public class Train extends BaseClass implements Comparable<Train> { |
|
|
|
carList().addTo(propList); |
|
|
|
carList().addTo(propList); |
|
|
|
|
|
|
|
|
|
|
|
if (isSet(currentBlock)) currentBlock.button(currentBlock.toString()).addTo(new Tag("li").content(t("Current location:")+NBSP)).addTo(propList); |
|
|
|
if (isSet(currentBlock)) currentBlock.button(currentBlock.toString()).addTo(new Tag("li").content(t("Current location:")+NBSP)).addTo(propList); |
|
|
|
if (isSet(direction)) new Tag("li").content(t("Direction: heading {}",direction)).addTo(propList); |
|
|
|
Tag directionLi = null; |
|
|
|
|
|
|
|
if (isSet(direction)) directionLi = new Tag("li").content(t("Direction: heading {}",direction)+NBSP); |
|
|
|
|
|
|
|
if (isNull(directionLi)) directionLi = new Tag("li"); |
|
|
|
|
|
|
|
button(t("reverse"), Map.of(ACTION,ACTION_REVERSE)).title(t("Turns the train, as if it went through a loop.")).addTo(directionLi).addTo(propList); |
|
|
|
|
|
|
|
|
|
|
|
Tag dest = new Tag("li").content(t("Destination:")+NBSP); |
|
|
|
Tag dest = new Tag("li").content(t("Destination:")+NBSP); |
|
|
|
if (isNull(destination)) { |
|
|
|
if (isNull(destination)) { |
|
|
@ -584,6 +591,22 @@ public class Train extends BaseClass implements Comparable<Train> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* This turns the train as if it went through a loop. Example: |
|
|
|
|
|
|
|
* before: CabCar→ MiddleCar→ Loco→ |
|
|
|
|
|
|
|
* after: ←Loco ←MiddleCar ←CabCar |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Tag reverse() { |
|
|
|
|
|
|
|
LOG.debug("train.reverse();"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isSet(direction)) { |
|
|
|
|
|
|
|
direction = direction.inverse(); |
|
|
|
|
|
|
|
reverseTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (isSet(currentBlock)) plan.place(currentBlock); |
|
|
|
|
|
|
|
return properties(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void reverseTrace() { |
|
|
|
private void reverseTrace() { |
|
|
|
LinkedList<Tile> reversed = new LinkedList<Tile>(); |
|
|
|
LinkedList<Tile> reversed = new LinkedList<Tile>(); |
|
|
|
LOG.debug("Trace: {}",trace); |
|
|
|
LOG.debug("Trace: {}",trace); |
|
|
@ -808,17 +831,17 @@ public class Train extends BaseClass implements Comparable<Train> { |
|
|
|
return name(); |
|
|
|
return name(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* this inverts the direction the train is heading to. Example: |
|
|
|
|
|
|
|
* before: CabCar→ MiddleCar→ Loco→ |
|
|
|
|
|
|
|
* after: ←CabCar ←MiddleCar ←Loco |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
public Tag turn() { |
|
|
|
public Tag turn() { |
|
|
|
LOG.debug("train.turn()"); |
|
|
|
LOG.debug("train.turn()"); |
|
|
|
|
|
|
|
|
|
|
|
for (Car car : cars) car.turn(); |
|
|
|
for (Car car : cars) car.turn(); |
|
|
|
Collections.reverse(cars); |
|
|
|
Collections.reverse(cars); |
|
|
|
if (isSet(direction)) { |
|
|
|
return reverse(); |
|
|
|
direction = direction.inverse(); |
|
|
|
|
|
|
|
reverseTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (isSet(currentBlock)) plan.place(currentBlock); |
|
|
|
|
|
|
|
return properties(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected Train update(HashMap<String, String> params) { |
|
|
|
protected Train update(HashMap<String, String> params) { |
|
|
|