Ajout QoL
This commit is contained in:
@@ -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;
|
||||
|
@@ -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 += `<br>Peut être maintenu: ${maintain}<br>Actions complexes : ${complex}`;
|
||||
if ( !devotionSort.data.notes) devotionSort.data.notes = "";
|
||||
msgData.msg += `<br><strong>Description : </strong>${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 += `<br>Et provoque les dégats critiques suivants : `;
|
||||
msgData.msg += `<br>Et provoque les dégats critiques suivants : [[/roll ${devotionSort.data.damagecritical}]]`;
|
||||
formula = devotionSort.data.damagecritical;
|
||||
} else {
|
||||
msgData.msg += `<br>Et provoque les dégats suivants : `;
|
||||
msgData.msg += `<br>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 <strong>${degatsRoll.total} Points de Dégâts</strong> (${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 } );
|
||||
}
|
||||
}
|
||||
|
95
modules/vadentis-hud.js
Normal file
95
modules/vadentis-hud.js
Normal file
@@ -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);
|
||||
}
|
||||
|
||||
}
|
@@ -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();
|
||||
|
||||
});
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user