Amélioration du split
Bouton split géré avec itemActions Ajout d'un bouton pour augmenter les piles (pour le MJ)
This commit is contained in:
@ -2,7 +2,6 @@ import { ITEM_TYPES } from "../constants.js";
|
||||
import { Grammar } from "../grammar.js";
|
||||
import { RdDItem } from "../item.js";
|
||||
import { SystemCompendiums } from "../settings/system-compendiums.js";
|
||||
import { ITEM_ACTIONS } from "./item-actions.js";
|
||||
import { DialogEnchanter } from "./potion/dialog-enchanter.js";
|
||||
|
||||
const POTION_MAGIQUE = ['AlchimieEnchante', 'ReposEnchante', 'SoinEnchante', 'AutreEnchante']
|
||||
@ -15,6 +14,19 @@ const MAP_CATEGORIE_ENCHANTEMENT = [
|
||||
{ basique: 'Soin', enchante: 'SoinEnchante' },
|
||||
{ basique: 'Autre', enchante: 'AutreEnchante' }]
|
||||
|
||||
const _CONSOMMER_POTION = {
|
||||
code: 'item-potion-consommer', label: 'Consommer', icon: it => 'fa-solid fa-vial',
|
||||
optionsFilter: options => options.editable,
|
||||
action: (item, actor) => actor.consommerPotion(item)
|
||||
}
|
||||
|
||||
const _ENCHANTER = {
|
||||
code: 'item-enchanter', label: 'Enchanter', icon: it => 'fa-solid fa-sparkles',
|
||||
filter: it => game.user.isGM || it.isEnchantable(),
|
||||
optionsFilter: options => options.editable,
|
||||
action: (item, actor) => item.enchanterPotion()
|
||||
}
|
||||
|
||||
export class RdDItemPotion extends RdDItem {
|
||||
|
||||
static async herbesSoins() {
|
||||
@ -43,7 +55,7 @@ export class RdDItemPotion extends RdDItem {
|
||||
isMagique() { return POTION_MAGIQUE.includes(this.system.categorie) }
|
||||
|
||||
itemSpecificActions() {
|
||||
return ITEM_ACTIONS[ITEM_TYPES.potion]
|
||||
return [_CONSOMMER_POTION, _ENCHANTER]
|
||||
}
|
||||
|
||||
getActions(options = { warnIfNot: true }) {
|
||||
@ -94,8 +106,6 @@ export class RdDItemPotion extends RdDItem {
|
||||
const nouveauReve = Math.max(this.system.pr - 1, 0)
|
||||
return {
|
||||
_id: this.id,
|
||||
name: this.name,
|
||||
img: this.img,
|
||||
'system.pr': nouveauReve,
|
||||
'system.quantite': nouveauReve > 0 ? this.system.quantite : 0,
|
||||
'system.magique': nouveauReve > 0
|
||||
@ -107,6 +117,7 @@ export class RdDItemPotion extends RdDItem {
|
||||
async $onEnchanterPotion(enchanter) {
|
||||
if (enchanter.nouveaupr == 0) {
|
||||
await this.update({
|
||||
name: this.name, // TODO: enlever "enchantée" ?
|
||||
'system.pr': 0,
|
||||
'system.purifie': false,
|
||||
'system.magique': false,
|
||||
@ -118,6 +129,7 @@ export class RdDItemPotion extends RdDItem {
|
||||
}
|
||||
else {
|
||||
await this.update({
|
||||
name: this.name, // TODO: ajout "enchantée" ?
|
||||
'system.pr': enchanter.nouveaupr,
|
||||
'system.purifie': enchanter.purifier,
|
||||
'system.magique': true,
|
||||
|
Reference in New Issue
Block a user