Compare commits

..

2 Commits

Author SHA1 Message Date
da1719a336 Start SheetV2 & fields 2025-02-02 00:07:52 +01:00
78e30b5503 Correction message min/max de race 2025-02-02 00:06:38 +01:00
139 changed files with 3364 additions and 5176 deletions

View File

@ -1,60 +1,4 @@
# 12.0 # 12.0
## 12.0.50 - Le sommeil d'Astrobazzarh
- Le don de double rêve n'interrompt plus le sommeil toutes les heures
- la perte de fatigue à la descente des TMR est visible immédiatement
## 12.0.49 - La deuxième lame d'Astrobazzarh
- Corrections
- les défenses particulières sont correctement affichées
- les vieux boucliers (sans catégorie de parade car créés il y a longtemps) peuvent parer...
- Les attaques à distance n'ont pas de difficulté libre
## 12.0.48 - La chèvre d'Astrobazzarh
- le Bandersnatch a une protection de 10
- la consistance chèvre est maintenant possible dans les recettes
alchimiques (et toutes les consistances avec accents)
- un échec au lancement d'un sort pour le mettre en réserve brise
la concentration du haut-rêvant
- Correction: les réussites particulières fonctionnent avec les caractéristiques dérivées
## 12.0.47
- Correction sur les mise à jour en cascade -
- Correction sur le force rendering après un changement de competence
## 12.0.46 - Le double demi d'Astrobazzarh
- correction des raffraîchissement lors du sommeil qui empêchait de dormir
plusieurs heures
- Si la fatigue n'est pas utilisée, les rounds dans les TMR font perdre de l'endurance (au lieu d'en gagner)
- les TMRs se ferment correctement quand la fatigue maximale est dépassée
- le message de lancement de sort en réserve donne la description du sort
- suppression de double-messages lors de la fermeture des TMR
## 12.0.45 - Les errements d'Astrobazzarh, encore
- La difficulté des méditations n'augmente plus en cas de réussite et d'échec normal
- Renommage du Bouton pour révéler/masquer le demi-rêve
## 12.0.44 - Les errements d'Astrobazzarh, suite
- on peut de nouveau dormir et se réveiller reposé
- les possessions utilisent maintenant correctement le rêve actuel
- les sorts variables ne causent plus de soucis de voie pour le lancement de sorts
- les acteurs ayant un sort avec un coût de rêve entier ne sont plus considérés
comme pouvant avoir un rêve variable
## 12.0.42 - Les errements d'Astrobazzarh
- Correction de différentes automatisations de combat incorrectes
- Correction des jets `@roll[vue/-2]` qui tentaient de chercher une compétence -2 (à cause des armes à 1/2 mains)
## 12.0.41 - La loupe d'Astrobazzarh
- On peut de nouveau effectuer des tirages cachés
- Le stress transformé est bien diminué lorsqu'on met le stress dans une compétence
## 12.0.40 - Les mains d'Astrobazzarh
- correction des attaques particulières en combat
- correction de message sur les min/max liés aux modificateurs de races (s'applique uniquement sur la taille)
## 12.0.39 - Les mains d'Astrobazzarh ## 12.0.39 - Les mains d'Astrobazzarh
- les armes à 1 ou 2 mains fonctionnent dans les liens de jets de dés - les armes à 1 ou 2 mains fonctionnent dans les liens de jets de dés
- commande `/jet` pour poster une demande de jet de dés - commande `/jet` pour poster une demande de jet de dés

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +0,0 @@
const gulp = require('gulp');
const less = require('gulp-less');
function onError(err) {
util.log(util.colors.red.bold('[ERROR LESS]:'),util.colors.bgRed(err.message));
this.emit('end');
};
/* ----------------------------------------- */
/* Compile LESS
/* ----------------------------------------- */
function compileLESS() {
return gulp.src("less/foundryvtt-reve-de-dragon.less")
.pipe(less()).on('error',console.log.bind(console))
.pipe(gulp.dest("./css"))
}
const css = gulp.series(compileLESS);
/* ----------------------------------------- */
/* Watch Updates
/* ----------------------------------------- */
const SIMPLE_LESS = ["less/*.less"];
function watchUpdates() {
gulp.watch(SIMPLE_LESS, css);
}
/* ----------------------------------------- */
/* Export Tasks
/* ----------------------------------------- */
exports.default = gulp.series(
gulp.parallel(css),
watchUpdates
);
exports.css = css;
exports.watchUpdates = watchUpdates;

View File

@ -1,45 +0,0 @@
:root {
/* =================== 2. DEBUGGING HIGHLIGHTERS ============ */
// --debug-background-color-red: #ff000054;
// --debug-background-color-blue: #1d00ff54;
// --debug-background-color-green: #54ff0054;
// --debug-box-shadow-red: inset 0 0 2px red;
// --debug-box-shadow-blue: inset 0 0 2px blue;
// --debug-box-shadow-green: inset 0 0 2px green;
/* =================== 3. some constants ============ */
--color-controls:rgba(0, 0, 0, 0.9);
--color-controls-light:hsla(0, 0%, 20%, 0.8);
--color-controls-hover:hsla(60, 100%, 75%, 0.7);
--color-control-border-hover:rgba(255, 128, 0, 0.8);
--color-gold: rgba(191, 149, 63, 0.8);
--gradient-gold: linear-gradient(30deg, rgba(191, 149, 63, 0.3), rgba(252, 246, 186, 0.3), rgba(179, 135, 40, 0.3), rgba(251, 245, 183, 0.3), rgba(170, 119, 28, 0.3));
--gradient-silver: linear-gradient(30deg, rgba(61, 55, 93, 0.3), rgba(178, 179, 196, 0.3), rgba(59, 62, 63, 0.6), rgba(206, 204, 199, 0.3), rgba(61, 46, 49, 0.3));
--gradient-green: linear-gradient(30deg, rgba(7, 76, 0, 0.3), rgba(66, 163, 65, 0.2), rgba(184, 226, 163, 0.1), rgba(66, 163, 65, 0.2), rgba(184, 226, 163, 0.3));
--gradient-red: linear-gradient(150deg, rgba(255, 0, 0, 0.3), rgba(255, 200, 128, 0.05),rgba(255, 200, 128, 0.1), rgba(255,10,0,0.3));
--gradient-violet: linear-gradient(150deg, rgba(100, 45, 124, 0.6), rgba(216, 157, 192, 0.3), rgba(177, 157, 216, 0.5), rgba(107, 62, 121, 0.3), rgba(100, 45, 124, 0.6));
--gradient-purple-black: linear-gradient(150deg, rgba(0, 0, 0, 0.7), rgba(100, 45, 124, 0.4), rgba(82, 17, 131, 0.3),rgba(100, 45, 124, 0.4), rgba(0, 0, 0, 0.7));
--gradient-silver-light: linear-gradient(30deg, rgba(61, 55, 93, 0.2), rgba(178, 179, 196, 0.1), rgba(59, 62, 63, 0.2), rgba(206, 204, 199, 0.1), rgba(61, 46, 49, 0.2));
--gradient-daylight: conic-gradient(
from 0deg,
hsla(50, 100%, 80%, 0.7),
hsla(30, 30%, 40%, 0.1) 25%,
hsla(250, 50%, 40%, 0.1) 25%,
hsla(250, 30%, 30%, 0.7) 50%,
hsla(250, 50%, 40%, 0.1) 75%,
hsla(30, 30%, 40%, 0.1) 75%,
hsla(50, 100%, 80%, 0.7)
);
--background-custom-button: linear-gradient(to bottom, rgba(33, 55, 74, 0.988) 5%, rgba(21, 40, 51, 0.671) 100%);
--background-custom-button-hover: linear-gradient(to bottom, rgb(128, 0, 0) 5%, rgb(62, 1, 1) 100%);
--background-control-selected: linear-gradient(to bottom, hsla(0, 100%, 25%, 0.5) 5%, hsla(0, 100%, 12%, 0.5) 100%);
--background-tooltip: hsla(60, 12%, 85%, 0.95);
--color-tooltip:hsla(282, 47%, 33%, 0.9);
--color-tooltip-faint:hsla(282, 47%, 66%, 0.5);
--background-error:hsla(16, 100%, 50%, 0.8);
--color-profile-border: hsla(0, 0%, 80%, 0.05);
}

View File

@ -1,84 +0,0 @@
/* ==================== (A) Fonts ==================== */
@font-face {
font-family: "GoudyAcc";
src: url('../fonts/goudyacc.ttf') format("truetype");
}
@font-face {
font-family: "MedievalSharp";
src: url('../fonts/MedievalSharp.ttf') format("truetype");
}
@font-face {
font-family: "GrenzeGotisch";
src: url('../fonts/GrenzeGotisch-Regular.ttf') format("truetype");
}
@font-face {
font-family: "Fondamento";
src: url('../fonts/Fondamento.ttf') format("truetype");
}
@font-face {
font-family: "CaslonAntique";
src: url('../fonts/CaslonAntique.ttf') format("truetype");
}
@font-face {
font-family: 'HeuresDraconiques';
src:
url('../fonts/heuresdraconiques2.woff') format('woff'),
url('../fonts/heuresdraconiques2.woff2') format('woff2'),
url('../fonts/heuresdraconiques2.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
:root {
/* =================== 1. ACTOR SHEET FONT STYLES =========== */
--window-header-title-font-family: CaslonAntique;
--window-header-title-font-size: 1.6rem;
--window-header-title-font-weight: normal;
--window-header-title-color: #f5f5f5;
--major-button-font-family: CaslonAntique;
--major-button-font-size: 1.4rem;
--major-button-font-weight: normal;
--major-button-color: #dadada;
--tab-header-font-family: CaslonAntique;
--tab-header-font-size: 1.2rem;
--tab-header-font-weight: 700;
--tab-header-color: #403f3e;
--tab-header-color-active: #4a0404;
--actor-input-font-family: CaslonAntique;
--actor-input-font-size: 1.2rem;
--actor-input-font-weight: 500;
--actor-input-color: black;
--actor-label-font-family: CaslonAntique;
--actor-label-font-size: 1.2rem;
--actor-label-font-weight: 700;
--actor-label-color: #464331c4;
}
/* Global styles & Font */
.window-app {
font-family: CaslonAntique;
text-align: justify;
font-size: 1rem;
letter-spacing: 1px;
}
/* Fonts */
.sheet header.sheet-header h1 input,
.window-app .window-header,
#actors .directory-list,
#navigation #scene-list .scene.nav-item {
font-family: "GoudyAcc"
}
/* For title, sidebar character and scene */
.sheet nav.sheet-tabs,
.window-app input,
.sheet header.sheet-header .header-compteurs,
.sheet header.sheet-header .flex-group-center.flex-fatigue,
select, button, .item-checkbox, #sidebar, #players, #navigation #nav-toggle {
font-family: "CaslonAntique"; /* For sheet parts; For nav and title */
}

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +0,0 @@
.application.sheet.fvtt-rdd {
.sheet-common();
section.window-content{
padding: 0rem;
section header.sheet-header {
.sheet-header();
}
}
}

View File

@ -1,32 +0,0 @@
.sheet-common() {
.window-content{
font-family: CaslonAntique;
text-align: justify;
font-size: 1rem;
letter-spacing: 1px;
font-size: calc(var(--font-size-standard) * 1);
color: var(--color-dark-1);
background: var(--background-image-base) no-repeat;
background-size: 100% 100%;
}
}
.sheet-header() {
background: #011d33 url(../assets/ui/bg_header.webp) no-repeat left top;
color: rgba(255, 255, 255, 1);
:is(
input[type="text"],
input[type="number"],
input[type="password"],
input[type="datetime-local"],
input[type="date"],
input[type="time"]) {
color: rgba(255, 255, 255, 0.75);
background: rgba(255, 255, 255, 0.1);
border: 0 none;
margin-bottom: 0.2rem;
}
}

View File

@ -237,11 +237,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
this.html.find('.carac-xp-augmenter').click(async event => await this.actor.updateCaracXPAuto(event.currentTarget.name.replace("augmenter.", ""))) this.html.find('.carac-xp-augmenter').click(async event => await this.actor.updateCaracXPAuto(event.currentTarget.name.replace("augmenter.", "")))
this.html.find('.competence-xp-augmenter').click(async event => await this.actor.updateCompetenceXPAuto(RdDSheetUtility.getItemId(event))) this.html.find('.competence-xp-augmenter').click(async event => await this.actor.updateCompetenceXPAuto(RdDSheetUtility.getItemId(event)))
this.html.find('.competence-stress-augmenter').click(async event =>{ this.html.find('.competence-stress-augmenter').click(async event => await this.actor.updateCompetenceStress(RdDSheetUtility.getItemId(event)))
await this.actor.updateCompetenceStress(RdDSheetUtility.getItemId(event))
this.render(true)
}
)
if (this.options.vueDetaillee) { if (this.options.vueDetaillee) {
// On carac change // On carac change

View File

@ -243,7 +243,7 @@ export class RdDActor extends RdDBaseActorSang {
} }
await this.resetInfoSommeil() await this.resetInfoSommeil()
ChatMessage.create(message); ChatMessage.create(message);
setTimeout(() => this.sheet.render(), 20) this.sheet.render(true);
} }
async _recuperationSante(message) { async _recuperationSante(message) {
@ -279,32 +279,28 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */ /* -------------------------------------------- */
async dormirChateauDormant() { async dormirChateauDormant() {
if (!ReglesOptionnelles.isUsing("chateau-dormant-gardien") || !this.system.sommeil || this.system.sommeil.nouveaujour) { if (!ReglesOptionnelles.isUsing("chateau-dormant-gardien") || !this.system.sommeil || this.system.sommeil.nouveaujour) {
await this.$dormirChateauDormant();
setTimeout(() => this.sheet.render(), 20)
}
}
async $dormirChateauDormant() {
const message = { const message = {
whisper: ChatUtility.getOwners(this), whisper: ChatUtility.getOwners(this),
content: "" content: ""
}; };
await this._recuperationSante(message); await this._recuperationSante(message)
await this._recupereMoralChateauDormant(message); await this._recupereMoralChateauDormant(message)
await this._recupereChance(); await this._recupereChance()
await this.transformerStress(); await this.transformerStress()
await this.retourSeuilDeReve(message); await this.retourSeuilDeReve(message)
await this.setBonusPotionSoin(0); await this.setBonusPotionSoin(0)
await this.retourSust(message); await this.retourSust(message)
await this.$perteReveEnchantementsChateauDormants(); await this.$perteReveEnchantementsChateauDormants()
await this.$suppressionLancementsSort(); await this.$suppressionLancementsSort()
await RdDCoeur.applyCoeurChateauDormant(this, message); await RdDCoeur.applyCoeurChateauDormant(this, message)
if (message.content != "") { if (message.content != "") {
message.content = `A la fin Chateau Dormant, ${message.content}<br>Un nouveau jour se lève`; message.content = `A la fin Chateau Dormant, ${message.content}<br>Un nouveau jour se lève`;
ChatMessage.create(message); ChatMessage.create(message);
} }
await this.resetInfoSommeil(); await this.resetInfoSommeil();
this.sheet.render(true);
}
} }
async resetInfoSommeil() { async resetInfoSommeil() {
@ -446,9 +442,10 @@ export class RdDActor extends RdDBaseActorSang {
message.content += 'Vous ne trouvez pas le sommeil'; message.content += 'Vous ne trouvez pas le sommeil';
} }
else { else {
let dormi = await this.$dormirDesHeures(message, heures, options); let jetsReve = [];
if (dormi.jetsReve.length > 0) { let dormi = await this.dormirDesHeures(jetsReve, message, heures, options);
message.content += `Vous récupérez ${dormi.jetsReve.map(it => it < 0 ? '0 (réveil)' : it).reduce(Misc.joining("+"))} Points de rêve. `; if (jetsReve.length > 0) {
message.content += `Vous récupérez ${jetsReve.map(it => it < 0 ? '0 (réveil)' : it).reduce(Misc.joining("+"))} Points de rêve. `;
} }
if (dormi.etat == 'eveil') { if (dormi.etat == 'eveil') {
await this.reveilReveDeDragon(message, dormi.heures); await this.reveilReveDeDragon(message, dormi.heures);
@ -461,9 +458,11 @@ export class RdDActor extends RdDBaseActorSang {
ChatMessage.create(message); ChatMessage.create(message);
} }
if (options.chateauDormant) { if (options.chateauDormant) {
await this.$dormirChateauDormant(); await this.dormirChateauDormant();
}
else {
this.sheet.render(true);
} }
setTimeout(() => this.sheet.render(), 20)
} }
async reveilReveDeDragon(message, heures) { async reveilReveDeDragon(message, heures) {
@ -473,18 +472,18 @@ export class RdDActor extends RdDBaseActorSang {
} }
} }
async $dormirDesHeures(message, heures, options) { async dormirDesHeures(jetsReve, message, heures, options) {
const dormi = { heures: 0, etat: 'dort', jetsReve: [] }; const dormi = { heures: 0, etat: 'dort' };
for (; dormi.heures < heures && dormi.etat == 'dort'; dormi.heures++) { for (; dormi.heures < heures && dormi.etat == 'dort'; dormi.heures++) {
await this.$recupererEthylisme(message); await this._recupererEthylisme(message);
if (options.grisReve) { if (options.grisReve) {
await this.$recupererFatigue(message); await this.recupererFatigue(message);
} }
else if (!this.system.sommeil?.insomnie) { else if (!this.system.sommeil?.insomnie) {
await this.$recupererFatigue(message); await this.recupererFatigue(message);
await this.$jetRecuperationReve(dormi, message); dormi.etat = await this.jetRecuperationReve(jetsReve, message);
if (dormi.etat == 'dort' && EffetsDraconiques.isDonDoubleReve(this)) { if (dormi.etat == 'dort' && EffetsDraconiques.isDonDoubleReve(this)) {
await this.$jetRecuperationReve(dormi, message); dormi.etat = await this.jetRecuperationReve(jetsReve, message);
} }
} }
} }
@ -492,36 +491,35 @@ export class RdDActor extends RdDBaseActorSang {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async $jetRecuperationReve(dormi, message) { async jetRecuperationReve(jetsReve, message) {
if (this.getReveActuel() < this.system.reve.seuil.value) { if (this.getReveActuel() < this.system.reve.seuil.value) {
const reve = await RdDDice.rollTotal("1dr") let reve = await RdDDice.rollTotal("1dr");
if (reve >= 7) { if (reve >= 7) {
// Rêve de Dragon ! // Rêve de Dragon !
message.content += `Vous faites un <strong>Rêve de Dragon</strong> de ${reve} Points de rêve qui vous réveille! `; message.content += `Vous faites un <strong>Rêve de Dragon</strong> de ${reve} Points de rêve qui vous réveille! `;
await this.combattreReveDeDragon(reve); await this.combattreReveDeDragon(reve);
dormi.jetsReve.push(-1); jetsReve.push(-1);
dormi.etat = 'eveil' return 'eveil';
return
} }
else { else {
if (!ReglesOptionnelles.isUsing("recuperation-reve")) { if (!ReglesOptionnelles.isUsing("recuperation-reve")) {
ChatMessage.create({ ChatMessage.create({
whisper: ChatUtility.getOwners(this), whisper: ChatUtility.getOwners(this),
content: `Pas de récupération de rêve (${reve} points ignorés)` content: `Pas de récupération de rêve (${reve} points ignorés)`
}) });
dormi.jetsReve.push(0) jetsReve.push(0);
} }
else { else {
await this.reveActuelIncDec(reve) await this.reveActuelIncDec(reve);
dormi.jetsReve.push(reve) jetsReve.push(reve);
} }
} }
} }
dormi.etat = 'dort' return 'dort';
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async $recupererEthylisme(message) { async _recupererEthylisme(message) {
if (!ReglesOptionnelles.isUsing("recuperation-ethylisme")) { return; } if (!ReglesOptionnelles.isUsing("recuperation-ethylisme")) { return; }
let value = Math.min(Number.parseInt(this.system.compteurs.ethylisme.value) + 1, 1); let value = Math.min(Number.parseInt(this.system.compteurs.ethylisme.value) + 1, 1);
if (value <= 0) { if (value <= 0) {
@ -543,6 +541,7 @@ export class RdDActor extends RdDBaseActorSang {
max = Math.floor(max / 2); max = Math.floor(max / 2);
} }
const manquant = max - this.system.sante.endurance.value; const manquant = max - this.system.sante.endurance.value;
if (manquant > 0) { if (manquant > 0) {
await this.santeIncDec("endurance", manquant); await this.santeIncDec("endurance", manquant);
message.content += `Vous récuperez ${manquant} points d'endurance. `; message.content += `Vous récuperez ${manquant} points d'endurance. `;
@ -550,15 +549,15 @@ export class RdDActor extends RdDBaseActorSang {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async $recupererFatigue(message) { async recupererFatigue(message) {
if (ReglesOptionnelles.isUsing("appliquer-fatigue")) { if (ReglesOptionnelles.isUsing("appliquer-fatigue")) {
let fatigue = this.system.sante.fatigue.value let fatigue = this.system.sante.fatigue.value;
const fatigueMin = this.getFatigueMin() const fatigueMin = this.getFatigueMin();
if (fatigue <= fatigueMin) { if (fatigue <= fatigueMin) {
return return;
} }
fatigue = Math.max(fatigueMin, this._calculRecuperationSegment(fatigue)) fatigue = Math.max(fatigueMin, this._calculRecuperationSegment(fatigue));
await this.update({ 'system.sante.fatigue.value': fatigue }); await this.update({ "system.sante.fatigue.value": fatigue });
if (fatigue == 0) { if (fatigue == 0) {
message.content += "Vous êtes complêtement reposé. "; message.content += "Vous êtes complêtement reposé. ";
} }
@ -668,23 +667,19 @@ export class RdDActor extends RdDBaseActorSang {
if (!RdDItemRace.checkRacialMax(this, caracName, to)) { if (!RdDItemRace.checkRacialMax(this, caracName, to)) {
return return
} }
let updates = {};
if (caracName == LIST_CARAC_PERSONNAGE.reve.code) { if (caracName == LIST_CARAC_PERSONNAGE.reve.code) {
if (to > Misc.toInt(this.system.reve.seuil.value)) { if (to > Misc.toInt(this.system.reve.seuil.value)) {
updates[`system.reve.seuil.value`] = to; // SFA : Direct and packed changes this.setPointsDeSeuil(to);
//this.setPointsDeSeuil(to);
} }
} }
if (caracName == LIST_CARAC_PERSONNAGE.chance.code) { if (caracName == LIST_CARAC_PERSONNAGE.chance.code) {
if (to > Misc.toInt(this.system.compteurs.chance.value)) { if (to > Misc.toInt(this.system.compteurs.chance.value)) {
updates[`system.compteurs.chance.value`] = to; // SFA : Direct and packed changes this.setPointsDeChance(to);
//this.setPointsDeChance(to);
} }
} }
let selectedCarac = this.findCaracByName(caracName); let selectedCarac = this.findCaracByName(caracName);
const from = selectedCarac.value const from = selectedCarac.value
updates[`system.carac.${caracName}.value`] = to; await this.update({ [`system.carac.${caracName}.value`]: to });
await this.update(updates);
await ExperienceLog.add(this, XP_TOPIC.CARAC, from, to, caracName); await ExperienceLog.add(this, XP_TOPIC.CARAC, from, to, caracName);
} }
@ -741,7 +736,7 @@ export class RdDActor extends RdDBaseActorSang {
await competence.update({ await competence.update({
"system.xp": toXp, "system.xp": toXp,
"system.niveau": toNiveau, "system.niveau": toNiveau,
}, { render: false }) });
await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, toXp, competence.name); await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, toXp, competence.name);
await ExperienceLog.add(this, XP_TOPIC.NIVEAU, fromNiveau, toNiveau, competence.name); await ExperienceLog.add(this, XP_TOPIC.NIVEAU, fromNiveau, toNiveau, competence.name);
} }
@ -772,7 +767,7 @@ export class RdDActor extends RdDBaseActorSang {
await competence.update({ await competence.update({
"system.xp": newXp, "system.xp": newXp,
"system.niveau": toNiveau, "system.niveau": toNiveau,
}, { render: false }) });
const toXpStress = Math.max(0, fromXpStress - xpUtilise); const toXpStress = Math.max(0, fromXpStress - xpUtilise);
await this.update({ "system.compteurs.experience.value": toXpStress }); await this.update({ "system.compteurs.experience.value": toXpStress });
@ -788,7 +783,7 @@ export class RdDActor extends RdDBaseActorSang {
const toNiveau = compValue ?? RdDItemCompetence.getNiveauBase(competence.system.categorie, competence.getCategories()); const toNiveau = compValue ?? RdDItemCompetence.getNiveauBase(competence.system.categorie, competence.getCategories());
this.notifyCompetencesTronc(competence, toNiveau); this.notifyCompetencesTronc(competence, toNiveau);
const fromNiveau = competence.system.niveau; const fromNiveau = competence.system.niveau;
await competence.update({ 'system.niveau': toNiveau }, { render: true }) await competence.update({ 'system.niveau': toNiveau });
await ExperienceLog.add(this, XP_TOPIC.NIVEAU, fromNiveau, toNiveau, competence.name, true); await ExperienceLog.add(this, XP_TOPIC.NIVEAU, fromNiveau, toNiveau, competence.name, true);
} }
} }
@ -813,7 +808,7 @@ export class RdDActor extends RdDBaseActorSang {
if (isNaN(toXp) || typeof (toXp) != 'number') toXp = 0; if (isNaN(toXp) || typeof (toXp) != 'number') toXp = 0;
const fromXp = competence.system.xp; const fromXp = competence.system.xp;
this.checkCompetenceXP(idOrName, toXp); this.checkCompetenceXP(idOrName, toXp);
await competence.update({ 'system.xp': toXp }, { render: false }) await competence.update({ 'system.xp': toXp });
await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, toXp, competence.name, true); await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, toXp, competence.name, true);
if (toXp > fromXp) { if (toXp > fromXp) {
RdDUtility.checkThanatosXP(competence) RdDUtility.checkThanatosXP(competence)
@ -827,7 +822,7 @@ export class RdDActor extends RdDBaseActorSang {
if (competence) { if (competence) {
if (isNaN(toXpSort) || typeof (toXpSort) != 'number') toXpSort = 0; if (isNaN(toXpSort) || typeof (toXpSort) != 'number') toXpSort = 0;
const fromXpSort = competence.system.xp_sort; const fromXpSort = competence.system.xp_sort;
await competence.update({ 'system.xp_sort': toXpSort }, { render: false }) await competence.update({ 'system.xp_sort': toXpSort });
await ExperienceLog.add(this, XP_TOPIC.XPSORT, fromXpSort, toXpSort, competence.name, true); await ExperienceLog.add(this, XP_TOPIC.XPSORT, fromXpSort, toXpSort, competence.name, true);
if (toXpSort > fromXpSort) { if (toXpSort > fromXpSort) {
RdDUtility.checkThanatosXP(competence) RdDUtility.checkThanatosXP(competence)
@ -839,7 +834,7 @@ export class RdDActor extends RdDBaseActorSang {
async updateCompetenceArchetype(idOrName, compValue) { async updateCompetenceArchetype(idOrName, compValue) {
let competence = this.getCompetence(idOrName) let competence = this.getCompetence(idOrName)
if (competence) { if (competence) {
await competence.update({ 'system.niveau_archetype': Math.max(compValue ?? 0, 0) }) await competence.update({ 'system.niveau_archetype': Math.max(compValue ?? 0, 0) });
} }
} }
@ -1052,10 +1047,20 @@ export class RdDActor extends RdDBaseActorSang {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async deleteRencontreTMRAtPosition() {
const rencontreIds = this.itemTypes[ITEM_TYPES.rencontre].filter(this.filterRencontreTMRDemiReve()).map(it => it.id)
if (rencontreIds.length > 0) {
await this.deleteEmbeddedDocuments('Item', rencontreIds)
}
}
getRencontreTMREnAttente() { getRencontreTMREnAttente() {
return this.itemTypes[ITEM_TYPES.rencontre].find(this.filterRencontreTMRDemiReve())
}
filterRencontreTMRDemiReve() {
const position = this.getDemiReve() const position = this.getDemiReve()
return this.itemTypes[ITEM_TYPES.rencontre].find(it => it.system.coord == position) return it => it.system.coord == position
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -1579,7 +1584,7 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */ /* -------------------------------------------- */
async _appliquerAppelMoral(rollData) { async _appliquerAppelMoral(rollData) {
if (!rollData.use.moral || game.settings.get("core", "rollMode") == 'selfroll') { if (!rollData.use.moral || game.settings.get("core", "rollMode") == 'selfroll'){
return return
} }
if (rollData.rolled.isEchec || if (rollData.rolled.isEchec ||
@ -1765,7 +1770,7 @@ export class RdDActor extends RdDBaseActorSang {
if (reveActuel == 0) { // 0 points de reve if (reveActuel == 0) { // 0 points de reve
ChatMessage.create({ content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" }); ChatMessage.create({ content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" });
} }
if (!rollData.isSortReserve || !rolled.isSuccess) { if (!rollData.isSortReserve) {
this.tmrApp?.close(); this.tmrApp?.close();
} }
} }
@ -2111,6 +2116,7 @@ export class RdDActor extends RdDBaseActorSang {
label: "Jet de méditation", label: "Jet de méditation",
callbacks: [ callbacks: [
this.createCallbackExperience(), this.createCallbackExperience(),
{ condition: r => r.rolled.isEPart, action: r => this._meditationEPart(r) },
{ action: r => this._meditationResult(r) } { action: r => this._meditationResult(r) }
] ]
}); });
@ -2119,16 +2125,21 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */ /* -------------------------------------------- */
async _meditationResult(meditationRoll) { async _meditationResult(meditationRoll) {
this.santeIncDec("fatigue", 2);
if (meditationRoll.rolled.isSuccess) { if (meditationRoll.rolled.isSuccess) {
await this.createEmbeddedDocuments("Item", [RdDItemSigneDraconique.prepareSigneDraconiqueMeditation(meditationRoll.meditation, meditationRoll.rolled)]); await this.createEmbeddedDocuments("Item", [RdDItemSigneDraconique.prepareSigneDraconiqueMeditation(meditationRoll.meditation, meditationRoll.rolled)]);
} }
if (meditationRoll.rolled.isEPart){
await this.updateEmbeddedDocuments('Item', [{ _id: meditationRoll.meditation._id, 'system.malus': meditationRoll.meditation.system.malus - 1 }]);
}
await this.santeIncDec("fatigue", 2);
await RdDRollResult.displayRollData(meditationRoll, this.name, 'chat-resultat-meditation.hbs'); await RdDRollResult.displayRollData(meditationRoll, this.name, 'chat-resultat-meditation.hbs');
} }
/* -------------------------------------------- */
_meditationEPart(meditationRoll) {
this.updateEmbeddedDocuments('Item', [{ _id: meditationRoll.meditation._id, 'system.malus': meditationRoll.meditation.system.malus - 1 }]);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
_getSignesDraconiques(coord) { _getSignesDraconiques(coord) {
const type = TMRUtility.getTMRType(coord); const type = TMRUtility.getTMRType(coord);
@ -2516,6 +2527,7 @@ export class RdDActor extends RdDBaseActorSang {
}) })
} }
const blessure = this.getItem(blessureId, 'blessure') const blessure = this.getItem(blessureId, 'blessure')
console.log('TODO update blessure', this, blessureId, rollData, rollData.tache);
if (blessure && !blessure.system.premierssoins.done) { if (blessure && !blessure.system.premierssoins.done) {
const tache = rollData.tache; const tache = rollData.tache;
if (rollData.rolled.isETotal) { if (rollData.rolled.isETotal) {
@ -2632,13 +2644,12 @@ export class RdDActor extends RdDBaseActorSang {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async incDecItemUse(itemId, shouldIncrease = true) { async incDecItemUse(itemId, inc = 1) {
if (shouldIncrease) {
const currentItemUse = this.getFlag(SYSTEM_RDD, 'itemUse'); const currentItemUse = this.getFlag(SYSTEM_RDD, 'itemUse');
let itemUse = currentItemUse ? foundry.utils.duplicate(currentItemUse) : {}; let itemUse = currentItemUse ? foundry.utils.duplicate(currentItemUse) : {};
itemUse[itemId] = (itemUse[itemId] ?? 0) + 1; itemUse[itemId] = (itemUse[itemId] ?? 0) + inc;
await this.setFlag(SYSTEM_RDD, 'itemUse', itemUse); await this.setFlag(SYSTEM_RDD, 'itemUse', itemUse);
} console.log("ITEM USE INC", inc, itemUse);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -277,9 +277,14 @@ export class RdDBaseActorReve extends RdDBaseActor {
return dialog return dialog
} }
createCallbackExperience() { return { action: r => { } } } createEmptyCallback() {
createCallbackAppelAuMoral() { return { action: r => { } } } return {
condition: r => false,
action: r => { }
};
}
createCallbackExperience() { return this.createEmptyCallback(); }
createCallbackAppelAuMoral() { return this.createEmptyCallback(); }
async _onCloseRollDialog(html) { } async _onCloseRollDialog(html) { }
async rollCaracCompetence(caracName, compName, diff, options = { title: "" }) { async rollCaracCompetence(caracName, compName, diff, options = { title: "" }) {

View File

@ -39,12 +39,7 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
return 0; return 0;
} }
isCumulFatigueCauseSommeil(cumulFatigue){ getFatigueRestante() { return this.getFatigueMax() - this.getFatigueActuelle() }
return ReglesOptionnelles.isUsing("appliquer-fatigue")
? (this.getFatigueRestante() <= cumulFatigue)
: (this.getEnduranceActuelle() <= cumulFatigue)
}
getFatigueRestante() {return this.getFatigueMax() - this.getFatigueActuelle() }
getFatigueMin() { return this.system.sante.endurance.max - this.system.sante.endurance.value } getFatigueMin() { return this.system.sante.endurance.max - this.system.sante.endurance.value }
malusFatigue() { malusFatigue() {

View File

@ -244,19 +244,16 @@ export class RdDBaseActor extends Actor {
async onUpdateActor(update, options, actorId) { } async onUpdateActor(update, options, actorId) { }
async onDeleteItem(item, options, id) { async onDeleteItem(item, options, id) {
if (item.isInventaire()) { if (item.isInventaire()) {
await this._removeItemFromConteneur(item) this._removeItemFromConteneur(item)
} }
} }
async _removeItemFromConteneur(item) { _removeItemFromConteneur(item) {
const updates = this.items.filter(it => it.isConteneur() && it.system.contenu.includes(item.id)) this.items.filter(it => it.isConteneur() && it.system.contenu.includes(item.id))
.map(conteneur => { .forEach(conteneur => {
const nouveauContenu = conteneur.system.contenu.filter(id => id != item.id) const nouveauContenu = conteneur.system.contenu.filter(id => id != item.id);
return { _id: conteneur.id, 'system.contenu': nouveauContenu } conteneur.update({ 'system.contenu': nouveauContenu });
}) });
if (updates.length > 0) {
await this.updateEmbeddedDocuments('Item', updates)
}
} }
async onTimeChanging(oldTimestamp, newTimestamp) { async onTimeChanging(oldTimestamp, newTimestamp) {
@ -747,7 +744,7 @@ export class RdDBaseActor extends Actor {
async jetDeMoral() { this.actionImpossible("jet de moral") } async jetDeMoral() { this.actionImpossible("jet de moral") }
async resetItemUse() { } async resetItemUse() { }
async incDecItemUse(itemId, shouldIncrease = true) { } async incDecItemUse(itemId, inc = 1) { }
getItemUse(itemId) { return 0; } getItemUse(itemId) { return 0; }
async finDeRound(options = { terminer: false }) { } async finDeRound(options = { terminer: false }) { }

View File

@ -3,7 +3,7 @@ import { Misc } from "../../misc.js"
import { EXPORT_CSV_SCRIPTARIUM, OptionsAvancees } from "../../settings/options-avancees.js" import { EXPORT_CSV_SCRIPTARIUM, OptionsAvancees } from "../../settings/options-avancees.js"
import { Mapping } from "./mapping.js" import { Mapping } from "./mapping.js"
const IMG_SCRIPTARIUM = '<img class="context-menu-img" src="systems/foundryvtt-reve-de-dragon/assets/ui/scriptarium.svg">' const IMG_SCRIPTARIUM = '<img class="context-menu-img" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/scriptarium.svg">'
export class ExportScriptarium { export class ExportScriptarium {

View File

@ -1,4 +1,3 @@
export { default as RdDItemBaseSheet} from "./common-item-sheet.mjs" export { default as RdDItemSheet} from "./common-item-sheet.mjs"
export { default as RdDMonnaieSheet } from "./monnaie-sheet.mjs" export { default as RdDMonnaieSheet } from "./monnaie-sheet.mjs"
export { default as RdDMunitionSheet } from "./munition-sheet.mjs" export { default as RdDMunitionSheet } from "./munition-sheet.mjs"

View File

@ -1,20 +1,8 @@
const { HandlebarsApplicationMixin } = foundry.applications.api const { HandlebarsApplicationMixin } = foundry.applications.api
import { SYSTEM_RDD } from "../../constants.js" import { SYSTEM_RDD } from "../../constants.js"
import { Misc } from "../../misc.js" import { Misc } from "../../misc.js"
import { RdDSheetUtility } from "../../rdd-sheet-utility.js";
export default class RdDItemSheet extends HandlebarsApplicationMixin(foundry.applications.sheets.ItemSheetV2) {
export default class RdDItemBaseSheet extends HandlebarsApplicationMixin(foundry.applications.sheets.ItemSheetV2) {
static preloadHandlebars(...templatesList) {
const handlebars = ["systems/foundryvtt-reve-de-dragon/templates/sheets/item/common/header.hbs"]
templatesList.forEach(templates =>
templates.forEach(t =>
t.handlebars().forEach(h => handlebars.push(h))
)
)
loadTemplates(Misc.distinct(handlebars))
}
static register(sheetClass) { static register(sheetClass) {
const itemType = sheetClass.ITEM_TYPE const itemType = sheetClass.ITEM_TYPE
@ -25,29 +13,20 @@ export default class RdDItemBaseSheet extends HandlebarsApplicationMixin(foundry
}) })
} }
static registerAll(...sheetClasses) {
const handlebars = ["systems/foundryvtt-reve-de-dragon/templates/sheets/item/common/header.hbs"]
sheetClasses.forEach(sheetClass => {
sheetClass.TEMPLATES.forEach(t =>
t.handlebars().forEach(h => handlebars.push(h))
)
const itemType = sheetClass.ITEM_TYPE
Items.registerSheet(SYSTEM_RDD, sheetClass, {
label: Misc.typeName('Item', itemType),
types: [itemType],
makeDefault: true
})
})
loadTemplates(Misc.distinct(handlebars))
}
static get ITEM_TYPE() { return undefined } static get ITEM_TYPE() { return undefined }
/**
* Different sheet modes.
* @enum {number}
*/
static SHEET_MODES = { EDIT: 0, PLAY: 1 }
constructor(options = {}) { constructor(options = {}) {
super(options) super(options)
this.#dragDrop = this.#createDragDropHandlers()
} }
static get TEMPLATES() { return [] } #dragDrop
_sheetMode = this.constructor.SHEET_MODES.PLAY
/** @override */ /** @override */
static DEFAULT_OPTIONS = { static DEFAULT_OPTIONS = {
@ -62,30 +41,140 @@ export default class RdDItemBaseSheet extends HandlebarsApplicationMixin(foundry
window: { window: {
resizable: true, resizable: true,
}, },
dragDrop: [{ dragSelector: "[data-drag]", dropSelector: null }],
actions: { actions: {
editImage: RdDItemBaseSheet.#onEditImage, toggleSheet: RdDItemSheet.#onToggleSheet,
editImage: RdDItemSheet.#onEditImage,
},
} }
/**
* Is the sheet currently in 'Play' mode?
* @type {boolean}
*/
get isPlayMode() {
return this._sheetMode === this.constructor.SHEET_MODES.PLAY
}
/**
* Is the sheet currently in 'Edit' mode?
* @type {boolean}
*/
get isEditMode() {
return this._sheetMode === this.constructor.SHEET_MODES.EDIT
} }
/** @override */ /** @override */
async _prepareContext() { async _prepareContext() {
return { const context = {
item: this.document,
options: RdDSheetUtility.getOptions(this.document, this.isEditable),
fields: this.document.schema.fields, fields: this.document.schema.fields,
systemFields: this.document.system.schema.fields, systemFields: this.document.system.schema.fields,
item: this.document,
system: this.document.system, system: this.document.system,
source: this.document.toObject(), source: this.document.toObject(),
isEditMode: this.isEditMode,
isPlayMode: this.isPlayMode,
isEditable: this.isEditable, isEditable: this.isEditable,
} }
return context
} }
/** @override */
_onRender(context, options) {
this.#dragDrop.forEach((d) => d.bind(this.element))
}
// #region Drag-and-Drop Workflow
/**
* Create drag-and-drop workflow handlers for this Application
* @returns {DragDrop[]} An array of DragDrop handlers
* @private
*/
#createDragDropHandlers() {
return this.options.dragDrop.map((d) => {
d.permissions = {
dragstart: this._canDragStart.bind(this),
drop: this._canDragDrop.bind(this),
}
d.callbacks = {
dragstart: this._onDragStart.bind(this),
dragover: this._onDragOver.bind(this),
drop: this._onDrop.bind(this),
}
return new DragDrop(d)
})
}
/**
* Define whether a user is able to begin a dragstart workflow for a given drag selector
* @param {string} selector The candidate HTML selector for dragging
* @returns {boolean} Can the current user drag this selector?
* @protected
*/
_canDragStart(selector) {
return this.isEditable
}
/**
* Define whether a user is able to conclude a drag-and-drop workflow for a given drop selector
* @param {string} selector The candidate HTML selector for the drop target
* @returns {boolean} Can the current user drop on this selector?
* @protected
*/
_canDragDrop(selector) {
return this.isEditable && this.document.isOwner
}
/**
* Callback actions which occur at the beginning of a drag start workflow.
* @param {DragEvent} event The originating DragEvent
* @protected
*/
_onDragStart(event) {
const el = event.currentTarget
if ("link" in event.target.dataset) return
// Extract the data you need
let dragData = null
if (!dragData) return
// Set data transfer
event.dataTransfer.setData("text/plain", JSON.stringify(dragData))
}
/**
* Callback actions which occur when a dragged element is over a drop target.
* @param {DragEvent} event The originating DragEvent
* @protected
*/
_onDragOver(event) { }
/**
* Callback actions which occur when a dragged element is dropped on a target.
* @param {DragEvent} event The originating DragEvent
* @protected
*/
async _onDrop(event) { }
// #endregion
// #region Actions // #region Actions
/**
* Handle toggling between Edit and Play mode.
* @param {Event} event The initiating click event.
* @param {HTMLElement} target The current target of the event listener.
*/
static #onToggleSheet(event, target) {
const modes = this.constructor.SHEET_MODES
this._sheetMode = this.isEditMode ? modes.PLAY : modes.EDIT
this.render()
}
/** /**
* Handle changing a Document's image. * Handle changing a Document's image.
* *
* @this RdDItemBaseSheet * @this RdDItemSheet
* @param {PointerEvent} event The originating click event * @param {PointerEvent} event The originating click event
* @param {HTMLElement} target The capturing HTML element which defined a [data-action] * @param {HTMLElement} target The capturing HTML element which defined a [data-action]
* @returns {Promise} * @returns {Promise}

View File

@ -1,35 +1,35 @@
import { TEMPLATE_DESCRIPTION, TEMPLATE_INVENTAIRE } from "../../common/_module.mjs"; import { TEMPLATE_DESCRIPTION, TEMPLATE_INVENTAIRE } from "../../common/_module.mjs";
import { ITEM_TYPES } from "../../constants.js"; import { ITEM_TYPES } from "../../constants.js";
import RdDItemBaseSheet from "./common-item-sheet.mjs"; import RdDItemSheet from "./common-item-sheet.mjs";
export default class RdDMonnaieSheet extends RdDItemBaseSheet {
export default class RdDMonnaieSheet extends RdDItemSheet {
/** @override */ /** @override */
static get ITEM_TYPE() { return ITEM_TYPES.monnaie } static get ITEM_TYPE() { return ITEM_TYPES.monnaie }
static get TEMPLATES() { return [TEMPLATE_DESCRIPTION, TEMPLATE_INVENTAIRE] }
/** @override */ /** @override */
static DEFAULT_OPTIONS = Object.assign({}, static DEFAULT_OPTIONS = {
RdDItemBaseSheet.DEFAULT_OPTIONS,
{
classes: ["fvtt-rdd", "item", "monnaie"], classes: ["fvtt-rdd", "item", "monnaie"],
position: { width: 400 }, position: {
window: { contentClasses: ["monnaie-content"] } width: 600,
}) },
window: {
contentClasses: ["monnaie-content"],
},
}
/** @override */ /** @override */
static PARTS = { static PARTS = {
main: { main: {
template: "systems/foundryvtt-reve-de-dragon/templates/sheets/item/monnaie.hbs", template: "systems/foundryvtt-reve-de-dragon/templates/item/monnaie.hbs",
}, },
} }
/** @override */ /** @override */
async _prepareContext() { async _prepareContext() {
return Object.assign( const context = await super._prepareContext()
await super._prepareContext(), return Object.assign(context,
await TEMPLATE_DESCRIPTION.prepareContext(this.document), await TEMPLATE_DESCRIPTION.prepareContext(this.item),
await TEMPLATE_INVENTAIRE.prepareContext(this.document) await TEMPLATE_INVENTAIRE.prepareContext(this.item)
) )
} }
} }

View File

@ -1,34 +1,35 @@
import { TEMPLATE_DESCRIPTION, TEMPLATE_INVENTAIRE } from "../../common/_module.mjs"; import { TEMPLATE_DESCRIPTION, TEMPLATE_INVENTAIRE } from "../../common/_module.mjs";
import { ITEM_TYPES } from "../../constants.js"; import { ITEM_TYPES } from "../../constants.js";
import RdDItemBaseSheet from "./common-item-sheet.mjs"; import RdDItemSheet from "./common-item-sheet.mjs";
export default class RdDMunitionSheet extends RdDItemBaseSheet { export default class RdDMunitionSheet extends RdDItemSheet {
/** @override */ /** @override */
static get ITEM_TYPE() { return ITEM_TYPES.munition } static get ITEM_TYPE() { return ITEM_TYPES.munition }
static get TEMPLATES() { return [TEMPLATE_DESCRIPTION, TEMPLATE_INVENTAIRE] }
/** @override */ /** @override */
static DEFAULT_OPTIONS = Object.assign({}, static DEFAULT_OPTIONS = {
RdDItemBaseSheet.DEFAULT_OPTIONS,
{
classes: ["fvtt-rdd", "item", "munition"], classes: ["fvtt-rdd", "item", "munition"],
position: { width: 400 }, position: {
window: { contentClasses: ["munition-content"] } width: 600,
}) },
window: {
contentClasses: ["munition-content"],
},
}
/** @override */ /** @override */
static PARTS = { static PARTS = {
main: { main: {
template: "systems/foundryvtt-reve-de-dragon/templates/sheets/item/munition.hbs", template: "systems/foundryvtt-reve-de-dragon/templates/item/munition.hbs",
}, },
} }
/** @override */ /** @override */
async _prepareContext() { async _prepareContext() {
return Object.assign( const context = await super._prepareContext()
await super._prepareContext(), return Object.assign(context,
await TEMPLATE_DESCRIPTION.prepareContext(this.document), await TEMPLATE_DESCRIPTION.prepareContext(this.item),
await TEMPLATE_INVENTAIRE.prepareContext(this.document) await TEMPLATE_INVENTAIRE.prepareContext(this.item)
) )
} }
} }

View File

@ -5,7 +5,7 @@ import { RdDUtility } from "../../rdd-utility.js";
import { RdDAlchimie } from "../../rdd-alchimie.js"; import { RdDAlchimie } from "../../rdd-alchimie.js";
import { TextRollManager } from "./text-roll-formatter.js"; import { TextRollManager } from "./text-roll-formatter.js";
const REGEX_ALCHIMIE_TERMES = "(?<termes>([-A-Za-zÀ-ÖØ-öø-ÿ ])+)" const REGEX_ALCHIMIE_TERMES = "(?<termes>(\\w|-)+)"
const REGEX_ALCHIMIE_MANIP = "(?<manip>(couleur|consistance))" const REGEX_ALCHIMIE_MANIP = "(?<manip>(couleur|consistance))"
const XREGEXP_ROLL_ALCHIMIE = XRegExp("@roll\\[" + REGEX_ALCHIMIE_MANIP + "\\s+" + REGEX_ALCHIMIE_TERMES + "\\]", 'giu') const XREGEXP_ROLL_ALCHIMIE = XRegExp("@roll\\[" + REGEX_ALCHIMIE_MANIP + "\\s+" + REGEX_ALCHIMIE_TERMES + "\\]", 'giu')
const XREGEXP_ROLL_ALCHIMIE_MANIP = XRegExp("@" + REGEX_ALCHIMIE_MANIP + "\\{" + REGEX_ALCHIMIE_TERMES + "\\}", 'giu') const XREGEXP_ROLL_ALCHIMIE_MANIP = XRegExp("@" + REGEX_ALCHIMIE_MANIP + "\\{" + REGEX_ALCHIMIE_TERMES + "\\}", 'giu')

View File

@ -5,7 +5,7 @@ import { RdDUtility } from "../../rdd-utility.js";
import { TextRollManager } from "./text-roll-formatter.js"; import { TextRollManager } from "./text-roll-formatter.js";
const REGECP_CARAC = "(?<carac>[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+)" const REGECP_CARAC = "(?<carac>[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+)"
const REGEXP_COMP = "(\\/(?<competence>[A-Za-zÀ-ÖØ-öø-ÿ ]+([1-2]?[A-Za-zÀ-ÖØ-öø-ÿ ]+)?))?" const REGEXP_COMP = "(\\/(?<competence>[A-Za-z0-9À-ÖØ-öø-ÿ -]+))?"
const REGEXP_DIFF = "(/(?<diff>[\\+\\-]?\\d+(d\\d+)?))?" const REGEXP_DIFF = "(/(?<diff>[\\+\\-]?\\d+(d\\d+)?))?"
const REGEXP_ROLL_CARAC_COMP = REGECP_CARAC + REGEXP_COMP + REGEXP_DIFF const REGEXP_ROLL_CARAC_COMP = REGECP_CARAC + REGEXP_COMP + REGEXP_DIFF
const XREGEXP_ROLL_CARAC_COMP = XRegExp("@roll\\[" + REGEXP_ROLL_CARAC_COMP + "\\]", 'giu') const XREGEXP_ROLL_CARAC_COMP = XRegExp("@roll\\[" + REGEXP_ROLL_CARAC_COMP + "\\]", 'giu')

View File

@ -62,6 +62,7 @@ export class ChatUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static removeMessages(socketData) { static removeMessages(socketData) {
if (Misc.isFirstConnectedGM()) { if (Misc.isFirstConnectedGM()) {
ChatUtility.onRemoveMessages(socketData); ChatUtility.onRemoveMessages(socketData);
@ -96,7 +97,7 @@ export class ChatUtility {
} }
break break
case "gmroll": case "gmroll":
messageData.whisper = actor ? ChatUtility.getOwners(actor) : ChatUtility.getUserAndGMs() messageData.whisper = ChatUtility.getOwners(actor)
break break
case "selfroll": case "selfroll":
messageData.whisper = [game.user] messageData.whisper = [game.user]
@ -107,7 +108,7 @@ export class ChatUtility {
} }
static getOwners(document) { static getOwners(document) {
return document ? game.users.filter(it => document.getUserLevel(it) == CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER) : [game.user] return game.users.filter(it => document.getUserLevel(it) == CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER)
} }
static getUserAndGMs() { static getUserAndGMs() {
@ -198,7 +199,7 @@ export class ChatUtility {
static async onCreateChatMessage(chatMessage, options, id) { static async onCreateChatMessage(chatMessage, options, id) {
if (chatMessage.isAuthor) { if (chatMessage.isAuthor) {
await chatMessage.setFlag(SYSTEM_RDD, 'rdd-timestamp', game.system.rdd.calendrier.getTimestamp()); await chatMessage.setFlag(SYSTEM_RDD, 'rdd-timestamp', game.system.rdd.calendrier.getTimestamp());
await chatMessage.update({ content: await RdDTextEditor.enrichHTML(chatMessage.content, undefined, { showLink: false }) }) await chatMessage.update({ content: await RdDTextEditor.enrichHTML(chatMessage.content, undefined, {showLink:false}) })
} }
} }
} }

View File

@ -4,5 +4,4 @@ import { CommonInventaire } from "./inventaire.mjs";
export const TEMPLATE_DESCRIPTION = new CommonDescription() export const TEMPLATE_DESCRIPTION = new CommonDescription()
export const TEMPLATE_INVENTAIRE = new CommonInventaire() export const TEMPLATE_INVENTAIRE = new CommonInventaire()
export const ALL_COMMON_TEMPLATES = [TEMPLATE_DESCRIPTION, TEMPLATE_INVENTAIRE]

View File

@ -4,7 +4,5 @@
*/ */
export default class CommonTemplate { export default class CommonTemplate {
fields() { } fields() { }
handlebars() { return [] }
actions() { return {} }
async prepareContext(item) { } async prepareContext(item) { }
} }

View File

@ -12,21 +12,11 @@ export class CommonDescription extends CommonTemplate {
} }
} }
handlebars() {
return [
"systems/foundryvtt-reve-de-dragon/templates/sheets/item/common/template-description.hbs",
]
}
actions() {
return {}
}
async prepareContext(item) { async prepareContext(item) {
const enriched = { return {
description: await RdDTextEditor.enrichHTML(item.system.description, item), description: await RdDTextEditor.enrichHTML(item.system.description, item),
descriptionmj: await RdDTextEditor.enrichHTML(item.system.descriptionmj, item), descriptionmj: await RdDTextEditor.enrichHTML(item.system.descriptionmj, item),
} }
return { enriched }
} }
} }

View File

@ -3,7 +3,7 @@ export const DECIMAL = { required: true, nullable: false, min: 0, integer: false
export const INTEGER_SIGNED = { required: true, nullable: false, integer: true } export const INTEGER_SIGNED = { required: true, nullable: false, integer: true }
export const DECIMAL_SIGNED = { required: true, nullable: false, integer: false } export const DECIMAL_SIGNED = { required: true, nullable: false, integer: false }
export const STRING = { required: true, nullable: false, blank: true, trim: true } export const STRING = { required: true, nullable: false, blank: true, trim: true }
export const HTMLSTRING = { initial: "", required: true, nullable: false, blank: true, textSearch: true } export const HTMLSTRING = { initial: "", required: true, nullable: false, blank: true, trim: false, textSearch: true }
export const MODEL_ARRAY = { initial: [], required: true, nullable: false } export const MODEL_ARRAY = { initial: [], required: true, nullable: false }

View File

@ -23,14 +23,6 @@ export class CommonInventaire extends CommonTemplate {
{ label: "Environnement", ...MODEL_ARRAY }), { label: "Environnement", ...MODEL_ARRAY }),
} }
} }
handlebars() {
return [
"systems/foundryvtt-reve-de-dragon/templates/sheets/item/common/template-inventaire.hbs"
]
}
async prepareContext(item) { async prepareContext(item) {
return {}
} }
} }

View File

@ -1,2 +1,2 @@
export { default as RdDItemMonnaie } from "./monnaie.mjs" export { default as RdDModelMonnaie } from "./monnaie.mjs"
export { default as RdDItemMunition } from "./munition.mjs" export { default as RdDModelMunition } from "./munition.mjs"

View File

@ -120,13 +120,13 @@ export class RdDItemArme extends Item {
static defenseArmeParade(armeAttaque, armeParade) { static defenseArmeParade(armeAttaque, armeParade) {
const defCategory = RdDItemArme.getCategorieParade(armeParade) const defCategory = RdDItemArme.getCategorieParade(armeParade)
if (defCategory == 'boucliers') { if (defCategory == 'bouclier') {
return 'norm' return 'norm'
} }
if (armeAttaque?.system?.competence?.toLowerCase().match(/(fléau)/)) { if (armeAttaque.system.competence.toLowerCase().match(/(fléau)/)) {
return '' return ''
} }
if (armeParade.system?.tir) { if (armeParade.system.tir) {
return '' return ''
} }
const attCategory = RdDItemArme.getCategorieParade(armeAttaque) const attCategory = RdDItemArme.getCategorieParade(armeAttaque)

View File

@ -100,7 +100,7 @@ export class RdDItemSheetV1 extends ItemSheet {
description: await RdDTextEditor.enrichHTML(this.item.system.description, this.item), description: await RdDTextEditor.enrichHTML(this.item.system.description, this.item),
descriptionmj: await RdDTextEditor.enrichHTML(this.item.system.descriptionmj, this.item), descriptionmj: await RdDTextEditor.enrichHTML(this.item.system.descriptionmj, this.item),
isComestible: this.item.getUtilisationCuisine(), isComestible: this.item.getUtilisationCuisine(),
options: RdDSheetUtility.mergeDocumentRights({}, this.item, this.isEditable), options: RdDSheetUtility.mergeDocumentRights(this.options, this.item, this.isEditable),
competences: await SystemCompendiums.getCompetences(ACTOR_TYPES.personnage), competences: await SystemCompendiums.getCompetences(ACTOR_TYPES.personnage),
categories: RdDItem.getCategories(this.item.type), categories: RdDItem.getCategories(this.item.type),
} }

View File

@ -56,10 +56,6 @@ export class RdDItemSort extends Item {
return voies.map(voie => RdDItemCompetence.getVoieDraconic(competencesDraconic, voie)) return voies.map(voie => RdDItemCompetence.getVoieDraconic(competencesDraconic, voie))
} }
static getBestDraconicSort(competencesDraconic, sort) {
return RdDItemSort.getDraconicsSort(competencesDraconic, sort).sort(Misc.descending(it => it.system.niveau)).find(it=>true)
}
static getOrdreCode(code) { static getOrdreCode(code) {
return (VOIES_DRACONIC.find(it => it.code == code)?.ordre ?? '?') return (VOIES_DRACONIC.find(it => it.code == code)?.ordre ?? '?')
} }
@ -96,7 +92,7 @@ export class RdDItemSort extends Item {
/* -------------------------------------------- */ /* -------------------------------------------- */
static isCoutVariable(sort) { static isCoutVariable(sort) {
return sort && !Number.isInteger(sort.system.ptreve) && (sort.system.ptreve.toLowerCase() == "variable" || sort.system.ptreve.indexOf("+") >= 0); return sort && (sort.system.ptreve.toLowerCase() == "variable" || sort.system.ptreve.indexOf("+") >= 0);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -55,10 +55,6 @@ export class RdDItemRace extends RdDItem {
isMax(actor, code, value = undefined) { isMax(actor, code, value = undefined) {
const path = RdDCarac.carac(code)?.path const path = RdDCarac.carac(code)?.path
if (path == undefined) {
// cas des caractéristiques dérivées, pas de max
return false
}
if (value == undefined) { if (value == undefined) {
value = path ? foundry.utils.getProperty(actor, path) : 0 value = path ? foundry.utils.getProperty(actor, path) : 0
} }

View File

@ -743,13 +743,23 @@ export class RdDCombat {
this.attacker.createCallbackExperience(), this.attacker.createCallbackExperience(),
this.attacker.createCallbackAppelAuMoral(), this.attacker.createCallbackAppelAuMoral(),
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) }, { action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
{ action: async r => await this.attacker.incDecItemUse(arme._id, arme && !RdDCombat.isParticuliere(r)) }, { action: r => this._increaseItemUse(r, arme) },
{ action: r => this._onAttaque(r) }, { action: r => this._onAttaqueNormale(r) },
{ action: r => this._onAttaqueParticuliere(r) },
{ action: r => this._onAttaqueEchec(r) },
{ action: r => this._onAttaqueEchecTotal(r) },
] ]
}); });
dialog.render(true); dialog.render(true);
} }
_increaseItemUse(rollData, arme) {
if (!arme || RdDCombat.isParticuliere(rollData)) {
return
}
this.attacker.incDecItemUse(arme._id)
}
/* -------------------------------------------- */ /* -------------------------------------------- */
_prepareAttaque(competence, arme) { _prepareAttaque(competence, arme) {
let rollData = { let rollData = {
@ -780,23 +790,11 @@ export class RdDCombat {
return rollData; return rollData;
} }
async _onAttaque(attackerRoll) {
if (RdDCombat.isParticuliere(attackerRoll)) {
return await this._onAttaqueParticuliere(attackerRoll)
}
if (RdDCombat.isReussite(attackerRoll)) {
return await this._onAttaqueNormale(attackerRoll)
}
// if (RdDCombat.isParticuliere(attackerRoll) && attackerRoll.particuliere == undefined) {
// return
// }
if (RdDCombat.isEchecTotal(attackerRoll)) {
return await this._onAttaqueEchecTotal(attackerRoll)
}
return await this._onAttaqueEchec(attackerRoll)
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onAttaqueParticuliere(rollData) { async _onAttaqueParticuliere(rollData) {
if (!RdDCombat.isParticuliere(rollData)) {
return
}
const isMeleeDiffNegative = (rollData.competence.type == 'competencecreature' || rollData.selectedCarac.label == "Mêlée") && rollData.diffLibre < 0; const isMeleeDiffNegative = (rollData.competence.type == 'competencecreature' || rollData.selectedCarac.label == "Mêlée") && rollData.diffLibre < 0;
// force toujours, sauf empoignade // force toujours, sauf empoignade
// finesse seulement en mélée, pour l'empoignade, ou si la difficulté libre est de -1 minimum // finesse seulement en mélée, pour l'empoignade, ou si la difficulté libre est de -1 minimum
@ -834,6 +832,9 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onAttaqueNormale(attackerRoll) { async _onAttaqueNormale(attackerRoll) {
if (!RdDCombat.isReussite(attackerRoll) || RdDCombat.isParticuliere(attackerRoll)) {
return
}
console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll); console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll);
attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker, this.defender.isEntite()); attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker, this.defender.isEntite());
@ -848,7 +849,7 @@ export class RdDCombat {
return; return;
} }
if (this.defender) { if (this.target) {
await this._sendMessageDefense(attackerRoll, defenderRoll); await this._sendMessageDefense(attackerRoll, defenderRoll);
} }
} }
@ -950,6 +951,9 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onAttaqueEchecTotal(attackerRoll) { async _onAttaqueEchecTotal(attackerRoll) {
if (!RdDCombat.isEchecTotal(attackerRoll)) {
return
}
const choixEchecTotal = await ChatMessage.create({ const choixEchecTotal = await ChatMessage.create({
whisper: ChatUtility.getOwners(this.attacker), whisper: ChatUtility.getOwners(this.attacker),
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-etotal.hbs', { content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-etotal.hbs', {
@ -976,20 +980,26 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onAttaqueEchec(attackerRoll) { async _onAttaqueEchec(rollData) {
console.log("RdDCombat.onAttaqueEchec >>>", attackerRoll); if (!RdDCombat.isEchec(rollData)) {
await RdDRollResult.displayRollData(attackerRoll, this.attacker, 'chat-resultat-attaque.hbs'); return
}
console.log("RdDCombat.onAttaqueEchec >>>", rollData);
await RdDRollResult.displayRollData(rollData, this.attacker, 'chat-resultat-attaque.hbs');
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async choixParticuliere(rollData, choix) { async choixParticuliere(rollData, choix) {
console.log("RdDCombat.choixParticuliere >>>", rollData, choix); console.log("RdDCombat.choixParticuliere >>>", rollData, choix);
await this.attacker.incDecItemUse(rollData.arme.id, choix != "rapidite") if (choix != "rapidite") {
this.attacker.incDecItemUse(rollData.arme.id);
}
this.removeChatMessageActionsPasseArme(rollData.passeArme); this.removeChatMessageActionsPasseArme(rollData.passeArme);
rollData.particuliere = choix; rollData.particuliere = choix;
await this._onAttaqueNormale(rollData) await this._onAttaqueNormale(rollData);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -1013,8 +1023,10 @@ export class RdDCombat {
this.defender.createCallbackExperience(), this.defender.createCallbackExperience(),
this.defender.createCallbackAppelAuMoral(), this.defender.createCallbackAppelAuMoral(),
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) }, { action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
{ action: async r => await this.defender.incDecItemUse(armeParadeId, !RdDCombat.isParticuliere(r)) }, { condition: r => !RdDCombat.isParticuliere(r), action: r => this.defender.incDecItemUse(armeParadeId) },
{ action: r => this._onParade(r) }, { condition: RdDCombat.isReussite, action: r => this._onParadeNormale(r) },
{ condition: RdDCombat.isParticuliere, action: r => this._onParadeParticuliere(r) },
{ condition: RdDCombat.isEchec, action: r => this._onParadeEchec(r) },
] ]
}); });
dialog.render(true); dialog.render(true);
@ -1045,20 +1057,8 @@ export class RdDCombat {
return defenderRoll; return defenderRoll;
} }
async _onParade(defenderRoll) {
if (RdDCombat.isReussite(defenderRoll)) {
await this._onParadeNormale(defenderRoll)
if (RdDCombat.isParticuliere(defenderRoll)) {
await this._onParadeParticuliere(defenderRoll)
}
return
}
await this._onParadeEchec(defenderRoll)
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onParadeParticuliere(defenderRoll) { _onParadeParticuliere(defenderRoll) {
console.log("RdDCombat._onParadeParticuliere >>>", defenderRoll); console.log("RdDCombat._onParadeParticuliere >>>", defenderRoll);
if (!defenderRoll.attackerRoll.isPart) { if (!defenderRoll.attackerRoll.isPart) {
// TODO: attaquant doit jouer résistance et peut être désarmé p132 // TODO: attaquant doit jouer résistance et peut être désarmé p132
@ -1067,6 +1067,7 @@ export class RdDCombat {
this.defender) this.defender)
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onParadeNormale(defenderRoll) { async _onParadeNormale(defenderRoll) {
console.log("RdDCombat._onParadeNormale >>>", defenderRoll); console.log("RdDCombat._onParadeNormale >>>", defenderRoll);
@ -1105,9 +1106,11 @@ export class RdDCombat {
callbacks: [ callbacks: [
this.defender.createCallbackExperience(), this.defender.createCallbackExperience(),
this.defender.createCallbackAppelAuMoral(), this.defender.createCallbackAppelAuMoral(),
{ action: async r => await this.defender.incDecItemUse(esquive._id, !RdDCombat.isParticuliere(r)) }, { condition: r => !RdDCombat.isParticuliere(r), action: r => this.defender.incDecItemUse(esquive._id) },
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) }, { action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
{ action: r => this._onEsquive(r) }, { condition: RdDCombat.isReussite, action: r => this._onEsquiveNormale(r) },
{ condition: RdDCombat.isParticuliere, action: r => this._onEsquiveParticuliere(r) },
{ condition: RdDCombat.isEchec, action: r => this._onEsquiveEchec(r) },
] ]
}); });
dialog.render(true); dialog.render(true);
@ -1135,19 +1138,9 @@ export class RdDCombat {
return rollData; return rollData;
} }
async _onEsquive(defenderRoll) {
if (RdDCombat.isReussite(defenderRoll)) {
await this._onEsquiveNormale(defenderRoll)
if (RdDCombat.isParticuliere(defenderRoll)) {
await this._onEsquiveParticuliere(defenderRoll)
}
return
}
return await this._onEsquiveEchec(defenderRoll)
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onEsquiveParticuliere(defenderRoll) { _onEsquiveParticuliere(rollData) {
console.log("RdDCombat._onEsquiveParticuliere >>>", defenderRoll); console.log("RdDCombat._onEsquiveParticuliere >>>", rollData);
ChatUtility.createChatWithRollMode( ChatUtility.createChatWithRollMode(
{ content: "<strong>Vous pouvez esquiver une deuxième fois!</strong>" }, { content: "<strong>Vous pouvez esquiver une deuxième fois!</strong>" },
this.defender); this.defender);

View File

@ -104,8 +104,8 @@ export class SystemReveDeDragon {
this.RdDHotbar = RdDHotbar this.RdDHotbar = RdDHotbar
this.RdDStatBlockParser = RdDStatBlockParser this.RdDStatBlockParser = RdDStatBlockParser
this.itemClasses = { this.itemClasses = {
monnaie: items.RdDItemMonnaie, monnaie: items.RdDModelMonnaie,
munition: items.RdDItemMunition, munition: items.RdDModelMunition,
armure: RdDItemArmure, armure: RdDItemArmure,
blessure: RdDItemBlessure, blessure: RdDItemBlessure,
gemme: RdDItemGemme, gemme: RdDItemGemme,
@ -213,10 +213,8 @@ export class SystemReveDeDragon {
makeDefault: true makeDefault: true
}) })
sheets.RdDItemBaseSheet.registerAll( sheets.RdDItemSheet.register(sheets.RdDMonnaieSheet)
sheets.RdDMonnaieSheet, sheets.RdDItemSheet.register(sheets.RdDMunitionSheet)
sheets.RdDMunitionSheet
)
Items.registerSheet(SYSTEM_RDD, RdDItemSheetV1, { Items.registerSheet(SYSTEM_RDD, RdDItemSheetV1, {
types: [ types: [

View File

@ -104,8 +104,8 @@ export class RdDPossession {
rollData.selectedCarac = carac.reve rollData.selectedCarac = carac.reve
} }
else { else {
rollData.selectedCarac = rollingActor.system.carac.reve
rollData.forceCarac = { 'reve-actuel': { label: "Rêve Actuel", value: rollingActor.getReveActuel() } } rollData.forceCarac = { 'reve-actuel': { label: "Rêve Actuel", value: rollingActor.getReveActuel() } }
rollData.selectedCarac = rollData.forceCarac['reve-actuel']
rollData.competence.system.defaut_carac = 'reve-actuel' rollData.competence.system.defaut_carac = 'reve-actuel'
} }
} }

View File

@ -1,3 +1,4 @@
import { ChatUtility } from "./chat-utility.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDDice } from "./rdd-dice.js"; import { RdDDice } from "./rdd-dice.js";
import { ReglesOptionnelles } from "./settings/regles-optionnelles.js"; import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";

View File

@ -279,7 +279,7 @@ export class RdDRoll extends Dialog {
async setSelectedSort(sort) { async setSelectedSort(sort) {
this.rollData.selectedSort = sort; // Update the selectedCarac this.rollData.selectedSort = sort; // Update the selectedCarac
this.rollData.competence = RdDItemSort.getBestDraconicSort(this.rollData.draconicList, sort) this.rollData.competence = RdDItemCompetence.getVoieDraconic(this.rollData.draconicList, sort.system.draconic);
this.rollData.bonus = RdDItemSort.getCaseBonus(sort, this.rollData.tmr.coord); this.rollData.bonus = RdDItemSort.getCaseBonus(sort, this.rollData.tmr.coord);
this.rollData.diffLibre = RdDItemSort.getDifficulte(sort, -7); this.rollData.diffLibre = RdDItemSort.getDifficulte(sort, -7);
RdDItemSort.setCoutReveReel(sort); RdDItemSort.setCoutReveReel(sort);

View File

@ -3,11 +3,11 @@ import { RdDItem } from "./item.js";
export class RdDSheetUtility { export class RdDSheetUtility {
static getOptions(document, editable) { static mergeDocumentRights(options, document, editable) {
const userRightLevel = game.user.isGM const userRightLevel = game.user.isGM
? CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER ? CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER
: document.getUserLevel(game.user); : document.getUserLevel(game.user);
return { let newOptions = {
isGM: game.user.isGM, isGM: game.user.isGM,
isOwned: document.parent ? true : false, isOwned: document.parent ? true : false,
editable: editable, editable: editable,
@ -16,15 +16,10 @@ export class RdDSheetUtility {
isObserver: userRightLevel >= CONST.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER, isObserver: userRightLevel >= CONST.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER,
isOwner: userRightLevel >= CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER isOwner: userRightLevel >= CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER
} }
}
static mergeDocumentRights(options, document, editable) {
const newOptions = RdDSheetUtility.getOptions(document, editable);
foundry.utils.mergeObject(options, newOptions); foundry.utils.mergeObject(options, newOptions);
return options; return options;
} }
static getItem(event, actor) { static getItem(event, actor) {
return actor.items.get(RdDSheetUtility.getItemId(event)) return actor.items.get(RdDSheetUtility.getItemId(event))
} }

View File

@ -15,6 +15,7 @@ import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
import { RdDDice } from "./rdd-dice.js"; import { RdDDice } from "./rdd-dice.js";
import { STATUSES } from "./settings/status-effects.js"; import { STATUSES } from "./settings/status-effects.js";
import { RdDRencontre } from "./item/rencontre.js"; import { RdDRencontre } from "./item/rencontre.js";
import { RdDTimestamp } from "./time/rdd-timestamp.js";
import { ITEM_TYPES } from "./constants.js"; import { ITEM_TYPES } from "./constants.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
@ -82,7 +83,7 @@ export class RdDTMRDialog extends Dialog {
this.subdialog = undefined this.subdialog = undefined
this.displaySize = undefined this.displaySize = undefined
if (!this.viewOnly && !game.user.isGM) { if (!this.viewOnly && !game.user.isGM) {
this.$tellToGM(this.actor.name + " monte dans les terres médianes (" + tmrData.mode + ")"); this._tellToGM(this.actor.name + " monte dans les terres médianes (" + tmrData.mode + ")");
} }
this.callbacksOnAnimate = []; this.callbacksOnAnimate = [];
const displaySize = TMR_DISPLAY_SIZE.clamp(game.settings.get(SYSTEM_RDD, TMR_DISPLAY_SIZE.code) ?? TMR_DISPLAY_SIZE.def); const displaySize = TMR_DISPLAY_SIZE.clamp(game.settings.get(SYSTEM_RDD, TMR_DISPLAY_SIZE.code) ?? TMR_DISPLAY_SIZE.def);
@ -138,7 +139,7 @@ export class RdDTMRDialog extends Dialog {
this.cumulFatigue += this.fatigueParCase; this.cumulFatigue += this.fatigueParCase;
// Le reste... // Le reste...
this.$updateValuesDisplay(); this.updateValuesDisplay();
} }
lancerUnSort() { lancerUnSort() {
@ -189,7 +190,7 @@ export class RdDTMRDialog extends Dialog {
forceTMRContinueAction() { forceTMRContinueAction() {
ui.notifications.warn('Vous devez finir votre action avant de continuer dans les TMR'); ui.notifications.warn('Vous devez finir votre action avant de continuer dans les TMR');
this.bringSubDialogToTop(); this.bringSubDialogToTop();
return false return;
} }
setTMRPendingAction(dialog) { setTMRPendingAction(dialog) {
@ -296,7 +297,7 @@ export class RdDTMRDialog extends Dialog {
const coordOrig = this._getCoordActor(); const coordOrig = this._getCoordActor();
const coordTarget = TMRUtility.deplacement(coordOrig, move); const coordTarget = TMRUtility.deplacement(coordOrig, move);
await this._deplacerDemiReve(coordTarget, 'normal'); await this._deplacerDemiReve(coordTarget, 'normal');
await this.$checkQuitterTMR(); this.checkQuitterTMR();
} }
calculCoutMonteeTMR() { calculCoutMonteeTMR() {
@ -304,7 +305,7 @@ export class RdDTMRDialog extends Dialog {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async $updateValuesDisplay() { async updateValuesDisplay() {
if (this.viewOnly || !this.rendered) { if (this.viewOnly || !this.rendered) {
return; return;
} }
@ -335,31 +336,22 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async close() { async close() {
await this.$forceClose(this.actor.name + " a quitté les terres médianes")
}
async $forceClose(message) {
if (this.subdialog) { if (this.subdialog) {
this.forceTMRContinueAction() return this.forceTMRContinueAction()
return false
} }
this.descenteTMR = true; this.descenteTMR = true;
if (this.actor.tmrApp) { if (this.actor.tmrApp) {
this.actor.tmrApp = undefined // Cleanup reference this.actor.tmrApp = undefined; // Cleanup reference
const appliquerFatigue = ReglesOptionnelles.isUsing("appliquer-fatigue")
await this.actor.santeIncDec(
appliquerFatigue ? "fatigue" : "endurance",
(appliquerFatigue ? 1 : -1) * this.cumulFatigue)
if (!this.viewOnly) { if (!this.viewOnly) {
await this.actor.setEffect(STATUSES.StatusDemiReve, false) await this.actor.setEffect(STATUSES.StatusDemiReve, false)
this.$tellToUserAndGM(message) this._tellToGM(this.actor.name + " a quitté les terres médianes");
} }
await this.actor.santeIncDec((ReglesOptionnelles.isUsing("appliquer-fatigue") ? "fatigue" : "endurance"),
this.cumulFatigue)
} }
this.pixiTMR.close();
this.pixiTMR = undefined
await super.close(); await super.close();
return true this.pixiTMR.close()
this.pixiTMR = undefined
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -371,53 +363,48 @@ export class RdDTMRDialog extends Dialog {
} }
switch (action) { switch (action) {
case 'derober': case 'derober':
await this.$derober() await this.derober();
this.restoreTMRAfterAction() this.restoreTMRAfterAction();
return return;
case 'refouler': case 'refouler':
await this.$refouler() await this.refouler();
break break;
case 'maitriser': case 'maitriser':
await this.$maitriserRencontre() await this.maitriserRencontre();
break break;
case 'ignorer': case 'ignorer':
await this.$ignorerRencontre() await this.ignorerRencontre();
break break;
} }
await this.postRencontre(tmr); await this.postRencontre(tmr);
this.restoreTMRAfterAction(); this.restoreTMRAfterAction();
} }
async $derober() { async derober() {
if (this.currentRencontre) {
console.log("-> derober", this.currentRencontre); console.log("-> derober", this.currentRencontre);
await this.actor.addTMRRencontre(this.currentRencontre); await this.actor.addTMRRencontre(this.currentRencontre);
this.$forceClose(`${this.actor.name} s'est dérobé face à la rencontre ${this.currentRencontre.name}, et quitte les TMR.`) this._tellToGM(this.actor.name + " s'est dérobé et quitte les TMR.");
} this.close();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async $refouler() { async refouler() {
if (this.currentRencontre) {
console.log("-> refouler", this.currentRencontre); console.log("-> refouler", this.currentRencontre);
await this.actor.ajouterRefoulement(this.currentRencontre.system.refoulement, `${this.currentRencontre.system.genre == 'f' ? 'une' : 'un'} ${this.currentRencontre.name}`); await this.actor.ajouterRefoulement(this.currentRencontre.system.refoulement, `${this.currentRencontre.system.genre == 'f' ? 'une' : 'un'} ${this.currentRencontre.name}`);
await this.$deleteRencontreTMRAtPosition() await this.actor.deleteRencontreTMRAtPosition()
this.updateTokens(); this.updateTokens();
this.$updateValuesDisplay(); this.updateValuesDisplay();
this.$nettoyerRencontre(); this.nettoyerRencontre();
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async $ignorerRencontre() { async ignorerRencontre() {
if (this.currentRencontre) {
console.log("-> ignorer", this.currentRencontre); console.log("-> ignorer", this.currentRencontre);
this.$tellToGM(this.actor.name + " a ignoré: " + this.currentRencontre.name); this._tellToGM(this.actor.name + " a ignoré: " + this.currentRencontre.name);
await this.$deleteRencontreTMRAtPosition() await this.actor.deleteRencontreTMRAtPosition()
this.updateTokens(); this.updateTokens();
this.$updateValuesDisplay(); this.updateValuesDisplay();
this.$nettoyerRencontre(); this.nettoyerRencontre();
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -434,29 +421,41 @@ export class RdDTMRDialog extends Dialog {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async $checkQuitterTMR() { checkQuitterTMR() {
const reason = this.actor.isDead() if (this.actor.isDead()) {
? "est mort" this._tellToGM("Vous êtes mort : vous quittez les Terres médianes !");
: this.actor.isCumulFatigueCauseSommeil(this.cumulFatigue) this.close();
? "s'écroule de fatigue" return true;
: (this.actor.getReveActuel() == 0)
? "tombe à 0 Points de Rêve"
: undefined
if (reason) {
if (!this.actor.isDead()) {
await this.$refouler()
} }
this.$forceClose(`${this.actor.name} ${reason} et quitte les Terres médianes !`)
return true if (ReglesOptionnelles.isUsing("appliquer-fatigue")
? (this.actor.getFatigueRestante() <= this.cumulFatigue)
: (this.actor.getEnduranceActuelle() <= this.cumulFatigue)
) {
this._tellToGM("Vous vous écroulez de fatigue : vous quittez les Terres médianes !");
this.quitterLesTMRInconscient();
return true;
} }
return false
if (this.actor.getReveActuel() == 0) {
this._tellToGM("Vos Points de Rêve sont à 0 : vous quittez les Terres médianes !");
this.quitterLesTMRInconscient();
return true;
}
return false;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async $maitriserRencontre() { async quitterLesTMRInconscient() {
await this.refouler();
this.close();
}
/* -------------------------------------------- */
async maitriserRencontre() {
console.log("-> maitriser", this.currentRencontre); console.log("-> maitriser", this.currentRencontre);
await this.$deleteRencontreTMRAtPosition(); await this.actor.deleteRencontreTMRAtPosition()
this.updateTokens(); this.updateTokens();
let rencontreData = { let rencontreData = {
@ -471,21 +470,11 @@ export class RdDTMRDialog extends Dialog {
tmr: TMRUtility.getTMR(this._getCoordActor()) tmr: TMRUtility.getTMR(this._getCoordActor())
} }
await this.$tentativeMaitrise(rencontreData); await this._tentativeMaitrise(rencontreData);
}
async $deleteRencontreTMRAtPosition() {
const position = this.actor.getDemiReve()
const rencontreIds = this.actor.itemTypes[ITEM_TYPES.rencontre]
.filter(it => it.system.coord == position)
.map(it => it.id)
if (rencontreIds.length > 0) {
await this.actor.deleteEmbeddedDocuments('Item', rencontreIds)
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async $tentativeMaitrise(rencData) { async _tentativeMaitrise(rencData) {
this.rencontreState = 'normal'; this.rencontreState = 'normal';
rencData.reve = this.actor.getReveActuel(); rencData.reve = this.actor.getReveActuel();
@ -494,7 +483,7 @@ export class RdDTMRDialog extends Dialog {
RollDataAjustements.calcul(rencData, this.actor); RollDataAjustements.calcul(rencData, this.actor);
rencData.rolled = rencData.presentCite rencData.rolled = rencData.presentCite
? this.$rollPresentCite(rencData) ? this._rollPresentCite(rencData)
: await RdDResolutionTable.roll(rencData.reve, RollDataAjustements.sum(rencData.ajustements)); : await RdDResolutionTable.roll(rencData.reve, RollDataAjustements.sum(rencData.ajustements));
const result = rencData.rolled.isSuccess const result = rencData.rolled.isSuccess
@ -504,41 +493,38 @@ export class RdDTMRDialog extends Dialog {
await RdDRencontre.appliquer(result.effets, this, rencData); await RdDRencontre.appliquer(result.effets, this, rencData);
rencData.poesie = { extrait: result.poesie, reference: result.reference }; rencData.poesie = { extrait: result.poesie, reference: result.reference };
rencData.message = this.$formatMessageRencontre(rencData, result.message); rencData.message = this.formatMessageRencontre(rencData, result.message);
ChatMessage.create({ ChatMessage.create({
whisper: ChatUtility.getOwners(this.actor), whisper: ChatUtility.getOwners(this.actor),
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-rencontre-tmr.hbs`, rencData) content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-rencontre-tmr.hbs`, rencData)
}); });
this.$updateValuesDisplay(); this.updateValuesDisplay();
if (await this.$checkQuitterTMR()) { if (this.checkQuitterTMR()) {
return; return;
} }
if (this.rencontreState == 'persistant') { if (this.rencontreState == 'persistant') {
this.$nouvelleTentativeMaitrise(rencData); this._nouvelleTentativeMaitrise(rencData);
} }
else if (!this.isRencontreDeplacement()) { else if (!this.isRencontreDeplacement()) {
this.$nettoyerRencontre(); this.nettoyerRencontre();
} }
} }
$nouvelleTentativeMaitrise(rencData) { _nouvelleTentativeMaitrise(rencData) {
setTimeout(() => { setTimeout(() => {
/** // TODO: remplacer par une boucle while(this.currentRencontre) ?
* TODO: remplacer par une boucle while(this.currentRencontre) ?
* ajouter un moyen d'attendre la saisie de l'utilisateur (jet obligatoire)?
*/
rencData.nbRounds++; rencData.nbRounds++;
if (ReglesOptionnelles.isUsing("appliquer-fatigue")) { if (ReglesOptionnelles.isUsing("appliquer-fatigue")) {
this.cumulFatigue += this.fatigueParCase; this.cumulFatigue += this.fatigueParCase;
} }
this.$tentativeMaitrise(rencData); this._tentativeMaitrise(rencData);
this.$deleteTmrMessages(rencData.actor, rencData.nbRounds); this._deleteTmrMessages(rencData.actor, rencData.nbRounds);
}, 2000); }, 2000);
} }
$formatMessageRencontre(rencData, template) { formatMessageRencontre(rencData, template) {
let messageDuree = '' let messageDuree = ''
if (rencData.nbRounds > 1) { if (rencData.nbRounds > 1) {
if (rencData.rolled.isSuccess) { if (rencData.rolled.isSuccess) {
@ -557,7 +543,7 @@ export class RdDTMRDialog extends Dialog {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
$rollPresentCite(rencData) { _rollPresentCite(rencData) {
let rolled = RdDResolutionTable.computeChances(rencData.reve, 0); let rolled = RdDResolutionTable.computeChances(rencData.reve, 0);
foundry.utils.mergeObject(rolled, { caracValue: rencData.reve, finalLevel: 0, roll: rolled.score }); foundry.utils.mergeObject(rolled, { caracValue: rencData.reve, finalLevel: 0, roll: rolled.score });
RdDResolutionTable.succesRequis(rolled); RdDResolutionTable.succesRequis(rolled);
@ -565,7 +551,7 @@ export class RdDTMRDialog extends Dialog {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
$deleteTmrMessages(actor, nbRounds = -1) { _deleteTmrMessages(actor, nbRounds = -1) {
setTimeout(() => { setTimeout(() => {
if (nbRounds < 0) { if (nbRounds < 0) {
ChatUtility.removeChatMessageContaining(`<h4 data-categorie="tmr" data-actor-id="${actor._id}"`); ChatUtility.removeChatMessageContaining(`<h4 data-categorie="tmr" data-actor-id="${actor._id}"`);
@ -584,7 +570,7 @@ export class RdDTMRDialog extends Dialog {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
$tellToGM(message) { _tellToGM(message) {
ChatMessage.create({ ChatMessage.create({
user: game.user.id, user: game.user.id,
content: message, content: message,
@ -593,7 +579,7 @@ export class RdDTMRDialog extends Dialog {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
$tellToUserAndGM(message) { _tellToUserAndGM(message) {
ChatMessage.create({ ChatMessage.create({
user: game.user.id, user: game.user.id,
content: message, content: message,
@ -615,7 +601,7 @@ export class RdDTMRDialog extends Dialog {
if (this.currentRencontre) { if (this.currentRencontre) {
if (this.rencontresExistantes.find(it => it.id == this.currentRencontre.id)) { if (this.rencontresExistantes.find(it => it.id == this.currentRencontre.id)) {
// rencontre en attente suite à dérobade // rencontre en attente suite à dérobade
await this.$maitriserRencontre(); await this.maitriserRencontre();
} }
else { else {
const dialog = new RdDTMRRencontreDialog(this.actor, this.currentRencontre, tmr); const dialog = new RdDTMRRencontreDialog(this.actor, this.currentRencontre, tmr);
@ -662,7 +648,7 @@ export class RdDTMRDialog extends Dialog {
tmr: tmr, tmr: tmr,
presentCite: presentCite presentCite: presentCite
}; };
await this.$tentativeMaitrise(rencontreData); await this._tentativeMaitrise(rencontreData);
this.postRencontre(tmr); this.postRencontre(tmr);
} }
@ -741,7 +727,7 @@ export class RdDTMRDialog extends Dialog {
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-resultat-maitrise-tmr.hbs`, rollData) content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-resultat-maitrise-tmr.hbs`, rollData)
}); });
if (rollData.rolled.isEchec) { if (rollData.rolled.isEchec) {
await this.$forceClose(`n'a pas maîtrisé la case ${rollData.tmr.label} et quitte les terres médianes`) await this.close();
} }
await this.souffleSiEchecTotal(rollData); await this.souffleSiEchecTotal(rollData);
} }
@ -796,7 +782,7 @@ export class RdDTMRDialog extends Dialog {
onConqueteReussie: r => EffetsDraconiques.fermetureCites.onVisiteSupprimer(r.actor, tmr, (casetmr) => this.removeToken(tmr, casetmr)), onConqueteReussie: r => EffetsDraconiques.fermetureCites.onVisiteSupprimer(r.actor, tmr, (casetmr) => this.removeToken(tmr, casetmr)),
onConqueteEchec: r => { onConqueteEchec: r => {
this.souffleSiEchecTotal(rollData); this.souffleSiEchecTotal(rollData);
this.$forceClose(`${this.actor.name} n'a pas maîtrisé la ${tmr.label}, et quitte les TMR.`) this.close()
}, },
canClose: false canClose: false
}); });
@ -811,7 +797,7 @@ export class RdDTMRDialog extends Dialog {
onConqueteReussie: r => EffetsDraconiques.periple.onVisiteSupprimer(r.actor, tmr, (casetmr) => this.removeToken(tmr, casetmr)), onConqueteReussie: r => EffetsDraconiques.periple.onVisiteSupprimer(r.actor, tmr, (casetmr) => this.removeToken(tmr, casetmr)),
onConqueteEchec: r => { onConqueteEchec: r => {
this.souffleSiEchecTotal(rollData); this.souffleSiEchecTotal(rollData);
this.$forceClose(`${this.actor.name} n'a pas purifié la ${tmr.label}, et quitte les TMR.`) this.close()
}, },
canClose: false canClose: false
}); });
@ -825,7 +811,7 @@ export class RdDTMRDialog extends Dialog {
difficulte: -7, difficulte: -7,
action: 'Conquérir', action: 'Conquérir',
onConqueteReussie: r => EffetsDraconiques.conquete.onVisiteSupprimer(r.actor, tmr, (casetmr) => this.removeToken(tmr, casetmr)), onConqueteReussie: r => EffetsDraconiques.conquete.onVisiteSupprimer(r.actor, tmr, (casetmr) => this.removeToken(tmr, casetmr)),
onConqueteEchec: r => this.$forceClose(`${this.actor.name} n'a pas conquis la case ${tmr.label}, et quitte les TMR.`), onConqueteEchec: r => this.close(),
canClose: false canClose: false
}); });
} }
@ -936,15 +922,19 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async processSortReserve(sortReserve) { async processSortReserve(sortReserve) {
await this.actor.deleteEmbeddedDocuments('Item', [sortReserve.id]); await this.actor.deleteEmbeddedDocuments('Item', [sortReserve.id]);
console.log("declencheSortEnReserve", sortReserve) console.log("declencheSortEnReserve", sortReserve);
const sort = sortReserve.system.sortid ? this.actor.items.get(sortReserve.system.sortid) : undefined const heureCible = RdDTimestamp.definition(sortReserve.system.heurecible).label;
const message = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-lancement-sortreserve.hbs`, this._tellToUserAndGM(`Vous avez déclenché
{ sortReserve, sort }) ${sortReserve.system.echectotal ? "<strong>l'échec total!</strong>" : "le sort"}
await this.$forceClose(message) en réserve <strong>${sortReserve.name}</strong>
avec ${sortReserve.system.ptreve} points de Rêve
en ${sortReserve.system.coord} (${TMRUtility.getTMRLabel(sortReserve.system.coord)}).
L'heure ciblée est ${heureCible}`);
this.close();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
$nettoyerRencontre() { nettoyerRencontre() {
// Suppression des dessins des zones possibles // Suppression des dessins des zones possibles
this.currentRencontre?.graphics?.forEach(graphic => this.pixiTMR.removeGraphic(graphic)) this.currentRencontre?.graphics?.forEach(graphic => this.pixiTMR.removeGraphic(graphic))
// Nettoyage de la structureet de l'état // Nettoyage de la structureet de l'état
@ -1031,7 +1021,7 @@ export class RdDTMRDialog extends Dialog {
console.log("STATUS :", this.rencontreState, this.currentRencontre); console.log("STATUS :", this.rencontreState, this.currentRencontre);
} }
await this.$checkQuitterTMR(); this.checkQuitterTMR();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -1064,13 +1054,13 @@ export class RdDTMRDialog extends Dialog {
*/ */
this.notifierResonanceSigneDraconique(targetCoord); this.notifierResonanceSigneDraconique(targetCoord);
await this.actor.rollUnSort(targetCoord); await this.actor.rollUnSort(targetCoord);
this.$nettoyerRencontre(); this.nettoyerRencontre();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
externalRefresh() { externalRefresh() {
this.createPixiSprites(); this.createPixiSprites();
this.$updateValuesDisplay(); this.updateValuesDisplay();
this.updateTokens(); this.updateTokens();
console.log("TMR REFRESHED !!!"); console.log("TMR REFRESHED !!!");
} }
@ -1081,7 +1071,7 @@ export class RdDTMRDialog extends Dialog {
return this.forceTMRContinueAction() return this.forceTMRContinueAction()
} }
if (this.currentRencontre != 'normal') { if (this.currentRencontre != 'normal') {
this.$nettoyerRencontre(); this.nettoyerRencontre();
} }
let tmr = TMRUtility.getTMR(targetCoord); let tmr = TMRUtility.getTMR(targetCoord);
// Gestion cases spéciales type Trou noir, etc // Gestion cases spéciales type Trou noir, etc
@ -1093,7 +1083,7 @@ export class RdDTMRDialog extends Dialog {
if (ReglesOptionnelles.isUsing("appliquer-fatigue")) { if (ReglesOptionnelles.isUsing("appliquer-fatigue")) {
this.cumulFatigue += this.fatigueParCase; this.cumulFatigue += this.fatigueParCase;
} }
this.$updateValuesDisplay(); this.updateValuesDisplay();
this.actor.notifyRefreshTMR(); this.actor.notifyRefreshTMR();
if (deplacementType == 'normal') { // Pas de rencontres après un saut de type passeur/changeur/... if (deplacementType == 'normal') { // Pas de rencontres après un saut de type passeur/changeur/...

View File

@ -318,7 +318,6 @@ export class RdDUtility {
// gestion des dates et heures // gestion des dates et heures
Handlebars.registerHelper('timestamp-imgSigneHeure', (heure) => { return new Handlebars.SafeString(RdDTimestamp.imgSigneHeure(heure)) }); Handlebars.registerHelper('timestamp-imgSigneHeure', (heure) => { return new Handlebars.SafeString(RdDTimestamp.imgSigneHeure(heure)) });
Handlebars.registerHelper('timestamp-imgSigne', (heure) => { return new Handlebars.SafeString(RdDTimestamp.imgSigne(heure)) }); Handlebars.registerHelper('timestamp-imgSigne', (heure) => { return new Handlebars.SafeString(RdDTimestamp.imgSigne(heure)) });
Handlebars.registerHelper('timestamp-definition', (heure) => RdDTimestamp.definition(heure))
Handlebars.registerHelper('timestamp-extract', timestamp => new RdDTimestamp(timestamp).toCalendrier()); Handlebars.registerHelper('timestamp-extract', timestamp => new RdDTimestamp(timestamp).toCalendrier());
Handlebars.registerHelper('timestamp-formulesDuree', () => RdDTimestamp.formulesDuree()); Handlebars.registerHelper('timestamp-formulesDuree', () => RdDTimestamp.formulesDuree());
Handlebars.registerHelper('timestamp-formulesPeriode', () => RdDTimestamp.formulesPeriode()); Handlebars.registerHelper('timestamp-formulesPeriode', () => RdDTimestamp.formulesPeriode());

View File

@ -3,9 +3,9 @@ import { Draconique } from "./draconique.js";
import { PixiTMR } from "./pixi-tmr.js"; import { PixiTMR } from "./pixi-tmr.js";
const IMAGE_CARTE_TMR = 'image-carte-tmr'; const IMAGE_CARTE_TMR = 'image-carte-tmr';
const TMR_V1 = "systems/foundryvtt-reve-de-dragon/assets/ui/tmr-v1.webp"; const TMR_V1 = "systems/foundryvtt-reve-de-dragon/styles/img/ui/tmr-v1.webp";
const TMR_V2 = "systems/foundryvtt-reve-de-dragon/assets/ui/tmr-v2.webp"; const TMR_V2 = "systems/foundryvtt-reve-de-dragon/styles/img/ui/tmr-v2.webp";
const TMR_V3_COULEUR = "systems/foundryvtt-reve-de-dragon/assets/ui/tmr-v3-couleur.webp"; const TMR_V3_COULEUR = "systems/foundryvtt-reve-de-dragon/styles/img/ui/tmr-v3-couleur.webp";
export class CarteTmr extends Draconique { export class CarteTmr extends Draconique {

View File

@ -1,37 +1,14 @@
{ {
"name": "foundryvtt-reve-de-dragon",
"description": "<h2><em>Rêve de Dragon</em> pour Foundry Virtual TableTop</h2>",
"private": true,
"version": "1.0.0",
"license": "Creative Commons",
"main": "gulpfile.js",
"scripts": { "scripts": {
"build": "npx vite build", "build": "npx vite build",
"gulp": "gulp",
"run": "npx vite serve",
"packCompendiumsToDist": "node ./tools/packCompendiumsToDist.mjs", "packCompendiumsToDist": "node ./tools/packCompendiumsToDist.mjs",
"packCompendiumsToPublic": "node ./tools/packCompendiumsToPublic.mjs", "packCompendiumsToPublic": "node ./tools/packCompendiumsToPublic.mjs",
"unpackCompendiumsFromPublic": "node ./tools/unpackCompendiumsFromPublic.mjs" "unpackCompendiumsFromPublic": "node ./tools/unpackCompendiumsFromPublic.mjs"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.8.0", "@foundryvtt/foundryvtt-cli": "^1.0.3"
"@foundryvtt/foundryvtt-cli": "^1.0.3",
"commander": "^11.1.0",
"eslint": "^9.9.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsdoc": "^48.11.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.9.0",
"less": "^4.1.3",
"prettier": "^3.3.3"
}, },
"dependencies": { "dependencies": {
"gulp": "^5.0.0",
"gulp-less": "^5.0.0",
"rollup-plugin-visualizer": "^5.12.0" "rollup-plugin-visualizer": "^5.12.0"
},
"repository": {
"type": "git",
"url": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon.git"
} }
} }

View File

@ -196,7 +196,7 @@ system:
derivee: false derivee: false
protection: protection:
type: number type: number
value: 10 value: 2
label: Protection label: Protection
derivee: false derivee: false
compteurs: compteurs:

View File

@ -2,7 +2,7 @@ name: Terres médianes du rêve
type: script type: script
scope: global scope: global
author: Hp9ImM4o9YRTSdfu author: Hp9ImM4o9YRTSdfu
img: systems/foundryvtt-reve-de-dragon/assets/ui/icon-tmr-normal.svg img: systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-normal.svg
command: |- command: |-
const selected = game.system.rdd.RdDUtility.getSelectedActor(); const selected = game.system.rdd.RdDUtility.getSelectedActor();
if (!selected) { if (!selected) {
@ -18,8 +18,8 @@ command: |-
title: `Monter dans les TMR`, title: `Monter dans les TMR`,
content: `Monter dans les TMR`, content: `Monter dans les TMR`,
buttons: { buttons: {
normale: { label: `normale`, icon: `<img class="button-img" src="systems/foundryvtt-reve-de-dragon/assets/ui/icon-tmr-normal.svg" alt="Montée dans les Terres M&eacute;dianes !"/>`, callback: () => selected.displayTMR("normal") }, normale: { label: `normale`, icon: `<img class="button-img" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-normal.svg" alt="Montée dans les Terres M&eacute;dianes !"/>`, callback: () => selected.displayTMR("normal") },
rapide: { label: `rapide`, icon: `<img class="button-img" src="systems/foundryvtt-reve-de-dragon/assets/ui/icon-tmr-rapide.svg" alt="Montée accélérée dans les Terres M&eacute;dianes !"/>`, callback: () => selected.displayTMR("rapide") }, rapide: { label: `rapide`, icon: `<img class="button-img" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-rapide.svg" alt="Montée accélérée dans les Terres M&eacute;dianes !"/>`, callback: () => selected.displayTMR("rapide") },
}, },
}); });

View File

@ -5,7 +5,7 @@ sort: 0
pages: pages:
- name: 'Figure: Documentation MJ/Joueurs' - name: 'Figure: Documentation MJ/Joueurs'
type: image type: image
src: systems/foundryvtt-reve-de-dragon/assets/logo.webp src: systems/foundryvtt-reve-de-dragon/styles/img/logo.webp
title: title:
show: false show: false
level: 1 level: 1
@ -94,9 +94,9 @@ pages:
<li><img style="background-color:purple;vertical-align:middle" src="icons/svg/bones.svg" width="25" height="30" /> Encaisser des dommages</li> <li><img style="background-color:purple;vertical-align:middle" src="icons/svg/bones.svg" width="25" height="30" /> Encaisser des dommages</li>
<li><img style="background-color:purple;vertical-align:middle" src="icons/svg/regen.svg" width="25" height="30" /> Remise à neuf (Uniquement pour le MJ) pour enlever toutes les blessures/états du personnage.</li> <li><img style="background-color:purple;vertical-align:middle" src="icons/svg/regen.svg" width="25" height="30" /> Remise à neuf (Uniquement pour le MJ) pour enlever toutes les blessures/états du personnage.</li>
<li><img style="background-color:purple;vertical-align:middle" src="icons/svg/sleep.svg" width="25" height="30" /> Le sommeil (dormir une heure, une nuit, gris rêve)</li> <li><img style="background-color:purple;vertical-align:middle" src="icons/svg/sleep.svg" width="25" height="30" /> Le sommeil (dormir une heure, une nuit, gris rêve)</li>
<li><img style="background-color:purple;vertical-align:middle" src="systems/foundryvtt-reve-de-dragon/assets/ui/icon-tmr-normal.svg" width="25" height="30" /> Montée dans les Terres Médianes</li> <li><img style="background-color:purple;vertical-align:middle" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-normal.svg" width="25" height="30" /> Montée dans les Terres Médianes</li>
<li><img style="background-color:purple;vertical-align:middle" src="systems/foundryvtt-reve-de-dragon/assets/ui/icon-tmr-rapide.svg" width="25" height="30" /> Montée rapide</li> <li><img style="background-color:purple;vertical-align:middle" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-rapide.svg" width="25" height="30" /> Montée rapide</li>
<li><img style="background-color:purple;vertical-align:middle" src="systems/foundryvtt-reve-de-dragon/assets/ui/icon-tmr-view.svg" width="25" height="30" /> Regarder ses terres médianes (sans monter)</li> <li><img style="background-color:purple;vertical-align:middle" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-view.svg" width="25" height="30" /> Regarder ses terres médianes (sans monter)</li>
</ul> </ul>
<h1>Combat</h1> <h1>Combat</h1>
<p>Pour l'initiative et les attaques, des options sont disponibles <p>Pour l'initiative et les attaques, des options sont disponibles
@ -171,7 +171,7 @@ pages:
<li>Les retours que vous nous ferez via <a href="https://discord.gg/pPSDNJk">discord</a> <li>Les retours que vous nous ferez via <a href="https://discord.gg/pPSDNJk">discord</a>
(channel #rêve-de-dragon) ;-)</li> (channel #rêve-de-dragon) ;-)</li>
</ul> </ul>
<p><img style="border:0;display:block;margin-left:auto;margin-right:auto" src="systems/foundryvtt-reve-de-dragon/assets/rdd_pause.webp" width="210" height="216" /></p> <p><img style="border:0;display:block;margin-left:auto;margin-right:auto" src="systems/foundryvtt-reve-de-dragon/styles/img/rdd_pause.webp" width="210" height="216" /></p>
_id: p0xOSy6tZwU4DOq5 _id: p0xOSy6tZwU4DOq5
image: {} image: {}
video: video:

View File

@ -5,7 +5,7 @@ sort: 0
pages: pages:
- name: 'Figure: Passeur fou' - name: 'Figure: Passeur fou'
type: image type: image
src: systems/foundryvtt-reve-de-dragon/assets/ui/tmp_main_r1.webp src: systems/foundryvtt-reve-de-dragon/styles/img/ui/tmp_main_r1.webp
title: title:
show: false show: false
level: 1 level: 1

View File

@ -5,7 +5,7 @@ sort: 0
pages: pages:
- name: 'Figure: Tourbillon rouge' - name: 'Figure: Tourbillon rouge'
type: image type: image
src: systems/foundryvtt-reve-de-dragon/assets/ui/tmp_main_r1.webp src: systems/foundryvtt-reve-de-dragon/styles/img/ui/tmp_main_r1.webp
title: title:
show: false show: false
level: 1 level: 1

View File

@ -1,6 +1,6 @@
name: Rêve de Dragon name: Rêve de Dragon
type: rencontre type: rencontre
img: systems/foundryvtt-reve-de-dragon/assets/rdd_pause.webp img: systems/foundryvtt-reve-de-dragon/styles/img/rdd_pause.webp
system: system:
description: '' description: ''
descriptionmj: '' descriptionmj: ''

View File

@ -38,7 +38,7 @@ regions: []
ownership: ownership:
default: 0 default: 0
background: background:
src: systems/foundryvtt-reve-de-dragon/assets/ecran_rdd.webp src: systems/foundryvtt-reve-de-dragon/styles/img/ecran_rdd.webp
offsetX: 0 offsetX: 0
offsetY: 0 offsetY: 0
anchorX: 0 anchorX: 0

4
styles/img/.directory Normal file
View File

@ -0,0 +1,4 @@
[Dolphin]
Timestamp=2020,11,21,13,59,38
Version=4
VisibleRoles=Details_text,Details_size,Details_modificationtime,Details_creationtime,CustomizedDetails

View File

Before

Width:  |  Height:  |  Size: 193 KiB

After

Width:  |  Height:  |  Size: 193 KiB

View File

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

View File

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 163 KiB

View File

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 103 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 716 KiB

After

Width:  |  Height:  |  Size: 716 KiB

View File

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

5
styles/img/ui/.directory Normal file
View File

@ -0,0 +1,5 @@
[Dolphin]
HeaderColumnWidths=634,87,118
Timestamp=2020,6,10,17,19,0
Version=4
ViewMode=1

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Some files were not shown because too many files have changed in this diff Show More