Skip to content

Commit 3a3c6bf

Browse files
authored
Fix MegaMek#7855: Fix Victory Report for AdvancedBuildingEntity (MegaMek#7856)
Fixes MegaMek#7855
2 parents d2300f0 + ee1f968 commit 3a3c6bf

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

megamek/src/megamek/common/units/AbstractBuildingEntity.java

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,43 @@ public void addEquipment(Mounted<?> mounted, int loc, boolean rearMounted)
715715
*/
716716
@Override
717717
public Vector<Report> victoryReport() {
718-
return null;
718+
Vector<Report> vDesc = new Vector<>();
719+
720+
Report report = new Report(7025);
721+
report.type = Report.PUBLIC;
722+
report.addDesc(this);
723+
vDesc.addElement(report);
724+
725+
report = new Report(7036);
726+
report.type = Report.PUBLIC;
727+
report.newlines = 0;
728+
vDesc.addElement(report);
729+
vDesc.addAll(getCrew().getDescVector(false));
730+
report = new Report(7070, Report.PUBLIC);
731+
report.add(getKillNumber());
732+
vDesc.addElement(report);
733+
734+
if (isDestroyed()) {
735+
Entity killer = game.getEntity(killerId);
736+
if (killer == null) {
737+
killer = game.getOutOfGameEntity(killerId);
738+
}
739+
if (killer != null) {
740+
report = new Report(7072, Report.PUBLIC);
741+
report.addDesc(killer);
742+
} else {
743+
report = new Report(7073, Report.PUBLIC);
744+
}
745+
vDesc.addElement(report);
746+
report.newlines = 2;
747+
} else if (getCrew().isEjected()) {
748+
report = new Report(7071, Report.PUBLIC);
749+
vDesc.addElement(report);
750+
report.newlines = 2;
751+
}
752+
753+
754+
return vDesc;
719755
}
720756

721757
/**

megamek/unittests/megamek/common/AbstractBuildingEntityTest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
import static org.junit.jupiter.api.Assertions.assertEquals;
3737
import static org.junit.jupiter.api.Assertions.assertFalse;
3838
import static org.junit.jupiter.api.Assertions.assertNotNull;
39-
import static org.junit.jupiter.api.Assertions.assertNull;
4039
import static org.junit.jupiter.api.Assertions.assertTrue;
4140
import static org.mockito.ArgumentMatchers.any;
4241

42+
import java.util.Vector;
4343
import java.util.stream.Stream;
4444

4545
import megamek.common.board.Coords;
@@ -251,7 +251,15 @@ void testAddEquipment(AbstractBuildingEntity building) throws Exception {
251251
@ParameterizedTest
252252
@MethodSource("buildingProvider")
253253
void testVictoryReport(AbstractBuildingEntity building) {
254-
assertNull(building.victoryReport());
254+
// Arrange
255+
initializeBuildingOnBoard(building);
256+
257+
// Act
258+
Vector<Report> victoryReports = building.victoryReport();
259+
260+
// Assert
261+
assertNotNull(victoryReports);
262+
assertEquals(4, victoryReports.size());
255263
}
256264

257265
@ParameterizedTest

0 commit comments

Comments
 (0)