-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5867 from Algebro7/atmospheric-control-roll-errata
Advanced Atmospheric Control Roll Errata
- Loading branch information
Showing
8 changed files
with
208 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
megamek/unittests/megamek/server/totalwarfare/TWGameManagerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package megamek.server.totalwarfare; | ||
|
||
import megamek.common.*; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Vector; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class TWGameManagerTest { | ||
private Player player; | ||
private TWGameManager gameManager; | ||
private Game game; | ||
|
||
@BeforeAll | ||
static void before() { | ||
EquipmentType.initializeTypes(); | ||
} | ||
|
||
@BeforeEach | ||
void setUp() { | ||
player = new Player(0, "Test"); | ||
gameManager = new TWGameManager(); | ||
game = gameManager.getGame(); | ||
game.addPlayer(0, player); | ||
} | ||
|
||
@Test | ||
void testAddControlWithAdvAtmosphericMergesIntoOneRollAero() { | ||
AeroSpaceFighter aero = new AeroSpaceFighter(); | ||
game.addEntity(aero); | ||
Vector<PilotingRollData> rolls = new Vector<>(); | ||
StringBuilder reasons = new StringBuilder(); | ||
|
||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "critical hit")); | ||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "avionics hit")); | ||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "threshold")); | ||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "highest damage threshold exceeded")); | ||
gameManager.addControlWithAdvAtmospheric(aero, rolls, reasons); | ||
assertEquals(1, rolls.size()); | ||
} | ||
|
||
@Test | ||
void testAddControlWithAdvAtmosphericIncludesAllReasonsAero() { | ||
AeroSpaceFighter aero = new AeroSpaceFighter(); | ||
game.addEntity(aero); | ||
Vector<PilotingRollData> rolls = new Vector<>(); | ||
StringBuilder reasons = new StringBuilder(); | ||
|
||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "critical hit")); | ||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "avionics hit")); | ||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "threshold")); | ||
game.addControlRoll(new PilotingRollData(aero.getId(), 0, "highest damage threshold exceeded")); | ||
gameManager.addControlWithAdvAtmospheric(aero, rolls, reasons); | ||
assertTrue(reasons.toString().contains("critical hit")); | ||
assertTrue(reasons.toString().contains("avionics hit")); | ||
assertTrue(reasons.toString().contains("threshold")); | ||
assertTrue(reasons.toString().contains("highest damage threshold exceeded")); | ||
} | ||
|
||
@Test | ||
void testAddControlWithAdvAtmosphericMergesIntoOneRollLAM() { | ||
LandAirMech mech = new LandAirMech(LandAirMech.GYRO_STANDARD, LandAirMech.COCKPIT_STANDARD, LandAirMech.LAM_STANDARD); | ||
game.addEntity(mech); | ||
Vector<PilotingRollData> rolls = new Vector<>(); | ||
StringBuilder reasons = new StringBuilder(); | ||
|
||
game.addControlRoll(new PilotingRollData(mech.getId(), 0, "avionics hit")); | ||
game.addControlRoll(new PilotingRollData(mech.getId(), 0, "threshold")); | ||
game.addControlRoll(new PilotingRollData(mech.getId(), 0, "highest damage threshold exceeded")); | ||
gameManager.addControlWithAdvAtmospheric(mech, rolls, reasons); | ||
assertEquals(1, rolls.size()); | ||
} | ||
|
||
@Test | ||
void testAddControlWithAdvAtmosphericIncludesAllReasonsLAM() { | ||
LandAirMech mech = new LandAirMech(LandAirMech.GYRO_STANDARD, LandAirMech.COCKPIT_STANDARD, LandAirMech.LAM_STANDARD); | ||
game.addEntity(mech); | ||
Vector<PilotingRollData> rolls = new Vector<>(); | ||
StringBuilder reasons = new StringBuilder(); | ||
|
||
game.addControlRoll(new PilotingRollData(mech.getId(), 0, "avionics hit")); | ||
game.addControlRoll(new PilotingRollData(mech.getId(), 0, "threshold")); | ||
game.addControlRoll(new PilotingRollData(mech.getId(), 0, "highest damage threshold exceeded")); | ||
gameManager.addControlWithAdvAtmospheric(mech, rolls, reasons); | ||
assertTrue(reasons.toString().contains("avionics hit")); | ||
assertTrue(reasons.toString().contains("threshold")); | ||
assertTrue(reasons.toString().contains("highest damage threshold exceeded")); | ||
} | ||
} |