Macro pour compétences de créature
This commit is contained in:
parent
5c256e2c49
commit
7b18fd25c3
@ -1,3 +1,4 @@
|
||||
import { TYPES } from "./item.js";
|
||||
|
||||
export class RdDHotbar {
|
||||
|
||||
@ -16,21 +17,29 @@ export class RdDHotbar {
|
||||
}
|
||||
|
||||
static async addToHotbar(item, slot) {
|
||||
if (item?.type == "arme") { // Used to manage weapons with multiple skills
|
||||
if (item.system.competence != "") {
|
||||
await this.createItemMacro(item, slot, "competence")
|
||||
slot++
|
||||
}
|
||||
if (item.system.lancer != "") {
|
||||
await this.createItemMacro(item, slot, "lancer")
|
||||
slot++
|
||||
}
|
||||
if (item.system.tir != "") {
|
||||
await this.createItemMacro(item, slot, "lancer")
|
||||
slot++
|
||||
}
|
||||
} else {
|
||||
await this.createItemMacro(item, slot)
|
||||
switch (item?.type ?? "") {
|
||||
case TYPES.arme:
|
||||
{
|
||||
// Les armes peuvent avoir plusieurs usages
|
||||
if (item.system.competence != "") {
|
||||
await this.createItemMacro(item, slot, "competence")
|
||||
slot++
|
||||
}
|
||||
if (item.system.lancer != "") {
|
||||
await this.createItemMacro(item, slot, "lancer")
|
||||
slot++
|
||||
}
|
||||
if (item.system.tir != "") {
|
||||
await this.createItemMacro(item, slot, "lancer")
|
||||
slot++
|
||||
}
|
||||
}
|
||||
return
|
||||
case TYPES.competence:
|
||||
case TYPES.competencecreature:
|
||||
default:
|
||||
await this.createItemMacro(item, slot)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,16 +55,16 @@ export class RdDHotbar {
|
||||
|
||||
// Create item macro if rollable item - weapon, spell, prayer, trait, or skill
|
||||
if (documentData.type == "Item") {
|
||||
let item = fromUuidSync(documentData.uuid)
|
||||
if (item == undefined) {
|
||||
item = this.actor.items.get(documentData.uuid)
|
||||
}
|
||||
const item = fromUuidSync(documentData.uuid) ?? this.actor.items.get(documentData.uuid)
|
||||
console.log("DROP", documentData, item)
|
||||
if (!item || (item.type != "arme" && item.type != "competence")) {
|
||||
return true
|
||||
switch (item?.type ?? "")
|
||||
{
|
||||
case TYPES.arme:
|
||||
case TYPES.competence:
|
||||
case TYPES.competencecreature:
|
||||
this.addToHotbar(item, slot)
|
||||
return false
|
||||
}
|
||||
this.addToHotbar(item, slot)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
@ -68,7 +77,9 @@ export class RdDHotbar {
|
||||
let actor;
|
||||
if (speaker.token) actor = game.actors.tokens[speaker.token];
|
||||
if (!actor) actor = game.actors.get(speaker.actor);
|
||||
|
||||
if (!actor) {
|
||||
return ui.notifications.warn(`Impossible de trouver le personnage concerné`);
|
||||
}
|
||||
let item = actor?.items.find(it => it.name === itemName && it.type == itemType) ?? undefined;
|
||||
if (!item) {
|
||||
return ui.notifications.warn(`Impossible de trouver l'objet de cette macro`);
|
||||
@ -76,9 +87,10 @@ export class RdDHotbar {
|
||||
|
||||
// Trigger the item roll
|
||||
switch (item.type) {
|
||||
case "arme":
|
||||
case TYPES.arme:
|
||||
return actor.rollArme(item, competenceName);
|
||||
case "competence":
|
||||
case TYPES.competence:
|
||||
case TYPES.competencecreature:
|
||||
return actor.rollCompetence(itemName);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user