Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

battleCalculator #1 (fix issue 12688 battle calc attacker/defender determination) #12816

Merged
merged 1 commit into from
Aug 4, 2024

Conversation

frigoref
Copy link
Member

@frigoref frigoref commented Aug 4, 2024

issue 12688 (battle calc on own territory shows own player as attacker and defender) Desired:

  1. Attacker: Current player always, except when only allied units present (then next enemy)
  2. Defender: As enemy to attacker with most units (fallback: whomever is at war and has the next turn)

AttackerAndDefenderSelectorTest.java

  • simplification of method getAttackerAndDefender()
  • new methods getBestAttacker() and getBestAttacker()
  • removed now unused methods getOpponentWithPriorityList, playersAtWarWith, neutralPlayersTowards, getEnemyWithMostUnits

UnitCollection.java

  • rename method getPlayersByUnitCount to getPlayersSortedByUnitCount

BattleCalculatorDialog.java

  • extract common logic from method addAttackers and addDefenders to new method adjustBattleCalculatorPanel
  • extract static attribute modifications from instance method dispose into new static method disposeInstance (especially pack also for adding attacker)

BattleCalculatorPanel.java

  • introduce new methods setAttackerWithUnits and setDefenderWithUnits to limit attacker/defender change to own instance
  • make setter of attribute attacker/defender private
  • rename methods hasAttackingUnitsAdded and hasDefendingUnitsAdded to hasAttackingUnits and hasDefendingUnits
  • rename attribute attackerUnitsTotalHitpoints to attackerUnitsTotalHitPoints

Notes to Reviewer

issue 12688 (battle calc on own territory shows own player as attacker and defender)
Desired:
1. Attacker: Current player always, except when only allied units present (then next enemy)
2. Defender: As enemy to attacker with most units (fallback: whomever is at war and has the next turn)

AttackerAndDefenderSelectorTest.java
- simplification of method getAttackerAndDefender()
- new methods getBestAttacker() and getBestAttacker()
- removed now unused methods getOpponentWithPriorityList, playersAtWarWith, neutralPlayersTowards, getEnemyWithMostUnits

UnitCollection.java
- rename method getPlayersByUnitCount to getPlayersSortedByUnitCount

BattleCalculatorDialog.java
- extract common logic from method addAttackers and addDefenders to new method adjustBattleCalculatorPanel
- extract static attribute modifications from instance method dispose into new static method disposeInstance (especially pack also for adding attacker)

BattleCalculatorPanel.java
- introduce new methods setAttackerWithUnits and setDefenderWithUnits to limit attacker/defender change to own instance
- make setter of attribute attacker/defender private
- rename methods hasAttackingUnitsAdded and hasDefendingUnitsAdded to hasAttackingUnits and hasDefendingUnits
- rename attribute attackerUnitsTotalHitpoints to attackerUnitsTotalHitPoints
@frigoref frigoref merged commit 4505bce into triplea-game:master Aug 4, 2024
1 check passed
@frigoref
Copy link
Member Author

frigoref commented Aug 4, 2024

Should solve to issue 12688 (2.6: When opening battle calc on own territory on own turn, your country is selected as both attacker and defender)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant