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

Introduce TARGET versions of failure/success notifications. #3572

Merged
merged 5 commits into from
Jul 18, 2018
Merged

Introduce TARGET versions of failure/success notifications. #3572

merged 5 commits into from
Jul 18, 2018

Conversation

asvitkine
Copy link
Contributor

@asvitkine asvitkine commented Jul 18, 2018

Introduce TARGET versions of failure/success notifications.

This allows for fixing #3558
with a corresponding change to the Feudal Japan map setting the
new properties.

Details:

TARGET_NOTIFICATION_SUCCESS will send to target(s) only.
Everyone else (not active player, not targets) will continue to receive OTHER_NOTIFICATION_SUCCESS, if it's value is not NONE (as is now).

If TARGET_NOTIFICATION_SUCCESS does not exist in the properties, then OTHER_NOTIFICATION_SUCCESS is used for everyone except active player.
This way, maps continue to work as-is unless updated.

The Feudal Japan map will be updated to add TARGET_NOTIFICATION_SUCCESS
and set OTHER_NOTIFICATION_SUCCESS to NONE.

Same thing for _FAILURE notifications.

This allows for fixing #3558
with a corresponding chsange to the Feudal Japan map setting the
new property.
@codecov-io
Copy link

codecov-io commented Jul 18, 2018

Codecov Report

Merging #3572 into master will decrease coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3572      +/-   ##
============================================
- Coverage     22.07%   22.07%   -0.01%     
  Complexity     5937     5937              
============================================
  Files           838      838              
  Lines         71921    71938      +17     
  Branches      11546    11546              
============================================
  Hits          15880    15880              
- Misses        53949    53966      +17     
  Partials       2092     2092
Impacted Files Coverage Δ Complexity Δ
...java/games/strategy/triplea/ui/UserActionText.java 0% <0%> (ø) 0 <0> (ø) ⬇️
.../strategy/triplea/delegate/UserActionDelegate.java 0% <0%> (ø) 0 <0> (ø) ⬇️

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 2c70470...90307a2. Read the comment docs.

@asvitkine asvitkine changed the title Introduce PARTICIPANTS versions of failure/success notifications. Introduce TARGET versions of failure/success notifications. Jul 18, 2018
dontSendTo.add(player);

final Collection<PlayerID> otherPlayers = getData().getPlayerList().getPlayers();
otherPlayers.remove(player);
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to move otherPlayers to after the first sendNotificationToPlayers call since it isn't used until the second call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, done.

if (hasMessage(actionKey, TARGET_NOTIFICATION_SUCCESS)) {
return getMessage(actionKey, TARGET_NOTIFICATION_SUCCESS);
} else {
return getNotificationSuccessOthers(actionKey);
Copy link
Member

Choose a reason for hiding this comment

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

Not following this logic. Shouldn't this return "NONE"?

Copy link
Contributor Author

@asvitkine asvitkine Jul 18, 2018

Choose a reason for hiding this comment

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

This is so maps that implement OTHER notifications continue to work as-is. That is, if TARGET is not specified then OTHER is sent to all other players, as is now.

There are other ways to do this, such as returning NONE and having logic in the caller to check for that and in the case of NONE, send OTHER to all players. This way is actually a bit cleaner since the caller doesn't need to have complicated logic to handle it.

But this way is also more flexible - for example if mapmaker wanted to only send notifications to players and others, but not target - they can do it with this set up (by setting TARGET to NONE). If we instead did it the other way, then this wouldn't be possible.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I now see what you are doing here. I'm fine with that as I was just thinking about it the first way you describe.

if (hasMessage(actionKey, TARGET_NOTIFICATION_FAILURE)) {
return getMessage(actionKey, TARGET_NOTIFICATION_FAILURE);
} else {
return getNotificationFailureOthers(actionKey);
Copy link
Member

Choose a reason for hiding this comment

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

Not following this logic. Shouldn't this return "NONE"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See above.

@ron-murhammer
Copy link
Member

@asvitkine Looks pretty good. Added a few comments.

@ron-murhammer ron-murhammer merged commit 5e2a3f3 into triplea-game:master Jul 18, 2018
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