Merge pull request 'Gestion de la Faune' (#587) from VincentVk/foundryvtt-reve-de-dragon:v10 into v10

Reviewed-on: #587
This commit is contained in:
uberwald 2022-12-03 23:16:36 +01:00
commit 51273bcc3e
36 changed files with 453 additions and 350 deletions

BIN
icons/faune/cerf.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

BIN
icons/faune/chevre.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

BIN
icons/faune/crabe.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

BIN
icons/faune/lapin.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

BIN
icons/faune/oie.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
icons/faune/oiseau.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

BIN
icons/faune/poisson.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
icons/faune/rongeur.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

BIN
icons/faune/saumon.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

BIN
icons/faune/singe-vert.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@ -20,6 +20,7 @@
"TypeMonnaie": "Monnaie",
"TypeHerbe": "Herbe ou plante",
"TypeIngredient": "Ingrédient",
"TypeFaune": "Faune",
"TypeLivre": "Livre",
"TypePotion": "Potion",
"TypeArme": "Arme",

View File

@ -132,10 +132,12 @@ export class RdDActorSheet extends ActorSheet {
/* -------------------------------------------- */
async _onDropItem(event, dragData) {
const destItemId = $(event.target)?.closest('.item').attr('data-item-id')
const dropParams = RdDSheetUtility.prepareItemDropParameters(destItemId, this.actor.id, dragData, this.objetVersConteneur)
const callSuper = await this.actor.processDropItem(dropParams)
if (callSuper) {
await super._onDropItem(event, dragData)
const dropParams = RdDSheetUtility.prepareItemDropParameters(destItemId, this.actor, dragData, this.objetVersConteneur)
if (dropParams){
const callSuper = await this.actor.processDropItem(dropParams)
if (callSuper) {
await super._onDropItem(event, dragData)
}
}
}

View File

@ -145,7 +145,7 @@ export class RdDActor extends Actor {
// Make separate methods for each Actor type (character, npc, etc.) to keep
// things organized.
if (this.isPersonnage()) this._prepareCharacterData(this)
if (this.isCreature()) this._prepareCreatureData(this)
if (this.isCreatureEntite()) this._prepareCreatureData(this)
if (this.isVehicule()) this._prepareVehiculeData(this)
this.computeEtatGeneral();
}
@ -193,10 +193,36 @@ export class RdDActor extends Actor {
}
}
canReceive(item) {
if (this.isCreature()) {
return item.type == 'competencecreature' || RdDItem.isItemInventaire(item);
}
if (this.isEntite()) {
return item.type == 'competencecreature';
}
if (this.isVehicule()) {
return RdDItem.isItemInventaire(item);
}
if (this.isPersonnage()) {
switch (item.type) {
case 'competencecreature': case 'tarot':
return false;
}
return true;
}
return false;
}
/* -------------------------------------------- */
isCreature() {
isCreatureEntite() {
return this.type == 'creature' || this.type == 'entite';
}
isCreature() {
return this.type == 'creature';
}
isEntite() {
return this.type == 'entite';
}
/* -------------------------------------------- */
isPersonnage() {
return this.type == 'personnage';
@ -1175,13 +1201,13 @@ export class RdDActor extends Actor {
}
let result = true;
const item = this.getObjet(itemId);
if (item?.isEquipement() && sourceActorId == targetActorId) {
if (item?.isInventaire() && sourceActorId == targetActorId) {
// rangement
if (srcId != destId && itemId != destId) { // déplacement de l'objet
const src = this.getObjet(srcId);
const dest = this.getObjet(destId);
const cible = this.getContenantOrParent(dest);
const [empilable, message] = item.isEquipementEmpilable(dest);
const [empilable, message] = item.isInventaireEmpilable(dest);
if (empilable) {
await this.regrouperEquipementsSimilaires(item, dest);
result = false;
@ -1359,7 +1385,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
computePrixTotalEquipement() {
const valeur = this.items.filter(it => it.isEquipement())
const valeur = this.items.filter(it => it.isInventaire())
.map(it => it.valeurTotale())
.reduce(Misc.sum(), 0);
return valeur;
@ -2995,7 +3021,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
getHeureNaissance() {
if (this.isCreature()) {
if (this.isCreatureEntite()) {
return 0;
}
return this.system.heure;
@ -3003,7 +3029,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
ajustementAstrologique() {
if (this.isCreature()) {
if (this.isCreatureEntite()) {
return 0;
}
// selon l'heure de naissance...

View File

@ -23,7 +23,7 @@ const MILIEUX = [
"Sous-sols"
]
const ITEM_ENVIRONNEMENT_TYPES = [
'herbe', 'ingredient'
'herbe', 'ingredient', 'faune'
]
export class Environnement {
@ -126,22 +126,12 @@ export class Environnement {
export class EnvironmentSheetHelper {
static defaultOptions(defaultOptions, type) {
static defaultOptions(defaultOptions) {
return mergeObject(defaultOptions, {
classes: ["rdd", "sheet", "item"],
template: `systems/foundryvtt-reve-de-dragon/templates/item-${type}-sheet.html`,
width: 500,
height: 600,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "informations" }]
});
}
/* -------------------------------------------- */
static getHeaderButtons(sheet, buttons) {
buttons.unshift({ class: "post", icon: "fas fa-comment", onclick: ev => sheet.item.postItem() });
return buttons;
}
static setPosition(sheet, superPosition) {
const position = superPosition;
const sheetHeader = sheet.element.find(".sheet-header");
@ -152,22 +142,14 @@ export class EnvironmentSheetHelper {
/* -------------------------------------------- */
static async getData(sheet, formData) {
const autresMilieux = await game.system.rdd.environnement.autresMilieux(sheet.item);
mergeObject(formData, {
title: formData.name,
isGM: game.user.isGM,
owner: sheet.actor?.isOwner,
isOwned: sheet.actor ? true : false,
actorId: sheet.actor?.id,
editable: sheet.isEditable,
cssClass: sheet.isEditable ? "editable" : "locked",
milieux: autresMilieux
return mergeObject(formData, {
milieux: await game.system.rdd.environnement.autresMilieux(sheet.item)
});
return formData;
}
static activateListeners(sheet, html) {
if (!sheet.options.editable) return;
html.find("input.input-selection-milieu").keypress(event => {
if (event.keyCode == '13') {
EnvironmentSheetHelper.onAddMilieu(html, sheet, event);
@ -238,13 +220,4 @@ export class EnvironmentSheetHelper {
return $(event.currentTarget)?.parents("div.environnement-milieu").data("milieu");
}
static template(itemType) {
/* -------------------------------------------- */
return `systems/foundryvtt-reve-de-dragon/templates/item-${itemType}-sheet.html`;
}
static title(item) {
return Misc.typeName('Item', item.type) + ': ' + item.name;
}
}

View File

@ -0,0 +1,58 @@
import { RdDItemSheet } from "./item-sheet.js";
import { RdDSheetUtility } from "./rdd-sheet-utility.js";
import { RdDUtility } from "./rdd-utility.js";
export class RdDConteneurItemSheet extends RdDItemSheet {
static get ITEM_TYPE() { return "conteneur" };
async getData() {
const formData = await super.getData();
if (this.actor) {
this.prepareConteneurData(formData);
}
}
activateListeners(html) {
super.activateListeners(html);
if (!this.options.editable) return;
html.find('.conteneur-name a').click(async event => {
RdDUtility.toggleAfficheContenu(RdDSheetUtility.getItemId(event));
this.render(true);
});
}
/* -------------------------------------------- */
prepareConteneurData(formData) {
RdDUtility.filterEquipementParType(formData, this.actor.itemTypes);
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
formData.subItems = formData.conteneurs.find(it => it._id == this.item.id)?.subItems;
}
async _onDragStart(event) {
console.log("_onDragStart", event);
if (event.target.classList.contains("entity-link")) return;
const itemId = event.srcElement?.attributes["data-item-id"].value;
const item = this.actor.items.get(itemId);
// Create drag data
const dragData = {
actorId: this.actor.id,
type: "Item",
data: item.system
};
event.dataTransfer.setData("text/plain", JSON.stringify(dragData));
}
async _onDropItem(event, dragData) {
if (this.actor) {
const dropParams = RdDSheetUtility.prepareItemDropParameters(this.item.id, this.actor, dragData, this.objetVersConteneur);
await this.actor.processDropItem(dropParams);
await this.render(true);
}
}
}

View File

@ -0,0 +1,54 @@
import { EnvironmentSheetHelper } from "./environnement.js";
import { RdDItemSheet } from "./item-sheet.js";
import { RdDUtility } from "./rdd-utility.js";
export class RdDFauneItemSheet extends RdDItemSheet {
static get ITEM_TYPE() { return "faune" };
static get defaultOptions() {
return EnvironmentSheetHelper.defaultOptions(super.defaultOptions);
}
setPosition(options = {}) {
return EnvironmentSheetHelper.setPosition(this, super.setPosition(options));
}
async getData() {
const formData = await super.getData();
return await EnvironmentSheetHelper.getData(this, formData);
}
activateListeners(html) {
super.activateListeners(html);
if (!this.options.editable) return;
EnvironmentSheetHelper.activateListeners(this, html);
html.find("a.linked-actor-delete").click(event => this.onDeleteLinkedActor());
}
async _onDropActor(event, dragData) {
console.log('faune:dropActor', event, dragData)
const actor = fromUuidSync(dragData.uuid);
if (actor?.pack) {
this.item.update({
'system.actor.pack': actor.pack,
'system.actor.id': actor._id,
'system.actor.name': actor.name
});
}
else {
ui.notifications.warn(`${actor.name} ne provient pas d'eun compendium.
<br>Choisissez une créature du compendium pour représenter un élément de faune générique`)
}
}
async onDeleteLinkedActor() {
this.item.update({
'system.actor.pack': '',
'system.actor.id': '',
'system.actor.name': ''
});
}
}

View File

@ -1,26 +1,12 @@
import { SYSTEM_RDD } from "./constants.js";
import { EnvironmentSheetHelper } from "./environnement.js";
import { RdDItemSheet } from "./item-sheet.js";
import { Misc } from "./misc.js";
const ITEM_TYPE = 'herbe';
export class RdDHerbeItemSheet extends RdDItemSheet {
static register() {
Items.registerSheet(SYSTEM_RDD, RdDHerbeItemSheet, {
label: Misc.typeName('Item', ITEM_TYPE),
types: [ITEM_TYPE],
makeDefault: true
});
}
static get ITEM_TYPE() { return "herbe" };
static get defaultOptions() {
return EnvironmentSheetHelper.defaultOptions(super.defaultOptions, ITEM_TYPE);
}
_getHeaderButtons() {
return EnvironmentSheetHelper.getHeaderButtons(this, super._getHeaderButtons());
return EnvironmentSheetHelper.defaultOptions(super.defaultOptions);
}
setPosition(options = {}) {
@ -36,12 +22,4 @@ export class RdDHerbeItemSheet extends RdDItemSheet {
super.activateListeners(html);
EnvironmentSheetHelper.activateListeners(this, html);
}
get template() {
return EnvironmentSheetHelper.template(this.item.type);
}
get title() {
return EnvironmentSheetHelper.title(this.item);
}
}

View File

@ -1,25 +1,12 @@
import { SYSTEM_RDD } from "./constants.js";
import { EnvironmentSheetHelper } from "./environnement.js";
import { RdDItemSheet } from "./item-sheet.js";
import { Misc } from "./misc.js";
const ITEM_TYPE = 'ingredient';
export class RdDIngredientItemSheet extends RdDItemSheet {
static register() {
Items.registerSheet(SYSTEM_RDD, RdDIngredientItemSheet, {
label: Misc.typeName('Item', ITEM_TYPE),
types: [ITEM_TYPE],
makeDefault: true
});
}
static get ITEM_TYPE() { return "ingredient" };
static get defaultOptions() {
return EnvironmentSheetHelper.defaultOptions(super.defaultOptions, ITEM_TYPE);
}
_getHeaderButtons() {
return EnvironmentSheetHelper.getHeaderButtons(this, super._getHeaderButtons());
return EnvironmentSheetHelper.defaultOptions(super.defaultOptions);
}
setPosition(options = {}) {
@ -35,12 +22,4 @@ export class RdDIngredientItemSheet extends RdDItemSheet {
super.activateListeners(html);
EnvironmentSheetHelper.activateListeners(this, html);
}
get template() {
return EnvironmentSheetHelper.template(this.item.type);
}
get title() {
return EnvironmentSheetHelper.title(this.item);
}
}

View File

@ -1,29 +1,16 @@
import { RdDRencontre } from "./item-rencontre.js";
import { RdDItemSheet } from "./item-sheet.js";
/**
* Item sheet pour configurer les rencontres
* @extends {ItemSheet}
*/
export class RdDRencontreItemSheet extends ItemSheet {
export class RdDRencontreItemSheet extends RdDItemSheet {
static get ITEM_TYPE() { return "rencontre" };
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["rdd", "sheet", "item"],
template: "systems/foundryvtt-reve-de-dragon/templates/item-rencontre-sheet.html",
width: 500,
height: 500,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }]
});
}
/* -------------------------------------------- */
_getHeaderButtons() {
let buttons = super._getHeaderButtons();
buttons.unshift({ class: "post", icon: "fas fa-comment", onclick: ev => this.item.postItem() });
return buttons;
}
/* -------------------------------------------- */
/** @override */
setPosition(options = {}) {
@ -34,7 +21,6 @@ export class RdDRencontreItemSheet extends ItemSheet {
return position;
}
/* -------------------------------------------- */
async getData() {
const formData = duplicate(this.item);
@ -96,13 +82,4 @@ export class RdDRencontreItemSheet extends ItemSheet {
updates[key] = liste;
this.item.update(updates);
}
get template() {
/* -------------------------------------------- */
return `systems/foundryvtt-reve-de-dragon/templates/item-rencontre-sheet.html`;
}
get title() {
return `Rencontre: ${this.object.name}`;
}
}

View File

@ -9,30 +9,54 @@ import { ReglesOptionelles } from "./settings/regles-optionelles.js";
import { SYSTEM_RDD } from "./constants.js";
import { RdDSheetUtility } from "./rdd-sheet-utility.js";
import { SystemCompendiums } from "./settings/system-compendiums.js";
import { Misc } from "./misc.js";
/**
* Extend the basic ItemSheet with some very simple modifications
* @extends {ItemSheet}
* Extend the basic ItemSheet for RdD specific items
*/
export class RdDItemSheet extends ItemSheet {
static get ITEM_TYPE() {
return undefined
}
static defaultTemplate(type) {
return type ?
`systems/foundryvtt-reve-de-dragon/templates/item-${type}-sheet.html` :
"systems/foundryvtt-reve-de-dragon/templates/item-sheet.html";
}
static register(sheetClass) {
Items.registerSheet(SYSTEM_RDD, sheetClass, {
label: Misc.typeName('Item', sheetClass.ITEM_TYPE),
types: [sheetClass.ITEM_TYPE],
makeDefault: true
})
}
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: [SYSTEM_RDD, "sheet", "item"],
template: "systems/foundryvtt-reve-de-dragon/templates/item-sheet.html",
template: RdDItemSheet.defaultTemplate(RdDItemSheet.ITEM_TYPE),
width: 550,
height: 550
});
}
/* -------------------------------------------- */
get template() {
return RdDItemSheet.defaultTemplate(this.item.type);
}
get title() {
return `${Misc.typeName('Item', this.item.type)}: ${this.item.name}`;
}
/* -------------------------------------------- */
_getHeaderButtons() {
let buttons = super._getHeaderButtons();
// Add "Post to chat" button
// We previously restricted this to GM and editable items only. If you ever find this comment because it broke something: eh, sorry!
if ("cout" in this.item.system && this.item.isVideOuNonConteneur()) {
if (this.item.isInventaire() && this.item.isVideOuNonConteneur()) {
buttons.unshift({
class: "vendre",
icon: "fas fa-comments-dollar",
@ -69,18 +93,13 @@ export class RdDItemSheet extends ItemSheet {
system: this.item.system,
isGM: game.user.isGM,
actorId: this.actor?.id,
isOwned: this.actor ? true : false,
owner: this.item.isOwner,
editable: this.isEditable,
cssClass: this.isEditable ? "editable" : "locked",
isSoins: false,
description: await TextEditor.enrichHTML(this.item.system.description, {async: true}),
descriptionmj: await TextEditor.enrichHTML(this.item.system.descriptionmj, {async: true})
}
if (this.actor) {
formData.isOwned = true;
if (this.item.type == 'conteneur') {
this.prepareConteneurData(formData);
}
description: await TextEditor.enrichHTML(this.item.system.description, { async: true }),
descriptionmj: await TextEditor.enrichHTML(this.item.system.descriptionmj, { async: true })
}
const competences = await SystemCompendiums.getCompetences(this.actor?.type);
@ -97,18 +116,18 @@ export class RdDItemSheet extends ItemSheet {
formData.competences = competences.filter(it => RdDItemCompetence.isDraconic(it));
}
if (this.item.type == 'recettecuisine') {
formData.ingredients = await TextEditor.enrichHTML(this.object.system.ingredients, {async: true})
formData.ingredients = await TextEditor.enrichHTML(this.object.system.ingredients, { async: true })
}
if (this.item.type == 'extraitpoetique') {
formData.extrait = await TextEditor.enrichHTML(this.object.system.extrait, {async: true})
formData.texte = await TextEditor.enrichHTML(this.object.system.texte, {async: true})
formData.extrait = await TextEditor.enrichHTML(this.object.system.extrait, { async: true })
formData.texte = await TextEditor.enrichHTML(this.object.system.texte, { async: true })
}
if (this.item.type == 'recettealchimique') {
RdDAlchimie.processManipulation(this.item, this.actor && this.actor.id);
formData.manipulation_update = await TextEditor.enrichHTML(this.object.system.manipulation_update, {async: true})
formData.utilisation = await TextEditor.enrichHTML(this.object.system.utilisation, {async: true})
formData.enchantement = await TextEditor.enrichHTML(this.object.system.enchantement, {async: true})
formData.sureffet = await TextEditor.enrichHTML(this.object.system.sureffet, {async: true})
formData.manipulation_update = await TextEditor.enrichHTML(this.object.system.manipulation_update, { async: true })
formData.utilisation = await TextEditor.enrichHTML(this.object.system.utilisation, { async: true })
formData.enchantement = await TextEditor.enrichHTML(this.object.system.enchantement, { async: true })
formData.sureffet = await TextEditor.enrichHTML(this.object.system.sureffet, { async: true })
}
if (this.item.type == 'gemme') {
formData.gemmeTypeList = RdDGemme.getGemmeTypeOptionList();
@ -133,25 +152,10 @@ export class RdDItemSheet extends ItemSheet {
return formData;
}
/* -------------------------------------------- */
prepareConteneurData(formData) {
RdDUtility.filterEquipementParType(formData, this.actor.itemTypes);
this.objetVersConteneur = RdDUtility.buildArbreDeConteneurs(formData.conteneurs, formData.objets);
formData.subItems = formData.conteneurs.find(it => it._id == this.item.id)?.subItems;
}
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
super.activateListeners(html);
if (this.item.type == 'conteneur') {
this.form.ondragstart = (event) => this._onDragStart(event);
this.form.ondrop = (event) => this._onDrop(event);
}
let itemSheetDialog = this;
HtmlUtility._showControlWhen($(".item-cout"), ReglesOptionelles.isUsing('afficher-prix-joueurs') || game.user.isGM || !this.item.isOwned);
@ -159,6 +163,9 @@ export class RdDItemSheet extends ItemSheet {
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
this.form.ondragstart = (event) => this._onDragStart(event);
this.form.ondrop = (event) => this._onDrop(event);
// Select competence categorie
html.find(".categorie").change(event => this._onSelectCategorie(event));
@ -229,10 +236,6 @@ export class RdDItemSheet extends ItemSheet {
const item = RdDSheetUtility.getItem(event, this.actor);
this.actor.actionItem(item, async () => itemSheetDialog.render(true));
});
html.find('.conteneur-name a').click(async event => {
RdDUtility.toggleAfficheContenu(RdDSheetUtility.getItemId(event));
this.render(true);
});
}
/* -------------------------------------------- */
@ -247,65 +250,51 @@ export class RdDItemSheet extends ItemSheet {
}
/* -------------------------------------------- */
get template() {
let type = this.item.type
return `systems/foundryvtt-reve-de-dragon/templates/item-${type}-sheet.html`;
}
/* -------------------------------------------- */
/** @override */
_updateObject(event, formData) {
// Données de bonus de cases ?
formData['system.bonuscase'] = RdDItemSort.buildBonusCaseStringFromFormData(formData.bonusValue, formData.caseValue);
if (this.item.type == 'sort') {
// Données de bonus de cases ?
formData['system.bonuscase'] = RdDItemSort.buildBonusCaseStringFromFormData(formData.bonusValue, formData.caseValue);
}
return this.item.update(formData);
}
/* -------------------------------------------- */
async _onDragStart(event) {
console.log("_onDragStart", event);
if (event.target.classList.contains("entity-link")) return;
const itemId = event.srcElement?.attributes["data-item-id"].value;
const item = this.actor.items.get(itemId);
// Create drag data
const dragData = {
actorId: this.actor.id,
type: "Item",
data: item.system
};
event.dataTransfer.setData("text/plain", JSON.stringify(dragData));
}
async _onDrop(event) {
// Try to extract the dragData
let dragData;
try {
dragData = JSON.parse(event.dataTransfer.getData('text/plain'));
} catch (err) {
return false;
}
let dragData = RdDItemSheet.$extractDragData(event);
if (!dragData) return false;
const allowed = Hooks.call("dropActorSheetData", this.actor, this, dragData);
if (allowed === false) return;
if (allowed === false) return false;
// Handle different dragData types
switch (dragData.type) {
case "Item":
return this._onDropItem(event, dragData);
case "Actor":
return this._onDropActor(event, dragData);
}
return super._onDrop(event);
}
/* -------------------------------------------- */
async _onDropItem(event, dragData) {
if (this.actor) {
const dropParams = RdDSheetUtility.prepareItemDropParameters(this.item.id, this.actor.id, dragData, this.objetVersConteneur);
await this.actor.processDropItem(dropParams);
await this.render(true);
}
static $extractDragData(event) {
try {
const eventData = event?.dataTransfer?.getData('text/plain');
if (eventData) {
return JSON.parse(eventData);
}
} catch (err) { }
return undefined;
}
async _onDropItem(event, dragData) {
}
async _onDropActor(event, dragData) {
}
}

View File

@ -1,29 +1,14 @@
import { SYSTEM_RDD } from "./constants.js";
import { RdDItemSheet } from "./item-sheet.js";
import { RdDItemSigneDraconique } from "./item-signedraconique.js";
import { TMRUtility } from "./tmr-utility.js";
/**
* Item sheet pour signes draconiques
* @extends {ItemSheet}
* @extends {RdDItemSheet}
*/
export class RdDSigneDraconiqueItemSheet extends ItemSheet {
export class RdDSigneDraconiqueItemSheet extends RdDItemSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: [SYSTEM_RDD, "sheet", "item"],
template: "systems/foundryvtt-reve-de-dragon/templates/item-signedraconique-sheet.html",
width: 550,
height: 550
});
}
/* -------------------------------------------- */
_getHeaderButtons() {
let buttons = super._getHeaderButtons();
buttons.unshift({ class: "post", icon: "fas fa-comment", onclick: ev => this.item.postItem() });
return buttons;
}
static get ITEM_TYPE() { return "signedraconique" }
/* -------------------------------------------- */
/** @override */
@ -61,12 +46,13 @@ export class RdDSigneDraconiqueItemSheet extends ItemSheet {
if (!this.options.editable) return;
html.find(".signe-aleatoire").click(event => this.setSigneAleatoire());
html.find("input.select-tmr").change((event) => this.onSelectTmr(event));
html.find(".signe-xp-sort").change((event) => this.onValeurXpSort(event.currentTarget.attributes['data-typereussite']?.value, Number(event.currentTarget.value)));
html.find("input.select-tmr").change(event => this.onSelectTmr(event));
html.find(".signe-xp-sort").change(event => this.onValeurXpSort(event.currentTarget.attributes['data-typereussite']?.value, Number(event.currentTarget.value)));
}
async setSigneAleatoire() {
const newSigne = await RdDItemSigneDraconique.randomSigneDraconique();
newSigne.name = this.item.name;
this.item.update(newSigne);
}
@ -88,12 +74,4 @@ export class RdDSigneDraconiqueItemSheet extends ItemSheet {
await this.item.update({ 'system.valeur': newValeur });
}
/* -------------------------------------------- */
get template() {
return `systems/foundryvtt-reve-de-dragon/templates/item-signedraconique-sheet.html`;
}
get title() {
return `Signe draconique: ${this.object.name}`;
}
}

View File

@ -1,16 +1,16 @@
import { DialogItemVente } from "./dialog-item-vente.js";
import { Grammar } from "./grammar.js";
import { Monnaie } from "./item-monnaie.js";
import { RdDHerbes } from "./rdd-herbes.js";
import { RdDUtility } from "./rdd-utility.js";
const typesObjetsEquipement = [
const typesObjetsInventaire = [
"arme",
"armure",
"conteneur",
"gemme",
"herbe",
"ingredient",
"faune",
"livre",
"monnaie",
"munition",
@ -36,6 +36,7 @@ export const defaultItemImg = {
conteneur: "systems/foundryvtt-reve-de-dragon/icons/objets/sac_a_dos.webp",
sort: "systems/foundryvtt-reve-de-dragon/icons/competence_oniros.webp",
herbe: "systems/foundryvtt-reve-de-dragon/icons/botanique/Endorlotte.webp",
faune: "systems/foundryvtt-reve-de-dragon/icons/faune/rongeur.webp",
ingredient: "systems/foundryvtt-reve-de-dragon/icons/objets/sable_poudre.webp",
livre: "systems/foundryvtt-reve-de-dragon/icons/objets/livre.webp",
potion: "systems/foundryvtt-reve-de-dragon/icons/objets/liqueur_de_bagdol.webp",
@ -70,7 +71,11 @@ export class RdDItem extends Item {
return defaultItemImg[itemType];
}
static isEquipementFieldEditable(type, field) {
static isItemInventaire(newLocal) {
return typesObjetsInventaire.includes(newLocal.type);
}
static isFieldInventaireModifiable(type, field) {
switch (field) {
case 'quantite':
if (['conteneur'].includes(type)) {
@ -78,8 +83,8 @@ export class RdDItem extends Item {
}
break;
case 'cout':
if(['monnaie'].includes(type)){
return game.user.isGM;
if (['monnaie'].includes(type)) {
return game.user.isGM;
}
break;
}
@ -98,12 +103,12 @@ export class RdDItem extends Item {
constructor(itemData, context) {
if (!itemData.img) {
itemData.img = RdDItem.getDefaultImg(itemData.type);
}
}
super(itemData, context);
}
}
static getTypesObjetsEquipement() {
return typesObjetsEquipement
static getItemTypesInventaire() {
return typesObjetsInventaire
}
static getTypesOeuvres() {
@ -113,11 +118,14 @@ export class RdDItem extends Item {
isCompetencePersonnage() {
return this.type == 'competence'
}
isCompetenceCreature() {
return this.type == 'competencecreature'
}
isCompetence() {
return typesObjetsCompetence.includes(this.type)
}
isEquipement() {
return typesObjetsEquipement.includes(this.type)
isInventaire() {
return RdDItem.isItemInventaire(this)
}
isOeuvre() {
return typesObjetsOeuvres.includes(this.type)
@ -136,7 +144,7 @@ export class RdDItem extends Item {
}
getItemGroup() {
if (this.isEquipement()) return "equipement";
if (this.isInventaire()) return "equipement";
if (this.isOeuvre()) return "oeuvre";
if (this.isDraconique()) return "draconique";
if (this.isConnaissance()) return "connaissance";
@ -180,7 +188,7 @@ export class RdDItem extends Item {
getEncTotal() {
return this.getEnc() * this.getQuantite();
}
}
getEnc() {
switch (this.type) {
@ -202,7 +210,7 @@ export class RdDItem extends Item {
prepareDerivedData() {
super.prepareDerivedData();
if (this.isEquipement()) {
if (this.isInventaire()) {
this.system.encTotal = this.getEncTotal();
if (this.isPotion()) {
this.prepareDataPotion()
@ -229,13 +237,13 @@ export class RdDItem extends Item {
case 'potion': return this._actionOrWarnQuantiteZero('Boire', warn);
case 'livre': return this._actionOrWarnQuantiteZero('Lire', warn);
case 'conteneur': return 'Ouvrir';
case 'herbe': return this.isHerbeAPotion() ? this._actionOrWarnQuantiteZero('Décoction', warn) : undefined;
case 'queue': case 'ombre': return this.system.refoulement>0 ? 'Refouler' : undefined;
case 'herbe': return this.isHerbeAPotion() ? this._actionOrWarnQuantiteZero('Décoction', warn) : undefined;
case 'queue': case 'ombre': return this.system.refoulement > 0 ? 'Refouler' : undefined;
}
return undefined;
}
_actionOrWarnQuantiteZero(actionName, warn){
_actionOrWarnQuantiteZero(actionName, warn) {
if ((this.system.quantite ?? 0) <= 0) {
if (warn) {
ui.notifications.warn(`Vous n'avez plus de ${this.name}.`);
@ -275,14 +283,14 @@ export class RdDItem extends Item {
/* -------------------------------------------- */
// détermine si deux équipements sont similaires: de même type, et avec les même champs hormis la quantité
isEquipementEmpilable(other) {
if (!other || !this.isEquipement()) {
isInventaireEmpilable(other) {
if (!other || !this.isInventaire()) {
return [false, undefined];
}
if (this.system.quantite == undefined) {
return [false, `Impossible de regrouper des ${this.type}, ils ne sont pas empilables`];
}
}
else if (this.type != other.type) {
return [false, `Impossible de regrouper des ${this.type} avec des ${other.type}`];
}
@ -309,7 +317,7 @@ export class RdDItem extends Item {
ui.notifications.warn(`Votre ${this.name} n'est pas vide, pas possible de le proposer`);
return;
}
await DialogItemVente.display(this, async (vente) => {
await DialogItemVente.display(this, async (vente) => {
vente["properties"] = this.getProprietes();
if (vente.isOwned) {
if (vente.quantiteNbLots * vente.tailleLot > vente.quantiteMax) {
@ -318,7 +326,7 @@ export class RdDItem extends Item {
}
}
vente.jsondata = JSON.stringify(vente.item);
console.log(vente);
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-vente-item.html', vente);
ChatMessage.create(RdDUtility.chatDataSetup(html));
@ -327,7 +335,7 @@ export class RdDItem extends Item {
/* -------------------------------------------- */
getProprietes() {
return this[`_${this.type}ChatData`]();
return this[`_${this.type}ChatData`]().filter(it => it != undefined);
}
/* -------------------------------------------- */
@ -351,29 +359,31 @@ export class RdDItem extends Item {
});
}
static propertyIfDefined(name, val, condition = (it) => true) {
return condition ? [`<b>${name}</b>: ${val}`] : [];
static propertyIfDefined(name, val, condition = true) {
return condition ? `<b>${name}</b>: ${val}` : undefined;
}
_inventaireTemplateChatData() {
return [
RdDItem.propertyIfDefined('Qualité', this.system.qualite, this.system.qualite != 0),
RdDItem.propertyIfDefined('Encombrement', this.system.encombrement)
// cout et quantité masqués
]
}
/* -------------------------------------------- */
_objetChatData() {
return [].concat(
RdDItem.propertyIfDefined('Résistance', this.system.resistance, this.system.resistance),
RdDItem.propertyIfDefined('Qualité', this.system.qualite, this.system.qualite),
RdDItem.propertyIfDefined('Encombrement', this.system.encombrement),
);
return this._inventaireTemplateChatData()
}
/* -------------------------------------------- */
_nourritureboissonChatData() {
return [].concat(
return [
RdDItem.propertyIfDefined('Sustentation', this.system.sust, this.system.sust > 0),
RdDItem.propertyIfDefined('Désaltère', this.system.desaltere, this.system.boisson),
RdDItem.propertyIfDefined('Force alcool', this.system.force, this.system.boisson && this.system.alcoolise),
RdDItem.propertyIfDefined('Exotisme', this.system.exotisme, this.system.exotisme < 0),
RdDItem.propertyIfDefined('Qualité', this.system.qualite, this.system.qualite),
RdDItem.propertyIfDefined('Encombrement', this.system.encombrement),
);
...this._inventaireTemplateChatData()
]
}
/* -------------------------------------------- */
_armeChatData() {
@ -382,21 +392,19 @@ export class RdDItem extends Item {
`<b>Dommages</b>: ${this.system.dommages}`,
`<b>Force minimum</b>: ${this.system.force}`,
`<b>Resistance</b>: ${this.system.resistance}`,
`<b>Encombrement</b>: ${this.system.encombrement}`
...this._inventaireTemplateChatData()
]
}
/* -------------------------------------------- */
_conteneurChatData() {
return [
`<b>Capacité</b>: ${this.system.capacite} Enc.`,
`<b>Encombrement</b>: ${this.system.encombrement}`
...this._inventaireTemplateChatData()
]
}
/* -------------------------------------------- */
_munitionChatData() {
return [
`<b>Encombrement</b>: ${this.system.encombrement}`
]
return this._inventaireTemplateChatData()
}
/* -------------------------------------------- */
_armureChatData() {
@ -404,7 +412,7 @@ export class RdDItem extends Item {
`<b>Protection</b>: ${this.system.protection}`,
`<b>Détérioration</b>: ${this.system.deterioration}`,
`<b>Malus armure</b>: ${this.system.malus}`,
`<b>Encombrement</b>: ${this.system.encombrement}`
...this._inventaireTemplateChatData()
]
}
/* -------------------------------------------- */
@ -438,16 +446,24 @@ export class RdDItem extends Item {
_herbeChatData() {
return [
`<b>Milieu</b>: ${this.system.milieu}`,
`<b>Rareté</b>: ${this.system.rarete}`,
`<b>Catégorie</b>: ${this.system.categorie}`,
...this._inventaireTemplateChatData()
]
}
/* -------------------------------------------- */
_ingredientChatData() {
return [
`<b>Milieu</b>: ${this.system.milieu}`,
`<b>Rareté</b>: ${this.system.rarete}`,
`<b>Catégorie</b>: ${this.system.categorie}`,
...this._inventaireTemplateChatData()
]
}
/* -------------------------------------------- */
_fauneChatData() {
return [
`<b>Sustentation</b>: ${this.system.sust}`,
`<b>Milieu</b>: ${this.system.milieu}`,
...this._inventaireTemplateChatData()
]
}
/* -------------------------------------------- */
@ -457,12 +473,9 @@ export class RdDItem extends Item {
`<b>Compétence</b>: ${this.system.competence}`,
`<b>Périodicité</b>: ${this.system.periodicite}`,
`<b>Fatigue</b>: ${this.system.fatigue}`,
`<b>Difficulté</b>: ${this.system.difficulte}`
].concat([
this.system.cacher_points_de_tache ? [] :`<b>Points de Tâche</b>: ${this.system.points_de_tache}`
]).concat([
`<b>Difficulté</b>: ${this.system.difficulte}`,
RdDItem.propertyIfDefined('Points de Tâche', this.system.points_de_tache, this.system.cacher_points_de_tache),
`<b>Points de Tâche atteints</b>: ${this.system.points_de_tache_courant}`]
);
}
/* -------------------------------------------- */
_livreChatData() {
@ -470,8 +483,8 @@ export class RdDItem extends Item {
`<b>Compétence</b>: ${this.system.competence}`,
`<b>Auteur</b>: ${this.system.auteur}`,
`<b>Difficulté</b>: ${this.system.difficulte}`,
`<b>Points de Tâche</b>: ${this.system.points_de_tache}`,
`<b>Encombrement</b>: ${this.system.encombrement}`
RdDItem.propertyIfDefined('Points de Tâche', this.system.points_de_tache, this.system.cacher_points_de_tache),
...this._inventaireTemplateChatData()
]
}
/* -------------------------------------------- */
@ -479,32 +492,44 @@ export class RdDItem extends Item {
return [
`<b>Rareté</b>: ${this.system.rarete}`,
`<b>Catégorie</b>: ${this.system.categorie}`,
`<b>Encombrement</b>: ${this.system.encombrement}`,
...this._inventaireTemplateChatData()
]
}
/* -------------------------------------------- */
_queueChatData() {
function label(categorie) {
switch (categorie) {
case 'ideefixe': return 'Idée fixe';
case 'lancinant': return 'Désir lancinant';
}
return ''
}
return [
`<b>Refoulement</b>: ${this.system.refoulement}`
`<b>Refoulement</b>: ${this.system.refoulement}`,
`<b>Catégorie</b>: ${label(this.system.categorie)}`,
`<b>Affecte</b>: ${this.system.hautrevant ? 'les haut-rêvants' : 'tout le monde'}`,
]
}
/* -------------------------------------------- */
_ombreChatData() {
return [
`<b>Refoulement</b>: ${this.system.refoulement}`
]
return this._queueChatData()
}
/* -------------------------------------------- */
_souffleChatData() {
return [];
return [
`<b>Affecte</b>: ${this.system.hautrevant ? 'les haut-rêvants' : 'tout le monde'}`,
];
}
/* -------------------------------------------- */
_teteChatData() {
return [];
return [
`<b>Affecte</b>: ${this.system.hautrevant ? 'les haut-rêvants' : 'tout le monde'}`,
];
}
/* -------------------------------------------- */
_tarotChatData() {
return [
RdDItem.propertyIfDefined('Carte', RdDUtility.linkCompendium(this.pack, this.id, this.name), this.pack),
`<b>Concept</b>: ${this.system.concept}`,
`<b>Aspect</b>: ${this.system.aspect}`,
]
@ -518,10 +543,7 @@ export class RdDItem extends Item {
}
/* -------------------------------------------- */
_monnaieChatData() {
return [
`<b>Valeur en Sols</b>: ${this.system.cout}`,
`<b>Encombrement</b>: ${this.system.encombrement}`
]
return this._inventaireTemplateChatData()
}
/* -------------------------------------------- */
_meditationChatData() {
@ -545,9 +567,9 @@ export class RdDItem extends Item {
]
}
return [
`<b>Force</b>: ${this.system.force}`,
`<b>Force</b>: ${this.system.formule}`,
`<b>Refoulement</b>: ${this.system.refoulement}`,
`<b>Présent de cités</b>: ${this.system.presentCite}`,
RdDItem.propertyIfDefined('<b>Présent de cités</b>', '', this.system.presentCite),
]
}
/* -------------------------------------------- */
@ -562,15 +584,12 @@ export class RdDItem extends Item {
if (!this.system.identifie) {
return [`<b>Inconnue</b>`]
}
let properties = [
`<b>Malignité</b>: ${this.system.malignite}`,
`<b>Périodicité</b>: ${this.system.periodicite}`,
`<b>Dommages</b>: ${this.system.dommages}`
]
if (this.system.remedesconnus) {
properties.push(`<b>Remedes</b>: ${this.system.remedes}`)
}
return properties;
return [
`<b>Malignité</b>: ${this.system.malignite}`,
`<b>Périodicité</b>: ${this.system.periodicite}`,
`<b>Dommages</b>: ${this.system.dommages}`,
RdDItem.propertyIfDefined('<b>Remedes</b>', this.system.remedes, this.system.remedesconnus),
]
}
/* -------------------------------------------- */
@ -585,7 +604,7 @@ export class RdDItem extends Item {
`<b>Taille</b>: ${this.system.taille}`,
`<b>Inertie</b>: ${this.system.inertie}`,
`<b>Enchantabilité</b>: ${this.system.enchantabilite}`,
`<b>Prix</b>: ${this.system.cout}`,
...this._inventaireTemplateChatData()
]
}

View File

@ -42,7 +42,8 @@ export class Misc {
}
static typeName(type, subType) {
return game.i18n.localize(`${type.toUpperCase()}.Type${Misc.upperFirst(subType)}`);
return subType ? game.i18n.localize(`${type.toUpperCase()}.Type${Misc.upperFirst(subType)}`)
: '';
}
/**

View File

@ -246,7 +246,7 @@ export class RdDCombatManager extends Combat {
if (actions.length > 0) {
return actions;
}
if (actor.isCreature()) {
if (actor.isCreatureEntite()) {
actions = actions.concat(RdDCombatManager.listActionsCreature(actor.itemTypes['competencecreature']));
} else {
// Recupération des items 'arme'
@ -821,7 +821,7 @@ export class RdDCombat {
essais: {}
};
if (this.attacker.isCreature()) {
if (this.attacker.isCreatureEntite()) {
RdDItemCompetenceCreature.setRollDataCreature(rollData);
}
else if (arme) {
@ -1079,7 +1079,7 @@ export class RdDCombat {
show: {}
};
if (this.defender.isCreature()) {
if (this.defender.isCreatureEntite()) {
RdDItemCompetenceCreature.setRollDataCreature(defenderRoll);
}
@ -1158,7 +1158,7 @@ export class RdDCombat {
show: {}
};
if (this.defender.isCreature()) {
if (this.defender.isCreatureEntite()) {
RdDItemCompetenceCreature.setRollDataCreature(rollData);
}
return rollData;

View File

@ -42,6 +42,8 @@ import { TMRRencontres } from "./tmr-rencontres.js";
import { RdDHerbeItemSheet } from "./item-herbe-sheet.js";
import { Environnement } from "./environnement.js";
import { RdDIngredientItemSheet } from "./item-ingredient-sheet.js";
import { RdDFauneItemSheet } from "./item-faune-sheet.js";
import { RdDConteneurItemSheet } from "./item-conteneur-sheet.js";
/* -------------------------------------------- */
/* Foundry VTT Initialization */
@ -163,8 +165,8 @@ Hooks.once("init", async function () {
RdDCombat.onSocketMessage(sockmsg);
ChatUtility.onSocketMessage(sockmsg);
RdDActor.onSocketMessage(sockmsg);
} catch(e) {
console.error('game.socket.on(SYSTEM_SOCKET_ID) Exception: ', sockmsg,' => ', e)
} catch (e) {
console.error('game.socket.on(SYSTEM_SOCKET_ID) Exception: ', sockmsg, ' => ', e)
}
});
@ -187,28 +189,24 @@ Hooks.once("init", async function () {
Actors.registerSheet(SYSTEM_RDD, RdDActorVehiculeSheet, { types: ["vehicule"], makeDefault: true });
Actors.registerSheet(SYSTEM_RDD, RdDActorEntiteSheet, { types: ["entite"], makeDefault: true });
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet(SYSTEM_RDD, RdDSigneDraconiqueItemSheet, {
label: "Signe draconique",
types: ["signedraconique"],
makeDefault: true
});
Items.registerSheet(SYSTEM_RDD, RdDRencontreItemSheet, {
label: "Rencontre",
types: ["rencontre"],
makeDefault: true
});
RdDHerbeItemSheet.register();
RdDIngredientItemSheet.register();
RdDItemSheet.register(RdDSigneDraconiqueItemSheet);
RdDItemSheet.register(RdDRencontreItemSheet);
RdDItemSheet.register(RdDConteneurItemSheet);
RdDItemSheet.register(RdDHerbeItemSheet);
RdDItemSheet.register(RdDFauneItemSheet);
RdDItemSheet.register(RdDIngredientItemSheet);
Items.registerSheet(SYSTEM_RDD, RdDItemSheet, {
types: [
"competence", "competencecreature",
"recettealchimique", "musique", "chant", "danse", "jeu", "recettecuisine", "oeuvre",
"objet", "arme", "armure", "conteneur", "livre", "potion", "munition",
"objet", "arme", "armure", "livre", "potion", "munition",
"monnaie", "nourritureboisson", "gemme",
"meditation", "queue", "ombre", "souffle", "tete", "casetmr", "sort", "sortreserve",
"nombreastral", "tache", "maladie", "poison", "possession",
"tarot", "extraitpoetique"
], makeDefault: true
], makeDefault: true
});
CONFIG.Combat.documentClass = RdDCombatManager;
@ -247,8 +245,8 @@ function messageDeBienvenue() {
/* -------------------------------------------- */
// Register world usage statistics
function registerUsageCount( registerKey ) {
if ( game.user.isGM ) {
function registerUsageCount(registerKey) {
if (game.user.isGM) {
game.settings.register("world", "world-key", {
name: "Unique world key",
scope: "world",
@ -258,9 +256,9 @@ function registerUsageCount( registerKey ) {
});
let worldKey = game.settings.get("world", "world-key")
if ( worldKey == undefined || worldKey == "" ) {
if (worldKey == undefined || worldKey == "") {
worldKey = randomID(32)
game.settings.set("world", "world-key", worldKey )
game.settings.set("world", "world-key", worldKey)
}
let regURL = `https://www.uberwald.me/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.version}"`
$.ajax(regURL)
@ -300,7 +298,7 @@ Hooks.once("ready", async function () {
}
if (Misc.isUniqueConnectedGM()) {
messageDeBienvenue();
registerUsageCount( SYSTEM_RDD );
registerUsageCount(SYSTEM_RDD);
}
});

View File

@ -45,7 +45,7 @@ export class RdDPossession {
defender: defender,
targetToken: Targets.extractTokenData(target)
};
if (attacker.isCreature()) {
if (attacker.isCreatureEntite()) {
RdDItemCompetenceCreature.setRollDataCreature(rollData)
}

View File

@ -19,17 +19,23 @@ export class RdDSheetUtility {
return $(event.currentTarget)?.parents(".item");
}
static prepareItemDropParameters(destItemId, actorId, dragData, objetVersConteneur) {
static prepareItemDropParameters(destItemId, actor, dragData, objetVersConteneur) {
const item = fromUuidSync(dragData.uuid)
return {
destId: destItemId,
targetActorId: actorId,
itemId: item.id,
sourceActorId: item.actor?.id,
srcId: objetVersConteneur[item.id],
onEnleverConteneur: () => { delete objetVersConteneur[item.id]; },
onAjouterDansConteneur: (itemId, conteneurId) => { objetVersConteneur[itemId] = conteneurId; }
if (actor.canReceive(item)) {
return {
destId: destItemId,
targetActorId: actor.id,
itemId: item.id,
sourceActorId: item.actor?.id,
srcId: objetVersConteneur[item.id],
onEnleverConteneur: () => { delete objetVersConteneur[item.id]; },
onAjouterDansConteneur: (itemId, conteneurId) => { objetVersConteneur[itemId] = conteneurId; }
}
}
else {
ui.notifications.warn(`Impossible de donner ${item.name} à ${actor.name}: ${item.type} / ${actor.type}`);
}
return undefined;
}
static async splitItem(item, actor, onSplit = () => { }) {

View File

@ -1,5 +1,4 @@
/* Common useful functions shared between objects */
import { ChatUtility } from "./chat-utility.js";
import { RdDCombat } from "./rdd-combat.js";
import { Misc } from "./misc.js";
@ -14,7 +13,6 @@ import { RdDPossession } from "./rdd-possession.js";
import { RdDNameGen } from "./rdd-namegen.js";
import { RdDConfirm } from "./rdd-confirm.js";
import { RdDCalendrier } from "./rdd-calendrier.js";
import { RdDCarac } from "./rdd-carac.js";
import { Environnement } from "./environnement.js";
/* -------------------------------------------- */
@ -185,6 +183,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/item-sort-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-herbe-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-ingredient-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-faune-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-livre-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-tache-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-potion-sheet.html',
@ -220,6 +219,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/enum-tmr-type.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-tmr-effet.html',
// Partials
'systems/foundryvtt-reve-de-dragon/templates/common/compendium-link.hbs',
'systems/foundryvtt-reve-de-dragon/templates/partial-description-overflow.html',
'systems/foundryvtt-reve-de-dragon/templates/partial-description-sort.html',
'systems/foundryvtt-reve-de-dragon/templates/partial-roll-ajustements.html',
@ -328,14 +328,18 @@ export class RdDUtility {
return a.name.localeCompare(b.name);
})
);
Handlebars.registerHelper('linkCompendium', (compendium, id, name) => `@Compendium[${compendium}.${id}]{${name}}`);
Handlebars.registerHelper('linkCompendium', (pack, id, name)=> RdDUtility.linkCompendium(pack, id, name));
Handlebars.registerHelper('uniteQuantite', (type) => RdDItem.getUniteQuantite(type));
Handlebars.registerHelper('isEquipementFieldEditable', (type, field) => RdDItem.isEquipementFieldEditable(type, field));
Handlebars.registerHelper('isFieldInventaireModifiable', (type, field) => RdDItem.isFieldInventaireModifiable(type, field));
Handlebars.registerHelper('getFrequenceRarete', (rarete, field) => Environnement.getFrequenceRarete(rarete, field));
Handlebars.registerHelper('either', (a, b) => a ?? b);
return loadTemplates(templatePaths);
}
static linkCompendium(pack, id, name) {
return `@Compendium[${pack}.${id}]{${name}}`;
}
/* -------------------------------------------- */
static async creerObjet(actorSheet) {
let itemType = $(".item-type").val();
@ -344,7 +348,7 @@ export class RdDUtility {
/* -------------------------------------------- */
static async selectObjetType(actorSheet) {
let typeObjets = RdDItem.getTypesObjetsEquipement();
let typeObjets = RdDItem.getItemTypesInventaire();
let options = `<span class="competence-label">Selectionnez le type d'équipement</span><select class="item-type">`;
for (let typeName of typeObjets) {
options += `<option value="${typeName}">${typeName}</option>`
@ -466,9 +470,9 @@ export class RdDUtility {
formData.livres = this.arrayOrEmpty(itemTypes['livre']);
formData.potions = this.arrayOrEmpty(itemTypes['potion']);
formData.ingredients = this.arrayOrEmpty(itemTypes['ingredient']);
formData.faunes = this.arrayOrEmpty(itemTypes['faune']);
formData.herbes = this.arrayOrEmpty(itemTypes['herbe']);
formData.monnaie = this.arrayOrEmpty(itemTypes['monnaie']);
formData.monnaie.sort(Monnaie.triValeurEntiere());
formData.monnaie = this.arrayOrEmpty(itemTypes['monnaie']).sort(Monnaie.triValeurEntiere());
formData.nourritureboissons = this.arrayOrEmpty(itemTypes['nourritureboisson']);
formData.gemmes = this.arrayOrEmpty(itemTypes['gemme']);
@ -481,6 +485,7 @@ export class RdDUtility {
.concat(formData.potions)
.concat(formData.ingredients)
.concat(formData.herbes)
.concat(formData.faunes)
.concat(formData.monnaie)
.concat(formData.nourritureboissons)
.concat(formData.gemmes);

View File

@ -497,8 +497,7 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) {
}
.foundryvtt-reve-de-dragon .sheet-body,
.foundryvtt-reve-de-dragon .sheet-body .tab,
.foundryvtt-reve-de-dragon .sheet-body .tab .editor {
.foundryvtt-reve-de-dragon .sheet-body .tab {
height: 100%;
}
@ -543,7 +542,7 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) {
.editor {
border: 2;
height: 300px;
height: 10rem;
padding: 0 3px;
}

View File

@ -1,8 +1,8 @@
{
"id": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"version": "10.3.4",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.3.4.zip",
"version": "10.3.5",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.3.5.zip",
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
"compatibility": {
"minimum": "10",

View File

@ -572,7 +572,7 @@
"types": [
"competence", "competencecreature",
"recettealchimique", "musique", "chant", "danse", "jeu", "recettecuisine", "oeuvre",
"objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition",
"objet", "arme", "armure", "conteneur", "herbe", "ingredient", "faune", "livre", "potion", "munition",
"monnaie", "nourritureboisson", "gemme",
"meditation", "rencontre", "queue", "ombre", "souffle", "tete", "casetmr", "signedraconique", "sort", "sortreserve",
"nombreastral", "tache", "maladie", "poison", "possession",
@ -700,11 +700,11 @@
},
"nourritureboisson": {
"templates": [ "description", "inventaire" ],
"sust": 0,
"boisson": false,
"desaltere": 0,
"alcoolise": false,
"force": 0,
"sust": 0,
"exotisme": 0
},
"herbe": {
@ -717,8 +717,20 @@
"templates": [ "description", "inventaire", "environnement" ],
"niveau": 0,
"base": 0,
"sust": 0,
"exotisme": 0,
"categorie": ""
},
"faune": {
"templates": [ "description", "inventaire", "environnement"],
"sust": 0,
"exotisme": 0,
"actor": {
"id": "",
"pack": "",
"name": ""
}
},
"livre": {
"templates": [ "description", "inventaire" ],
"competence": "",

View File

@ -0,0 +1 @@
<a class="content-link" draggable="true" data-pack="{{pack}}" data-uuid="Compendium.{{pack}}.{{id}}" data-id="{{id}}"><i class="fas fa-suitcase"></i>{{name}}</a>

View File

@ -0,0 +1,47 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
</div>
</header>
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="informations">Informations</a>
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-tab-environnement.html"}}
</nav>
<section class="sheet-body">
<div class="tab items" data-group="primary" data-tab="informations">
<div class="flexcol">
<div class="form-group">
<label for="system.sust">Sustentation (si applicable)</label>
<input class="attribute-value" type="number" name="system.sust" value="{{system.sust}}" data-dtype="Number" min="0"/>
</div>
{{#if (gt system.sust 0)}}
<div class="form-group">
<label for="system.exotisme">Exotisme</label>
<input class="attribute-value" type="number" name="system.exotisme" value="{{system.exotisme}}" data-dtype="Number" min="-10" max="0"/>
</div>
{{/if}}
<div class="form-group">
<label>Créature correspondante</label>
<div>
{{#if system.actor.id}}
<label>
{{>'systems/foundryvtt-reve-de-dragon/templates/common/compendium-link.hbs'
pack=system.actor.pack id=system.actor.id name=system.actor.name}}
</label>
<a class="linked-actor-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
{{else}}
<label>Pas de fiche de créature</label>
{{/if}}
</div>
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-inventaire.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</div>
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-environnement.html"}}
</section>
</form>

View File

@ -5,7 +5,7 @@
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
{{#if isIngredientPotionBase}}
<div class="form-group">
<span for="xp"><a class="creer-potion-base chat-card-button" data-actor-id="{{actorId}}">Fabriquer une potion depuis cette plante</a></span>
<span><a class="creer-potion-base chat-card-button" data-actor-id="{{actorId}}">Fabriquer une potion depuis cette plante</a></span>
</div>
{{/if}}
</div>

View File

@ -1,20 +1,20 @@
<div class="form-group">
<label for="system.qualite">Qualité</label>
<input class="attribute-value" type="text" name="system.qualite" value="{{system.qualite}}" data-dtype="Number"
{{#unless (isEquipementFieldEditable type 'qualite')}}disabled{{/unless}}/>
{{#unless (isFieldInventaireModifiable type 'qualite')}}disabled{{/unless}}/>
</div>
<div class="form-group">
<label for="system.encombrement">Encombrement</label>
<input class="attribute-value" type="text" name="system.encombrement" value="{{system.encombrement}}" data-dtype="Number"
{{#unless (isEquipementFieldEditable type 'encombrement')}}disabled{{/unless}}/>
{{#unless (isFieldInventaireModifiable type 'encombrement')}}disabled{{/unless}}/>
</div>
<div class="form-group">
<label for="system.quantite">Quantité {{uniteQuantite type}}</label>
<input class="attribute-value" type="text" name="system.quantite" value="{{system.quantite}}" data-dtype="Number"
{{#unless (isEquipementFieldEditable type 'quantite')}}disabled{{/unless}}/>
{{#unless (isFieldInventaireModifiable type 'quantite')}}disabled{{/unless}}/>
</div>
<div class="form-group item-cout">
<label for="system.cout">Prix (sols) </label>
<input class="attribute-value" type="text" name="system.cout" value="{{system.cout}}" data-dtype="Number"
{{#unless (isEquipementFieldEditable type 'cout')}}disabled{{/unless}}/>
{{#unless (isFieldInventaireModifiable type 'cout')}}disabled{{/unless}}/>
</div>