Gestion des signes draconiques #455
@ -171,8 +171,8 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getReveActuel() {
|
||||
const actorData = Misc.data(this);
|
||||
return Misc.toInt(actorData.data.reve?.reve?.value ?? actorData.data.carac.reve.value);
|
||||
const templateData = Misc.templateData(this);
|
||||
return Misc.toInt(templateData.reve?.reve?.value ?? templateData.carac.reve.value);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getChanceActuel() {
|
||||
@ -1613,6 +1613,12 @@ export class RdDActor extends Actor {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
appliquerExperience(rollData) {
|
||||
const callback = this.createCallbackExperience();
|
||||
if (callback.condition(rollData)) { callback.action(rollData); }
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
createCallbackExperience() {
|
||||
return {
|
||||
@ -1948,6 +1954,32 @@ export class RdDActor extends Actor {
|
||||
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-general.html');
|
||||
}
|
||||
|
||||
async rollCaracCompetence(caracName, compName, diff) {
|
||||
const carac = this.getCaracByName(caracName);
|
||||
if (!carac) {
|
||||
ui.notifications.warn(`${this.name} n'a pas de caractéristique correspondant à ${caracName}`)
|
||||
return;
|
||||
}
|
||||
const competence = this.getCompetence(compName);
|
||||
if (compName && !competence) {
|
||||
ui.notifications.warn(`${this.name} n'a pas de compétence correspondant à ${compName}`)
|
||||
return;
|
||||
}
|
||||
let rollData = {
|
||||
alias: this.name,
|
||||
caracValue: Number(carac.value),
|
||||
selectedCarac: carac,
|
||||
competence: competence,
|
||||
finalLevel: (competence?.data.niveau??0) + diff,
|
||||
diffLibre: diff,
|
||||
showDice: true,
|
||||
show: { title: "Jets multiples" }
|
||||
};
|
||||
await RdDResolutionTable.rollData(rollData);
|
||||
this.appliquerExperience(rollData);
|
||||
RdDResolutionTable.displayRollData( rollData, this )
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollCompetence(name) {
|
||||
let rollData = { competence: this.getCompetence(name) }
|
||||
@ -2380,19 +2412,29 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _findCaracByName(carac, name) {
|
||||
name = name.toLowerCase();
|
||||
name = Grammar.toLowerCaseNoAccent(name);
|
||||
switch (name) {
|
||||
case 'reve-actuel': case 'rêve actuel':
|
||||
return carac.reve;
|
||||
case 'chance-actuelle': case 'chance actuelle':
|
||||
return carac.chance;
|
||||
}
|
||||
for (const [key, value] of Object.entries(carac)) {
|
||||
if (name == key || name == value.label.toLowerCase()) {
|
||||
return carac[key];
|
||||
const keys = Object.entries(carac)
|
||||
.filter(it => it[0].includes(name) || Grammar.toLowerCaseNoAccent(it[1].label).includes(name))
|
||||
.map(it => it[0]);
|
||||
if (keys.length>1){
|
||||
const names = keys.reduce((a, b) => `${a}<br>${b}`);
|
||||
ui.notifications.info(`Plusieurs caractéristiques possibles:<br>${names}<br>La première sera choisie.`);
|
||||
}
|
||||
if (keys.length>0){
|
||||
return carac[keys[0]];
|
||||
}
|
||||
return carac[name]; // Per default
|
||||
// for (const [key, value] of Object.entries(carac)) {
|
||||
// if (key.includes(name) || Grammar.toLowerCaseNoAccent(value.label).includes('name')) {
|
||||
// return carac[key];
|
||||
// }
|
||||
// }
|
||||
return undefined; // Per default
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -3070,22 +3112,20 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
_deleteStatusEffectsByIds(effectIds, options) {
|
||||
this.deleteEmbeddedEntity('ActiveEffect', effectIds, options);
|
||||
this.applyActiveEffects();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addStatusEffectById(id, options = { renderSheet: true }) {
|
||||
async addStatusEffectById(id, options = { renderSheet: false }) {
|
||||
const statusEffect = CONFIG.statusEffects.find(it => it.id == id);
|
||||
await this.addStatusEffect(statusEffect, options);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addStatusEffect(statusEffect, options = { renderSheet: true }) {
|
||||
async addStatusEffect(statusEffect, options = { renderSheet: false }) {
|
||||
this.deleteStatusEffectById(statusEffect.id, options);
|
||||
const effet = duplicate(statusEffect);
|
||||
effet["flags.core.statusId"] = effet.id;
|
||||
await this.createEmbeddedEntity('ActiveEffect', effet, options);
|
||||
this.applyActiveEffects();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { Grammar } from "./grammar.js";
|
||||
|
||||
const competenceTroncs = [["Esquive", "Dague", "Corps à corps"],
|
||||
["Epée à 1 main", "Epée à 2 mains", "Hache à 1 main", "Hache à 2 mains", "Lance", "Masse à 1 main", "Masse à 2 mains"]];
|
||||
|
||||
@ -183,8 +185,17 @@ export class RdDItemCompetence extends Item {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static findCompetence(list, name) {
|
||||
name = name.toLowerCase();
|
||||
return list.find(it => it.name.toLowerCase() == name && (it.type == "competence" || it.type == "competencecreature"))
|
||||
name = Grammar.toLowerCaseNoAccent(name);
|
||||
const competences = list.filter(it => Grammar.toLowerCaseNoAccent(it.name).includes(name) && (it.type == "competence" || it.type == "competencecreature"));
|
||||
if (competences.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
const competence = competences[0];
|
||||
if (competences.length>1) {
|
||||
const names = competences.map(it => it.name).reduce((a, b) => `${a}<br>${b}`);
|
||||
ui.notifications.info(`Plusieurs compétences possibles:<br>${names}<br>La première sera choisie: ${competence.name}`);
|
||||
}
|
||||
return competence;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -11,9 +11,9 @@ import { RdDRollResolutionTable } from "./rdd-roll-resolution-table.js";
|
||||
import { RdDRollTables } from "./rdd-rolltables.js";
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
import { TMRRencontres } from "./tmr-rencontres.js";
|
||||
import { TMRType, TMRUtility } from "./tmr-utility.js";
|
||||
import { TMRUtility } from "./tmr-utility.js";
|
||||
|
||||
const rddRollNumeric = /(\d+)\s*([\+\-]?\d+)?\s*(s)?/;
|
||||
const rddRollNumeric = /$(\d+)\s*([\+\-]?\d+)?\s*(s)?/;
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class RdDCommands {
|
||||
@ -64,9 +64,11 @@ export class RdDCommands {
|
||||
descr: `Effectue un jet de dés dans la table de résolution. Exemples:
|
||||
<br><strong>/rdd</strong> ouvre la table de résolution
|
||||
<br><strong>/rdd 10 3</strong> effectue un jet 10 à +3
|
||||
<br><strong>/rdd 10 +2</strong> effectue un jet 10 à +2
|
||||
<br><strong>/rdd 15 -2</strong> effectue un jet 15 à -2
|
||||
<br><strong>/rdd 15 0 s</strong> effectue un jet 15 à 0, avec significative requise`
|
||||
<br><strong>/rdd 15 0 s</strong> effectue un jet 15 à 0, avec significative requise
|
||||
<br><strong>/rdd Vue Vigilance -2</strong> effectue un jet de Vue/Vigilance à -2 pour les tokens sélectionnés
|
||||
<br><strong>/rdd vol déser +2</strong> effectue un jet de Volonté/Survie en désert à +2 pour les tokens sélectionnés
|
||||
`
|
||||
});
|
||||
rddCommands.registerCommand({ path: ["/ddr"], func: (content, msg, params) => rddCommands.rollDeDraconique(msg), descr: "Lance un Dé Draconique" });
|
||||
|
||||
@ -217,6 +219,27 @@ export class RdDCommands {
|
||||
await this.rollRdDNumeric(msg, carac, diff, significative);
|
||||
return;
|
||||
}
|
||||
|
||||
let actors = canvas.tokens.controlled.map(it => it.actor).filter(it => it);
|
||||
if (actors && actors.length > 0){
|
||||
let length = params.length;
|
||||
let diff = Number(params[length-1]);
|
||||
if (Number.isInteger(Number(diff))){
|
||||
length --;
|
||||
}
|
||||
else {
|
||||
diff = 0;
|
||||
}
|
||||
const caracName = params[0];
|
||||
const compName = length>1 ? params.slice(1, length).reduce((a, b) => `${a} ${b}`): undefined;
|
||||
for (let actor of actors) {
|
||||
await actor.rollCaracCompetence(caracName, compName, diff);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else{
|
||||
ui.notifications.warn("Sélectionnez au moins un personnage pour lancer les dés")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user