-
Notifications
You must be signed in to change notification settings - Fork 57
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
Chore: rip out v9 compatibility and other chore commits #262
Chore: rip out v9 compatibility and other chore commits #262
Conversation
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.
Great set of changes. I have a bunch of conceptual questions and "while we're in there" fixes to suggest.
src/module/actor/actor-sheet.js
Outdated
@@ -122,7 +122,7 @@ export class OseActorSheet extends ActorSheet { | |||
*/ | |||
_useConsumable(event, decrement) { | |||
const item = this._getItemFromActor(event); | |||
const itemData = item?.system || item?.data?.data; //v9-compatibility | |||
const itemData = item?.system; | |||
|
|||
if (decrement) { | |||
item.update({ "data.quantity.value": itemData.quantity.value - 1 }); |
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.
We should replace these data.[...]
updates with system.[...]
.
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.
Yes, thanks for the catch. If I haven't caught every remaining data reference, I've at least taken care of the ones in document update methods in today's first commit
src/module/actor/actor-sheet.js
Outdated
@@ -187,7 +187,7 @@ export class OseActorSheet extends ActorSheet { | |||
let element = event.currentTarget; | |||
let attack = element.parentElement.parentElement.dataset.attack; | |||
const rollData = { | |||
actor: isNewerVersion(game.version, "10.264") ? this : this.data, //v9-compatibility | |||
actor: 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.
Isn't this
the OseActorSheet
(or subclass) 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.
this
is OseActorSheetCharacter
. _rollAttack()
is only used for "improvised melee" and "improvised ranged" (by clicking on the MEL and MIS headers of the melee and missile bonus boxes).
Because it appeared targetAttack()
will take either one for the roll data without complaint, I looked into the reason...it's completely ignored
removed rollData
as irrelevant in my third commit today
src/module/actor/actor-sheet.js
Outdated
@@ -187,7 +187,7 @@ export class OseActorSheet extends ActorSheet { | |||
let element = event.currentTarget; | |||
let attack = element.parentElement.parentElement.dataset.attack; | |||
const rollData = { | |||
actor: isNewerVersion(game.version, "10.264") ? this : this.data, //v9-compatibility | |||
actor: this, | |||
roll: {}, | |||
}; | |||
actorObject.targetAttack(rollData, attack, { |
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.
Thoughts on setting rolldata
on the actor instead of the actor sheet? Do we need to give rollData
the actor sheet?
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.
rollData has been removed from the function (see last comment)
@@ -204,7 +204,7 @@ export class OseActorSheet extends ActorSheet { | |||
const dropTarget = event.target.closest("[data-item-id]"); | |||
const targetId = dropTarget ? dropTarget.dataset.itemId : null; | |||
const target = siblings.find((s) => s.data._id === targetId); | |||
const targetData = target?.system || target?.data?.data; //v9-compatibility | |||
const targetData = target?.system; |
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.
Should we bail if there's no target?
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 there will be a merge conflict with your item data model code here
For now, I did decide to throw an error which might be a good idea in other places where we can think of a useful error to write for debugging
src/module/item/item-sheet.js
Outdated
@@ -72,11 +72,11 @@ export class OseItemSheet extends ItemSheet { | |||
this.object.popManualTag(value); | |||
}); | |||
html.find("a.melee-toggle").click(() => { | |||
this.object.update({ data: { melee: !this.object.data.data.melee } }); | |||
this.object.update({ data: { melee: !this.object.system.melee } }); |
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.object.update({ 'system.melee': !this.object.system.melee })
src/module/macros.js
Outdated
@@ -15,7 +15,7 @@ export async function createOseMacro(data, slot) { | |||
return ui.notifications.warn( | |||
game.i18.localize("OSE.warn.macrosOnlyForOwnedItems") | |||
); | |||
const item = data.data; | |||
const item = data; |
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.
Why not just rename the param above to item
?
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.
oops, turns out this is not an Item document object after all! So this code change breaks the (probably not often used) ability to drag an item from your sheet to your macro bar to create a roll macro (or if there is no roll for the item, a "view item" macro)
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 change has been undone. I'd like to refactor this as part of a different PR
src/module/party/party.js
Outdated
act.data.flags[systemName] && | ||
act.data.flags[systemName].party === true); | ||
console.log(characters) | ||
const systemName = game.system.id == "ose" ? game.system.id : "ose-dev"; |
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.
Can this come from CONFIG.OSE
?
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.
addressed in third commit today named "fix: one-use keys..."
src/module/party/party.js
Outdated
(act) => | ||
act.type === "character" && | ||
act.flags[systemName] && | ||
act.flags[systemName].party === true |
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.
Could this prop intentionally be a truthy value that isn't true
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 did a cursory check of setFlag in the repo and only found "party" only ever getting set to true or false
src/templates/apps/party-sheet.html
Outdated
{{localize 'OSE.dialog.xp.label'}} | ||
</button> | ||
{{/if}} | ||
</div> | ||
<div class="body party-members"> | ||
{{#if user.isGM}} | ||
{{#if (eq partyActors.length 0)}} | ||
{{#if user.isGM}} {{#if (eq partyActors.length 0)}} |
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.
Rather than nesting ifs, could we add a prop to the backing JS file for 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.
Hope you'll accept this solution to eliminate nesting ifs
The and
helper is from foundry.js
still working on this PR There's a problem with drag and drop I'm starting to diagnose and I don't know where they got introduced |
itemIds.push(itemData.id); | ||
const item = this.actor.items.get(itemData[0]._id); | ||
await item.update({ system: { containerId: container.id } }); | ||
await container.update({ system: { itemIds: itemIds } }); |
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.
There are some places where we return promises, and others where we await promises in place at the end of a function. I don't think we have to standardize it for this PR, especially if we're not sure how long this sheet is going to stick around, but it might be good to hammer out the pattern we want to use.
@@ -456,11 +402,11 @@ export class OseActorSheet extends ActorSheet { | |||
|
|||
if (event.target.dataset.field === "value") { |
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.
We could probably DRY up blocks like this so we only call item.update
in one spot, like so:
() => {
const {field} = event.target.dataset;
if (field !== 'value' && field !== 'max')
throw new Error('Malformed update call when updating item quantity');
return item.update({
[`system.quantity.${field}]: parseInt(event.target.value)
});
}
Not worth holding the PR up for, just a thought
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.
Looks good to me
Tests: 395/395 passing
I placed the
--ignore-scripts
flag on thenpm ci
command after verifying locally that current dependencies do not have required postinstall scripts fornpm run build
to function properly