Jets de masse
Quelques exemples: - `/rdd dexterite bricolage -2` - `/rdd vue survie en sous-sol -2` - `/rdd vue désert 0` - `/rdd vue vigi -3` - `/rdd vol vigi 0` : Volonté Vigilance - `/rdd chance-actuelle 0` - `/rdd reve-actuel -8` Attention: - `/rdd vue vig 0` => Navigation et Vigilance correspondent, c'est Navigation qui est pris (premier dans l'ordre alphabétique), avec un message.
This commit is contained in:
parent
d95a0ebfc1
commit
5fb8d22a7a
@ -171,8 +171,8 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getReveActuel() {
|
getReveActuel() {
|
||||||
const actorData = Misc.data(this);
|
const templateData = Misc.templateData(this);
|
||||||
return Misc.toInt(actorData.data.reve?.reve?.value ?? actorData.data.carac.reve.value);
|
return Misc.toInt(templateData.reve?.reve?.value ?? templateData.carac.reve.value);
|
||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getChanceActuel() {
|
getChanceActuel() {
|
||||||
@ -1613,6 +1613,12 @@ export class RdDActor extends Actor {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
appliquerExperience(rollData) {
|
||||||
|
const callback = this.createCallbackExperience();
|
||||||
|
if (callback.condition(rollData)) { callback.action(rollData); }
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
createCallbackExperience() {
|
createCallbackExperience() {
|
||||||
return {
|
return {
|
||||||
@ -1948,6 +1954,32 @@ export class RdDActor extends Actor {
|
|||||||
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-general.html');
|
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) {
|
async rollCompetence(name) {
|
||||||
let rollData = { competence: this.getCompetence(name) }
|
let rollData = { competence: this.getCompetence(name) }
|
||||||
@ -2380,19 +2412,29 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static _findCaracByName(carac, name) {
|
static _findCaracByName(carac, name) {
|
||||||
name = name.toLowerCase();
|
name = Grammar.toLowerCaseNoAccent(name);
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'reve-actuel': case 'rêve actuel':
|
case 'reve-actuel': case 'rêve actuel':
|
||||||
return carac.reve;
|
return carac.reve;
|
||||||
case 'chance-actuelle': case 'chance actuelle':
|
case 'chance-actuelle': case 'chance actuelle':
|
||||||
return carac.chance;
|
return carac.chance;
|
||||||
}
|
}
|
||||||
for (const [key, value] of Object.entries(carac)) {
|
const keys = Object.entries(carac)
|
||||||
if (name == key || name == value.label.toLowerCase()) {
|
.filter(it => it[0].includes(name) || Grammar.toLowerCaseNoAccent(it[1].label).includes(name))
|
||||||
return carac[key];
|
.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.`);
|
||||||
}
|
}
|
||||||
return carac[name]; // Per default
|
if (keys.length>0){
|
||||||
|
return carac[keys[0]];
|
||||||
|
}
|
||||||
|
// 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) {
|
_deleteStatusEffectsByIds(effectIds, options) {
|
||||||
this.deleteEmbeddedEntity('ActiveEffect', 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);
|
const statusEffect = CONFIG.statusEffects.find(it => it.id == id);
|
||||||
await this.addStatusEffect(statusEffect, options);
|
await this.addStatusEffect(statusEffect, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async addStatusEffect(statusEffect, options = { renderSheet: true }) {
|
async addStatusEffect(statusEffect, options = { renderSheet: false }) {
|
||||||
this.deleteStatusEffectById(statusEffect.id, options);
|
this.deleteStatusEffectById(statusEffect.id, options);
|
||||||
const effet = duplicate(statusEffect);
|
const effet = duplicate(statusEffect);
|
||||||
effet["flags.core.statusId"] = effet.id;
|
effet["flags.core.statusId"] = effet.id;
|
||||||
await this.createEmbeddedEntity('ActiveEffect', effet, options);
|
await this.createEmbeddedEntity('ActiveEffect', effet, options);
|
||||||
this.applyActiveEffects();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { Grammar } from "./grammar.js";
|
||||||
|
|
||||||
const competenceTroncs = [["Esquive", "Dague", "Corps à corps"],
|
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"]];
|
["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) {
|
static findCompetence(list, name) {
|
||||||
name = name.toLowerCase();
|
name = Grammar.toLowerCaseNoAccent(name);
|
||||||
return list.find(it => it.name.toLowerCase() == name && (it.type == "competence" || it.type == "competencecreature"))
|
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 { RdDRollTables } from "./rdd-rolltables.js";
|
||||||
import { RdDUtility } from "./rdd-utility.js";
|
import { RdDUtility } from "./rdd-utility.js";
|
||||||
import { TMRRencontres } from "./tmr-rencontres.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 {
|
export class RdDCommands {
|
||||||
@ -64,9 +64,11 @@ export class RdDCommands {
|
|||||||
descr: `Effectue un jet de dés dans la table de résolution. Exemples:
|
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</strong> ouvre la table de résolution
|
||||||
<br><strong>/rdd 10 3</strong> effectue un jet 10 à +3
|
<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 -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" });
|
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);
|
await this.rollRdDNumeric(msg, carac, diff, significative);
|
||||||
return;
|
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