Fixes pour possession

This commit is contained in:
sladecraven 2022-07-09 09:04:35 +02:00
commit 7d32a70e00
14 changed files with 236 additions and 105 deletions

View File

@ -91,8 +91,9 @@ export class RdDActorSheet extends ActorSheet {
formData.combat = duplicate(formData.armes ?? []); formData.combat = duplicate(formData.armes ?? []);
RdDItemArme.computeNiveauArmes(formData.combat, formData.competences); RdDItemArme.computeNiveauArmes(formData.combat, formData.competences);
RdDItemArme.ajoutCorpsACorps(formData.combat, formData.competences, formData.data.carac); RdDItemArme.ajoutCorpsACorps(formData.combat, formData.competences, formData.data.carac);
formData.esquives = this.actor.getCompetences("Esquive").map(i => foundry.utils.deepClone(i.system)) formData.esquives = this.actor.getCompetences("Esquive").map(i => foundry.utils.deepClone(i.system));
formData.combat = RdDCombatManager.finalizeArmeList(formData.combat, formData.competences, formData.data.carac); formData.combat = RdDCombatManager.listActionsArmes(formData.combat, formData.competences, formData.data.carac);
this.armesList = formData.combat; this.armesList = formData.combat;
// Common data // Common data
@ -332,8 +333,8 @@ export class RdDActorSheet extends ActorSheet {
html.find('.arme-initiative a').click(async event => { html.find('.arme-initiative a').click(async event => {
let combatant = game.combat.data.combatants.find(c => c.actor.data._id == this.actor.data._id); let combatant = game.combat.data.combatants.find(c => c.actor.data._id == this.actor.data._id);
if (combatant) { if (combatant) {
let arme = this._getEventArmeCombat(event); let action = this._getEventArmeCombat(event);
RdDCombatManager.rollInitiativeCompetence(combatant._id, arme); RdDCombatManager.rollInitiativeAction(combatant._id, action);
} else { } else {
ui.notifications.info("Impossible de lancer l'initiative sans être dans un combat."); ui.notifications.info("Impossible de lancer l'initiative sans être dans un combat.");
} }

View File

@ -391,6 +391,9 @@ export class RdDActor extends Actor {
getPossession(possessionId) { getPossession(possessionId) {
return this.items.find(it => it.type == 'possession' && it.system.possessionid == possessionId); return this.items.find(it => it.type == 'possession' && it.system.possessionid == possessionId);
} }
getPossessions() {
return this.items.filter(it => it.type == 'possession');
}
getDemiReve() { getDemiReve() {
return this.system.reve.tmrpos.coord; return this.system.reve.tmrpos.coord;
@ -2536,7 +2539,7 @@ export class RdDActor extends Actor {
if (rollData.competence.system.ispossession) { if (rollData.competence.system.ispossession) {
RdDPossession.onAttaquePossession(this, rollData.competence) RdDPossession.onAttaquePossession(this, rollData.competence)
} else { } else {
const arme = RdDItemCompetenceCreature.toArme(rollData.competence) const arme = RdDItemCompetenceCreature.toActionArme(rollData.competence)
RdDCombat.createUsingTarget(this)?.attaque(competence, arme) RdDCombat.createUsingTarget(this)?.attaque(competence, arme)
} }
return return
@ -3119,7 +3122,7 @@ export class RdDActor extends Actor {
return carac.chance; return carac.chance;
} }
let entry = Misc.findFirstLike(name, Object.entries(carac), { mapper: it => it[1].label, description: 'caractéristique' }); let entry = Misc.findFirstLike(name, Object.entries(carac), { mapper: it => it[1].label, description: 'caractéristique' });
return entry.length > 0 ? carac[entry[0]] : undefined; return entry && entry.length > 0 ? carac[entry[0]] : undefined;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -30,7 +30,7 @@ export class RdDItemArme extends Item {
switch (armeData ? armeData.type : '') { switch (armeData ? armeData.type : '') {
case 'arme': return armeData; case 'arme': return armeData;
case 'competencecreature': case 'competencecreature':
return RdDItemCompetenceCreature.toArme(armeData); return RdDItemCompetenceCreature.toActionArme(armeData);
} }
return RdDItemArme.mainsNues(); return RdDItemArme.mainsNues();
} }
@ -186,7 +186,7 @@ export class RdDItemArme extends Item {
categorie_parade: 'sans-armes' categorie_parade: 'sans-armes'
} }
}; };
mergeObject(corpsACorps.system, actorData ??{}, { overwrite: false }); mergeObject(corpsACorps.system, actorData ?? {}, { overwrite: false });
return corpsACorps; return corpsACorps;
} }

View File

@ -210,8 +210,11 @@ export class RdDItemCompetence extends Item {
/* -------------------------------------------- */ /* -------------------------------------------- */
static findCompetence(list, idOrName, options = {}) { static findCompetence(list, idOrName, options = {}) {
if (idOrName == undefined) {
return undefined;
}
options = mergeObject(options, { options = mergeObject(options, {
filter: it => RdDItemCompetence.isCompetence(it), preFilter: it => RdDItemCompetence.isCompetence(it),
description: 'compétence', description: 'compétence',
}); });
return list.find(it => it.id == idOrName && RdDItemCompetence.isCompetence(it)) return list.find(it => it.id == idOrName && RdDItemCompetence.isCompetence(it))

View File

@ -11,12 +11,12 @@ export class RdDItemCompetenceCreature extends Item {
rollData.competence.system.categorie = "creature" rollData.competence.system.categorie = "creature"
rollData.selectedCarac = rollData.carac.carac_creature rollData.selectedCarac = rollData.carac.carac_creature
if (rollData.competence.system.iscombat) { if (rollData.competence.system.iscombat) {
rollData.arme = RdDItemCompetenceCreature.toArme(rollData.competence); rollData.arme = RdDItemCompetenceCreature.toActionArme(rollData.competence);
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static toArme(item) { static toActionArme(item) {
if (RdDItemCompetenceCreature.isCompetenceAttaque(item)) { if (RdDItemCompetenceCreature.isCompetenceAttaque(item)) {
// si c'est un Item compétence: cloner pour ne pas modifier lma compétence // si c'est un Item compétence: cloner pour ne pas modifier lma compétence
let arme = (item instanceof Item) ? item.clone(): item; let arme = (item instanceof Item) ? item.clone(): item;
@ -28,11 +28,12 @@ export class RdDItemCompetenceCreature extends Item {
dommagesReels: arme.system.dommages, dommagesReels: arme.system.dommages,
penetration: 0, penetration: 0,
force: 0, force: 0,
rapide: true rapide: true,
action: 'attaque'
}); });
return arme; return arme;
} }
console.error("RdDItemCompetenceCreature.toArme(", item, ") : impossible de transformer l'Item en arme"); console.error("RdDItemCompetenceCreature.toActionArme(", item, ") : impossible de transformer l'Item en arme");
return undefined; return undefined;
} }

View File

@ -181,7 +181,7 @@ export class Misc {
if (!single) { if (!single) {
single = subset[0]; single = subset[0];
const choices = Misc.join(subset.map(it => options.mapper(it)), '<br>'); const choices = Misc.join(subset.map(it => options.mapper(it)), '<br>');
options.info(`Plusieurs choix de ${options.description}s possibles:<br>${choices}<br>Le premier sera choisi: ${mapToValue(single)}`); options.onMessage(`Plusieurs choix de ${options.description}s possibles:<br>${choices}<br>Le premier sera choisi: ${options.mapper(single)}`);
} }
return single; return single;
} }
@ -200,7 +200,7 @@ export class Misc {
} }
value = Grammar.toLowerCaseNoAccent(value); value = Grammar.toLowerCaseNoAccent(value);
const subset = elements.filter(options.preFilter) const subset = elements.filter(options.preFilter)
.filter(it => Grammar.toLowerCaseNoAccent(options.mapper(it)).includes(value)); .filter(it => Grammar.toLowerCaseNoAccent(options.mapper(it))?.includes(value));
if (subset.length == 0) { if (subset.length == 0) {
options.onMessage(`Pas de ${options.description} correspondant à ${value}`); options.onMessage(`Pas de ${options.description} correspondant à ${value}`);
} }

View File

@ -1,5 +1,6 @@
import { ChatUtility } from "./chat-utility.js"; import { ChatUtility } from "./chat-utility.js";
import { HIDE_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; import { HIDE_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
import { Grammar } from "./grammar.js";
import { RdDItemArme } from "./item-arme.js"; import { RdDItemArme } from "./item-arme.js";
import { RdDItemCompetence } from "./item-competence.js"; import { RdDItemCompetence } from "./item-competence.js";
import { RdDItemCompetenceCreature } from "./item-competencecreature.js"; import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
@ -26,7 +27,7 @@ const premierRoundInit = [
{ pattern: 'epeegnome', init: 5.35 }, { pattern: 'epeegnome', init: 5.35 },
{ pattern: 'masse', init: 5.30 }, { pattern: 'masse', init: 5.30 },
{ pattern: 'gourdin', init: 5.25 }, { pattern: 'gourdin', init: 5.25 },
{ pattern: 'fléau', init: 5.20 }, { pattern: 'fleau', init: 5.20 },
{ pattern: 'dague', init: 5.15 }, { pattern: 'dague', init: 5.15 },
{ pattern: 'autre', init: 5.10 }, { pattern: 'autre', init: 5.10 },
]; ];
@ -84,6 +85,7 @@ export class RdDCombatManager extends Combat {
// calculate initiative // calculate initiative
for (let cId = 0; cId < ids.length; cId++) { for (let cId = 0; cId < ids.length; cId++) {
const combatant = this.combatants.get(ids[cId]); const combatant = this.combatants.get(ids[cId]);
<<<<<<< HEAD
//if (!c) return results; //if (!c) return results;
let rollFormula = formula; // Init per default let rollFormula = formula; // Init per default
@ -106,6 +108,25 @@ export class RdDCombatManager extends Combat {
competence = RdDItemCompetence.findCompetence(combatant.actor.items, compName); competence = RdDItemCompetence.findCompetence(combatant.actor.items, compName);
let bonusEcaille = (armeCombat && armeCombat.data.magique) ? armeCombat.system.ecaille_efficacite : 0; let bonusEcaille = (armeCombat && armeCombat.data.magique) ? armeCombat.system.ecaille_efficacite : 0;
rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.system.niveau, combatant.actor.system.carac[competence.system.defaut_carac].value, bonusEcaille) + ")/100)"; rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.system.niveau, combatant.actor.system.carac[competence.system.defaut_carac].value, bonusEcaille) + ")/100)";
=======
let rollFormula = formula ?? RdDCombatManager.formuleInitiative(2, 10, 0, 0);
if (!formula) {
if (combatant.actor.data.type == 'creature' || combatant.actor.data.type == 'entite') {
const competence = combatant.actor.data.items.find(it => it.data.data.iscombat)
if (competence) {
rollFormula = RdDCombatManager.formuleInitiative(2, competence.data.carac_value, competence.data.niveau, 0);
}
} else {
const armeCombat = combatant.actor.data.items.find(it => it.type == 'arme' && itemData.data.equipe)
const compName = (armeCombat == undefined) ? "Corps à corps" : armeCombat.data.competence;
const competence = RdDItemCompetence.findCompetence(combatant.actor.data.items, compName);
if (competence) {
const carac = combatant.actor.data.data.carac[competence.data.defaut_carac].value;
const niveau = competence.data.niveau;
const bonusEcaille = (armeCombat?.data.magique) ? armeCombat.data.ecaille_efficacite : 0;
rollFormula = RdDCombatManager.formuleInitiative(2, carac, niveau, bonusEcaille);
}
>>>>>>> origin/v1.5
} }
} }
//console.log("Combatat", c); //console.log("Combatat", c);
@ -142,6 +163,10 @@ export class RdDCombatManager extends Combat {
return this; return this;
}; };
static formuleInitiative(rang, carac, niveau, bonusMalus) {
return `${rang} +( (${RdDCombatManager.calculInitiative(niveau, carac, bonusMalus)} )/100)`;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static calculInitiative(niveau, caracValue, bonusEcaille = 0) { static calculInitiative(niveau, caracValue, bonusEcaille = 0) {
let base = niveau + Math.floor(caracValue / 2); let base = niveau + Math.floor(caracValue / 2);
@ -150,11 +175,12 @@ export class RdDCombatManager extends Combat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
/** Retourne une liste triée d'armes avec le split arme1 main / arme 2 main */ /** Retourne une liste triée d'actions d'armes avec le split arme1 main / arme 2 main */
static finalizeArmeList(armes, competences, carac) { static listActionsArmes(armes, competences, carac) {
// Gestion des armes 1/2 mains // Gestion des armes 1/2 mains
let armesEquipe = []; let actionsArme = [];
for (const arme of armes) { for (const arme of armes) {
<<<<<<< HEAD
let armeData = duplicate(arme) let armeData = duplicate(arme)
if (armeData.system.equipe) { if (armeData.system.equipe) {
let compData = competences.find(c => c.name.toLowerCase() == armeData.system.competence.toLowerCase()) let compData = competences.find(c => c.name.toLowerCase() == armeData.system.competence.toLowerCase())
@ -185,43 +211,92 @@ export class RdDCombatManager extends Combat {
const tableauDegats = armeData.system.dommages.split("/"); const tableauDegats = armeData.system.dommages.split("/");
armeData.system.dommagesReels = Number(tableauDegats[0]); armeData.system.dommagesReels = Number(tableauDegats[0]);
arme2main.system.dommagesReels = Number(tableauDegats[1]); arme2main.system.dommagesReels = Number(tableauDegats[1]);
=======
let action = duplicate(Misc.data(arme));
if (action.data.equipe) {
let compData = competences.map(c => Misc.data(c)).find(c => c.name == action.data.competence);
actionsArme.push(action);
action.action = 'attaque';
action.data.dommagesReels = Number(action.data.dommages);
action.data.niveau = compData.data.niveau;
action.data.initiative = RdDCombatManager.calculInitiative(compData.data.niveau, carac[compData.data.defaut_carac].value);
// Dupliquer les armes pouvant être à 1 main et 2 mains en patchant la compétence
if (action.data.unemain && !action.data.deuxmains) {
action.data.mainInfo = "(1m)";
} else if (!action.data.unemain && action.data.deuxmains) {
action.data.mainInfo = "(2m)";
} else if (action.data.unemain && action.data.deuxmains) {
action.data.mainInfo = "(1m)";
const comp2m = action.data.competence.replace(" 1 main", " 2 mains"); // Replace !
const comp = Misc.data(competences.find(c => c.name == comp2m));
const arme2main = duplicate(action);
arme2main.data.mainInfo = "(2m)";
arme2main.data.niveau = comp.data.niveau;
arme2main.data.competence = comp2m;
arme2main.data.initiative = RdDCombatManager.calculInitiative(arme2main.data.niveau, carac[comp.data.defaut_carac].value);
actionsArme.push(arme2main);
const containsSlash = action.data.dommages.includes("/");
if (containsSlash) {
const tableauDegats = action.data.dommages.split("/");
action.data.dommagesReels = Number(tableauDegats[0]);
arme2main.data.dommagesReels = Number(tableauDegats[1]);
>>>>>>> origin/v1.5
} }
else{ else{
ui.notifications.info("Les dommages de l'arme à 1/2 mains " + armeData.name + " ne sont pas corrects (ie sous la forme X/Y)"); ui.notifications.info("Les dommages de l'arme à 1/2 mains " + action.name + " ne sont pas corrects (ie sous la forme X/Y)");
} }
} }
} }
} }
return armesEquipe.sort(Misc.ascending(armeData => armeData.name + (armeData.system.mainInfo ?? ''))) return actionsArme.sort(Misc.ascending(armeData => armeData.name + (armeData.system.mainInfo ?? '')));
}
static listActionsPossessions(actor) {
return RdDCombatManager._indexActions(actor.getPossessions().map(p =>
{
return {
name: p.name,
action: 'conjurer',
data: {
competence: p.name,
possessionid: p.data.data.possessionid,
}
}
}));
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static buildListeActionsCombat(combatant) { static listActionsCombat(combatant) {
if (combatant.actor == undefined) { const actor = combatant.actor;
ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`) let actions = RdDCombatManager.listActionsPossessions(actor);
return []; if (actions.length>0) {
return actions;
} }
const actorData = combatant.actor let items = actor.items;
let items = combatant.actor.items if (actor.isCreature()) {
let actions = []
if (combatant.actor.isCreature()) {
actions = actions.concat(items.filter(it => RdDItemCompetenceCreature.isCompetenceAttaque(it)) actions = actions.concat(items.filter(it => RdDItemCompetenceCreature.isCompetenceAttaque(it))
.map(competence => RdDItemCompetenceCreature.toArme(competence))); .map(competence => RdDItemCompetenceCreature.toActionArme(competence)));
} else { } else {
// Recupération des items 'arme' // Recupération des items 'arme'
let armes = items.filter(it => RdDItemArme.isArmeUtilisable(it)) let armes = items.filter(it => RdDItemArme.isArmeUtilisable(it))
//.concat(RdDItemArme.empoignade()) //.concat(RdDItemArme.empoignade())
.concat(RdDItemArme.mainsNues()); .concat(RdDItemArme.mainsNues());
let competences = items.filter(it => it.type == 'competence') let competences = items.filter(it => it.type == 'competence');
actions = actions.concat(RdDCombatManager.finalizeArmeList(armes, competences, actorData.data.carac)); actions = actions.concat(RdDCombatManager.listActionsArmes(armes, competences, actor.data.data.carac));
if (actorData.data.attributs.hautrevant.value) { if (actor.data.data.attributs.hautrevant.value) {
actions.push({ name: "Draconic", data: { initOnly: true, competence: "Draconic" } }); actions.push({ name: "Draconic", action: 'haut-reve', data: { initOnly: true, competence: "Draconic" } });
} }
} }
actions.push({ name: "Autre action", data: { initOnly: true, competence: "Autre action" } }); return RdDCombatManager._indexActions(actions);
}
static _indexActions(actions) {
for (let index = 0; index < actions.length; index++) { for (let index = 0; index < actions.length; index++) {
actions[index].index = index; actions[index].index = index;
} }
@ -235,15 +310,15 @@ export class RdDCombatManager extends Combat {
let initMissing = game.combat.data.combatants.find(it => !it.initiative); let initMissing = game.combat.data.combatants.find(it => !it.initiative);
if (!initMissing) { // Premier round ! if (!initMissing) { // Premier round !
for (let combatant of game.combat.data.combatants) { for (let combatant of game.combat.data.combatants) {
let arme = combatant.initiativeData?.arme; let action = combatant.initiativeData?.arme;
//console.log("Parsed !!!", combatant, initDone, game.combat.current, arme); //console.log("Parsed !!!", combatant, initDone, game.combat.current, arme);
if (arme && arme.type == "arme") { if (action && action.type == "arme") {
for (let initData of premierRoundInit) { for (let initData of premierRoundInit) {
if (arme.data.initpremierround.toLowerCase().includes(initData.pattern)) { if (Grammar.toLowerCaseNoAccentNoSpace(action.data.initpremierround).includes(initData.pattern)) {
let msg = `<h4>L'initiative de ${combatant.actor.name} a été modifiée !</h4> let msg = `<h4>L'initiative de ${combatant.actor.name} a été modifiée !</h4>
<hr> <hr>
<div> <div>
Etant donné son ${arme.name}, son initative pour ce premier round est désormais de ${initData.init}. Etant donné son ${action.name}, son initative pour ce premier round est désormais de ${initData.init}.
</div>` </div>`
ChatMessage.create({ content: msg }); ChatMessage.create({ content: msg });
game.combat.setInitiative(combatant._id, initData.init); game.combat.setInitiative(combatant._id, initData.init);
@ -281,7 +356,7 @@ export class RdDCombatManager extends Combat {
].concat(options); ].concat(options);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static rollInitiativeCompetence(combatantId, arme) { static rollInitiativeAction(combatantId, action) {
const combatant = game.combat.combatants.get(combatantId); const combatant = game.combat.combatants.get(combatantId);
if (combatant.actor == undefined) { if (combatant.actor == undefined) {
ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`) ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
@ -299,18 +374,23 @@ export class RdDCombatManager extends Combat {
} else if (combatant.actor.getSurprise() == "demi") { } else if (combatant.actor.getSurprise() == "demi") {
initOffset = 0; initOffset = 0;
initInfo = "Demi Surprise" initInfo = "Demi Surprise"
} else if (arme.name == "Autre action") { } else if (action.action == 'conjurer') {
initOffset = 10;
caracForInit = combatant.actor.getReveActuel();
initInfo = "Possession"
} else if (action.name == 'autre') {
initOffset = 2; initOffset = 2;
initInfo = "Autre Action" initInfo = "Autre Action"
} else if (arme.name == "Draconic") { } else if (action.action == 'haut-reve') {
initOffset = 9; initOffset = 9;
initInfo = "Draconic" initInfo = "Draconic"
} else { } else {
compData = RdDItemCompetence.findCompetence(combatant.actor.items, arme.system.competence); compData = RdDItemCompetence.findCompetence(combatant.actor.items, arme.system.competence);
compNiveau = compData.system.niveau; compNiveau = compData.system.niveau;
initInfo = arme.name + " / " + arme.data.competence; initInfo = action.name + " / " + action.data.competence;
if (combatant.actor.type == 'creature' || combatant.actor.type == 'entite') { if (combatant.actor.type == 'creature' || combatant.actor.type == 'entite') {
caracForInit = compData.system.carac_value; caracForInit = compData.data.carac_value;
if (compData.system.categorie == "lancer") { if (compData.system.categorie == "lancer") {
initOffset = 7; initOffset = 7;
} }
@ -319,14 +399,15 @@ export class RdDCombatManager extends Combat {
} }
} else { } else {
caracForInit = combatant.actor.system.carac[compData.system.defaut_carac].value; caracForInit = combatant.actor.system.carac[compData.system.defaut_carac].value;
initOffset = RdDCombatManager._baseInitOffset(compData.system.categorie, arme); initOffset = RdDCombatManager._baseInitOffset(compData.system.categorie, action);
} }
} }
let malus = combatant.actor.getEtatGeneral(); // Prise en compte état général let malus = combatant.actor.getEtatGeneral(); // Prise en compte état général
// Cas des créatures et entités vs personnages // Cas des créatures et entités vs personnages
let rollFormula = initOffset + "+ ( (" + RdDCombatManager.calculInitiative(compNiveau, caracForInit) + " + " + malus + ") /100)"; let rollFormula = RdDCombatManager.formuleInitiative(initOffset, caracForInit, compNiveau, malus);
// Garder la trace de l'arme/compétence utilisée pour l'iniative // Garder la trace de l'arme/compétence utilisée pour l'iniative
combatant.initiativeData = { arme: arme } // pour reclasser l'init au round 0 combatant.initiativeData = { arme: action } // pour reclasser l'init au round 0
game.combat.rollInitiative(combatantId, rollFormula, { initInfo: initInfo }); game.combat.rollInitiative(combatantId, rollFormula, { initInfo: initInfo });
} }
@ -349,16 +430,21 @@ export class RdDCombatManager extends Combat {
static displayInitiativeMenu(html, combatantId) { static displayInitiativeMenu(html, combatantId) {
console.log("Combatant ; ", combatantId); console.log("Combatant ; ", combatantId);
const combatant = game.combat.combatants.get(combatantId); const combatant = game.combat.combatants.get(combatantId);
let armesList = RdDCombatManager.buildListeActionsCombat(combatant); if (! (combatant?.actor) ) {
ui.notifications.warn(`Le combatant ${combatant.name ?? combatantId} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
return;
}
let actions = RdDCombatManager.listActionsCombat(combatant);
// Build the relevant submenu // Build the relevant submenu
if (armesList) { if (actions) {
let menuItems = []; let menuItems = [];
for (let arme of armesList) { for (let action of actions) {
menuItems.push({ menuItems.push({
name: arme.data.competence, name: action.data.competence,
icon: "<i class='fas fa-dice-d6'></i>", icon: "<i class='fas fa-dice-d6'></i>",
callback: target => { RdDCombatManager.rollInitiativeCompetence(combatantId, arme) } callback: target => { RdDCombatManager.rollInitiativeAction(combatantId, action) }
}); });
} }
new ContextMenu(html, ".directory-list", menuItems).render(); new ContextMenu(html, ".directory-list", menuItems).render();

View File

@ -276,9 +276,11 @@ export class RdDCommands {
diff = 0; diff = 0;
} }
const caracName = params[0]; const caracName = params[0];
const compName = length > 1 ? Misc.join(params.slice(1, length), ' ') : undefined; let competence = length > 1 ? actors[0].getCompetence(Misc.join(params.slice(1, length), ' ')) : undefined;
if (competence) {
for (let actor of actors) { for (let actor of actors) {
await actor.rollCaracCompetence(caracName, compName, diff); await actor.rollCaracCompetence(caracName, competence.name, diff);
}
} }
return; return;
} }

View File

@ -84,16 +84,11 @@ export class RdDPossession {
attacker: attacker, attacker: attacker,
defender: defender, defender: defender,
competence: defender.getDraconicOuPossession(), competence: defender.getDraconicOuPossession(),
selectedCarac: defender.system.carac.reve, selectedCarac: defender.system.data.carac.reve,
forceCarac: { 'reve-actuel': { label: "Rêve Actuel", value: defender.getReveActuel() } }
} }
if (rollData.isECNIDefender) {
rollData.competence.system.defaut_carac = "reve"
rollData.forceCarac = { 'reve': { label: "Rêve", value: defender.system.carac.reve.value } }
} else {
rollData.competence.system.defaut_carac = 'reve-actuel' rollData.competence.system.defaut_carac = 'reve-actuel'
rollData.forceCarac = { 'reve-actuel': { label: "Rêve Actuel", value: defender.getReveActuel() } }
}
const dialog = await RdDRoll.create(defender, rollData, const dialog = await RdDRoll.create(defender, rollData,
{ {

View File

@ -23,28 +23,36 @@ export class RdDTokenHud {
let token = canvas.tokens.get(tokenId); let token = canvas.tokens.get(tokenId);
let actor = token.actor; let actor = token.actor;
let combatant = game.combat.combatants.find(c => c.tokenId == tokenId); let combatant = game.combat.combatants.find(c => c.tokenId == tokenId);
if (! (combatant?.actor) ) {
ui.notifications.warn(`Le combatant ${token.name} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
return;
}
app.hasExtension = true; app.hasExtension = true;
let armesList = RdDCombatManager.buildListeActionsCombat(combatant); let actionsCombat = RdDCombatManager.listActionsCombat(combatant);
const hudData = { const hudData = {
combatant: combatant, armes: armesList, combatant: combatant,
commandes: [{ name: 'Initiative +1', command: 'inc', value: 0.01 }, { name: 'Initiative -1', command: 'dec', value: -0.01 }] actions: actionsCombat,
commandes: [
{ name: "Autre action", command: 'autre' },
{ name: 'Initiative +1', command: 'inc', value: 0.01 },
{ name: 'Initiative -1', command: 'dec', value: -0.01 }]
}; };
const controlIconCombat = html.find('.control-icon[data-action=combat]'); const controlIconCombat = html.find('.control-icon[data-action=combat]');
// initiative // initiative
await RdDTokenHud._configureSubMenu(controlIconCombat, 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html', hudData, await RdDTokenHud._configureSubMenu(controlIconCombat,
'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html',
hudData,
(event) => { (event) => {
let initCommand = event.currentTarget.attributes['data-command'].value; let initCommand = event.currentTarget.attributes['data-command']?.value;
let combatantId = event.currentTarget.attributes['data-combatant-id'].value; let combatantId = event.currentTarget.attributes['data-combatant-id']?.value;
if (!initCommand) { if (initCommand) {
let armeIndex = event.currentTarget.attributes['data-arme-id'].value; RdDTokenHud._initiativeCommand(initCommand, combatantId);
let arme = armesList[armeIndex]; } else {
RdDCombatManager.rollInitiativeCompetence(combatantId, arme); let index = event.currentTarget.attributes['data-action-index'].value;
} else if (initCommand == 'inc') { let action = actionsCombat[index];
RdDCombatManager.incDecInit(combatantId, 0.01); RdDCombatManager.rollInitiativeAction(combatantId, action);
} else if (initCommand == 'dec') {
RdDCombatManager.incDecInit(combatantId, -0.01);
} }
}); });
@ -52,11 +60,26 @@ export class RdDTokenHud {
// combat // combat
await RdDTokenHud._configureSubMenu(controlIconTarget, 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html', hudData, await RdDTokenHud._configureSubMenu(controlIconTarget, 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html', hudData,
(event) => { (event) => {
let armeIndex = event.currentTarget.attributes['data-arme-id'].value; const actionIndex = event.currentTarget.attributes['data-action-index']?.value;
actor.rollArme(armesList[armeIndex]); const action = actionsCombat[actionIndex];
if (action.action == 'conjurer') {
actor.conjurerPossession(actor.getPossession(action.data.possessionid));
}
else {
actor.rollArme(action);
}
}); });
} }
static _initiativeCommand(initCommand, combatantId) {
switch (initCommand) {
case 'inc': return RdDCombatManager.incDecInit(combatantId, 0.01);
case 'dec': return RdDCombatManager.incDecInit(combatantId, -0.01);
case 'autre': return RdDCombatManager.rollInitiativeAction(combatantId,
{ name: "Autre action", action: 'autre', data: { initOnly: true, competence: "Autre action" } });
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static async addTokenHudExtensions(app, html, tokenId) { static async addTokenHudExtensions(app, html, tokenId) {
const controlIconCombat = html.find('.control-icon[data-action=combat]'); const controlIconCombat = html.find('.control-icon[data-action=combat]');

View File

@ -29,7 +29,7 @@
"url": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/", "url": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/",
"license": "LICENSE.txt", "license": "LICENSE.txt",
"flags": {}, "flags": {},
"version": "10.0.1", "version": "10.0.2",
"minimumCoreVersion": "10", "minimumCoreVersion": "10",
"compatibleCoreVersion": "10", "compatibleCoreVersion": "10",
"scripts": [], "scripts": [],
@ -500,7 +500,7 @@
"dependencies": [], "dependencies": [],
"socket": true, "socket": true,
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.0.1.zip", "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.0.2.zip",
"protected": false, "protected": false,
"gridDistance": 1, "gridDistance": 1,
"gridUnits": "m", "gridUnits": "m",

View File

@ -17,16 +17,22 @@
<a class='defense-possession chat-card-button' <a class='defense-possession chat-card-button'
data-attackerId='{{attacker.id}}' data-attackerId='{{attacker.id}}'
data-defenderId='{{defender.id}}' data-defenderId='{{defender.id}}'
data-possessionId='{{possession.system.possessionid}}'>Résister à la possession</a> data-possessionId='{{possession.system.possessionid}}'>
{{#if isECNIDefender}}
Résister à la conjuration
{{else}}
Résister à la possession
{{/if}}
</a> </a>
{{else}} {{else}}
La Tentative de Possession a échouée ! La Tentative de {{#if isECNIDefender}}conjuration{{else}}possession{{/if}} a échoué !
{{/if}} {{/if}}
{{else}} {{else}}
{{#if rolled.isSuccess}} {{#if rolled.isSuccess}}
La Tentative de Possession a été conjurée ! {{defender.name}} résiste à la tentative de possession. La tentative de {{#if isECNIDefender}}conjuration a été repoussée{{else}}possession a été conjurée{{/if}}!
{{defender.name}} a résisté.
{{else}} {{else}}
La Tentative de Possession n'a pas pu être conjurée ! La tentative de {{#if isECNIDefender}}conjuration a réussi{{else}}possession n'a pas pu être conjurée{{/if}}!
{{/if}} {{/if}}
{{/if}} {{/if}}
<br>Points de Possession: {{possession.ptsPossession}} <br>Points de Possession: {{possession.ptsPossession}}

View File

@ -1,10 +1,13 @@
<div class="control-icon rdd-combat "> <div class="control-icon rdd-combat ">
<img class="rdd-hud-togglebutton" src="systems/foundryvtt-reve-de-dragon/icons/heures/hd06.svg" width="36" height="36" title="Attaque"/> <img class="rdd-hud-togglebutton" src="systems/foundryvtt-reve-de-dragon/icons/heures/hd06.svg" width="36" height="36" title="Attaque"/>
<div class="rdd-hud-list tokenhudext left"> <div class="rdd-hud-list tokenhudext left">
{{#each armes as |arme key|}} {{#each actions as |action key|}}
{{#unless arme.data.initOnly}} {{#unless action.data.initOnly}}
<div class="control-icon tokenhudicon rdd-hud-menu rdd-attaque" data-combatant-id="{{../combatant.id}}" data-arme-id="{{arme.index}}" title="{{arme.name}}"> <div class="control-icon tokenhudicon rdd-hud-menu rdd-attaque"
<label>C:{{arme.name}} {{arme.data.mainInfo}}</label> data-combatant-id="{{../combatant.id}}"
data-action-index="{{action.index}}"
title="{{action.name}}">
<label>{{action.name}} {{action.data.mainInfo}}</label>
</div> </div>
{{/unless}} {{/unless}}
{{/each}} {{/each}}

View File

@ -1,14 +1,22 @@
<div class="control-icon rdd-initiative "> <div class="control-icon rdd-initiative ">
<img class="rdd-hud-togglebutton" src="icons/svg/sword.svg" width="36" height="36" title="Initiative" /> <img class="rdd-hud-togglebutton" src="icons/svg/sword.svg" width="36" height="36" title="Initiative" />
<div class="rdd-hud-list tokenhudext right"> <div class="rdd-hud-list tokenhudext right">
{{#each armes as |arme key|}} {{#each actions as |action key|}}
<div class="control-icon tokenhudicon rdd-hud-menu" data-command="{{arme.command}}" data-combatant-id="{{../combatant.id}}" data-arme-id="{{arme.index}}" title="{{arme.name}}"> {{log 'action-hud-init' action}}
<label>I:{{arme.name}} {{arme.data.mainInfo}}</label> <div class="control-icon tokenhudicon rdd-hud-menu"
data-combatant-id="{{../combatant.id}}"
data-action-index="{{action.index}}"
title="{{action.name}}">
<label>init: {{action.name}} {{action.data.mainInfo}}</label>
</div> </div>
{{/each}} {{/each}}
{{#each commandes as |commande key|}} {{#each commandes as |commande key|}}
<div class="control-icon tokenhudicon rdd-hud-menu" data-command="{{commande.command}}" data-combatant-id="{{../combatant.id}}" data-arme-id="{{commande.index}}" title="{{commande.name}}"> <div class="control-icon tokenhudicon rdd-hud-menu"
<label>I:{{commande.name}}</label> data-command="{{commande.command}}"
data-combatant-id="{{../combatant.id}}"
data-action-index="{{commande.index}}"
title="{{commande.name}}">
<label>{{commande.name}}</label>
</div> </div>
{{/each}} {{/each}}
</div> </div>