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

add report roll tooltip #4873

Merged
merged 13 commits into from
Dec 12, 2023
8 changes: 5 additions & 3 deletions megamek/src/megamek/client/ui/swing/MovementDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -4208,15 +4208,17 @@ private void dumpBombs() {
dumpBombsDialog.getChoices();
// first make a control roll
PilotingRollData psr = ce().getBasePilotingRoll(overallMoveType);
int ctrlroll = Compute.d6(2);
Roll diceRoll = Compute.rollD6(2);
int rollValue = diceRoll.getIntValue();
String rollReport = diceRoll.getReport();
Report r = new Report(9500);
r.subject = ce().getId();
r.add(ce().getDisplayName());
r.add(psr);
r.add(ctrlroll);
r.addDataWithTooltip(String.valueOf(rollValue), rollReport);
r.newlines = 0;
r.indent(1);
if (ctrlroll < psr.getValue()) {
if (rollValue < psr.getValue()) {
r.choose(false);
String title = Messages.getString("MovementDisplay.DumpingBombs.title");
String body = Messages.getString("MovementDisplay.DumpFailure.message");
Expand Down
18 changes: 10 additions & 8 deletions megamek/src/megamek/common/Building.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,24 +432,26 @@ public boolean rollBasement(Coords coords, Board board, Vector<Report> vPhaseRep
Report r = new Report(2111, Report.PUBLIC);
r.add(getName());
r.add(coords.getBoardNum());
int basementRoll = Compute.d6(2);
r.add(basementRoll);
if (basementRoll == 2) {
Roll diceRoll = Compute.rollD6(2);
int rollValue = diceRoll.getIntValue();
String rollReport = diceRoll.getReport();
r.addDataWithTooltip(String.valueOf(rollValue), rollReport);
if (rollValue == 2) {
basement.put(coords, BasementType.TWO_DEEP_FEET);
hex.addTerrain(new Terrain(Terrains.BLDG_BASEMENT_TYPE, basement.get(coords).ordinal()));
} else if (basementRoll == 3) {
} else if (rollValue == 3) {
basement.put(coords, BasementType.ONE_DEEP_FEET);
hex.addTerrain(new Terrain(Terrains.BLDG_BASEMENT_TYPE, basement.get(coords).ordinal()));
} else if (basementRoll == 4) {
} else if (rollValue == 4) {
basement.put(coords, BasementType.ONE_DEEP_NORMAL);
hex.addTerrain(new Terrain(Terrains.BLDG_BASEMENT_TYPE, basement.get(coords).ordinal()));
} else if (basementRoll == 10) {
} else if (rollValue == 10) {
basement.put(coords, BasementType.ONE_DEEP_NORMAL);
hex.addTerrain(new Terrain(Terrains.BLDG_BASEMENT_TYPE, basement.get(coords).ordinal()));
} else if (basementRoll == 11) {
} else if (rollValue == 11) {
basement.put(coords, BasementType.ONE_DEEP_HEAD);
hex.addTerrain(new Terrain(Terrains.BLDG_BASEMENT_TYPE, basement.get(coords).ordinal()));
} else if (basementRoll == 12) {
} else if (rollValue == 12) {
basement.put(coords, BasementType.TWO_DEEP_HEAD);
hex.addTerrain(new Terrain(Terrains.BLDG_BASEMENT_TYPE, basement.get(coords).ordinal()));
} else {
Expand Down
41 changes: 23 additions & 18 deletions megamek/src/megamek/common/Compute.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
import megamek.common.enums.BasementType;
import megamek.common.enums.IlluminationLevel;
import megamek.common.options.OptionsConstants;
import megamek.common.verifier.TestEntity;
import megamek.common.weapons.InfantryAttack;
import megamek.common.weapons.Weapon;
import megamek.common.weapons.artillery.ArtilleryCannonWeapon;
import megamek.common.weapons.bayweapons.BayWeapon;
import megamek.common.weapons.gaussrifles.HAGWeapon;
import megamek.common.weapons.infantry.InfantryWeapon;
import megamek.common.weapons.mgs.MGWeapon;
import megamek.common.weapons.mortars.MekMortarWeapon;
import megamek.server.Server;
import megamek.server.SmokeCloud;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -137,46 +135,53 @@ public class Compute {
{ 30, 10, 10, 12, 18, 18, 18, 18, 24, 24, 30, 30 },
{ 40, 12, 12, 18, 24, 24, 24, 24, 32, 32, 40, 40 } };

/**
* Wrapper to random#d6()
*/
public static int d6() {
return d6( 1);
}

/**
* Wrapper to random#d6(n)
*/
public static int d6(int dice) {
Roll roll = random.d6(dice);
if (Server.getServerInstance() != null) {
if (Server.getServerInstance().getGame().getOptions()
.booleanOption(OptionsConstants.BASE_RNG_LOG)) {
Server.getServerInstance().reportRoll(roll);
}
}
return roll.getIntValue();
return rollD6(dice).getIntValue();
}

/**
* Wrapper to random#d6(n)
*/
public static int d6(int dice, int keep) {
Roll roll = random.d6(dice, keep);
return rollD6(dice, keep).getIntValue();
}

/**
* Wrapper to random#d6(n)
*/
public static Roll rollD6(int dice) {
Roll roll = random.d6(dice);
if (Server.getServerInstance() != null) {
if (Server.getServerInstance().getGame().getOptions()
.booleanOption(OptionsConstants.BASE_RNG_LOG)) {
.booleanOption(OptionsConstants.BASE_RNG_LOG)) {
Server.getServerInstance().reportRoll(roll);
}
}
return roll.getIntValue();
return roll;
}

/**
* Wrapper to random#d6()
* Wrapper to random#d6(n)
*/
public static int d6() {
Roll roll = random.d6();
public static Roll rollD6(int dice, int keep) {
Roll roll = random.d6(dice, keep);
if (Server.getServerInstance() != null) {
if (Server.getServerInstance().getGame().getOptions()
.booleanOption(OptionsConstants.BASE_RNG_LOG)) {
.booleanOption(OptionsConstants.BASE_RNG_LOG)) {
Server.getServerInstance().reportRoll(roll);
}
}
return roll.getIntValue();
return roll;
}

/**
Expand Down
12 changes: 6 additions & 6 deletions megamek/src/megamek/common/Crew.java
Original file line number Diff line number Diff line change
Expand Up @@ -1157,20 +1157,20 @@ public void resetGameState() {
}
}

public int rollGunnerySkill() {
public Roll rollGunnerySkill() {
if (getOptions().booleanOption(OptionsConstants.PILOT_APTITUDE_GUNNERY)) {
return Compute.d6(3, 2);
return Compute.rollD6(3, 2);
}

return Compute.d6(2);
return Compute.rollD6(2);
}

public int rollPilotingSkill() {
public Roll rollPilotingSkill() {
if (getOptions().booleanOption(OptionsConstants.PILOT_APTITUDE_PILOTING)) {
return Compute.d6(3, 2);
return Compute.rollD6(3, 2);
}

return Compute.d6(2);
return Compute.rollD6(2);
}

public int getCurrentPilotIndex() {
Expand Down
14 changes: 8 additions & 6 deletions megamek/src/megamek/common/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13454,31 +13454,33 @@
if (isSupercharger) {
// do the damage - engine crits
int hits = 0;
int roll = Compute.d6(2);
Roll diceRoll = Compute.rollD6(2);
int rollValue = diceRoll.getIntValue();
String rollReport = diceRoll.getReport();
r = new Report(6310);
r.subject = getId();
r.add(roll);
r.addDataWithTooltip(String.valueOf(rollValue), rollReport);
r.newlines = 0;
vDesc.addElement(r);
if (roll <= 7) {
if (rollValue <= 7) {
// no effect
r = new Report(6005);
r.subject = getId();
r.newlines = 0;
vDesc.addElement(r);
} else if ((roll >= 8) && (roll <= 9)) {
} else if ((rollValue >= 8) && (rollValue <= 9)) {
Fixed Show fixed Hide fixed
hits = 1;
r = new Report(6315);
r.subject = getId();
r.newlines = 0;
vDesc.addElement(r);
} else if ((roll >= 10) && (roll <= 11)) {
} else if ((rollValue >= 10) && (rollValue <= 11)) {
hits = 2;
r = new Report(6320);
r.subject = getId();
r.newlines = 0;
vDesc.addElement(r);
} else if (roll == 12) {
} else if (rollValue == 12) {
hits = 3;
r = new Report(6325);
r.subject = getId();
Expand Down
16 changes: 10 additions & 6 deletions megamek/src/megamek/common/Mech.java
Original file line number Diff line number Diff line change
Expand Up @@ -5462,9 +5462,11 @@ public Vector<Report> doCheckEngineStallRoll(Vector<Report> vPhaseReport) {
vPhaseReport.add(Report.subjectReport(2285, getId()).add(psr.getValueAsString()).add(psr.getDesc()));
vPhaseReport.add(Report.subjectReport(2290, getId()).indent().noNL().add(1).add(psr.getPlainDesc()));

int diceRoll = getCrew().rollPilotingSkill();
Report r = Report.subjectReport(2300, getId()).add(psr).add(diceRoll);
if (diceRoll < psr.getValue()) {
Roll diceRoll = getCrew().rollPilotingSkill();
int rollValue = diceRoll.getIntValue();
String rollReport = diceRoll.getReport();
Report r = Report.subjectReport(2300, getId()).add(psr).addDataWithTooltip(String.valueOf(rollValue), rollReport);
if (rollValue < psr.getValue()) {
setStalled(true);
vPhaseReport.add(r.noNL().choose(false));
vPhaseReport.add(Report.subjectReport(2303, getId()));
Expand Down Expand Up @@ -5492,9 +5494,11 @@ public void checkUnstall(Vector<Report> vPhaseReport) {
vPhaseReport.add(Report.subjectReport(2285, getId()).add(psr.getValueAsString()).add(psr.getDesc()));
vPhaseReport.add(Report.subjectReport(2290, getId()).indent().noNL().add(1).add(psr.getPlainDesc()));

int diceRoll = getCrew().rollPilotingSkill();
Report r = Report.subjectReport(2300, getId()).add(psr).add(diceRoll);
if (diceRoll < psr.getValue()) {
Roll diceRoll = getCrew().rollPilotingSkill();
int rollValue = diceRoll.getIntValue();
String rollReport = diceRoll.getReport();
Report r = Report.subjectReport(2300, getId()).add(psr).addDataWithTooltip(String.valueOf(rollValue), rollReport);
if (rollValue < psr.getValue()) {
vPhaseReport.add(r.choose(false));
} else {
setStalled(false);
Expand Down
2 changes: 2 additions & 0 deletions megamek/src/megamek/common/PhysicalResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class PhysicalResult implements Serializable {
public ToHitData toHitRight = null;
public int roll = -1;
public int rollRight = -1;
public String rollReport = "";
public String rollRightReport = "";
public int damage = 0;
public int damageRight = 0;
public boolean pushBackResolved = false;
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/weapons/AR10Handler.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public boolean handle(GamePhase phase, Vector<Report> vPhaseReport) {
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down
1 change: 0 additions & 1 deletion megamek/src/megamek/common/weapons/AmmoWeaponHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import megamek.common.actions.WeaponAttackAction;
import megamek.common.options.OptionsConstants;
import megamek.server.GameManager;
import megamek.server.Server;
import org.apache.logging.log4j.LogManager;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public boolean accept(Entity entity) {
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public boolean handle(GamePhase phase, Vector<Report> vPhaseReport) {
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public boolean handle(GamePhase phase, Vector<Report> vPhaseReport) {
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ else if ((null != bestSpotter) && !(this instanceof ArtilleryWeaponDirectFireHan
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public boolean handle(GamePhase phase, Vector<Report> vPhaseReport) {
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down
4 changes: 2 additions & 2 deletions megamek/src/megamek/common/weapons/BayWeaponHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public boolean handle(GamePhase phase, Vector<Report> vPhaseReport) {
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down Expand Up @@ -436,7 +436,7 @@ public boolean handleAeroSanity(GamePhase phase, Vector<Report> vPhaseReport) {
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/weapons/BombAttackHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public boolean handle(GamePhase phase, Vector<Report> vPhaseReport) {
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down
4 changes: 2 additions & 2 deletions megamek/src/megamek/common/weapons/CLIATMHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ public boolean handle(GamePhase phase, Vector<Report> vPhaseReport) {
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down Expand Up @@ -643,7 +643,7 @@ public boolean handle(GamePhase phase, Vector<Report> vPhaseReport) {
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public boolean handle(GamePhase phase, Vector<Report> vPhaseReport) {
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down Expand Up @@ -641,7 +641,7 @@ public boolean handleAeroSanity(GamePhase phase, Vector<Report> vPhaseReport) {
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public boolean handle(GamePhase phase, Vector<Report> vPhaseReport) {
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ && getParentBayHandler() != null) {
r = new Report(3155);
r.newlines = 0;
r.subject = subjectId;
r.add(roll);
r.addDataWithTooltip(String.valueOf(roll), rollReport);
vPhaseReport.addElement(r);

// do we hit?
Expand Down
Loading
Loading