Working on Compatibility for FVTT v10
token.img -> token.texture.src some missing data/system comp.keys() -> comp.index.keys()
This commit is contained in:
@@ -174,12 +174,13 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
if (
|
||||
this.actor.items.some((embedItem) => {
|
||||
// Search in children
|
||||
if (embedItem.items instanceof Map && embedItem.items.has(item.data._id)) {
|
||||
if (embedItem.items instanceof Map && embedItem.items.has(item._id)) {
|
||||
return true;
|
||||
}
|
||||
return embedItem._id === item._id;
|
||||
})
|
||||
) {
|
||||
console.log("LR5E | This item already exist in this actor", item.uuid);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -220,7 +221,7 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
|
||||
// Add embed advancements bonus
|
||||
for (let [embedId, embedItem] of item.system.items) {
|
||||
if (embedItem.data.type === "advancement") {
|
||||
if (embedItem.type === "advancement") {
|
||||
await this.actor.addBonus(embedItem);
|
||||
}
|
||||
}
|
||||
@@ -277,14 +278,10 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
const item = this.actor.items.get(li.dataset.itemParentId)?.items.get(li.dataset.itemId);
|
||||
if (item) {
|
||||
const dragData = {
|
||||
actorId: this.actor.id,
|
||||
sceneId: this.actor.isToken ? canvas.scene?.id : null,
|
||||
tokenId: this.actor.isToken ? this.actor.token.id : null,
|
||||
pack: this.actor.pack,
|
||||
type: "Item",
|
||||
data: foundry.utils.duplicate(item.data),
|
||||
data: foundry.utils.duplicate(item),
|
||||
};
|
||||
dragData.data.data.parent_id = null;
|
||||
dragData.data.system.parent_id = null;
|
||||
event.dataTransfer.setData("text/plain", JSON.stringify(dragData));
|
||||
return;
|
||||
}
|
||||
@@ -450,7 +447,7 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
}
|
||||
|
||||
// Remove 1 qty if possible
|
||||
if (tmpItem.data.data.quantity > 1 && this._modifyQuantity(tmpItem.id, -1)) {
|
||||
if (tmpItem.system.quantity > 1 && this._modifyQuantity(tmpItem.id, -1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -463,8 +460,8 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
|
||||
case "title":
|
||||
// Remove embed advancements bonus
|
||||
for (let [embedId, embedItem] of tmpItem.data.data.items) {
|
||||
if (embedItem.data.type === "advancement") {
|
||||
for (let [embedId, embedItem] of tmpItem.system.items) {
|
||||
if (embedItem.type === "advancement") {
|
||||
await this.actor.removeBonus(embedItem);
|
||||
}
|
||||
}
|
||||
@@ -603,7 +600,7 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
_getWeaponSkillId(weaponId) {
|
||||
const item = this.actor.items.get(weaponId);
|
||||
if (!!item && item.type === "weapon") {
|
||||
return item.data.data.skill;
|
||||
return item.system.skill;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -644,11 +641,11 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
||||
|
||||
// Required for tech in titles, search in sub items
|
||||
const item = await game.l5r5e.HelpersL5r5e.getEmbedItemByEvent(event, this.actor);
|
||||
if (!item || item.type !== "technique" || !item.data.data.skill) {
|
||||
if (!item || item.type !== "technique" || !item.system.skill) {
|
||||
return;
|
||||
}
|
||||
|
||||
const itemData = item.data.data;
|
||||
const itemData = item.system;
|
||||
new game.l5r5e.DicePickerDialog({
|
||||
actor: this.actor,
|
||||
ringId: itemData.ring || null,
|
||||
|
||||
@@ -100,7 +100,7 @@ export class CharacterGenerator {
|
||||
if (!comp.indexed) {
|
||||
await comp.getDocuments();
|
||||
}
|
||||
document = comp.getDocument(CharacterGenerator._getRandomArrayValue(Array.from(comp.keys())));
|
||||
document = comp.getDocument(CharacterGenerator._getRandomArrayValue(Array.from(comp.index.keys())));
|
||||
}
|
||||
await game.l5r5e.HelpersL5r5e.refreshItemProperties(document);
|
||||
return document;
|
||||
@@ -145,7 +145,7 @@ export class CharacterGenerator {
|
||||
const randomNames = await game.l5r5e.HelpersL5r5e.drawManyFromPack("l5r5e.core-name-tables", table, 1, {
|
||||
displayChat: false,
|
||||
});
|
||||
return randomNames?.results[0]?.data.text || "";
|
||||
return randomNames?.results[0]?.text || "";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,8 +387,8 @@ export class CharacterGenerator {
|
||||
//<editor-fold desc="toActor generators">
|
||||
/**
|
||||
* Generate attributes (rings, attributes, skills, confrontation ranks)
|
||||
* @param {boolean} isNpc
|
||||
* @param {DocumentData.data} actorDatas
|
||||
* @param {boolean} isNpc
|
||||
* @param {DocumentData.system} actorDatas
|
||||
* @private
|
||||
*/
|
||||
_generateAttributes(isNpc, actorDatas) {
|
||||
@@ -425,7 +425,7 @@ export class CharacterGenerator {
|
||||
|
||||
/**
|
||||
* Generate Demeanor (npc only)
|
||||
* @param {DocumentData.data} actorDatas
|
||||
* @param {DocumentData.system} actorDatas
|
||||
* @private
|
||||
*/
|
||||
_generateDemeanor(actorDatas) {
|
||||
@@ -462,7 +462,7 @@ export class CharacterGenerator {
|
||||
for (const pack of ["adversities", "distinctions", "passions", "anxieties"]) {
|
||||
const item = await CharacterGenerator._getItemFromPack(`l5r5e.core-peculiarities-${pack}`);
|
||||
if (item) {
|
||||
newItemsData.push(foundry.utils.duplicate(item.data));
|
||||
newItemsData.push(foundry.utils.duplicate(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -506,7 +506,7 @@ export class CharacterGenerator {
|
||||
for (const itemId of itemCfg[pack]) {
|
||||
const item = await CharacterGenerator._getItemFromPack(`l5r5e.core-${pack}`, itemId);
|
||||
if (item) {
|
||||
newItemsData.push(foundry.utils.duplicate(item.data));
|
||||
newItemsData.push(foundry.utils.duplicate(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -616,8 +616,7 @@ export class CharacterGenerator {
|
||||
} while (item && item.system.rank > avgrv);
|
||||
|
||||
if (item) {
|
||||
console.log(item); //todo tmp check this!
|
||||
newItemsData.push(foundry.utils.duplicate(item.data));
|
||||
newItemsData.push(foundry.utils.duplicate(item));
|
||||
}
|
||||
} // fr qty
|
||||
} // fr techCfg
|
||||
@@ -625,7 +624,7 @@ export class CharacterGenerator {
|
||||
|
||||
/**
|
||||
* Fill notes with some values that don't appear in sheet
|
||||
* @param {DocumentData.data} actorDatas
|
||||
* @param {DocumentData.system} actorDatas
|
||||
* @return {Promise<void>}
|
||||
* @private
|
||||
*/
|
||||
@@ -671,7 +670,7 @@ export class CharacterGenerator {
|
||||
|
||||
/**
|
||||
* Generate Narrative fluff
|
||||
* @param {DocumentData.data} actorDatas
|
||||
* @param {DocumentData.system} actorDatas
|
||||
* @private
|
||||
*/
|
||||
_generateNarrative(actorDatas) {
|
||||
|
||||
@@ -190,7 +190,7 @@ export class DicePickerDialog extends FormApplication {
|
||||
set targetInfos(targetToken) {
|
||||
this.object.targetInfos = targetToken
|
||||
? {
|
||||
img: targetToken.img,
|
||||
img: targetToken.texture.src || null,
|
||||
name: targetToken.name,
|
||||
}
|
||||
: null;
|
||||
|
||||
@@ -548,8 +548,8 @@ export class RollnKeepDialog extends FormApplication {
|
||||
roll,
|
||||
game.user,
|
||||
true,
|
||||
this._message.data.whisper.length === 0 ? null : this._message.data.whisper,
|
||||
this._message.data.blind
|
||||
this._message.whisper.length === 0 ? null : this._message.whisper,
|
||||
this._message.blind
|
||||
);
|
||||
}
|
||||
|
||||
@@ -657,7 +657,7 @@ export class RollnKeepDialog extends FormApplication {
|
||||
if (this.roll.l5r5e.isInitiativeRoll) {
|
||||
let msgOptions = {
|
||||
rnkRoll: this.roll,
|
||||
rollMode: game.l5r5e.HelpersL5r5e.getRollMode(this._message.data),
|
||||
rollMode: game.l5r5e.HelpersL5r5e.getRollMode(this._message),
|
||||
};
|
||||
|
||||
await this.roll.l5r5e.actor.rollInitiative({
|
||||
@@ -673,7 +673,7 @@ export class RollnKeepDialog extends FormApplication {
|
||||
// Send it to chat, switch to new message
|
||||
this.message = await this.roll.toMessage(
|
||||
{},
|
||||
{ rollMode: game.l5r5e.HelpersL5r5e.getRollMode(this._message.data) }
|
||||
{ rollMode: game.l5r5e.HelpersL5r5e.getRollMode(this._message) }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ export class RollL5r5e extends Roll {
|
||||
set targetInfos(targetToken) {
|
||||
this.l5r5e.targetInfos = targetToken
|
||||
? {
|
||||
img: targetToken.img,
|
||||
img: targetToken.texture.src || null,
|
||||
name: targetToken.name,
|
||||
}
|
||||
: null;
|
||||
@@ -287,8 +287,7 @@ export class RollL5r5e extends Roll {
|
||||
isPublicRoll: !isPrivate,
|
||||
tooltip: isPrivate ? "" : await this.getTooltip({ from: "render" }),
|
||||
total: isPrivate ? "?" : this.total,
|
||||
//data: this.data,
|
||||
profileImg: this.l5r5e.actor?.img ? this.l5r5e.actor?.img : "icons/svg/mystery-man.svg",
|
||||
profileImg: this.l5r5e.actor?.img || "icons/svg/mystery-man.svg",
|
||||
l5r5e: isPrivate
|
||||
? {}
|
||||
: {
|
||||
|
||||
@@ -129,7 +129,7 @@ export class HelpersL5r5e {
|
||||
* @param {string} uuid "Item.5qI6SU85VSFqji8W"
|
||||
* @param {string} id "5qI6SU85VSFqji8W"
|
||||
* @param {string} type Type ("Item", "JournalEntry"...)
|
||||
* @param {any[]|null} data Plain data
|
||||
* @param {any[]|null} data Plain document data
|
||||
* @param {string|null} pack Pack name
|
||||
* @param {string|null} parentId Used to avoid an infinite loop in properties if set
|
||||
* @return {Promise<null>}
|
||||
|
||||
Reference in New Issue
Block a user