Merge branch 'roll-competence' into 'dev_1.1'
Roll competence See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!61
This commit is contained in:
commit
591abd00e9
@ -128,7 +128,7 @@ export class RdDActorCreatureSheet extends ActorSheet {
|
|||||||
// Roll Skill
|
// Roll Skill
|
||||||
html.find('.competence-label a').click((event) => {
|
html.find('.competence-label a').click((event) => {
|
||||||
let compName = event.currentTarget.text;
|
let compName = event.currentTarget.text;
|
||||||
this.actor.rollCompetence( compName );
|
this.actor.rollCompetenceCreature( compName );
|
||||||
});
|
});
|
||||||
|
|
||||||
html.find('#vie-plus').click((event) => {
|
html.find('#vie-plus').click((event) => {
|
||||||
|
@ -95,7 +95,7 @@ export class RdDActorEntiteSheet extends ActorSheet {
|
|||||||
// Roll Skill
|
// Roll Skill
|
||||||
html.find('.competence-label a').click((event) => {
|
html.find('.competence-label a').click((event) => {
|
||||||
let compName = event.currentTarget.text;
|
let compName = event.currentTarget.text;
|
||||||
this.actor.rollCompetence( compName );
|
this.actor.rollCompetenceCreature( compName );
|
||||||
});
|
});
|
||||||
|
|
||||||
html.find('#endurance-plus').click((event) => {
|
html.find('#endurance-plus').click((event) => {
|
||||||
|
@ -286,7 +286,7 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
html.find('.arme-label a').click((event) => {
|
html.find('.arme-label a').click((event) => {
|
||||||
let armeName = event.currentTarget.text;
|
let armeName = event.currentTarget.text;
|
||||||
let competenceName = event.currentTarget.attributes['data-competence-name'].value;
|
let competenceName = event.currentTarget.attributes['data-competence-name'].value;
|
||||||
this.actor.rollArme( armeName, competenceName);
|
this.actor.rollArme(competenceName, armeName);
|
||||||
});
|
});
|
||||||
// Initiative pour l'arme
|
// Initiative pour l'arme
|
||||||
html.find('.arme-initiative a').click((event) => {
|
html.find('.arme-initiative a').click((event) => {
|
||||||
|
335
module/actor.js
335
module/actor.js
@ -16,6 +16,7 @@ import { RdDDice } from "./rdd-dice.js";
|
|||||||
import { RdDRollTables } from "./rdd-rolltables.js";
|
import { RdDRollTables } from "./rdd-rolltables.js";
|
||||||
import { ChatUtility } from "./chat-utility.js";
|
import { ChatUtility } from "./chat-utility.js";
|
||||||
import { RdDItemSort } from "./item-sort.js";
|
import { RdDItemSort } from "./item-sort.js";
|
||||||
|
import { Grammar } from "./grammar.js";
|
||||||
|
|
||||||
export class RdDActor extends Actor {
|
export class RdDActor extends Actor {
|
||||||
|
|
||||||
@ -90,7 +91,6 @@ export class RdDActor extends Actor {
|
|||||||
if (actorData.type === 'personnage') this._prepareCharacterData(actorData);
|
if (actorData.type === 'personnage') this._prepareCharacterData(actorData);
|
||||||
if (actorData.type === 'creature') this.computeEtatGeneral(actorData);
|
if (actorData.type === 'creature') this.computeEtatGeneral(actorData);
|
||||||
if (actorData.type === 'humanoide') this.computeEtatGeneral(actorData);
|
if (actorData.type === 'humanoide') this.computeEtatGeneral(actorData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -141,14 +141,8 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async performRoll(rollData, attacker = undefined) {
|
async performRoll(rollData, attacker = undefined) {
|
||||||
|
|
||||||
// Cas des bonus de cases pour les sorts
|
|
||||||
let sortBonus = 0;
|
|
||||||
if (rollData.selectedSort) {
|
|
||||||
sortBonus = RdDItemSort.getCaseBonus( rollData.selectedSort, rollData.coord );
|
|
||||||
}
|
|
||||||
// garder le résultat
|
// garder le résultat
|
||||||
rollData.rolled = await RdDResolutionTable.roll(rollData.caracValue, rollData.finalLevel, sortBonus);
|
rollData.rolled = await RdDResolutionTable.rollData(rollData);
|
||||||
|
|
||||||
//console.log("performRoll", rollData)
|
//console.log("performRoll", rollData)
|
||||||
if ( !rollData.attackerRoll) {// Store in the registry if not a defense roll
|
if ( !rollData.attackerRoll) {// Store in the registry if not a defense roll
|
||||||
@ -206,7 +200,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
computeRecul( rollData ) { // Calcul du recul (p. 132)
|
computeRecul( rollData, encaisser = undefined ) { // Calcul du recul (p. 132)
|
||||||
if ( rollData.arme || encaisser ) {
|
if ( rollData.arme || encaisser ) {
|
||||||
if ( (rollData.attackerRoll.particuliereAttaque && rollData.attackerRoll.particuliereAttaque == 'force') || rollData.attackerRoll.isCharge) {
|
if ( (rollData.attackerRoll.particuliereAttaque && rollData.attackerRoll.particuliereAttaque == 'force') || rollData.attackerRoll.isCharge) {
|
||||||
let reculNiveau = this.data.data.taille.value - (rollData.attackerRoll.forceValue+rollData.attackerRoll.arme.dommages);
|
let reculNiveau = this.data.data.taille.value - (rollData.attackerRoll.forceValue+rollData.attackerRoll.arme.dommages);
|
||||||
@ -271,7 +265,6 @@ export class RdDActor extends Actor {
|
|||||||
if (rollData.needSignificative)
|
if (rollData.needSignificative)
|
||||||
explications += " Significative nécessaire!";
|
explications += " Significative nécessaire!";
|
||||||
}
|
}
|
||||||
this.computeRecul( rollData );
|
|
||||||
encaisser = rollData.needSignificative ? !rolled.isSign : !rolled.isSuccess;
|
encaisser = rollData.needSignificative ? !rolled.isSign : !rolled.isSuccess;
|
||||||
this.computeRecul( rollData, encaisser );
|
this.computeRecul( rollData, encaisser );
|
||||||
} else { // This is the attack roll!
|
} else { // This is the attack roll!
|
||||||
@ -303,12 +296,6 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort management
|
|
||||||
if (rollData.selectedSort) { // Lancement de sort !
|
|
||||||
resumeCompetence = rollData.selectedDraconic.name + "/" + rollData.selectedSort.name;
|
|
||||||
explications = await this._rollLancementDeSort(rollData, rolled);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save it for fight in the flags area
|
// Save it for fight in the flags area
|
||||||
game.system.rdd.rollDataHandler[this.data._id] = duplicate(rollData);
|
game.system.rdd.rollDataHandler[this.data._id] = duplicate(rollData);
|
||||||
|
|
||||||
@ -370,68 +357,6 @@ export class RdDActor extends Actor {
|
|||||||
return dmgArme + dmgPerso;
|
return dmgArme + dmgPerso;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
async _rollLancementDeSort(rollData, rolled) {
|
|
||||||
|
|
||||||
let sort = duplicate(rollData.selectedSort);
|
|
||||||
|
|
||||||
let closeTMR = true;
|
|
||||||
let coutReve = sort.data.ptreve_reel; // toujours positionné par cas de sort à ptreve variables
|
|
||||||
|
|
||||||
let explications = "<br>Lancement du sort <strong>" + sort.name + "</strong> : " + Misc.upperFirst(sort.data.draconic)
|
|
||||||
+ " pour " + coutReve + " points de Rêve"
|
|
||||||
+ "<br>Depuis la case " + rollData.coord + " (" + TMRUtility.getTMRDescription(rollData.coord).label + ")";
|
|
||||||
|
|
||||||
let myReve = duplicate(this.data.data.reve.reve);
|
|
||||||
if (rolled.isSuccess) { // Réussite du sort !
|
|
||||||
sort.ptreve_reel = coutReve;
|
|
||||||
if (rolled.isPart) {
|
|
||||||
coutReve = Math.max(Math.ceil(coutReve / 2), 1);
|
|
||||||
}
|
|
||||||
// Incrémenter/gére le bonus de case
|
|
||||||
RdDItemSort.incrementBonusCase(this, sort, rollData.coord);
|
|
||||||
|
|
||||||
if (myReve.value > coutReve){
|
|
||||||
explications += "<br>Réussite du sort: " + coutReve + " points de Rêve sont dépensés (Bonus de case : +" + rolled.bonus + "%)";
|
|
||||||
|
|
||||||
if (rollData.isSortReserve) {
|
|
||||||
// Mise en réserve
|
|
||||||
myReve.value--;
|
|
||||||
await this.sortMisEnReserve(rollData, sort);
|
|
||||||
closeTMR = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Todo 0 pts de reve !!!!
|
|
||||||
explications += "<br>Pas assez de rêve";
|
|
||||||
mergeObject(rollData, RdDResolutionTable.getResultat("echec"));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (rolled.isETotal) { // Echec total !
|
|
||||||
coutReve *= 2;
|
|
||||||
myReve.value = myReve.value - coutReve;
|
|
||||||
explications += "<br><strong>Echec TOTAL</strong> du sort : " + coutReve + " Points de Rêve";
|
|
||||||
} else {
|
|
||||||
coutReve = 0
|
|
||||||
explications += "<br>Echec du sort !";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
myReve.value = Math.max(myReve.value - coutReve, 0);
|
|
||||||
await this.update({ "data.reve.reve": myReve });
|
|
||||||
|
|
||||||
if (myReve.value == 0) { // 0 points de reve
|
|
||||||
ChatMessage.create({ content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" });
|
|
||||||
closeTMR = true;
|
|
||||||
}
|
|
||||||
if (closeTMR) {
|
|
||||||
this.currentTMR.close(); // Close TMR !
|
|
||||||
} else {
|
|
||||||
this.currentTMR.maximize(); // Re-display TMR
|
|
||||||
}
|
|
||||||
return explications
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async dormirChateauDormant() {
|
async dormirChateauDormant() {
|
||||||
let message = {
|
let message = {
|
||||||
@ -1324,38 +1249,6 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
async rollUnSort(coord) {
|
|
||||||
let draconicList = this.getDraconicList();
|
|
||||||
let sortList = duplicate(this.getSortList()); // Duplication car les pts de reve sont modifiés dans le sort
|
|
||||||
|
|
||||||
let rollData = {
|
|
||||||
selectedCarac: this.data.data.carac.reve,
|
|
||||||
etat: this.data.data.compteurs.etat.value,
|
|
||||||
draconicList: draconicList,
|
|
||||||
sortList: sortList,
|
|
||||||
selectedDraconic: this.getBestDraconic(),
|
|
||||||
selectedSort: sortList[0],
|
|
||||||
coord: coord,
|
|
||||||
coordLabel: TMRUtility.getTMRDescription( coord).label,
|
|
||||||
finalLevel: 0,
|
|
||||||
diffConditions: 0,
|
|
||||||
diffLibre: sortList[0].data.difficulte, // Per default at startup
|
|
||||||
coutreve: Array(20).fill().map((item, index) => 1 + index),
|
|
||||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
|
||||||
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
|
||||||
malusArmureValue: 0,
|
|
||||||
surencMalusFlag: false, // A ne pas utiliser pour les sorts
|
|
||||||
surencMalusValue: 0,
|
|
||||||
surencMalusApply: false,
|
|
||||||
isNatation: false,
|
|
||||||
useEncForNatation: false
|
|
||||||
}
|
|
||||||
if ( this.currentTMR) this.currentTMR.minimize(); // Hide
|
|
||||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html', rollData);
|
|
||||||
new RdDRollDialog("sort", html, rollData, this ).render(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
_createCallbackExperience() {
|
_createCallbackExperience() {
|
||||||
return {
|
return {
|
||||||
@ -1375,15 +1268,136 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollCarac( caracName )
|
async rollUnSort(coord) {
|
||||||
|
let sortList = duplicate(this.getSortList()); // Duplication car les pts de reve sont modifiés dans le sort
|
||||||
|
if (!sortList || sortList.length == 0)
|
||||||
{
|
{
|
||||||
let rollData = { selectedCarac: this.getCaracByName(caracName) };
|
ui.notifications.info("Aucun sort disponible!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let rollData = {
|
||||||
|
selectedCarac: this.data.data.carac.reve,
|
||||||
|
draconicList: this.getDraconicList(),
|
||||||
|
sortList: sortList,
|
||||||
|
selectedDraconic: this.getBestDraconic(),
|
||||||
|
selectedSort: sortList[0],
|
||||||
|
coord: coord,
|
||||||
|
coordLabel: TMRUtility.getTMRDescription( coord).label,
|
||||||
|
diffLibre: sortList[0].data.difficulte, // Per default at startup
|
||||||
|
coutreve: Array(20).fill().map((item, index) => 1 + index)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( this.currentTMR) this.currentTMR.minimize(); // Hide
|
||||||
|
const dialog = await RdDRoll.create(this, rollData,
|
||||||
|
{html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html'},
|
||||||
|
{
|
||||||
|
name: 'lancer-un-sort',
|
||||||
|
label: 'Lancer un sort',
|
||||||
|
callbacks: [
|
||||||
|
this._createCallbackExperience(),
|
||||||
|
{ action: r => this._rollUnSortResult(r, false) }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'mettre-en-reserve',
|
||||||
|
label: 'Mettre un sort en réserve',
|
||||||
|
callbacks: [
|
||||||
|
this._createCallbackExperience(),
|
||||||
|
{ action: r => this._rollUnSortResult(r, true) }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
);
|
||||||
|
dialog.render(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
async _rollUnSortResult(rollData, isSortReserve = false) {
|
||||||
|
rollData.isSortReserve = isSortReserve;
|
||||||
|
let rolled = rollData.rolled;
|
||||||
|
let sort = rollData.selectedSort;
|
||||||
|
let closeTMR = !rollData.isSortReserve;
|
||||||
|
|
||||||
|
let explications = rollData.isSortReserve
|
||||||
|
? ("<br>Mise en réserve du sort en " + rollData.coordLabel + "(" + rollData.coord + ")<strong>")
|
||||||
|
: "<br>Lancement du sort <strong>";
|
||||||
|
explications += sort.name + "</strong> : " + Misc.upperFirst(sort.data.draconic)
|
||||||
|
+ " pour " + sort.data.ptreve_reel + " points de Rêve"
|
||||||
|
+ "<br>Depuis la case " + rollData.coord + " (" + TMRUtility.getTMRDescription(rollData.coord).label + ")";
|
||||||
|
|
||||||
|
let depenseReve = sort.data.ptreve_reel;
|
||||||
|
let myReve = duplicate(this.data.data.reve.reve);
|
||||||
|
if (rolled.isSuccess) { // Réussite du sort !
|
||||||
|
//sort.ptreve_reel = coutReve;
|
||||||
|
if (rolled.isPart) {
|
||||||
|
depenseReve = Math.max(Math.floor(depenseReve / 2), 1);
|
||||||
|
}
|
||||||
|
if (rollData.isSortReserve) {
|
||||||
|
depenseReve++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myReve.value > depenseReve) {
|
||||||
|
explications += "<br>Réussite du sort: " + depenseReve + " points de Rêve sont dépensés (Bonus de case en " + rollData.coord + ": +" + rolled.bonus + "%)";
|
||||||
|
|
||||||
|
// Incrémenter/gére le bonus de case
|
||||||
|
RdDItemSort.incrementBonusCase(this, sort, rollData.coord);
|
||||||
|
|
||||||
|
if (rollData.isSortReserve) {
|
||||||
|
await this.sortMisEnReserve(rollData, sort);
|
||||||
|
closeTMR = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Todo 0 pts de reve !!!!
|
||||||
|
depenseReve = 0;
|
||||||
|
explications += "<br>Pas assez de rêve";
|
||||||
|
mergeObject(rollData, RdDResolutionTable.getResultat("echec"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (rolled.isETotal) { // Echec total !
|
||||||
|
depenseReve = Math.max(myReve.value, Math.floor(depenseReve * 1.5))
|
||||||
|
explications += "<br><strong>Echec TOTAL</strong> du sort : " + depenseReve + " Points de Rêve";
|
||||||
|
// TODO: mise en réserve d'un échec total...
|
||||||
|
} else {
|
||||||
|
depenseReve = 0
|
||||||
|
explications += "<br>Echec du sort !";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
myReve.value = Math.max(myReve.value - depenseReve, 0);
|
||||||
|
await this.update({ "data.reve.reve": myReve });
|
||||||
|
|
||||||
|
if (myReve.value == 0) { // 0 points de reve
|
||||||
|
ChatMessage.create({ content: this.name + " est réduit à 0 Points de Rêve, et tombe endormi !" });
|
||||||
|
closeTMR = true;
|
||||||
|
}
|
||||||
|
if (closeTMR) {
|
||||||
|
this.currentTMR.close(); // Close TMR !
|
||||||
|
} else {
|
||||||
|
this.currentTMR.maximize(); // Re-display TMR
|
||||||
|
}
|
||||||
|
// Final chat message
|
||||||
|
let chatOptions = {
|
||||||
|
content: "<strong>Test : " + rollData.selectedCarac.label + " / " + rollData.selectedDraconic.name + " / " + rollData.selectedSort.name + "</strong>"
|
||||||
|
+ "<br>Difficultés <strong>libre : " + rollData.diffLibre + "</strong> / conditions : " + Misc.toSignedString(rollData.diffConditions) +" / état : " + rollData.etat
|
||||||
|
+ RdDResolutionTable.explain(rolled)
|
||||||
|
+ explications
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatUtility.chatWithRollMode(chatOptions, this.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async rollCarac( caracName ) {
|
||||||
|
let rollData = {
|
||||||
|
selectedCarac: this.getCaracByName(caracName),
|
||||||
|
needSignificative : !this.isEntiteCauchemar() && this.data.data.sante.sonne.value
|
||||||
|
};
|
||||||
|
|
||||||
const dialog = await RdDRoll.create(this, rollData,
|
const dialog = await RdDRoll.create(this, rollData,
|
||||||
{html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html'},
|
{html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html'},
|
||||||
{
|
{
|
||||||
name: 'jet-'+caracName,
|
name: 'jet-'+caracName,
|
||||||
label: 'Lancer : '+rollData.selectedCarac.label,
|
label: 'Jet ' + Grammar.apostrophe('de', rollData.selectedCarac.label),
|
||||||
callbacks: [
|
callbacks: [
|
||||||
this._createCallbackExperience(),
|
this._createCallbackExperience(),
|
||||||
{ action: this._rollCaracResult }
|
{ action: this._rollCaracResult }
|
||||||
@ -1410,6 +1424,45 @@ export class RdDActor extends Actor {
|
|||||||
ChatUtility.chatWithRollMode(chatOptions, this.name)
|
ChatUtility.chatWithRollMode(chatOptions, this.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async rollCompetence( name ) {
|
||||||
|
let rollData = {
|
||||||
|
competence: duplicate(RdDUtility.findCompetence( this.data.items, name)),
|
||||||
|
needSignificative : !this.isEntiteCauchemar() && this.data.data.sante.sonne.value
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rollData.competence.type == 'competencecreature') {
|
||||||
|
// Fake competence pour créature
|
||||||
|
mergeObject(rollData.competence, { data : { defaut_carac: "carac_creature", categorie: "creature" } });
|
||||||
|
rollData.carac = { carac_creature: { label: competence.name, value: competence.data.carac_value } };
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
rollData.carac = this.data.data.carac;
|
||||||
|
}
|
||||||
|
console.log("rollCompetence !!!", rollData.competence);
|
||||||
|
|
||||||
|
const dialog = await RdDRoll.create(this, rollData,
|
||||||
|
{html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html'},
|
||||||
|
{
|
||||||
|
name: 'jet-competence',
|
||||||
|
label: 'Jet ' +Grammar.apostrophe('de', name),
|
||||||
|
callbacks: [
|
||||||
|
this._createCallbackExperience(),
|
||||||
|
{ action: this._competenceResult }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
);
|
||||||
|
dialog.render(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
_competenceResult(rollData) {
|
||||||
|
ChatUtility.chatWithRollMode({
|
||||||
|
content: "<strong>Test : " + rollData.selectedCarac.label + " / " + rollData.competence.name + "</strong>"
|
||||||
|
+ "<br>Difficultés <strong>libre : " + rollData.diffLibre + "</strong> / conditions : " + Misc.toSignedString(rollData.diffConditions) +" / état : " + rollData.etat
|
||||||
|
+ RdDResolutionTable.explain(rollData.rolled)
|
||||||
|
+ "<br>Points de taches : " + rollData.rolled.ptTache + ", ajustement qualité: " + rollData.rolled.ptQualite
|
||||||
|
}, this.name)
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollAppelChance( )
|
async rollAppelChance( )
|
||||||
@ -1526,28 +1579,51 @@ export class RdDActor extends Actor {
|
|||||||
this.currentTMR.render(true);
|
this.currentTMR.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
rollArme( armeName, competenceName=undefined ) {
|
async rollCompetenceCreature( compName ) {
|
||||||
let armeItem = this.data.items.find(item=>item.type==="arme" && (item.name === armeName));
|
let competence = RdDUtility.findCompetence( this.data.items, compName);
|
||||||
if (armeItem ) {
|
|
||||||
if ( competenceName == undefined) competenceName = armeItem.data.competence;
|
if ( competence.type == 'competencecreature' && competence.data.iscombat ) {
|
||||||
this.rollCompetence( competenceName, armeItem );
|
armeItem = { name: compName, data: { dommages: competence.data.dommages, dommagesReels: competence.data.dommages} };
|
||||||
} else {
|
this.rollCompetenceCombat(competence, armeItem);
|
||||||
this.rollCompetence( armeName ); //Bypass mode!
|
}
|
||||||
|
else {
|
||||||
|
this.rollCompetence(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollCompetence( name, armeItem=undefined, attackerRoll=undefined, attacker = undefined) {
|
rollArme(competenceName, armeName) {
|
||||||
|
let armeItem = this.data.items.find(item=>item.type==="arme" && (item.name === armeName));
|
||||||
|
if (armeItem && competenceName == undefined) competenceName = armeItem.data.competence;
|
||||||
|
let competence = RdDUtility.findCompetence(this.data.items, competenceName == undefined? armeName : competenceName);
|
||||||
|
|
||||||
|
if (armeItem==undefined && competence.type == 'competencecreature' && competence.data.iscombat ) {
|
||||||
|
armeItem = { name: name, data: { dommages: competence.data.dommages, dommagesReels: competence.data.dommages} };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (armeItem || armeName) {
|
||||||
|
this.rollCompetenceCombat( competenceName, armeItem );
|
||||||
|
} else {
|
||||||
|
this.rollCompetence( competence.name );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async rollCompetenceCombat( name, armeItem=undefined, attackerRoll=undefined, attacker = undefined) {
|
||||||
let competence = RdDUtility.findCompetence( this.data.items, name);
|
let competence = RdDUtility.findCompetence( this.data.items, name);
|
||||||
console.log("rollCompetence !!!", competence, armeItem, attackerRoll);
|
if ( competence.type == 'competencecreature' && competence.data.iscombat ) {
|
||||||
|
armeItem = { name: name, data: { dommages: competence.data.dommages, dommagesReels: competence.data.dommages} };
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("rollCompetenceCombat !!!", competence, armeItem, attackerRoll);
|
||||||
// Common rollData values
|
// Common rollData values
|
||||||
let rollData = {
|
let rollData = {
|
||||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||||
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
||||||
etat: this.data.data.compteurs.etat.value,
|
etat: this.data.data.compteurs.etat.value,
|
||||||
diffConditions: 0,
|
diffConditions: 0,
|
||||||
forceValue : (this.data.data.carac.force) ? this.data.data.carac.force.value : 0, // Utilisé pour le jet de recul
|
forceValue : attackerRoll ? (this.data.data.carac.force ? this.data.data.carac.force.value : this.data.data.carac.reve.value) : 0, // Utilisé pour le jet de recul
|
||||||
diffLibre: (attackerRoll) ? attackerRoll.diffLibre : 0,
|
diffLibre: (attackerRoll) ? attackerRoll.diffLibre : 0,
|
||||||
attackerRoll: attackerRoll,
|
attackerRoll: attackerRoll,
|
||||||
finalLevel: 0,
|
finalLevel: 0,
|
||||||
@ -1561,7 +1637,7 @@ export class RdDActor extends Actor {
|
|||||||
encValueForNatation: 0
|
encValueForNatation: 0
|
||||||
}
|
}
|
||||||
if ( this.type == 'personnage ') {
|
if ( this.type == 'personnage ') {
|
||||||
rollData.malusArmureValue = (this.data.data.attributs) ? this.data.data.attributs.malusarmure.value : 0;
|
rollData.malusArmureValue = (this.data.data.attributs && this.data.data.attributs.malusarmure) ? this.data.data.attributs.malusarmure.value : 0,
|
||||||
rollData.surencMalusFlag = (this.data.data.compteurs.surenc.value < 0);
|
rollData.surencMalusFlag = (this.data.data.compteurs.surenc.value < 0);
|
||||||
rollData.surencMalusValue = this.data.data.compteurs.surenc.value;
|
rollData.surencMalusValue = this.data.data.compteurs.surenc.value;
|
||||||
rollData.surencMalusApply = false;
|
rollData.surencMalusApply = false;
|
||||||
@ -1571,9 +1647,6 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( competence.type == 'competencecreature') { // Specific case for Creatures
|
if ( competence.type == 'competencecreature') { // Specific case for Creatures
|
||||||
if ( competence.data.iscombat ) {
|
|
||||||
armeItem = { name: name, data: { dommages: competence.data.dommages, dommagesReels: competence.data.dommages} };
|
|
||||||
}
|
|
||||||
competence.data.defaut_carac = "carac_creature"; // Fake default competence
|
competence.data.defaut_carac = "carac_creature"; // Fake default competence
|
||||||
competence.data.categorie = "creature"; // Fake default competence
|
competence.data.categorie = "creature"; // Fake default competence
|
||||||
rollData.competence = competence;
|
rollData.competence = competence;
|
||||||
@ -1705,17 +1778,21 @@ export class RdDActor extends Actor {
|
|||||||
{
|
{
|
||||||
let armeItem = this.getOwnedItem(armeId); // Item.data.data !
|
let armeItem = this.getOwnedItem(armeId); // Item.data.data !
|
||||||
console.log("Going to PARY !!!!!!!!!", armeItem, attackerRoll.diffLibre);
|
console.log("Going to PARY !!!!!!!!!", armeItem, attackerRoll.diffLibre);
|
||||||
|
<<<<<<< HEAD
|
||||||
if (armeItem.type == 'competencecreature') {
|
if (armeItem.type == 'competencecreature') {
|
||||||
this.rollCompetence( armeItem.name, armeItem.data, attackerRoll, attacker);
|
this.rollCompetence( armeItem.name, armeItem.data, attackerRoll, attacker);
|
||||||
} else {
|
} else {
|
||||||
this.rollCompetence( armeItem.data.data.competence, armeItem.data, attackerRoll, attacker);
|
this.rollCompetence( armeItem.data.data.competence, armeItem.data, attackerRoll, attacker);
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
this.rollCompetenceCombat( armeItem.data.data.competence, armeItem.data, attackerRoll, attacker);
|
||||||
|
>>>>>>> e2644f1 (Séparation compétences/combat)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
esquiverAttaque( attackerRoll, attacker = undefined )
|
esquiverAttaque( attackerRoll, attacker = undefined )
|
||||||
{
|
{
|
||||||
this.rollCompetence( "esquive", undefined, attackerRoll, attacker );
|
this.rollCompetenceCombat( "esquive", undefined, attackerRoll, attacker );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
18
module/grammar.js
Normal file
18
module/grammar.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
const articlesApostrophes = {
|
||||||
|
'de' : 'd\'',
|
||||||
|
'le' : 'l\'',
|
||||||
|
'la' : 'l\''
|
||||||
|
}
|
||||||
|
export class Grammar {
|
||||||
|
|
||||||
|
static apostrophe(article, word) {
|
||||||
|
if (articlesApostrophes[article] && Grammar.startsWithVoyel(word)) {
|
||||||
|
return articlesApostrophes[article] + word
|
||||||
|
}
|
||||||
|
return article + ' ' + word;
|
||||||
|
}
|
||||||
|
static startsWithVoyel(word) {
|
||||||
|
return word.match(/^[aeiouy]/i)
|
||||||
|
}
|
||||||
|
}
|
@ -104,7 +104,7 @@ export class RdDResolutionTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async roll(caracValue, finalLevel, bonus = 0 ) {
|
static async roll(caracValue, finalLevel, bonus = undefined ) {
|
||||||
let chances = this.computeChances(caracValue, finalLevel);
|
let chances = this.computeChances(caracValue, finalLevel);
|
||||||
chances.showDice = true;
|
chances.showDice = true;
|
||||||
this.updateChancesWithBonus( chances, bonus);
|
this.updateChancesWithBonus( chances, bonus);
|
||||||
|
@ -34,12 +34,13 @@ export class RdDRoll extends Dialog {
|
|||||||
finalLevel: 0,
|
finalLevel: 0,
|
||||||
diffConditions: 0,
|
diffConditions: 0,
|
||||||
diffLibre: 0,
|
diffLibre: 0,
|
||||||
malusArmureValue: actor.data.data.attributs ? actor.data.data.attributs.malusarmure.value : 0,
|
malusArmureValue: (actor.type == 'personnage ' && actor.data.data.attributs && actor.data.data.attributs.malusarmure) ? actor.data.data.attributs.malusarmure.value : 0,
|
||||||
surencMalusFlag: (actor.data.data.compteurs.surenc.value < 0),
|
surencMalusFlag: actor.type == 'personnage ' ? (actor.data.data.compteurs.surenc.value < 0) : false,
|
||||||
surencMalusValue: actor.data.data.compteurs.surenc.value,
|
surencMalusValue: actor.type == 'personnage ' ? actor.data.data.compteurs.surenc.value : 0,
|
||||||
surencMalusApply: false,
|
surencMalusApply: false,
|
||||||
isNatation: false,
|
isNatation: rollData.competence ? rollData.competence.name.toLowerCase().includes("natation") : false,
|
||||||
useEncForNatation: false
|
useEncForNatation: false,
|
||||||
|
encValueForNatation: actor.encombrementTotal ? Math.floor(actor.encombrementTotal) : 0
|
||||||
},
|
},
|
||||||
{ overwrite: false });
|
{ overwrite: false });
|
||||||
}
|
}
|
||||||
@ -74,6 +75,9 @@ export class RdDRoll extends Dialog {
|
|||||||
|
|
||||||
async onAction(action, html) {
|
async onAction(action, html) {
|
||||||
await RdDResolutionTable.rollData(this.rollData);
|
await RdDResolutionTable.rollData(this.rollData);
|
||||||
|
|
||||||
|
console.log("RdDRoll -=>", this.rollData, this.rollData.rolled);
|
||||||
|
|
||||||
if (action.callbacks)
|
if (action.callbacks)
|
||||||
for (let callback of action.callbacks) {
|
for (let callback of action.callbacks) {
|
||||||
if (callback.condition == undefined || callback.condition(this.rollData)) {
|
if (callback.condition == undefined || callback.condition(this.rollData)) {
|
||||||
@ -101,6 +105,7 @@ export class RdDRoll extends Dialog {
|
|||||||
|
|
||||||
// Sort management
|
// Sort management
|
||||||
if (rollData.selectedSort) {
|
if (rollData.selectedSort) {
|
||||||
|
rollData.bonus = RdDItemSort.getCaseBonus( rollData.selectedSort, rollData.coord ),
|
||||||
//console.log("Toggle show/hide", rollData.selectedSort);
|
//console.log("Toggle show/hide", rollData.selectedSort);
|
||||||
HtmlUtility._showControlWhen("#div-sort-difficulte", RdDItemSort.isDifficulteVariable(rollData.selectedSort))
|
HtmlUtility._showControlWhen("#div-sort-difficulte", RdDItemSort.isDifficulteVariable(rollData.selectedSort))
|
||||||
HtmlUtility._showControlWhen("#div-sort-ptreve", RdDItemSort.isCoutVariable(rollData.selectedSort))
|
HtmlUtility._showControlWhen("#div-sort-ptreve", RdDItemSort.isCoutVariable(rollData.selectedSort))
|
||||||
@ -153,6 +158,7 @@ export class RdDRoll extends Dialog {
|
|||||||
html.find('#sort').change((event) => {
|
html.find('#sort').change((event) => {
|
||||||
let sortKey = Misc.toInt(event.currentTarget.value);
|
let sortKey = Misc.toInt(event.currentTarget.value);
|
||||||
this.rollData.selectedSort = rollData.sortList[sortKey]; // Update the selectedCarac
|
this.rollData.selectedSort = rollData.sortList[sortKey]; // Update the selectedCarac
|
||||||
|
this.rollData.bonus = RdDItemSort.getCaseBonus( rollData.selectedSort, rollData.coord );
|
||||||
RdDItemSort.setCoutReveReel(rollData.selectedSort);
|
RdDItemSort.setCoutReveReel(rollData.selectedSort);
|
||||||
//console.log("RdDRollSelectDialog - Sort selection", rollData.selectedSort);
|
//console.log("RdDRollSelectDialog - Sort selection", rollData.selectedSort);
|
||||||
updateRollResult(rollData);
|
updateRollResult(rollData);
|
||||||
|
@ -388,7 +388,7 @@ export class RdDTMRDialog extends Dialog {
|
|||||||
console.log("declencheSortEnReserve", sortReserve)
|
console.log("declencheSortEnReserve", sortReserve)
|
||||||
const declenchementSort = "Vous avez déclenché le sort <strong>" + sortReserve.sort.name
|
const declenchementSort = "Vous avez déclenché le sort <strong>" + sortReserve.sort.name
|
||||||
+ "</strong> en réserve en " + sortReserve.coord + " (" + TMRUtility.getTMRDescription(sortReserve.coord).label
|
+ "</strong> en réserve en " + sortReserve.coord + " (" + TMRUtility.getTMRDescription(sortReserve.coord).label
|
||||||
+ ") avec " + sortReserve.sort.ptreve_reel + " points de Rêve";
|
+ ") avec " + sortReserve.sort.data.ptreve_reel + " points de Rêve";
|
||||||
this._tellToGM(declenchementSort);
|
this._tellToGM(declenchementSort);
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ export class RdDTokenHud {
|
|||||||
hudCombat.find('label').click(async (event) => {
|
hudCombat.find('label').click(async (event) => {
|
||||||
let armeIndex = event.currentTarget.attributes['data-arme-id'].value;
|
let armeIndex = event.currentTarget.attributes['data-arme-id'].value;
|
||||||
let arme = armesList[armeIndex];
|
let arme = armesList[armeIndex];
|
||||||
actor.rollArme( arme.name, arme.data.competence);
|
actor.rollArme( arme.data.competence, arme.name);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user