From 7264d2dd99d980d156db83c89f89ba61febc9448 Mon Sep 17 00:00:00 2001 From: test Date: Tue, 6 Aug 2024 04:51:50 +1000 Subject: [PATCH] Add militarization_time --- .../manager/v2/impl/pw/CommandManager2.java | 1 + .../v2/impl/pw/commands/StatCommands.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/CommandManager2.java b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/CommandManager2.java index 4b443c9e..2a664cec 100644 --- a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/CommandManager2.java +++ b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/CommandManager2.java @@ -239,6 +239,7 @@ public static Map parseArguments(Set params, String inpu public CommandManager2 registerDefaults() { // this.commands.registerMethod(new TestCommands(), List.of("test"), "test", "test"); getCommands().registerMethod(new GrantCommands(), List.of("grant"), "costBulk", "cost"); + getCommands().registerMethod(new GrantCommands(), List.of("alliance", "stats"), "militarizationTime", "militarization_time"); getCommands().registerMethod(new WarCommands(), List.of("sheets_ia"), "ActivitySheetDate", "activity_date"); getCommands().registerMethod(new WarCommands(), List.of("sheets_ia"), "WarDecSheetDate", "declares_date"); diff --git a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/StatCommands.java b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/StatCommands.java index 156fa003..7ab07f6a 100644 --- a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/StatCommands.java +++ b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/StatCommands.java @@ -1529,6 +1529,24 @@ public String allianceMetricsCompareByTurn(@Me IMessageIO channel, @Me Guild gui return "Done!"; } + @Command(desc = "Compare the metric over time between multiple alliances") + public String militarizationTime(@Me IMessageIO channel, DBAlliance alliance, @Default("7d") @Timediff long start_time, + @Switch("e") @Timestamp Long end_time, + @Switch("j") boolean attach_json, + @Switch("c") boolean attach_csv) throws IOException { + if (end_time == null) end_time = System.currentTimeMillis(); + end_time = Math.max(end_time, System.currentTimeMillis()); + start_time = end_time - start_time; + + long endTurn = Math.min(TimeUtil.getTurn(), TimeUtil.getTurn(end_time)); + long startTurn = TimeUtil.getTurn(start_time); + + List metrics = new ArrayList<>(Arrays.asList(AllianceMetric.SOLDIER_PCT, AllianceMetric.TANK_PCT, AllianceMetric.AIRCRAFT_PCT, AllianceMetric.SHIP_PCT)); + TimeNumericTable table = AllianceMetric.generateTable(metrics, startTurn, endTurn, alliance.getName(), Collections.singleton(alliance)); + table.write(channel, TimeFormat.TURN_TO_DATE, TableNumberFormat.PERCENTAGE_ONE, start_time, attach_json, attach_csv); + return "Done!"; + } + @Command(desc = "Graph an alliance metric over time for two coalitions") public String allianceMetricsAB(@Me IMessageIO channel, @Me Guild guild, @Me GuildDB db, AllianceMetric metric, Set coalition1, Set coalition2, @Arg("Date to start from")