Corrections signes draconiques

This commit is contained in:
Vincent Vandemeulebrouck 2021-05-18 19:51:12 +02:00
parent 8fb69b0bc5
commit a48f76e8eb
8 changed files with 26 additions and 27 deletions

View File

@ -2557,16 +2557,17 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollMeditation(id) { async rollMeditation(id) {
let meditation = Misc.data(this.getMeditation(id)); const meditation = duplicate(Misc.data(this.getMeditation(id)));
const competence = duplicate(Misc.data(this.getCompetence(meditation.data.competence)));
competence.data.defaut_carac = "intellect"; // Meditation = toujours avec intellect
let meditationData = { let meditationData = {
competence: duplicate(Misc.data(this.getCompetence(meditation.data.competence))), competence: competence,
meditation: duplicate(meditation), meditation: meditation,
conditionMeditation: { isHeure: false, isVeture: false, isComportement: false, isPurification: false }, conditionMeditation: { isHeure: false, isVeture: false, isComportement: false, isPurification: false },
diffConditions: 0, diffConditions: 0,
use: { libre: false, conditions: true, }, use: { libre: false, conditions: true, },
carac: { "intellect": Misc.templateData(this).carac.intellect } carac: { "intellect": Misc.templateData(this).carac.intellect }
}; };
meditationData.competence.data.defaut_carac = "intellect"; // Meditation = tjs avec intellect
const dialog = await RdDRoll.create(this, meditationData, const dialog = await RdDRoll.create(this, meditationData,
{ {

View File

@ -8,7 +8,7 @@ import { TMRType, TMRUtility } from "./tmr-utility.js";
export class DialogCreateSigneDraconique extends Dialog { export class DialogCreateSigneDraconique extends Dialog {
static async createSigneForActors() { static async createSigneForActors() {
const signe = await RdDItemSigneDraconique.randomSigneDraconique(); const signe = await RdDItemSigneDraconique.randomSigneDraconique({ephemere: true});
let dialogData = { let dialogData = {
signe: signe, signe: signe,
tmrs: TMRUtility.listSelectedTMR(signe.data.typesTMR ?? []), tmrs: TMRUtility.listSelectedTMR(signe.data.typesTMR ?? []),
@ -76,7 +76,7 @@ export class DialogCreateSigneDraconique extends Dialog {
html.find(".signe-xp-sort").change((event) => this.onValeurXpSort(event)); html.find(".signe-xp-sort").change((event) => this.onValeurXpSort(event));
} }
async setSigneAleatoire() { async setSigneAleatoire() {
const newSigne = await RdDItemSigneDraconique.randomSigneDraconique(); const newSigne = await RdDItemSigneDraconique.randomSigneDraconique({ephemere: true});
$("[name='signe.name']").val(newSigne.name); $("[name='signe.name']").val(newSigne.name);
$("[name='signe.data.valeur.norm']").val(newSigne.data.valeur.norm); $("[name='signe.data.valeur.norm']").val(newSigne.data.valeur.norm);

View File

@ -67,15 +67,6 @@ export class RdDSigneDraconiqueItemSheet extends ItemSheet {
async setSigneAleatoire() { async setSigneAleatoire() {
const newSigne = await RdDItemSigneDraconique.randomSigneDraconique(); const newSigne = await RdDItemSigneDraconique.randomSigneDraconique();
// $("[name='signe.name']").val(newSigne.name);
// $("[name='signe.data.valeur.norm']").val(newSigne.data.valeur.norm);
// $("[name='signe.data.valeur.sign']").val(newSigne.data.valeur.sign);
// $("[name='signe.data.valeur.part']").val(newSigne.data.valeur.part);
// $("[name='signe.data.difficulte']").val(newSigne.data.difficulte);
// $("[name='signe.data.duree']").val(newSigne.data.duree);
// $("[name='signe.data.ephemere']").prop("checked", newSigne.data.ephemere);
// $(".select-tmr").val(newSigne.data.typesTMR);
// this.setEphemere(newSigne.data.ephemere);
this.object.update(newSigne); this.object.update(newSigne);
} }

View File

@ -1,7 +1,8 @@
import { defaultItemImg } from "./item.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDDice } from "./rdd-dice.js"; import { RdDDice } from "./rdd-dice.js";
import { RdDRollTables } from "./rdd-rolltables.js"; import { RdDRollTables } from "./rdd-rolltables.js";
import { TMRType } from "./tmr-utility.js"; import { TMRType, TMRUtility } from "./tmr-utility.js";
const tableSignesIndicatifs = [ const tableSignesIndicatifs = [
{ rarete: "Très facile", difficulte: 0, xp: 6, nbCases: 14 }, { rarete: "Très facile", difficulte: 0, xp: 6, nbCases: 14 },
@ -11,6 +12,7 @@ const tableSignesIndicatifs = [
{ rarete: "Ardu", difficulte: -8, xp: 30, nbCases: 1 } { rarete: "Ardu", difficulte: -8, xp: 30, nbCases: 1 }
] ]
export class RdDItemSigneDraconique { export class RdDItemSigneDraconique {
static prepareSigneDraconiqueMeditation(meditation, rolled) { static prepareSigneDraconiqueMeditation(meditation, rolled) {
@ -21,11 +23,11 @@ export class RdDItemSigneDraconique {
type: "signedraconique", type: "signedraconique",
img: meditation.img, img: meditation.img,
data: { data: {
"typesTMR": [Misc.upperFirst(meditation.data.tmr)], typesTMR: [TMRUtility.typeTmrName(meditation.data.tmr)],
"difficulte": RdDItemSigneDraconique.getDiffSigneMeditation(rolled.code), difficulte: RdDItemSigneDraconique.getDiffSigneMeditation(rolled.code),
"ephemere": true, ephemere: true,
"duree": "1 round", duree: "1 round",
"valeur": { "norm": 3, "sign": 5, "part": 10 } valeur: { "norm": 3, "sign": 5, "part": 10 }
} }
}; };
} }
@ -68,15 +70,15 @@ export class RdDItemSigneDraconique {
} }
} }
static async randomSigneDraconique() { static async randomSigneDraconique(options = { ephemere: undefined }) {
let modele = await RdDDice.rollOneOf(tableSignesIndicatifs); let modele = await RdDDice.rollOneOf(tableSignesIndicatifs);
return { return {
name: await RdDItemSigneDraconique.randomSigneDescription(), name: await RdDItemSigneDraconique.randomSigneDescription(),
type: "signedraconique", type: "signedraconique",
img: 'systems/foundryvtt-reve-de-dragon/icons/tmr/signe_draconique.webp', img: defaultItemImg.signedraconique,
data: { data: {
typesTMR: await RdDItemSigneDraconique.randomTmrs(modele.nbCases), typesTMR: await RdDItemSigneDraconique.randomTmrs(modele.nbCases),
ephemere: true, ephemere: options?.ephemere == undefined ? RdDDice.rollTotal("1d2") == 2 : options.ephemere,
duree: "1 round", duree: "1 round",
difficulte: modele.difficulte, difficulte: modele.difficulte,
valeur: { norm: modele.xp, sign: modele.xp, part: Math.floor(modele.xp * 1.5) }, valeur: { norm: modele.xp, sign: modele.xp, part: Math.floor(modele.xp * 1.5) },
@ -85,7 +87,8 @@ export class RdDItemSigneDraconique {
} }
static async randomTmrs(nbTmr = undefined) { static async randomTmrs(nbTmr = undefined) {
let tmrs = Object.values(TMRType).map(value => Misc.upperFirst(value.name)); let tmrs = Object.values(TMRType)
.map(value => TMRUtility.typeTmrName(value.name));
let keep = nbTmr ?? (await RdDDice.rollTotal("1d" + TMRType.length) + 1); let keep = nbTmr ?? (await RdDDice.rollTotal("1d" + TMRType.length) + 1);
for (let i = tmrs.length; i > keep; i--) { for (let i = tmrs.length; i > keep; i--) {
tmrs.splice(await RdDDice.rollTotal("1d" + i), 1); tmrs.splice(await RdDDice.rollTotal("1d" + i), 1);

View File

@ -218,6 +218,7 @@ export class RdDUtility {
Handlebars.registerHelper('buildConteneur', (objet) => { return RdDUtility.buildConteneur(objet); }); Handlebars.registerHelper('buildConteneur', (objet) => { return RdDUtility.buildConteneur(objet); });
Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord)); Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord));
Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord)); Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord));
Handlebars.registerHelper('typeTmr-name', coord => TMRUtility.typeTmrName(coord));
Handlebars.registerHelper('equals', (a, b) => a == b); Handlebars.registerHelper('equals', (a, b) => a == b);
return loadTemplates(templatePaths); return loadTemplates(templatePaths);

View File

@ -347,6 +347,9 @@ export class TMRUtility {
return Grammar.articleDetermine(tmr.type) + ' ' + tmr.label; return Grammar.articleDetermine(tmr.type) + ' ' + tmr.label;
} }
static typeTmrName(type){
return Misc.upperFirst(TMRType[Grammar.toLowerCaseNoAccent(type)].name);
}
static listSelectedTMR(typesTMR) { static listSelectedTMR(typesTMR) {
return Object.values(TMRType).map(value => Misc.upperFirst(value.name)) return Object.values(TMRType).map(value => Misc.upperFirst(value.name))
.sort() .sort()

View File

@ -6,7 +6,7 @@
<hr> <hr>
<div> <div>
{{#if rolled.isSuccess}} {{#if rolled.isSuccess}}
Vous apercevez un signe draconique éphémère, qu'il faut aller lire en <strong>{{meditation.data.tmr}}</strong>. Vous apercevez un signe draconique éphémère, qu'il faut aller lire en <strong>{{typeTmr-name meditation.data.tmr}}</strong>.
{{else}} {{else}}
Votre méditation ne porte pas ses fruits, vous ne voyez aucun signe Draconique. Votre méditation ne porte pas ses fruits, vous ne voyez aucun signe Draconique.
{{/if}} {{/if}}

View File

@ -7,7 +7,7 @@
<label><strong>{{meditation.data.theme}}</strong></label> <label><strong>{{meditation.data.theme}}</strong></label>
<hr> <hr>
<label>Support: <strong>{{upperFirst meditation.data.support}}</strong></label> <label>Support: <strong>{{upperFirst meditation.data.support}}</strong></label>
<label>Case TMR: <strong>{{upperFirst meditation.data.tmr}}</strong></label> <label>Case TMR: <strong>{{typeTmr-name meditation.data.tmr}}</strong></label>
<label>Durée: 60 minutes</label> <label>Durée: 60 minutes</label>
<hr> <hr>
<label>Intellect / {{competence.name}}: <label>Intellect / {{competence.name}}: