Working on Compatibility for FVTT v10
Added `itemUuid` to Roll/RnK
This commit is contained in:
@@ -6,6 +6,7 @@ __! Be certain to carefully back up any critical user data before installing thi
|
|||||||
- Updated the System to FoundryVTT v10.
|
- Updated the System to FoundryVTT v10.
|
||||||
- Removed restriction on technique types when dropping a technique (Sheet and 20Q. #39).
|
- Removed restriction on technique types when dropping a technique (Sheet and 20Q. #39).
|
||||||
- Added a `game.user.isFirstGM` property for some traitements (socket and migration) to prevent multiple executions with multiple GM connected.
|
- Added a `game.user.isFirstGM` property for some traitements (socket and migration) to prevent multiple executions with multiple GM connected.
|
||||||
|
- Added `itemUuid` to Roll/RnK for technique and weapons to be readable in ChatMessage (use `fromUuid()` / `fromUuidSync()` to get the object).
|
||||||
- Updated the initiative behaviour, he now open the DicePicker for connected players.
|
- Updated the initiative behaviour, he now open the DicePicker for connected players.
|
||||||
- Added socket API `openDicePicker` to remotely open the DicePicker (see usage below).
|
- Added socket API `openDicePicker` to remotely open the DicePicker (see usage below).
|
||||||
|
|
||||||
|
|||||||
@@ -594,15 +594,21 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the skillId for this weaponId
|
* Get the skillId and uuid for this weaponId
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_getWeaponSkillId(weaponId) {
|
_getWeaponInfos(weaponId) {
|
||||||
const item = this.actor.items.get(weaponId);
|
if (!weaponId) {
|
||||||
if (!!item && item.type === "weapon") {
|
return null;
|
||||||
return item.system.skill;
|
|
||||||
}
|
}
|
||||||
return null;
|
const item = this.actor.items.get(weaponId);
|
||||||
|
if (!item || item.type !== "weapon") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
uuid: item.uuid,
|
||||||
|
skill: item.system.skill,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -614,19 +620,15 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
const li = $(event.currentTarget);
|
const li = $(event.currentTarget);
|
||||||
let skillId = li.data("skill") || null;
|
const weapon = this._getWeaponInfos(li.data("weapon-id") || null);
|
||||||
|
|
||||||
const weaponId = li.data("weapon-id") || null;
|
|
||||||
if (weaponId) {
|
|
||||||
skillId = this._getWeaponSkillId(weaponId);
|
|
||||||
}
|
|
||||||
|
|
||||||
new game.l5r5e.DicePickerDialog({
|
new game.l5r5e.DicePickerDialog({
|
||||||
ringId: li.data("ring") || null,
|
ringId: li.data("ring") || null,
|
||||||
skillId: skillId,
|
skillId: weapon?.skill || li.data("skill") || null,
|
||||||
skillCatId: li.data("skillcat") || null,
|
skillCatId: li.data("skillcat") || null,
|
||||||
isInitiativeRoll: li.data("initiative") || false,
|
isInitiativeRoll: li.data("initiative") || false,
|
||||||
actor: this.actor,
|
actor: this.actor,
|
||||||
|
itemUuid: weapon?.uuid,
|
||||||
}).render(true);
|
}).render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -651,6 +653,7 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
|||||||
ringId: itemData.ring || null,
|
ringId: itemData.ring || null,
|
||||||
difficulty: itemData.difficulty || null,
|
difficulty: itemData.difficulty || null,
|
||||||
skillsList: itemData.skill || null,
|
skillsList: itemData.skill || null,
|
||||||
|
itemUuid: item.uuid,
|
||||||
}).render(true);
|
}).render(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
targetInfos: null,
|
targetInfos: null,
|
||||||
useVoidPoint: false,
|
useVoidPoint: false,
|
||||||
isInitiativeRoll: false,
|
isInitiativeRoll: false,
|
||||||
|
itemUuid: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,8 +108,9 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
* difficulty number (0-9)
|
* difficulty number (0-9)
|
||||||
* difficultyHidden boolean
|
* difficultyHidden boolean
|
||||||
* isInitiativeRoll boolean
|
* isInitiativeRoll boolean
|
||||||
|
* itemUuid string
|
||||||
*
|
*
|
||||||
* @param options actor, actorId, ringId, actorName, skillId, skillCatId, difficulty, difficultyHidden, isInitiativeRoll
|
* @param options actor, actorId, ringId, actorName, skillId, skillCatId, difficulty, difficultyHidden, isInitiativeRoll, itemUuid
|
||||||
*/
|
*/
|
||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
super({}, options);
|
super({}, options);
|
||||||
@@ -165,6 +167,11 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
|
|
||||||
// InitiativeRoll
|
// InitiativeRoll
|
||||||
this.object.isInitiativeRoll = !!options.isInitiativeRoll;
|
this.object.isInitiativeRoll = !!options.isInitiativeRoll;
|
||||||
|
|
||||||
|
// Item UUID (weapon/technique)
|
||||||
|
if (options.itemUuid) {
|
||||||
|
this.object.itemUuid = options.itemUuid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -533,11 +540,12 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
// Initiative roll
|
// Initiative roll
|
||||||
let msgOptions = {
|
let msgOptions = {
|
||||||
skillId: this.object.skill.id,
|
skillId: this.object.skill.id,
|
||||||
|
itemUuid: this.object.itemUuid,
|
||||||
|
rnkMessage: null,
|
||||||
difficulty: this.object.difficulty.value,
|
difficulty: this.object.difficulty.value,
|
||||||
difficultyHidden: this.object.difficulty.hidden,
|
|
||||||
useVoidPoint: this.object.useVoidPoint,
|
useVoidPoint: this.object.useVoidPoint,
|
||||||
skillAssistance: this.object.skill.assistance,
|
skillAssistance: this.object.skill.assistance,
|
||||||
rnkMessage: null,
|
difficultyHidden: this.object.difficulty.hidden,
|
||||||
};
|
};
|
||||||
|
|
||||||
await this._actor.rollInitiative({
|
await this._actor.rollInitiative({
|
||||||
@@ -558,12 +566,13 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
roll.actor = this._actor;
|
roll.actor = this._actor;
|
||||||
roll.l5r5e.stance = this.object.ring.id;
|
roll.l5r5e.stance = this.object.ring.id;
|
||||||
roll.l5r5e.skillId = this.object.skill.id;
|
roll.l5r5e.skillId = this.object.skill.id;
|
||||||
|
roll.l5r5e.itemUuid = this.object.itemUuid;
|
||||||
roll.l5r5e.skillCatId = this.object.skill.cat;
|
roll.l5r5e.skillCatId = this.object.skill.cat;
|
||||||
roll.l5r5e.difficulty = this.object.difficulty.value;
|
roll.l5r5e.difficulty = this.object.difficulty.value;
|
||||||
roll.l5r5e.difficultyHidden = this.object.difficulty.hidden;
|
roll.l5r5e.targetInfos = this.object.targetInfos;
|
||||||
roll.l5r5e.voidPointUsed = this.object.useVoidPoint;
|
roll.l5r5e.voidPointUsed = this.object.useVoidPoint;
|
||||||
roll.l5r5e.skillAssistance = this.object.skill.assistance;
|
roll.l5r5e.skillAssistance = this.object.skill.assistance;
|
||||||
roll.l5r5e.targetInfos = this.object.targetInfos;
|
roll.l5r5e.difficultyHidden = this.object.difficulty.hidden;
|
||||||
|
|
||||||
await roll.roll();
|
await roll.roll();
|
||||||
message = await roll.toMessage();
|
message = await roll.toMessage();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export class RollL5r5e extends Roll {
|
|||||||
skillCatId: "",
|
skillCatId: "",
|
||||||
skillId: "",
|
skillId: "",
|
||||||
stance: "",
|
stance: "",
|
||||||
|
itemUuid: null,
|
||||||
strifeApplied: 0,
|
strifeApplied: 0,
|
||||||
summary: {
|
summary: {
|
||||||
totalSuccess: 0,
|
totalSuccess: 0,
|
||||||
@@ -359,7 +360,7 @@ export class RollL5r5e extends Roll {
|
|||||||
rollMode: rMode,
|
rollMode: rMode,
|
||||||
temporary: !create,
|
temporary: !create,
|
||||||
});
|
});
|
||||||
return create ? message : message.data;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
|
|||||||
@@ -15,6 +15,44 @@ export class ItemL5r5e extends Item {
|
|||||||
return super.actor || game.actors.get(this.system.parent_id?.actor_id) || null;
|
return super.actor || game.actors.get(this.system.parent_id?.actor_id) || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Universally Unique Identifier (uuid) for this Document instance patched for embedded items on items
|
||||||
|
* @type {string}
|
||||||
|
* @memberof ClientDocumentMixin#
|
||||||
|
*/
|
||||||
|
get uuid() {
|
||||||
|
const uuid = [];
|
||||||
|
const parents = this.system.parent_id;
|
||||||
|
|
||||||
|
if (parents?.item_id) {
|
||||||
|
if (parents?.actor_id) {
|
||||||
|
uuid.push(`Actor.${parents.actor_id}`);
|
||||||
|
}
|
||||||
|
uuid.push(`Item.${parents.item_id}`);
|
||||||
|
}
|
||||||
|
uuid.push(super.uuid);
|
||||||
|
|
||||||
|
return uuid.join(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a reference to the Array of source data within the data object for a certain embedded Document name
|
||||||
|
*
|
||||||
|
* TODO probably useless if we can add "items" in metadata.embedded, but no clue how to.
|
||||||
|
*
|
||||||
|
* @param {string} embeddedName The name of the embedded Document type
|
||||||
|
* @return {Collection} The Collection instance of embedded Documents of the requested type
|
||||||
|
*/
|
||||||
|
getEmbeddedCollection(embeddedName) {
|
||||||
|
const collectionName = embeddedName === "Item" ? "items" : this.constructor.metadata.embedded[embeddedName];
|
||||||
|
if (!collectionName) {
|
||||||
|
throw new Error(
|
||||||
|
`${embeddedName} is not a valid embedded Document within the ${this.documentName} Document`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return this[collectionName];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new entity using provided input data
|
* Create a new entity using provided input data
|
||||||
* @override
|
* @override
|
||||||
|
|||||||
Reference in New Issue
Block a user