diff --git a/modules/vadentis-actor-sheet.js b/modules/vadentis-actor-sheet.js
index 4bd4c23..93f787f 100644
--- a/modules/vadentis-actor-sheet.js
+++ b/modules/vadentis-actor-sheet.js
@@ -70,6 +70,28 @@ export class VadentisActorSheet extends ActorSheet {
const li = $(ev.currentTarget).parents(".item");
VadentisUtility.confirmDelete(this, li);
});
+
+ html.find('.munition-moins').click(event => {
+ const li = $(event.currentTarget).parents(".item");
+ const item = this.actor.getOwnedItem(li.data("item-id"));
+ this.actor.decrementeMunition( item );
+ } );
+ html.find('.munition-plus').click(event => {
+ const li = $(event.currentTarget).parents(".item");
+ const item = this.actor.getOwnedItem(li.data("item-id"));
+ this.actor.incrementeMunition( item );
+ } );
+
+ html.find('.argent-moins').click(event => {
+ const li = $(event.currentTarget).parents(".item");
+ const item = this.actor.getOwnedItem(li.data("item-id"));
+ this.actor.decrementeArgent( item );
+ } );
+ html.find('.argent-plus').click(event => {
+ const li = $(event.currentTarget).parents(".item");
+ const item = this.actor.getOwnedItem(li.data("item-id"));
+ this.actor.incrementeArgent( item );
+ } );
html.find('.combat-label a').click((event) => {
let combatName = event.currentTarget.attributes.name.value;
@@ -119,6 +141,16 @@ export class VadentisActorSheet extends ActorSheet {
const weapon = this.actor.getOwnedItem(li.data("item-id"));
this.actor.rollDamage(weapon, 'criticaldamage');
});
+ html.find('.sort-damage').click((event) => {
+ const li = $(event.currentTarget).parents(".item");
+ const weapon = this.actor.getOwnedItem(li.data("item-id"));
+ this.actor.rollSortDevotionDamage(weapon, 'damage');
+ });
+ html.find('.sort-damage-critical').click((event) => {
+ const li = $(event.currentTarget).parents(".item");
+ const weapon = this.actor.getOwnedItem(li.data("item-id"));
+ this.actor.rollSortDevotionDamage(weapon, 'damagecritical');
+ });
html.find('.competence-base').change((event) => {
let skillName = event.currentTarget.attributes.skillname.value;
diff --git a/modules/vadentis-actor.js b/modules/vadentis-actor.js
index 082abad..ecfb6e0 100644
--- a/modules/vadentis-actor.js
+++ b/modules/vadentis-actor.js
@@ -108,6 +108,12 @@ export class VadentisActor extends Actor {
}
}
+ /* -------------------------------------------- */
+ buildListeActionsCombat( ) {
+ let armes = [];
+
+ }
+
/* -------------------------------------------- */
calculerSommeStats( ) {
for (const key in this.data.data.combat) {
@@ -144,7 +150,9 @@ export class VadentisActor extends Actor {
let maintain = (devotionSort.data.ismaintain)?"Oui":"Non";
let complex = (devotionSort.data.complexactions)?"Oui":"Non";
msgData.msg += `
Peut être maintenu: ${maintain}
Actions complexes : ${complex}`;
+ if ( !devotionSort.data.notes) devotionSort.data.notes = "";
msgData.msg += `
Description : ${devotionSort.data.notes.replace(/<\/?[^>]+(>|$)/g, "")}`;
+
let newEnergie = this.data.data.stats.pointsenergie.value - devotionSort.data.pe;
await this.update( {'data.stats.pointsenergie.value': newEnergie });
if (myRoll.results[0] >= devotionSort.data.valuecritical ) { // Critique ?
@@ -158,10 +166,10 @@ export class VadentisActor extends Actor {
if ( devotionSort.data.damage != "") {
let formula = devotionSort.data.damage;
if (myRoll.results[0] >= devotionSort.data.valuecritical ) { // Critique ?
- msgData.msg += `
Et provoque les dégats critiques suivants : `;
+ msgData.msg += `
Et provoque les dégats critiques suivants : [[/roll ${devotionSort.data.damagecritical}]]`;
formula = devotionSort.data.damagecritical;
} else {
- msgData.msg += `
Et provoque les dégats suivants : `;
+ msgData.msg += `
Et provoque les dégats suivants : [[/roll ${devotionSort.data.damage}]]`;
}
}
if ( newEnergie < 0) {
@@ -199,6 +207,23 @@ export class VadentisActor extends Actor {
});
}
+ /* -------------------------------------------- */
+ async rollSortDevotionDamage( sort, damageType ) {
+ let formula = VadentisUtility.processDamageString( sort.data.data[damageType], this );
+ let degatsRoll = await VadentisUtility.processRoll( formula );
+ let msgData = {
+ alias: this.name,
+ img: "systems/foundryvtt-vadentis/images/icons/tchat_dégâts_infligés.webp",
+ title: `Dégâts de ${sort.name}`,
+ msg: `Le sort ${sort.name} produit ${degatsRoll.total} Points de Dégâts (${formula}).`
+ }
+ ChatMessage.create({
+ //whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
+ content: await renderTemplate(`systems/foundryvtt-vadentis/templates/chat-generic-result.html`, msgData)
+ });
+ }
+
+
/* -------------------------------------------- */
async applyDamage( damageValue ) {
let pvData = this.data.data.stats.pointsvie;
@@ -278,6 +303,13 @@ export class VadentisActor extends Actor {
}
}
+ /* -------------------------------------------- */
+ rollSortOuDevotion( sortId ) {
+ let sort = this.data.items.find( item => item._id == sortId );
+ this.processSortDevotion( sort.type, sort);
+ }
+
+
/* -------------------------------------------- */
async rollTechnique( techniqueId ) {
let technique = this.data.items.find( item => item.type == 'technique' && item._id == techniqueId );
@@ -382,12 +414,39 @@ export class VadentisActor extends Actor {
let stat = this.data.data.magie[magieName];
this.genericRoll( stat, magieName );
}
+
+ /* -------------------------------------------- */
+ async incrementeArgent( arme ) {
+ let monnaie = this.data.items.find( item => item.type == 'monnaie' && item.name == arme.name);
+ if (monnaie) {
+ let newValeur = monnaie.data.nombre + 1;
+ await this.updateOwnedItem( { _id: monnaie._id, 'data.nombre': newValeur } );
+ }
+ }
+ /* -------------------------------------------- */
+ async decrementeArgent( arme ) {
+ let monnaie = this.data.items.find( item => item.type == 'monnaie' && item.name == arme.name);
+ if (monnaie) {
+ let newValeur = monnaie.data.nombre - 1;
+ newValeur = (newValeur <= 0) ? 0 : newValeur;
+ await this.updateOwnedItem( { _id: monnaie._id, 'data.nombre': newValeur } );
+ }
+ }
+ /* -------------------------------------------- */
+ async incrementeMunition( arme ) {
+ let armeTir = this.data.items.find( item => item.type == 'tir' && item.name == arme.name);
+ if (armeTir) {
+ let newMunition = armeTir.data.munition + 1;
+ await this.updateOwnedItem( { _id: armeTir._id, 'data.munition': newMunition } );
+ }
+ }
/* -------------------------------------------- */
async decrementeMunition( arme ) {
let armeTir = this.data.items.find( item => item.type == 'tir' && item.name == arme.name);
if (armeTir) {
let newMunition = armeTir.data.munition - 1;
+ newMunition = (newMunition <= 0) ? 0 : newMunition;
await this.updateOwnedItem( { _id: armeTir._id, 'data.munition': newMunition } );
}
}
diff --git a/modules/vadentis-hud.js b/modules/vadentis-hud.js
new file mode 100644
index 0000000..59430e4
--- /dev/null
+++ b/modules/vadentis-hud.js
@@ -0,0 +1,95 @@
+/* -------------------------------------------- */
+import { VadentisUtility } from "./vadentis-utility.js";
+
+/* -------------------------------------------- */
+export class VadentisTokenHud {
+
+ static init(){
+ // Integration du TokenHUD
+ Hooks.on('renderTokenHUD', (app, html, data) => { VadentisTokenHud.addTokenHudExtensions(app, html, data._id) });
+ }
+
+ /* -------------------------------------------- */
+ static async removeExtensionHud( app, html, tokenId) {
+ let combat = html.find('.control-icon.vadentis-combat');
+ combat.remove();
+ let sort = html.find('.control-icon.vadentis-sort');
+ sort.remove();
+ }
+
+ /* -------------------------------------------- */
+ static async addExtensionHud( app, html, tokenId ) {
+
+ let token = canvas.tokens.get(tokenId);
+ let actor = token.actor;
+ let combatant = game.combat.data.combatants.find(c => c.tokenId == token.data._id);
+ app.hasExtension = true;
+
+ let armesList = combatant.actor.getArmes() ;
+ let sortsList = combatant.actor.getSorts().concat( combatant.actor.getDevotions() );
+ const hudData = { combatant: combatant, armes: armesList, sorts: sortsList }
+
+ // sort
+ await VadentisTokenHud._configureSubMenu(html.find('.control-icon.combat'), 'systems/foundryvtt-vadentis/templates/hud-actor-sort.html', hudData,
+ (event) => {
+ let combatantId = event.currentTarget.attributes['data-combatant-id'].value;
+ const combatant = game.combat.getCombatant(combatantId);
+ let sortId = event.currentTarget.attributes['data-sort-id'].value;
+ combatant.actor.rollSortOuDevotion( sortId );
+ });
+
+ // combat
+ await VadentisTokenHud._configureSubMenu(html.find('.control-icon.target'), 'systems/foundryvtt-vadentis/templates/hud-actor-attaque.html', hudData,
+ (event) => {
+ let armeId = event.currentTarget.attributes['data-arme-id'].value;
+ actor.rollArme(armeId);
+ });
+ }
+
+ /* -------------------------------------------- */
+ static async addTokenHudExtensions(app, html, tokenId) {
+
+ html.find('.control-icon.combat').click(event => {
+ if ( event.currentTarget.className.includes('active')) {
+ VadentisTokenHud.removeExtensionHud( app, html, tokenId);
+ } else {
+ setTimeout( function() { RdDTokenHud.addExtensionHud( app, html, tokenId) } , 200 );
+ }
+ } );
+
+ let combatIcon = html.find('.control-icon.combat');
+ if ( combatIcon[0].className.includes('active') ) {
+ VadentisTokenHud.addExtensionHud( app, html, tokenId);
+ }
+ }
+
+ /* -------------------------------------------- */
+ static _showControlWhen(control, condition) {
+ if (condition) {
+ control.show();
+ }
+ else {
+ control.hide();
+ }
+ }
+
+ /* -------------------------------------------- */
+ static async _configureSubMenu(insertionPoint, template, hudData, onMenuItem) {
+ const hud = $(await renderTemplate(template, hudData));
+ const imgHud = hud.find('img.vadentis-hud-togglebutton');
+ const list = hud.find('div.vadentis-hud-list');
+
+ hud.toggleClass('active');
+ VadentisTokenHud._showControlWhen(list, hud.hasClass('active'));
+
+ imgHud.click(event => {
+ hud.toggleClass('active');
+ VadentisTokenHud._showControlWhen(list, hud.hasClass('active'));
+ });
+
+ list.find('.vadentis-hud-menu').click(onMenuItem);
+
+ insertionPoint.after(hud);
+ }
+
+}
\ No newline at end of file
diff --git a/modules/vadentis-main.js b/modules/vadentis-main.js
index c1eff2b..db18c56 100644
--- a/modules/vadentis-main.js
+++ b/modules/vadentis-main.js
@@ -13,6 +13,7 @@ import { VadentisItemSheet } from "./vadentis-item-sheet.js";
import { VadentisActorSheet } from "./vadentis-actor-sheet.js";
import { VadentisUtility } from "./vadentis-utility.js";
import { VadentisCombat } from "./vadentis-combat.js";
+import { VadentisTokenHud } from "./vadentis-hud.js";
/* -------------------------------------------- */
/* Foundry VTT Initialization */
@@ -60,6 +61,8 @@ Hooks.once("init", async function () {
Hooks.on('updateCombat', (combat, round, diff, id) => {
VadentisUtility.updateCombat(combat, round, diff, id);
});
+
+ VadentisTokenHud.init();
});
diff --git a/modules/vadentis-utility.js b/modules/vadentis-utility.js
index c809bbe..bf84b13 100644
--- a/modules/vadentis-utility.js
+++ b/modules/vadentis-utility.js
@@ -10,7 +10,9 @@ export class VadentisUtility extends Entity {
const templatePaths = [
'systems/foundryvtt-vadentis/templates/actor-sheet.html',
'systems/foundryvtt-vadentis/templates/item-sheet.html',
- 'systems/foundryvtt-vadentis/templates/editor-notes-gm.html'
+ 'systems/foundryvtt-vadentis/templates/editor-notes-gm.html',
+ 'systems/foundryvtt-vadentis/templates/hud-actor-attaque.html',
+ 'systems/foundryvtt-vadentis/templates/hud-actor-sort.html'
]
return loadTemplates(templatePaths);
}
diff --git a/styles/simple.css b/styles/simple.css
index 90c2fd8..de335fa 100644
--- a/styles/simple.css
+++ b/styles/simple.css
@@ -742,7 +742,7 @@ ul, li {
.control-icon.tokenhudicon.right {
margin-left: 8px;
}
-.rdd-hud-menu label {
+.vadentis-hud-menu label {
font-size: 0.75rem;
}
#token-hud .status-effects.active{
diff --git a/system.json b/system.json
index 0329fe1..4c44386 100644
--- a/system.json
+++ b/system.json
@@ -2,7 +2,7 @@
"name": "foundryvtt-vadentis",
"title": "Vadentis",
"description": "Système Vadentis pour FoundryVTT",
- "version": "0.1.6",
+ "version": "0.1.7",
"manifestPlusVersion": "1.0.0",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.9",
diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html
index 0f9df60..ec2215d 100644
--- a/templates/actor-sheet.html
+++ b/templates/actor-sheet.html
@@ -291,6 +291,7 @@
{{sort.name}}
{{sort.data.difficulty}}
+ {{sort.data.damage}} / {{sort.data.damagecritical}}