Gestion des actions sur les items
- dans la liste d'équipement, liste d'actions fournie par code - support d'actions multiples - listener générique Utilisation du mécanisme pour tous les items, standardisation de l'apparence des boutons d'items
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
import { ITEM_TYPES } from "../constants.js";
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { RdDItem } from "../item.js";
|
||||
import { SystemCompendiums } from "../settings/system-compendiums.js";
|
||||
import { RdDTimestamp } from "../time/rdd-timestamp.js";
|
||||
import { ITEM_ACTIONS } from "./item-actions.js";
|
||||
import { DialogEnchanter } from "./potion/dialog-enchanter.js";
|
||||
|
||||
const POTION_MAGIQUE = ['AlchimieEnchante', 'ReposEnchante', 'SoinEnchante', 'AutreEnchante']
|
||||
@ -41,6 +42,10 @@ export class RdDItemPotion extends RdDItem {
|
||||
isEnchantable() { return POTION_ENCHANTABLE.includes(this.system.categorie) }
|
||||
isMagique() { return POTION_MAGIQUE.includes(this.system.categorie) }
|
||||
|
||||
itemSpecificActions() {
|
||||
return ITEM_ACTIONS[ITEM_TYPES.potion]
|
||||
}
|
||||
|
||||
getActions(options = { warnIfNot: true }) {
|
||||
const actionConsommer = this.prepareAction('Consommer', options.warnIfNot);
|
||||
if (this.isEnchantable()) {
|
||||
@ -53,8 +58,7 @@ export class RdDItemPotion extends RdDItem {
|
||||
actionConsommer
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
// TDOD: purifier?
|
||||
getUtilisation() {
|
||||
switch (this.system.categorie) {
|
||||
case 'Alchimie': case 'AlchimieEnchante':
|
||||
@ -89,11 +93,11 @@ export class RdDItemPotion extends RdDItem {
|
||||
if (this.system.magique && !this.system.prpermanent && this.system.pr > 0) {
|
||||
const nouveauReve = Math.max(this.system.pr - 1, 0)
|
||||
return {
|
||||
_id: it._id,
|
||||
_id: this.id,
|
||||
name: this.name,
|
||||
img: this.img,
|
||||
'system.pr': nouveauReve,
|
||||
'system.quantite': nouveauReve > 0 ? it.system.quantite : 0,
|
||||
'system.quantite': nouveauReve > 0 ? this.system.quantite : 0,
|
||||
'system.magique': nouveauReve > 0
|
||||
}
|
||||
}
|
||||
@ -113,16 +117,16 @@ export class RdDItemPotion extends RdDItem {
|
||||
})
|
||||
}
|
||||
else {
|
||||
const updates = {
|
||||
await this.update({
|
||||
'system.pr': enchanter.nouveaupr,
|
||||
'system.purifie': enchanter.purifier,
|
||||
'system.magique': true,
|
||||
'system.categorie': this.categorieEnchantement().enchante,
|
||||
'system.prpermanent': enchanter.prpermanent,
|
||||
'system.prdate': RdDItemPotion.dateEnchantement()
|
||||
}
|
||||
this.update(updates)
|
||||
})
|
||||
}
|
||||
this.sheet?.render(true)
|
||||
}
|
||||
|
||||
calculPuissance() { return this.system.herbebonus * this.system.pr }
|
||||
@ -134,7 +138,7 @@ export class RdDItemPotion extends RdDItem {
|
||||
}
|
||||
|
||||
static dateEnchantement() {
|
||||
return game.system.rdd.calendrier.getTimestamp().debutJournee()
|
||||
return game.system.rdd.calendrier.getTimestamp().debutJournee().indexDate
|
||||
}
|
||||
|
||||
static buildHerbesList(listeHerbes, max) {
|
||||
|
Reference in New Issue
Block a user