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 triggers to resource income #3236

Merged
merged 3 commits into from
Mar 6, 2018
Merged

Conversation

ron-murhammer
Copy link
Member

Follow up of #3035

Functional Changes

  • Resource income now takes into account NO triggers as well

Tests

  • Best test is to open Global 40 2nd before the change you see +35 PU income for Germany and after you see the correct +40 PU income
  • Tested on revised, v3, global, and civil war to ensure they function

@codecov-io
Copy link

codecov-io commented Mar 6, 2018

Codecov Report

Merging #3236 into master will increase coverage by 0.46%.
The diff coverage is 90.47%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3236      +/-   ##
============================================
+ Coverage     21.01%   21.47%   +0.46%     
- Complexity     5672     5803     +131     
============================================
  Files           830      830              
  Lines         72732    72749      +17     
  Branches      11862    11863       +1     
============================================
+ Hits          15282    15622     +340     
+ Misses        55426    55031     -395     
- Partials       2024     2096      +72
Impacted Files Coverage Δ Complexity Δ
...tegy/triplea/delegate/AbstractEndTurnDelegate.java 6.37% <100%> (+5.26%) 8 <0> (+6) ⬆️
...trategy/triplea/attachments/TriggerAttachment.java 34.2% <100%> (+3.55%) 158 <2> (+16) ⬆️
...mes/strategy/triplea/delegate/EndTurnDelegate.java 19.19% <83.33%> (+18.72%) 10 <3> (+8) ⬆️
...in/java/games/strategy/engine/data/GameParser.java 69.6% <0%> (+0.12%) 175% <0%> (+1%) ⬆️
.../java/games/strategy/triplea/delegate/Matches.java 45.72% <0%> (+0.96%) 363% <0%> (+7%) ⬆️
...strategy/triplea/delegate/SpecialMoveDelegate.java 0.99% <0%> (+0.99%) 1% <0%> (+1%) ⬆️
...s/strategy/triplea/attachments/UnitAttachment.java 42.04% <0%> (+1.08%) 242% <0%> (+10%) ⬆️
...ategy/triplea/attachments/TerritoryAttachment.java 40.04% <0%> (+1.47%) 57% <0%> (+3%) ⬆️
...c/main/java/games/strategy/triplea/Properties.java 71.85% <0%> (+1.48%) 96% <0%> (+2%) ⬆️
...ames/strategy/engine/data/RelationshipTracker.java 66.66% <0%> (+1.85%) 11% <0%> (ø) ⬇️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bfcaefe...d8590ba. Read the comment docs.

Copy link
Member

@ssoloff ssoloff left a comment

Choose a reason for hiding this comment

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

Sorry, I'm not going to have a chance to test this tonight. If it's not merged by tomorrow afternoon, I should have time to do it then.

However, the unit test coverage actually looks pretty good. I know Codecov only says there's ~26% coverage, but after running the new unit test from the IDE, it looks like most of the important stuff is hit. There's a few branches that are missed but not too bad.


private static IntegerMap<Resource> triggerResourceChange(final Set<TriggerAttachment> satisfiedTriggers,
final IDelegateBridge bridge, final String beforeOrAfter, final String stepName, final boolean useUses,
final boolean testUses, final boolean testChance, final boolean testWhen, final StringBuilder strbuf) {
Copy link
Member

Choose a reason for hiding this comment

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

Since this method already has a lot of parameters, the new out parameter kind of gets buried. Might want to consider returning a composite type that contains both the IntegerMap and the String. Lombok should make creating such a value type pretty lightweight.

Otherwise, at least documenting that strbuf is an output parameter would be useful. Also, a description in the Javadocs of what it will contain, or just renaming the variable, would be great, as strbuf isn't very descriptive.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll just rename for now. I eventually want to refactor it further so the string for end turn report is done at the end.

*/
public static int findNationalObjectivePus(final PlayerID player, final GameData data, final IDelegateBridge bridge) {
public static IntegerMap<Resource> findNationalObjectiveAndTriggerResources(final PlayerID player,
Copy link
Member

Choose a reason for hiding this comment

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

This method appears to only be called from AbstractEndTurnDelegate. Can it be moved there and made private, or do you have plans for it in a forthcoming PR? (Moving it would also get rid of one more instance of that smell in AbstractEndTurnDelegate where a superclass calls a static method in a subclass.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I'm leaving it there for now as its similar to the method below it and want to further refactor them.

testNationalObjectivesAndTriggers(player, data, bridge, triggers, objectives);

// Find triggers value
IntegerMap<Resource> resources = new IntegerMap<>();
Copy link
Member

Choose a reason for hiding this comment

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

resources could be made final with an else block below that initializes it to an empty map.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Member

@ssoloff ssoloff left a comment

Choose a reason for hiding this comment

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

Tested with a few maps. No issues observed.

@ssoloff ssoloff merged commit 88a0b17 into master Mar 6, 2018
@RoiEXLab RoiEXLab deleted the Add_Triggers_To_Resource_Income branch March 6, 2018 17:03
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.

None yet

3 participants