added token target id
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 1.7.0 - DiceRoller for Techniques & Npc Generator
|
## 1.7.0 - DiceRoller for Techniques & Npc Generator
|
||||||
- NPC Sheet : Added generator feature (demeanor, clan and families names courteously authorized by Edge).
|
- NPC Sheet : Added random generator feature (demeanor, clan and families names courteously authorized by Edge).
|
||||||
- PC/NPC sheet:
|
- PC/NPC sheet:
|
||||||
- Added the ability to techniques, with a skill set, to open the DicePicker with presets values.
|
- Added the ability to techniques, with a skill set, to open the DicePicker with presets values.
|
||||||
- Some can interact with targets, but do the default difficulty if none.
|
- Some can interact with targets, but do the default difficulty if none.
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
value: 2,
|
value: 2,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
addVoidPoint: false,
|
addVoidPoint: false,
|
||||||
|
targetTokenId: null,
|
||||||
},
|
},
|
||||||
useVoidPoint: false,
|
useVoidPoint: false,
|
||||||
isInitiativeRoll: false,
|
isInitiativeRoll: false,
|
||||||
@@ -528,6 +529,7 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
roll.l5r5e.difficultyHidden = this.object.difficulty.hidden;
|
roll.l5r5e.difficultyHidden = this.object.difficulty.hidden;
|
||||||
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.targetTokenId = this.object.difficulty.targetTokenId;
|
||||||
|
|
||||||
await roll.roll();
|
await roll.roll();
|
||||||
message = await roll.toMessage();
|
message = await roll.toMessage();
|
||||||
@@ -611,21 +613,21 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the actor who have the min/max value for this property
|
* Return the token actor who have the min/max value for this property
|
||||||
* @param {string} property Property name (vigilance, strife.value)
|
* @param {string} property Property name (vigilance, strife.value)
|
||||||
* @param {boolean|null} isMin Null: single target, Min/Max: get the actor who have the max value
|
* @param {boolean|null} isMin Null: single target, Min/Max: get the actor who have the max value
|
||||||
* @return {ActorL5r5e|null}
|
* @return {TokenDocument|null}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
static _getTargetActorFromSelection(property, isMin = null) {
|
static _getTargetTokenFromSelection(property, isMin = null) {
|
||||||
if (game.user.targets.size < 1) {
|
if (game.user.targets.size < 1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let targetActor;
|
let targetToken;
|
||||||
if (isMin === null) {
|
if (isMin === null) {
|
||||||
// only one target, get the first element
|
// only one target, get the first element
|
||||||
targetActor = Array.from(game.user.targets).values().next()?.value.document.actor;
|
targetToken = Array.from(game.user.targets).values().next()?.value.document.actor;
|
||||||
} else {
|
} else {
|
||||||
// Group (Min/Max)
|
// Group (Min/Max)
|
||||||
const targetGrp = Array.from(game.user.targets).reduce(
|
const targetGrp = Array.from(game.user.targets).reduce(
|
||||||
@@ -642,16 +644,16 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((isMin && value < acc.value) || (!isMin && value > acc.value)) {
|
if ((isMin && value < acc.value) || (!isMin && value > acc.value)) {
|
||||||
acc.actor = targetActor;
|
acc.actor = tgt.document;
|
||||||
acc.value = value;
|
acc.value = value;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
{ actor: null, value: 0 }
|
{ actor: null, value: 0 }
|
||||||
);
|
);
|
||||||
targetActor = targetGrp.actor;
|
targetToken = targetGrp.actor;
|
||||||
}
|
}
|
||||||
return targetActor;
|
return targetToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -686,15 +688,20 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define which actor is needed for the difficulty
|
// Define which actor is needed for the difficulty
|
||||||
let targetActor;
|
let targetActor = null;
|
||||||
|
let targetTokenId = null;
|
||||||
if (infos[1] === "S") {
|
if (infos[1] === "S") {
|
||||||
targetActor = this._actor;
|
targetActor = this._actor;
|
||||||
} else if (game.user.targets.size > 0) {
|
} else if (game.user.targets.size > 0) {
|
||||||
// Between the targets
|
// Between the targets
|
||||||
targetActor = DicePickerDialog._getTargetActorFromSelection(
|
const targetToken = DicePickerDialog._getTargetTokenFromSelection(
|
||||||
infos[4] || infos[2],
|
infos[4] || infos[2],
|
||||||
!infos[3] ? null : infos[3] === "min"
|
!infos[3] ? null : infos[3] === "min"
|
||||||
);
|
);
|
||||||
|
if (targetToken) {
|
||||||
|
targetActor = targetToken.actor;
|
||||||
|
targetTokenId = targetToken.data._id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Wrong syntax or no target set, do manual TN
|
// Wrong syntax or no target set, do manual TN
|
||||||
if (!targetActor) {
|
if (!targetActor) {
|
||||||
@@ -713,6 +720,7 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
if (infos[1] === "T") {
|
if (infos[1] === "T") {
|
||||||
this.difficultyHidden = true;
|
this.difficultyHidden = true;
|
||||||
this._difficultyHiddenIsLock.option = true;
|
this._difficultyHiddenIsLock.option = true;
|
||||||
|
this.object.difficulty.targetTokenId = targetTokenId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export class RollL5r5e extends Roll {
|
|||||||
skillId: "",
|
skillId: "",
|
||||||
skillCatId: "",
|
skillCatId: "",
|
||||||
actor: null,
|
actor: null,
|
||||||
|
targetTokenId: null,
|
||||||
difficulty: 2,
|
difficulty: 2,
|
||||||
difficultyHidden: false,
|
difficultyHidden: false,
|
||||||
voidPointUsed: false,
|
voidPointUsed: false,
|
||||||
@@ -250,6 +251,7 @@ export class RollL5r5e extends Roll {
|
|||||||
if (!this._evaluated) {
|
if (!this._evaluated) {
|
||||||
await this.roll();
|
await this.roll();
|
||||||
}
|
}
|
||||||
|
console.log(this.l5r5e);
|
||||||
|
|
||||||
// Define chat data
|
// Define chat data
|
||||||
const chatData = {
|
const chatData = {
|
||||||
|
|||||||
Reference in New Issue
Block a user