complete missions in end route
This commit is contained in:
@@ -229,12 +229,13 @@ public class HelperController {
|
||||
boolean isEnd = route.isEnd();
|
||||
RouteEntryModel entry = this.entry;
|
||||
if (profile.isDocked() && MainController.getProfile().getStation().equals(entry.getStation())) {
|
||||
route.complete();
|
||||
if (!isEnd)
|
||||
profile.setDocked(false);
|
||||
else {
|
||||
if (!route.isLoop()) {
|
||||
profile.clearRoute();
|
||||
} else {
|
||||
route.complete();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -246,26 +247,6 @@ public class HelperController {
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void next(){
|
||||
int index = route.getCurrentEntry();
|
||||
if (index < route.getJumps() - 1){
|
||||
route.setCurrentEntry(index + 1);
|
||||
} else {
|
||||
if (route.isLoop()){
|
||||
route.setCurrentEntry(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void previous(){
|
||||
int index = route.getCurrentEntry();
|
||||
if (index > 0){
|
||||
route.setCurrentEntry(index - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void copy(){
|
||||
Main.copyToClipboard(system.getText());
|
||||
|
||||
@@ -257,6 +257,7 @@ public class RouteModel {
|
||||
|
||||
public void updateCurrentEntry(SystemModel system, StationModel station, boolean undock) {
|
||||
if (undock){
|
||||
complete();
|
||||
int index = getCurrentEntry();
|
||||
RouteEntryModel entry = entries.get(index);
|
||||
if (index < entries.size()-1 && system.equals(entry.getStation().getSystem()) && entry.getStation().equals(station)){
|
||||
@@ -300,7 +301,7 @@ public class RouteModel {
|
||||
int index = getCurrentEntry();
|
||||
RouteEntryModel entry = entries.get(index);
|
||||
Collection<OrderModel> orders = entry.orders();
|
||||
for (int i = index+1; i < entries.size(); i++) {
|
||||
for (int i = index; i < entries.size(); i++) {
|
||||
RouteEntryModel e = entries.get(i);
|
||||
for (MissionModel mission : e.missions()) {
|
||||
mission.complete(orders);
|
||||
@@ -314,25 +315,30 @@ public class RouteModel {
|
||||
}
|
||||
}
|
||||
}
|
||||
Collection<MissionModel> missions = new ArrayList<>(entry.missions());
|
||||
if (index == entries.size()-1){
|
||||
removeCompletedMissions();
|
||||
if (isLoop()) setCurrentEntry(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeCompletedMissions(){
|
||||
boolean needRefresh = false;
|
||||
for (MissionModel mission : missions) {
|
||||
mission.complete(orders);
|
||||
if (mission.isCompleted()){
|
||||
Collection<RouteReserve> reserves = mission.getReserves();
|
||||
if (reserves != null) {
|
||||
needRefresh = true;
|
||||
_route.unreserve(reserves);
|
||||
for (RouteEntryModel entry : entries) {
|
||||
Collection<MissionModel> missions = new ArrayList<>(entry.missions());
|
||||
for (MissionModel mission : missions) {
|
||||
if (mission.isCompleted()) {
|
||||
Collection<RouteReserve> reserves = mission.getReserves();
|
||||
if (reserves != null) {
|
||||
needRefresh = true;
|
||||
_route.unreserve(reserves);
|
||||
}
|
||||
entry.remove(mission);
|
||||
}
|
||||
entry.remove(mission);
|
||||
}
|
||||
}
|
||||
if (needRefresh){
|
||||
refresh();
|
||||
}
|
||||
if (index == entries.size()-1){
|
||||
if (isLoop()) setCurrentEntry(0);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnd(){
|
||||
|
||||
Reference in New Issue
Block a user