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