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

Apply damage to original attack target #368

Merged
merged 7 commits into from
Mar 28, 2023

Conversation

amir-arad
Copy link
Contributor

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 flag

fixes #287

image

Copy link
Collaborator

@wyrmisis wyrmisis left a 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.

src/module/chat.ts Outdated Show resolved Hide resolved
src/module/chat.ts Outdated Show resolved Hide resolved
src/module/chat.ts Outdated Show resolved Hide resolved
 - extract `applyDamageToTarget` function
 - return early
 - improve ui errors to edge cases
@amir-arad amir-arad requested a review from wyrmisis March 20, 2023 17:56
case CONFIG.OSE.apply_damage_options.selected:
return !!canvas.tokens?.controlled.length;
default: {
console.log('unknown setting');
Copy link
Collaborator

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

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.

Copy link
Collaborator

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

Copy link
Member

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

Copy link
Collaborator

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.

Copy link
Collaborator

@wyrmisis wyrmisis left a 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!

@wyrmisis wyrmisis dismissed their stale review March 21, 2023 21:44

Changes addressed; re-reviewed.

@amir-arad amir-arad requested review from wyrmisis and anthonyronda and removed request for wyrmisis and anthonyronda March 28, 2023 09:27
Copy link
Member

@anthonyronda anthonyronda left a 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

Comment on lines 137 to 141
apply_damage_options: {
selected : "selected",
targeted : "selected",
originalTarget : "selected",
},
Copy link
Member

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

Copy link
Contributor Author

@amir-arad amir-arad Mar 28, 2023

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}}
Copy link
Member

Choose a reason for hiding this comment

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

I like this :)

case CONFIG.OSE.apply_damage_options.selected:
return !!canvas.tokens?.controlled.length;
default: {
ui.notifications?.error(`unexpected OSE setting applyDamageOption: ${applyDamageOption}`);
Copy link
Member

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

Copy link
Contributor Author

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
@amir-arad amir-arad requested a review from anthonyronda March 28, 2023 18:25
Copy link
Member

@anthonyronda anthonyronda left a 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',
Copy link
Member

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

@anthonyronda anthonyronda merged commit 1459044 into vttred:main Mar 28, 2023
@anthonyronda
Copy link
Member

Thanks for your contribution @amir-arad 🎉

@all-contributors please add @amir-arad for code

@allcontributors
Copy link
Contributor

@anthonyronda

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

I've put up a pull request to add @amir-arad! 🎉

@anthonyronda
Copy link
Member

@amir-arad please also take a look at #59 and tell me your preferred name and optional email for entering in the AUTHORS file :)

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.

Make damage be dealt to player target token
4 participants