Merge branch 'v1.5-fixes-et-competences' into 'v1.5'

Plusieurs fixes et améliorations de confort

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!298
This commit is contained in:
Leratier Bretonnien 2021-11-26 23:36:44 +00:00
commit a6b6a9ea2e
21 changed files with 145 additions and 81 deletions

View File

@ -108,11 +108,11 @@ export class RdDActorEntiteSheet extends ActorSheet {
this.actor.rollCompetence( compName ); this.actor.rollCompetence( compName );
}); });
html.find('#endurance-plus').click((event) => { html.find('.endurance-plus').click((event) => {
this.actor.santeIncDec("endurance", 1); this.actor.santeIncDec("endurance", 1);
this.render(true); this.render(true);
}); });
html.find('#endurance-moins').click((event) => { html.find('.endurance-moins').click((event) => {
this.actor.santeIncDec("endurance", -1); this.actor.santeIncDec("endurance", -1);
this.render(true); this.render(true);
}); });

View File

@ -78,7 +78,9 @@ export class RdDActorSheet extends ActorSheet {
formData.calc.surEncombrementMessage = (formData.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : ""; formData.calc.surEncombrementMessage = (formData.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : "";
formData.competences.forEach(item => { formData.competences.forEach(item => {
item.visible = !this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(item); item.visible = this.options.cherchercompetence
? RdDItemCompetence.nomContientTexte(item, this.options.cherchercompetence)
: ( !this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(item) );
RdDItemCompetence.levelUp(item, formData.data.compteurs.experience.value); RdDItemCompetence.levelUp(item, formData.data.compteurs.experience.value);
}); });
@ -421,6 +423,10 @@ export class RdDActorSheet extends ActorSheet {
this.options.editCaracComp = !this.options.editCaracComp; this.options.editCaracComp = !this.options.editCaracComp;
this.render(true); this.render(true);
}); });
html.find('.cherchercompetence').change(async event => {
this.options.cherchercompetence = event.currentTarget.value;
this.render(true);
});
html.find('.vue-detaillee').click(async event => { html.find('.vue-detaillee').click(async event => {
console.log("CONTROLS", this.options.vueDetaillee) console.log("CONTROLS", this.options.vueDetaillee)
this.options.vueDetaillee = !this.options.vueDetaillee; this.options.vueDetaillee = !this.options.vueDetaillee;
@ -468,10 +474,10 @@ export class RdDActorSheet extends ActorSheet {
this.actor.jetEthylisme(); this.actor.jetEthylisme();
}); });
html.find('#jet-vie').click(async event => { html.find('.jet-vie').click(async event => {
this.actor.jetVie(); this.actor.jetVie();
}); });
html.find('#jet-endurance').click(async event => { html.find('.jet-endurance').click(async event => {
this.actor.jetEndurance(); this.actor.jetEndurance();
}); });
@ -484,28 +490,28 @@ export class RdDActorSheet extends ActorSheet {
this.actor.monnaieIncDec(li.data("item-id"), -1); this.actor.monnaieIncDec(li.data("item-id"), -1);
}); });
html.find('#vie-plus').click(async event => { html.find('.vie-plus').click(async event => {
this.actor.santeIncDec("vie", 1); this.actor.santeIncDec("vie", 1);
}); });
html.find('#vie-moins').click(async event => { html.find('.vie-moins').click(async event => {
this.actor.santeIncDec("vie", -1); this.actor.santeIncDec("vie", -1);
}); });
html.find('#endurance-plus').click(async event => { html.find('.endurance-plus').click(async event => {
this.actor.santeIncDec("endurance", 1); this.actor.santeIncDec("endurance", 1);
}); });
html.find('#endurance-moins').click(async event => { html.find('.endurance-moins').click(async event => {
this.actor.santeIncDec("endurance", -1); this.actor.santeIncDec("endurance", -1);
}); });
html.find('#ptreve-actuel-plus').click(async event => { html.find('.ptreve-actuel-plus').click(async event => {
this.actor.reveActuelIncDec(1); this.actor.reveActuelIncDec(1);
}); });
html.find('#ptreve-actuel-moins').click(async event => { html.find('.ptreve-actuel-moins').click(async event => {
this.actor.reveActuelIncDec(-1); this.actor.reveActuelIncDec(-1);
}); });
html.find('#fatigue-plus').click(async event => { html.find('.fatigue-plus').click(async event => {
this.actor.santeIncDec("fatigue", 1); this.actor.santeIncDec("fatigue", 1);
}); });
html.find('#fatigue-moins').click(async event => { html.find('.fatigue-moins').click(async event => {
this.actor.santeIncDec("fatigue", -1); this.actor.santeIncDec("fatigue", -1);
}); });
} }

View File

@ -63,7 +63,7 @@ export class RdDActor extends Actor {
} }
static remoteActorCall(data) { static remoteActorCall(data) {
if (Misc.isElectedUser()) { if (Misc.isUniqueConnectedGM()) {
RdDActor.onRemoteActorCall(data); RdDActor.onRemoteActorCall(data);
} }
else { else {
@ -72,7 +72,7 @@ export class RdDActor extends Actor {
} }
static onRemoteActorCall(data) { static onRemoteActorCall(data) {
if (Misc.isElectedUser()) { // Seul le joueur choisi effectue l'appel if (Misc.isUniqueConnectedGM()) { // Seul le joueur choisi effectue l'appel
const actor = game.actors.get(data?.actorId); const actor = game.actors.get(data?.actorId);
if (!actor) { if (!actor) {
console.info("RdDActor.onRemoteActorCall: Pas d'Actor disponible ", data); console.info("RdDActor.onRemoteActorCall: Pas d'Actor disponible ", data);
@ -3685,7 +3685,7 @@ export class RdDActor extends Actor {
ui.notifications.info("Inutile de se vendre à soi-même"); ui.notifications.info("Inutile de se vendre à soi-même");
return; return;
} }
if (!Misc.isElectedUser()) { if (!Misc.isUniqueConnectedGM()) {
RdDActor.remoteActorCall({actorId: achat.vendeurId ?? achat.acheteurId, method: 'achatVente', args: [achat]}); RdDActor.remoteActorCall({actorId: achat.vendeurId ?? achat.acheteurId, method: 'achatVente', args: [achat]});
return; return;
} }
@ -4172,7 +4172,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async onCreateOwnedDraconique(item, options, id) { async onCreateOwnedDraconique(item, options, id) {
if (Misc.isElectedUser()) { if (Misc.isUniqueConnectedGM()) {
let draconique = Draconique.all().find(it => it.match(item)); let draconique = Draconique.all().find(it => it.match(item));
if (draconique) { if (draconique) {
draconique.onActorCreateOwned(this, item) draconique.onActorCreateOwned(this, item)
@ -4183,7 +4183,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async onDeleteOwnedDraconique(item, options, id) { async onDeleteOwnedDraconique(item, options, id) {
if (Misc.isElectedUser()) { if (Misc.isUniqueConnectedGM()) {
let draconique = Draconique.all().find(it => it.match(item)); let draconique = Draconique.all().find(it => it.match(item));
if (draconique) { if (draconique) {
draconique.onActorDeleteOwned(this, item) draconique.onActorDeleteOwned(this, item)
@ -4193,7 +4193,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async onDeleteOwnedCaseTmr(item, options, id) { async onDeleteOwnedCaseTmr(item, options, id) {
if (Misc.isElectedUser()) { if (Misc.isUniqueConnectedGM()) {
let draconique = Draconique.all().find(it => it.isCase(item)); let draconique = Draconique.all().find(it => it.isCase(item));
if (draconique) { if (draconique) {
draconique.onActorDeleteCaseTmr(this, Misc.data(item)) draconique.onActorDeleteCaseTmr(this, Misc.data(item))

View File

@ -41,7 +41,7 @@ export class ChatUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static onRemoveMessages(data) { static onRemoveMessages(data) {
if (Misc.isElectedUser()) { if (Misc.isUniqueConnectedGM()) {
if (data.part) { if (data.part) {
const toDelete = game.messages.filter(it => it.data.content.includes(data.part)); const toDelete = game.messages.filter(it => it.data.content.includes(data.part));
toDelete.forEach(it => it.delete()); toDelete.forEach(it => it.delete());
@ -53,7 +53,7 @@ export class ChatUtility {
} }
static onRemoveMessages(data) { static onRemoveMessages(data) {
if (Misc.isElectedUser()) { if (Misc.isUniqueConnectedGM()) {
if (data.part) { if (data.part) {
const toDelete = game.messages.filter(it => it.data.content.includes(data.part)); const toDelete = game.messages.filter(it => it.data.content.includes(data.part));
toDelete.forEach(it => it.delete()); toDelete.forEach(it => it.delete());
@ -66,7 +66,7 @@ export class ChatUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static removeMessages(data) { static removeMessages(data) {
if (Misc.isElectedUser()){ if (Misc.isUniqueConnectedGM()){
ChatUtility.onRemoveMessages(data); ChatUtility.onRemoveMessages(data);
} }
else { else {

View File

@ -46,9 +46,9 @@ export class DialogStress extends Dialog {
validerStress() { validerStress() {
this.dialogData.motif = $("[name='motif']").val(); this.dialogData.motif = $("form.rdddialogstress input[name='motif']").val();
this.dialogData.stress = $("[name='stress']").val(); this.dialogData.stress = $("form.rdddialogstress input[name='stress']").val();
this.dialogData.immediat = $("[name='immediat']").prop("checked");; this.dialogData.immediat = $("form.rdddialogstress input[name='immediat']").prop("checked");;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -201,6 +201,10 @@ export class RdDItemCompetence extends Item {
return Number(itemData.data.niveau) != RdDItemCompetence.getNiveauBase(itemData.data.categorie); return Number(itemData.data.niveau) != RdDItemCompetence.getNiveauBase(itemData.data.categorie);
} }
static nomContientTexte(itemData, texte) {
return Grammar.toLowerCaseNoAccent(itemData.name).includes(Grammar.toLowerCaseNoAccent(texte))
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static isNiveauBase(itemData) { static isNiveauBase(itemData) {
return Number(itemData.data.niveau) == RdDItemCompetence.getNiveauBase(itemData.data.categorie); return Number(itemData.data.niveau) == RdDItemCompetence.getNiveauBase(itemData.data.categorie);

View File

@ -101,6 +101,11 @@ export class Misc {
return [...new Set(array)]; return [...new Set(array)];
} }
static join(params, separator = '') {
return params.reduce((a, b) => a + separator + b);
}
static data(it) { static data(it) {
if (it instanceof Actor || it instanceof Item || it instanceof Combatant) { if (it instanceof Actor || it instanceof Item || it instanceof Combatant) {
return it.data; return it.data;
@ -126,10 +131,22 @@ export class Misc {
if (ownerId && game.user.id == ownerId) { if (ownerId && game.user.id == ownerId) {
return ownerId; return ownerId;
} }
return (game.user.isGM ? game.user.id : game.users.entities.find(u => u.isGM && u.active)?.id) ?? game.user.id; return Misc.firstConnectedGM()?.id ?? game.user.id;
} }
static isElectedUser() {
return game.user.id == Misc.connectedGMOrUser(); static getActiveUser(id) {
return game.users.entities.find(u => u.id == id && u.active);
}
static firstConnectedGM() {
return game.users.entities.sort(Misc.ascending(u => u.id)).find(u => u.isGM && u.active);
}
/**
* @returns true pour un seul utilisateur: le premier GM connecté par ordre d'id
*/
static isUniqueConnectedGM() {
return game.user.id == Misc.firstConnectedGM()?.id;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -161,7 +178,7 @@ export class Misc {
let single = subset.find(it => Grammar.toLowerCaseNoAccent(options.mapper(it)) == Grammar.toLowerCaseNoAccent(value)); let single = subset.find(it => Grammar.toLowerCaseNoAccent(options.mapper(it)) == Grammar.toLowerCaseNoAccent(value));
if (!single) { if (!single) {
single = subset[0]; single = subset[0];
const choices = subset.map(it => options.mapper(it)).reduce((a, b) => `${a}<br>${b}`); const choices = Misc.join(subset.map(it => options.mapper(it)), '<br>');
options.info(`Plusieurs choix de ${options.description}s possibles:<br>${choices}<br>Le premier sera choisi: ${mapToValue(single)}`); options.info(`Plusieurs choix de ${options.description}s possibles:<br>${choices}<br>Le premier sera choisi: ${mapToValue(single)}`);
} }
return single; return single;

View File

@ -68,9 +68,10 @@ export class RdDAstrologieJoueur extends Dialog {
etat: this.dataNombreAstral.etat, etat: this.dataNombreAstral.etat,
astrologie: this.dataNombreAstral.astrologie, astrologie: this.dataNombreAstral.astrologie,
conditions: $("#diffConditions").val(), conditions: $("#diffConditions").val(),
date: $("#joursAstrologie").val() date: $("#joursAstrologie").val(),
userId: game.user.id
} }
if (game.user.isGM) { if (Misc.isUniqueConnectedGM()) {
game.system.rdd.calendrier.requestNombreAstral(data); game.system.rdd.calendrier.requestNombreAstral(data);
} else { } else {
game.socket.emit("system.foundryvtt-reve-de-dragon", { game.socket.emit("system.foundryvtt-reve-de-dragon", {
@ -83,7 +84,6 @@ export class RdDAstrologieJoueur extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
quitDialog() { quitDialog() {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -82,12 +82,9 @@ export class RdDCalendrier extends Application {
this.calendrier.annee = this.calendrier.annee ?? Math.floor((this.calendrier.moisRdD ?? 0) / RDD_MOIS_PAR_AN); this.calendrier.annee = this.calendrier.annee ?? Math.floor((this.calendrier.moisRdD ?? 0) / RDD_MOIS_PAR_AN);
this.calendrier.moisRdD = (this.calendrier.moisRdD ?? 0) % RDD_MOIS_PAR_AN; this.calendrier.moisRdD = (this.calendrier.moisRdD ?? 0) % RDD_MOIS_PAR_AN;
if (game.user.isGM) { // Uniquement si GM if (Misc.isUniqueConnectedGM()) { // Uniquement si GM
game.settings.set(SYSTEM_RDD, "calendrier", this.calendrier); game.settings.set(SYSTEM_RDD, "calendrier", this.calendrier);
}
// nombre astral
if (game.user.isGM) {
this.listeNombreAstral = this.getListeNombreAstral(); this.listeNombreAstral = this.getListeNombreAstral();
this.rebuildListeNombreAstral(false); // Ensure always up-to-date this.rebuildListeNombreAstral(false); // Ensure always up-to-date
} }
@ -189,7 +186,7 @@ export class RdDCalendrier extends Application {
/* -------------------------------------------- */ /* -------------------------------------------- */
async rebuildListeNombreAstral(showDice = true) { async rebuildListeNombreAstral(showDice = true) {
if (game.user.isGM) { if (Misc.isUniqueConnectedGM()) {
console.log("rebuildListeNombreAstral", showDice); console.log("rebuildListeNombreAstral", showDice);
let jourCourant = this.getCurrentDayIndex(); let jourCourant = this.getCurrentDayIndex();
let newList = []; let newList = [];
@ -320,7 +317,7 @@ export class RdDCalendrier extends Application {
/* -------------------------------------------- */ /* -------------------------------------------- */
async requestNombreAstral(request) { async requestNombreAstral(request) {
if (game.user.isGM) { // Only GM if (Misc.isUniqueConnectedGM()) { // Only once
console.log(request); console.log(request);
let jourDiff = this.getLectureAstrologieDifficulte(request.date); let jourDiff = this.getLectureAstrologieDifficulte(request.date);
let niveau = Number(request.astrologie.data.niveau) + Number(request.conditions) + Number(jourDiff) + Number(request.etat); let niveau = Number(request.astrologie.data.niveau) + Number(request.conditions) + Number(jourDiff) + Number(request.etat);
@ -343,7 +340,7 @@ export class RdDCalendrier extends Application {
game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral); game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral);
} }
request.nbAstral = nbAstral; request.nbAstral = nbAstral;
if (game.user.isGM) { if (Misc.getActiveUser(request.userId)?.isGM) {
RdDUtility.responseNombreAstral(request); RdDUtility.responseNombreAstral(request);
} else { } else {
game.socket.emit("system.foundryvtt-reve-de-dragon", { game.socket.emit("system.foundryvtt-reve-de-dragon", {

View File

@ -227,7 +227,7 @@ export class RdDCombatManager extends Combat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static processPremierRoundInit() { static processPremierRoundInit() {
// Check if we have the whole init ! // Check if we have the whole init !
if (game.user.isGM && game.combat.current.round == 1) { if (Misc.isUniqueConnectedGM() && game.combat.current.round == 1) {
let initMissing = game.combat.data.combatants.find(it => !it.initiative); let initMissing = game.combat.data.combatants.find(it => !it.initiative);
if (!initMissing) { // Premier round ! if (!initMissing) { // Premier round !
for (let combatant of game.combat.data.combatants) { for (let combatant of game.combat.data.combatants) {
@ -422,7 +422,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static combatNouveauTour(combat) { static combatNouveauTour(combat) {
if (Misc.isElectedUser()) { if (Misc.isUniqueSingleUser()) {
let turn = combat.turns.find(t => t.token?.id == combat.current.tokenId); let turn = combat.turns.find(t => t.token?.id == combat.current.tokenId);
if (turn?.actor) { if (turn?.actor) {
RdDCombat.displayActorCombatStatus(combat, turn.actor); RdDCombat.displayActorCombatStatus(combat, turn.actor);
@ -540,7 +540,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static onMsgEncaisser(data) { static onMsgEncaisser(data) {
if (Misc.isElectedUser()) { if (Misc.isUniqueSingleUser()) {
let attackerRoll = RdDCombat._getAttaque(data.attackerId); // Retrieve the rolldata from the store let attackerRoll = RdDCombat._getAttaque(data.attackerId); // Retrieve the rolldata from the store
let attacker = data.attackerId ? game.actors.get(data.attackerId) : null; let attacker = data.attackerId ? game.actors.get(data.attackerId) : null;
let defender = canvas.tokens.get(data.defenderTokenId).actor; let defender = canvas.tokens.get(data.defenderTokenId).actor;
@ -555,7 +555,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static onMsgDefense(msg) { static onMsgDefense(msg) {
let defenderToken = canvas.tokens.get(msg.defenderTokenId); let defenderToken = canvas.tokens.get(msg.defenderTokenId);
if (defenderToken && Misc.isElectedUser()) { if (defenderToken && Misc.isUniqueSingleUser()) {
const rddCombat = RdDCombat.createForAttackerAndDefender(msg.attackerId, msg.defenderTokenId); const rddCombat = RdDCombat.createForAttackerAndDefender(msg.attackerId, msg.defenderTokenId);
if (rddCombat) { if (rddCombat) {
const defenderRoll = msg.defenderRoll; const defenderRoll = msg.defenderRoll;
@ -913,7 +913,7 @@ export class RdDCombat {
dmg: attackerRoll.dmg, dmg: attackerRoll.dmg,
}; };
if (!Misc.isElectedUser()) { if (!Misc.isUniqueSingleUser()) {
this._socketSendMessageDefense(paramChatDefense, defenderRoll); this._socketSendMessageDefense(paramChatDefense, defenderRoll);
} }
else { else {
@ -1286,7 +1286,7 @@ export class RdDCombat {
this._onEchecTotal(defenderRoll); this._onEchecTotal(defenderRoll);
} }
if (Misc.isElectedUser()) { if (Misc.isUniqueSingleUser()) {
attackerRoll.attackerId = this.attackerId; attackerRoll.attackerId = this.attackerId;
attackerRoll.defenderTokenId = defenderTokenId; attackerRoll.defenderTokenId = defenderTokenId;

View File

@ -2,6 +2,7 @@
import { DialogCreateSigneDraconique } from "./dialog-create-signedraconique.js"; import { DialogCreateSigneDraconique } from "./dialog-create-signedraconique.js";
import { DialogStress } from "./dialog-stress.js"; import { DialogStress } from "./dialog-stress.js";
import { Grammar } from "./grammar.js";
import { RdDItemCompetence } from "./item-competence.js"; import { RdDItemCompetence } from "./item-competence.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDCarac } from "./rdd-carac.js"; import { RdDCarac } from "./rdd-carac.js";
@ -40,6 +41,11 @@ export class RdDCommands {
descr: `Tire une case aléatoire des Terres médianes descr: `Tire une case aléatoire des Terres médianes
<br><strong>/tmra forêt</strong> détermine une 'forêt' aléatoire <br><strong>/tmra forêt</strong> détermine une 'forêt' aléatoire
<br><strong>/tmra</strong> détermine une case aléatoire dans toutes les TMR` }); <br><strong>/tmra</strong> détermine une case aléatoire dans toutes les TMR` });
rddCommands.registerCommand({
path: ["/tmr"], func: (content, msg, params) => rddCommands.findTMR(msg, params),
descr: `Cherche où se trouve une case des Terres médianes
<br><strong>/tmr? sordide</strong> indique que la cité Sordide est en D13
<br><strong>/tmr? foret</strong> donne la liste des TMR dont le nom contient "foret" (donc, toutes les forêts)` });
rddCommands.registerCommand({ rddCommands.registerCommand({
path: ["/tmrr"], func: (content, msg, params) => rddCommands.getRencontreTMR(params), path: ["/tmrr"], func: (content, msg, params) => rddCommands.getRencontreTMR(params),
descr: `Détermine une rencontre dans un type de case descr: `Détermine une rencontre dans un type de case
@ -80,7 +86,7 @@ export class RdDCommands {
<br><strong>/payer 10d</strong> permet d'envoyer un message pour payer 10 deniers` <br><strong>/payer 10d</strong> permet d'envoyer un message pour payer 10 deniers`
}); });
rddCommands.registerCommand({ rddCommands.registerCommand({
path: ["/astro"], func: (content, msg, params) => RdDUtility.afficherHeuresChanceMalchance(RdDCommands.toParamString(params)), path: ["/astro"], func: (content, msg, params) => RdDUtility.afficherHeuresChanceMalchance(Misc.join(params, ' ')),
descr: `Affiche les heures de chance et de malchance selon l'heure de naissance donnée en argument. Exemples pour l'heure de la Lyre: descr: `Affiche les heures de chance et de malchance selon l'heure de naissance donnée en argument. Exemples pour l'heure de la Lyre:
<br><strong>/astro 7</strong> <br><strong>/astro 7</strong>
<br><strong>/astro Lyre</strong> <br><strong>/astro Lyre</strong>
@ -113,10 +119,6 @@ export class RdDCommands {
this.commandsTable = {}; this.commandsTable = {};
} }
static toParamString(params) {
return params.length == 1 ? params[0] : params.reduce((a, b) => `${a} ${b}`, '');
}
/* -------------------------------------------- */ /* -------------------------------------------- */
registerCommand(command) { registerCommand(command) {
this._addCommand(this.commandsTable, command.path, '', command); this._addCommand(this.commandsTable, command.path, '', command);
@ -160,7 +162,7 @@ export class RdDCommands {
if (rollMode === "blindroll") msg["blind"] = true; if (rollMode === "blindroll") msg["blind"] = true;
msg["type"] = 0; msg["type"] = 0;
let command = commandLine[0]; let command = commandLine[0].toLowerCase();
let params = commandLine.slice(1); let params = commandLine.slice(1);
return this.process(command, params, content, msg); return this.process(command, params, content, msg);
@ -251,7 +253,7 @@ export class RdDCommands {
RdDRollResolutionTable.open(); RdDRollResolutionTable.open();
} }
else { else {
let flatParams = params.reduce((a, b) => `${a} ${b}`); let flatParams = Misc.join(params, ' ');
const numericParams = flatParams.match(rddRollNumeric); const numericParams = flatParams.match(rddRollNumeric);
if (numericParams) { if (numericParams) {
const carac = Misc.toInt(numericParams[1]); const carac = Misc.toInt(numericParams[1]);
@ -272,7 +274,7 @@ export class RdDCommands {
diff = 0; diff = 0;
} }
const caracName = params[0]; const caracName = params[0];
const compName = length > 1 ? params.slice(1, length).reduce((a, b) => `${a} ${b}`) : undefined; const compName = length > 1 ? Misc.join(params.slice(1, length), ' ') : undefined;
for (let actor of actors) { for (let actor of actors) {
await actor.rollCaracCompetence(caracName, compName, diff); await actor.rollCaracCompetence(caracName, compName, diff);
} }
@ -314,6 +316,14 @@ export class RdDCommands {
} }
} }
async findTMR(msg, params) {
const search = Misc.join(params, ' ');
const found = TMRUtility.findTMR(search);
if (found?.length > 0) {
return RdDCommands._chatAnswer(msg, `Les TMRs correspondant à '${search}' sont:` + Misc.join(found.map(it => `<br>${it.coord}: ${it.label}`)));
}
return RdDCommands._chatAnswer(msg, 'Aucune TMR correspondant à ' + search);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
getCoutXpComp(msg, params) { getCoutXpComp(msg, params) {
@ -359,7 +369,7 @@ export class RdDCommands {
ui.notifications.warn("Seul le MJ est autorisé à utiliser la commande /stress"); ui.notifications.warn("Seul le MJ est autorisé à utiliser la commande /stress");
return false; return false;
} }
if (params.length == 0) { if (params.length < 3) {
DialogStress.distribuerStress(); DialogStress.distribuerStress();
} }
else { else {
@ -369,8 +379,8 @@ export class RdDCommands {
return; return;
} }
let motif = params[1]; let motif = params.slice(1, params.length - 2);
let name = params[2]; let name = params[params.length - 1];
if (name == undefined) { if (name == undefined) {
for (let actor of game.actors) { for (let actor of game.actors) {
actor.distribuerStress('stress', stress, motif); actor.distribuerStress('stress', stress, motif);

View File

@ -34,6 +34,7 @@ import { RdDItem } from "./item.js";
import { RdDDice } from "./rdd-dice.js"; import { RdDDice } from "./rdd-dice.js";
import { RdDPossession } from "./rdd-possession.js"; import { RdDPossession } from "./rdd-possession.js";
import { RdDSigneDraconiqueItemSheet } from "./item-signedraconique-sheet.js"; import { RdDSigneDraconiqueItemSheet } from "./item-signedraconique-sheet.js";
import { Misc } from "./misc.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Foundry VTT Initialization */ /* Foundry VTT Initialization */
@ -254,7 +255,7 @@ Hooks.once("ready", async function () {
user: game.user.id user: game.user.id
}); });
} }
if (game.user.isGM) { if (Misc.isUniqueConnectedGM()) {
messageDeBienvenue(); messageDeBienvenue();
} }
}); });
@ -299,7 +300,7 @@ Hooks.once('diceSoNiceReady', (dice3d) => RdDDice.diceSoNiceReady(dice3d));
Hooks.on("chatMessage", (html, content, msg) => { Hooks.on("chatMessage", (html, content, msg) => {
if (content[0] == '/') { if (content[0] == '/') {
let regExp = /(\S+)/g; let regExp = /(\S+)/g;
let commands = content.toLowerCase().match(regExp); let commands = content.match(regExp);
if (game.system.rdd.commands.processChatCommand(commands, content, msg)) { if (game.system.rdd.commands.processChatCommand(commands, content, msg)) {
return false; return false;
} }

View File

@ -347,7 +347,7 @@ export class TMRUtility {
return Grammar.articleDetermine(tmr.type) + ' ' + tmr.label; return Grammar.articleDetermine(tmr.type) + ' ' + tmr.label;
} }
static typeTmrName(type){ static typeTmrName(type) {
return Misc.upperFirst(TMRType[Grammar.toLowerCaseNoAccent(type)].name); return Misc.upperFirst(TMRType[Grammar.toLowerCaseNoAccent(type)].name);
} }
static listSelectedTMR(typesTMR) { static listSelectedTMR(typesTMR) {
@ -424,6 +424,11 @@ export class TMRUtility {
return Object.values(TMRMapping).filter(filter); return Object.values(TMRMapping).filter(filter);
} }
static findTMR(search) {
const labelSearch = Grammar.toLowerCaseNoAccent(search)
return TMRUtility.filterTMR(it => Grammar.toLowerCaseNoAccent(it.label).match(labelSearch) || it.coord == search);
}
static filterTMRCoord(filter) { static filterTMRCoord(filter) {
return TMRUtility.filterTMR(filter).map(it => it.coord); return TMRUtility.filterTMR(filter).map(it => it.coord);
} }

View File

@ -55,12 +55,6 @@ export class PixiTMR {
carteTmr.interactive = true; carteTmr.interactive = true;
carteTmr.buttonMode = true; carteTmr.buttonMode = true;
carteTmr.tmrObject = this; carteTmr.tmrObject = this;
// atténue les couleurs des TMRs
const tmrColorFilter = new PIXI.filters.ColorMatrixFilter();
tmrColorFilter.contrast(1);
tmrColorFilter.brightness(0.2);
tmrColorFilter.saturate(-0.5);
carteTmr.filters = [tmrColorFilter];
if (!this.tmrObject.viewOnly) { if (!this.tmrObject.viewOnly) {
carteTmr.on('pointerdown', event => this.onClickBackground(event)); carteTmr.on('pointerdown', event => this.onClickBackground(event));
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 MiB

After

Width:  |  Height:  |  Size: 313 KiB

View File

@ -644,7 +644,7 @@ section.sheet-body:after {
max-width: 90%; max-width: 90%;
} }
#vie-plus, #vie-moins, #endurance-plus, #endurance-moins, #fatigue-plus, #fatigue-moins, #ptreve-actuel-plus, #ptreve-actuel-moins, .monnaie-plus, .monnaie-moins { .plus-moins {
display: inline-block; display: inline-block;
width: 1.25rem; width: 1.25rem;
background: rgba(30, 25, 20, 1); background: rgba(30, 25, 20, 1);

View File

@ -2,6 +2,25 @@
<span class="competence-title">{{categorie}}</span> <span class="competence-title">{{categorie}}</span>
</header> </header>
<ul class="item-list alterne-list competence-list"> <ul class="item-list alterne-list competence-list">
{{#if @root.options.vueDetaillee}}
<li class="item flexrow list-item ">
<span class="competence-label"></span>
<span class="competence-value" >Niv.</span>
<span class="competence-xp">xp</span>
{{#if (eq categorie 'Draconic')}}
<span class="competence-xp-sort">sort</span>
{{/if}}
<div class="item-controls">
<i class="far fa-arrow-alt-circle-up"></i>
<span class="competence-archetype">Arch</span>
<i class="far fa-edit"></i>
{{#if @root.options.isGM}}
<i class="far fa-trash"></i>
{{/if}}
</div>
</li>
{{/if}}
{{#each competences as |comp key|}} {{#each competences as |comp key|}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html" comp}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html" comp}}
{{/each}} {{/each}}

View File

@ -28,6 +28,8 @@
title="Dépenser {{data.stressXpMax}} points de stress {{#if data.isStressLevelUp}} pour augmenter d'un niveau {{/if}}"> title="Dépenser {{data.stressXpMax}} points de stress {{#if data.isStressLevelUp}} pour augmenter d'un niveau {{/if}}">
<i class="fas fa-arrow-alt-circle-up allouer-stress{{#if data.isStressLevelUp}}-level-up{{/if}}"></i> <i class="fas fa-arrow-alt-circle-up allouer-stress{{#if data.isStressLevelUp}}-level-up{{/if}}"></i>
</a> </a>
{{else}}
<i class="far fa-circle"></i>
{{/if}} {{/if}}
<input class="competence-archetype niveau-archetype" type="text" compname="{{name}}" name="comp-archetype-{{name}}" <input class="competence-archetype niveau-archetype" type="text" compname="{{name}}" name="comp-archetype-{{name}}"
value="{{numberFormat data.niveau_archetype decimals=0 sign=true}}" data-dtype="number" value="{{numberFormat data.niveau_archetype decimals=0 sign=true}}" data-dtype="number"

View File

@ -5,7 +5,10 @@
<img class="sheet-competence-img" src="{{piece.img}}" title="{{piece.name}}"/> <img class="sheet-competence-img" src="{{piece.img}}" title="{{piece.name}}"/>
<span class="competence-title competence-label">{{piece.name}}</span> <span class="competence-title competence-label">{{piece.name}}</span>
<span class="competence-title competence-label">{{piece.data.quantite}}</span> <span class="competence-title competence-label">{{piece.data.quantite}}</span>
<span class="competence-title"><a class="monnaie-plus">+</a><a class="monnaie-moins">-</a></span> <span class="competence-title">
<a class="monnaie-plus plus-moins">+</a>
<a class="monnaie-moins plus-moins">-</a>
</span>
<div class="item-controls flex-shrink"> <div class="item-controls flex-shrink">
<a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a> <a class="item-control item-edit" title="Editer"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a> <a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>

View File

@ -11,39 +11,39 @@
<ul class="flex-group-center flex-compteurs"> <ul class="flex-group-center flex-compteurs">
<li> <li>
<label class="ctn-vie"> <label class="ctn-vie">
<a id="jet-vie">Vie</a> <a class="jet-vie">Vie</a>
<a id="vie-moins">-</a> <a class="vie-moins plus-moins">-</a>
<input class="resource-content" type="text" name="data.sante.vie.value" value="{{data.sante.vie.value}}" data-dtype="Number"/> <input class="resource-content" type="text" name="data.sante.vie.value" value="{{data.sante.vie.value}}" data-dtype="Number"/>
<span>/ {{data.sante.vie.max}}</span> <span>/ {{data.sante.vie.max}}</span>
<a id="vie-plus">+</a> <a class="vie-plus plus-moins">+</a>
</label> </label>
</li> </li>
<li> <li>
<label class="ctn-endu"> <label class="ctn-endu">
<a id="jet-endurance">Endurance</a> <a class="jet-endurance">Endurance</a>
<a id="endurance-moins">-</a> <a class="endurance-moins plus-moins">-</a>
<input class="resource-content" type="text" name="data.sante.endurance.value" value="{{data.sante.endurance.value}}" data-dtype="Number"/> <input class="resource-content" type="text" name="data.sante.endurance.value" value="{{data.sante.endurance.value}}" data-dtype="Number"/>
<span>/ {{data.sante.endurance.max}}</span> <span>/ {{data.sante.endurance.max}}</span>
<a id="endurance-plus">+</a> <a class="endurance-plus plus-moins">+</a>
</label> </label>
</li> </li>
<li> <li>
<label class="appliquerFatigue ctn-fatigue tooltip"> <label class="appliquerFatigue ctn-fatigue tooltip">
<span class="tooltiptext ttt-fatigue">{{{calc.fatigue.html}}}</span> <span class="tooltiptext ttt-fatigue">{{{calc.fatigue.html}}}</span>
Fatigue Fatigue
<a id="fatigue-moins">-</a> <a class="fatigue-moins plus-moins">-</a>
<input class="resource-content" id="fatigue-value" type="text" name="data.sante.fatigue.value" value="{{data.sante.fatigue.value}}" data-dtype="Number" /> <input class="resource-content" id="fatigue-value" type="text" name="data.sante.fatigue.value" value="{{data.sante.fatigue.value}}" data-dtype="Number" />
<span>/ {{data.sante.fatigue.max}}</span> <span>/ {{data.sante.fatigue.max}}</span>
<a id="fatigue-plus">+</a> <a class="fatigue-plus plus-moins">+</a>
</label> </label>
</li> </li>
<li> <li>
<label class="ctn-reve"> <label class="ctn-reve">
<span class="ptreve-actuel"><a>Rêve</a></span> <span class="ptreve-actuel"><a>Rêve</a></span>
<a id="ptreve-actuel-moins">-</a> <a class="ptreve-actuel-moins plus-moins">-</a>
<input class="resource-content" id="pointsreve-value" type="text" name="data.reve.reve.value" value="{{data.reve.reve.value}}" data-dtype="Number" /> <input class="resource-content" id="pointsreve-value" type="text" name="data.reve.reve.value" value="{{data.reve.reve.value}}" data-dtype="Number" />
<span>/ {{data.reve.seuil.value}}</span> <span>/ {{data.reve.seuil.value}}</span>
<a id="ptreve-actuel-plus">+</a> <a class="ptreve-actuel-plus plus-moins">+</a>
</label> </label>
</li> </li>
</ul> </ul>
@ -208,10 +208,16 @@
{{!-- Compétences Tab --}} {{!-- Compétences Tab --}}
<div class="tab competences" data-group="primary" data-tab="competences"> <div class="tab competences" data-group="primary" data-tab="competences">
<div class="flexrow"> <div class="grid grid-4col">
<span><a class="lock-unlock-sheet"><img class="small-button-container" <span><a class="lock-unlock-sheet"><img class="small-button-container"
src="systems/foundryvtt-reve-de-dragon/icons/{{#if options.editCaracComp}}unlocked.svg{{else}}locked.svg{{/if}}" alt="blocker/débloquer" src="systems/foundryvtt-reve-de-dragon/icons/{{#if options.editCaracComp}}unlocked.svg{{else}}locked.svg{{/if}}" alt="blocker/débloquer">
>{{#if options.editCaracComp}}Verrouiller{{else}}Déverrouiller{{/if}}</a></span> {{#if options.editCaracComp}}Verrouiller{{else}}Déverrouiller{{/if}}</a></span>
<span class="flexrow">
<i class="fas fa-search"></i>
<input class="cherchercompetence" type="text" value="{{options.cherchercompetence}}" name="cherchercompetence"
size="8" data-dtype="String" placeholder="chercher"/>
<span></span>
</span>
<span><a class="show-hide-competences"><img class="small-button-container" <span><a class="show-hide-competences"><img class="small-button-container"
src="systems/foundryvtt-reve-de-dragon/icons/{{#if options.showCompNiveauBase}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer tout"> src="systems/foundryvtt-reve-de-dragon/icons/{{#if options.showCompNiveauBase}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer tout">
{{#if options.showCompNiveauBase}}Montrer tout{{else}}Filtrer{{/if}}</a> {{#if options.showCompNiveauBase}}Montrer tout{{else}}Filtrer{{/if}}</a>

View File

@ -1,4 +1,4 @@
<form class="rdddialog"> <form class="rdddialogstress">
<div class="flexcol"> <div class="flexcol">
<div class="form-group"> <div class="form-group">
<label for="motif">Motif</label> <label for="motif">Motif</label>