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:
parent
8969d5e0ed
commit
6083dd41fa
@ -108,7 +108,6 @@ export class RdDBaseActorSheet extends ActorSheet {
|
|||||||
|
|
||||||
this.html.find('.item-equip-armure').click(async event => this.actor.equiperObjet(this.getItem(event)))
|
this.html.find('.item-equip-armure').click(async event => this.actor.equiperObjet(this.getItem(event)))
|
||||||
this.html.find('.item-delete').click(async event => RdDUtility.confirmActorItemDelete(this.getItem(event), this.actor));
|
this.html.find('.item-delete').click(async event => RdDUtility.confirmActorItemDelete(this.getItem(event), this.actor));
|
||||||
this.html.find('.item-split').click(async event => RdDSheetUtility.splitItem(this.getItem(event), this.actor))
|
|
||||||
this.html.find('.item-quantite-plus').click(async event => this.actor.itemQuantiteIncDec(this.getItemId(event), 1));
|
this.html.find('.item-quantite-plus').click(async event => this.actor.itemQuantiteIncDec(this.getItemId(event), 1));
|
||||||
this.html.find('.item-quantite-moins').click(async event => this.actor.itemQuantiteIncDec(this.getItemId(event), -1));
|
this.html.find('.item-quantite-moins').click(async event => this.actor.itemQuantiteIncDec(this.getItemId(event), -1));
|
||||||
|
|
||||||
|
@ -200,23 +200,19 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
this.html.find('.chat-roll-text').click(async event => await RdDTextEditor.chatRollText(event))
|
this.html.find('.chat-roll-text').click(async event => await RdDTextEditor.chatRollText(event))
|
||||||
|
|
||||||
if (this.actor) {
|
if (this.actor) {
|
||||||
// TODO
|
|
||||||
this.html.find('.actionItem').click(event => ItemAction.onActionItem(event, this.actor, this.options))
|
this.html.find('.actionItem').click(event => ItemAction.onActionItem(event, this.actor, this.options))
|
||||||
|
|
||||||
|
// TODO: utiliser un itemAction?
|
||||||
this.html.find('.item-potion-consommer').click(event => this.itemActionConsommer(event))
|
this.html.find('.item-potion-consommer').click(event => this.itemActionConsommer(event))
|
||||||
|
|
||||||
this.html.find('.item-split').click( event => this.itemActionSplit(event))
|
|
||||||
this.html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true));
|
|
||||||
this.html.find('.item-delete').click(async event => this.itemActionDelete(event));
|
|
||||||
|
|
||||||
this.html.find('.item-quantite-plus').click(async event => {
|
this.html.find('.item-quantite-plus').click(async event => {
|
||||||
await this.actor.itemQuantiteIncDec(RdDSheetUtility.getItemId(event), 1)
|
await this.actor.itemQuantiteIncDec(RdDSheetUtility.getItemId(event), 1)
|
||||||
this.render();
|
this.render()
|
||||||
});
|
})
|
||||||
this.html.find('.item-quantite-moins').click(async event => {
|
this.html.find('.item-quantite-moins').click(async event => {
|
||||||
await this.actor.itemQuantiteIncDec(RdDSheetUtility.getItemId(event), -1)
|
await this.actor.itemQuantiteIncDec(RdDSheetUtility.getItemId(event), -1)
|
||||||
this.render();
|
this.render()
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateItemTimestamp = (path, timestamp) => this.item.update({ [path]: foundry.utils.duplicate(timestamp) })
|
const updateItemTimestamp = (path, timestamp) => this.item.update({ [path]: foundry.utils.duplicate(timestamp) })
|
||||||
|
@ -27,6 +27,12 @@ const _MONTRER = {
|
|||||||
code: 'item-montrer', label: 'Montrer', icon: it => 'fa-solid fa-comment',
|
code: 'item-montrer', label: 'Montrer', icon: it => 'fa-solid fa-comment',
|
||||||
action: (item, actor) => item.postItemToChat()
|
action: (item, actor) => item.postItemToChat()
|
||||||
}
|
}
|
||||||
|
const _SPLIT = {
|
||||||
|
code: 'item-split', label: 'Séparer le goupe', icon: it => 'fa-solid fa-unlink',
|
||||||
|
filter: it => Misc.toInt(it.system.quantite) > 1,
|
||||||
|
action: (item, actor) => RdDSheetUtility.splitItem(item, actor)
|
||||||
|
}
|
||||||
|
|
||||||
const _EDIT = {
|
const _EDIT = {
|
||||||
code: 'item-edit', label: 'Editer', icon: it => 'fa-solid fa-edit',
|
code: 'item-edit', label: 'Editer', icon: it => 'fa-solid fa-edit',
|
||||||
action: (item, actor) => item.sheet.render(true)
|
action: (item, actor) => item.sheet.render(true)
|
||||||
@ -89,19 +95,6 @@ const _REFOULER = {
|
|||||||
action: (item, actor) => actor.actionRefoulement(item)
|
action: (item, actor) => actor.actionRefoulement(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 => it.isEnchantable(),
|
|
||||||
optionsFilter: options => options.editable,
|
|
||||||
action: (item, actor) => item.enchanterPotion()
|
|
||||||
}
|
|
||||||
|
|
||||||
const _SORT_RESERVE = {
|
const _SORT_RESERVE = {
|
||||||
code: 'item-sortreserve-add', label: 'Ajouter en réserve', icon: it => 'fa-solid fa-sparkles',
|
code: 'item-sortreserve-add', label: 'Ajouter en réserve', icon: it => 'fa-solid fa-sparkles',
|
||||||
filter: it => game.user.isGM && !it.system.isrituel,
|
filter: it => game.user.isGM && !it.system.isrituel,
|
||||||
@ -109,7 +102,7 @@ const _SORT_RESERVE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const COMMON_ACTIONS = [_EQUIPER]
|
export const COMMON_ACTIONS = [_EQUIPER]
|
||||||
export const DEFAULT_ACTIONS = [_SPACEHOLDER, _VENDRE, _MONTRER, _EDIT, _DELETE]
|
export const DEFAULT_ACTIONS = [_SPACEHOLDER, _SPLIT, _VENDRE, _MONTRER, _EDIT, _DELETE]
|
||||||
|
|
||||||
export const ITEM_ACTIONS = {
|
export const ITEM_ACTIONS = {
|
||||||
faune: [_CUISINER, _MANGER_CRU],
|
faune: [_CUISINER, _MANGER_CRU],
|
||||||
@ -120,7 +113,6 @@ export const ITEM_ACTIONS = {
|
|||||||
nourritureboisson: [_MANGER, _BOIRE],
|
nourritureboisson: [_MANGER, _BOIRE],
|
||||||
ombre: [_REFOULER],
|
ombre: [_REFOULER],
|
||||||
plante: [_CUISINER, _MANGER_CRU],
|
plante: [_CUISINER, _MANGER_CRU],
|
||||||
potion: [_CONSOMMER_POTION, _ENCHANTER],
|
|
||||||
queue: [_REFOULER],
|
queue: [_REFOULER],
|
||||||
sort: [_SORT_RESERVE],
|
sort: [_SORT_RESERVE],
|
||||||
service: [_ACHAT_SERVICE]
|
service: [_ACHAT_SERVICE]
|
||||||
@ -130,7 +122,7 @@ export const ITEM_ACTIONS = {
|
|||||||
export class ItemAction {
|
export class ItemAction {
|
||||||
|
|
||||||
static applies(action, item, options) {
|
static applies(action, item, options) {
|
||||||
return action
|
return action && item
|
||||||
&& item.isActionAllowed(action.code)
|
&& item.isActionAllowed(action.code)
|
||||||
&& (!action.filter || action.filter(item))
|
&& (!action.filter || action.filter(item))
|
||||||
&& (!action.optionsFilter || action.optionsFilter(options))
|
&& (!action.optionsFilter || action.optionsFilter(options))
|
||||||
@ -146,7 +138,7 @@ export class ItemAction {
|
|||||||
static onActionItem(event, actor, options) {
|
static onActionItem(event, actor, options) {
|
||||||
const item = RdDSheetUtility.getItem(event, actor)
|
const item = RdDSheetUtility.getItem(event, actor)
|
||||||
const code = $(event.currentTarget).data('code')
|
const code = $(event.currentTarget).data('code')
|
||||||
const action = item.itemActions().find(it => it.code == code)
|
const action = item?.itemActions().find(it => it.code == code)
|
||||||
if (action && (!action.optionsFilter || action.optionsFilter(options))) {
|
if (action && (!action.optionsFilter || action.optionsFilter(options))) {
|
||||||
action.action(item, actor)
|
action.action(item, actor)
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ import { ITEM_TYPES } from "../constants.js";
|
|||||||
import { Grammar } from "../grammar.js";
|
import { Grammar } from "../grammar.js";
|
||||||
import { RdDItem } from "../item.js";
|
import { RdDItem } from "../item.js";
|
||||||
import { SystemCompendiums } from "../settings/system-compendiums.js";
|
import { SystemCompendiums } from "../settings/system-compendiums.js";
|
||||||
import { ITEM_ACTIONS } from "./item-actions.js";
|
|
||||||
import { DialogEnchanter } from "./potion/dialog-enchanter.js";
|
import { DialogEnchanter } from "./potion/dialog-enchanter.js";
|
||||||
|
|
||||||
const POTION_MAGIQUE = ['AlchimieEnchante', 'ReposEnchante', 'SoinEnchante', 'AutreEnchante']
|
const POTION_MAGIQUE = ['AlchimieEnchante', 'ReposEnchante', 'SoinEnchante', 'AutreEnchante']
|
||||||
@ -15,6 +14,19 @@ const MAP_CATEGORIE_ENCHANTEMENT = [
|
|||||||
{ basique: 'Soin', enchante: 'SoinEnchante' },
|
{ basique: 'Soin', enchante: 'SoinEnchante' },
|
||||||
{ basique: 'Autre', enchante: 'AutreEnchante' }]
|
{ 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 {
|
export class RdDItemPotion extends RdDItem {
|
||||||
|
|
||||||
static async herbesSoins() {
|
static async herbesSoins() {
|
||||||
@ -43,7 +55,7 @@ export class RdDItemPotion extends RdDItem {
|
|||||||
isMagique() { return POTION_MAGIQUE.includes(this.system.categorie) }
|
isMagique() { return POTION_MAGIQUE.includes(this.system.categorie) }
|
||||||
|
|
||||||
itemSpecificActions() {
|
itemSpecificActions() {
|
||||||
return ITEM_ACTIONS[ITEM_TYPES.potion]
|
return [_CONSOMMER_POTION, _ENCHANTER]
|
||||||
}
|
}
|
||||||
|
|
||||||
getActions(options = { warnIfNot: true }) {
|
getActions(options = { warnIfNot: true }) {
|
||||||
@ -94,8 +106,6 @@ export class RdDItemPotion extends RdDItem {
|
|||||||
const nouveauReve = Math.max(this.system.pr - 1, 0)
|
const nouveauReve = Math.max(this.system.pr - 1, 0)
|
||||||
return {
|
return {
|
||||||
_id: this.id,
|
_id: this.id,
|
||||||
name: this.name,
|
|
||||||
img: this.img,
|
|
||||||
'system.pr': nouveauReve,
|
'system.pr': nouveauReve,
|
||||||
'system.quantite': nouveauReve > 0 ? this.system.quantite : 0,
|
'system.quantite': nouveauReve > 0 ? this.system.quantite : 0,
|
||||||
'system.magique': nouveauReve > 0
|
'system.magique': nouveauReve > 0
|
||||||
@ -107,6 +117,7 @@ export class RdDItemPotion extends RdDItem {
|
|||||||
async $onEnchanterPotion(enchanter) {
|
async $onEnchanterPotion(enchanter) {
|
||||||
if (enchanter.nouveaupr == 0) {
|
if (enchanter.nouveaupr == 0) {
|
||||||
await this.update({
|
await this.update({
|
||||||
|
name: this.name, // TODO: enlever "enchantée" ?
|
||||||
'system.pr': 0,
|
'system.pr': 0,
|
||||||
'system.purifie': false,
|
'system.purifie': false,
|
||||||
'system.magique': false,
|
'system.magique': false,
|
||||||
@ -118,6 +129,7 @@ export class RdDItemPotion extends RdDItem {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await this.update({
|
await this.update({
|
||||||
|
name: this.name, // TODO: ajout "enchantée" ?
|
||||||
'system.pr': enchanter.nouveaupr,
|
'system.pr': enchanter.nouveaupr,
|
||||||
'system.purifie': enchanter.purifier,
|
'system.purifie': enchanter.purifier,
|
||||||
'system.magique': true,
|
'system.magique': true,
|
||||||
|
@ -66,10 +66,12 @@ export class RdDSheetUtility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async splitItem(item, actor, onSplit = () => { }) {
|
static async splitItem(item, actor, onSplit = () => { }) {
|
||||||
const dialog = await DialogSplitItem.create(item, async (item, split) => {
|
const _onSplit = async (item, split) => {
|
||||||
await RdDSheetUtility._onSplitItem(item, split, actor);
|
await RdDSheetUtility._onSplitItem(item, split, actor);
|
||||||
onSplit();
|
onSplit();
|
||||||
});
|
await RdDSheetUtility.renderItemBranch(actor, item)
|
||||||
|
}
|
||||||
|
const dialog = await DialogSplitItem.create(item, _onSplit)
|
||||||
dialog.render(true)
|
dialog.render(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,7 +467,7 @@ table {border: 1px solid #7a7971;}
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
.equipement-nom {
|
.equipement-nom {
|
||||||
flex-grow : 4;
|
flex-grow : 3;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
<a class="item-quantite-moins" data-tooltip="Diminuer la quantité de {{item.name}}"><i class="fa-solid fa-square-minus"></i></a>
|
<a class="item-quantite-moins" data-tooltip="Diminuer la quantité de {{item.name}}"><i class="fa-solid fa-square-minus"></i></a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{item.system.quantite}}
|
{{item.system.quantite}}
|
||||||
{{#if (gt item.system.quantite 1)}}
|
{{#if @root.options.isGM}}
|
||||||
<a class="item-split" data-tooltip="Séparer le groupe de {{item.name}}"><i class="fas fa-unlink"></i></a>
|
<a class="item-quantite-plus" data-tooltip="Augmenter la quantité de {{item.name}}"><i class="fa-solid fa-square-plus"></i></a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</span>
|
</span>
|
||||||
<span class="equipement-detail">{{numberFormat item.system.encTotal decimals=2}}</span>
|
<span class="equipement-detail">{{numberFormat item.system.encTotal decimals=2}}</span>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<ul class="item-list alterne-list">
|
<ul class="item-list alterne-list">
|
||||||
<li class="competence-header flexrow">
|
<li class="competence-header flexrow">
|
||||||
<span class="equipement-nom">Nom</span>
|
<span class="equipement-nom">Nom</span>
|
||||||
<span class="equipement-detail">Q.</span>
|
<span class="equipement-detail-buttons">Q.</span>
|
||||||
<span class="equipement-detail">Enc.</span>
|
<span class="equipement-detail">Enc.</span>
|
||||||
<span class="equipement-actions">Actions</span>
|
<span class="equipement-actions">Actions</span>
|
||||||
</li>
|
</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user