Skip to content

Commit

Permalink
add tests for advanced atmospheric control rolls
Browse files Browse the repository at this point in the history
  • Loading branch information
Algebro7 committed Aug 8, 2024
1 parent a4d91d8 commit f6b60f6
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions megamek/unittests/megamek/server/GameManagerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package megamek.server;

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 GameManagerTest {
private Player player;
private GameManager gameManager;
private Game game;

@BeforeAll
static void before() {
EquipmentType.initializeTypes();
}

@BeforeEach
void setUp() {
player = new Player(0, "Test");
gameManager = new GameManager();
game = gameManager.getGame();
game.addPlayer(0, player);
}

@Test
void testAddControlWithAdvAtmosphericMergesIntoOneRoll() {
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());
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 testAddControlWithAdvAtmosphericIncludesAllReasons() {
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"));
}
}

0 comments on commit f6b60f6

Please sign in to comment.