Gestion des signes draconiques #455

Closed
vincent.vandeme wants to merge 233 commits from v1.4-signes-draconiques into master
9 changed files with 162 additions and 132 deletions
Showing only changes of commit 3c793296a6 - Show all commits

View File

@ -167,7 +167,7 @@ export class RdDActor extends Actor {
// Initialize empty items
RdDCarac.computeCarac(actorData.data);
this.computeIsHautRevant();
this.computeEncombrementTotalEtMalusArmure();
await this.computeEncombrementTotalEtMalusArmure();
this.computePrixTotalEquipement();
this.computeEtatGeneral();
// Sanity check
@ -786,7 +786,7 @@ export class RdDActor extends Actor {
let comp = this.getCompetence(compName);
if (comp) {
let troncList = RdDItemCompetence.isTronc(compName);
let nouveauNiveau = compValue ?? RdDItemCompetence.getNiveauBase(comp.data.categorie);
let nouveauNiveau = compValue ?? RdDItemCompetence.getNiveauBase(Misc.data(comp).data.categorie);
if (troncList) {
let message = "Vous avez modifié une compétence 'tronc'. Vérifiez que les compétences suivantes évoluent ensemble jusqu'au niveau 0 : ";
for (let troncName of troncList) {
@ -1068,7 +1068,7 @@ export class RdDActor extends Actor {
}
/* -------------------------------------------- */
async computeIsHautRevant() {
computeIsHautRevant() {
const tplData = Misc.templateData(this);
tplData.attributs.hautrevant.value = this.listItemsData('tete').find(it => Grammar.toLowerCaseNoAccent(it.name) == 'don de haut-reve')
? "Haut rêvant"
@ -1083,11 +1083,10 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
computeEncombrement() {
const tplData = Misc.templateData(this);
tplData.encTotal = this.filterItemsData(it => it.data.encombrement != undefined)
this.encTotal = this.filterItemsData(it => it.data.encombrement != undefined)
.map(it => it.data.encTotal)
.reduce(Misc.sum(), 0);
return tplData.encTotal;
return this.encTotal;
}
/* -------------------------------------------- */
@ -1104,12 +1103,11 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
computePrixTotalEquipement() {
const tplData = Misc.templateData(this);
tplData.prixTotalEquipement = this.filterItemsData(it => it.data.prixTotal)
this.prixTotalEquipement = this.filterItemsData(it => it.data.prixTotal)
.map(it => it.data.prixTotal ?? 0)
.reduce(Misc.sum(), 0);
// Mise à jour valeur totale de l'équipement
return tplData.prixTotalEquipement;
return this.prixTotalEquipement;
}
/* -------------------------------------------- */
@ -1849,12 +1847,6 @@ export class RdDActor extends Actor {
return 0;
}
/* -------------------------------------------- */
appliquerExperience(rollData) {
const callback = this.createCallbackExperience();
if (callback.condition(rollData)) { callback.action(rollData); }
}
/* -------------------------------------------- */
createCallbackExperience() {
return {
@ -1895,25 +1887,25 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async checkCompetenceXP(compName, newXP = undefined) {
let competence = this.getCompetence(compName);
if (competence && newXP && newXP == competence.data.xp) { // Si édition, mais sans changement XP
let compData = Misc.data(this.getCompetence(compName));
if (compData && newXP && newXP == compData.data.xp) { // Si édition, mais sans changement XP
return;
}
newXP = (newXP) ? newXP : competence.data.xp;
if (competence && newXP > 0) {
let xpNeeded = RdDItemCompetence.getCompetenceNextXp(competence.data.niveau + 1);
newXP = (newXP) ? newXP : compData.data.xp;
if (compData && newXP > 0) {
let xpNeeded = RdDItemCompetence.getCompetenceNextXp(compData.data.niveau + 1);
if (newXP >= xpNeeded) {
let newCompetence = duplicate(competence);
newCompetence.data.niveau += 1;
newCompetence.data.xp = newXP;
let newCompData = duplicate(compData);
newCompData.data.niveau += 1;
newCompData.data.xp = newXP;
let xpData = {
alias: this.name,
competence: newCompetence.name,
niveau: newCompetence.data.niveau,
xp: newCompetence.data.xp,
archetype: newCompetence.data.niveau_archetype,
archetypeWarning: newCompetence.data.niveau > competence.data.niveau_archetype
competence: newCompData.name,
niveau: newCompData.data.niveau,
xp: newCompData.data.xp,
archetype: newCompData.data.niveau_archetype,
archetypeWarning: newCompData.data.niveau > compData.data.niveau_archetype
}
ChatUtility.createChatMessage(this.name, "default", {
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-competence-xp.html`, xpData)
@ -2198,7 +2190,7 @@ export class RdDActor extends Actor {
ui.notifications.warn(`${this.name} n'a pas de caractéristique correspondant à ${caracName}`)
return;
}
const competence = this.getCompetence(compName);
const competence = Misc.data(this.getCompetence(compName));
if (compName && !competence) {
ui.notifications.warn(`${this.name} n'a pas de compétence correspondant à ${compName}`)
return;
@ -2214,14 +2206,19 @@ export class RdDActor extends Actor {
show: { title: options?.title ?? '' }
};
await RdDResolutionTable.rollData(rollData);
this.appliquerExperience(rollData);
this._appliquerExperienceRollData(rollData);
RdDResolutionTable.displayRollData(rollData, this)
return rollData.rolled;
}
/* -------------------------------------------- */
_appliquerExperienceRollData(rollData) {
const callback = this.createCallbackExperience();
if (callback.condition(rollData)) { callback.action(rollData); }
}
/* -------------------------------------------- */
async rollCompetence(name) {
let rollData = { competence: this.getCompetence(name) }
let rollData = { competence: Misc.data(this.getCompetence(name)) }
if (rollData.competence.type == 'competencecreature') {
if (rollData.competence.data.iscombat) {
@ -2272,7 +2269,7 @@ export class RdDActor extends Actor {
async rollTache(id) {
const actorData = Misc.data(this);
const tacheData = Misc.data(this.getTache(id));
const compData = duplicate(Misc.data(this.getCompetence(tacheData.data.competence)));
const compData = Misc.data(this.getCompetence(tacheData.data.competence));
compData.data.defaut_carac = tacheData.data.carac; // Patch !
let rollData = {
@ -2321,7 +2318,7 @@ export class RdDActor extends Actor {
mergeObject(artData, {
oeuvre: oeuvre,
art: oeuvre.type,
competence: duplicate(this.getCompetence(oeuvre.data.competence ?? artData.art)),
competence: Misc.data(this.getCompetence(oeuvre.data.competence ?? artData.art)),
diffLibre: - (oeuvre.data.niveau ?? 0),
diffConditions: 0,
use: { libre: false, conditions: true },
@ -2383,14 +2380,14 @@ export class RdDActor extends Actor {
_getCaracDanse(oeuvre) {
if (oeuvre.data.agilite) { return "agilite"; }
else if (oeuvre.data.apparence) { return "apparence"; }
const competence = this.getCompetence(oeuvre.data.competence);
return competence.data.defaut_carac;
const compData = Misc.data(this.getCompetence(oeuvre.data.competence));
return compData.data.defaut_carac;
}
/* -------------------------------------------- */
async rollMusique(id) {
const artData = { art: 'musique', verbe: 'Jouer' };
const oeuvre = duplicate(this.getItemOfType(id, artData.art));
const oeuvre = Misc.data(this.getItemOfType(id, artData.art));
await this._rollArt(artData, "ouie", oeuvre);
}
@ -2402,7 +2399,7 @@ export class RdDActor extends Actor {
proportions: 1,
ajouterEquipement: false
};
const oeuvre = duplicate(this.getRecetteCuisine(id));
const oeuvre = Misc.data(this.getRecetteCuisine(id));
await this._rollArt(artData, 'odoratgout', oeuvre, r => this._resultRecetteCuisine(r));
}
@ -2453,8 +2450,8 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async rollMeditation(id) {
let meditation = duplicate(this.getMeditation(id));
let competence = duplicate(this.getCompetence(meditation.data.competence));
let meditation = Misc.data(this.getMeditation(id));
let competence = Misc.data(this.getCompetence(meditation.data.competence));
competence.data.defaut_carac = "intellect"; // Meditation = tjs avec intellect
let meditationData = {
competence: competence,
@ -2469,7 +2466,7 @@ export class RdDActor extends Actor {
use: { libre: false, conditions: true, },
carac: {}
};
meditationData.carac["intellect"] = duplicate(Misc.templateData(this).carac["intellect"]);
meditationData.carac["intellect"] = Misc.templateData(this).carac["intellect"];
console.log("rollMeditation !!!", meditationData);
@ -2627,7 +2624,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async ajouteNombreAstral(data) {
// Gestion expérience (si existante)
data.competence = this.getCompetence("astrologie");
data.competence = Misc.data(this.getCompetence("astrologie"));
data.selectedCarac = Misc.templateData(this).carac["vue"];
this._appliquerAjoutExperience(data);
@ -2762,7 +2759,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
rollArme(compName, armeName = undefined) {
let arme = armeName ? this.data.items.find(it => Misc.data(it).name == armeName && RdDItemArme.isArme(it)) : undefined;
let competence = this.getCompetence(compName);
let competence = Misc.data(this.getCompetence(compName));
if (arme || armeName || (competence.type == 'competencecreature' && competence.data.iscombat)) {
RdDCombat.createUsingTarget(this)?.attaque(competence, arme);
@ -3209,7 +3206,7 @@ export class RdDActor extends Actor {
let recette = this.getItemOfType(recetteId, 'recettealchimique');
const actorData = Misc.data(this);
if (recette) {
let competence = this.getCompetence("alchimie");
let competence = Misc.data(this.getCompetence("alchimie"));
let diffAlchimie = RdDAlchimie.getDifficulte(alchimieData);
let rollData = {
recette: recette,

View File

@ -95,7 +95,7 @@ export class RdDCarac {
* ainsi que de Perception active et volontaire.
*/
static isActionPhysique(selectedCarac) {
return Grammar.toLowerCaseNoAccent(selectedCarac?.label).match(/(apparence|force|agilite|dexterite|vue|ouie|odorat|empathie|melee|tir|lancer|derobee)/);
return Grammar.toLowerCaseNoAccent(selectedCarac?.label)?.match(/(apparence|force|agilite|dexterite|vue|ouie|odorat|empathie|melee|tir|lancer|derobee)/);
}
/* -------------------------------------------- */

View File

@ -796,11 +796,9 @@ export class RdDCombat {
}
// # utilisation esquive
let esquiveUsage = 0;
let esquive = this.defender.getCompetence("esquive");
if (esquive) {
esquiveUsage = this.defender.getItemUse(esquive._id);
}
const esquive = Misc.data(this.defender.getCompetence("esquive"));
const corpsACorps = Misc.data(this.defender.getCompetence("Corps à corps"));
const esquiveUsage = esquive ? this.defender.getItemUse(esquive._id) : 0;
const paramChatDefense = {
passeArme: attackerRoll.passeArme,
@ -810,7 +808,7 @@ export class RdDCombat {
attackerId: this.attackerId,
esquiveUsage: esquiveUsage,
defenderTokenId: this.defenderTokenId,
mainsNues: attackerRoll.dmg.mortalite != 'mortel' && this.defender.getCompetence("Corps à corps"),
mainsNues: attackerRoll.dmg.mortalite != 'mortel' && corpsACorps,
armes: this._filterArmesParade(this.defender, attackerRoll.competence, attackerRoll.arme),
diffLibre: attackerRoll.ajustements?.diffLibre?.value ?? 0,
attaqueParticuliere: attackerRoll.particuliere,
@ -955,12 +953,13 @@ export class RdDCombat {
_prepareParade(attackerRoll, armeParade) {
const compName = armeParade.data.competence;
const armeAttaque = attackerRoll.arme;
const parade = Misc.data(this.defender.getCompetence(compName));
let defenderRoll = {
passeArme: attackerRoll.passeArme,
diffLibre: attackerRoll.diffLibre,
attackerRoll: attackerRoll,
competence: this.defender.getCompetence(compName),
competence: parade,
arme: armeParade,
surprise: this.defender.getSurprise(true),
needParadeSignificative: ReglesOptionelles.isUsing('categorieParade') && RdDItemArme.needParadeSignificative(armeAttaque, armeParade),
@ -1011,7 +1010,7 @@ export class RdDCombat {
/* -------------------------------------------- */
async esquive(attackerRoll) {
let esquive = this.defender.getCompetence("esquive");
const esquive = Misc.data(this.defender.getCompetence("esquive"));
if (esquive == undefined) {
ui.notifications.error(this.defender.name + " n'a pas de compétence 'esquive'");
return;

View File

@ -268,7 +268,7 @@ export class RdDRoll extends Dialog {
let dmgText = Misc.toSignedString(rollData.dmg.total);
if (rollData.coupsNonMortels) {
dmgText = '(' + dmgText + ')';
dmgText = `(${dmgText}) non-mortel`
}
if (rollData.selectedSort) {
rollData.bonus = RdDItemSort.getCaseBonus(rollData.selectedSort, rollData.tmr.coord);
@ -287,7 +287,7 @@ export class RdDRoll extends Dialog {
// Mise à jour valeurs
$("#compdialogTitle").text(this._getTitle(rollData));
$('#coupsNonMortels').prop('checked', rollData.coupsNonMortels);
$("#dmg-arme-actor").text(dmgText);
$(".dmg-arme-actor").text(dmgText);
$('.table-ajustement').remove();
$(".table-resolution").remove();
$(".table-proba-reussite").remove();
@ -353,9 +353,9 @@ export class RdDRoll extends Dialog {
const niveau = Misc.toSignedString(rollData.competence.data.niveau);
if (compName == carac) {
// cas des créatures
return carac + " " + niveau
return carac + " Niveau " + niveau
}
const armeTitle = (rollData.arme) ? " (" + rollData.arme.name + ") " : "";
return carac + "/" + compName + armeTitle + " " + niveau
return carac + "/" + compName + armeTitle + " Niveau " + niveau
}
}

View File

@ -55,7 +55,7 @@ export const referenceAjustements = {
getValue: (rollData, actor) => actor.getEtatGeneral()
},
malusArmure: {
isVisible: (rollData, actor) => RdDCarac.isAgiliteOuDerivee(rollData.competence),
isVisible: (rollData, actor) => RdDCarac.isAgiliteOuDerivee(rollData.selectedCarac),
isUsed: (rollData, actor) => RdDCarac.isAgiliteOuDerivee(rollData.selectedCarac),
getLabel: (rollData, actor) => 'Malus armure',
getValue: (rollData, actor) => actor.getMalusArmure()
@ -131,6 +131,7 @@ export class RollDataAjustements {
for (var key in referenceAjustements) {
const reference = referenceAjustements[key];
rollData.ajustements[key] = {
visible: reference.isVisible && reference.isVisible(rollData, actor),
used: reference.isUsed(rollData, actor),
label: reference.getLabel && reference.getLabel(rollData, actor),
value: reference.getValue && reference.getValue(rollData, actor),

View File

@ -855,8 +855,7 @@ ul, li {
/* Position the tooltip text */
position: absolute;
z-index: 1;
top: -10px;
left: 18%;
left: 25px;
/* Fade in tooltip */
visibility: hidden;

View File

@ -1,6 +1,9 @@
<form class="skill-roll-dialog">
<h2 class="compdialog" id="compdialogTitle"></h2>
<div class="form-group">
<div class="grid grid-2col">
<div class="flex-group-left">
<div class="flexrow">
<label>Caractéristique </label>
<select name="carac" id="carac" data-dtype="String">
{{#select carac}}
@ -9,14 +12,63 @@
{{/each}}
{{/select}}
</select>
<label class="diffMoral">Moral: {{#if (gt moral 0)}}+{{/if}}{{moral}}</label>
<div class="tooltipAppelAuMoral divAppelAuMoral">
<img class="imgAppelAuMoral small-button-container" src="/systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg">
<span class="tooltipAppelAuMoralText">Sans appel au moral</span>
</div>
</div>
<div class="form-group">
{{#if arme}}
{{#if attackerRoll}}
{{#if attackerRoll.tactique}}
<div class="flexrow">
<label>Tactique: </label><label>{{attackerRoll.tactique}}</label>
</div>
{{/if}}
{{else}}
<div class="flexrow">
<label>Tactique:</label>
<span class="tooltip">
<select class="select-by-name" name="tactique" id="tactique-combat" data-dtype="String" {{#unless use.conditions}}disabled{{/unless}}>
<option value="Attaque normale">Attaque normale</option>
<option value="charge">Charge</option>
<option value="feinte">Feinte</option>
</select>
<div class="tooltiptext ttt-ajustements">
<div>
<strong>Charge</strong> : Les longueurs d'armes n'interviennent pas dans la charge, il faut gérer une initiative aléatoire dans ce cas.
<br><strong>Feinte</strong> : Vous devez avoir l'initative sur votre adversaire et y renoncer.
</div>
</div>
</span>
</div>
{{/if}}
{{#if ajustements.attaqueDefenseurSurpris.used}}
<div class="flexrow">
<label id="defenseur-surprise">{{ajustements.attaqueDefenseurSurpris.label}}</label>
</div>
{{/if}}
{{/if}}
{{#if arme}}
{{#unless attackerRoll}}
<div class="flexrow">
{{#if (eq arme.data.mortalite 'non-mortel')}}
<label>D&eacute;gats:</label><label class="dmg-arme-actor"></label>
{{else}}
<label>D&eacute;gats:
</label>
<span>
<input class="attribute-value" type="checkbox" id="coupsNonMortels" name="coupsNonMortels" {{#if coupsNonMortels}}checked{{/if}}/>
<label class="dmg-arme-actor">
</label>
</span>
{{/if}}
</div>
{{/unless}}
{{/if}}
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-enctotal.html"}}
</div>
<div class="flex-group-left">
<div class="flexrow">
{{#if attackerRoll}}
<label>Difficulté</label>
<label>{{diffLibre}}</label>
@ -30,7 +82,11 @@
{{/select}}
</select>
{{/if}}
<label>&nbsp;&nbsp;Conditions</label>
</div>
<div class="flexrow">
</div>
<div class="flexrow">
<label>Conditions</label>
<select name="diffConditions" id="diffConditions" data-dtype="number" {{#unless use.conditions}}disabled{{/unless}}>
{{#select diffConditions}}
{{#each ajustementsConditions as |key|}}
@ -38,45 +94,19 @@
{{/each}}
{{/select}}
</select>
</div>
<div class="flexrow">
<label class="diffMoral">Moral: {{#if (gt moral 0)}}+{{/if}}{{moral}}</label>
<div class="tooltipAppelAuMoral divAppelAuMoral">
<img class="imgAppelAuMoral small-button-container" src="/systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg">
<span class="tooltipAppelAuMoralText">Sans appel au moral</span>
</div>
</div>
<div id="tableAjustements" class="flexrow">
</div>
</div>
</div>
{{#if arme}}
<div class="form-group">
{{#if attackerRoll}}
{{#if attackerRoll.tactique}}
<label>Tactique: {{attackerRoll.tactique}}</label>
{{/if}}
<label>D&eacute;gats:</label><label id="dmg-arme-actor"></label>
<label></label>
{{else}}
<span class="tooltip">
<label>Tactique:</label>
<select class="select-by-name" name="tactique" id="tactique-combat" data-dtype="String" {{#unless use.conditions}}disabled{{/unless}}>
<option value="Attaque normale">Attaque normale</option>
<option value="charge">Charge</option>
<option value="feinte">Feinte</option>
</select>
<div class="tooltiptext ttt-ajustements">
<div>
<strong>Charge</strong> : Les longueurs d'armes n'interviennent pas dans la charge, il faut gérer une initiative aléatoire dans ce cas.
<br><strong>Feinte</strong> : Vous devez avoir l'initative sur votre adversaire et y renoncer.
</div>
</div>
</span>
<label>D&eacute;gats:</label><label id="dmg-arme-actor"></label>
<label>Non Mortel</label>
<input class="attribute-value" type="checkbox" id="coupsNonMortels" name="coupsNonMortels" {{#if coupsNonMortels}}checked{{/if}}/>
{{/if}}
{{#if ajustements.attaqueDefenseurSurpris.used}}
<label id="defenseur-surprise">{{ajustements.attaqueDefenseurSurpris.label}}</label>
{{/if}}
</div>
{{/if}}
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-enctotal.html"}}
<div id="tableAjustements">
</div>
<div id="tableResolution">
</div>
<div id="tableProbaReussite">

View File

@ -1,6 +1,8 @@
{{#if ajustements.encTotal.visible}}
<div class="form-group">
<label>Appliquer l'encombrement total comme malus ({{encTotal}}) ? </label>
<div class="flexrow">
<label>
<input class="attribute-value checkbox-by-name" type="checkbox" name="useMalusEncTotal" {{#if useMalusEncTotal}}checked{{/if}}/>
Appliquer l'encombrement comme malus ({{encTotal}}) ?
</label>
</div>
{{/if}}

View File

@ -1,6 +1,8 @@
{{#if surencMalusFlag}}
<div class="form-group">
<label for="xp">Appliquer le malus de sur-encombrement ? </label>
<div class="flexrow">
<label>
<input class="attribute-value checkbox-by-name" type="checkbox" name="useMalusSurenc" {{#if useMalusSurenc}}checked{{/if}}/>
Appliquer le sur-encombrement
</label>
</div>
{{/if}}