Preliminary verssion for fight

This commit is contained in:
LeRatierBretonnien 2020-06-07 23:16:29 +02:00
parent 1f875bafc5
commit 9d2c0da852
12 changed files with 295 additions and 141 deletions

View File

@ -27,18 +27,18 @@ long_line_behaviour=1
long_line_column=72 long_line_column=72
[files] [files]
current_page=10 current_page=7
FILE_NAME_0=8019;JSON;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplate.json;0;2 FILE_NAME_0=4085;JSON;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplate.json;0;2
FILE_NAME_1=2995;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor-sheet.js;0;2 FILE_NAME_1=3814;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor-sheet.js;0;2
FILE_NAME_2=9441;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Factor-sheet.html;0;2 FILE_NAME_2=10112;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Factor-sheet.html;0;2
FILE_NAME_3=6869;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor.js;0;2 FILE_NAME_3=1756;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-roll-dialog.js;0;2
FILE_NAME_4=6424;CSS;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fstyles%2Fsimple.css;0;2 FILE_NAME_4=4053;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor.js;0;2
FILE_NAME_5=4430;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-utility.js;0;2 FILE_NAME_5=1134;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Ftemplates%2Factors%2Factor-skills.html;0;2
FILE_NAME_6=1134;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Ftemplates%2Factors%2Factor-skills.html;0;2 FILE_NAME_6=0;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fdialog-competence.html;0;2
FILE_NAME_7=7542;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Fscripts%2Factor%2Fsheet%2Fcharacter-sheet.js;0;2 FILE_NAME_7=16055;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-utility.js;0;2
FILE_NAME_8=705;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fdialog-competence.html;0;2 FILE_NAME_8=543;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-main.js;0;2
FILE_NAME_9=985;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Fsimple.js;0;2 FILE_NAME_9=365;JSON;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fsystem.json;0;2
FILE_NAME_10=795;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fitem-arme-sheet.html;0;2 FILE_NAME_10=309;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Fhook-renderChatLog.js;0;2
[VTE] [VTE]
last_dir=/home/sigmar last_dir=/home/sigmar

View File

@ -42,10 +42,11 @@ export class RdDActorSheet extends ActorSheet {
} }
list.push(item); list.push(item);
} }
// Competence per category
data.competenceByCategory = {}; data.competenceByCategory = {};
if (data.itemsByType.competence) { if (data.itemsByType.competence) {
for (const item of data.itemsByType.competence) { for (const item of data.itemsByType.competence) {
console.log("Push...", item, item.data.categorie); //console.log("Push...", item, item.data.categorie);
let list = data.competenceByCategory[item.data.categorie]; let list = data.competenceByCategory[item.data.categorie];
if (!list) { if (!list) {
list = []; list = [];
@ -55,6 +56,17 @@ export class RdDActorSheet extends ActorSheet {
} }
} }
// Update arme list with niveau from the associated competence
if (data.itemsByType.arme) {
for (const arme of data.itemsByType.arme) {
arme.data.niveau = 0; // Per default, TODO to be fixed
for ( const melee of data.competenceByCategory.melee ) {
if (melee.name == arme.data.competence )
arme.data.niveau = melee.data.niveau
}
}
}
//endurance.max below is normal, this the base used to compute the grid. //endurance.max below is normal, this the base used to compute the grid.
data.data.fatigueHTML = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.endurance.max ).html() + "</table>"; data.data.fatigueHTML = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.endurance.max ).html() + "</table>";
data.data.materiel = this._checkNull(data.itemsByType['objet']); data.data.materiel = this._checkNull(data.itemsByType['objet']);
@ -63,7 +75,7 @@ export class RdDActorSheet extends ActorSheet {
data.data.livres = this._checkNull(data.itemsByType['livre']); data.data.livres = this._checkNull(data.itemsByType['livre']);
data.data.potions = this._checkNull(data.itemsByType['potions']); data.data.potions = this._checkNull(data.itemsByType['potions']);
data.data.competenceByCategory = data.competenceByCategory; data.data.competenceByCategory = data.competenceByCategory;
data.data.armes = data.itemsByType.arme;
//console.log(">>>>> data update"); //console.log(">>>>> data update");
return data; return data;
@ -98,47 +110,47 @@ export class RdDActorSheet extends ActorSheet {
this.actor.rollCompetence( compName); this.actor.rollCompetence( compName);
}); });
// Roll Weapon
html.find('.arme-label a').click((event) => {
let armeName = event.currentTarget.text;
this.actor.rollArme( armeName);
});
// On carac change // On carac change
$(".carac-value").change((event) => { $(".carac-value").change((event) => {
let caracName = event.currentTarget.name.replace(".value", "").replace("data.carac.", ""); let caracName = event.currentTarget.name.replace(".value", "").replace("data.carac.", "");
console.log("Value changed :", event, caracName); //console.log("Value changed :", event, caracName);
this.actor.updateCarac( caracName, parseInt(event.target.value) ); this.actor.updateCarac( caracName, parseInt(event.target.value) );
} ); } );
// On competence change // On competence change
$(".competence-value").change((event) => { $(".competence-value").change((event) => {
let compName = event.currentTarget.attributes.compname.value; let compName = event.currentTarget.attributes.compname.value;
console.log("Competence changed :", compName); //console.log("Competence changed :", compName);
this.actor.updateCompetence( compName, parseInt(event.target.value) ); this.actor.updateCompetence( compName, parseInt(event.target.value) );
} ); } );
$("#vie-plus").click((event) => { $("#vie-plus").click((event) => {
this.actor.santeIncDec("vie", 1); this.actor.santeIncDec("vie", 1);
this.actor.update({"data.sante.vie.value": this.actor.data.data.sante.vie.value});
this.render(true); this.render(true);
}); });
$("#vie-moins").click((event) => { $("#vie-moins").click((event) => {
this.actor.santeIncDec("vie", -1); this.actor.santeIncDec("vie", -1);
this.actor.update({"data.sante.vie.value": this.actor.data.data.sante.vie.value});
this.render(true); this.render(true);
}); });
$("#endurance-plus").click((event) => { $("#endurance-plus").click((event) => {
this.actor.santeIncDec("endurance", 1); this.actor.santeIncDec("endurance", 1);
this.actor.update({"data.sante.endurance.value": this.actor.data.data.sante.endurance.value});
this.render(true); this.render(true);
}); });
$("#endurance-moins").click((event) => { $("#endurance-moins").click((event) => {
this.actor.santeIncDec("endurance", -1); this.actor.santeIncDec("endurance", -1);
this.actor.update({"data.sante.endurance.value": this.actor.data.data.sante.endurance.value});
this.render(true); this.render(true);
}); });
$("#fatigue-plus").click((event) => { $("#fatigue-plus").click((event) => {
this.actor.santeIncDec("fatigue", 1); this.actor.santeIncDec("fatigue", 1);
this.actor.update({"data.sante.fatigue.value": this.actor.data.data.sante.fatigue.value});
this.render(true); this.render(true);
}); });
$("#fatigue-moins").click((event) => { $("#fatigue-moins").click((event) => {
this.actor.santeIncDec("fatigue", -1); this.actor.santeIncDec("fatigue", -1);
this.actor.update({"data.sante.fatigue.value": this.actor.data.data.sante.fatigue.value});
this.render(true); this.render(true);
}); });
} }

View File

@ -25,6 +25,9 @@ export class RdDActor extends Actor {
return super.create(data, options); return super.create(data, options);
} }
super.create(data, options); super.create(data, options);
// Create flags data
await this.setFlag("foundryvtt-reve-de-dragon", "rollData", {} );
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -48,10 +51,12 @@ export class RdDActor extends Actor {
_prepareCharacterData(actorData) { _prepareCharacterData(actorData) {
// Initialize empty items // Initialize empty items
RdDUtility.computeCarac(actorData.data); RdDUtility.computeCarac(actorData.data);
this.computeEtatGeneral();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
performRoll( rollData ) { async performRoll( rollData ) {
let myroll = new Roll("d100"); let myroll = new Roll("d100");
myroll.roll(); myroll.roll();
let quality = "Echec"; let quality = "Echec";
@ -66,38 +71,73 @@ export class RdDActor extends Actor {
let xpcomp = (Math.abs(rollData.finalLevel) % 2 == 1) ? xpcarac+1 : xpcarac; let xpcomp = (Math.abs(rollData.finalLevel) % 2 == 1) ? xpcarac+1 : xpcarac;
xpmsg = "<br>Points d'expérience gagné ! " + xpcarac + " - " + xpcomp; xpmsg = "<br>Points d'expérience gagné ! " + xpcarac + " - " + xpcomp;
} }
tache = 4; rollData.pointsDeTache = 4;
} else if (result <= (rollData.rollTarget.score /2) ) { } else if (result <= (rollData.rollTarget.score /2) ) {
quality = "Réussite Significative"; quality = "Réussite Significative";
tache = 2; rollData.pointsDeTache = 2;
} else if (result <= (rollData.rollTarget.score) ) { } else if (result <= (rollData.rollTarget.score) ) {
quality = "Réussite Normale"; quality = "Réussite Normale";
tache = 1; rollData.pointsDeTache = 1;
} else if (result < (rollData.rollTarget.epart) ) { } else if (result < (rollData.rollTarget.epart) ) {
quality = "Echec Normal"; quality = "Echec Normal";
tache = 0; rollData.pointsDeTache = 0;
} else if (result < (rollData.rollTarget.etotal) ) { } else if (result < (rollData.rollTarget.etotal) ) {
quality = "Echec Particulier"; quality = "Echec Particulier";
tache = -2; rollData.pointsDeTache = -2;
} else if (result >= (rollData.rollTarget.etotal) ) { } else if (result >= (rollData.rollTarget.etotal) ) {
quality = "Echec Total"; quality = "Echec Total";
tache = -4; rollData.pointsDeTache = -4;
} }
let chatOptions = { "content": "<strong>Test : " + rollData.selectedCarac.label + " / " + rollData.competence.name + "</strong><br>Jet : " + // Weapon management
let defenseMsg;
let specialStr = "<br>Points de taches : " + rollData.pointsDeTache; // Per default
if ( rollData.arme ) { // In case of fight, replace the "tache" per dommages + localization. "tache" indicates if result is OK or not
if ( rollData.pointsDeTache > 0 ) {
let myroll = new Roll("2d10");
myroll.roll();
rollData.degats = parseInt(myroll.result) + parseInt(rollData.arme.data.dommages) + parseInt(this.data.data.attributs.plusdom.value);
rollData.loc = RdDUtility.getLocalisation();
for (let target of game.user.targets) {
console.log("Target", target);
specialStr = "<br><strong>Cible</strong> : " + target.actor.data.name;
defenseMsg = { title: "Défense en combat",
content: "Action de défense en combat!<br><span class='chat-card-button-area'><a class='chat-card-button' id='encaisser-button' data-attackerid='"+
this.data._id + "' data-defenderid='" + target.actor.data._id + "'>Encaisser !</a></span>",
whisper: ChatMessage.getWhisperRecipients(target.actor.data.name) };
}
specialStr += "<br>Dommages : " + rollData.degats + "<br>Localisation : " + rollData.loc.label;
} else {
specialStr = "<br>Echec ! Pas de dommages";
}
}
// Save it for fight
await this.setFlag( "foundryvtt-reve-de-dragon", "rollData", undefined );
await this.setFlag( "foundryvtt-reve-de-dragon", "rollData", rollData );
console.log("MINE:", this);
let chatOptions = { content: "<strong>Test : " + rollData.selectedCarac.label + " / " + rollData.competence.name + "</strong><br>Jet : " +
rollData.selectedCarac.value + " / " + rollData.finalLevelStr + " - " + rollData.rollTarget.score + "%<br><strong>Résutat : </strong>" + myroll.total + "<br>" + rollData.selectedCarac.value + " / " + rollData.finalLevelStr + " - " + rollData.rollTarget.score + "%<br><strong>Résutat : </strong>" + myroll.total + "<br>" +
"<strong>" + quality + "</strong><br>Points de taches : " + tache + xpmsg, "<strong>" + quality + "</strong>" + specialStr + xpmsg,
"title": "Test" user: game.user._id,
title: "Résultat du test"
} }
ChatMessage.create( chatOptions ); ChatMessage.create( chatOptions );
if ( defenseMsg ) { // target hit !
ChatMessage.create( defenseMsg );
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
updateCarac( caracName, caracValue ) updateCarac( caracName, caracValue )
{ {
let data = this.data.data; //let data = this.data.data;
data.carac[caracName].value = caracValue; // Force update ? let caracpath = "data.carac." + caracName + ".value"
RdDUtility.computeCarac( data ); this.update( { caracpath: caracValue } );
//data.carac[caracName].value = caracValue; // Force update ?
//RdDUtility.computeCarac( data );
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -126,24 +166,27 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
testSiSonne( endurance ) testSiSonne( sante, endurance )
{ {
let myroll = new Roll("d20"); let myroll = new Roll("d20");
myroll.roll(); myroll.roll();
let result = myroll.total; let result = myroll.total;
if ( result <= endurance.value) if ( result <= endurance.value)
this.data.data.sante.sonne.value = false; sante.sonne.value = false;
if ( result > endurance.value || result == 20) // 20 is always a failure if ( result > endurance.value || result == 20) // 20 is always a failure
this.data.data.sante.sonne.value = true; sante.sonne.value = true;
if (result == 1) { if (result == 1) {
this.data.data.sante.sonne.value = false; sante.sonne.value = false;
this.data.data.carac.constitution.xp++; // 1 XP on 1 ! let xp = parseInt(this.data.data.carac.constitution.xp) + parseInt(1);
this.update( {"data.carac.constitution.xp": xp } ); // +1 XP !
// TODO : Output to chat
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
santeIncDec(name, inc ) { async santeIncDec(name, inc ) {
let data = this.data.data.sante[name]; const sante = duplicate(this.data.data.sante);
let data = sante[name];
let lastValue = data.value; // Useful for Endurance and Sonné let lastValue = data.value; // Useful for Endurance and Sonné
data.value = data.value + inc; data.value = data.value + inc;
if ( data.value > data.max ) data.value = data.max; if ( data.value > data.max ) data.value = data.max;
@ -151,13 +194,13 @@ export class RdDActor extends Actor {
if (name == "endurance") { if (name == "endurance") {
if ( inc < 0 ) // Each endurance lost -> fatigue lost if ( inc < 0 ) // Each endurance lost -> fatigue lost
this.data.data.sante.fatigue.value = this.data.data.sante.fatigue.value - inc sante.fatigue.value = sante.fatigue.value - inc
// If endurance is 0 -> -1 vie // If endurance is 0 -> -1 vie
if ( data.value == 0 ) { if ( data.value == 0 ) {
this.data.data.sante.vie.value = this.data.data.sante.vie.value - 1; sante.vie.value = sante.vie.value - 1;
} }
let diffVie = this.data.data.sante.vie.max - this.data.data.sante.vie.value; let diffVie = sante.vie.max - sante.vie.value;
if ( data.value > data.max - (diffVie*2) ) { if ( data.value > data.max - (diffVie*2) ) {
data.value = data.max - (diffVie*2); data.value = data.max - (diffVie*2);
} }
@ -167,20 +210,53 @@ export class RdDActor extends Actor {
if (data.value > maxEnd ) data.value = maxEnd; if (data.value > maxEnd ) data.value = maxEnd;
if ( blessures.critiques.nombre > 0 && data.value > 1) data.value = 1; if ( blessures.critiques.nombre > 0 && data.value > 1) data.value = 1;
if (lastValue - data.value > 1) this.testSiSonne(data); // Peut-être sonné si 2 points d'endurance perdus d'un coup if (lastValue - data.value > 1) this.testSiSonne(sante, data); // Peut-être sonné si 2 points d'endurance perdus d'un coup
} }
let diffEndurance = this.data.data.sante.endurance.max - this.data.data.sante.endurance.value; let diffEndurance = sante.endurance.max - this.data.data.sante.endurance.value;
if ( this.data.data.sante.fatigue.value < diffEndurance) // If endurance lost, then the same amount of fatigue cannot be recovered if ( sante.fatigue.value < diffEndurance) // If endurance lost, then the same amount of fatigue cannot be recovered
this.data.data.sante.fatigue.value = diffEndurance; sante.fatigue.value = diffEndurance;
console.log(">>>> NEW VI", name, data.value); await this.update( {"data.sante": sante } );
this.computeEtatGeneral(); }
/* -------------------------------------------- */
manageBlessures( blessuresData )
{
let blessures = duplicate(this.data.data.blessures);
if (blessuresData.legeres > 0 ) {
blessures.legeres.nombre += 1;
if ( blessures.legeres.nombre > 5 ) {
blessures.legeres.nombre = 5;
blessuresData.graves += 1;
} else {
blessures.legeres.liste[blessures.legeres.nombre-1].etat = "active";
blessures.legeres.liste[blessures.legeres.nombre-1].loc = blessuresData.locName;
}
}
if ( blessuresData.graves > 0 ) {
blessures.graves.nombre += 1;
if ( blessures.graves.nombre > 2 ) {
blessures.graves.nombre = 2;
blessuresData.critiques += 1;
} else {
blessures.graves.liste[blessures.graves.nombre-1].etat = "active";
blessures.graves.liste[blessures.graves.nombre-1].loc = blessuresData.locName;
}
}
if ( blessuresData.critiques > 0 ) {
blessuresData.endurance = this.data.data.sante.endurance.value; // Patch with real endurance current value (ie end -> 0 when critique)
blessures.critiques.nombre = 1;
blessures.critiques.liste[0].etat = "active";
blessures.critiques.liste[0].loc = blessuresData.locName;
}
if ( blessuresData.legeres > 0 || blessuresData.graves > 0 || blessuresData.critiques > 0 )
this.update( { "data.blessures": blessures } );
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
rollArme( armeName ) { rollArme( armeName ) {
let armeItem = RdDUtility.findCompetence( this.data.items, armeName); let armeItem = RdDUtility.findCompetence( this.data.items, armeName );
this.rollCompetence( armeItem.data.competence, armeItem ); this.rollCompetence( armeItem.data.competence, armeItem );
} }
@ -199,7 +275,40 @@ export class RdDActor extends Actor {
} }
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', rollData); let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', rollData);
new RdDRollDialog("competence", html, rollData, this ).render(true); if (armeItem) {
new RdDRollDialog("arme", html, rollData, this ).render(true);
} else {
new RdDRollDialog("competence", html, rollData, this ).render(true);
}
}
/* -------------------------------------------- */
computeArmure( locData )
{
/* TODO */
return 0;
}
/* -------------------------------------------- */
encaisserDommages( attackerActor )
{
let attackerRoll = attackerActor.getFlag("foundryvtt-reve-de-dragon", "rollData");
console.log("RollData!", attackerActor, attackerRoll);
let degatsReel = attackerRoll.degats - this.computeArmure(attackerRoll.loc);
let result = RdDUtility.computeBlessuresSante(degatsReel);
this.santeIncDec("vie", result.vie);
this.santeIncDec("endurance", result.vie);
result.locName = attackerRoll.loc.label; // Add the localisation namme
this.manageBlessures( result ); // Will upate the result table
ChatMessage.create( {title: "Blessures !", content: this.data.name + " a encaissé : " +
"<br>" + result.legeres + " légères, " + result.graves + " graves et " +
result.critiques + " critique." +
"<br>Et perdu : " +
"<br>" + result.endurance + " Endurance et " + result.vie + " Points de Vie" } );
this.computeEtatGeneral();
this.sheet.render(true);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -28,6 +28,10 @@ export class RdDRollDialog extends Dialog {
dialogConf.title = "Test de compétence", dialogConf.title = "Test de compétence",
dialogOptions.width = 600; dialogOptions.width = 600;
dialogOptions.height = 360; dialogOptions.height = 360;
} else if (mode == "arme") {
dialogConf.title = "Test de combat/arme",
dialogOptions.width = 600;
dialogOptions.height = 360;
} }
super(dialogConf, dialogOptions); super(dialogConf, dialogOptions);
@ -55,7 +59,8 @@ export class RdDRollDialog extends Dialog {
$("#roll-param").text( rollData.selectedCarac.value + " / " + rollData.finalLevelStr ); $("#roll-param").text( rollData.selectedCarac.value + " / " + rollData.finalLevelStr );
rollData.rollTarget = game.data.RdDUtility.getResolutionField( rollData.selectedCarac.value, rollData.finalLevel); rollData.rollTarget = game.data.RdDUtility.getResolutionField( rollData.selectedCarac.value, rollData.finalLevel);
let niveauStr = (rollData.competence.data.niveau >= 0) ? "+" + rollData.competence.data.niveau : rollData.competence.data.niveau; let niveauStr = (rollData.competence.data.niveau >= 0) ? "+" + rollData.competence.data.niveau : rollData.competence.data.niveau;
$("#compdialogTitle").text( rollData.competence.name + " - " + niveauStr + " - " + rollData.selectedCarac.label ); let armeTitle = ( rollData.arme ) ? " ("+rollData.arme.name+") " : ""; // If a weapon is there, add it in the title
$("#compdialogTitle").text( rollData.selectedCarac.label + "/" + rollData.competence.name + armeTitle + " " + niveauStr );
$(".table-resolution").remove(); $(".table-resolution").remove();
game.data.RdDUtility.makeHTMLResolutionTable( $("#resolutionTable"), rollData.selectedCarac.value-2, parseInt(rollData.selectedCarac.value) + 2, -10, 11, game.data.RdDUtility.makeHTMLResolutionTable( $("#resolutionTable"), rollData.selectedCarac.value-2, parseInt(rollData.selectedCarac.value) + 2, -10, 11,
rollData.selectedCarac.value, rollData.finalLevel ); rollData.selectedCarac.value, rollData.finalLevel );

View File

@ -74,9 +74,11 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html',
//Items //Items
'systems/foundryvtt-reve-de-dragon/templates/item-competence-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/item-competence-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-arme-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/competence-categorie.html', 'systems/foundryvtt-reve-de-dragon/templates/competence-categorie.html',
'systems/foundryvtt-reve-de-dragon/templates/competence-carac-defaut.html', 'systems/foundryvtt-reve-de-dragon/templates/competence-carac-defaut.html',
'systems/foundryvtt-reve-de-dragon/templates/competence-base.html', 'systems/foundryvtt-reve-de-dragon/templates/competence-base.html',
'systems/foundryvtt-reve-de-dragon/templates/arme-competence.html',
// Dialogs // Dialogs
'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html' 'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html'
]; ];
@ -214,12 +216,15 @@ export class RdDUtility {
data.carac.lancer.value = Math.floor( (parseInt(data.carac.tir.value) + parseInt(data.carac.force.value)) / 2); data.carac.lancer.value = Math.floor( (parseInt(data.carac.tir.value) + parseInt(data.carac.force.value)) / 2);
data.sante.vie.max = Math.ceil( parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value) /2 ); data.sante.vie.max = Math.ceil( parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value) /2 );
data.sante.vie.value = data.sante.vie.max; if ( data.sante.vie.value > data.sante.vie.max)
data.sante.vie.value = data.sante.vie.max;
let endurance = Math.max( parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value), parseInt(data.sante.vie.max) + parseInt(data.carac.volonte.value) ); let endurance = Math.max( parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value), parseInt(data.sante.vie.max) + parseInt(data.carac.volonte.value) );
data.sante.endurance.max = endurance; data.sante.endurance.max = endurance;
data.sante.endurance.value = endurance; if ( data.sante.endurance.value > endurance)
data.sante.endurance.value = endurance;
data.sante.fatigue.max = endurance*2; data.sante.fatigue.max = endurance*2;
data.sante.fatigue.value = 0; if ( data.sante.fatigue.value > data.sante.fatigue.max )
data.sante.fatigue.value = data.sante.fatigue.max;
data.attributs.sconst.value = 5; // Max ! data.attributs.sconst.value = 5; // Max !
if ( data.carac.constitution.value < 9 ) if ( data.carac.constitution.value < 9 )
@ -236,9 +241,9 @@ export class RdDUtility {
data.attributs.sust.value = 3; data.attributs.sust.value = 3;
//Compteurs //Compteurs
data.compteurs.reve.value = data.carac.reve.value; //data.compteurs.reve.value = data.carac.reve.value;
data.compteurs.reve.max = data.carac.reve.value; data.compteurs.reve.max = data.carac.reve.value;
data.compteurs.chance.value = data.carac.chance.value; //data.compteurs.chance.value = data.carac.chance.value;
data.compteurs.chance.max = data.carac.chance.value; data.compteurs.chance.max = data.carac.chance.value;
} }
@ -289,14 +294,55 @@ export class RdDUtility {
let myroll = new Roll("d20"); let myroll = new Roll("d20");
myroll.roll(); myroll.roll();
let result = myroll.total; let result = myroll.total;
if ( result <= 3 ) return "Jambe, genou, pied, jarret"; let txt = ""
if ( result <= 7 ) return "Hanche, cuisse, fesse"; if ( result <= 3 ) txt = "Jambe, genou, pied, jarret";
if ( result <= 9 ) return "Ventre, reins"; else if ( result <= 7 ) txt = "Hanche, cuisse, fesse";
if ( result <= 12 ) return "Poitrine, dos"; else if ( result <= 9 ) txt = "Ventre, reins";
if ( result <= 14 ) return "Avant-bras, main, coude"; else if ( result <= 12 ) txt = "Poitrine, dos";
if ( result <= 18 ) return "Epaule, bras, omoplate"; else if ( result <= 14 ) txt = "Avant-bras, main, coude";
if ( result == 19) return "Tête autre"; else if ( result <= 18 ) txt = "Epaule, bras, omoplate";
if ( result == 20) return "Tête visage"; else if ( result == 19) txt = "Tête autre";
else if ( result == 20) txt = "Tête visage";
return { result: result, label: txt };
}
/* -------------------------------------------- */
static computeBlessuresSante( degats )
{
console.log("Degats !!", degats);
let result = { "vie": 0,
"endurance": 0,
"legeres": 0,
"graves": 0,
"critiques": 0
};
if ( degats < 11 ) {
result.type = "contusion";
let myroll = new Roll("1d4");
myroll.roll();
result.endurance = - myroll.result;
} else if ( degats < 16 ) {
result.type = "blessure légère";
let myroll = new Roll("1d6");
myroll.roll();
result.endurance = - myroll.result;
result.legeres = 1
} else if (degats < 20 ) {
result.type = "blessure grave";
let myroll = new Roll("2d6");
myroll.roll();
result.endurance = - myroll.result;
result.vie = -2;
result.graves = 1;
} else {
result.type = "critique";
result.endurance = -100; // Force endurance to 0
result.vie = -4 - (degats - 20);
result.critiques = 1;
}
return result;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -330,4 +376,16 @@ export class RdDUtility {
} }
} }
/* -------------------------------------------- */
static async chatListeners( html )
{
html.on("click", '#encaisser-button', event => {
event.preventDefault();
console.log("Encaisser button", event);
let attackerActor = game.actors.get(event.currentTarget.attributes['data-attackerid'].value );
let defenderActor = game.actors.get(event.currentTarget.attributes['data-defenderid'].value );
defenderActor.encaisserDommages( attackerActor);
});
}
} }

View File

@ -1,50 +0,0 @@
/**
* RdD system
* Author: LeRatierBretonnien
* Software License: GNU GPLv3
*/
/* -------------------------------------------- */
/* -------------------------------------------- */
// Import Modules
import { RdDActor } from "./actor.js";
import { RdDItemSheet } from "./item-sheet.js";
import { RdDActorSheet } from "./actor-sheet.js";
import { RdDUtility } from "./rdd-utility.js";
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.once("init", async function() {
console.log(`Initializing Reve de Dragon System`);
// preload handlebars templates
RdDUtility.preloadHandlebarsTemplates();
/**
* Set an initiative formula for the system
* @type {String}
*/
CONFIG.Combat.initiative = {
formula: "1d20",
decimals: 2
};
// Define custom Entity classes
CONFIG.Actor.entityClass = RdDActor;
CONFIG.RDD = {}
CONFIG.RDD.resolutionTable = RdDUtility.buildResolutionTable();
CONFIG.RDD.level_category = RdDUtility.getLevelCategory();
CONFIG.RDD.carac_array = RdDUtility.getCaracArray();
CONFIG.RDD.bonusmalus = RdDUtility.getBonusMalus();
game.data.RdDUtility = RdDUtility;
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorSheet, { makeDefault: true });
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("foundryvtt-reve-de-dragon", RdDItemSheet, {makeDefault: true});
});

View File

@ -2,19 +2,19 @@
"name": "foundryvtt-reve-de-dragon", "name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon", "title": "Rêve de Dragon",
"description": "L'implémentation de Rêve de Dragon pour FoundryVTT", "description": "L'implémentation de Rêve de Dragon pour FoundryVTT",
"version": 0.6, "version": "0.7.0",
"minimumCoreVersion": "0.6.0", "minimumCoreVersion": "0.6.0",
"compatibleCoreVersion": "0.6.0", "compatibleCoreVersion": "0.6.0",
"templateVersion": 9, "templateVersion": 10,
"author": "LeRatierBretonnien", "author": "LeRatierBretonnien",
"esmodules": ["module/simple.js"], "esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ],
"styles": ["styles/simple.css"], "styles": ["styles/simple.css"],
"packs": [], "packs": [],
"languages": [], "languages": [],
"gridDistance": 5, "gridDistance": 5,
"gridUnits": "ft", "gridUnits": "ft",
"primaryTokenAttribute": "vie", "primaryTokenAttribute": "data.sante.vie",
"secondaryTokenAttribute": "fatigue", "secondaryTokenAttribute": "data.sante.fatigue",
"url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon/", "url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon/",
"manifest": "https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon/raw/master/system.json", "manifest": "https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon/raw/master/system.json",
"download": "https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon/-/archive/master/foundryvtt-reve-de-dragon-master.zip", "download": "https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon/-/archive/master/foundryvtt-reve-de-dragon-master.zip",

View File

@ -164,11 +164,11 @@
<span class="competence-title">XP</span> <span class="competence-title">XP</span>
</header> </header>
<ol class="item-list"> <ol class="item-list">
{{#each data.competenceByCategory.melee as |comp key|}} {{#each data.armes as |arme key|}}
<li class="item flexrow" data-attribute="{{key}}"> <li class="item flexrow" data-attribute="{{key}}">
<span class="competence-label" name="data.competenceByCategory.melee[{{key}}].name"><a>{{comp.name}}</a></span> <span class="arme-label" name="data.armes[{{key}}].name"><a>{{arme.name}}</a></span>
<input class="competence-value" type="text" name="data.competenceByCategory.melee[{{key}}].data.niveau" compname="{{comp.name}}" value="{{numberFormat comp.data.niveau decimals=0 sign=true}}" data-dtype="number"/> <span class="competence-label" name="data.armes[{{key}}].data.competence">{{arme.data.competence}}</span>
<input class="competence-xp" type="text" name="data.competenceByCategory.melee[{{key}}].data.xp" compname="{{comp.name}}" value="{{comp.data.xp}}" data-dtype="number"/> <span class="competence-label" name="data.armes[{{key}}].data.niveau">{{numberFormat arme.data.niveau decimals=0 sign=true}}</span>
</li> </li>
{{/each}} {{/each}}
</ol> </ol>

View File

@ -1 +1,17 @@
<option value="Dague">Dague</option>
<option value="Epée à 1 main">Epée à 1 main</option>
<option value="Epée à 2 mains">Epée à 2 mains</option>
<option value="Hache à 1 main">Hache à 1 main</option>
<option value="Hache à 2 mains">Hache à 2 mains</option>
<option value="Masse à 1 main">Masse à 1 main</option>
<option value="Masse à 2 mains">Masse à 2 mains</option>
<option value="Fléau">Fléau</option>
<option value="Lance">Lance</option>
<option value="Arme d'hast">Arme d'hast</option>
<option value="Bouclier">Bouclier</option>
<option value="Arbalète">Arbalète</option>
<option value="Arc">Arc</option>
<option value="Fronde">Fronde</option>
<option value="Dague de jet">Dague de jet</option>
<option value="Javelot">Javelot</option>
<option value="Fouet">Fouet</option>

View File

@ -1,4 +1,4 @@
<option value="generale">generale</option> <option value="generale">Générale</option>
<option value="particuliere">Particulières</option> <option value="particuliere">Particulières</option>
<option value="specialisee">Spécialisées</option> <option value="specialisee">Spécialisées</option>
<option value="connaissance">Connaissances</option> <option value="connaissance">Connaissances</option>

View File

@ -20,6 +20,12 @@
{{/select}} {{/select}}
</select> </select>
</div> </div>
{{#if arme}}
<div>
<label>Arme : {{arme.name}}</label>
<label>Degats : {{arme.data.dommages}}</label>
</div>
{{/if}}
<div class="form-group"> <div class="form-group">
<label for="categorie">Etat général</label><label>{{numberFormat etat decimals=0 sign=true}}</label> <label for="categorie">Etat général</label><label>{{numberFormat etat decimals=0 sign=true}}</label>
</div> </div>

View File

@ -9,13 +9,11 @@
{{!-- Sheet Body --}} {{!-- Sheet Body --}}
<section class="sheet-body"> <section class="sheet-body">
<div class="form-group"> <div class="form-group">
<label for="categorie">Compétence</label> <label for="categorie">Compétence associée</label>
<select name="data.competence" id="competence" data-dtype="String"> <select name="data.competence" id="competence" data-dtype="String">
{{#select item.data.competence}} {{#select item.data.competence}}
{{each armeCompetence as |competence key|}} {{>"systems/foundryvtt-reve-de-dragon/templates/arme-competence.html"}}
<option value={{bmvalue}}>{{competence.name}}</option> {{/select}}
{{/each}}
{{/select}}
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">