Merge pull request '10.3.3' (#585) from VincentVk/foundryvtt-reve-de-dragon:v10 into v10

Reviewed-on: public/foundryvtt-reve-de-dragon#585
This commit is contained in:
uberwald 2022-12-02 23:51:15 +01:00
commit a43c725b06
4 changed files with 30 additions and 22 deletions

View File

@ -1362,7 +1362,7 @@ export class RdDActor extends Actor {
const valeur = this.items.filter(it => it.isEquipement()) const valeur = this.items.filter(it => it.isEquipement())
.map(it => it.valeurTotale()) .map(it => it.valeurTotale())
.reduce(Misc.sum(), 0); .reduce(Misc.sum(), 0);
return valeur / 100; return valeur;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -8,17 +8,16 @@ const RARETES = [
{ name: 'Frequente', frequence: 18, min: 9, max: 36 }, { name: 'Frequente', frequence: 18, min: 9, max: 36 },
{ name: 'Rare', frequence: 6, min: 3, max: 12 }, { name: 'Rare', frequence: 6, min: 3, max: 12 },
{ name: 'Rarissime', frequence: 2, min: 1, max: 4 }] { name: 'Rarissime', frequence: 2, min: 1, max: 4 }]
const DEFAULT_RARETE = 1;
const SETTINGS_LISTE_MILIEUX = "liste-milieux"; const SETTINGS_LISTE_MILIEUX = "liste-milieux";
const MILIEUX = [ const MILIEUX = [
"Collines", "Collines",
"Déserts", "Déserts",
"Désolations",
"Forêts", "Forêts",
"Forêts Tropicales",
"Marais", "Marais",
"Milieux Aquatiques", "Cours d'eau",
"Milieux Maritimes", "Maritimes",
"Montagnes", "Montagnes",
"Plaines", "Plaines",
"Sous-Sols", "Sous-Sols",
@ -46,7 +45,7 @@ export class Environnement {
} }
static getRarete(name = undefined) { static getRarete(name = undefined) {
return RARETES.find(it => it.name == name) ?? RARETES[0]; return RARETES.find(it => it.name == name) ?? RARETES[DEFAULT_RARETE];
} }
static getFrequenceRarete(rarete, field = undefined) { static getFrequenceRarete(rarete, field = undefined) {
@ -67,7 +66,7 @@ export class Environnement {
async findEnvironnementsLike(search) { async findEnvironnementsLike(search) {
const milieux = (await this.milieux()).filter(it => Grammar.includesLowerCaseNoAccent(it, search)); const milieux = (await this.milieux()).filter(it => Grammar.includesLowerCaseNoAccent(it, search));
if (milieux.length > 1){ if (milieux.length > 1) {
const milieuExact = milieux.find(it => Grammar.equalsInsensitive(it, search)); const milieuExact = milieux.find(it => Grammar.equalsInsensitive(it, search));
if (milieuExact) { if (milieuExact) {
return [milieuExact]; return [milieuExact];
@ -151,21 +150,31 @@ export class EnvironmentSheetHelper {
static activateListeners(sheet, html) { static activateListeners(sheet, html) {
if (!sheet.options.editable) return; if (!sheet.options.editable) return;
html.find("input.input-selection-milieu").keypress(event => {
if (event.keyCode == '13') {
EnvironmentSheetHelper.onAddMilieu(html, sheet, event);
}
event.stopPropagation();
})
html.find("a.milieu-add").click(event => EnvironmentSheetHelper.onAddMilieu(html, sheet, event)); html.find("a.milieu-add").click(event => EnvironmentSheetHelper.onAddMilieu(html, sheet, event));
html.find("div.environnement-milieu a.milieu-delete").click(event => EnvironmentSheetHelper.onDeleteMilieu(sheet, event)); html.find("div.environnement-milieu a.milieu-delete").click(event => EnvironmentSheetHelper.onDeleteMilieu(sheet, event));
html.find("div.environnement-milieu select.environnement-rarete").change(event => EnvironmentSheetHelper.onChange(sheet, event, html.find("div.environnement-milieu select.environnement-rarete").change(event => EnvironmentSheetHelper.onChange(sheet, event,
(updated) => { updated => EnvironmentSheetHelper.$changeRarete(event, updated)));
const name = $(event.currentTarget).val();
const rarete = Environnement.getRarete(name);
updated.rarete = rarete.name;
updated.frequence = Math.min(
Math.max(rarete.min, updated.frequence ?? rarete.frequence),
rarete.max);
}));
html.find("div.environnement-milieu input[name='environnement-frequence']").change(event => EnvironmentSheetHelper.onChange(sheet, event, html.find("div.environnement-milieu input[name='environnement-frequence']").change(event => EnvironmentSheetHelper.onChange(sheet, event,
(updated) => { updated => EnvironmentSheetHelper.$changeFrequence(updated, event)));
updated.frequence = Number($(event.currentTarget).val()) }
}));
static $changeFrequence(updated, event) {
updated.frequence = Number($(event.currentTarget).val());
}
static $changeRarete(event, updated) {
const name = $(event.currentTarget).val();
const rarete = Environnement.getRarete(name);
updated.rarete = rarete.name;
updated.frequence = Math.min(
Math.max(rarete.min, updated.frequence ?? rarete.frequence),
rarete.max);
} }
static async onAddMilieu(html, sheet, event) { static async onAddMilieu(html, sheet, event) {
@ -187,7 +196,7 @@ export class EnvironmentSheetHelper {
static async onDeleteMilieu(sheet, event) { static async onDeleteMilieu(sheet, event) {
const milieu = EnvironmentSheetHelper.$getEventMilieu(event); const milieu = EnvironmentSheetHelper.$getEventMilieu(event);
if (milieu) { if (milieu != undefined) {
const newList = sheet.item.system.environnement.filter(it => it.milieu != milieu) const newList = sheet.item.system.environnement.filter(it => it.milieu != milieu)
.sort(Misc.ascending(it => it.milieu)); .sort(Misc.ascending(it => it.milieu));
await sheet.item.update({ 'system.environnement': newList }); await sheet.item.update({ 'system.environnement': newList });

View File

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

View File

@ -81,7 +81,6 @@ function autocomplete(input, proposals) {
currentFocus--; currentFocus--;
addActive(container); addActive(container);
} else if (e.keyCode == 13) { } else if (e.keyCode == 13) {
e.preventDefault();
if (currentFocus > -1 && container) { if (currentFocus > -1 && container) {
container[currentFocus].click(); container[currentFocus].click();
} }