Working on Compatibility for FVTT v10
This commit is contained in:
@@ -16,12 +16,12 @@ export class ActorL5r5e extends Actor {
|
||||
data.img = `${CONFIG.l5r5e.paths.assets}icons/actors/${data.type}.svg`;
|
||||
}
|
||||
|
||||
// Some tweak on actors token
|
||||
data.token = data.token || {};
|
||||
// Some tweak on actors prototypeToken
|
||||
data.prototypeToken = data.prototypeToken || {};
|
||||
switch (data.type) {
|
||||
case "character":
|
||||
foundry.utils.mergeObject(
|
||||
data.token,
|
||||
data.prototypeToken,
|
||||
{
|
||||
// vision: true,
|
||||
// dimSight: 30,
|
||||
@@ -41,7 +41,7 @@ export class ActorL5r5e extends Actor {
|
||||
|
||||
case "npc":
|
||||
foundry.utils.mergeObject(
|
||||
data.token,
|
||||
data.prototypeToken,
|
||||
{
|
||||
actorLink: true,
|
||||
disposition: 0, // neutral
|
||||
@@ -58,7 +58,7 @@ export class ActorL5r5e extends Actor {
|
||||
|
||||
case "army":
|
||||
foundry.utils.mergeObject(
|
||||
data.token,
|
||||
data.prototypeToken,
|
||||
{
|
||||
actorLink: true,
|
||||
disposition: 0, // neutral
|
||||
@@ -94,22 +94,25 @@ export class ActorL5r5e extends Actor {
|
||||
context.pack = this.pack;
|
||||
|
||||
// NPC switch between types : Linked actor for Adversary, unlinked for Minion
|
||||
if (!!data["data.type"] && this.data.type === "npc" && data["data.type"] !== this.data.data.type) {
|
||||
data["token.actorLink"] = data["data.type"] === "adversary";
|
||||
if (!!data["system.type"] && this.type === "npc" && data["system.type"] !== this.system.type) {
|
||||
data["prototypeToken.actorLink"] = data["system.type"] === "adversary";
|
||||
}
|
||||
|
||||
// Only on linked Actor
|
||||
if (!!data["token.actorLink"] || (data["token.actorLink"] === undefined && this.data.token.actorLink)) {
|
||||
if (
|
||||
!!data["prototypeToken.actorLink"] ||
|
||||
(data["prototypeToken.actorLink"] === undefined && this.prototypeToken?.actorLink)
|
||||
) {
|
||||
// Update the token name/image if the sheet name/image changed, but only if
|
||||
// they was previously the same, and token img was not set in same time
|
||||
["name", "img"].forEach((fieldName) => {
|
||||
Object.entries({ name: "name", img: "texture.src" }).forEach(([dataProp, TknProp]) => {
|
||||
if (
|
||||
data[fieldName] &&
|
||||
!data["token." + fieldName] &&
|
||||
this.data[fieldName] === this.data.token[fieldName] &&
|
||||
this.data[fieldName] !== data[fieldName]
|
||||
data[dataProp] &&
|
||||
!data["prototypeToken." + TknProp] &&
|
||||
this[dataProp] === foundry.utils.getProperty(this.prototypeToken, TknProp) &&
|
||||
this[dataProp] !== data[dataProp]
|
||||
) {
|
||||
data["token." + fieldName] = data[fieldName];
|
||||
data["prototypeToken." + TknProp] = data[dataProp];
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -128,36 +131,37 @@ export class ActorL5r5e extends Actor {
|
||||
super.prepareData();
|
||||
|
||||
if (this.isCharacter) {
|
||||
const data = this.data.data;
|
||||
const system = this.system;
|
||||
|
||||
// No automation for npc as they cheat in stats
|
||||
if (this.data.type === "character") {
|
||||
ActorL5r5e.computeDerivedAttributes(data);
|
||||
if (this.type === "character") {
|
||||
ActorL5r5e.computeDerivedAttributes(system);
|
||||
}
|
||||
|
||||
// Attributes bars
|
||||
data.fatigue.max = data.endurance;
|
||||
data.strife.max = data.composure;
|
||||
data.void_points.max = data.rings.void;
|
||||
system.fatigue.max = system.endurance;
|
||||
system.strife.max = system.composure;
|
||||
system.void_points.max = system.rings.void;
|
||||
|
||||
// if compromise, vigilance = 1
|
||||
data.is_compromised = data.strife.value > data.strife.max;
|
||||
system.is_compromised = system.strife.value > system.strife.max;
|
||||
|
||||
// Make sure void points are never greater than max
|
||||
if (data.void_points.value > data.void_points.max) {
|
||||
data.void_points.value = data.void_points.max;
|
||||
if (system.void_points.value > system.void_points.max) {
|
||||
system.void_points.value = system.void_points.max;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set derived attributes (endurance, composure, focus, vigilance) from rings values
|
||||
* @param {Object} system
|
||||
*/
|
||||
static computeDerivedAttributes(data) {
|
||||
data.endurance = (Number(data.rings.earth) + Number(data.rings.fire)) * 2;
|
||||
data.composure = (Number(data.rings.earth) + Number(data.rings.water)) * 2;
|
||||
data.focus = Number(data.rings.air) + Number(data.rings.fire);
|
||||
data.vigilance = Math.ceil((Number(data.rings.air) + Number(data.rings.water)) / 2);
|
||||
static computeDerivedAttributes(system) {
|
||||
system.endurance = (Number(system.rings.earth) + Number(system.rings.fire)) * 2;
|
||||
system.composure = (Number(system.rings.earth) + Number(system.rings.water)) * 2;
|
||||
system.focus = Number(system.rings.air) + Number(system.rings.fire);
|
||||
system.vigilance = Math.ceil((Number(system.rings.air) + Number(system.rings.water)) / 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,8 +191,8 @@ export class ActorL5r5e extends Actor {
|
||||
*/
|
||||
async _updateActorFromAdvancement(item, isAdd) {
|
||||
if (item && item.type === "advancement") {
|
||||
const actor = foundry.utils.duplicate(this.data.data);
|
||||
const itemData = item.data.data;
|
||||
const actor = foundry.utils.duplicate(this.system);
|
||||
const itemData = item.system;
|
||||
if (itemData.advancement_type === "ring") {
|
||||
// Ring
|
||||
if (isAdd) {
|
||||
@@ -216,7 +220,7 @@ export class ActorL5r5e extends Actor {
|
||||
|
||||
// Update Actor
|
||||
await this.update({
|
||||
data: foundry.utils.diffObject(this.data.data, actor),
|
||||
system: foundry.utils.diffObject(this.system, actor),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -226,8 +230,8 @@ export class ActorL5r5e extends Actor {
|
||||
* @return {Promise<string|null>}
|
||||
*/
|
||||
async renderTextTemplate() {
|
||||
const data = (await this.sheet?.getData()) || this;
|
||||
const tpl = await renderTemplate(`${CONFIG.l5r5e.paths.templates}actors/actor-text.html`, data);
|
||||
const sheetData = (await this.sheet?.getData()) || this;
|
||||
const tpl = await renderTemplate(`${CONFIG.l5r5e.paths.templates}actors/actor-text.html`, sheetData);
|
||||
if (!tpl) {
|
||||
return null;
|
||||
}
|
||||
@@ -239,7 +243,7 @@ export class ActorL5r5e extends Actor {
|
||||
* @return {boolean}
|
||||
*/
|
||||
get isCharacter() {
|
||||
return ["character", "npc"].includes(this.data.type);
|
||||
return ["character", "npc"].includes(this.type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,7 +251,7 @@ export class ActorL5r5e extends Actor {
|
||||
* @return {boolean}
|
||||
*/
|
||||
get haveWeaponEquipped() {
|
||||
return this.items.some((e) => e.type === "weapon" && !!e.data.data.equipped);
|
||||
return this.items.some((e) => e.type === "weapon" && !!e.system.equipped);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,7 +259,7 @@ export class ActorL5r5e extends Actor {
|
||||
* @return {boolean}
|
||||
*/
|
||||
get haveWeaponReadied() {
|
||||
return this.items.some((e) => e.type === "weapon" && !!e.data.data.equipped && !!e.data.data.readied);
|
||||
return this.items.some((e) => e.type === "weapon" && !!e.system.equipped && !!e.system.readied);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,7 +267,7 @@ export class ActorL5r5e extends Actor {
|
||||
* @return {boolean}
|
||||
*/
|
||||
get haveArmorEquipped() {
|
||||
return this.items.some((e) => e.type === "armor" && !!e.data.data.equipped);
|
||||
return this.items.some((e) => e.type === "armor" && !!e.system.equipped);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,9 +286,9 @@ export class ActorL5r5e extends Actor {
|
||||
};
|
||||
|
||||
// Prepared is a boolean or if null we get the info in the actor
|
||||
let isPrepared = this.data.type === "character" ? cfg.character : cfg[this.data.data.type];
|
||||
let isPrepared = this.type === "character" ? cfg.character : cfg[this.system.type];
|
||||
if (isPrepared === "null") {
|
||||
isPrepared = this.data.data.prepared ? "true" : "false";
|
||||
isPrepared = this.system.prepared ? "true" : "false";
|
||||
}
|
||||
|
||||
return isPrepared;
|
||||
@@ -298,7 +302,7 @@ export class ActorL5r5e extends Actor {
|
||||
if (!this.isCharacter) {
|
||||
return null;
|
||||
}
|
||||
return Math.floor(this.data.data.social.status / 10);
|
||||
return Math.floor(this.system.social.status / 10);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,7 +313,7 @@ export class ActorL5r5e extends Actor {
|
||||
if (!this.isCharacter) {
|
||||
return null;
|
||||
}
|
||||
return this.data.type === "npc" ? this.data.data.conflict_rank.social : this.data.data.identity.school_rank;
|
||||
return this.type === "npc" ? this.system.conflict_rank.social : this.system.identity.school_rank;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,6 +324,6 @@ export class ActorL5r5e extends Actor {
|
||||
if (!this.isCharacter) {
|
||||
return null;
|
||||
}
|
||||
return this.data.type === "npc" ? this.data.data.conflict_rank.martial : this.data.data.identity.school_rank;
|
||||
return this.type === "npc" ? this.system.conflict_rank.martial : this.system.identity.school_rank;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
* @private
|
||||
*/
|
||||
_initialize() {
|
||||
const data = this.object.data.data;
|
||||
const data = this.object.system;
|
||||
|
||||
// update linked actor datas
|
||||
if (data.commander_actor_id) {
|
||||
@@ -79,10 +79,13 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
*/
|
||||
activateEditor(name, options = {}, initialContent = "") {
|
||||
// Symbols Compatibility with old compendium modules (PRE l5r v1.7.2)
|
||||
if (["data.army_abilities", "data.supplies_logistics", "data.past_battles"].includes(name) && initialContent) {
|
||||
if (
|
||||
["system.army_abilities", "system.supplies_logistics", "system.past_battles"].includes(name) &&
|
||||
initialContent
|
||||
) {
|
||||
initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false);
|
||||
}
|
||||
super.activateEditor(name, options, initialContent);
|
||||
return super.activateEditor(name, options, initialContent);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +103,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
// Casualties/Panic +/-
|
||||
html.find(".addsub-control").on("click", this._modifyCasualtiesOrPanic.bind(this));
|
||||
|
||||
if (this.actor.data.data.soft_locked) {
|
||||
if (this.actor.system.soft_locked) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,12 +112,19 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
getData(options = {}) {
|
||||
const sheetData = super.getData(options);
|
||||
async getData(options = {}) {
|
||||
const sheetData = await super.getData(options);
|
||||
|
||||
// Split Items by types
|
||||
sheetData.data.splitItemsList = this._splitItems(sheetData);
|
||||
|
||||
// Editors enrichment
|
||||
for (const name of ["army_abilities", "supplies_logistics", "past_battles"]) {
|
||||
sheetData.data.enrichedHtml[name] = await TextEditor.enrichHTML(sheetData.data.system[name], {
|
||||
async: true,
|
||||
});
|
||||
}
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
@@ -143,15 +153,15 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
*/
|
||||
async _onDrop(event) {
|
||||
// *** Everything below here is only needed if the sheet is editable ***
|
||||
if (!this.isEditable || this.actor.data.data.soft_locked) {
|
||||
if (!this.isEditable || this.actor.system.soft_locked) {
|
||||
return;
|
||||
}
|
||||
|
||||
const item = await game.l5r5e.HelpersL5r5e.getDragnDropTargetObject(event);
|
||||
if (!item || item.documentName !== "Item" || !["army_cohort", "army_fortification"].includes(item.data.type)) {
|
||||
if (!item || item.documentName !== "Item" || !["army_cohort", "army_fortification"].includes(item.type)) {
|
||||
// actor dual trigger...
|
||||
if (item?.documentName !== "Actor") {
|
||||
console.warn("L5R5E | Characters items are not allowed", item?.data?.type, item);
|
||||
console.warn("L5R5E | Characters items are not allowed", item?.type, item);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -162,7 +172,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
return;
|
||||
}
|
||||
|
||||
let itemData = item.data.toObject(true);
|
||||
let itemData = item.toObject(true);
|
||||
|
||||
// Finally, create the embed
|
||||
return this.actor.createEmbeddedDocuments("Item", [itemData]);
|
||||
@@ -175,7 +185,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
*/
|
||||
async _onDropActors(type, event) {
|
||||
// *** Everything below here is only needed if the sheet is editable ***
|
||||
if (!this.isEditable || this.actor.data.data.soft_locked) {
|
||||
if (!this.isEditable || this.actor.system.soft_locked) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -211,7 +221,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
*/
|
||||
async _updateLinkedActorData(type, actor, isInit = false) {
|
||||
if (!actor || actor.documentName !== "Actor" || !actor.isCharacter) {
|
||||
console.warn("L5R5E | Wrong actor type", actor?.data?.type, actor);
|
||||
console.warn("L5R5E | Wrong actor type", actor?.type, actor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -219,26 +229,26 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
const actorData = {};
|
||||
switch (type) {
|
||||
case "commander":
|
||||
actorData["data.commander"] = actor.data.name;
|
||||
actorData["data.commander_actor_id"] = actor.data._id;
|
||||
actorData["data.commander_standing.honor"] = actor.data.data.social.honor;
|
||||
actorData["data.commander_standing.glory"] = actor.data.data.social.glory;
|
||||
actorData["data.commander_standing.status"] = actor.data.data.social.status;
|
||||
actorData["system.commander"] = actor.name;
|
||||
actorData["system.commander_actor_id"] = actor._id;
|
||||
actorData["system.commander_standing.honor"] = actor.system.social.honor;
|
||||
actorData["system.commander_standing.glory"] = actor.system.social.glory;
|
||||
actorData["system.commander_standing.status"] = actor.system.social.status;
|
||||
|
||||
// Replace the image by commander's image
|
||||
if (
|
||||
!isInit &&
|
||||
this.actor.data.img !== actor.data.img &&
|
||||
![`${actorPath}character.svg`, `${actorPath}npc.svg`].includes(actor.data.img)
|
||||
this.actor.img !== actor.img &&
|
||||
![`${actorPath}character.svg`, `${actorPath}npc.svg`].includes(actor.img)
|
||||
) {
|
||||
actorData["img"] = actor.data.img;
|
||||
actorData["token.img"] = actor.data.token.img;
|
||||
actorData["img"] = actor.img;
|
||||
actorData["prototypeToken.texture.src"] = actor.prototypeToken.texture.src;
|
||||
}
|
||||
break;
|
||||
|
||||
case "warlord":
|
||||
actorData["data.warlord"] = actor.data.name;
|
||||
actorData["data.warlord_actor_id"] = actor.data._id;
|
||||
actorData["system.warlord"] = actor.name;
|
||||
actorData["system.warlord_actor_id"] = actor._id;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -269,7 +279,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
console.warn("L5R5E | Unknown type", type);
|
||||
return;
|
||||
}
|
||||
return this.actor.update({ data: actorData });
|
||||
return this.actor.update({ system: actorData });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,13 +300,10 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
switch (type) {
|
||||
case "casualties":
|
||||
await this.actor.update({
|
||||
data: {
|
||||
system: {
|
||||
battle_readiness: {
|
||||
casualties_strength: {
|
||||
value: Math.max(
|
||||
0,
|
||||
this.actor.data.data.battle_readiness.casualties_strength.value + mod
|
||||
),
|
||||
value: Math.max(0, this.actor.system.battle_readiness.casualties_strength.value + mod),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -305,10 +312,10 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
||||
|
||||
case "panic":
|
||||
await this.actor.update({
|
||||
data: {
|
||||
system: {
|
||||
battle_readiness: {
|
||||
panic_discipline: {
|
||||
value: Math.max(0, this.actor.data.data.battle_readiness.panic_discipline.value + mod),
|
||||
value: Math.max(0, this.actor.system.battle_readiness.panic_discipline.value + mod),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -19,8 +19,8 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
getData(options = {}) {
|
||||
const sheetData = super.getData(options);
|
||||
async getData(options = {}) {
|
||||
const sheetData = await super.getData(options);
|
||||
|
||||
sheetData.data.stances = CONFIG.l5r5e.stances;
|
||||
sheetData.data.techniquesList = game.l5r5e.HelpersL5r5e.getTechniquesList({ displayInTypes: true });
|
||||
@@ -58,31 +58,31 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
sheetData.items.forEach((item) => {
|
||||
switch (item.type) {
|
||||
case "technique":
|
||||
if (!out[item.data.technique_type]) {
|
||||
if (!out[item.system.technique_type]) {
|
||||
console.warn(
|
||||
`L5R5E | Empty or unknown technique type[${item.data.technique_type}] forced to "kata" in item id[${item._id}], name[${item.name}]`
|
||||
`L5R5E | Empty or unknown technique type[${item.system.technique_type}] forced to "kata" in item id[${item._id}], name[${item.name}]`
|
||||
);
|
||||
item.data.technique_type = "kata";
|
||||
item.system.technique_type = "kata";
|
||||
}
|
||||
out[item.data.technique_type].push(item);
|
||||
out[item.system.technique_type].push(item);
|
||||
break;
|
||||
|
||||
case "title":
|
||||
// Embed technique in titles
|
||||
Array.from(item.data.items).forEach(([id, embedItem]) => {
|
||||
if (embedItem.data.type === "technique") {
|
||||
if (!out[embedItem.data.data.technique_type]) {
|
||||
Array.from(item.system.items).forEach(([id, embedItem]) => {
|
||||
if (embedItem.type === "technique") {
|
||||
if (!out[embedItem.system.technique_type]) {
|
||||
console.warn(
|
||||
`L5R5E | Empty or unknown technique type[${embedItem.data.data.technique_type}] forced to "kata" in item id[${id}], name[${embedItem.data.name}], parent: id[${item._id}], name[${item.name}]`
|
||||
`L5R5E | Empty or unknown technique type[${embedItem.system.technique_type}] forced to "kata" in item id[${id}], name[${embedItem.name}], parent: id[${item._id}], name[${item.name}]`
|
||||
);
|
||||
embedItem.data.data.technique_type = "kata";
|
||||
embedItem.system.technique_type = "kata";
|
||||
}
|
||||
out[embedItem.data.data.technique_type].push(embedItem.data);
|
||||
out[embedItem.system.technique_type].push(embedItem);
|
||||
}
|
||||
});
|
||||
|
||||
// If unlocked, add the "title_ability" as technique (or always displayed for npc)
|
||||
if (item.data.xp_used >= item.data.xp_cost || this.document.type === "npc") {
|
||||
if (item.system.xp_used >= item.system.xp_cost || this.document.type === "npc") {
|
||||
out["title_ability"].push(item);
|
||||
}
|
||||
break;
|
||||
@@ -91,17 +91,17 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
|
||||
// Remove unused techs
|
||||
Object.keys(out).forEach((tech) => {
|
||||
if (out[tech].length < 1 && !sheetData.data.data.techniques[tech] && !schoolTechniques.includes(tech)) {
|
||||
if (out[tech].length < 1 && !sheetData.data.system.techniques[tech] && !schoolTechniques.includes(tech)) {
|
||||
delete out[tech];
|
||||
}
|
||||
});
|
||||
|
||||
// Manage school add button
|
||||
sheetData.data.data.techniques["school_ability"] = out["school_ability"].length === 0;
|
||||
sheetData.data.data.techniques["mastery_ability"] = out["mastery_ability"].length === 0;
|
||||
sheetData.data.system.techniques["school_ability"] = out["school_ability"].length === 0;
|
||||
sheetData.data.system.techniques["mastery_ability"] = out["mastery_ability"].length === 0;
|
||||
|
||||
// Always display "school_ability", but display a empty "mastery_ability" field only if rank >= 5
|
||||
if (sheetData.data.data.identity?.school_rank < 5 && out["mastery_ability"].length === 0) {
|
||||
if (sheetData.data.system.identity?.school_rank < 5 && out["mastery_ability"].length === 0) {
|
||||
delete out["mastery_ability"];
|
||||
}
|
||||
|
||||
@@ -134,56 +134,59 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
*/
|
||||
async _onDrop(event) {
|
||||
// *** Everything below here is only needed if the sheet is editable ***
|
||||
if (!this.isEditable || this.actor.data.data.soft_locked) {
|
||||
if (!this.isEditable || this.actor.system.soft_locked) {
|
||||
console.log("LR5E | Not editable");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check item type and subtype
|
||||
const item = await game.l5r5e.HelpersL5r5e.getDragnDropTargetObject(event);
|
||||
if (!item || !["Item", "JournalEntry"].includes(item.documentName) || item.data.type === "property") {
|
||||
if (!item || !["Item", "JournalEntry"].includes(item.documentName) || item.type === "property") {
|
||||
console.log(`LR5E | Wrong subtype ${item?.type}`, item);
|
||||
return;
|
||||
}
|
||||
|
||||
// Specific curriculum journal drop
|
||||
if (item.documentName === "JournalEntry") {
|
||||
// npc does not have this
|
||||
if (!this.actor.data.data.identity?.school_curriculum_journal) {
|
||||
if (!this.actor.system.identity?.school_curriculum_journal) {
|
||||
console.log("LR5E | NPC won't go to school :'(");
|
||||
return;
|
||||
}
|
||||
this.actor.data.data.identity.school_curriculum_journal = {
|
||||
id: item.data._id,
|
||||
name: item.data.name,
|
||||
this.actor.system.identity.school_curriculum_journal = {
|
||||
id: item._id,
|
||||
name: item.name,
|
||||
pack: item.pack || null,
|
||||
};
|
||||
await this.actor.update({
|
||||
data: {
|
||||
system: {
|
||||
identity: {
|
||||
school_curriculum_journal: this.actor.data.data.identity.school_curriculum_journal,
|
||||
school_curriculum_journal: this.actor.system.identity.school_curriculum_journal,
|
||||
},
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Dropped a item with same "id" as one owned
|
||||
if (this.actor.data.items) {
|
||||
// Dropped an item with same "id" as one owned
|
||||
if (this.actor.items) {
|
||||
// Exit if we already owned exactly this id (drag a personal item on our own sheet)
|
||||
if (
|
||||
this.actor.data.items.some((embedItem) => {
|
||||
this.actor.items.some((embedItem) => {
|
||||
// Search in children
|
||||
if (embedItem.items instanceof Map && embedItem.items.has(item.data._id)) {
|
||||
return true;
|
||||
}
|
||||
return embedItem.data._id === item.data._id;
|
||||
return embedItem._id === item._id;
|
||||
})
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add quantity instead if they have (id is different so use type and name)
|
||||
if (item.data.data.quantity) {
|
||||
const tmpItem = this.actor.data.items.find(
|
||||
(embedItem) => embedItem.name === item.data.name && embedItem.type === item.data.type
|
||||
if (item.system.quantity) {
|
||||
const tmpItem = this.actor.items.find(
|
||||
(embedItem) => embedItem.name === item.name && embedItem.type === item.type
|
||||
);
|
||||
if (tmpItem && this._modifyQuantity(tmpItem.id, 1)) {
|
||||
return;
|
||||
@@ -197,13 +200,13 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
return;
|
||||
}
|
||||
|
||||
let itemData = item.data.toObject(true);
|
||||
let itemData = item.toObject(true);
|
||||
|
||||
// Item subtype specific
|
||||
switch (itemData.type) {
|
||||
case "army_cohort":
|
||||
case "army_fortification":
|
||||
console.warn("L5R5E | Army items are not allowed", item?.data?.type, item);
|
||||
console.warn("L5R5E | Army items are not allowed", item?.type, item);
|
||||
return;
|
||||
|
||||
case "advancement":
|
||||
@@ -216,24 +219,22 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
await item.generateNewIdsForAllEmbedItems();
|
||||
|
||||
// Add embed advancements bonus
|
||||
for (let [embedId, embedItem] of item.data.data.items) {
|
||||
for (let [embedId, embedItem] of item.system.items) {
|
||||
if (embedItem.data.type === "advancement") {
|
||||
await this.actor.addBonus(embedItem);
|
||||
}
|
||||
}
|
||||
|
||||
// refresh data
|
||||
itemData = item.data.toObject(true);
|
||||
itemData = item.toObject(true);
|
||||
break;
|
||||
|
||||
case "technique":
|
||||
// School_ability and mastery_ability, allow only 1 per type
|
||||
if (CONFIG.l5r5e.techniques.get(itemData.data.technique_type)?.type === "school") {
|
||||
if (CONFIG.l5r5e.techniques.get(itemData.system.technique_type)?.type === "school") {
|
||||
if (
|
||||
Array.from(this.actor.items).some((e) => {
|
||||
return (
|
||||
e.type === "technique" && e.data.data.technique_type === itemData.data.technique_type
|
||||
);
|
||||
return e.type === "technique" && e.system.technique_type === itemData.system.technique_type;
|
||||
})
|
||||
) {
|
||||
ui.notifications.info(game.i18n.localize("l5r5e.techniques.only_one"));
|
||||
@@ -241,27 +242,27 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
}
|
||||
|
||||
// No cost for schools
|
||||
itemData.data.xp_cost = 0;
|
||||
itemData.data.xp_used = 0;
|
||||
itemData.data.in_curriculum = true;
|
||||
itemData.system.xp_cost = 0;
|
||||
itemData.system.xp_used = 0;
|
||||
itemData.system.in_curriculum = true;
|
||||
} else {
|
||||
// Check if technique is allowed for this character
|
||||
if (!game.user.isGM && !this.actor.data.data.techniques[itemData.data.technique_type]) {
|
||||
if (!game.user.isGM && !this.actor.system.techniques[itemData.system.technique_type]) {
|
||||
ui.notifications.info(game.i18n.localize("l5r5e.techniques.not_allowed"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify cost
|
||||
itemData.data.xp_cost =
|
||||
itemData.data.xp_cost > 0 ? itemData.data.xp_cost : CONFIG.l5r5e.xp.techniqueCost;
|
||||
itemData.data.xp_used = itemData.data.xp_cost;
|
||||
itemData.system.xp_cost =
|
||||
itemData.system.xp_cost > 0 ? itemData.system.xp_cost : CONFIG.l5r5e.xp.techniqueCost;
|
||||
itemData.system.xp_used = itemData.system.xp_cost;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Modify the bought at rank to the current actor rank
|
||||
if (itemData.data.bought_at_rank !== undefined && this.actor.data.data.identity?.school_rank) {
|
||||
itemData.data.bought_at_rank = this.actor.data.data.identity.school_rank;
|
||||
if (itemData.system.bought_at_rank !== undefined && this.actor.system.identity?.school_rank) {
|
||||
itemData.system.bought_at_rank = this.actor.system.identity.school_rank;
|
||||
}
|
||||
|
||||
// Finally create the embed
|
||||
@@ -332,10 +333,10 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
this.actor.data.data.prepared = !this.actor.data.data.prepared;
|
||||
this.actor.system.prepared = !this.actor.system.prepared;
|
||||
this.actor.update({
|
||||
data: {
|
||||
prepared: this.actor.data.data.prepared,
|
||||
system: {
|
||||
prepared: this.actor.system.prepared,
|
||||
},
|
||||
});
|
||||
this.render(false);
|
||||
@@ -367,26 +368,26 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
const item = this.actor.items.get(created[0].id);
|
||||
|
||||
// Assign current school rank to the new adv/tech
|
||||
if (this.actor.data.data.identity?.school_rank) {
|
||||
item.data.data.bought_at_rank = this.actor.data.data.identity.school_rank;
|
||||
if (["advancement", "technique"].includes(item.data.type)) {
|
||||
item.data.data.rank = this.actor.data.data.identity.school_rank;
|
||||
if (this.actor.system.identity?.school_rank) {
|
||||
item.system.bought_at_rank = this.actor.system.identity.school_rank;
|
||||
if (["advancement", "technique"].includes(item.type)) {
|
||||
item.system.rank = this.actor.system.identity.school_rank;
|
||||
}
|
||||
}
|
||||
|
||||
switch (item.data.type) {
|
||||
switch (item.type) {
|
||||
case "item": // no break
|
||||
case "armor": // no break
|
||||
case "weapon":
|
||||
item.data.data.equipped = isEquipped;
|
||||
item.system.equipped = isEquipped;
|
||||
break;
|
||||
|
||||
case "technique": {
|
||||
// If technique, select the current sub-type
|
||||
if (CONFIG.l5r5e.techniques.get(techniqueType)) {
|
||||
item.data.name = game.i18n.localize(`l5r5e.techniques.${techniqueType}`);
|
||||
item.data.img = `${CONFIG.l5r5e.paths.assets}icons/techs/${techniqueType}.svg`;
|
||||
item.data.data.technique_type = techniqueType;
|
||||
item.name = game.i18n.localize(`l5r5e.techniques.${techniqueType}`);
|
||||
item.img = `${CONFIG.l5r5e.paths.assets}icons/techs/${techniqueType}.svg`;
|
||||
item.system.technique_type = techniqueType;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -496,8 +497,8 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
const item = this.actor.items.get(itemId);
|
||||
if (item.type !== "item") {
|
||||
item.update({
|
||||
data: {
|
||||
in_curriculum: !item.data.data.in_curriculum,
|
||||
system: {
|
||||
in_curriculum: !item.system.in_curriculum,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -510,10 +511,10 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
_modifyQuantity(itemId, add) {
|
||||
const tmpItem = this.actor.items.get(itemId);
|
||||
if (tmpItem) {
|
||||
tmpItem.data.data.quantity = Math.max(1, tmpItem.data.data.quantity + add);
|
||||
tmpItem.system.quantity = Math.max(1, tmpItem.system.quantity + add);
|
||||
tmpItem.update({
|
||||
data: {
|
||||
quantity: tmpItem.data.data.quantity,
|
||||
system: {
|
||||
quantity: tmpItem.system.quantity,
|
||||
},
|
||||
});
|
||||
return true;
|
||||
@@ -539,9 +540,9 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
switch (type) {
|
||||
case "fatigue":
|
||||
await this.actor.update({
|
||||
data: {
|
||||
system: {
|
||||
fatigue: {
|
||||
value: Math.max(0, this.actor.data.data.fatigue.value + mod),
|
||||
value: Math.max(0, this.actor.system.fatigue.value + mod),
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -549,9 +550,9 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
|
||||
case "strife":
|
||||
await this.actor.update({
|
||||
data: {
|
||||
system: {
|
||||
strife: {
|
||||
value: Math.max(0, this.actor.data.data.strife.value + mod),
|
||||
value: Math.max(0, this.actor.system.strife.value + mod),
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -579,20 +580,20 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
|
||||
const itemId = $(event.currentTarget).data("item-id");
|
||||
const tmpItem = this.actor.items.get(itemId);
|
||||
if (!tmpItem || tmpItem.data.data[type] === undefined) {
|
||||
if (!tmpItem || tmpItem.system[type] === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
tmpItem.data.data[type] = !tmpItem.data.data[type];
|
||||
tmpItem.system[type] = !tmpItem.system[type];
|
||||
const data = {
|
||||
equipped: tmpItem.data.data.equipped,
|
||||
equipped: tmpItem.system.equipped,
|
||||
};
|
||||
// Only weapons
|
||||
if (tmpItem.data.data.readied !== undefined) {
|
||||
data.readied = tmpItem.data.data.readied;
|
||||
if (tmpItem.system.readied !== undefined) {
|
||||
data.readied = tmpItem.system.readied;
|
||||
}
|
||||
|
||||
tmpItem.update({ data });
|
||||
tmpItem.update({ system: data });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,16 +29,16 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
if (this.isEditable && !this.actor.limited) {
|
||||
// Lock/Unlock
|
||||
buttons.unshift({
|
||||
label: `l5r5e.global.${this.actor.data.data.soft_locked ? "" : "un"}locked`,
|
||||
label: `l5r5e.global.${this.actor.system.soft_locked ? "" : "un"}locked`,
|
||||
class: "l5r-softlock",
|
||||
icon: this.actor.data.data.soft_locked ? "fas fa-lock" : "fas fa-unlock",
|
||||
icon: this.actor.system.soft_locked ? "fas fa-lock" : "fas fa-unlock",
|
||||
onclick: () =>
|
||||
game.l5r5e.HelpersL5r5e.debounce(
|
||||
"lock-" + this.object.id,
|
||||
() => {
|
||||
this.actor.update({
|
||||
data: {
|
||||
soft_locked: !this.actor.data.data.soft_locked,
|
||||
system: {
|
||||
soft_locked: !this.actor.system.soft_locked,
|
||||
},
|
||||
});
|
||||
},
|
||||
@@ -66,8 +66,8 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
getData(options = {}) {
|
||||
const sheetData = super.getData(options);
|
||||
async getData(options = {}) {
|
||||
const sheetData = await super.getData(options);
|
||||
|
||||
// System Header Buttons
|
||||
sheetData.l5rHeaderButtons = this._getL5rHeaderButtons();
|
||||
@@ -79,8 +79,14 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
|
||||
// Editors enrichment
|
||||
sheetData.data.enrichedHtml = {
|
||||
description: await TextEditor.enrichHTML(sheetData.data.system.description, { async: true }),
|
||||
notes: await TextEditor.enrichHTML(sheetData.data.system.notes, { async: true }),
|
||||
};
|
||||
|
||||
// Shortcut for some tests
|
||||
sheetData.data.editable_not_soft_locked = sheetData.editable && !sheetData.data.data.soft_locked;
|
||||
sheetData.data.editable_not_soft_locked = sheetData.editable && !sheetData.data.system.soft_locked;
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
@@ -105,10 +111,10 @@ export class BaseSheetL5r5e extends ActorSheet {
|
||||
*/
|
||||
activateEditor(name, options = {}, initialContent = "") {
|
||||
// Symbols Compatibility with old compendium modules (PRE l5r v1.7.2)
|
||||
if (["data.notes", "data.description"].includes(name) && initialContent) {
|
||||
if (["system.notes", "system.description"].includes(name) && initialContent) {
|
||||
initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false);
|
||||
}
|
||||
super.activateEditor(name, options, initialContent);
|
||||
return super.activateEditor(name, options, initialContent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -69,7 +69,7 @@ export class CharacterGeneratorDialog extends FormApplication {
|
||||
* Try to get values from actor to initialize the generator
|
||||
*/
|
||||
initializeFromActor() {
|
||||
const actorDatas = this.actor.data.data;
|
||||
const actorDatas = this.actor.system;
|
||||
|
||||
// Identity
|
||||
this.object.clan = actorDatas.identity.clan || "random";
|
||||
@@ -97,7 +97,7 @@ export class CharacterGeneratorDialog extends FormApplication {
|
||||
label: game.i18n.localize("l5r5e.clans." + e),
|
||||
}));
|
||||
return {
|
||||
...super.getData(options),
|
||||
...(await super.getData(options)),
|
||||
isNpc: this.actor.type === "npc",
|
||||
clanList: [{ id: "random", label: game.i18n.localize("l5r5e.global.random") }, ...clans],
|
||||
genderList: [
|
||||
|
||||
@@ -291,7 +291,7 @@ export class CharacterGenerator {
|
||||
narrative: true,
|
||||
}
|
||||
) {
|
||||
const actorDatas = actor.data.data;
|
||||
const actorDatas = actor.system;
|
||||
const isNpc = actor.type === "npc";
|
||||
|
||||
// Need to set some required values
|
||||
@@ -304,7 +304,7 @@ export class CharacterGenerator {
|
||||
actorDatas.identity.female = this.isFemale;
|
||||
|
||||
// Name
|
||||
let newName = actor.data.name;
|
||||
let newName = actor.name;
|
||||
if (generate.name) {
|
||||
newName =
|
||||
this.data.family +
|
||||
@@ -325,9 +325,9 @@ export class CharacterGenerator {
|
||||
`${folder}/npc.svg`,
|
||||
`${folder}/traditional-japanese-man.svg`,
|
||||
`${folder}/traditional-japanese-woman.svg`,
|
||||
].includes(actor.data.img)
|
||||
].includes(actor.img)
|
||||
? `${folder}/traditional-japanese-${this.isFemale ? "woman" : "man"}.svg`
|
||||
: actor.data.img;
|
||||
: actor.img;
|
||||
|
||||
// Generate attributes & Social Standing
|
||||
if (generate.attributes) {
|
||||
@@ -453,7 +453,7 @@ export class CharacterGenerator {
|
||||
*/
|
||||
async _generatePeculiarities(actor, newItemsData) {
|
||||
// Clear actor peculiarities
|
||||
const deleteIds = actor.data.items.filter((e) => e.type === "peculiarity").map((e) => e.id);
|
||||
const deleteIds = actor.items.filter((e) => e.type === "peculiarity").map((e) => e.id);
|
||||
if (deleteIds.length > 0) {
|
||||
await actor.deleteEmbeddedDocuments("Item", deleteIds);
|
||||
}
|
||||
@@ -476,7 +476,7 @@ export class CharacterGenerator {
|
||||
*/
|
||||
async _generateItems(actor, newItemsData) {
|
||||
// Clear actor items
|
||||
const deleteIds = actor.data.items.filter((e) => ["armor", "weapon", "item"].includes(e.type)).map((e) => e.id);
|
||||
const deleteIds = actor.items.filter((e) => ["armor", "weapon", "item"].includes(e.type)).map((e) => e.id);
|
||||
if (deleteIds.length > 0) {
|
||||
await actor.deleteEmbeddedDocuments("Item", deleteIds);
|
||||
}
|
||||
@@ -521,7 +521,7 @@ export class CharacterGenerator {
|
||||
*/
|
||||
async _generateTechniques(actor, newItemsData) {
|
||||
// Clear actor items
|
||||
const deleteIds = actor.data.items.filter((e) => e.type === "technique").map((e) => e.id);
|
||||
const deleteIds = actor.items.filter((e) => e.type === "technique").map((e) => e.id);
|
||||
if (deleteIds.length > 0) {
|
||||
await actor.deleteEmbeddedDocuments("Item", deleteIds);
|
||||
}
|
||||
@@ -598,7 +598,7 @@ export class CharacterGenerator {
|
||||
const cfg = techCfg[pack];
|
||||
|
||||
// Minimum skill required (npc only for now)
|
||||
if (!!cfg.skill && actor.data.data.skills[cfg.skill.grp_name] < cfg.skill.value_min) {
|
||||
if (!!cfg.skill && actor.system.skills[cfg.skill.grp_name] < cfg.skill.value_min) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -613,9 +613,10 @@ export class CharacterGenerator {
|
||||
let item;
|
||||
do {
|
||||
item = await CharacterGenerator._getItemFromPack(`l5r5e.core-techniques-${pack}`);
|
||||
} while (item && item.data.data.rank > avgrv);
|
||||
} while (item && item.system.rank > avgrv);
|
||||
|
||||
if (item) {
|
||||
console.log(item); //todo tmp check this!
|
||||
newItemsData.push(foundry.utils.duplicate(item.data));
|
||||
}
|
||||
} // fr qty
|
||||
|
||||
@@ -41,14 +41,14 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
/**
|
||||
* Commons datas
|
||||
*/
|
||||
getData(options = {}) {
|
||||
const sheetData = super.getData(options);
|
||||
async getData(options = {}) {
|
||||
const sheetData = await super.getData(options);
|
||||
|
||||
// Min rank = 1
|
||||
this.actor.data.data.identity.school_rank = Math.max(1, this.actor.data.data.identity.school_rank);
|
||||
this.actor.system.identity.school_rank = Math.max(1, this.actor.system.identity.school_rank);
|
||||
|
||||
// Split Money
|
||||
sheetData.data.data.money = this._zeniToMoney(this.actor.data.data.zeni);
|
||||
sheetData.data.system.money = this._zeniToMoney(this.actor.system.zeni);
|
||||
|
||||
// Split school advancements by rank, and calculate xp spent and add it to total
|
||||
this._prepareSchoolAdvancement(sheetData);
|
||||
@@ -57,8 +57,8 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
this._prepareOthersAdvancement(sheetData);
|
||||
|
||||
// Total
|
||||
sheetData.data.data.xp_saved = Math.floor(
|
||||
parseInt(sheetData.data.data.xp_total) - parseInt(sheetData.data.data.xp_spent)
|
||||
sheetData.data.system.xp_saved = Math.floor(
|
||||
parseInt(sheetData.data.system.xp_total) - parseInt(sheetData.data.system.xp_spent)
|
||||
);
|
||||
|
||||
return sheetData;
|
||||
@@ -87,7 +87,7 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
"data.identity.family",
|
||||
CONFIG.l5r5e.families.get(
|
||||
Object.entries(game.i18n.translations.l5r5e.clans).find(
|
||||
([k, v]) => v === this.actor.data.data.identity.clan
|
||||
([k, v]) => v === this.actor.system.identity.clan
|
||||
)?.[0]
|
||||
)
|
||||
);
|
||||
@@ -118,7 +118,7 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
// TODO class "Active" Bug on load, dunno why :/
|
||||
this._tabs
|
||||
.find((e) => e._navSelector === ".advancements-tabs")
|
||||
.activate("advancement_rank_" + (this.actor.data.data.identity.school_rank || 0));
|
||||
.activate("advancement_rank_" + (this.actor.system.identity.school_rank || 0));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,14 +126,14 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
*/
|
||||
_prepareSchoolAdvancement(sheetData) {
|
||||
const adv = [];
|
||||
sheetData.data.data.xp_spent = 0;
|
||||
sheetData.data.system.xp_spent = 0;
|
||||
sheetData.items
|
||||
.filter((item) => ["peculiarity", "technique", "advancement"].includes(item.type))
|
||||
.forEach((item) => {
|
||||
const { xp_used_total, xp_used } = game.l5r5e.HelpersL5r5e.getItemsXpCost(item);
|
||||
sheetData.data.data.xp_spent += xp_used_total;
|
||||
sheetData.data.system.xp_spent += xp_used_total;
|
||||
|
||||
const rank = Math.max(0, item.data.bought_at_rank);
|
||||
const rank = Math.max(0, item.system.bought_at_rank);
|
||||
if (!adv[rank]) {
|
||||
adv[rank] = {
|
||||
rank: rank,
|
||||
@@ -162,16 +162,16 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
);
|
||||
|
||||
// Sort by rank desc
|
||||
sheetData.data.advancementsOthers.sort((a, b) => (b.data.rank || 0) - (a.data.rank || 0));
|
||||
sheetData.data.advancementsOthers.sort((a, b) => (b.system.rank || 0) - (a.system.rank || 0));
|
||||
|
||||
// Total xp spent in curriculum & total
|
||||
sheetData.data.advancementsOthersTotalXp = sheetData.data.advancementsOthers.reduce(
|
||||
(acc, item) => acc + parseInt(item.data.xp_used_total || item.data.xp_used || 0),
|
||||
(acc, item) => acc + parseInt(item.system.xp_used_total || item.system.xp_used || 0),
|
||||
0
|
||||
);
|
||||
|
||||
// Update the total spent
|
||||
sheetData.data.data.xp_spent += sheetData.data.advancementsOthersTotalXp;
|
||||
sheetData.data.system.xp_spent += sheetData.data.advancementsOthersTotalXp;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,39 +182,39 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
_updateObject(event, formData) {
|
||||
// Clan tag trim if autocomplete in school name
|
||||
if (
|
||||
formData["autoCompleteListName"] === "data.identity.school" &&
|
||||
formData["autoCompleteListName"] === "system.identity.school" &&
|
||||
formData["autoCompleteListSelectedIndex"] >= 0 &&
|
||||
!!formData["data.identity.clan"] &&
|
||||
formData["data.identity.school"].indexOf(` [${formData["data.identity.clan"]}]`) !== -1
|
||||
!!formData["system.identity.clan"] &&
|
||||
formData["system.identity.school"].indexOf(` [${formData["system.identity.clan"]}]`) !== -1
|
||||
) {
|
||||
formData["data.identity.school"] = formData["data.identity.school"].replace(
|
||||
` [${formData["data.identity.clan"]}]`,
|
||||
formData["system.identity.school"] = formData["system.identity.school"].replace(
|
||||
` [${formData["system.identity.clan"]}]`,
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
// Store money in Zeni
|
||||
if (formData["data.money.koku"] || formData["data.money.bu"] || formData["data.money.zeni"]) {
|
||||
formData["data.zeni"] = this._moneyToZeni(
|
||||
formData["data.money.koku"] || 0,
|
||||
formData["data.money.bu"] || 0,
|
||||
formData["data.money.zeni"] || 0
|
||||
if (formData["system.money.koku"] || formData["system.money.bu"] || formData["system.money.zeni"]) {
|
||||
formData["system.zeni"] = this._moneyToZeni(
|
||||
formData["system.money.koku"] || 0,
|
||||
formData["system.money.bu"] || 0,
|
||||
formData["system.money.zeni"] || 0
|
||||
);
|
||||
// Remove fake money object
|
||||
delete formData["data.money.koku"];
|
||||
delete formData["data.money.bu"];
|
||||
delete formData["data.money.zeni"];
|
||||
delete formData["system.money.koku"];
|
||||
delete formData["system.money.bu"];
|
||||
delete formData["system.money.zeni"];
|
||||
}
|
||||
|
||||
// Save computed values
|
||||
const currentData = this.object.data.data;
|
||||
formData["data.focus"] = currentData.focus;
|
||||
formData["data.vigilance"] = currentData.vigilance;
|
||||
formData["data.endurance"] = currentData.endurance;
|
||||
formData["data.composure"] = currentData.composure;
|
||||
formData["data.fatigue.max"] = currentData.fatigue.max;
|
||||
formData["data.strife.max"] = currentData.strife.max;
|
||||
formData["data.void_points.max"] = currentData.void_points.max;
|
||||
const currentData = this.object.system;
|
||||
formData["system.focus"] = currentData.focus;
|
||||
formData["system.vigilance"] = currentData.vigilance;
|
||||
formData["system.endurance"] = currentData.endurance;
|
||||
formData["system.composure"] = currentData.composure;
|
||||
formData["system.fatigue.max"] = currentData.fatigue.max;
|
||||
formData["system.strife.max"] = currentData.strife.max;
|
||||
formData["system.void_points.max"] = currentData.void_points.max;
|
||||
|
||||
return super._updateObject(event, formData);
|
||||
}
|
||||
@@ -276,10 +276,10 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
mod = Math.floor(mod * CONFIG.l5r5e.money[type === "koku" ? 0 : 1]);
|
||||
}
|
||||
|
||||
this.actor.data.data.zeni = +this.actor.data.data.zeni + mod;
|
||||
this.actor.system.zeni = +this.actor.system.zeni + mod;
|
||||
this.actor.update({
|
||||
data: {
|
||||
zeni: this.actor.data.data.zeni,
|
||||
system: {
|
||||
zeni: this.actor.system.zeni,
|
||||
},
|
||||
});
|
||||
this.render(false);
|
||||
@@ -294,11 +294,11 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
this.actor.data.data.identity.school_rank = this.actor.data.data.identity.school_rank + 1;
|
||||
this.actor.system.identity.school_rank = this.actor.system.identity.school_rank + 1;
|
||||
await this.actor.update({
|
||||
data: {
|
||||
system: {
|
||||
identity: {
|
||||
school_rank: this.actor.data.data.identity.school_rank,
|
||||
school_rank: this.actor.system.identity.school_rank,
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -314,7 +314,7 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
const actorJournal = this.actor.data.data.identity.school_curriculum_journal;
|
||||
const actorJournal = this.actor.system.identity.school_curriculum_journal;
|
||||
if (!actorJournal.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ export class NpcSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
*/
|
||||
_getL5rHeaderButtons() {
|
||||
const buttons = super._getL5rHeaderButtons();
|
||||
if (!this.isEditable || this.actor.limited || this.actor.data.data.soft_locked) {
|
||||
if (!this.isEditable || this.actor.limited || this.actor.system.soft_locked) {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
@@ -41,11 +41,11 @@ export class NpcSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
getData(options = {}) {
|
||||
const sheetData = super.getData();
|
||||
async getData(options = {}) {
|
||||
const sheetData = await super.getData();
|
||||
|
||||
// NPC Subtypes
|
||||
sheetData.data.data.types = NpcSheetL5r5e.types.map((e) => ({
|
||||
sheetData.data.types = NpcSheetL5r5e.types.map((e) => ({
|
||||
id: e,
|
||||
label: game.i18n.localize("l5r5e.character_types." + e),
|
||||
}));
|
||||
|
||||
@@ -145,7 +145,7 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
const skillsListStep7 = this._getSkillZero(skillsList, skillsPoints, "step7.skill");
|
||||
const skillsListStep17 = this._getSkillZero(skillsList, skillsPoints, "step17.skill");
|
||||
return {
|
||||
...super.getData(options),
|
||||
...(await super.getData(options)),
|
||||
ringsList: game.l5r5e.HelpersL5r5e.getRingsList(),
|
||||
skillsList,
|
||||
skillsListStep7,
|
||||
@@ -260,20 +260,20 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
// Get item
|
||||
const item = await game.l5r5e.HelpersL5r5e.getDragnDropTargetObject(event);
|
||||
if (item.documentName !== "Item" || !item) {
|
||||
console.warn(`L5R5E | Forbidden item for this drop zone ${type} : ${item.data.type}`);
|
||||
console.warn(`L5R5E | Forbidden item for this drop zone ${type} : ${item.type}`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Specific step18_heritage, all item/tech allowed
|
||||
if (stepKey === "step18.heritage_item") {
|
||||
type = item.data.type;
|
||||
type = item.type;
|
||||
}
|
||||
|
||||
if (
|
||||
(type !== "item" && item.data.type !== type) ||
|
||||
(type === "item" && !["item", "weapon", "armor"].includes(item.data.type))
|
||||
(type !== "item" && item.type !== type) ||
|
||||
(type === "item" && !["item", "weapon", "armor"].includes(item.type))
|
||||
) {
|
||||
console.warn(`L5R5E | Forbidden item for this drop zone ${type} : ${item.data.type}`);
|
||||
console.warn(`L5R5E | Forbidden item for this drop zone ${type} : ${item.type}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -284,13 +284,13 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
case "technique":
|
||||
// School Ability
|
||||
if (stepKey === "step3.school_ability") {
|
||||
if (item.data.data.technique_type !== "school_ability") {
|
||||
if (item.system.technique_type !== "school_ability") {
|
||||
console.warn(
|
||||
`L5R5E | This technique is not a school ability : ${item.data.data.technique_type}`
|
||||
`L5R5E | This technique is not a school ability : ${item.system.technique_type}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
} else if (!this.object.data.step3.allowed_techniques?.[item.data.data.technique_type]) {
|
||||
} else if (!this.object.data.step3.allowed_techniques?.[item.system.technique_type]) {
|
||||
// Tech not allowed
|
||||
ui.notifications.info(game.i18n.localize("l5r5e.techniques.not_allowed"));
|
||||
return;
|
||||
@@ -300,38 +300,38 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
case "peculiarity":
|
||||
switch (stepKey) {
|
||||
case "step9.distinction":
|
||||
if (item.data.data.peculiarity_type !== "distinction") {
|
||||
console.warn("L5R5E | Wrong type", item.data.data.peculiarity_type);
|
||||
if (item.system.peculiarity_type !== "distinction") {
|
||||
console.warn("L5R5E | Wrong type", item.system.peculiarity_type);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "step10.adversity":
|
||||
if (item.data.data.peculiarity_type !== "adversity") {
|
||||
console.warn("L5R5E | Wrong type", item.data.data.peculiarity_type);
|
||||
if (item.system.peculiarity_type !== "adversity") {
|
||||
console.warn("L5R5E | Wrong type", item.system.peculiarity_type);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "step11.passion":
|
||||
if (item.data.data.peculiarity_type !== "passion") {
|
||||
console.warn("L5R5E | Wrong type", item.data.data.peculiarity_type);
|
||||
if (item.system.peculiarity_type !== "passion") {
|
||||
console.warn("L5R5E | Wrong type", item.system.peculiarity_type);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "step12.anxiety":
|
||||
if (item.data.data.peculiarity_type !== "anxiety") {
|
||||
console.warn("L5R5E | Wrong type", item.data.data.peculiarity_type);
|
||||
if (item.system.peculiarity_type !== "anxiety") {
|
||||
console.warn("L5R5E | Wrong type", item.system.peculiarity_type);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "step13.advantage":
|
||||
if (!["distinction", "passion"].includes(item.data.data.peculiarity_type)) {
|
||||
console.warn("L5R5E | Wrong type", item.data.data.peculiarity_type);
|
||||
if (!["distinction", "passion"].includes(item.system.peculiarity_type)) {
|
||||
console.warn("L5R5E | Wrong type", item.system.peculiarity_type);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "step13.disadvantage":
|
||||
if (!["adversity", "anxiety"].includes(item.data.data.peculiarity_type)) {
|
||||
console.warn("L5R5E | Wrong type", item.data.data.peculiarity_type);
|
||||
if (!["adversity", "anxiety"].includes(item.system.peculiarity_type)) {
|
||||
console.warn("L5R5E | Wrong type", item.system.peculiarity_type);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -391,9 +391,9 @@ export class TwentyQuestionsDialog extends FormApplication {
|
||||
this.summary = this.object.validateForm();
|
||||
|
||||
// Store this form datas in actor
|
||||
this.actor.data.data.twenty_questions = this.object.data;
|
||||
this.actor.system.twenty_questions = this.object.data;
|
||||
await this.actor.update({
|
||||
data: {
|
||||
system: {
|
||||
template: formData["template"],
|
||||
twenty_questions: this.object.data,
|
||||
},
|
||||
|
||||
@@ -191,10 +191,10 @@ export class TwentyQuestions {
|
||||
* Initialize data from a actor
|
||||
*/
|
||||
fromActor(actor) {
|
||||
const actorDatas = actor.data.data;
|
||||
const actorDatas = actor.system;
|
||||
|
||||
// already 20q struct ?
|
||||
if (!foundry.utils.isObjectEmpty(actorDatas.twenty_questions)) {
|
||||
if (!foundry.utils.isEmpty(actorDatas.twenty_questions)) {
|
||||
this.data = {
|
||||
...this.data,
|
||||
...actorDatas.twenty_questions,
|
||||
@@ -220,14 +220,14 @@ export class TwentyQuestions {
|
||||
this.data.step6.social_ninjo = actorDatas.social.ninjo;
|
||||
this.data.step8.tenet_paramount = actorDatas.social.bushido_tenets.paramount;
|
||||
this.data.step8.tenet_less_significant = actorDatas.social.bushido_tenets.less_significant;
|
||||
this.data.step19.firstname = actor.data.name.replace(/^(?:\w+\s+)?(.+)$/gi, "$1") || "";
|
||||
this.data.step19.firstname = actor.name.replace(/^(?:\w+\s+)?(.+)$/gi, "$1") || "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill a actor data from this object
|
||||
*/
|
||||
async toActor(actor, itemsCache) {
|
||||
const actorDatas = actor.data.data;
|
||||
const actorDatas = actor.system;
|
||||
const formData = this.data;
|
||||
|
||||
this.data.generated = true;
|
||||
@@ -304,7 +304,7 @@ export class TwentyQuestions {
|
||||
});
|
||||
|
||||
// Clear and add items to actor
|
||||
const deleteIds = actor.data.items.map((e) => e.id);
|
||||
const deleteIds = actor.items.map((e) => e.id);
|
||||
if (deleteIds.length > 0) {
|
||||
await actor.deleteEmbeddedDocuments("Item", deleteIds);
|
||||
}
|
||||
@@ -330,7 +330,7 @@ export class TwentyQuestions {
|
||||
// Update actor
|
||||
await actor.update({
|
||||
name: ((formData.template !== "pow" ? formData.step2.family + " " : "") + formData.step19.firstname).trim(),
|
||||
data: actorDatas,
|
||||
system: actorDatas,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ export class CombatL5r5e extends Combat {
|
||||
}
|
||||
|
||||
// Shortcut to data
|
||||
const data = combatant.actor.data.data;
|
||||
const data = combatant.actor.system;
|
||||
|
||||
// Prepared is a boolean or if null we get the info in the actor sheet
|
||||
const isPc = combatant.actor.data.type === "character";
|
||||
const isPc = combatant.actor.type === "character";
|
||||
const isPrepared = combatant.actor.isPrepared;
|
||||
|
||||
// A character’s initiative value is based on their state of preparedness when the conflict began.
|
||||
@@ -145,17 +145,15 @@ export class CombatL5r5e extends Combat {
|
||||
// if tie : sort by honor, less honorable first
|
||||
if (a.initiative === b.initiative) {
|
||||
// skip if no actor or if armies
|
||||
if (!a.actor || !b.actor || a.actor.data.type === "army" || b.actor.data.type === "army") {
|
||||
if (!a.actor || !b.actor || a.actor.type === "army" || b.actor.type === "army") {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if tie again : Character > Adversary > Minion
|
||||
if (a.actor.data.data.social.honor === b.actor.data.data.social.honor) {
|
||||
return (
|
||||
CombatL5r5e._getWeightByActorType(a.actor.data) - CombatL5r5e._getWeightByActorType(b.actor.data)
|
||||
);
|
||||
if (a.actor.system.social.honor === b.actor.system.social.honor) {
|
||||
return CombatL5r5e._getWeightByActorType(a.actor) - CombatL5r5e._getWeightByActorType(b.actor);
|
||||
}
|
||||
return a.actor.data.data.social.honor - b.actor.data.data.social.honor;
|
||||
return a.actor.system.social.honor - b.actor.system.social.honor;
|
||||
}
|
||||
return b.initiative - a.initiative;
|
||||
}
|
||||
@@ -165,6 +163,6 @@ export class CombatL5r5e extends Combat {
|
||||
* @private
|
||||
*/
|
||||
static _getWeightByActorType(data) {
|
||||
return data.type === "npc" ? (data.data.type === "minion" ? 3 : 2) : 1;
|
||||
return data.type === "npc" ? (data.type === "minion" ? 3 : 2) : 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ export class DicePickerDialog extends FormApplication {
|
||||
return;
|
||||
}
|
||||
this._actor = actor;
|
||||
this.ringId = this._actor.data.data.stance;
|
||||
this.ringId = this._actor.system.stance;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,8 +190,8 @@ export class DicePickerDialog extends FormApplication {
|
||||
set targetInfos(targetToken) {
|
||||
this.object.targetInfos = targetToken
|
||||
? {
|
||||
img: targetToken.data.img,
|
||||
name: targetToken.data.name,
|
||||
img: targetToken.img,
|
||||
name: targetToken.name,
|
||||
}
|
||||
: null;
|
||||
}
|
||||
@@ -202,7 +202,7 @@ export class DicePickerDialog extends FormApplication {
|
||||
*/
|
||||
set ringId(ringId) {
|
||||
this.object.ring.id = CONFIG.l5r5e.stances.includes(ringId) ? ringId : "void";
|
||||
this.object.ring.value = this._actor.data.data.rings?.[this.object.ring.id] || 1;
|
||||
this.object.ring.value = this._actor.system.rings?.[this.object.ring.id] || 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,15 +268,15 @@ export class DicePickerDialog extends FormApplication {
|
||||
if (!this._actor) {
|
||||
return;
|
||||
}
|
||||
switch (this._actor.data.type) {
|
||||
switch (this._actor.type) {
|
||||
case "character":
|
||||
this.object.skill.value = this._actor.data.data.skills[skillCatId]?.[this.object.skill.id] || 0;
|
||||
this.object.skill.value = this._actor.system.skills[skillCatId]?.[this.object.skill.id] || 0;
|
||||
this.object.skill.defaultValue = this.object.skill.value;
|
||||
break;
|
||||
|
||||
case "npc":
|
||||
// Skill value is in categories for npc
|
||||
this.object.skill.value = this._actor.data.data.skills[skillCatId] || 0;
|
||||
this.object.skill.value = this._actor.system.skills[skillCatId] || 0;
|
||||
this.object.skill.defaultValue = this.object.skill.value;
|
||||
break;
|
||||
}
|
||||
@@ -317,7 +317,7 @@ export class DicePickerDialog extends FormApplication {
|
||||
* @type {String}
|
||||
*/
|
||||
get title() {
|
||||
return game.i18n.localize("l5r5e.dice.dicepicker.title") + (this._actor ? " - " + this._actor.data.name : "");
|
||||
return game.i18n.localize("l5r5e.dice.dicepicker.title") + (this._actor ? " - " + this._actor.name : "");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,7 +325,7 @@ export class DicePickerDialog extends FormApplication {
|
||||
* @return {boolean}
|
||||
*/
|
||||
get useCategory() {
|
||||
return !!this._actor && this._actor.data?.type === "npc";
|
||||
return !!this._actor && this._actor.type === "npc";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,9 +333,9 @@ export class DicePickerDialog extends FormApplication {
|
||||
* @param options
|
||||
* @return {Object}
|
||||
*/
|
||||
getData(options = null) {
|
||||
async getData(options = null) {
|
||||
return {
|
||||
...super.getData(options),
|
||||
...(await super.getData(options)),
|
||||
ringsList: game.l5r5e.HelpersL5r5e.getRingsList(this._actor),
|
||||
data: this.object,
|
||||
actor: this._actor,
|
||||
@@ -343,7 +343,7 @@ export class DicePickerDialog extends FormApplication {
|
||||
canUseVoidPoint:
|
||||
this.object.difficulty.addVoidPoint ||
|
||||
!this._actor ||
|
||||
(this._actor.isCharacter && this._actor.data.data.void_points.value > 0),
|
||||
(this._actor.isCharacter && this._actor.system.void_points.value > 0),
|
||||
disableSubmit: this.object.skill.value < 1 && this.object.ring.value < 1,
|
||||
difficultyHiddenIsLock: this._difficultyHiddenIsLock.gm || this._difficultyHiddenIsLock.option,
|
||||
};
|
||||
@@ -485,7 +485,7 @@ export class DicePickerDialog extends FormApplication {
|
||||
|
||||
// Update Actor
|
||||
if (this._actor) {
|
||||
const actorData = foundry.utils.duplicate(this._actor.data.data);
|
||||
const actorData = foundry.utils.duplicate(this._actor.system);
|
||||
|
||||
// Update the actor stance on initiative only
|
||||
if (this.object.isInitiativeRoll) {
|
||||
@@ -503,10 +503,10 @@ export class DicePickerDialog extends FormApplication {
|
||||
}
|
||||
|
||||
// Update actor if needed
|
||||
const updateDiff = foundry.utils.diffObject(this._actor.data.data, actorData);
|
||||
const updateDiff = foundry.utils.diffObject(this._actor.system, actorData);
|
||||
if (Object.keys(updateDiff).length > 0) {
|
||||
await this._actor.update({
|
||||
data: foundry.utils.diffObject(this._actor.data.data, actorData),
|
||||
system: updateDiff,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -588,7 +588,7 @@ export class DicePickerDialog extends FormApplication {
|
||||
this.object.useVoidPoint &&
|
||||
!this.object.difficulty.addVoidPoint &&
|
||||
!!this._actor &&
|
||||
this._actor.data.data.void_points.value < 1
|
||||
this._actor.system.void_points.value < 1
|
||||
) {
|
||||
this.object.useVoidPoint = false;
|
||||
this._quantityChange("ring", -1);
|
||||
@@ -619,7 +619,7 @@ export class DicePickerDialog extends FormApplication {
|
||||
|
||||
let command = `new game.l5r5e.DicePickerDialog(${JSON.stringify(params)}).render(true);`;
|
||||
|
||||
let macro = game.macros.contents.find((m) => m.data.name === name && m.data.command === command);
|
||||
let macro = game.macros.contents.find((m) => m.name === name && m.command === command);
|
||||
if (!macro) {
|
||||
macro = await Macro.create({
|
||||
name: name,
|
||||
@@ -631,7 +631,7 @@ export class DicePickerDialog extends FormApplication {
|
||||
}
|
||||
|
||||
// Search if already in player hotbar
|
||||
if (Object.values(game.user.data.hotbar).includes(macro.id)) {
|
||||
if (Object.values(game.user.hotbar).includes(macro.id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -663,7 +663,7 @@ export class DicePickerDialog extends FormApplication {
|
||||
return acc;
|
||||
}
|
||||
|
||||
const targetData = targetActor.data.data;
|
||||
const targetData = targetActor.system;
|
||||
const value = targetActor[property] || targetData[property] || null;
|
||||
if (!value) {
|
||||
return acc;
|
||||
@@ -734,8 +734,8 @@ export class DicePickerDialog extends FormApplication {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check in actor.<prop> or actor.data.data.<prop>
|
||||
difficulty = targetActor[infos[2]] || targetActor.data.data[infos[2]] || null;
|
||||
// Check in actor.<prop> or actor.system.<prop>
|
||||
difficulty = targetActor[infos[2]] || targetActor.system[infos[2]] || null;
|
||||
if (difficulty < 1) {
|
||||
console.log("L5R5E | Fail to parse difficulty from target");
|
||||
return false;
|
||||
|
||||
@@ -78,12 +78,20 @@ export class RollnKeepDialog extends FormApplication {
|
||||
return this._message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Current (first) Roll in ChatMessage
|
||||
* @returns {RollL5r5e}
|
||||
*/
|
||||
get messageRoll() {
|
||||
return this._message?.rolls?.[0] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this actor has right on this roll
|
||||
* @return {boolean}
|
||||
*/
|
||||
get isOwner() {
|
||||
return this._message?.isAuthor || this._message?._roll.l5r5e.actor?.isOwner || this._message?.isOwner || false;
|
||||
return this._message?.isAuthor || this.messageRoll.l5r5e.actor?.isOwner || this._message?.isOwner || false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +145,7 @@ export class RollnKeepDialog extends FormApplication {
|
||||
}
|
||||
|
||||
// Get the roll
|
||||
this.roll = game.l5r5e.RollL5r5e.fromData(this._message._roll);
|
||||
this.roll = game.l5r5e.RollL5r5e.fromData(this.messageRoll);
|
||||
|
||||
// Already history
|
||||
if (Array.isArray(this.roll.l5r5e.history)) {
|
||||
@@ -223,7 +231,7 @@ export class RollnKeepDialog extends FormApplication {
|
||||
* @param options
|
||||
* @return {Object}
|
||||
*/
|
||||
getData(options = null) {
|
||||
async getData(options = null) {
|
||||
const rollData = this.roll.l5r5e;
|
||||
|
||||
// Disable submit / edition
|
||||
@@ -239,7 +247,7 @@ export class RollnKeepDialog extends FormApplication {
|
||||
}
|
||||
|
||||
return {
|
||||
...super.getData(options),
|
||||
...(await super.getData(options)),
|
||||
isGM: game.user.isGM,
|
||||
showChoices: options.editable && !rollData.rnkEnded,
|
||||
showStrifeBt: options.editable && rollData.summary.strife > 0 && rollData.actor?.isCharacter,
|
||||
@@ -707,9 +715,9 @@ export class RollnKeepDialog extends FormApplication {
|
||||
const actorMod = strifeApplied - this.roll.l5r5e.strifeApplied;
|
||||
if (actorMod !== 0 && this.roll.l5r5e.actor?.isCharacter) {
|
||||
await this.roll.l5r5e.actor.update({
|
||||
data: {
|
||||
system: {
|
||||
strife: {
|
||||
value: Math.max(0, this.roll.l5r5e.actor.data.data.strife.value + actorMod),
|
||||
value: Math.max(0, this.roll.l5r5e.actor.system.strife.value + actorMod),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -74,8 +74,8 @@ export class RollL5r5e extends Roll {
|
||||
set targetInfos(targetToken) {
|
||||
this.l5r5e.targetInfos = targetToken
|
||||
? {
|
||||
img: targetToken.data.img,
|
||||
name: targetToken.data.name,
|
||||
img: targetToken.img,
|
||||
name: targetToken.name,
|
||||
}
|
||||
: null;
|
||||
}
|
||||
@@ -378,7 +378,7 @@ export class RollL5r5e extends Roll {
|
||||
} else if (data.l5r5e.actor.uuid) {
|
||||
// Only uuid, get the object
|
||||
let actor;
|
||||
let tmpItem = game.l5r5e.HelpersL5r5e.fromUuidNoPack(data.l5r5e.actor.uuid);
|
||||
const tmpItem = fromUuidSync(data.l5r5e.actor.uuid);
|
||||
if (tmpItem instanceof Actor) {
|
||||
actor = tmpItem;
|
||||
} else if (tmpItem instanceof TokenDocument) {
|
||||
|
||||
@@ -91,7 +91,7 @@ export class GmMonitor extends FormApplication {
|
||||
actors = game.actors.filter((e) => ids.includes(e.id));
|
||||
} else {
|
||||
// If empty add pc with owner
|
||||
actors = game.actors.filter((actor) => actor.data.type === "character" && actor.hasPlayerOwner);
|
||||
actors = game.actors.filter((actor) => actor.type === "character" && actor.hasPlayerOwner);
|
||||
this._saveActorsIds();
|
||||
}
|
||||
|
||||
@@ -120,9 +120,9 @@ export class GmMonitor extends FormApplication {
|
||||
* @return {Object}
|
||||
* @override
|
||||
*/
|
||||
getData(options = null) {
|
||||
async getData(options = null) {
|
||||
return {
|
||||
...super.getData(options),
|
||||
...(await super.getData(options)),
|
||||
data: {
|
||||
...this.object,
|
||||
actors: this.object.actors.filter((e) =>
|
||||
@@ -197,12 +197,13 @@ export class GmMonitor extends FormApplication {
|
||||
if (!json) {
|
||||
return;
|
||||
}
|
||||
|
||||
const data = JSON.parse(json);
|
||||
if (!data || data.type !== "Actor" || !data.id || !!this.object.actors.find((e) => e.id === data.id)) {
|
||||
if (!data || data.type !== "Actor" || !data.uuid || !!this.object.actors.find((a) => a.uuid === data.uuid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const actor = game.actors.find((e) => e.id === data.id);
|
||||
const actor = game.actors.find((a) => a.uuid === data.uuid);
|
||||
if (!actor) {
|
||||
return;
|
||||
}
|
||||
@@ -275,8 +276,7 @@ export class GmMonitor extends FormApplication {
|
||||
const add = event.which === 2 ? -999 : event.which === 1 ? 1 : -1;
|
||||
|
||||
// Stance
|
||||
let stanceIdx =
|
||||
CONFIG.l5r5e.stances.findIndex((s) => s === actor.data.data.stance) + (event.which === 1 ? 1 : -1);
|
||||
let stanceIdx = CONFIG.l5r5e.stances.findIndex((s) => s === actor.system.stance) + (event.which === 1 ? 1 : -1);
|
||||
if (stanceIdx < 0) {
|
||||
stanceIdx = CONFIG.l5r5e.stances.length - 1;
|
||||
} else if (stanceIdx > CONFIG.l5r5e.stances.length - 1) {
|
||||
@@ -287,40 +287,40 @@ export class GmMonitor extends FormApplication {
|
||||
switch (type) {
|
||||
// *** Characters ***
|
||||
case "fatigue":
|
||||
updateData["data.fatigue.value"] = Math.max(0, actor.data.data.fatigue.value + add);
|
||||
updateData["system.fatigue.value"] = Math.max(0, actor.system.fatigue.value + add);
|
||||
break;
|
||||
|
||||
case "strife":
|
||||
updateData["data.strife.value"] = Math.max(0, actor.data.data.strife.value + add);
|
||||
updateData["system.strife.value"] = Math.max(0, actor.system.strife.value + add);
|
||||
break;
|
||||
|
||||
case "void_points":
|
||||
updateData["data.void_points.value"] = Math.min(
|
||||
actor.data.data.void_points.max,
|
||||
Math.max(0, actor.data.data.void_points.value + add)
|
||||
updateData["system.void_points.value"] = Math.min(
|
||||
actor.system.void_points.max,
|
||||
Math.max(0, actor.system.void_points.value + add)
|
||||
);
|
||||
break;
|
||||
|
||||
case "stance":
|
||||
updateData["data.stance"] = CONFIG.l5r5e.stances[stanceIdx];
|
||||
updateData["system.stance"] = CONFIG.l5r5e.stances[stanceIdx];
|
||||
break;
|
||||
|
||||
case "prepared":
|
||||
updateData["data.prepared"] = !actor.data.data.prepared;
|
||||
updateData["system.prepared"] = !actor.system.prepared;
|
||||
break;
|
||||
|
||||
// *** Armies ***
|
||||
case "casualties":
|
||||
updateData["data.battle_readiness.casualties_strength.value"] = Math.max(
|
||||
updateData["system.battle_readiness.casualties_strength.value"] = Math.max(
|
||||
0,
|
||||
actor.data.data.battle_readiness.casualties_strength.value + add
|
||||
actor.system.battle_readiness.casualties_strength.value + add
|
||||
);
|
||||
break;
|
||||
|
||||
case "panic":
|
||||
updateData["data.battle_readiness.panic_discipline.value"] = Math.max(
|
||||
updateData["system.battle_readiness.panic_discipline.value"] = Math.max(
|
||||
0,
|
||||
actor.data.data.battle_readiness.panic_discipline.value + add
|
||||
actor.system.battle_readiness.panic_discipline.value + add
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -328,7 +328,7 @@ export class GmMonitor extends FormApplication {
|
||||
console.warn("L5R5E | Unsupported type", type);
|
||||
break;
|
||||
}
|
||||
if (!foundry.utils.isObjectEmpty(updateData)) {
|
||||
if (!foundry.utils.isEmpty(updateData)) {
|
||||
await actor.update(updateData);
|
||||
this.render(false);
|
||||
}
|
||||
@@ -336,52 +336,52 @@ export class GmMonitor extends FormApplication {
|
||||
|
||||
/**
|
||||
* Get tooltips information for this character
|
||||
* @param {BaseSheetL5r5e} actor
|
||||
* @param {ActorL5r5e} actor
|
||||
* @return {string}
|
||||
* @private
|
||||
*/
|
||||
async _getTooltipGlobal(actor) {
|
||||
const data = actor.data.data;
|
||||
const actorData = (await actor.sheet?.getData()?.data) || actor;
|
||||
|
||||
// Peculiarities
|
||||
const pec = actor.items.filter((e) => e.type === "peculiarity");
|
||||
const adv = pec
|
||||
.filter((e) => ["distinction", "passion"].includes(e.data.data.peculiarity_type))
|
||||
.filter((e) => ["distinction", "passion"].includes(e.system.peculiarity_type))
|
||||
.map((e) => e.name)
|
||||
.join(", ");
|
||||
const dis = pec
|
||||
.filter((e) => ["adversity", "anxiety"].includes(e.data.data.peculiarity_type))
|
||||
.filter((e) => ["adversity", "anxiety"].includes(e.system.peculiarity_type))
|
||||
.map((e) => e.name)
|
||||
.join(", ");
|
||||
|
||||
// *** Template ***
|
||||
return renderTemplate(`${CONFIG.l5r5e.paths.templates}gm/monitor-tooltips/global.html`, {
|
||||
actorData: data,
|
||||
actorData: actorData,
|
||||
advantages: adv,
|
||||
disadvantages: dis,
|
||||
suffix: data.template === "pow" ? "_pow" : "",
|
||||
actor_type: actor.data.type,
|
||||
suffix: actorData.system.template === "pow" ? "_pow" : "",
|
||||
actor_type: actor.type,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tooltips informations for this army
|
||||
* @param {BaseSheetL5r5e} actor
|
||||
* Get tooltips information for this army
|
||||
* @param {ActorL5r5e} actor
|
||||
* @return {string}
|
||||
* @private
|
||||
*/
|
||||
async _getTooltipArmiesGlobal(actor) {
|
||||
const actorData = (await actor.sheet?.getData()) || actor.data;
|
||||
const actorData = (await actor.sheet?.getData()?.data) || actor;
|
||||
|
||||
// *** Template ***
|
||||
return renderTemplate(`${CONFIG.l5r5e.paths.templates}gm/monitor-tooltips/global-armies.html`, {
|
||||
actorData: actorData.data,
|
||||
actorData: actorData,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get weapons informations for this actor
|
||||
* @param {BaseSheetL5r5e} actor
|
||||
* Get weapons information for this actor
|
||||
* @param {ActorL5r5e} actor
|
||||
* @return {string}
|
||||
* @private
|
||||
*/
|
||||
@@ -397,12 +397,12 @@ export class GmMonitor extends FormApplication {
|
||||
|
||||
// Readied Weapons
|
||||
const readied = actor.items
|
||||
.filter((e) => e.type === "weapon" && e.data.data.equipped && !!e.data.data.readied)
|
||||
.filter((e) => e.type === "weapon" && e.system.equipped && !!e.system.readied)
|
||||
.map((e) => display(e));
|
||||
|
||||
// Equipped Weapons
|
||||
const sheathed = actor.items
|
||||
.filter((e) => e.type === "weapon" && e.data.data.equipped && !e.data.data.readied)
|
||||
.filter((e) => e.type === "weapon" && e.system.equipped && !e.system.readied)
|
||||
.map((e) => display(e));
|
||||
|
||||
// *** Template ***
|
||||
@@ -413,20 +413,20 @@ export class GmMonitor extends FormApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get armors informations for this actor
|
||||
* @param {BaseSheetL5r5e} actor
|
||||
* Get armors information for this actor
|
||||
* @param {ActorL5r5e} actor
|
||||
* @return {string}
|
||||
* @private
|
||||
*/
|
||||
async _getTooltipArmors(actor) {
|
||||
// Equipped Armors
|
||||
const armors = actor.items
|
||||
.filter((e) => e.type === "armor" && e.data.data.equipped)
|
||||
.filter((e) => e.type === "armor" && e.system.equipped)
|
||||
.map(
|
||||
(e) =>
|
||||
e.name +
|
||||
` (<i class="fas fa-tint">${e.data.data.armor.physical}</i>` +
|
||||
` / <i class="fas fa-bolt">${e.data.data.armor.supernatural}</i>)`
|
||||
` (<i class="fas fa-tint">${e.system.armor.physical}</i>` +
|
||||
` / <i class="fas fa-bolt">${e.system.armor.supernatural}</i>)`
|
||||
);
|
||||
|
||||
// *** Template ***
|
||||
|
||||
@@ -67,7 +67,7 @@ export class GmToolbox extends FormApplication {
|
||||
// TODO better implementation needed : see KeyboardManager._onEscape(event, up, modifiers)
|
||||
// This windows is always open, so esc key is stuck at step 2 : Object.keys(ui.windows).length > 0
|
||||
// Case 3 (GM) - release controlled objects
|
||||
if (canvas?.ready && game.user.isGM && Object.keys(canvas.activeLayer._controlled).length) {
|
||||
if (canvas?.ready && game.user.isGM && Object.keys(canvas.activeLayer.controlled).length) {
|
||||
canvas.activeLayer.releaseAll();
|
||||
} else {
|
||||
// Case 4 - toggle the main menu
|
||||
@@ -102,9 +102,9 @@ export class GmToolbox extends FormApplication {
|
||||
* @return {Object}
|
||||
* @override
|
||||
*/
|
||||
getData(options = null) {
|
||||
async getData(options = null) {
|
||||
return {
|
||||
...super.getData(options),
|
||||
...(await super.getData(options)),
|
||||
data: this.object,
|
||||
};
|
||||
}
|
||||
@@ -201,46 +201,46 @@ export class GmToolbox extends FormApplication {
|
||||
}
|
||||
|
||||
// Manage left/right button
|
||||
if (!isAll && (actor.data.type !== "character" || !actor.hasPlayerOwner)) {
|
||||
if (!isAll && (actor.type !== "character" || !actor.hasPlayerOwner)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case "sleep":
|
||||
// Remove 'water x2' fatigue points
|
||||
actor.data.data.fatigue.value = Math.max(
|
||||
actor.system.fatigue.value = Math.max(
|
||||
0,
|
||||
actor.data.data.fatigue.value - Math.ceil(actor.data.data.rings.water * 2)
|
||||
actor.system.fatigue.value - Math.ceil(actor.system.rings.water * 2)
|
||||
);
|
||||
break;
|
||||
|
||||
case "scene_end":
|
||||
// If more than half the value => roundup half conflit & fatigue
|
||||
actor.data.data.fatigue.value = Math.min(
|
||||
actor.data.data.fatigue.value,
|
||||
Math.ceil(actor.data.data.fatigue.max / 2)
|
||||
actor.system.fatigue.value = Math.min(
|
||||
actor.system.fatigue.value,
|
||||
Math.ceil(actor.system.fatigue.max / 2)
|
||||
);
|
||||
actor.data.data.strife.value = Math.min(
|
||||
actor.data.data.strife.value,
|
||||
Math.ceil(actor.data.data.strife.max / 2)
|
||||
actor.system.strife.value = Math.min(
|
||||
actor.system.strife.value,
|
||||
Math.ceil(actor.system.strife.max / 2)
|
||||
);
|
||||
break;
|
||||
|
||||
case "reset_void":
|
||||
actor.data.data.void_points.value = Math.ceil(actor.data.data.void_points.max / 2);
|
||||
actor.system.void_points.value = Math.ceil(actor.system.void_points.max / 2);
|
||||
break;
|
||||
}
|
||||
|
||||
await actor.update({
|
||||
data: {
|
||||
system: {
|
||||
fatigue: {
|
||||
value: actor.data.data.fatigue.value,
|
||||
value: actor.system.fatigue.value,
|
||||
},
|
||||
strife: {
|
||||
value: actor.data.data.strife.value,
|
||||
value: actor.system.strife.value,
|
||||
},
|
||||
void_points: {
|
||||
value: actor.data.data.void_points.value,
|
||||
value: actor.system.void_points.value,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -66,6 +66,7 @@ export const RegisterHandlebars = function () {
|
||||
|
||||
// enrichHTML
|
||||
Handlebars.registerHelper("enrichHTML", function (text, options = {}) {
|
||||
options.async = false;
|
||||
return TextEditor.enrichHTML(text, options);
|
||||
});
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ export class HelpDialog extends FormApplication {
|
||||
* @param options
|
||||
* @return {Object}
|
||||
*/
|
||||
getData(options = null) {
|
||||
async getData(options = null) {
|
||||
return {
|
||||
...super.getData(options),
|
||||
...(await super.getData(options)),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ export class HelpersL5r5e {
|
||||
return CONFIG.l5r5e.stances.map((e) => ({
|
||||
id: e,
|
||||
label: game.i18n.localize(`l5r5e.rings.${e}`),
|
||||
value: actor?.data?.data?.rings?.[e] || 1,
|
||||
value: actor?.system?.rings?.[e] || 1,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -109,36 +109,6 @@ export class HelpersL5r5e {
|
||||
return CONFIG.l5r5e.roles.map((e) => game.i18n.localize(`l5r5e.roles.${e}`));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a Document by its Universally Unique Identifier (uuid).
|
||||
* Exactly the same as fromUuid but without Compendium as it need async.
|
||||
* @param {string} uuid The uuid of the Document to retrieve
|
||||
* @return {Document|null}
|
||||
*/
|
||||
static fromUuidNoPack(uuid) {
|
||||
let parts = uuid.split(".");
|
||||
let doc;
|
||||
|
||||
if (parts[0] === "Compendium") {
|
||||
// Compendium Documents need asynchronous
|
||||
return null;
|
||||
} else {
|
||||
// World Documents
|
||||
const [docName, docId] = parts.slice(0, 2);
|
||||
parts = parts.slice(2);
|
||||
const collection = CONFIG[docName].collection.instance;
|
||||
doc = collection.get(docId);
|
||||
}
|
||||
|
||||
// Embedded Documents
|
||||
while (doc && parts.length > 1) {
|
||||
const [embeddedName, embeddedId] = parts.slice(0, 2);
|
||||
doc = doc.getEmbeddedDocument(embeddedName, embeddedId);
|
||||
parts = parts.slice(2);
|
||||
}
|
||||
return doc || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the target object on a drag n drop event, or null if not found
|
||||
* @param {DragEvent} event
|
||||
@@ -156,24 +126,31 @@ export class HelpersL5r5e {
|
||||
|
||||
/**
|
||||
* Return the object from Game or Pack by his ID, or null if not found
|
||||
* @param {string} id
|
||||
* @param {string} type Type (Item, JournalEntry...)
|
||||
* @param {string} uuid "Item.5qI6SU85VSFqji8W"
|
||||
* @param {string} id "5qI6SU85VSFqji8W"
|
||||
* @param {string} type Type ("Item", "JournalEntry"...)
|
||||
* @param {any[]|null} data Plain data
|
||||
* @param {string|null} pack Pack name
|
||||
* @param {string|null} parentId Used to avoid an infinite loop in properties if set
|
||||
* @return {Promise<null>}
|
||||
*/
|
||||
static async getObjectGameOrPack({ id, type, data = null, pack = null, parentId = null }) {
|
||||
static async getObjectGameOrPack({ uuid, id, type, data = null, pack = null, parentId = null }) {
|
||||
let document = null;
|
||||
|
||||
try {
|
||||
// Direct Object
|
||||
if (data?._id) {
|
||||
document = HelpersL5r5e.createDocumentFromCompendium({ type, data });
|
||||
} else if (!id || !type) {
|
||||
} else if (!uuid && (!id || !type)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// UUID
|
||||
if (!document && !!uuid) {
|
||||
document = await fromUuid(uuid);
|
||||
}
|
||||
// TODO need to migrate to UUID
|
||||
|
||||
// Named pack
|
||||
if (!document) {
|
||||
// If no pack passed, but it's a core item, we know the pack to get it
|
||||
@@ -207,8 +184,8 @@ export class HelpersL5r5e {
|
||||
// Final
|
||||
if (document) {
|
||||
// Flag the source GUID
|
||||
if (document.uuid && !document.getFlag("core", "sourceId")) {
|
||||
document.data.update({ "flags.core.sourceId": document.uuid });
|
||||
if (document.uuid && !document.pack && !document.getFlag("core", "sourceId")) {
|
||||
document.updateSource({ "flags.core.sourceId": document.uuid });
|
||||
}
|
||||
|
||||
// Care to infinite loop in properties
|
||||
@@ -263,13 +240,13 @@ export class HelpersL5r5e {
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
static async refreshItemProperties(document) {
|
||||
if (document.data?.data?.properties && typeof Babele !== "undefined") {
|
||||
document.data.data.properties = await Promise.all(
|
||||
document.data.data.properties.map(async (property) => {
|
||||
if (document.system?.properties && typeof Babele !== "undefined") {
|
||||
document.system.properties = await Promise.all(
|
||||
document.system.properties.map(async (property) => {
|
||||
const gameProp = await HelpersL5r5e.getObjectGameOrPack({
|
||||
id: property.id,
|
||||
type: "Item",
|
||||
parentId: document.data?._id || 1,
|
||||
parentId: document._id || 1,
|
||||
});
|
||||
if (gameProp) {
|
||||
return { id: gameProp.id, name: gameProp.name };
|
||||
@@ -279,7 +256,7 @@ export class HelpersL5r5e {
|
||||
return property;
|
||||
})
|
||||
);
|
||||
document.data.update({ "data.properties": document.data.data.properties });
|
||||
document.updateSource({ "system.properties": document.system.properties });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,13 +424,13 @@ export class HelpersL5r5e {
|
||||
}
|
||||
|
||||
itemsList.forEach((item) => {
|
||||
let xp = parseInt(item.data.xp_used_total || item.data.xp_used || 0);
|
||||
let xp = parseInt(item.system.xp_used_total || item.system.xp_used || 0);
|
||||
|
||||
// Full price
|
||||
xp_used_total += xp;
|
||||
|
||||
// if not in curriculum, xp spent /2 for this item
|
||||
if (!item.data.in_curriculum && xp > 0) {
|
||||
if (!item.system.in_curriculum && xp > 0) {
|
||||
xp = Math.ceil(xp / 2);
|
||||
}
|
||||
|
||||
@@ -626,8 +603,8 @@ export class HelpersL5r5e {
|
||||
|
||||
// Create the link
|
||||
let link = null;
|
||||
if (object.data.flags.core?.sourceId) {
|
||||
link = object.data.flags.core?.sourceId.replace(/(\w+)\.(.+)/, "@$1[$2]");
|
||||
if (object.flags.core?.sourceId) {
|
||||
link = object.flags.core?.sourceId.replace(/(\w+)\.(.+)/, "@$1[$2]");
|
||||
if (!HelpersL5r5e.isLinkValid(link)) {
|
||||
link = null;
|
||||
}
|
||||
@@ -661,7 +638,7 @@ export class HelpersL5r5e {
|
||||
|
||||
// Get a matched World document
|
||||
// "@Item[L5RCoreIte000042]{Amigasa}"
|
||||
if (CONST.ENTITY_TYPES.includes(type)) {
|
||||
if (CONST.DOCUMENT_TYPES.includes(type)) {
|
||||
const collection = game.collections.get(type);
|
||||
const document = /^[a-zA-Z0-9]{16}$/.test(target) ? collection.get(target) : collection.getName(target);
|
||||
return !!document;
|
||||
|
||||
@@ -65,7 +65,7 @@ export default class HooksL5r5e {
|
||||
case "settings":
|
||||
// Add Changelog link
|
||||
html.find("#game-details .system").append(
|
||||
`<p><a href="${game.system.data.changelog}" target="_blank">Changelog</a></p>`
|
||||
`<p><a href="${game.system.changelog}" target="_blank">Changelog</a></p>`
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -198,13 +198,13 @@ export default class HooksL5r5e {
|
||||
if (["weapon", "armor", "item", "peculiarity", "technique", "peculiarity"].includes(document.type)) {
|
||||
html.find(`[data-document-id="${document.id}"]`).append(
|
||||
`<i` +
|
||||
(document.data.data.ring ? ` class="i_${document.data.data.ring}"` : ``) +
|
||||
(document.system.ring ? ` class="i_${document.system.ring}"` : ``) +
|
||||
`>` +
|
||||
(document.data.data.rarity
|
||||
? `${game.i18n.localize("l5r5e.sheets.rarity")} ${document.data.data.rarity}`
|
||||
(document.system.rarity
|
||||
? `${game.i18n.localize("l5r5e.sheets.rarity")} ${document.system.rarity}`
|
||||
: "") +
|
||||
(document.data.data.rank
|
||||
? game.i18n.localize("l5r5e.sheets.rank") + " " + document.data.data.rank
|
||||
(document.system.rank
|
||||
? game.i18n.localize("l5r5e.sheets.rank") + " " + document.system.rank
|
||||
: "") +
|
||||
`</i>`
|
||||
);
|
||||
|
||||
@@ -4,7 +4,7 @@ export class ItemL5r5e extends Item {
|
||||
* @returns {Collection<BaseItem>}
|
||||
*/
|
||||
get items() {
|
||||
return this.data.data.items || new Map();
|
||||
return this.system.items || new Map();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -12,7 +12,7 @@ export class ItemL5r5e extends Item {
|
||||
* @return {Actor|null}
|
||||
*/
|
||||
get actor() {
|
||||
return super.actor || game.actors.get(this.data.data.parent_id?.actor_id) || null;
|
||||
return super.actor || game.actors.get(this.system.parent_id?.actor_id) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,13 +29,13 @@ export class ItemL5r5e extends Item {
|
||||
/**
|
||||
* Update this Document using incremental data, saving it to the database.
|
||||
* @see {@link Document.updateDocuments}
|
||||
* @param {object} [data={}] Differential update data which modifies the existing values of this document data
|
||||
* @param {object} [data={}] Differential update data which modifies the existing values of this document data
|
||||
* @param {DocumentModificationContext} [context={}] Additional context which customizes the update workflow
|
||||
* @returns {Promise<Document>} The updated Document instance
|
||||
* @returns {Promise<Document>} The updated Document instance
|
||||
*/
|
||||
async update(data = {}, context = {}) {
|
||||
// Regular
|
||||
if (!this.data.data.parent_id) {
|
||||
if (!this.system.parent_id) {
|
||||
return super.update(data, context);
|
||||
}
|
||||
|
||||
@@ -47,19 +47,21 @@ export class ItemL5r5e extends Item {
|
||||
}
|
||||
|
||||
// Merge (DocumentData cannot be set)
|
||||
const result = foundry.utils.mergeObject(this.data, foundry.utils.expandObject(data));
|
||||
const result = foundry.utils.mergeObject(this, foundry.utils.expandObject(data));
|
||||
console.log(result); // TODO TMP
|
||||
|
||||
if (result.name) {
|
||||
this.data.name = result.name;
|
||||
this.name = result.name;
|
||||
}
|
||||
if (result.img) {
|
||||
this.data.img = result.img;
|
||||
this.img = result.img;
|
||||
}
|
||||
if (result.data) {
|
||||
this.data.data = result.data;
|
||||
this.data = result.data; // todo tmp check this!
|
||||
}
|
||||
|
||||
// Update
|
||||
await parentItem.updateEmbedItem(this.data.toObject(false));
|
||||
await parentItem.updateEmbedItem(this.toObject(false));
|
||||
|
||||
// Return new value for sheet
|
||||
return new Promise((resolve) => resolve(this));
|
||||
@@ -70,9 +72,9 @@ export class ItemL5r5e extends Item {
|
||||
super.prepareData();
|
||||
|
||||
// Prepare Embed items
|
||||
if (!(this.data.data.items instanceof Map)) {
|
||||
const itemsData = Array.isArray(this.data.data.items) ? this.data.data.items : [];
|
||||
this.data.data.items = new Map();
|
||||
if (!(this.system.items instanceof Map)) {
|
||||
const itemsData = Array.isArray(this.system.items) ? this.system.items : [];
|
||||
this.system.items = new Map();
|
||||
|
||||
itemsData.forEach((item) => {
|
||||
this.addEmbedItem(item, { save: false, newId: false, addBonusToActor: false });
|
||||
@@ -80,16 +82,16 @@ export class ItemL5r5e extends Item {
|
||||
}
|
||||
|
||||
// Sanitize some values
|
||||
switch (this.data.type) {
|
||||
switch (this.type) {
|
||||
case "armor":
|
||||
this.data.data.armor.physical = this.data.data.armor.physical || 0;
|
||||
this.data.data.armor.supernatural = this.data.data.armor.supernatural || 0;
|
||||
this.system.armor.physical = this.system.armor.physical || 0;
|
||||
this.system.armor.supernatural = this.system.armor.supernatural || 0;
|
||||
break;
|
||||
|
||||
case "weapon":
|
||||
this.data.data.range = this.data.data.range || 0;
|
||||
this.data.data.damage = this.data.data.damage || 0;
|
||||
this.data.data.deadliness = this.data.data.deadliness || 0;
|
||||
this.system.range = this.system.range || 0;
|
||||
this.system.damage = this.system.damage || 0;
|
||||
this.system.deadliness = this.system.deadliness || 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -103,8 +105,8 @@ export class ItemL5r5e extends Item {
|
||||
const parent = {
|
||||
item_id: this.id,
|
||||
};
|
||||
if (this.actor?.data?._id) {
|
||||
parent.actor_id = this.actor.data._id;
|
||||
if (this.actor?._id) {
|
||||
parent.actor_id = this.actor._id;
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
@@ -114,7 +116,7 @@ export class ItemL5r5e extends Item {
|
||||
* @return {ItemL5r5e|null}
|
||||
*/
|
||||
getItemFromParentId() {
|
||||
const parentIds = this.data.data.parent_id;
|
||||
const parentIds = this.system.parent_id;
|
||||
let parentItem;
|
||||
|
||||
if (parentIds?.actor_id) {
|
||||
@@ -134,12 +136,12 @@ export class ItemL5r5e extends Item {
|
||||
* @return {Promise<string|null>}
|
||||
*/
|
||||
async renderTextTemplate() {
|
||||
const data = (await this.sheet?.getData()) || this;
|
||||
if (data instanceof ItemL5r5e) {
|
||||
const sheetData = (await this.sheet?.getData()) || this;
|
||||
if (sheetData instanceof ItemL5r5e) {
|
||||
await game.l5r5e.HelpersL5r5e.refreshItemProperties(this);
|
||||
}
|
||||
const type = this.type.replace("_", "-"); // ex: item_pattern
|
||||
const tpl = await renderTemplate(`${CONFIG.l5r5e.paths.templates}items/${type}/${type}-text.html`, data);
|
||||
const tpl = await renderTemplate(`${CONFIG.l5r5e.paths.templates}items/${type}/${type}-text.html`, sheetData);
|
||||
if (!tpl) {
|
||||
return null;
|
||||
}
|
||||
@@ -148,7 +150,7 @@ export class ItemL5r5e extends Item {
|
||||
|
||||
// ***** Embedded items management *****
|
||||
/**
|
||||
* Shortcut for this.data.data.items.get
|
||||
* Shortcut for this.items.get
|
||||
* @param id
|
||||
* @return {ItemL5r5e|null}
|
||||
*/
|
||||
@@ -176,17 +178,17 @@ export class ItemL5r5e extends Item {
|
||||
|
||||
// New id
|
||||
if (newId) {
|
||||
item.data._id = foundry.utils.randomID();
|
||||
item._id = foundry.utils.randomID();
|
||||
}
|
||||
|
||||
// Copy the parent permission to the sub item
|
||||
item.data.permission = this.data.permission;
|
||||
item.ownership = this.ownership;
|
||||
|
||||
// Tag parent (flags won't work as we have no id in db)
|
||||
item.data.data.parent_id = this.getParentsIds();
|
||||
item.system.parent_id = this.getParentsIds();
|
||||
|
||||
// Object
|
||||
this.data.data.items.set(item.data._id, item);
|
||||
this.system.items.set(item._id, item);
|
||||
|
||||
// Add bonus to actor
|
||||
if (addBonusToActor) {
|
||||
@@ -199,7 +201,7 @@ export class ItemL5r5e extends Item {
|
||||
if (save) {
|
||||
await this.saveEmbedItems();
|
||||
}
|
||||
return item.data._id;
|
||||
return item._id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,21 +222,21 @@ export class ItemL5r5e extends Item {
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async deleteEmbedItem(id, { save = true, removeBonusFromActor = true } = {}) {
|
||||
if (!this.data.data.items.has(id)) {
|
||||
if (!this.system.items.has(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove bonus from actor
|
||||
if (removeBonusFromActor) {
|
||||
const actor = this.actor;
|
||||
const item = this.data.data.items.get(id);
|
||||
const item = this.system.items.get(id);
|
||||
if (item instanceof Item && actor instanceof Actor) {
|
||||
actor.removeBonus(item);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the embed item
|
||||
this.data.data.items.delete(id);
|
||||
this.system.items.delete(id);
|
||||
|
||||
if (save) {
|
||||
await this.saveEmbedItems();
|
||||
@@ -247,8 +249,8 @@ export class ItemL5r5e extends Item {
|
||||
*/
|
||||
async generateNewIdsForAllEmbedItems() {
|
||||
// Clear olds ids
|
||||
const oldItems = Array.from(this.data.data.items);
|
||||
this.data.data.items = new Map();
|
||||
const oldItems = Array.from(this.system.items);
|
||||
this.system.items = new Map();
|
||||
|
||||
// Re-add with new ids
|
||||
oldItems.forEach(([id, item]) => {
|
||||
@@ -264,7 +266,7 @@ export class ItemL5r5e extends Item {
|
||||
*/
|
||||
async saveEmbedItems() {
|
||||
await this.update({
|
||||
"data.items": Array.from(this.data.data.items).map(([id, item]) => item.data.toObject(false)),
|
||||
"system.items": Array.from(this.system.items).map(([id, item]) => item.toObject(false)),
|
||||
});
|
||||
this.sheet.render(false);
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
|
||||
return;
|
||||
}
|
||||
|
||||
// const currentType = this.object.data.data.advancement_type;
|
||||
const currentRing = this.object.data.data.ring;
|
||||
const currentSkill = this.object.data.data.skill;
|
||||
// const currentType = this.object.system.advancement_type;
|
||||
const currentRing = this.object.system.ring;
|
||||
const currentSkill = this.object.system.skill;
|
||||
|
||||
html.find("#advancement_type").on("change", (event) => {
|
||||
$(event.target).prop("disabled", true);
|
||||
@@ -78,9 +78,9 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
|
||||
* @private
|
||||
*/
|
||||
async _updateChoice(oldChoice, newChoice) {
|
||||
let xp_used = this.object.data.data.xp_used;
|
||||
let name = this.object.data.name;
|
||||
let img = this.object.data.img;
|
||||
let xp_used = this.object.system.xp_used;
|
||||
let name = this.object.name;
|
||||
let img = this.object.img;
|
||||
|
||||
// Modify image to reflect choice
|
||||
if (newChoice.ring) {
|
||||
@@ -96,7 +96,7 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
|
||||
// Object embed in actor ?
|
||||
const actor = this.document.actor;
|
||||
if (actor) {
|
||||
const actorData = foundry.utils.duplicate(actor.data.data);
|
||||
const actorData = foundry.utils.duplicate(actor.system);
|
||||
let skillCatId = null;
|
||||
|
||||
// Old choices
|
||||
@@ -132,7 +132,7 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
|
||||
|
||||
// Update Actor
|
||||
await actor.update({
|
||||
data: foundry.utils.diffObject(actor.data.data, actorData),
|
||||
system: foundry.utils.diffObject(actor.system, actorData),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e {
|
||||
await this.object.update({
|
||||
name: name,
|
||||
img: img,
|
||||
data: {
|
||||
system: {
|
||||
xp_used: xp_used,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ export class ArmyCohortSheetL5r5e extends ItemSheetL5r5e {
|
||||
* @private
|
||||
*/
|
||||
_initialize() {
|
||||
const data = this.object.data.data;
|
||||
const data = this.object.system;
|
||||
|
||||
// update linked actor datas
|
||||
if (data.leader_actor_id) {
|
||||
@@ -40,6 +40,20 @@ export class ArmyCohortSheetL5r5e extends ItemSheetL5r5e {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Object|Promise}
|
||||
*/
|
||||
async getData(options = {}) {
|
||||
const sheetData = await super.getData(options);
|
||||
|
||||
// Editors enrichment
|
||||
sheetData.data.enrichedHtml.abilities = await TextEditor.enrichHTML(sheetData.data.system.abilities, {
|
||||
async: true,
|
||||
});
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate a named TinyMCE text editor
|
||||
* @param {string} name The named data field which the editor modifies.
|
||||
@@ -49,10 +63,10 @@ export class ArmyCohortSheetL5r5e extends ItemSheetL5r5e {
|
||||
*/
|
||||
activateEditor(name, options = {}, initialContent = "") {
|
||||
// Symbols Compatibility with old compendium modules (PRE l5r v1.7.2)
|
||||
if (name === "data.abilities" && initialContent) {
|
||||
if (name === "system.abilities" && initialContent) {
|
||||
initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false);
|
||||
}
|
||||
super.activateEditor(name, options, initialContent);
|
||||
return super.activateEditor(name, options, initialContent);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,15 +114,15 @@ export class ArmyCohortSheetL5r5e extends ItemSheetL5r5e {
|
||||
*/
|
||||
async _updateLinkedActorData(actor) {
|
||||
if (!actor || actor.documentName !== "Actor" || !actor.isCharacter) {
|
||||
console.warn("L5R5E | Wrong actor type", actor?.data?.type, actor);
|
||||
console.warn("L5R5E | Wrong actor type", actor?.type, actor);
|
||||
return;
|
||||
}
|
||||
|
||||
return this.object.update({
|
||||
img: actor.data.img,
|
||||
data: {
|
||||
leader: actor.data.name,
|
||||
leader_actor_id: actor.data._id,
|
||||
img: actor.img,
|
||||
system: {
|
||||
leader: actor.name,
|
||||
leader_actor_id: actor._id,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -120,7 +134,7 @@ export class ArmyCohortSheetL5r5e extends ItemSheetL5r5e {
|
||||
*/
|
||||
async _removeLinkedActor() {
|
||||
return this.object.update({
|
||||
data: {
|
||||
system: {
|
||||
leader_actor_id: null,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -62,10 +62,10 @@ export class BaseItemSheetL5r5e extends ItemSheet {
|
||||
*/
|
||||
activateEditor(name, options = {}, initialContent = "") {
|
||||
// Symbols Compatibility with old compendium modules (PRE l5r v1.7.2)
|
||||
if (name === "data.description" && initialContent) {
|
||||
if (name === "system.description" && initialContent) {
|
||||
initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false);
|
||||
}
|
||||
super.activateEditor(name, options, initialContent);
|
||||
return super.activateEditor(name, options, initialContent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,15 +33,15 @@ export class ItemPatternSheetL5r5e extends ItemSheetL5r5e {
|
||||
* @return {Promise<null|{name, id}>}
|
||||
*/
|
||||
async getLinkedProperty(sheetData) {
|
||||
if (sheetData.data.data.linked_property_id) {
|
||||
if (sheetData.data.system.linked_property_id) {
|
||||
const linkedProperty = await game.l5r5e.HelpersL5r5e.getObjectGameOrPack({
|
||||
id: sheetData.data.data.linked_property_id,
|
||||
id: sheetData.data.system.linked_property_id,
|
||||
type: "Item",
|
||||
});
|
||||
if (linkedProperty) {
|
||||
return {
|
||||
id: linkedProperty.data._id,
|
||||
name: linkedProperty.data.name,
|
||||
id: linkedProperty._id,
|
||||
name: linkedProperty.name,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -77,15 +77,15 @@ export class ItemPatternSheetL5r5e extends ItemSheetL5r5e {
|
||||
|
||||
// Only property allowed here
|
||||
let item = await game.l5r5e.HelpersL5r5e.getDragnDropTargetObject(event);
|
||||
if (!item || item.documentName !== "Item" || item.data.type !== "property") {
|
||||
if (!item || item.documentName !== "Item" || item.type !== "property") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the new property, and update
|
||||
this.document.data.data.linked_property_id = item.id;
|
||||
this.document.system.linked_property_id = item.id;
|
||||
this.document.update({
|
||||
data: {
|
||||
linked_property_id: this.document.data.data.linked_property_id,
|
||||
system: {
|
||||
linked_property_id: this.document.system.linked_property_id,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -102,18 +102,18 @@ export class ItemPatternSheetL5r5e extends ItemSheetL5r5e {
|
||||
|
||||
let name;
|
||||
const linkedProperty = await game.l5r5e.HelpersL5r5e.getObjectGameOrPack({
|
||||
id: this.document.data.data.linked_property_id,
|
||||
id: this.document.system.linked_property_id,
|
||||
type: "Item",
|
||||
});
|
||||
if (linkedProperty) {
|
||||
name = linkedProperty.data.name;
|
||||
name = linkedProperty.name;
|
||||
}
|
||||
|
||||
const callback = async () => {
|
||||
this.document.data.data.linked_property_id = null;
|
||||
this.document.system.linked_property_id = null;
|
||||
this.document.update({
|
||||
data: {
|
||||
linked_property_id: this.document.data.data.linked_property_id,
|
||||
system: {
|
||||
linked_property_id: this.document.system.linked_property_id,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -27,6 +27,11 @@ export class ItemSheetL5r5e extends BaseItemSheetL5r5e {
|
||||
// Prepare Properties (id/name => object)
|
||||
await this._prepareProperties(sheetData);
|
||||
|
||||
// Editors enrichment
|
||||
sheetData.data.enrichedHtml = {
|
||||
description: await TextEditor.enrichHTML(sheetData.data.system.description, { async: true }),
|
||||
};
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
|
||||
@@ -37,9 +42,9 @@ export class ItemSheetL5r5e extends BaseItemSheetL5r5e {
|
||||
async _prepareProperties(sheetData) {
|
||||
sheetData.data.propertiesList = [];
|
||||
|
||||
if (Array.isArray(sheetData.data.data.properties)) {
|
||||
if (Array.isArray(sheetData.data.system.properties)) {
|
||||
const props = [];
|
||||
for (const property of sheetData.data.data.properties) {
|
||||
for (const property of sheetData.data.system.properties) {
|
||||
const gameProp = await game.l5r5e.HelpersL5r5e.getObjectGameOrPack({ id: property.id, type: "Item" });
|
||||
if (gameProp) {
|
||||
sheetData.data.propertiesList.push(gameProp);
|
||||
@@ -56,7 +61,7 @@ export class ItemSheetL5r5e extends BaseItemSheetL5r5e {
|
||||
});
|
||||
}
|
||||
}
|
||||
sheetData.data.data.properties = props;
|
||||
sheetData.data.system.properties = props;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,15 +119,15 @@ export class ItemSheetL5r5e extends BaseItemSheetL5r5e {
|
||||
}
|
||||
|
||||
// Specific ItemPattern's drop, get the associated props instead
|
||||
if (item.data.type === "item_pattern" && item.data.data.linked_property_id) {
|
||||
if (item.type === "item_pattern" && item.system.linked_property_id) {
|
||||
item = await game.l5r5e.HelpersL5r5e.getObjectGameOrPack({
|
||||
id: item.data.data.linked_property_id,
|
||||
id: item.system.linked_property_id,
|
||||
type: "Item",
|
||||
});
|
||||
}
|
||||
|
||||
// Final object has to be a property
|
||||
if (item.data.type !== "property") {
|
||||
if (item.type !== "property") {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -136,27 +141,27 @@ export class ItemSheetL5r5e extends BaseItemSheetL5r5e {
|
||||
* @private
|
||||
*/
|
||||
_addProperty(item) {
|
||||
if (!Array.isArray(this.document.data.data.properties)) {
|
||||
this.document.data.data.properties = [];
|
||||
if (!Array.isArray(this.document.system.properties)) {
|
||||
this.document.system.properties = [];
|
||||
}
|
||||
|
||||
if (this.document.data.data.properties.findIndex((p) => p.id === item.id) !== -1) {
|
||||
if (this.document.system.properties.findIndex((p) => p.id === item.id) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.document.data.data.properties.push({ id: item.id, name: item.name });
|
||||
this.document.system.properties.push({ id: item.id, name: item.name });
|
||||
|
||||
// This props remove others ?
|
||||
if (Array.isArray(item.data.data.properties) && item.data.data.properties.length > 0) {
|
||||
const idsToRemove = item.data.data.properties.map((e) => e.id);
|
||||
this.document.data.data.properties = this.document.data.data.properties.filter(
|
||||
if (Array.isArray(item.system.properties) && item.system.properties.length > 0) {
|
||||
const idsToRemove = item.system.properties.map((e) => e.id);
|
||||
this.document.system.properties = this.document.system.properties.filter(
|
||||
(p) => !idsToRemove.includes(p.id)
|
||||
);
|
||||
}
|
||||
|
||||
this.document.update({
|
||||
data: {
|
||||
properties: this.document.data.data.properties,
|
||||
system: {
|
||||
properties: this.document.system.properties,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -171,21 +176,21 @@ export class ItemSheetL5r5e extends BaseItemSheetL5r5e {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if (!Array.isArray(this.document.data.data.properties)) {
|
||||
if (!Array.isArray(this.document.system.properties)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const id = $(event.currentTarget).parents(".property").data("propertyId");
|
||||
const tmpProps = this.document.data.data.properties.find((p) => p.id === id);
|
||||
const tmpProps = this.document.system.properties.find((p) => p.id === id);
|
||||
if (!tmpProps) {
|
||||
return;
|
||||
}
|
||||
|
||||
const callback = async () => {
|
||||
this.document.data.data.properties = this.document.data.data.properties.filter((p) => p.id !== id);
|
||||
this.document.system.properties = this.document.system.properties.filter((p) => p.id !== id);
|
||||
this.document.update({
|
||||
data: {
|
||||
properties: this.document.data.data.properties,
|
||||
system: {
|
||||
properties: this.document.system.properties,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -27,9 +27,9 @@ export class TechniqueSheetL5r5e extends ItemSheetL5r5e {
|
||||
sheetData.data.techniquesList = game.l5r5e.HelpersL5r5e.getTechniquesList({ types });
|
||||
|
||||
// Sanitize Difficulty and Skill list
|
||||
sheetData.data.data.difficulty = TechniqueSheetL5r5e.formatDifficulty(sheetData.data.data.difficulty);
|
||||
sheetData.data.data.skill = TechniqueSheetL5r5e.translateSkillsList(
|
||||
TechniqueSheetL5r5e.formatSkillList(sheetData.data.data.skill.split(",")),
|
||||
sheetData.data.system.difficulty = TechniqueSheetL5r5e.formatDifficulty(sheetData.data.system.difficulty);
|
||||
sheetData.data.system.skill = TechniqueSheetL5r5e.translateSkillsList(
|
||||
TechniqueSheetL5r5e.formatSkillList(sheetData.data.system.skill.split(",")),
|
||||
false
|
||||
).join(", ");
|
||||
|
||||
@@ -46,16 +46,16 @@ export class TechniqueSheetL5r5e extends ItemSheetL5r5e {
|
||||
async _updateObject(event, formData) {
|
||||
// Change the image according to the type if this is already the case
|
||||
if (
|
||||
formData["data.technique_type"] &&
|
||||
formData.img === `${CONFIG.l5r5e.paths.assets}icons/techs/${this.object.data.data.technique_type}.svg`
|
||||
formData["system.technique_type"] &&
|
||||
formData.img === `${CONFIG.l5r5e.paths.assets}icons/techs/${this.object.system.technique_type}.svg`
|
||||
) {
|
||||
formData.img = `${CONFIG.l5r5e.paths.assets}icons/techs/${formData["data.technique_type"]}.svg`;
|
||||
formData.img = `${CONFIG.l5r5e.paths.assets}icons/techs/${formData["system.technique_type"]}.svg`;
|
||||
}
|
||||
|
||||
// Sanitize Difficulty and Skill list
|
||||
formData["data.difficulty"] = TechniqueSheetL5r5e.formatDifficulty(formData["data.difficulty"]);
|
||||
formData["data.skill"] = TechniqueSheetL5r5e.formatSkillList(
|
||||
TechniqueSheetL5r5e.translateSkillsList(formData["data.skill"].split(","), true)
|
||||
formData["system.difficulty"] = TechniqueSheetL5r5e.formatDifficulty(formData["system.difficulty"]);
|
||||
formData["system.skill"] = TechniqueSheetL5r5e.formatSkillList(
|
||||
TechniqueSheetL5r5e.translateSkillsList(formData["system.skill"].split(","), true)
|
||||
).join(",");
|
||||
|
||||
return super._updateObject(event, formData);
|
||||
@@ -77,7 +77,7 @@ export class TechniqueSheetL5r5e extends ItemSheetL5r5e {
|
||||
// Autocomplete
|
||||
game.l5r5e.HelpersL5r5e.autocomplete(
|
||||
html,
|
||||
"data.difficulty",
|
||||
"system.difficulty",
|
||||
[
|
||||
"@T:intrigueRank",
|
||||
"@T:focus",
|
||||
@@ -93,7 +93,7 @@ export class TechniqueSheetL5r5e extends ItemSheetL5r5e {
|
||||
);
|
||||
game.l5r5e.HelpersL5r5e.autocomplete(
|
||||
html,
|
||||
"data.skill",
|
||||
"system.skill",
|
||||
Object.values(TechniqueSheetL5r5e.getSkillsTranslationMap(false)),
|
||||
","
|
||||
);
|
||||
|
||||
@@ -22,12 +22,12 @@ export class TitleSheetL5r5e extends ItemSheetL5r5e {
|
||||
const sheetData = await super.getData(options);
|
||||
|
||||
// Prepare OwnedItems
|
||||
sheetData.data.embedItemsList = this._prepareEmbedItems(sheetData.data.data.items);
|
||||
sheetData.data.embedItemsList = this._prepareEmbedItems(sheetData.data.system.items);
|
||||
|
||||
// Automatically compute the total xp cost (full price) and XP in title (cursus, some halved prices)
|
||||
const { xp_used_total, xp_used } = game.l5r5e.HelpersL5r5e.getItemsXpCost(sheetData.data.embedItemsList);
|
||||
sheetData.data.data.xp_used_total = xp_used_total;
|
||||
sheetData.data.data.xp_used = xp_used;
|
||||
sheetData.data.system.xp_used_total = xp_used_total;
|
||||
sheetData.data.system.xp_used = xp_used;
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
@@ -41,11 +41,11 @@ export class TitleSheetL5r5e extends ItemSheetL5r5e {
|
||||
_prepareEmbedItems(itemsMap) {
|
||||
let itemsList = itemsMap;
|
||||
if (itemsMap instanceof Map) {
|
||||
itemsList = Array.from(itemsMap).map(([id, item]) => item.data);
|
||||
itemsList = Array.from(itemsMap).map(([id, item]) => item);
|
||||
}
|
||||
|
||||
// Sort by rank desc
|
||||
itemsList.sort((a, b) => (b.data.rank || 0) - (a.data.rank || 0));
|
||||
itemsList.sort((a, b) => (b.system.rank || 0) - (a.system.rank || 0));
|
||||
|
||||
return itemsList;
|
||||
}
|
||||
@@ -63,16 +63,16 @@ export class TitleSheetL5r5e extends ItemSheetL5r5e {
|
||||
|
||||
// Check item type and subtype
|
||||
let item = await game.l5r5e.HelpersL5r5e.getDragnDropTargetObject(event);
|
||||
if (!item || item.documentName !== "Item" || !["technique", "advancement"].includes(item.data.type)) {
|
||||
if (!item || item.documentName !== "Item" || !["technique", "advancement"].includes(item.type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const data = item.data.toObject(false);
|
||||
const data = item.toObject(false);
|
||||
|
||||
// Check xp for techs
|
||||
if (item.data.type === "technique") {
|
||||
data.data.xp_cost = data.data.xp_cost > 0 ? data.data.xp_cost : CONFIG.l5r5e.xp.techniqueCost;
|
||||
data.data.xp_used = data.data.xp_cost;
|
||||
if (item.type === "technique") {
|
||||
data.system.xp_cost = data.system.xp_cost > 0 ? data.system.xp_cost : CONFIG.l5r5e.xp.techniqueCost;
|
||||
data.system.xp_used = data.system.xp_cost;
|
||||
}
|
||||
|
||||
this.document.addEmbedItem(data);
|
||||
@@ -146,7 +146,7 @@ export class TitleSheetL5r5e extends ItemSheetL5r5e {
|
||||
}
|
||||
|
||||
// Switch the state and update
|
||||
item.data.data.in_curriculum = !item.data.data.in_curriculum;
|
||||
item.system.in_curriculum = !item.system.in_curriculum;
|
||||
return this.document.updateEmbedItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export class BaseJournalSheetL5r5e extends JournalSheet {
|
||||
if (initialContent) {
|
||||
initialContent = game.l5r5e.HelpersL5r5e.convertSymbols(initialContent, false);
|
||||
}
|
||||
super.activateEditor(name, options, initialContent);
|
||||
return super.activateEditor(name, options, initialContent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -202,8 +202,8 @@ Hooks.once("init", async () => {
|
||||
|
||||
// Override enrichHTML for Symbol replacement
|
||||
const oldEnrichHTML = TextEditor.prototype.constructor.enrichHTML;
|
||||
TextEditor.prototype.constructor.enrichHTML = function (content, options = {}) {
|
||||
return HelpersL5r5e.convertSymbols(oldEnrichHTML.call(this, content, options), true);
|
||||
TextEditor.prototype.constructor.enrichHTML = async function (content, options = {}) {
|
||||
return HelpersL5r5e.convertSymbols(await oldEnrichHTML.call(this, content, options), true);
|
||||
};
|
||||
|
||||
// Override the default Token _drawBar function to allow fatigue bar reversing.
|
||||
@@ -223,7 +223,7 @@ Hooks.once("init", async () => {
|
||||
|
||||
// Enlarge the bar for large tokens
|
||||
let h = Math.max(canvas.dimensions.size / 12, 8);
|
||||
if (this.data.height >= 2) {
|
||||
if (this.height >= 2) {
|
||||
h *= 1.6;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ export class MigrationL5r5e {
|
||||
// Migrate World Actors
|
||||
for (let actor of game.actors.contents) {
|
||||
try {
|
||||
const updateData = MigrationL5r5e._migrateActorData(actor.data, options);
|
||||
if (!foundry.utils.isObjectEmpty(updateData)) {
|
||||
const updateData = MigrationL5r5e._migrateActorData(actor, options);
|
||||
if (!foundry.utils.isEmpty(updateData)) {
|
||||
console.log(`L5R5E | Migrating Actor entity ${actor.name}`);
|
||||
await actor.update(updateData);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ export class MigrationL5r5e {
|
||||
for (let item of game.items.contents) {
|
||||
try {
|
||||
const updateData = MigrationL5r5e._migrateItemData(item.data, options);
|
||||
if (!foundry.utils.isObjectEmpty(updateData)) {
|
||||
if (!foundry.utils.isEmpty(updateData)) {
|
||||
console.log(`L5R5E | Migrating Item entity ${item.name}`);
|
||||
await item.update(updateData);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ export class MigrationL5r5e {
|
||||
for (let scene of game.scenes.contents) {
|
||||
try {
|
||||
const updateData = MigrationL5r5e._migrateSceneData(scene.data, options);
|
||||
if (!foundry.utils.isObjectEmpty(updateData)) {
|
||||
if (!foundry.utils.isEmpty(updateData)) {
|
||||
console.log(`L5R5E | Migrating Scene entity ${scene.name}`);
|
||||
await scene.update(updateData);
|
||||
// If we do not do this, then synthetic token actors remain in cache
|
||||
@@ -97,7 +97,7 @@ export class MigrationL5r5e {
|
||||
const updatedChatList = [];
|
||||
for (let message of game.collections.get("ChatMessage")) {
|
||||
const updateData = MigrationL5r5e._migrateChatMessage(message.data, options);
|
||||
if (!foundry.utils.isObjectEmpty(updateData)) {
|
||||
if (!foundry.utils.isEmpty(updateData)) {
|
||||
updateData["_id"] = message.data._id;
|
||||
updatedChatList.push(updateData);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ export class MigrationL5r5e {
|
||||
updateData = MigrationL5r5e._migrateSceneData(ent.data);
|
||||
break;
|
||||
}
|
||||
if (foundry.utils.isObjectEmpty(updateData)) {
|
||||
if (foundry.utils.isEmpty(updateData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ export class MigrationL5r5e {
|
||||
*/
|
||||
static _migrateActorData(actor, options = { force: false }) {
|
||||
const updateData = {};
|
||||
const actorData = actor.data;
|
||||
const actorData = actor.system;
|
||||
|
||||
// We need to be careful for unlinked tokens, only the diff is store in "data".
|
||||
// ex no diff : actor = {type: "npc"}, actorData = undefined
|
||||
@@ -243,16 +243,17 @@ export class MigrationL5r5e {
|
||||
if (options?.force || MigrationL5r5e.needUpdate("1.1.0")) {
|
||||
// Add "Prepared" in actor
|
||||
if (actorData.prepared === undefined) {
|
||||
updateData["data.prepared"] = true;
|
||||
updateData["system.prepared"] = true;
|
||||
}
|
||||
|
||||
// NPC are now without autostats, we need to save the value
|
||||
if (actor.type === "npc") {
|
||||
if (actorData.endurance < 1) {
|
||||
updateData["data.endurance"] = (Number(actorData.rings.earth) + Number(actorData.rings.fire)) * 2;
|
||||
updateData["data.composure"] = (Number(actorData.rings.earth) + Number(actorData.rings.water)) * 2;
|
||||
updateData["data.focus"] = Number(actorData.rings.air) + Number(actorData.rings.fire);
|
||||
updateData["data.vigilance"] = Math.ceil(
|
||||
updateData["system.endurance"] = (Number(actorData.rings.earth) + Number(actorData.rings.fire)) * 2;
|
||||
updateData["system.composure"] =
|
||||
(Number(actorData.rings.earth) + Number(actorData.rings.water)) * 2;
|
||||
updateData["system.focus"] = Number(actorData.rings.air) + Number(actorData.rings.fire);
|
||||
updateData["system.vigilance"] = Math.ceil(
|
||||
(Number(actorData.rings.air) + Number(actorData.rings.water)) / 2
|
||||
);
|
||||
}
|
||||
@@ -264,18 +265,18 @@ export class MigrationL5r5e {
|
||||
if (options?.force || MigrationL5r5e.needUpdate("1.3.0")) {
|
||||
// PC/NPC removed notes useless props "value"
|
||||
if (actorData.notes?.value) {
|
||||
updateData["data.notes"] = actorData.notes.value;
|
||||
updateData["system.notes"] = actorData.notes.value;
|
||||
}
|
||||
|
||||
// NPC have now more thant a Strength and a Weakness
|
||||
if (actor.type === "npc" && actorData.rings_affinities?.strength) {
|
||||
const aff = actorData.rings_affinities;
|
||||
updateData["data.rings_affinities." + aff.strength.ring] = aff.strength.value;
|
||||
updateData["data.rings_affinities." + aff.weakness.ring] = aff.weakness.value;
|
||||
updateData["system.rings_affinities." + aff.strength.ring] = aff.strength.value;
|
||||
updateData["system.rings_affinities." + aff.weakness.ring] = aff.weakness.value;
|
||||
|
||||
// Delete old keys
|
||||
updateData["data.rings_affinities.-=strength"] = null;
|
||||
updateData["data.rings_affinities.-=weakness"] = null;
|
||||
updateData["system.rings_affinities.-=strength"] = null;
|
||||
updateData["system.rings_affinities.-=weakness"] = null;
|
||||
}
|
||||
}
|
||||
// ***** End of 1.3.0 *****
|
||||
|
||||
Reference in New Issue
Block a user