Skip to content

Commit

Permalink
add flee direction to report
Browse files Browse the repository at this point in the history
  • Loading branch information
kuronekochomusuke committed Nov 28, 2024
1 parent 11e88e9 commit 1568e96
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 20 deletions.
3 changes: 2 additions & 1 deletion megamek/i18n/megamek/common/report-messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
1511= to maximise range.

2000=<newline><B>Movement Phase</B><newline>-------------------
2005=<newline><data> (<data>) flees the battlefield.
2005=<newline><data> (<data>) flees the battlefield in the direction <data>.
2010=It carries <data> (<data>) with it.
2015=It takes <data> (<data>) with it.
2016=It carries <data> with it.
Expand Down Expand Up @@ -1038,6 +1038,7 @@
7075=The following units never entered the field of battle:
7076=All fighters in squadron destroyed
7080=<newline>The following units are in retreat:
7081=fled in direction <data>.
7085=<newline>Graveyard contains:
7090=<newline>The following utterly destroyed units are not available for salvage:
7095=<newline>Detailed unit status saved to entitystatus.txt
Expand Down
71 changes: 52 additions & 19 deletions megamek/src/megamek/server/totalwarfare/TWGameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,29 @@ void prepareVictoryReport() {
while (retreat.hasMoreElements()) {
Entity entity = retreat.nextElement();
addReport(entity.victoryReport());

String fleeDirection;
switch (entity.getStartingPos(false)) {
case Board.START_N:
fleeDirection = "North";
break;
case Board.START_E:
fleeDirection = "Ease";
break;
case Board.START_S:
fleeDirection = "South";
break;
case Board.START_W:
fleeDirection = "West";
break;
default:
fleeDirection = "Edge";
}

r = new Report(7081, Report.PUBLIC);
r.indent();
r.add(fleeDirection);
addReport(r);
}
}
// List destroyed units
Expand Down Expand Up @@ -5304,7 +5327,6 @@ public Vector<Report> processLeaveMap(MovePath movePath, boolean flewOff, int re
r = new Report(9370, Report.PUBLIC);
}
r.addDesc(entity);
addReport(r);
OffBoardDirection fleeDirection;
if (movePath.getFinalCoords().getY() <= 0) {
fleeDirection = OffBoardDirection.NORTH;
Expand All @@ -5316,8 +5338,35 @@ public Vector<Report> processLeaveMap(MovePath movePath, boolean flewOff, int re
fleeDirection = OffBoardDirection.EAST;
}

if (returnable > -1) {
String fleeDir;
switch (fleeDirection) {
case NORTH:
entity.setStartingPos(Board.START_N);
fleeDir = "North";
break;
case EAST:
entity.setStartingPos(Board.START_E);
fleeDir = "East";
break;
case SOUTH:
entity.setStartingPos(Board.START_S);
fleeDir = "South";
break;
case WEST:
entity.setStartingPos(Board.START_W);
fleeDir = "West";
break;
default:
entity.setStartingPos(Board.START_EDGE);
fleeDir = "Edge";
}

r.add(fleeDir);
addReport(r);

entityUpdate(entity.getId());

if (returnable > -1) {
entity.setDeployed(false);
entity.setDeployRound(1 + game.getRoundCount() + returnable);
entity.setPosition(null);
Expand All @@ -5330,23 +5379,7 @@ public Vector<Report> processLeaveMap(MovePath movePath, boolean flewOff, int re
// fly off again instantly.
((IAero) entity).setOutControl(false);
}
switch (fleeDirection) {
case WEST:
entity.setStartingPos(Board.START_W);
break;
case NORTH:
entity.setStartingPos(Board.START_N);
break;
case EAST:
entity.setStartingPos(Board.START_E);
break;
case SOUTH:
entity.setStartingPos(Board.START_S);
break;
default:
entity.setStartingPos(Board.START_EDGE);
}
entityUpdate(entity.getId());

return vReport;
} else {
ServerHelper.clearBloodStalkers(game, entity.getId(), this);
Expand Down

0 comments on commit 1568e96

Please sign in to comment.