-
Notifications
You must be signed in to change notification settings - Fork 334
TargetRoll modernization #5696
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
TargetRoll modernization #5696
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5696 +/- ##
============================================
- Coverage 29.34% 29.33% -0.01%
+ Complexity 13868 13867 -1
============================================
Files 2466 2467 +1
Lines 263322 263338 +16
Branches 47174 47166 -8
============================================
- Hits 77264 77251 -13
- Misses 182170 182202 +32
+ Partials 3888 3885 -3 ☔ View full report in Codecov by Sentry. |
| toHit.addModifier(3 / dedicatedGunnerMod, "attacker used UMUs"); | ||
| } else if (entity instanceof LandAirMech && movement == EntityMovementType.MOVE_VTOL_WALK) { | ||
| toHit.addModifier(3, "attacker cruised"); | ||
| toHit.addModifier(3 / dedicatedGunnerMod, "attacker cruised"); | ||
| } else if (entity instanceof LandAirMech && movement == EntityMovementType.MOVE_VTOL_RUN) { | ||
| toHit.addModifier(4, "attacker flanked"); | ||
| toHit.addModifier(4 / dedicatedGunnerMod, "attacker flanked"); | ||
| } else if ((movement == EntityMovementType.MOVE_WALK) || (movement == EntityMovementType.MOVE_VTOL_WALK) | ||
| || (movement == EntityMovementType.MOVE_CAREFUL_STAND)) { | ||
| toHit.addModifier(1, "attacker walked"); | ||
| toHit.addModifier(1 / dedicatedGunnerMod, "attacker walked"); | ||
| } else if ((movement == EntityMovementType.MOVE_RUN) || (movement == EntityMovementType.MOVE_VTOL_RUN)) { | ||
| toHit.addModifier(2, "attacker ran"); | ||
| toHit.addModifier(2 / dedicatedGunnerMod, "attacker ran"); | ||
| } else if (movement == EntityMovementType.MOVE_SKID) { | ||
| toHit.addModifier(3, "attacker ran and skidded"); | ||
| toHit.addModifier(3 / dedicatedGunnerMod, "attacker ran and skidded"); | ||
| } else if (movement == EntityMovementType.MOVE_JUMP) { | ||
| if (entity.hasAbility(OptionsConstants.PILOT_JUMPING_JACK)) { | ||
| toHit.addModifier(1, "attacker jumped"); | ||
| toHit.addModifier(1 / dedicatedGunnerMod, "attacker jumped"); | ||
| } else if (entity.hasAbility(OptionsConstants.PILOT_HOPPING_JACK)) { | ||
| toHit.addModifier(2, "attacker jumped"); | ||
| toHit.addModifier(2 / dedicatedGunnerMod, "attacker jumped"); | ||
| } else { | ||
| toHit.addModifier(3, "attacker jumped"); | ||
| toHit.addModifier(3 / dedicatedGunnerMod, "attacker jumped"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we can get non-integer results here, which I believe Java will round down.
- is that expected behavior?
- do we check anywhere that this code produces the expected results for every combination?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think so as it was like that before
- No. Currently there are no combinations, this method only returns a single modifier. I did not check the rules as - see 1. :)
| return switch (total) { | ||
| case IMPOSSIBLE -> "Impossible"; | ||
| case AUTOMATIC_FAIL -> "Automatic Failure"; | ||
| case AUTOMATIC_SUCCESS -> "Automatic Success"; | ||
| case CHECK_FALSE -> "Did not need to roll"; | ||
| default -> Integer.toString(total); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So fresh and so clean!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah :) although strictly speaking this should be localized...
| return modifier.getValue() == AUTOMATIC_FAIL || modifier.getValue() == AUTOMATIC_SUCCESS | ||
| || modifier.getValue() == IMPOSSIBLE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be accomplished fairly quickly and cleanly with:
return Set.of(AUTOMATIC_FAIL, AUTOMATIC_SUCCESS, IMPOSSIBLE).contains(modifier.getValue());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of questions/comments but overall looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This modernizes some very old code of TargetRoll and TargetRollModifier. TargetRollModifier is now immutable for which I had to adapt two places in Compute. Also updates the test for TargetRoll.