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

SPA Cross-Country #4118

Merged
merged 7 commits into from
Feb 16, 2023
Merged

SPA Cross-Country #4118

merged 7 commits into from
Feb 16, 2023

Conversation

pheonixstorm
Copy link
Collaborator

With the exception of water movement this SPA is completed. Waiting on ruling for how tanks in depth 1 water should be treated. I'm thinking they should have the same LOS and targeting rules as amphibious tanks, but you never know sometimes.

@codecov
Copy link

codecov bot commented Jan 17, 2023

Codecov Report

Base: 22.97% // Head: 22.97% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (62f1b04) compared to base (492a8d6).
Patch coverage: 3.22% of modified lines in pull request are covered.

❗ Current head 62f1b04 differs from pull request most recent head 8b3e7dd. Consider uploading reports for the commit 8b3e7dd to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4118      +/-   ##
============================================
- Coverage     22.97%   22.97%   -0.01%     
  Complexity     4824     4824              
============================================
  Files          2282     2282              
  Lines        250115   250126      +11     
  Branches      46366    46382      +16     
============================================
+ Hits          57459    57460       +1     
- Misses       191204   191214      +10     
  Partials       1452     1452              
Impacted Files Coverage Δ
megamek/src/megamek/common/Tank.java 0.97% <0.00%> (-0.01%) ⬇️
megamek/src/megamek/common/Terrain.java 0.00% <0.00%> (ø)
...k/src/megamek/common/options/OptionsConstants.java 0.00% <ø> (ø)
...gamek/src/megamek/common/options/PilotOptions.java 100.00% <100.00%> (ø)
...egamek/client/ui/swing/boardview/AttackSprite.java 0.00% <0.00%> (ø)
...c/megamek/client/ui/swing/boardview/BoardView.java 0.62% <0.00%> (+<0.01%) ⬆️
megamek/src/megamek/common/Coords.java 48.50% <0.00%> (+0.28%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@Windchild292 Windchild292 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few things first

megamek/src/megamek/common/Terrain.java Outdated Show resolved Hide resolved
megamek/src/megamek/common/Terrain.java Outdated Show resolved Hide resolved
megamek/src/megamek/common/Terrain.java Outdated Show resolved Hide resolved
@pheonixstorm
Copy link
Collaborator Author

I've started a new branch to add in the isXXX calls so this will get cleaned up after it is merged along with the original terrain code and possibly some other areas.

@pheonixstorm
Copy link
Collaborator Author

Is there anything else I need to fix so this can get approved?

@pheonixstorm
Copy link
Collaborator Author

Conflict fixed

Copy link
Member

@SJuliez SJuliez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to merge this but I have some comments (agreeing with Windchild on this)

@@ -386,29 +388,52 @@ public int movementCost(Entity e) {
} else {
mp = 1;
}

if (isCrossCountry) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to chime in.
This only checks the movement mode. WHEELED is also used by QuadVees in wheeled mode. A vehicle pilot probably shouldn't command a qv but MM doesn't prevent this. I wonder if e.isVehicle() should be added to the crossCountry boolean definiton.

Also, I agree with Windchild that repeating mp *= 2 really calls for OR-ing the two conditions or it looks like an error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first one for woods was a bug that was fixed. I can probably try to do the if/else or if/else if better, but to cram it all in a single if would make it look rather confusing imo.

As for quadvee. A check for isVee will get added just to make sure it ignores any weirdness like that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree these are usually ugly to read with all the ((()()((()((()))). But having the same result multiple times screams error or legacy issue. Maybe a solution is to add a
final boolean allowedHoverWheeled = ((moveMode == EntityMovementMode.HOVER) || (moveMode == EntityMovementMode.TRACKED)) && (level == 6);
and then if (allowedHoverWheeled || (moveMode == EntityMovementMode.WHEELED)) {
This is still shorter than the if else and readable enough I guess. What do you say?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh hoverTracked of course

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could work, I will split the changes into multiple commits for review to make it easier to revert if it doesn't look right and you decide against it. Quadvee will be first then the others.

if ((e.hasAbility(OptionsConstants.INFANTRY_FOOT_CAV)
&& (moveMode == EntityMovementMode.INF_LEG))) {
mp -= 1;
}
return Math.max(0, mp);
case Terrains.WOODS:
mp = level;
if (isCrossCountry) {
if ((level == 1) && ((moveMode == EntityMovementMode.HOVER) || (moveMode == EntityMovementMode.WHEELED))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the other, OR-ing this looks even easier as level can't be 0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it can be greater than one, and certain vehicles can't travel is certain woods levels. Woods have 3 levels, 1 is light woods, 2 is heavy woods, and 3 is ultra heavy woods. Hover and Wheeled vehicles cannot enter woods at all while tracked vehicles can only enter light woods.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I feel we're talking past each other here.
With crossCountry, what this checks is:
if Level 1 and h/w --> mp2
-also- if Level > 1 --> mp
2
That is exactly the same as if (Level 1 and h/w) -or- Level > 1 --> mp2
Which is the same as: if level > 1 -or- h/w --> mp
2 (assuming level must be > 0)
(I have not thought about the rules, only the code as it is)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

italic text not intentional

@@ -494,12 +526,24 @@ public int movementCost(Entity e) {
} else {
mp = 1;
}

if (isCrossCountry) {
if (((moveMode == EntityMovementMode.HOVER) || (moveMode == EntityMovementMode.TRACKED))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as the others

@pheonixstorm
Copy link
Collaborator Author

Changes done.

@SJuliez SJuliez merged commit 11b5ccc into MegaMek:master Feb 16, 2023
@pheonixstorm pheonixstorm deleted the SPA-CrossCountry branch February 16, 2023 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants