-
Notifications
You must be signed in to change notification settings - Fork 56
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
Apply damage to original attack target #368
Apply damage to original attack target #368
Conversation
dont show context menu or button to apply damage unless possible
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 haven't been able to test the changes, but everything here looks reasonable to me. I left some general code quality questions.
- extract `applyDamageToTarget` function - return early - improve ui errors to edge cases
src/module/chat.ts
Outdated
case CONFIG.OSE.apply_damage_options.selected: | ||
return !!canvas.tokens?.controlled.length; | ||
default: { | ||
console.log('unknown setting'); |
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 we should make this more specific, and a UI warning. We shouldn't end up here, but if we do, it'd be helpful if a user could tell us how they got here!
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.
done
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.
@bakbakbakbakbak Just a heads up, I forget if you had tests written for this file or the other stuff in this PR, but this might change things for you.
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.
Thanks for the notice, I'll take a look at this
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.
probably best to revisit in a later revision of 0.8.x and leave the test as-is until after merging. We're probably expecting a non-zero amount of other surprises after such a large merge
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, I am having quite a bit on my plate right now either, and I have noticed that I procrastinate on this check here.
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'm good with the changes here, but I'd appreciate if someone else could have a look!
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.
The PR didn't seem to work as intended (got the new UI error message with each attack attempt) and in debugging I discovered a cause, shown below
src/module/config.ts
Outdated
apply_damage_options: { | ||
selected : "selected", | ||
targeted : "selected", | ||
originalTarget : "selected", | ||
}, |
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 causes an error in the switch statement. It will always be the default case unless selected
is the selected system setting
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.
eeek!
done
<div class="chat-target"> | ||
vs {{result.victim}} | ||
<div class="chat-target" data-id="{{result.victim.document.uuid}}"> | ||
vs {{result.victim.name}} |
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 like this :)
src/module/chat.ts
Outdated
case CONFIG.OSE.apply_damage_options.selected: | ||
return !!canvas.tokens?.controlled.length; | ||
default: { | ||
ui.notifications?.error(`unexpected OSE setting applyDamageOption: ${applyDamageOption}`); |
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.
Since I'm requesting changes, I think it's appropriate to ask to use a localized string here
Add the string itself to en.json
only, under the other error strings
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.
done
- fix `apply_damage_options` mistake - make ui messages support multilanguage
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.
Confirmed working in Foundry
LGTM
@@ -11,7 +11,10 @@ function canApplyDamage(html: JQuery) { | |||
case CONFIG.OSE.apply_damage_options.selected: | |||
return !!canvas.tokens?.controlled.length; | |||
default: { | |||
ui.notifications?.error(`unexpected OSE setting applyDamageOption: ${applyDamageOption}`); | |||
ui.notifications?.error(game.i18n.format("OSE.error.unexpectedSettings", { | |||
configName: 'applyDamageOption', |
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.
Oh nice, good idea :D
Thanks for your contribution @amir-arad 🎉 @all-contributors please add @amir-arad for code |
I couldn't determine any contributions to add, did you specify any contributions? I've put up a pull request to add @amir-arad! 🎉 |
@amir-arad please also take a look at #59 and tell me your preferred name and optional email for entering in the AUTHORS file :) |
Add the possibility to inflict damage from an attack to the original target of the attack. The original target is determined at the time of the attack, so even if the atytacking player changed target the damage will go to the right actor.
Protected by
applyDamageOption
(preexisting) feature flagfixes #287