Roll : Added target info in Roll
This commit is contained in:
@@ -139,6 +139,12 @@ export class DicePickerDialog extends FormApplication {
|
||||
this.skillCatId = options.skillCatId;
|
||||
}
|
||||
|
||||
// Target Infos : get the 1st selected target
|
||||
const targetToken = Array.from(game.user.targets).values().next()?.value?.document;
|
||||
if (targetToken) {
|
||||
this.targetInfos = targetToken;
|
||||
}
|
||||
|
||||
// Difficulty
|
||||
if (!options.difficulty || !this.parseDifficulty(options.difficulty)) {
|
||||
this.difficulty = game.settings.get("l5r5e", "initiative-difficulty-value");
|
||||
@@ -167,7 +173,7 @@ export class DicePickerDialog extends FormApplication {
|
||||
|
||||
/**
|
||||
* Set actor
|
||||
* @param actor
|
||||
* @param {ActorL5r5e} actor
|
||||
*/
|
||||
set actor(actor) {
|
||||
if (!actor || !(actor instanceof Actor) || !actor.isOwner) {
|
||||
@@ -177,13 +183,26 @@ export class DicePickerDialog extends FormApplication {
|
||||
this.ringId = this._actor.data.data.stance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Target Infos (Name, Img)
|
||||
* @param {TokenDocument} targetToken
|
||||
*/
|
||||
set targetInfos(targetToken) {
|
||||
this.object.targetInfos = targetToken
|
||||
? {
|
||||
img: targetToken.data.img,
|
||||
name: targetToken.data.name,
|
||||
}
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ring preset
|
||||
* @param ringId
|
||||
*/
|
||||
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];
|
||||
this.object.ring.value = this._actor.data.data.rings?.[this.object.ring.id] || 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,7 +341,9 @@ export class DicePickerDialog extends FormApplication {
|
||||
actor: this._actor,
|
||||
useCategory: this.useCategory,
|
||||
canUseVoidPoint:
|
||||
this.object.difficulty.addVoidPoint || !this._actor || this._actor.data.data.void_points.value > 0,
|
||||
this.object.difficulty.addVoidPoint ||
|
||||
!this._actor ||
|
||||
(this._actor.isCharacter && this._actor.data.data.void_points.value > 0),
|
||||
disableSubmit: this.object.skill.value < 1 && this.object.ring.value < 1,
|
||||
difficultyHiddenIsLock: this._difficultyHiddenIsLock.gm || this._difficultyHiddenIsLock.option,
|
||||
};
|
||||
@@ -632,13 +653,13 @@ export class DicePickerDialog extends FormApplication {
|
||||
let targetToken;
|
||||
if (isMin === null) {
|
||||
// only one target, get the first element
|
||||
targetToken = Array.from(game.user.targets).values().next()?.value.document;
|
||||
targetToken = Array.from(game.user.targets).values().next()?.value?.document;
|
||||
} else {
|
||||
// Group (Min/Max)
|
||||
const targetGrp = Array.from(game.user.targets).reduce(
|
||||
(acc, tgt) => {
|
||||
const targetActor = tgt.document.actor;
|
||||
if (!["character", "npc"].includes(targetActor.type)) {
|
||||
if (!targetActor.isCharacter) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
@@ -727,10 +748,7 @@ export class DicePickerDialog extends FormApplication {
|
||||
if (infos[1] === "T") {
|
||||
this.difficultyHidden = true;
|
||||
this._difficultyHiddenIsLock.option = true;
|
||||
this.object.targetInfos = {
|
||||
img: targetToken.data.img,
|
||||
name: targetToken.data.name,
|
||||
};
|
||||
this.targetInfos = targetToken;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ export class RollnKeepDialog extends FormApplication {
|
||||
return {
|
||||
...super.getData(options),
|
||||
isGM: game.user.isGM,
|
||||
showStrifeBt: rollData.summary.strife > 0 && rollData.actor,
|
||||
showStrifeBt: rollData.summary.strife > 0 && rollData.actor?.isCharacter,
|
||||
cssClass: this.options.classes.join(" "),
|
||||
data: this.object,
|
||||
l5r5e: rollData,
|
||||
@@ -706,7 +706,7 @@ export class RollnKeepDialog extends FormApplication {
|
||||
// Apply strife to actor
|
||||
const strifeApplied = Math.min(this.roll.l5r5e.summary.strife, Math.max(0, formData.strifeApplied));
|
||||
const actorMod = strifeApplied - this.roll.l5r5e.strifeApplied;
|
||||
if (actorMod !== 0 && this.roll.l5r5e.actor) {
|
||||
if (actorMod !== 0 && this.roll.l5r5e.actor?.isCharacter) {
|
||||
await this.roll.l5r5e.actor.update({
|
||||
data: {
|
||||
strife: {
|
||||
|
||||
@@ -5,39 +5,42 @@ export class RollL5r5e extends Roll {
|
||||
static CHAT_TEMPLATE = "dice/chat-roll.html";
|
||||
static TOOLTIP_TEMPLATE = "dice/tooltip.html";
|
||||
|
||||
/**
|
||||
* Specific data for L5R
|
||||
*/
|
||||
l5r5e = {
|
||||
actor: null,
|
||||
dicesTypes: {
|
||||
std: false,
|
||||
l5r: false,
|
||||
},
|
||||
difficulty: 2,
|
||||
difficultyHidden: false,
|
||||
history: null,
|
||||
initialFormula: null,
|
||||
isInitiativeRoll: false,
|
||||
keepLimit: null,
|
||||
rnkEnded: false,
|
||||
skillAssistance: 0,
|
||||
skillCatId: "",
|
||||
skillId: "",
|
||||
stance: "",
|
||||
strifeApplied: 0,
|
||||
summary: {
|
||||
totalSuccess: 0,
|
||||
totalBonus: 0,
|
||||
success: 0,
|
||||
explosive: 0,
|
||||
opportunity: 0,
|
||||
strife: 0,
|
||||
},
|
||||
targetInfos: null,
|
||||
voidPointUsed: false,
|
||||
};
|
||||
|
||||
constructor(formula, data = {}, options = {}) {
|
||||
super(formula, data, options);
|
||||
|
||||
this.l5r5e = {
|
||||
actor: null,
|
||||
dicesTypes: {
|
||||
std: false,
|
||||
l5r: false,
|
||||
},
|
||||
difficulty: 2,
|
||||
difficultyHidden: false,
|
||||
history: null,
|
||||
initialFormula: null,
|
||||
isInitiativeRoll: false,
|
||||
keepLimit: null,
|
||||
rnkEnded: false,
|
||||
skillAssistance: 0,
|
||||
skillCatId: "",
|
||||
skillId: "",
|
||||
stance: "",
|
||||
strifeApplied: 0,
|
||||
summary: {
|
||||
totalSuccess: 0,
|
||||
totalBonus: 0,
|
||||
success: 0,
|
||||
explosive: 0,
|
||||
opportunity: 0,
|
||||
strife: 0,
|
||||
},
|
||||
targetInfos: null,
|
||||
voidPointUsed: false,
|
||||
};
|
||||
|
||||
// Parse flavor for stance and skillId
|
||||
const flavors = Array.from(formula.matchAll(/\d+d([sr])\[([^\]]+)\]/gmu));
|
||||
flavors.forEach((res) => {
|
||||
@@ -48,12 +51,35 @@ export class RollL5r5e extends Roll {
|
||||
this.l5r5e.skillId = res[2];
|
||||
}
|
||||
});
|
||||
|
||||
// Target Infos : get the 1st selected target
|
||||
const targetToken = Array.from(game.user.targets).values().next()?.value?.document;
|
||||
if (targetToken) {
|
||||
this.targetInfos = targetToken;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set actor
|
||||
* @param {ActorL5r5e} actor
|
||||
*/
|
||||
set actor(actor) {
|
||||
this.l5r5e.actor = actor instanceof Actor && actor.isOwner ? actor : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Target Infos (Name, Img)
|
||||
* @param {TokenDocument} targetToken
|
||||
*/
|
||||
set targetInfos(targetToken) {
|
||||
this.l5r5e.targetInfos = targetToken
|
||||
? {
|
||||
img: targetToken.data.img,
|
||||
name: targetToken.data.name,
|
||||
}
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the Roll, replacing dice and evaluating the total result
|
||||
* @override
|
||||
|
||||
Reference in New Issue
Block a user