Skip to content

Conversation

@psikomonkie
Copy link
Member

@psikomonkie psikomonkie commented Dec 30, 2025

TO:AR p. 169-174 infantry vs. infantry combat inside TO:AR Advanced Buildings.

I can't believe I got tricked into implementing boarding rules.

Breaching!

  • New action for infantry (CI & BA) during the Pre-End phase to start an "Infantry v Infantry combat" in their current hex. Only available if there is a hostile TO:AR Advanced Building.
  • New action for infantry (CI & BA) during the Infantry vs Infantry Combat phase to withdraw or reinforce from "Infantry v Infantry combat" that it's currently participating in. Only available if the unit is engaged in combat or able to reinforce an existing combat.
  • TO:AR Advanced Building crews may participate in the defense of their building during "Infantry v Infantry combat" - they can opt to reinforce during the Infantry vs Infantry Combat phase..
  • Marine Point Score: Implemented the various Marine Point Score tables for calculating the MPS for different unit compositions. Get those BA vibro-claws ready!
  • Building Modifier: Very large buildings provide an additional bonus to the defender.
  • Infantry v Infantry Action Roll: Yeah all that nonsense, even the big table of different ratios and results.
  • Re-Converting Marine Points Score: Only the "complex" method, not the "simple" method.
  • Crew Losses & Crew Hits: Hits for non-infantry crew that're involved (Building crew, Dropship crew.....)
  • Collateral Damage: Combat inside structures is difficult - there's a chance to hit the structure (vessel or building) that the combat is taking place inside of.
  • Basic Princess Support: Princess will attempt to seize any TO:AR Advanced Buildings she moves infantry into if she thinks the attacking force is strong enough, and will reinforce to defend against player attempts at seizing princess's buildings. No logic to move the Infantry where it needs to be yet, just letting it use this if it happens to wander into the right hex.

Future Enhancements

  • Naval Boarding: Yarr, I'm excited for blackwater piracy, but not with this PR. This PR is designed with naval boarding in mind so it should mostly be a matter of getting naval grappling set up, then this should be plug and play.
  • Princess Rebalance: This makes Dropships much more vulnerable to infantry when grounded. In particular, I know Princess enjoys using grounded Aerodyne like a bad mobile structure - that'll be a terrible idea if 5 guys and a can opener can steal a Dropship. For my sanity, I think it'll be another PR.
  • Using a Captured Unit/Building: This is not part of this PR. This PR does let you use infantry to crew-kill a TO:AR Advanced Building, which should complement MekHQ's scenarios that request you to capture hostile structures.

Todo

  • Why is the end report skipping?
  • Ensure infantry combat data saves in the tiny window between the pre-end declarations and the end phase
  • Fix that it says "Attacking forces eliminated" even when it's the defenders being eliminated
  • Fix disabled tests
  • Untangle messy logic from changing course mid-way-through

@psikomonkie psikomonkie added In Development (Draft) An additional way to mark something as a draft. Make it stand out more. Draft Work in Progress labels Dec 30, 2025
@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

❌ Patch coverage is 29.47224% with 1029 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.61%. Comparing base (a855e63) to head (15f476c).
⚠️ Report is 46 commits behind head on main.

Files with missing lines Patch % Lines
.../phaseDisplay/InfantryVsInfantryCombatDisplay.java 0.00% 243 Missing ⚠️
...panels/phaseDisplay/PreEndDeclarationsDisplay.java 0.00% 208 Missing ⚠️
...src/megamek/server/totalWarfare/TWGameManager.java 39.77% 137 Missing and 22 partials ⚠️
...amek/client/bot/princess/InfantryCombatHelper.java 5.69% 115 Missing and 1 partial ⚠️
...amek/src/megamek/client/bot/princess/Princess.java 3.41% 111 Missing and 2 partials ⚠️
...ek/common/compute/MarinePointsScoreCalculator.java 38.09% 48 Missing and 4 partials ⚠️
megamek/src/megamek/common/units/Infantry.java 0.00% 31 Missing ⚠️
...mek/src/megamek/client/ui/clientGUI/ClientGUI.java 0.00% 18 Missing ⚠️
...c/megamek/common/units/AbstractBuildingEntity.java 36.00% 14 Missing and 2 partials ⚠️
...c/megamek/common/actions/InfantryCombatAction.java 0.00% 15 Missing ⚠️
... and 12 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7847      +/-   ##
============================================
+ Coverage     29.56%   29.61%   +0.05%     
- Complexity    16275    16597     +322     
============================================
  Files          3132     3145      +13     
  Lines        301264   303337    +2073     
  Branches      52822    53267     +445     
============================================
+ Hits          89080    89846     +766     
- Misses       202911   204078    +1167     
- Partials       9273     9413     +140     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}

List<Integer> entityIds = isAttacker ? combat.attackerIds : combat.defenderIds;
String sideName = isAttacker ? "Attackers" : "Defenders";

Check notice

Code scanning / CodeQL

Unread local variable Note

Variable 'String sideName' is never read.
/**
* Report combat ratio.
*/
private void reportCombatRatio(megamek.common.units.AbstractBuildingEntity building,

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'building' is never used.
/**
* Report combat roll and result.
*/
private void reportCombatRoll(megamek.common.units.AbstractBuildingEntity building,

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'building' is never used.
*/
private void reportSideEliminated(InfantryBuildingCombatTracker.BuildingCombat combat,
InfantryBuildingCombatTracker tracker,
megamek.common.units.AbstractBuildingEntity building,

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'building' is never used.
*/
private void reportSideRepulsed(InfantryBuildingCombatTracker.BuildingCombat combat,
InfantryBuildingCombatTracker tracker,
megamek.common.units.AbstractBuildingEntity building) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'building' is never used.
@psikomonkie psikomonkie changed the title DRAFT PR: Infantry vs Infantry Combat Inside TO:AR Buildings DRAFT PR: Breaching! nfantry vs Infantry Combat Inside TO:AR Buildings Dec 31, 2025
@psikomonkie psikomonkie changed the title DRAFT PR: Breaching! nfantry vs Infantry Combat Inside TO:AR Buildings DRAFT PR: Breaching! Infantry vs Infantry Combat Inside TO:AR Buildings Dec 31, 2025
@psikomonkie psikomonkie added the Infantry Issues related to Conventional Infantry. label Dec 31, 2025
@HammerGS HammerGS requested a review from Copilot January 1, 2026 22:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements TO:AR page 169 infantry vs. infantry combat inside TO:AR Advanced Buildings, commonly known as "breaching" mechanics. The implementation allows conventional infantry and battle armor to engage in building-to-building combat during the Physical phase.

Key Changes:

  • New infantry combat action system with Marine Points Score (MPS) calculation and combat resolution tables
  • Building crew participation in defense with crew casualties tracking
  • Collateral damage system affecting building structure during combat
  • Integration with existing building collapse mechanics

Reviewed changes

Copilot reviewed 81 out of 81 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
InfantryActionTracker.java New tracker class managing active infantry combat instances with attacker/defender lists
TWGameManager.java Core combat resolution logic including MPS calculation, casualty application, and combat outcome handling
MarinePointsScoreCalculator.java Implements TO:AR Marine Points Score tables for unit strength calculation
InfantryCombatTables.java Combat resolution tables and ratio calculations
Entity.java Added infantry combat state tracking fields and methods
BuildingEntity.java Enhanced building entity with weapon arc support and crew type
BuildingCollapseHandler.java Updated to handle building hex collapse during infantry combat
Multiple test files Comprehensive test coverage for all new systems

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

*
* @return LOS effects between the given positions
*/
public static LosEffects calculateLOS(final Game game, final @Nullable Entity attacker,
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method 'calculateLOS' may be confused with calculateLos.

Copilot uses AI. Check for mistakes.
void beforeEach() {
coords = new Coords(1, 1);
entity = new BipedMek();
getGame().addEntity(entity);
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot uses AI. Check for mistakes.
setBoard("BOARD");

mockEvent = mock(BoardViewEvent.class);
when(mockEvent.getBoardId()).thenReturn(getGame().getBoard().getBoardId());
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot uses AI. Check for mistakes.
when(mockEvent.getButton()).thenReturn(MouseEvent.BUTTON1);
when(mockEvent.getModifiers()).thenReturn(0);
when(mockClient.isMyTurn()).thenReturn(true);
when(mockClient.getGame()).thenReturn(getGame());
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot uses AI. Check for mistakes.
@BeforeEach
void setUpBoard() {
player = new Player(0, "Test Player");
getGame().addPlayer(0, player);
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot uses AI. Check for mistakes.
groundEntity.setOwner(player);
groundBoard = getBoard("GROUND_BOARD");
coords = new Coords(0, 0);
getGame().addEntity(groundEntity);
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot uses AI. Check for mistakes.
public int locations() {
if (getInternalBuilding() == null || getInternalBuilding().getCoordsList() == null) {
// Map can be null during construction
if (locationToRelativeCoordsMap == null || locationToRelativeCoordsMap.isEmpty()) {
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is useless. locationToRelativeCoordsMap cannot be null at this check, since new HashMap<Integer,CubeCoords>(...) always is non-null.

Copilot uses AI. Check for mistakes.
@psikomonkie psikomonkie added the Implementation of Missing Official Rule Used with the RFE tag for the implementation of missing official rule label Jan 2, 2026
* @return Best reinforcement unit, or null if none suitable
*/
public static Entity findBestReinforcement(List<Entity> candidates,
Entity target, Game game) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'game' is never used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Draft Work in Progress Implementation of Missing Official Rule Used with the RFE tag for the implementation of missing official rule In Development (Draft) An additional way to mark something as a draft. Make it stand out more. Infantry Issues related to Conventional Infantry.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant