diff --git a/module/actor.js b/module/actor.js
index bd2f631c..49ebc715 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -13,6 +13,7 @@ import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { RdDDice } from "./rdd-dice.js";
import { RdDRollTables } from "./rdd-rolltables.js";
import { ChatUtility } from "./chat-utility.js";
+import { RdDItemSort } from "./item-sort.js";
export class RdDActor extends Actor {
@@ -135,9 +136,13 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
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
- rollData.rolled = await RdDResolutionTable.roll(rollData.caracValue, rollData.finalLevel);
-
+ rollData.rolled = await RdDResolutionTable.roll(rollData.caracValue, rollData.finalLevel, sortBonus);
//console.log("performRoll", rollData)
if ( !rollData.attackerRoll) {// Store in the registry if not a defense roll
@@ -313,8 +318,11 @@ export class RdDActor extends Actor {
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 += "
Réussite du sort: " + coutReve + " points de Rêve sont dépensés";
+ explications += "
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
@@ -354,6 +362,7 @@ export class RdDActor extends Actor {
return explications
}
+ /* -------------------------------------------- */
async dormirChateauDormant() {
let message = {
whisper: ChatUtility.getWhisperRecipientsAndGMs( this.name ),
@@ -373,6 +382,7 @@ export class RdDActor extends Actor {
ChatMessage.create( message );
}
+ /* -------------------------------------------- */
async _recupererBlessures(message, type, liste, moindres) {
let count = 0;
const definitions = RdDUtility.getDefinitionsBlessures();
@@ -813,7 +823,7 @@ export class RdDActor extends Actor {
let refoulement = duplicate(this.data.data.reve.refoulement);
refoulement.value = refoulement.value + value;
- let total = new Roll("d20").roll().total;
+ let total = new Roll("1d20").roll().total;
if ( total <= refoulement.value ) {
refoulement.value = 0;
this.ajouterSouffle();
@@ -926,7 +936,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
testSiSonne( sante, endurance )
{
- let result = new Roll("d20").roll().total;
+ let result = new Roll("1d20").roll().total;
if ( result <= endurance)
sante.sonne.value = false;
if ( result > endurance || result == 20) // 20 is always a failure
diff --git a/module/item-sheet.js b/module/item-sheet.js
index cdcfdf6a..aef5a734 100644
--- a/module/item-sheet.js
+++ b/module/item-sheet.js
@@ -1,3 +1,5 @@
+import { RdDItemSort } from "./item-sort.js";
+
/**
* Extend the basic ItemSheet with some very simple modifications
* @extends {ItemSheet}
@@ -25,6 +27,15 @@ export class RdDItemSheet extends ItemSheet {
sheetBody.css("height", bodyHeight);
return position;
}
+
+ /* -------------------------------------------- */
+ getData() {
+ let data = super.getData();
+
+ data.bonusCaseList = RdDItemSort.getBonusCaseList(data, true);
+
+ return data;
+ }
/* -------------------------------------------- */
@@ -63,6 +74,9 @@ export class RdDItemSheet extends ItemSheet {
/** @override */
_updateObject(event, formData) {
+ // Données de bonus de cases ?
+ formData = RdDItemSort.buildBonusCaseStringFromFormData( formData );
+
return this.object.update(formData);
}
}
diff --git a/module/item-sort.js b/module/item-sort.js
index b03de5f9..c7fae266 100644
--- a/module/item-sort.js
+++ b/module/item-sort.js
@@ -1,20 +1,28 @@
+/* -------------------------------------------- */
import { Misc } from "./misc.js";
+import { TMRUtility } from "./tmr-utility.js";
+/* -------------------------------------------- */
export class RdDItemSort extends Item {
+ /* -------------------------------------------- */
static isDifficulteVariable(sort) {
return sort && (sort.data.difficulte.toLowerCase() == "variable");
}
+
+ /* -------------------------------------------- */
static isCoutVariable(sort) {
return sort && (sort.data.ptreve.toLowerCase() == "variable" || sort.data.ptreve.indexOf("+") >= 0);
}
+ /* -------------------------------------------- */
static setCoutReveReel(sort){
if (sort) {
sort.data.ptreve_reel = this.isCoutVariable(sort) ? 1 : sort.data.ptreve;
}
}
+ /* -------------------------------------------- */
static getDifficulte(sort, variable) {
if (sort && !RdDItemSort.isDifficulteVariable(sort)) {
return Misc.toInt(sort.data.difficulte);
@@ -22,4 +30,89 @@ export class RdDItemSort extends Item {
return variable;
}
+ /* -------------------------------------------- */
+ static buildBonusCaseList( caseBonusString, newCase ) {
+ let bonusCaseList = [];
+ let bonusCaseArray = caseBonusString.split(',');
+ for( let bonusCase of bonusCaseArray) {
+ let bonusSplit = bonusCase.split(':');
+ bonusCaseList.push( { case: bonusSplit[0], bonus: bonusSplit[1] } );
+ }
+ if ( newCase )
+ bonusCaseList.push( {case: "Nouvelle", bonus: 0} );
+ return bonusCaseList;
+ }
+
+ /* -------------------------------------------- */
+ /**
+ * Retourne une liste de bonus/case pour un item-sheet
+ * @param {} item
+ */
+ static getBonusCaseList( data, newCase = false ) {
+
+ let bonusCaseList = [];
+ // Gestion spéciale case bonus
+ if ( data.item.type == 'sort') {
+ bonusCaseList = this.buildBonusCaseList(data.data.bonuscase, newCase );
+ }
+ return bonusCaseList;
+ }
+
+ /* -------------------------------------------- */
+ /** Met à jour les données de formulaire
+ * si static des bonus de cases sont présents
+ * */
+ static buildBonusCaseStringFromFormData( formData ) {
+ if ( formData.bonusValue ) {
+ let list = [];
+ for(let i=0; i sur " + rolled.score + "%";
if (rolled.caracValue != null && rolled.finalLevel!= null) {
@@ -84,19 +85,32 @@ export class RdDResolutionTable {
return message;
}
+
/* -------------------------------------------- */
- static async roll(caracValue, finalLevel) {
+ static updateChancesWithBonus( chances, bonus ) {
+ let newScore = Number(chances.score) + Number(bonus);
+ chances.score = newScore;
+ chances.sign = this._reussiteSignificative(newScore);
+ chances.part = this._reussitePart(newScore);
+ chances.epart = this._echecParticulier(newScore);
+ chances.etotal = this._echecTotal(newScore);
+ }
+
+ /* -------------------------------------------- */
+ static async roll(caracValue, finalLevel, bonus = 0 ) {
let chances = this.computeChances(caracValue, finalLevel);
chances.showDice = true;
+ this.updateChancesWithBonus( chances, bonus);
let rolled = await this.rollChances(chances);
rolled.caracValue = caracValue;
rolled.finalLevel = finalLevel;
+ rolled.bonus = bonus;
return rolled;
}
/* -------------------------------------------- */
static async rollChances(chances) {
- let myRoll = new Roll("d100").roll();
+ let myRoll = new Roll("1d100").roll();
myRoll.showDice = chances.showDice;
await RdDDice.show(myRoll);
chances.roll = myRoll.total;
@@ -211,6 +225,7 @@ export class RdDResolutionTable {
return table;
}
+ /* -------------------------------------------- */
static _buildHTMLHeader(dataRow, minLevel, maxLevel) {
let tr = $("
");
@@ -226,6 +241,7 @@ export class RdDResolutionTable {
return tr;
}
+ /* -------------------------------------------- */
static _buildHTMLRow(dataRow, rowIndex, caracValue, levelValue, minLevel, maxLevel) {
let tr = $("
");
let max = maxLevel;
diff --git a/module/rdd-roll-dialog.js b/module/rdd-roll-dialog.js
index 01833848..17a5adaf 100644
--- a/module/rdd-roll-dialog.js
+++ b/module/rdd-roll-dialog.js
@@ -44,16 +44,17 @@ export class RdDRollDialog extends Dialog {
}
super(dialogConf, dialogOptions)
- this.mode = mode
- this.rollData = rollData
- this.actor = actor
- this.attacker = attacker
+ this.mode = mode;
+ this.rollData = rollData;
+ this.actor = actor;
+ if (attacker)
+ this.attacker = attacker;
}
/* -------------------------------------------- */
performRollSort(html, isSortReserve = false) {
this.rollData.isSortReserve = isSortReserve;
- this.actor.performRoll(this.rollData, attacker);
+ this.actor.performRoll(this.rollData, this.attacker);
}
/* -------------------------------------------- */
diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js
index 58ab0d15..8eaca821 100644
--- a/module/rdd-tmr-dialog.js
+++ b/module/rdd-tmr-dialog.js
@@ -271,7 +271,7 @@ export class RdDTMRDialog extends Dialog {
let rencontre = this.rencontresExistantes.find(prev => prev.coord == coordTMR);
if (rencontre == undefined) {
- let myRoll = new Roll("d7").roll();
+ let myRoll = new Roll("1d7").roll();
if (myRoll.total == 7) {
rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
}
diff --git a/module/rdd-utility.js b/module/rdd-utility.js
index c4ab40b8..56627a73 100644
--- a/module/rdd-utility.js
+++ b/module/rdd-utility.js
@@ -540,7 +540,7 @@ export class RdDUtility {
/* -------------------------------------------- */
static getLocalisation( )
{
- let result = new Roll("d20").roll().total;
+ let result = new Roll("1d20").roll().total;
let txt = ""
if ( result <= 3 ) txt = "Jambe, genou, pied, jarret";
else if ( result <= 7 ) txt = "Hanche, cuisse, fesse";
diff --git a/module/tmr-utility.js b/module/tmr-utility.js
index b5fa18b4..1012cdad 100644
--- a/module/tmr-utility.js
+++ b/module/tmr-utility.js
@@ -253,9 +253,12 @@ const tmrMovePattern =
{ name: 'topleft', x: -1, y: -1 }
]
+/* -------------------------------------------- */
+
/* -------------------------------------------- */
export class TMRUtility {
+
/* -------------------------------------------- */
static convertToTMRCoord( x, y )
{
@@ -264,6 +267,18 @@ export class TMRUtility {
return letterX+y
}
+ /* -------------------------------------------- */
+ static verifyTMRCoord( coord ) {
+ let TMRregexp = new RegExp(/([A-M])(\d+)/g);
+ let res = TMRregexp.exec( coord );
+ if (res && res[1] && res[2]) {
+ if (res[2] > 0 && res[2] < 16) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/* -------------------------------------------- */
static convertToCellCoord( coordTMR )
{
@@ -294,7 +309,7 @@ export class TMRUtility {
/* -------------------------------------------- */
static getDirectionPattern() {
- let index = new Roll("d"+tmrMovePattern.length+" -1").roll().total;
+ let index = new Roll("1d"+tmrMovePattern.length+" -1").roll().total;
return tmrMovePattern[index];
}
@@ -344,7 +359,7 @@ export class TMRUtility {
static async rencontreTMRTypeCase(typeTMR, roll=undefined) {
if (!roll) {
//roll = await RdDDice.show(new Roll("d100").evaluate()).total;
- roll = new Roll("d100").roll().total;
+ roll = new Roll("1d100").roll().total;
console.log("rencontreTMRTypeCase", roll);
}
typeTMR = typeTMR.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
@@ -373,7 +388,7 @@ export class TMRUtility {
return false;
}
if (roll == undefined) {
- roll = new Roll("d100").evaluate().total;
+ roll = new Roll("1d100").evaluate().total;
}
roll = Math.max(1, Math.min(roll, 100));
diff --git a/system.json b/system.json
index 96adade5..c3ed785f 100644
--- a/system.json
+++ b/system.json
@@ -5,7 +5,7 @@
"version": "1.1.0",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.7",
- "templateVersion": 54,
+ "templateVersion": 55,
"author": "LeRatierBretonnien",
"esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ],
"styles": ["styles/simple.css"],
diff --git a/template.json b/template.json
index 05d28638..0d3aba8c 100644
--- a/template.json
+++ b/template.json
@@ -530,7 +530,7 @@
}
},
"Item": {
- "types": ["objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle", "tete", "competencecreature", "tarot"],
+ "types": ["objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle", "tete", "competencecreature", "tarot", "monnaie"],
"objet": {
"description": "",
"quantite": 1,
@@ -611,7 +611,8 @@
"caseTMR": "",
"caseTMRspeciale": "",
"ptreve": "",
- "xp": 0
+ "xp": 0,
+ "bonuscase": ""
},
"herbe": {
"description": "",
@@ -675,11 +676,17 @@
},
"tete": {
"description": ""
- },
+ },
"tarot": {
"concept":"",
"aspect":"",
"description": ""
- }
+ },
+ "monnaie": {
+ "quantite": "",
+ "valeur_deniers":0,
+ "encombrement":0,
+ "description": ""
}
}
+}
diff --git a/templates/item-sort-sheet.html b/templates/item-sort-sheet.html
index 253ecff8..2a81d1c1 100644
--- a/templates/item-sort-sheet.html
+++ b/templates/item-sort-sheet.html
@@ -56,6 +56,13 @@
+ {{#each bonusCaseList as |bcData key|}}
+
+
+
+
+
+ {{/each}}