Skip to content

Commit 68c2f7c

Browse files
committed
- Fixed carrier scheduled to depart message. Now it will say carrier will depart in H hours M minutes.
- Consolidated action map, to reduce the options even farther based on isOnFoot, isInMainShip, and isInSRV.
1 parent df9c6b2 commit 68c2f7c

File tree

11 files changed

+112
-93
lines changed

11 files changed

+112
-93
lines changed

app/src/main/java/elite/intel/ai/brain/AiActionsMap.java

Lines changed: 59 additions & 69 deletions
Large diffs are not rendered by default.

app/src/main/java/elite/intel/ai/brain/handlers/commands/ClosePanelHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ public class ClosePanelHandler implements CommandHandler {
66

77
@Override
88
public void handle(String action, JsonObject params, String responseText) {
9-
UiExit.close();
9+
UiNavCommon.close();
1010
}
1111
}

app/src/main/java/elite/intel/ai/brain/handlers/commands/Commands.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public enum Commands {
133133
SHOW_STORAGE_PANEL ("show_storage_panel", null, OpenStoragePanelHandler.class),
134134
SHOW_STATUS_PANEL ("show_status_panel", null, OpenStatusPanelHandler.class),
135135
SHOW_STATION_SERVICES ("show_station_services_panel", null, OpenStationServicesHandler.class),
136+
LAUNCH_SHIP ("launch_ship", null, LaunchShipHandler.class),
136137
EXIT_CLOSE ("exit_close", null, ClosePanelHandler.class),
137138

138139

app/src/main/java/elite/intel/ai/brain/handlers/commands/DisembarkHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class DisembarkHandler implements CommandHandler {
1515

1616
@Override
1717
public void handle(String action, JsonObject params, String responseText) {
18-
UiExit.close();
18+
UiNavCommon.close();
1919
if (status.isInSrv()) {
2020
GameControllerBus.publish(new GameInputEvent(Bindings.GameCommand.BINDING_FOCUS_ROLE_PANEL.getGameBinding(), 0));
2121

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package elite.intel.ai.brain.handlers.commands;
2+
3+
import com.google.gson.JsonObject;
4+
import elite.intel.ai.hands.events.GameInputEvent;
5+
import elite.intel.gameapi.GameControllerBus;
6+
7+
public class LaunchShipHandler implements CommandHandler {
8+
@Override
9+
public void handle(String action, JsonObject params, String responseText) {
10+
UiNavCommon.close();
11+
UiNavCommon.prepToKnownUiPositionWhileInTheShipAtStation();
12+
GameControllerBus.publish(new GameInputEvent(Bindings.GameCommand.BINDING_UI_UP.getGameBinding(), 0));
13+
GameControllerBus.publish(new GameInputEvent(Bindings.GameCommand.BINDING_ACTIVATE.getGameBinding(), 0));
14+
}
15+
}

app/src/main/java/elite/intel/ai/brain/handlers/commands/OpenFleetCarrierManagementHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class OpenFleetCarrierManagementHandler implements CommandHandler {
1414

1515
/// not a sure fire. assumes default UI selection. will fail often.
1616
@Override public void handle(String action, JsonObject params, String responseText) {
17+
UiNavCommon.close();
1718
if(status.isOnFoot()){
1819
GameControllerBus.publish(new GameInputEvent(BINDING_ON_FOOT_WHEEL.getGameBinding(), 500));
1920
GameControllerBus.publish(new GameInputEvent(BINDING_UI_RIGHT.getGameBinding(), 0));

app/src/main/java/elite/intel/ai/brain/handlers/commands/OpenStationServicesHandler.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,10 @@ public class OpenStationServicesHandler implements CommandHandler {
88

99
@Override
1010
public void handle(String action, JsonObject params, String responseText) {
11-
UiExit.close();
12-
13-
prepToKnownUiPosition();
11+
UiNavCommon.close();
12+
UiNavCommon.prepToKnownUiPositionWhileInTheShipAtStation();
1413
GameControllerBus.publish(new GameInputEvent(Bindings.GameCommand.BINDING_UI_UP.getGameBinding(), 0));
1514
GameControllerBus.publish(new GameInputEvent(Bindings.GameCommand.BINDING_UI_UP.getGameBinding(), 0));
1615
GameControllerBus.publish(new GameInputEvent(Bindings.GameCommand.BINDING_ACTIVATE.getGameBinding(), 0));
1716
}
18-
19-
20-
private void prepToKnownUiPosition() {
21-
GameControllerBus.publish(new GameInputEvent(Bindings.GameCommand.BINDING_UI_DOWN.getGameBinding(), 0));
22-
GameControllerBus.publish(new GameInputEvent(Bindings.GameCommand.BINDING_UI_DOWN.getGameBinding(), 0));
23-
GameControllerBus.publish(new GameInputEvent(Bindings.GameCommand.BINDING_UI_DOWN.getGameBinding(), 0));
24-
}
2517
}

app/src/main/java/elite/intel/ai/brain/handlers/commands/UiExit.java renamed to app/src/main/java/elite/intel/ai/brain/handlers/commands/UiNavCommon.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import elite.intel.session.Status;
66
import elite.intel.session.ui.UINavigator;
77

8-
public class UiExit {
8+
public class UiNavCommon {
99

1010
public static void close() {
1111
Status status = Status.getInstance();
@@ -15,4 +15,11 @@ public static void close() {
1515
}
1616
new UINavigator().closeOpenPanel();
1717
}
18+
19+
20+
public static void prepToKnownUiPositionWhileInTheShipAtStation() {
21+
GameControllerBus.publish(new GameInputEvent(Bindings.GameCommand.BINDING_UI_DOWN.getGameBinding(), 0));
22+
GameControllerBus.publish(new GameInputEvent(Bindings.GameCommand.BINDING_UI_DOWN.getGameBinding(), 0));
23+
GameControllerBus.publish(new GameInputEvent(Bindings.GameCommand.BINDING_UI_DOWN.getGameBinding(), 0));
24+
}
1825
}

app/src/main/java/elite/intel/gameapi/journal/subscribers/CarrierJumpRequestSubscriber.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import elite.intel.gameapi.SensorDataEvent;
77
import elite.intel.gameapi.journal.events.CarrierJumpRequestEvent;
88
import elite.intel.session.PlayerSession;
9-
import elite.intel.util.TimestampFormatter;
109

10+
import java.time.Duration;
1111
import java.time.Instant;
1212

1313
@SuppressWarnings("unused")
@@ -16,19 +16,29 @@ public class CarrierJumpRequestSubscriber {
1616
@Subscribe
1717
public void onCarrierJumpRequestEvent(CarrierJumpRequestEvent event) {
1818
Thread.ofVirtual().start(() -> {
19-
String fleetCarrierType = event.getCarrierType(); //nulls
20-
String destinationSystemName = event.getSystemName(); //nulls
2119
String destinationStellarBody = event.getBody();
2220
String rawDepartureTime = event.getDepartureTime();
23-
String formattedDepartureTime = TimestampFormatter.formatTimestamp(rawDepartureTime, true);
21+
22+
Instant departureInstant = Instant.parse(rawDepartureTime);
23+
long totalMinutes = Duration.between(Instant.now(), departureInstant).toMinutes();
24+
long hours = totalMinutes / 60;
25+
long minutes = totalMinutes % 60;
26+
27+
String timeUntil;
28+
if (hours > 0 && minutes > 0) {
29+
timeUntil = hours + (hours == 1 ? " hour" : " hours") + " and " + minutes + (minutes == 1 ? " minute" : " minutes");
30+
} else if (hours > 0) {
31+
timeUntil = hours + (hours == 1 ? " hour" : " hours");
32+
} else {
33+
timeUntil = minutes + (minutes == 1 ? " minute" : " minutes");
34+
}
2435

2536
StringBuilder sb = new StringBuilder();
26-
sb.append("Carrier Jump Scheduled: ");
27-
sb.append(" to ");
28-
sb.append(destinationStellarBody);
29-
sb.append(" departure time: ");
30-
sb.append(formattedDepartureTime);
31-
sb.append(".");
37+
sb.append("Carrier scheduled to depart");
38+
if (destinationStellarBody != null && !destinationStellarBody.isBlank()) {
39+
sb.append(" to ").append(destinationStellarBody);
40+
}
41+
sb.append(" in ").append(timeUntil).append(".");
3242

3343
PlayerSession playerSession = PlayerSession.getInstance();
3444
playerSession.setCarrierDepartureTime(rawDepartureTime);

app/src/main/java/elite/intel/util/TimestampFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static String formatTimestamp(String isoTimestamp, boolean useLocalTime)
2323
try {
2424
ZonedDateTime zdt = ZonedDateTime.parse(isoTimestamp, DateTimeFormatter.ISO_DATE_TIME);
2525
if (useLocalTime) {
26-
zdt = zdt.withZoneSameInstant(ZoneId.of("America/Los_Angeles")); // PDT
26+
zdt = zdt.withZoneSameInstant(ZoneId.systemDefault());
2727
}
2828
return zdt.format(HUMAN_READABLE_FORMATTER);
2929
} catch (Exception e) {

0 commit comments

Comments
 (0)