From 5b5f92ea1e6a61251c7fa074d2cab0eb66badc32 Mon Sep 17 00:00:00 2001 From: Will Date: Sun, 6 Dec 2026 07:25:06 -0500 Subject: [PATCH] Localize the hit assignment after a combat roll on combat.hits.* keys (1-5e) Co-Authored-By: Claude Opus 5.5 --- docs/LOCALIZATION_PLAN.md | 2 +- .../ti4/service/combat/CombatRollService.java | 383 ++++++++++++------ .../resources/i18n/messages/combat.properties | 28 ++ .../combat/CombatHitAssignmentTextTest.java | 119 ++++++ src/test/resources/i18n-ratchet.txt | 2 + 5 files changed, 401 insertions(+), 133 deletions(-) create mode 100644 src/test/java/ti4/service/combat/CombatHitAssignmentTextTest.java diff --git a/docs/LOCALIZATION_PLAN.md b/docs/LOCALIZATION_PLAN.md index b528b22a14..45058991da 100644 --- a/docs/LOCALIZATION_PLAN.md +++ b/docs/LOCALIZATION_PLAN.md @@ -388,7 +388,7 @@ Each row is one PR. Every PR leaves English output unchanged unless its row says | 1-12 | Russian style appendix to `BOT_MESSAGE_STYLING.md` and `docs/i18n/GLOSSARY_ru.md` | — | | 1-13 | Beta switch-on: AI-branch label dependencies re-measured, flag allowlist for volunteer games, games with AI seats forced to English, the "English leak" counter | 1-1…1-11, 1-0-ru, 1-1-ru…1-11-ru, 0A-9, 0B-3 | -Phase 1 status. 1-0 and 1-1 shipped in the pilot (https://github.com/AsyncTI4/TI4_map_generator_bot/pull/6289). 1-2 moves every send in `ti4.cron` onto `cron.*` keys (ratchet floor 0): the autoping reminders, including the 42 rotating ping lines (`cron.autoping.ping.`), the status and agenda phase reminders, the strategy card follow deadlines and the tech summary. `EndOldGamesCron` sends no player text. The `PASS_ON_WHENS`, `PASS_ON_AFTERS` and pre-vote buttons on the agenda reminders stay shared English constants until 1-9. 1-3a moves `PlayStrategyCardService` onto `scs.*` keys: the play header (its verb is a `select` over `StrategyCardPlayKind`), follow and not-following buttons, auto-not-following notices, follow offers, the Politics, Trade and Twilight's Fall notes and the official card buttons. Homebrew labels stay literal (ratchet floor 66); `ButtonHelperSCs` is 1-3b. 1-3b moves the official texts of `ButtonHelperSCs` onto `scs.*` keys: following and not following, the strategy token spend (now a `FollowTokenSpend` outcome, so `scFollow` and the Trade wash no longer read its text), pre-declining, the Leadership, Diplomacy, Politics, Technology, Imperial and Trade follow-ups and the Construction and Warfare production prompts. `I18nRatchetTest` now also takes a class line, since `ti4.helpers` is too big to floor; `ti4.helpers.ButtonHelperSCs 69` covers the homebrew sets left literal. Row 1-4 is split in four: 1-4a (`ti4.service.tactical` and its button subpackages, `TacticalActionButtonHandlers`), 1-4b (`ButtonHelperTacticalAction`), 1-4c (`ButtonHelperModifyUnits`, with the Xan Quantum Fabrication check) and 1-4d (production and the `Done*` buttons). 1-4a moves the movement buttons and prompts, the landing buttons and notices, the movement summary (its distance line is an ICU plural) and the official ability buttons onto `tactical.*` keys. Unit type names inside the landing labels stay English until game data is localized. The Land and Un-land labels carry five short names, so `DiscordLimitsI18nTest` checks them with 12-character samples; a long planet name is still cut by `Buttons.of`, as before. Homebrew buttons stay literal (floors: `ti4.service.tactical` 5, `.movement` 19, `.planet` 1, `.postmovement` 20, `TacticalActionButtonHandlers` 0). 1-4b moves the official texts of `ButtonHelperTacticalAction` onto `tactical.*` keys: starting a tactical action and choosing the system, the activation notices (Space Cannon range with ICU plural dice), the Space Cannon Offence prompts in Fog of War, Voidwatch, the after-movement and end-of-action offers, the build prompt (reusing the `scs.production.*` lines) and the unit buttons for a system. Base, PoK, Thunder's Edge and Twilight's Fall texts moved; homebrew stays literal (`ti4.helpers.ButtonHelperTacticalAction 56`). 1-4c takes the movement side of `ButtonHelperModifyUnits`: removing and capturing units, Infiltrate, retreat buttons and notices (ICU plurals for mechs, PDS and space docks), the after-landing prompts (combat or coexistence, the Keleres mech, returning fighters) and the Xan Quantum Fabrication id. Its unit placement handlers (`place_`, `placeOneNDone_`) are production and move to 1-4d; its hit assignment texts are combat and move to 1-5 (`ti4.helpers.ButtonHelperModifyUnits 88`). The remove, capture and infantry retreat labels join the Land labels on 12-character samples in `DiscordLimitsI18nTest`. 1-4d moves production onto `tactical.production.*` keys: the produce buttons of `Helper.getPlaceUnitButtons`, the running production summary (ICU plurals for units and resources, the PRODUCTION and _Bellum Gloriosum_ limits), the `place_` and `placeOneNDone_` notices (one select over placed or produced), the Construction token and Mahact agent prompts, the payment prompt with its official cost reducers, and the follow-ups (_Bellum Gloriosum_, Rally the Horde, Orbital Drop, _Planetary Defense Nexus_). The Done handler's command token notices move to `tactical.done.*`. `DoneButtonKind` labels come from `common.done*.button` keys through `red`/`bareRed`/`bareBlue` overloads that take a language; the English label stays for the legacy label lookup. `Buttons.doneExhaustingPlanets(lang)` and its two siblings replace the `DONE_EXHAUSTING_PLANETS_*` constants, which stay `@Deprecated` until their other 46 callers move. The spend summary (`Helper.buildSpentThingsMessage`) and the stored action summary stay English for now. Floors: `ti4.helpers.Helper 34`, `DeleteButtonsButtonHandler 6`, `ButtonHelperModifyUnits 80`. 1-5 is split by flow: 1-5a moves the start of a combat in `StartCombatService` onto `combat.*` keys: the coexist-or-fight and remove-structures prompts, the combat thread (starter, intro with the step lists, the no-action-cards, [0.0.1], Quietus and X89 reminders, automation offer), the Fog of War spectator thread, Space Cannon Offence and ANTI-FIGHTER BARRAGE buttons, the start-of-space-combat buttons, the Breach and Ahk Siever follow-ups and the official cards-info reminders (secret objectives, Mahact, N'orr Supremacy, Nekro, The Reaping, Salvage Operations, the Mentak commander). The thread and Space Cannon texts follow the active player's language; cards-info reminders follow their owner. `rollForDummyButton` is replaced by `spaceCannonForDummyButton(dummy, id, lang)`. Homebrew stays literal (`ti4.service.combat.StartCombatService 210`). 1-5b moves the official labels of `getGeneralCombatButtons` onto `combat.buttons.*` keys: hit assignment, repair, refresh, the retreat and ready-for-dice buttons, the roll buttons (space, ground, BOMBARDMENT, Space Cannon Defence, each with its dummy variant), the official agents and genomes (one `select` for Clever Clever, agent names stay English), and the official faction, technology and hero buttons (Supercharge, War Funding, Exotrireme II, Gravleash Maneuvers, Devotion, Munitions Reserves, Foresight, the Ral Nel commander and mech, the Sol commander, Indoctrinate, Magen Defense Grid, Stealth Corps, Dunlain Reaper, Assimilate, the Keleres, Rebellion and Bastion heroes). The buttons follow the active player's language. Homebrew stays literal (`StartCombatService 170`). 1-5c stops logic reading the combat roll message, which `TextAsLogicGuardTest` did not catch: `CombatRollResult` keeps the modifier lines, body, total line and after-total notes apart, so roll notes and the Mass Hypnosis and Leviathan totals no longer splice or regex-replace "With modifiers:" and "**Total hits N**"; the Thalnos offer is a flag; Fog of War mirroring takes the roll subject and hit count from `CombatMessageHelper.rollHeading` instead of regex-reading "rolls for" and "Total hits"; the four `substringAfter(message, "Total hits ")` callers read `totalHits()`, and the replay roll header takes `RollHeading.name()` instead of cutting it out of the summary line. English output is unchanged. 1-5d moves the roll output of `CombatMessageHelper` onto `combat.roll.*` keys: the heading (combat names with their round, the Crown of Thalnos reroll, BOMBARDMENT targets and Space Cannon Offence systems), the unit roll lines (ICU plurals for rolls, dice and hits, one `select` for always-hits), the modifier lines and extra-dice notices, the `With modifiers:` header, the total line and the duplicate and missing unit notices. Roll output follows the roller's channel language; `RollHeading.name()` stays English for the replay header. Homebrew callers and the replay renderer keep the English overloads. The roll body notes in `CombatRollService` and hit assignment follow (`CombatRollService`, `CombatMessageHelper`) and hit assignment in `ButtonHelperModifyUnits` follow. +Phase 1 status. 1-0 and 1-1 shipped in the pilot (https://github.com/AsyncTI4/TI4_map_generator_bot/pull/6289). 1-2 moves every send in `ti4.cron` onto `cron.*` keys (ratchet floor 0): the autoping reminders, including the 42 rotating ping lines (`cron.autoping.ping.`), the status and agenda phase reminders, the strategy card follow deadlines and the tech summary. `EndOldGamesCron` sends no player text. The `PASS_ON_WHENS`, `PASS_ON_AFTERS` and pre-vote buttons on the agenda reminders stay shared English constants until 1-9. 1-3a moves `PlayStrategyCardService` onto `scs.*` keys: the play header (its verb is a `select` over `StrategyCardPlayKind`), follow and not-following buttons, auto-not-following notices, follow offers, the Politics, Trade and Twilight's Fall notes and the official card buttons. Homebrew labels stay literal (ratchet floor 66); `ButtonHelperSCs` is 1-3b. 1-3b moves the official texts of `ButtonHelperSCs` onto `scs.*` keys: following and not following, the strategy token spend (now a `FollowTokenSpend` outcome, so `scFollow` and the Trade wash no longer read its text), pre-declining, the Leadership, Diplomacy, Politics, Technology, Imperial and Trade follow-ups and the Construction and Warfare production prompts. `I18nRatchetTest` now also takes a class line, since `ti4.helpers` is too big to floor; `ti4.helpers.ButtonHelperSCs 69` covers the homebrew sets left literal. Row 1-4 is split in four: 1-4a (`ti4.service.tactical` and its button subpackages, `TacticalActionButtonHandlers`), 1-4b (`ButtonHelperTacticalAction`), 1-4c (`ButtonHelperModifyUnits`, with the Xan Quantum Fabrication check) and 1-4d (production and the `Done*` buttons). 1-4a moves the movement buttons and prompts, the landing buttons and notices, the movement summary (its distance line is an ICU plural) and the official ability buttons onto `tactical.*` keys. Unit type names inside the landing labels stay English until game data is localized. The Land and Un-land labels carry five short names, so `DiscordLimitsI18nTest` checks them with 12-character samples; a long planet name is still cut by `Buttons.of`, as before. Homebrew buttons stay literal (floors: `ti4.service.tactical` 5, `.movement` 19, `.planet` 1, `.postmovement` 20, `TacticalActionButtonHandlers` 0). 1-4b moves the official texts of `ButtonHelperTacticalAction` onto `tactical.*` keys: starting a tactical action and choosing the system, the activation notices (Space Cannon range with ICU plural dice), the Space Cannon Offence prompts in Fog of War, Voidwatch, the after-movement and end-of-action offers, the build prompt (reusing the `scs.production.*` lines) and the unit buttons for a system. Base, PoK, Thunder's Edge and Twilight's Fall texts moved; homebrew stays literal (`ti4.helpers.ButtonHelperTacticalAction 56`). 1-4c takes the movement side of `ButtonHelperModifyUnits`: removing and capturing units, Infiltrate, retreat buttons and notices (ICU plurals for mechs, PDS and space docks), the after-landing prompts (combat or coexistence, the Keleres mech, returning fighters) and the Xan Quantum Fabrication id. Its unit placement handlers (`place_`, `placeOneNDone_`) are production and move to 1-4d; its hit assignment texts are combat and move to 1-5 (`ti4.helpers.ButtonHelperModifyUnits 88`). The remove, capture and infantry retreat labels join the Land labels on 12-character samples in `DiscordLimitsI18nTest`. 1-4d moves production onto `tactical.production.*` keys: the produce buttons of `Helper.getPlaceUnitButtons`, the running production summary (ICU plurals for units and resources, the PRODUCTION and _Bellum Gloriosum_ limits), the `place_` and `placeOneNDone_` notices (one select over placed or produced), the Construction token and Mahact agent prompts, the payment prompt with its official cost reducers, and the follow-ups (_Bellum Gloriosum_, Rally the Horde, Orbital Drop, _Planetary Defense Nexus_). The Done handler's command token notices move to `tactical.done.*`. `DoneButtonKind` labels come from `common.done*.button` keys through `red`/`bareRed`/`bareBlue` overloads that take a language; the English label stays for the legacy label lookup. `Buttons.doneExhaustingPlanets(lang)` and its two siblings replace the `DONE_EXHAUSTING_PLANETS_*` constants, which stay `@Deprecated` until their other 46 callers move. The spend summary (`Helper.buildSpentThingsMessage`) and the stored action summary stay English for now. Floors: `ti4.helpers.Helper 34`, `DeleteButtonsButtonHandler 6`, `ButtonHelperModifyUnits 80`. 1-5 is split by flow: 1-5a moves the start of a combat in `StartCombatService` onto `combat.*` keys: the coexist-or-fight and remove-structures prompts, the combat thread (starter, intro with the step lists, the no-action-cards, [0.0.1], Quietus and X89 reminders, automation offer), the Fog of War spectator thread, Space Cannon Offence and ANTI-FIGHTER BARRAGE buttons, the start-of-space-combat buttons, the Breach and Ahk Siever follow-ups and the official cards-info reminders (secret objectives, Mahact, N'orr Supremacy, Nekro, The Reaping, Salvage Operations, the Mentak commander). The thread and Space Cannon texts follow the active player's language; cards-info reminders follow their owner. `rollForDummyButton` is replaced by `spaceCannonForDummyButton(dummy, id, lang)`. Homebrew stays literal (`ti4.service.combat.StartCombatService 210`). 1-5b moves the official labels of `getGeneralCombatButtons` onto `combat.buttons.*` keys: hit assignment, repair, refresh, the retreat and ready-for-dice buttons, the roll buttons (space, ground, BOMBARDMENT, Space Cannon Defence, each with its dummy variant), the official agents and genomes (one `select` for Clever Clever, agent names stay English), and the official faction, technology and hero buttons (Supercharge, War Funding, Exotrireme II, Gravleash Maneuvers, Devotion, Munitions Reserves, Foresight, the Ral Nel commander and mech, the Sol commander, Indoctrinate, Magen Defense Grid, Stealth Corps, Dunlain Reaper, Assimilate, the Keleres, Rebellion and Bastion heroes). The buttons follow the active player's language. Homebrew stays literal (`StartCombatService 170`). 1-5c stops logic reading the combat roll message, which `TextAsLogicGuardTest` did not catch: `CombatRollResult` keeps the modifier lines, body, total line and after-total notes apart, so roll notes and the Mass Hypnosis and Leviathan totals no longer splice or regex-replace "With modifiers:" and "**Total hits N**"; the Thalnos offer is a flag; Fog of War mirroring takes the roll subject and hit count from `CombatMessageHelper.rollHeading` instead of regex-reading "rolls for" and "Total hits"; the four `substringAfter(message, "Total hits ")` callers read `totalHits()`, and the replay roll header takes `RollHeading.name()` instead of cutting it out of the summary line. English output is unchanged. 1-5d moves the roll output of `CombatMessageHelper` onto `combat.roll.*` keys: the heading (combat names with their round, the Crown of Thalnos reroll, BOMBARDMENT targets and Space Cannon Offence systems), the unit roll lines (ICU plurals for rolls, dice and hits, one `select` for always-hits), the modifier lines and extra-dice notices, the `With modifiers:` header, the total line and the duplicate and missing unit notices. 1-5e moves the hit assignment that follows a roll in `CombatRollService` onto `combat.hits.*` keys: the suffered-hits lines, the auto-assign, manual, cancel and next-round buttons (one wording for every dummy button), the SPACE CANNON, AFB, ground and BOMBARDMENT assignment prompts, the Fog of War relay notices, Duranium Armor repair and the Crown of Thalnos prompt; homebrew texts stay English. Roll output follows the roller's channel language; `RollHeading.name()` stays English for the replay header. Homebrew callers and the replay renderer keep the English overloads. The roll body notes in `CombatRollService` and hit assignment follow (`CombatRollService`, `CombatMessageHelper`) and hit assignment in `ButtonHelperModifyUnits` follow. **Phase 2: official component names, Cyrillic search.** Gated on the licensing decision (§7). diff --git a/src/main/java/ti4/service/combat/CombatRollService.java b/src/main/java/ti4/service/combat/CombatRollService.java index cdad7cf12e..ce4ba2df4d 100644 --- a/src/main/java/ti4/service/combat/CombatRollService.java +++ b/src/main/java/ti4/service/combat/CombatRollService.java @@ -119,8 +119,12 @@ import ti4.helpers.thirtyk.ThirtyKActionCardHooks; import ti4.helpers.thirtyk.ThirtyKExploreHooks; import ti4.helpers.thundersedge.TeHelperUnits; +import ti4.i18n.Arg; +import ti4.i18n.Arg.PlayerForm; import ti4.i18n.Lang; +import ti4.i18n.Msg; import ti4.i18n.SupportedLanguage; +import ti4.i18n.Texts; import ti4.json.JsonMapperManager; import ti4.message.MessageHelper; import ti4.model.CombatModifierModel; @@ -156,32 +160,35 @@ public void sendSpaceCannonOffenceHitAssignment( int hits, MessageChannel channel, GenericInteractionCreateEvent event) { - String message = "\n" + opponent.getRepresentation(true, true, true, true) + " suffered " - + StringHelper.pluralize(hits, "hit") + " from SPACE CANNON against your ships."; + SupportedLanguage lang = Lang.forCorrectChannel(opponent); + String message = "\n" + + text( + Msg.of("combat.hits.sufferedSpaceCannon") + .with("player", Arg.raw(opponent.getRepresentation(true, true, true, true))) + .with("count", Arg.count(hits)), + lang); MessageHelper.sendMessageToChannel(channel, message); List