Converted lots of document access to V10.
This commit is contained in:
@@ -26,9 +26,8 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
return Promise.resolve(super.getData(options)).then(context => {
|
||||
actor.prepareDerivedData()
|
||||
|
||||
const actorData = (actor as any).data.toObject(false)
|
||||
context.actor = actorData;
|
||||
context.data = actorData.data;
|
||||
context.actor = (actor as any).toObject(false)
|
||||
context.data = (actor as any).system
|
||||
|
||||
//console.log("Sheet Promise", context.actor, context.data)
|
||||
return context
|
||||
@@ -95,7 +94,7 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
itemId = row.dataset["item"]
|
||||
}
|
||||
|
||||
const context = this.actor.data
|
||||
const context = this.actor as any
|
||||
const item = context.items.get(itemId)
|
||||
console.log("edit-item", item)
|
||||
item.sheet.render(true)
|
||||
@@ -111,7 +110,7 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
itemId = row.dataset["item"]
|
||||
}
|
||||
|
||||
const context = this.actor.data
|
||||
const context = this.actor as any
|
||||
const item = context.items.get(itemId)
|
||||
item.delete()
|
||||
this.render(false)
|
||||
@@ -122,10 +121,7 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
let skillId = row.dataset["item"]
|
||||
|
||||
const actor = this.actor as any
|
||||
const context = this.actor.data
|
||||
const data = context.data
|
||||
|
||||
const item = context.items.get(skillId) as M5Item
|
||||
const item = actor.items.get(skillId) as M5Item
|
||||
await item.roll()
|
||||
})
|
||||
|
||||
@@ -134,8 +130,8 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
let skillName = row.dataset["skill"]
|
||||
|
||||
const actor = this.actor as M5Character
|
||||
const context = this.actor.data
|
||||
const data = context.data
|
||||
const context = this.actor as any
|
||||
const data = context.system
|
||||
|
||||
const skill = data.skills.general[skillName]
|
||||
const attribute = data.attributes[skill.attribute]
|
||||
@@ -161,7 +157,7 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
const row = event.target.parentElement.parentElement
|
||||
let skillName = row.dataset["skill"]
|
||||
|
||||
const data = this.actor.data.data
|
||||
const data = this.actor.system
|
||||
const unlearnedSkill = data.skills.general[skillName] as M5SkillUnlearned
|
||||
|
||||
const character = this.actor as M5Character
|
||||
@@ -182,10 +178,7 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
const row = event.target.parentElement.parentElement
|
||||
let itemId = row.dataset["item"]
|
||||
|
||||
const actor = this.actor as any
|
||||
const context = this.actor.data
|
||||
const data = context.data
|
||||
|
||||
const context = this.actor as any
|
||||
const item = context.items.get(itemId) as M5Item
|
||||
await item.roll()
|
||||
})
|
||||
@@ -219,11 +212,11 @@ export default class M5CharacterSheet extends ActorSheet {
|
||||
const item = this.actor.items.get(li.dataset.itemId)
|
||||
|
||||
// limit transfer on personal weapons/armour/gear
|
||||
if (["skill", "item", "weapon", "defensiveWeapon", "armor", "spell"].includes(item.data.type)) {
|
||||
if (["skill", "item", "weapon", "defensiveWeapon", "armor", "spell"].includes(item.type)) {
|
||||
const dragData = {
|
||||
type: "Transfer",
|
||||
actorId: this.actor.id,
|
||||
data: item.data,
|
||||
data: item.toObject(false),
|
||||
tokenId: null
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ export class M5ItemSheet extends ItemSheet {
|
||||
get template() {
|
||||
//console.log("M5ItemSheet", this.item.data.type)
|
||||
const path = "systems/midgard5/templates/sheets/item"
|
||||
return `${path}/${this.item.data.type}.hbs`
|
||||
return `${path}/${this.item.type}.hbs`
|
||||
}
|
||||
|
||||
override getData(options?: Partial<ItemSheet.Options>): ItemSheet.Data<ItemSheet.Options> | Promise<ItemSheet.Data<ItemSheet.Options>> {
|
||||
@@ -24,7 +24,7 @@ export class M5ItemSheet extends ItemSheet {
|
||||
const context = value as any
|
||||
|
||||
// Use a safe clone of the item data for further operations.
|
||||
const itemData = context.item.data
|
||||
const itemData = context.item
|
||||
|
||||
// Retrieve the roll data for TinyMCE editors.
|
||||
context.rollData = {}
|
||||
@@ -35,7 +35,7 @@ export class M5ItemSheet extends ItemSheet {
|
||||
}
|
||||
|
||||
// Add the actor's data to context.data for easier access, as well as flags.
|
||||
context.data = itemData.data
|
||||
context.system = itemData.system
|
||||
context.flags = itemData.flags
|
||||
|
||||
return context
|
||||
@@ -46,8 +46,8 @@ export class M5ItemSheet extends ItemSheet {
|
||||
super.activateListeners(html)
|
||||
|
||||
html.find(".add-mod").on("click", async (event) => {
|
||||
const context = this.object.data
|
||||
const mods = context.data.mods
|
||||
const context = this.object
|
||||
const mods = context.system.mods
|
||||
const modIndex = Object.keys(mods).length
|
||||
mods[modIndex.toString()] = {
|
||||
type: M5ModType.ATTRIBUTE,
|
||||
@@ -72,7 +72,7 @@ export class M5ItemSheet extends ItemSheet {
|
||||
itemId = row.dataset["item"]
|
||||
}
|
||||
|
||||
const context = this.item.data
|
||||
const context = this.item
|
||||
const item = context.items.get(itemId)
|
||||
item.delete()
|
||||
this.render(false)
|
||||
@@ -90,7 +90,7 @@ export class M5ItemSheet extends ItemSheet {
|
||||
rollIndex = row.dataset["roll"]
|
||||
}
|
||||
|
||||
const rolls = this.item.data.data.rolls.formulas
|
||||
const rolls = this.item.system.rolls.formulas
|
||||
rolls[rollIndex] = null
|
||||
|
||||
this.item.update({
|
||||
@@ -104,7 +104,7 @@ export class M5ItemSheet extends ItemSheet {
|
||||
})
|
||||
|
||||
html.find(".roll-create").on("click", async (event) => {
|
||||
const rolls = this.item.data.data.rolls.formulas
|
||||
const rolls = this.item.system.rolls.formulas
|
||||
|
||||
const indeces = Object.keys(rolls).map(index => parseInt(index)).sort().reverse()
|
||||
const index = (indeces.find(index => !!rolls[index.toString()]) ?? -1) + 1
|
||||
@@ -127,7 +127,7 @@ export class M5ItemSheet extends ItemSheet {
|
||||
})
|
||||
|
||||
// Drag & Drop
|
||||
if (["item"].includes(this.object.data?.type)) {
|
||||
if (["item"].includes(this.object.type)) {
|
||||
const itemToItemAssociation = new DragDrop({
|
||||
dragSelector: ".item",
|
||||
dropSelector: null,
|
||||
@@ -177,7 +177,7 @@ export class M5ItemSheet extends ItemSheet {
|
||||
}
|
||||
|
||||
if ((itemObject.type === "mod")) {
|
||||
let mods = obj?.data?.data?.mods
|
||||
let mods = obj?.system?.mods
|
||||
if (!mods)
|
||||
mods = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user