Services pour Commerces
Les services sont modifiés pour correspondre aux nouveaux commerces
This commit is contained in:
parent
87f12019ac
commit
d4ddc4e940
@ -28,7 +28,7 @@
|
|||||||
"TypeArmure": "Armure",
|
"TypeArmure": "Armure",
|
||||||
"TypeConteneur": "Conteneur",
|
"TypeConteneur": "Conteneur",
|
||||||
"TypeNourritureboisson": "Nourriture & boisson",
|
"TypeNourritureboisson": "Nourriture & boisson",
|
||||||
"TypeService": "Services/Boutique",
|
"TypeService": "Service",
|
||||||
"TypeChant": "Chant",
|
"TypeChant": "Chant",
|
||||||
"TypeDanse": "Danse",
|
"TypeDanse": "Danse",
|
||||||
"TypeMusique": "Musique",
|
"TypeMusique": "Musique",
|
||||||
|
@ -77,7 +77,6 @@ export class RdDBaseActorSheet extends ActorSheet {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
filterItemsPerTypeForSheet(formData, itemTypes) {
|
filterItemsPerTypeForSheet(formData, itemTypes) {
|
||||||
formData.services = Misc.arrayOrEmpty(itemTypes['service']);
|
|
||||||
formData.recettescuisine = Misc.arrayOrEmpty(itemTypes['recettecuisine']);
|
formData.recettescuisine = Misc.arrayOrEmpty(itemTypes['recettecuisine']);
|
||||||
formData.recettesAlchimiques = Misc.arrayOrEmpty(itemTypes['recettealchimique']);
|
formData.recettesAlchimiques = Misc.arrayOrEmpty(itemTypes['recettealchimique']);
|
||||||
formData.maladies = Misc.arrayOrEmpty(itemTypes['maladie']);
|
formData.maladies = Misc.arrayOrEmpty(itemTypes['maladie']);
|
||||||
@ -103,9 +102,8 @@ export class RdDBaseActorSheet extends ActorSheet {
|
|||||||
formData.oeuvres = Misc.arrayOrEmpty(itemTypes['oeuvre']);
|
formData.oeuvres = Misc.arrayOrEmpty(itemTypes['oeuvre']);
|
||||||
formData.jeux = Misc.arrayOrEmpty(itemTypes['jeu']);
|
formData.jeux = Misc.arrayOrEmpty(itemTypes['jeu']);
|
||||||
|
|
||||||
|
formData.services = Misc.arrayOrEmpty(itemTypes['service']);
|
||||||
formData.conteneurs = Misc.arrayOrEmpty(itemTypes['conteneur']);
|
formData.conteneurs = Misc.arrayOrEmpty(itemTypes['conteneur']);
|
||||||
|
|
||||||
formData.materiel = Misc.arrayOrEmpty(itemTypes['objet']);
|
formData.materiel = Misc.arrayOrEmpty(itemTypes['objet']);
|
||||||
formData.armes = Misc.arrayOrEmpty(itemTypes['arme']);
|
formData.armes = Misc.arrayOrEmpty(itemTypes['arme']);
|
||||||
formData.armures = Misc.arrayOrEmpty(itemTypes['armure']);
|
formData.armures = Misc.arrayOrEmpty(itemTypes['armure']);
|
||||||
@ -117,22 +115,12 @@ export class RdDBaseActorSheet extends ActorSheet {
|
|||||||
formData.herbes = Misc.arrayOrEmpty(itemTypes['herbe']);
|
formData.herbes = Misc.arrayOrEmpty(itemTypes['herbe']);
|
||||||
formData.nourritureboissons = Misc.arrayOrEmpty(itemTypes['nourritureboisson']);
|
formData.nourritureboissons = Misc.arrayOrEmpty(itemTypes['nourritureboisson']);
|
||||||
formData.gemmes = Misc.arrayOrEmpty(itemTypes['gemme']);
|
formData.gemmes = Misc.arrayOrEmpty(itemTypes['gemme']);
|
||||||
|
|
||||||
formData.monnaie = Misc.arrayOrEmpty(itemTypes['monnaie']).sort(Monnaie.triValeurEntiere());
|
formData.monnaie = Misc.arrayOrEmpty(itemTypes['monnaie']).sort(Monnaie.triValeurEntiere());
|
||||||
|
|
||||||
formData.objets = formData.conteneurs
|
formData.objets = RdDItem.getItemTypesInventaire('all')
|
||||||
.concat(formData.materiel)
|
.map(t => Misc.arrayOrEmpty(itemTypes[t]))
|
||||||
.concat(formData.armes)
|
.reduce((a, b) => a.concat(b), [])
|
||||||
.concat(formData.armures)
|
.sort(Misc.ascending(it => it.name));
|
||||||
.concat(formData.munitions)
|
|
||||||
.concat(formData.livres)
|
|
||||||
.concat(formData.potions)
|
|
||||||
.concat(formData.ingredients)
|
|
||||||
.concat(formData.herbes)
|
|
||||||
.concat(formData.faunes)
|
|
||||||
.concat(formData.monnaie)
|
|
||||||
.concat(formData.nourritureboissons)
|
|
||||||
.concat(formData.gemmes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */ /** @override */
|
/* -------------------------------------------- */ /** @override */
|
||||||
@ -205,7 +193,7 @@ export class RdDBaseActorSheet extends ActorSheet {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async selectObjetTypeToCreate() {
|
async selectObjetTypeToCreate() {
|
||||||
let typeObjets = RdDItem.getItemTypesInventaire();
|
let typeObjets = this.getTypesInventaire().sort(Misc.ascending(type => Misc.typeName('Item', type)));
|
||||||
let content = `<span class="competence-label">Selectionnez le type d'équipement</span><select class="item-type">`;
|
let content = `<span class="competence-label">Selectionnez le type d'équipement</span><select class="item-type">`;
|
||||||
for (let typeName of typeObjets) {
|
for (let typeName of typeObjets) {
|
||||||
content += `<option value="${typeName}">${Misc.typeName('Item', typeName)}</option>`
|
content += `<option value="${typeName}">${Misc.typeName('Item', typeName)}</option>`
|
||||||
@ -225,6 +213,10 @@ export class RdDBaseActorSheet extends ActorSheet {
|
|||||||
d.render(true);
|
d.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTypesInventaire() {
|
||||||
|
return RdDItem.getItemTypesInventaire();
|
||||||
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
setPosition(options = {}) {
|
setPosition(options = {}) {
|
||||||
const position = super.setPosition(options);
|
const position = super.setPosition(options);
|
||||||
|
@ -255,7 +255,7 @@ export class RdDBaseActor extends Actor {
|
|||||||
await this.decrementerVente(vendeur, itemVendu, quantite, cout);
|
await this.decrementerVente(vendeur, itemVendu, quantite, cout);
|
||||||
if (acheteur) {
|
if (acheteur) {
|
||||||
await acheteur.depenserSols(cout);
|
await acheteur.depenserSols(cout);
|
||||||
let createdItemId = await acheteur.creerQuantiteItem(vente.item, quantite);
|
const createdItemId = await acheteur.creerQuantiteItem(vente.item, quantite);
|
||||||
await acheteur.consommerNourritureAchetee(achat, vente, createdItemId);
|
await acheteur.consommerNourritureAchetee(achat, vente, createdItemId);
|
||||||
}
|
}
|
||||||
if (cout > 0) {
|
if (cout > 0) {
|
||||||
@ -309,13 +309,13 @@ export class RdDBaseActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async decrementerQuantiteItem(item, quantite, options={supprimerSiZero: true}) {
|
async decrementerQuantiteItem(item, quantite, options = { supprimerSiZero: true }) {
|
||||||
let resteQuantite = (item.system.quantite ?? 1) - quantite;
|
let resteQuantite = (item.system.quantite ?? 1) - quantite;
|
||||||
if (resteQuantite <= 0) {
|
if (resteQuantite <= 0) {
|
||||||
if (options.supprimerSiZero) {
|
if (options.supprimerSiZero) {
|
||||||
await this.deleteEmbeddedDocuments("Item", [item.id]);
|
await this.deleteEmbeddedDocuments("Item", [item.id]);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
await this.updateEmbeddedDocuments("Item", [{ _id: item.id, 'system.quantite': 0 }]);
|
await this.updateEmbeddedDocuments("Item", [{ _id: item.id, 'system.quantite': 0 }]);
|
||||||
}
|
}
|
||||||
if (resteQuantite < 0) {
|
if (resteQuantite < 0) {
|
||||||
@ -328,16 +328,18 @@ export class RdDBaseActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async creerQuantiteItem(item, quantite) {
|
async creerQuantiteItem(item, quantite) {
|
||||||
const isItemEmpilable = "quantite" in item.system;
|
if (this.canReceive(item)) {
|
||||||
const baseItem = {
|
const isItemEmpilable = "quantite" in item.system;
|
||||||
type: item.type,
|
const baseItem = {
|
||||||
img: item.img,
|
type: item.type,
|
||||||
name: item.name,
|
img: item.img,
|
||||||
system: mergeObject(item.system, { quantite: isItemEmpilable ? quantite : undefined })
|
name: item.name,
|
||||||
};
|
system: mergeObject(item.system, { quantite: isItemEmpilable ? quantite : undefined })
|
||||||
const newItems = isItemEmpilable ? [baseItem] : Array.from({ length: quantite }, (_, i) => baseItem);
|
};
|
||||||
const items = await this.createEmbeddedDocuments("Item", newItems);
|
const newItems = isItemEmpilable ? [baseItem] : Array.from({ length: quantite }, (_, i) => baseItem);
|
||||||
return items.length > 0 ? items[0].id : undefined;
|
const items = await this.createEmbeddedDocuments("Item", newItems);
|
||||||
|
return items.length > 0 ? items[0].id : undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -373,7 +375,7 @@ export class RdDBaseActor extends Actor {
|
|||||||
}
|
}
|
||||||
let result = true;
|
let result = true;
|
||||||
const item = this.getItem(itemId);
|
const item = this.getItem(itemId);
|
||||||
if (item?.isInventaire() && sourceActorId == targetActorId) {
|
if (item?.isInventaire('all') && sourceActorId == targetActorId) {
|
||||||
// rangement
|
// rangement
|
||||||
if (srcId != destId && itemId != destId) { // déplacement de l'objet
|
if (srcId != destId && itemId != destId) { // déplacement de l'objet
|
||||||
const src = this.getItem(srcId);
|
const src = this.getItem(srcId);
|
||||||
|
@ -43,6 +43,11 @@ export class RdDCommerceSheet extends RdDBaseActorSheet {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTypesInventaire() {
|
||||||
|
return RdDItem.getItemTypesInventaire('all');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async vente(item) {
|
async vente(item) {
|
||||||
const acheteur = RdDUtility.getSelectedActor();
|
const acheteur = RdDUtility.getSelectedActor();
|
||||||
if (!acheteur) {
|
if (!acheteur) {
|
||||||
|
@ -14,7 +14,7 @@ export class RdDCommerce extends RdDBaseActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canReceive(item) {
|
canReceive(item) {
|
||||||
if (item.isInventaire()) {
|
if (item.isInventaire('all')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.canReceive(item);
|
return super.canReceive(item);
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
import { RdDItemSheet } from "./item-sheet.js";
|
import { RdDItemSheet } from "./item-sheet.js";
|
||||||
import { Misc } from "./misc.js";
|
|
||||||
import { RdDUtility } from "./rdd-utility.js";
|
|
||||||
import { SystemCompendiums } from "./settings/system-compendiums.js";
|
|
||||||
import { DialogItemAchat } from "./dialog-item-achat.js";
|
|
||||||
import { RdDItem } from "./item.js";
|
|
||||||
import { RdDItemService } from "./item-service.js";
|
|
||||||
|
|
||||||
export class RdDServiceItemSheet extends RdDItemSheet {
|
export class RdDServiceItemSheet extends RdDItemSheet {
|
||||||
|
|
||||||
@ -18,64 +12,5 @@ export class RdDServiceItemSheet extends RdDItemSheet {
|
|||||||
|
|
||||||
activateListeners(html) {
|
activateListeners(html) {
|
||||||
super.activateListeners(html);
|
super.activateListeners(html);
|
||||||
|
|
||||||
this.html.find('a.rdd-world-content-link').click(async event => {
|
|
||||||
const itemRef = this.getItemRef(event);
|
|
||||||
game.items.get(itemRef.id)?.sheet.render(true)
|
|
||||||
});
|
|
||||||
|
|
||||||
this.html.find('a.sub-item-acheter').click(async event => {
|
|
||||||
const subItem = this.item.findRefItem(this.getItemRef(event));
|
|
||||||
await this.item.acheter(RdDUtility.getSelectedActor(), subItem);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!this.options.editable) return;
|
|
||||||
|
|
||||||
this.html.find('a.sub-item-vendre').click(async event => {
|
|
||||||
const subItem = this.item.findRefItem(this.getItemRef(event));
|
|
||||||
await this.item.vendre(subItem);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.html.find('a.sub-item-delete').click(async event => {
|
|
||||||
await this.item.removeRefItem(this.getItemRef(event));
|
|
||||||
});
|
|
||||||
|
|
||||||
this.html.find('a.sub-item-quantite-moins').click(async event => await this.item.increaseRefItemQuantite(this.getItemRef(event), -1))
|
|
||||||
this.html.find('a.sub-item-quantite-plus').click(async event => await this.item.increaseRefItemQuantite(this.getItemRef(event), 1))
|
|
||||||
this.html.find('input.sub-item-quantite').change(async event => {
|
|
||||||
const newQuantite = Math.max(0, Number.parseInt(this.html.find(event.currentTarget).val()));
|
|
||||||
await this.item.updateRefItem(this.getItemRef(event), it => it.system.quantite = newQuantite);
|
|
||||||
})
|
|
||||||
this.html.find('input.sub-item-cout').change(async event => {
|
|
||||||
const newCout = Math.max(0, Number(this.html.find(event.currentTarget).val()));
|
|
||||||
await this.item.updateRefItem(this.getItemRef(event), it => it.system.cout = newCout);
|
|
||||||
})
|
|
||||||
this.html.find('a.sub-item-info-add').click(__ =>
|
|
||||||
ui.notifications.info(`Utiliser le glisser-déposer pour ajouter des objets depuis un compendium ou les objets du monde`)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
async _onDropItem(event, dragData) {
|
|
||||||
let linkedItem = fromUuidSync(dragData.uuid);
|
|
||||||
const existing = this.item.system.items.find(it => it.pack == linkedItem.pack && it.id == linkedItem.id && it.type == linkedItem.type);
|
|
||||||
if (existing) {
|
|
||||||
ui.notifications.warn(`${this.item.name} contient déjà un ${existing.name}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (linkedItem.pack) {
|
|
||||||
linkedItem = await SystemCompendiums.loadDocument(linkedItem);
|
|
||||||
}
|
|
||||||
if (linkedItem.isInventaire()) {
|
|
||||||
await this.item.addRefItem(RdDItemService.createSubItem(linkedItem));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ui.notifications.warn(`${this.item.name} ne peut pas proposer à la vente de ${Misc.typeName('Item', linkedItem.type)}: ${linkedItem.name}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getItemRef(event) {
|
|
||||||
const itemRow = this.html.find(event.currentTarget)?.parents('.item.service-item');
|
|
||||||
return { id: itemRow?.data("item-id"), pack: itemRow?.data("pack") ?? undefined }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,141 +1,17 @@
|
|||||||
import { DialogItemAchat } from "./dialog-item-achat.js";
|
|
||||||
import { RdDItem } from "./item.js";
|
import { RdDItem } from "./item.js";
|
||||||
import { Misc } from "./misc.js";
|
|
||||||
|
|
||||||
export class RdDItemService extends RdDItem {
|
export class RdDItemService extends RdDItem {
|
||||||
|
|
||||||
static get defaultIcon() {
|
static get defaultIcon() {
|
||||||
return "systems/foundryvtt-reve-de-dragon/icons/items/services.webp";
|
return "systems/foundryvtt-reve-de-dragon/icons/services/lit.webp";
|
||||||
}
|
|
||||||
|
|
||||||
/** @override*/
|
|
||||||
getUserLevel(user) {
|
|
||||||
const level = super.getUserLevel(user);
|
|
||||||
if (level == CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE) {
|
|
||||||
// si quelqu'un a accès au lien d'un service, il peut le voir
|
|
||||||
return CONST.DOCUMENT_OWNERSHIP_LEVELS.LIMITED;
|
|
||||||
}
|
|
||||||
return level;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isService() { return true; }
|
isService() { return true; }
|
||||||
getChatItemTemplate() { return 'systems/foundryvtt-reve-de-dragon/templates/post-item-service.html'; }
|
getProprietes() {
|
||||||
getProprietes() { return []; }
|
return [
|
||||||
|
RdDItem.propertyIfDefined('Qualité', this.system.qualite, this.system.qualite != 0),
|
||||||
getServiceItem(itemRef) {
|
RdDItem.propertyIfDefined('Moral', 'Situation heureuse', this.system.moral),
|
||||||
if (itemRef && this.isService()) {
|
RdDItem.propertyIfDefined('Coût', `${this.system.cout} sols`),
|
||||||
return this.system.items.find(it => it.id == itemRef.id && it.pack == itemRef.pack);
|
];
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getQuantiteDisponible(itemRef, max) {
|
|
||||||
if (this.system.illimite) {
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
const subItem = this.getServiceItem(itemRef);
|
|
||||||
return subItem?.system.quantite ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
async venteRefItem(ref, quantite, cout) {
|
|
||||||
if (this.actor) {
|
|
||||||
await this.actor.ajouterSols(cout);
|
|
||||||
}
|
|
||||||
await this.increaseRefItemQuantite(ref, -quantite);
|
|
||||||
}
|
|
||||||
|
|
||||||
async vendre(subItem) {
|
|
||||||
const item = await RdDItem.getCorrespondingItem(subItem);
|
|
||||||
const quantiteMax = this.system.illimite ? undefined : subItem.system.quantite;
|
|
||||||
await item.proposerVente(quantiteMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
async acheter(acheteur, subItem) {
|
|
||||||
if (!acheteur) {
|
|
||||||
ui.notifications.warn(`Pas d'acheteur sélectionné`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const nbLots = this.system.illimite ? 1 : subItem.system.quantite;
|
|
||||||
if (nbLots <= 0) {
|
|
||||||
ui.notifications.warn(`${this.name} n'a plus de ${subItem.name} en vente`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await DialogItemAchat.onAcheter({
|
|
||||||
item: await RdDItem.getCorrespondingItem(subItem),
|
|
||||||
acheteur,
|
|
||||||
serviceSubItem: subItem,
|
|
||||||
service: this,
|
|
||||||
quantiteIllimite: this.system.illimite,
|
|
||||||
nbLots,
|
|
||||||
tailleLot: 1,
|
|
||||||
prixLot: subItem.system.cout
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static createSubItem(linkedItem) {
|
|
||||||
return {
|
|
||||||
id: linkedItem.id,
|
|
||||||
pack: linkedItem.pack,
|
|
||||||
name: linkedItem.name,
|
|
||||||
img: linkedItem.img,
|
|
||||||
system: {
|
|
||||||
quantite: 1,
|
|
||||||
cout: linkedItem.system.cout ?? 0
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static matchRefItem({ id, pack }) {
|
|
||||||
return it => it.id == id && (pack ? (it.pack == pack) : (!it.pack));
|
|
||||||
}
|
|
||||||
|
|
||||||
findRefItem(ref) {
|
|
||||||
return this.system.items.find(RdDItemService.matchRefItem(ref));
|
|
||||||
}
|
|
||||||
|
|
||||||
async increaseRefItemQuantite(ref, quantite) {
|
|
||||||
await this.updateRefItem(ref,
|
|
||||||
it => it.system.quantite = Math.max(0, it.system.quantite + quantite)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async updateRefItem(ref, update = it => { }) {
|
|
||||||
await this.updateRefItems(RdDItemService.matchRefItem(ref), update);
|
|
||||||
}
|
|
||||||
|
|
||||||
async addRefItem(newItem) {
|
|
||||||
if (!newItem.id) {
|
|
||||||
ui.notifications.warn(`${newItem?.name ?? '??'} n'a pas d'identifiant`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.system.items.find(RdDItemService.matchRefItem(newItem))) {
|
|
||||||
ui.notifications.warn(`${newItem?.name ?? newItem.id} est déjà présent ici`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await this.setRefItems([...this.system.items, newItem]);
|
|
||||||
}
|
|
||||||
|
|
||||||
async removeRefItem(ref) {
|
|
||||||
await this.removeRefItems(RdDItemService.matchRefItem(ref));
|
|
||||||
}
|
|
||||||
|
|
||||||
async removeRefItems(matcher = it => false) {
|
|
||||||
await this.setRefItems(this.system.items.filter(it => !matcher(it)));
|
|
||||||
}
|
|
||||||
|
|
||||||
async updateRefItems(matcher = it => false, update = it => { }) {
|
|
||||||
const updatedList = this.system.items.map(it => {
|
|
||||||
if (matcher(it)) {
|
|
||||||
update(it);
|
|
||||||
}
|
|
||||||
return it;
|
|
||||||
});
|
|
||||||
await this.setRefItems(updatedList);
|
|
||||||
}
|
|
||||||
|
|
||||||
async setRefItems(newItems) {
|
|
||||||
await this.update({ 'system.items': newItems.sort(Misc.ascending(it => it.type + ':' + it.name)) });
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -5,14 +5,14 @@ import { RdDHerbes } from "./rdd-herbes.js";
|
|||||||
import { RdDUtility } from "./rdd-utility.js";
|
import { RdDUtility } from "./rdd-utility.js";
|
||||||
import { SystemCompendiums } from "./settings/system-compendiums.js";
|
import { SystemCompendiums } from "./settings/system-compendiums.js";
|
||||||
|
|
||||||
const typesObjetsInventaire = [
|
const typesInventaireMateriel = [
|
||||||
"arme",
|
"arme",
|
||||||
"armure",
|
"armure",
|
||||||
"conteneur",
|
"conteneur",
|
||||||
|
"faune",
|
||||||
"gemme",
|
"gemme",
|
||||||
"herbe",
|
"herbe",
|
||||||
"ingredient",
|
"ingredient",
|
||||||
"faune",
|
|
||||||
"livre",
|
"livre",
|
||||||
"monnaie",
|
"monnaie",
|
||||||
"munition",
|
"munition",
|
||||||
@ -20,6 +20,11 @@ const typesObjetsInventaire = [
|
|||||||
"objet",
|
"objet",
|
||||||
"potion",
|
"potion",
|
||||||
]
|
]
|
||||||
|
const typesInventaire = {
|
||||||
|
materiel: typesInventaireMateriel,
|
||||||
|
all: ['service'].concat(typesInventaireMateriel),
|
||||||
|
}
|
||||||
|
|
||||||
const typesObjetsOeuvres = ["oeuvre", "recettecuisine", "musique", "chant", "danse", "jeu"]
|
const typesObjetsOeuvres = ["oeuvre", "recettecuisine", "musique", "chant", "danse", "jeu"]
|
||||||
const typesObjetsDraconiques = ["queue", "ombre", "souffle", "tete", "signedraconique", "sortreserve", "rencontre"]
|
const typesObjetsDraconiques = ["queue", "ombre", "souffle", "tete", "signedraconique", "sortreserve", "rencontre"]
|
||||||
const typesObjetsConnaissance = ["meditation", "recettealchimique", "sort"]
|
const typesObjetsConnaissance = ["meditation", "recettealchimique", "sort"]
|
||||||
@ -97,8 +102,8 @@ export class RdDItem extends Item {
|
|||||||
return game.items.get(itemRef.id ?? itemRef._id);
|
return game.items.get(itemRef.id ?? itemRef._id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getItemTypesInventaire() {
|
static getItemTypesInventaire(mode = 'materiel') {
|
||||||
return typesObjetsInventaire
|
return typesInventaire[mode ?? 'materiel']
|
||||||
}
|
}
|
||||||
|
|
||||||
static getTypesOeuvres() {
|
static getTypesOeuvres() {
|
||||||
@ -150,8 +155,8 @@ export class RdDItem extends Item {
|
|||||||
isCompetence() {
|
isCompetence() {
|
||||||
return typesObjetsCompetence.includes(this.type)
|
return typesObjetsCompetence.includes(this.type)
|
||||||
}
|
}
|
||||||
isInventaire() {
|
isInventaire(mode = 'materiel') {
|
||||||
return typesObjetsInventaire.includes(this.type);
|
return RdDItem.getItemTypesInventaire(mode).includes(this.type);
|
||||||
}
|
}
|
||||||
isOeuvre() {
|
isOeuvre() {
|
||||||
return typesObjetsOeuvres.includes(this.type)
|
return typesObjetsOeuvres.includes(this.type)
|
||||||
@ -463,7 +468,7 @@ export class RdDItem extends Item {
|
|||||||
img: this.img,
|
img: this.img,
|
||||||
pack: this.pack,
|
pack: this.pack,
|
||||||
name: this.name,
|
name: this.name,
|
||||||
actor : this.actor ? { id: this.actor.id } : undefined,
|
actor: this.actor ? { id: this.actor.id } : undefined,
|
||||||
system: { description: this.system.description },
|
system: { description: this.system.description },
|
||||||
properties: this.getProprietes(),
|
properties: this.getProprietes(),
|
||||||
}
|
}
|
||||||
@ -474,9 +479,6 @@ export class RdDItem extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getChatItemTemplate() {
|
getChatItemTemplate() {
|
||||||
switch (this.type) {
|
|
||||||
case 'service': return 'systems/foundryvtt-reve-de-dragon/templates/post-item-service.html';
|
|
||||||
}
|
|
||||||
return 'systems/foundryvtt-reve-de-dragon/templates/post-item.html';
|
return 'systems/foundryvtt-reve-de-dragon/templates/post-item.html';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,7 +583,7 @@
|
|||||||
"encombrement": 0,
|
"encombrement": 0,
|
||||||
"quantite": 1,
|
"quantite": 1,
|
||||||
"qualite": 0,
|
"qualite": 0,
|
||||||
"cout": 0
|
"cout": 0.0
|
||||||
},
|
},
|
||||||
"environnement": {
|
"environnement": {
|
||||||
"milieu": "",
|
"milieu": "",
|
||||||
@ -747,10 +747,8 @@
|
|||||||
"prdate": 0
|
"prdate": 0
|
||||||
},
|
},
|
||||||
"service": {
|
"service": {
|
||||||
"templates": [ "description"],
|
"templates": [ "description", "inventaire" ],
|
||||||
"illimite": false,
|
"moral": false
|
||||||
"items": [],
|
|
||||||
"services": []
|
|
||||||
},
|
},
|
||||||
"musique": {
|
"musique": {
|
||||||
"templates": [ "description" ],
|
"templates": [ "description" ],
|
||||||
|
@ -14,14 +14,14 @@
|
|||||||
</span>
|
</span>
|
||||||
{{#unless @root.system.illimite}}
|
{{#unless @root.system.illimite}}
|
||||||
<span class="equipement-detail flexrow">
|
<span class="equipement-detail flexrow">
|
||||||
{{#unless (and (eq item.type 'conteneur') (not vide))}}
|
{{#unless (or (eq item.type 'service') (and (eq item.type 'conteneur') (not vide)))}}
|
||||||
{{#if @root.options.isOwner}}
|
{{#if @root.options.isOwner}}
|
||||||
<a class="item-quantite-moins"><i class="fas fa-minus-square"></i></a>
|
<a class="item-quantite-moins"><i class="fas fa-minus-square"></i></a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<input {{#unless @root.options.isOwner}}disabled{{/unless}} type="number" class="item-quantite" name="items[{{key}}].system.quantite" value="{{item.system.quantite}}" data-dtype="Number" />
|
<input {{#unless @root.options.isOwner}}disabled{{/unless}} type="number" class="item-quantite" name="items[{{key}}].system.quantite" value="{{item.system.quantite}}" data-dtype="Number" />
|
||||||
{{#if @root.options.isOwner}}
|
{{#if @root.options.isOwner}}
|
||||||
<a class="item-quantite-plus"><i class="fas fa-plus-square"></i></a>
|
<a class="item-quantite-plus"><i class="fas fa-plus-square"></i></a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
</span>
|
</span>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
@ -2,69 +2,23 @@
|
|||||||
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
|
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
|
||||||
|
|
||||||
<section class="sheet-body">
|
<section class="sheet-body">
|
||||||
<div class="flexcol form-group small-editor">
|
|
||||||
{{editor description target="system.description" button=true owner=owner editable=(or isGM isOwner) engine="prosemirror"}}
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input {{@root.disabled}} class="attribute-value" type="checkbox" name="system.illimite" {{#if system.illimite}}checked{{/if}}/>
|
<span for="system.moral">Jet de moral en situation heureuse</span>
|
||||||
<span for="system.illimite">Quantité en vente illimitée</span>
|
<input {{@root.disabled}} class="attribute-value" type="checkbox" name="system.moral" {{#if system.moral}}checked{{/if}}/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flexcol">
|
|
||||||
<ul class="item-list alterne-list">
|
<div class="form-group">
|
||||||
<li class="item flexrow list-item">
|
<label for="system.qualite">Qualité</label>
|
||||||
<label class="flex-grow">A vendre</label>
|
<input class="attribute-value number-x3" type="number" name="system.qualite" value="{{system.qualite}}" data-dtype="Number"
|
||||||
{{#unless system.illimite}}
|
{{#unless (isFieldInventaireModifiable type 'qualite')}}disabled{{/unless}}/>
|
||||||
<label>Quantite</label>
|
|
||||||
{{/unless}}
|
|
||||||
<label>Prix (sols)</label>
|
|
||||||
<div class="item-controls">
|
|
||||||
{{#unless disabled}}
|
|
||||||
<a class="sub-item-info-add" title="Utiliser le drag&drop pour ajouter un objet dans la liste">
|
|
||||||
<i class="fa-solid fa-circle-info"></i>
|
|
||||||
</a>
|
|
||||||
{{/unless}}
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{{#each system.items as |item key|}}
|
|
||||||
<li class="item flexrow list-item service-item" data-item-id="{{item.id}}" data-pack="{{item.pack}}" data-key="{{key}}">
|
|
||||||
<label class="flex-grow">
|
|
||||||
{{#if item.img}}<img class="sheet-competence-img" src="{{item.img}}" title="{{item.name}}"/>{{/if}}
|
|
||||||
{{> 'systems/foundryvtt-reve-de-dragon/templates/common/compendium-link.hbs'
|
|
||||||
pack=item.pack id=item.id name=item.name}}
|
|
||||||
</label>
|
|
||||||
{{#unless @root.system.illimite}}
|
|
||||||
<span class="flexrow">
|
|
||||||
{{#unless @root.disabled}}
|
|
||||||
<a class="sub-item-quantite-moins"><i class="fas fa-minus-square"></i></a>
|
|
||||||
{{/unless}}
|
|
||||||
<input {{@root.disabled}} type="number" class="sub-item-quantite" name="items[{{key}}].system.quantite" value="{{item.system.quantite}}" data-dtype="Number" />
|
|
||||||
{{#unless @root.disabled}}
|
|
||||||
<a class="sub-item-quantite-plus"><i class="fas fa-plus-square"></i></a>
|
|
||||||
{{/unless}}
|
|
||||||
</span>
|
|
||||||
{{/unless}}
|
|
||||||
<span class="flexrow">
|
|
||||||
<input {{@root.disabled}} type="number" class="input-prix number-x3 sub-item-cout" name="items[{{key}}].system.cout" value="{{numberFormat item.system.cout decimals=2 sign=false}}" data-dtype="Number" />
|
|
||||||
</span>
|
|
||||||
<div class="item-controls">
|
|
||||||
<a class="sub-item-acheter" title="Acheter"><i class="fa-regular fa-coins"></i></a>
|
|
||||||
{{#unless @root.disabled}}
|
|
||||||
<a class="sub-item-vendre" title="Vendre"><i class="fas fa-comments-dollar"></i></a>
|
|
||||||
<a class="sub-item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
|
||||||
{{/unless}}
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{{/each}}
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
{{#if isGM}}
|
|
||||||
<br>
|
<div class="form-group item-cout">
|
||||||
<div class="flexcol">
|
<label for="system.cout">Prix (sols)</label>
|
||||||
<span><label>Description (MJ seulement): </label></span>
|
<input class="input-prix attribute-value number-x3" type="number" name="system.cout" value="{{numberFormat system.cout decimals=2 sign=false}}" data-dtype="Number"
|
||||||
<div class="form-group medium-editor">
|
{{#unless (isFieldInventaireModifiable type 'cout')}}disabled{{/unless}}/>
|
||||||
{{editor descriptionmj target="system.descriptionmj" button=true owner=owner editable=true engine="prosemirror"}}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
|
||||||
|
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
|
||||||
</section>
|
</section>
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
Reference in New Issue
Block a user