forked from public/foundryvtt-reve-de-dragon
Merge branch 'v1.4' of https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon into v1.4
This commit is contained in:
@ -35,49 +35,17 @@ export class RdDActorSheet extends ActorSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
// 0.8.0
|
||||
const objectData = Misc.data(this.object);
|
||||
// -------------- version 0.7.9
|
||||
// let formData = {
|
||||
// cssClass: this.entity.owner ? "editable" : "locked",
|
||||
// editable: this.isEditable,
|
||||
// entity: duplicate(this.entity.data),
|
||||
// limited: this.entity.limited,
|
||||
// options: this.options,
|
||||
// owner: this.entity.owner,
|
||||
// title: this.title
|
||||
// }
|
||||
// // Entity data
|
||||
// formData.actor = formData.entity;
|
||||
// formData.data = formData.entity.data;
|
||||
|
||||
// // Owned items
|
||||
// formData.items = formData.actor.items;
|
||||
// formData.items.sort((a, b) => (a.sort || 0) - (b.sort || 0));
|
||||
|
||||
// -------------- version 0.8.0
|
||||
|
||||
// // Copy and sort Items
|
||||
// items.sort((a, b) => (a.sort || 0) - (b.sort || 0));
|
||||
// data.items = items;
|
||||
|
||||
// // Copy Active Effects
|
||||
// data.effects = effects;
|
||||
//console.log("---- data");
|
||||
|
||||
// // Return template data
|
||||
let formData = {
|
||||
title: this.title,
|
||||
id: objectData.id,
|
||||
type: objectData.type,
|
||||
img: objectData.img,
|
||||
name: objectData.name,
|
||||
// actor: this.object,
|
||||
editable: this.isEditable,
|
||||
cssClass: this.isEditable ? "editable" : "locked",
|
||||
data: foundry.utils.deepClone(Misc.templateData(this.object)),
|
||||
effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)),
|
||||
// items: items,
|
||||
limited: this.object.limited,
|
||||
options: this.options,
|
||||
owner: this.document.isOwner,
|
||||
|
@ -299,8 +299,18 @@ export class RdDActor extends Actor {
|
||||
filterItemsData(filter) {
|
||||
return this.data.items.map(it => Misc.data(it)).filter(filter);
|
||||
}
|
||||
filterItems(filter) {
|
||||
return this.data.items.filter(it => filter(Misc.data(it)));
|
||||
}
|
||||
getItemOfType(id, type) {
|
||||
return id ? this.data.items.find(it => it.id == id && Misc.data(it).type == type) : undefined;
|
||||
if (id && type) {
|
||||
let itemById = this.data.items.find(it => it.id == id);
|
||||
const itemData = Misc.data(itemById);
|
||||
if (itemData.type == type) {
|
||||
return itemById;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
getMonnaie(id) {
|
||||
return this.getItemOfType(id, 'monnaie');
|
||||
@ -1221,13 +1231,13 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async cacheTMR( ) {
|
||||
async cacheTMR() {
|
||||
await this.update({ 'data.reve.tmrpos.cache': true });
|
||||
}
|
||||
async montreTMR( ) {
|
||||
async montreTMR() {
|
||||
await this.update({ 'data.reve.tmrpos.cache': false });
|
||||
}
|
||||
isTMRCache( ) {
|
||||
isTMRCache() {
|
||||
return this.data.data.reve.tmrpos.cache;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
@ -1318,7 +1328,7 @@ export class RdDActor extends Actor {
|
||||
async reveActuelIncDec(value) {
|
||||
let mydata = Misc.templateData(this);
|
||||
let reve = Math.max(mydata.reve.reve.value + value, 0);
|
||||
await this.update( { "data.reve.reve.value": reve });
|
||||
await this.update({ "data.reve.reve.value": reve });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -1681,7 +1691,7 @@ export class RdDActor extends Actor {
|
||||
if (rollEthylisme.isEchec) {
|
||||
await this._jetDeMoralEthylique(ethylisme);
|
||||
}
|
||||
await this.update({'data.compteurs.ethylisme': ethylisme});
|
||||
await this.update({ 'data.compteurs.ethylisme': ethylisme });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -1708,6 +1718,7 @@ export class RdDActor extends Actor {
|
||||
switch (Misc.data(item).type) {
|
||||
case 'nourritureboisson': return await this.actionNourritureboisson(item);
|
||||
case 'potion': return await this.actionPotion(item);
|
||||
case 'livre': return await this.actionLire(item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1719,6 +1730,12 @@ export class RdDActor extends Actor {
|
||||
async actionPotion(item) {
|
||||
return await this.consommerPotion(item)
|
||||
}
|
||||
async actionLire(item) {
|
||||
const tache = await this.creerTacheDepuisLivre(item, { renderSheet: false });
|
||||
if (tache) {
|
||||
await this.rollTache(tache.id);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async consommer(item, choix) {
|
||||
@ -2022,8 +2039,8 @@ export class RdDActor extends Actor {
|
||||
let draconicList = this.getDraconicList().map(d => duplicate(Misc.data(d)));
|
||||
for (let sort of sortList) {
|
||||
let draconicsSort = this.getDraconicsSort(draconicList, sort).map(it => it.name);
|
||||
for (let index = 0; index < draconicList.length && sort.data.listIndex==undefined; index++){
|
||||
if (draconicsSort.includes(draconicList[index].name)){
|
||||
for (let index = 0; index < draconicList.length && sort.data.listIndex == undefined; index++) {
|
||||
if (draconicsSort.includes(draconicList[index].name)) {
|
||||
sort.data.listIndex = index;
|
||||
}
|
||||
}
|
||||
@ -2288,22 +2305,29 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async creerTacheDepuisLivre(item) {
|
||||
async creerTacheDepuisLivre(item, options = { renderSheet: true }) {
|
||||
const itemData = Misc.data(item);
|
||||
let tache = {
|
||||
name: "Lire " + item.name, type: 'tache',
|
||||
data: {
|
||||
carac: 'intellect',
|
||||
competence: 'Ecriture',
|
||||
difficulte: itemData.data.difficulte,
|
||||
periodicite: "60 minutes",
|
||||
fatigue: 2,
|
||||
points_de_tache: itemData.data.points_de_tache,
|
||||
points_de_tache_courant: 0,
|
||||
description: "Lecture du livre " + item.name + " - XP : " + itemData.data.xp + " - Compétences : " + itemData.data.competence
|
||||
const nomTache = "Lire " + itemData.name;
|
||||
const filterTacheLecture = it => it.type == 'tache' && it.name == nomTache;
|
||||
let tachesExistantes = this.filterItems(filterTacheLecture);
|
||||
if (tachesExistantes.length == 0) {
|
||||
const tache = {
|
||||
name: nomTache, type: 'tache',
|
||||
data: {
|
||||
carac: 'intellect',
|
||||
competence: 'Ecriture',
|
||||
difficulte: itemData.data.difficulte,
|
||||
periodicite: "60 minutes",
|
||||
fatigue: 2,
|
||||
points_de_tache: itemData.data.points_de_tache,
|
||||
points_de_tache_courant: 0,
|
||||
description: "Lecture du livre " + item.name + " - XP : " + itemData.data.xp + " - Compétences : " + itemData.data.competence
|
||||
}
|
||||
}
|
||||
await this.createEmbeddedDocuments('Item', [tache], options);
|
||||
tachesExistantes = this.filterItems(filterTacheLecture);
|
||||
}
|
||||
await this.createEmbeddedDocuments('Item', [tache], { renderSheet: true });
|
||||
return tachesExistantes.length > 0 ? tachesExistantes[0] : undefined;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -2330,7 +2354,6 @@ export class RdDActor extends Actor {
|
||||
callbacks: [
|
||||
this.createCallbackExperience(),
|
||||
this.createCallbackAppelAuMoral(),
|
||||
{ condition: r => r.rolled.isETotal, action: r => this._tacheETotal(r) },
|
||||
{ action: r => this._tacheResult(r) }
|
||||
]
|
||||
});
|
||||
@ -2340,19 +2363,17 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async _tacheResult(rollData) {
|
||||
// Mise à jour de la tache
|
||||
rollData.tache = duplicate(rollData.tache);
|
||||
rollData.tache.data.points_de_tache_courant += rollData.rolled.ptTache;
|
||||
if (rollData.rolled.isETotal){
|
||||
rollData.tache.data.difficulte--;
|
||||
}
|
||||
this.updateEmbeddedDocuments('Item', [rollData.tache]);
|
||||
this.santeIncDec("fatigue", rollData.tache.data.fatigue);
|
||||
|
||||
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-tache.html');
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_tacheETotal(rollData) {
|
||||
rollData.tache.data.difficulte--;
|
||||
this.updateEmbeddedDocuments('Item', [rollData.tache]);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _rollArt(artData, selected, oeuvre, callBackResult = r => this._resultArt(r)) {
|
||||
const actorData = Misc.data(this);
|
||||
@ -2776,7 +2797,7 @@ export class RdDActor extends Actor {
|
||||
refreshTMRView(tmrData) {
|
||||
console.log("REFRESH !!!!");
|
||||
if (this.currentTMR) {
|
||||
this.currentTMR.externalRefresh( tmrData)
|
||||
this.currentTMR.externalRefresh(tmrData)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,7 @@ export class RdDItem extends Item {
|
||||
switch (itemData.type) {
|
||||
case 'nourritureboisson': return itemData.data.boisson ? 'Boire' : 'Manger';
|
||||
case 'potion': return 'Boire';
|
||||
case 'livre': return 'Lire';
|
||||
}
|
||||
if (options.warnIfNot) {
|
||||
ui.notifications.warn(`Impossible d'utilise un ${itemData.name}, aucune action associée définie.`);
|
||||
|
@ -40,7 +40,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
const dialogOptions = {
|
||||
classes: ["tmrdialog"],
|
||||
width: 920, height: 980,
|
||||
'z-index': 20
|
||||
'z-index': 40
|
||||
}
|
||||
super(dialogConf, dialogOptions);
|
||||
|
||||
|
@ -20,7 +20,7 @@ export class RdDTMRRencontreDialog extends Dialog {
|
||||
const dialogOptions = {
|
||||
classes: ["tmrrencdialog"],
|
||||
width: 320, height: 240,
|
||||
'z-index': 20
|
||||
'z-index': 50
|
||||
}
|
||||
super(dialogConf, dialogOptions);
|
||||
|
||||
|
@ -7,49 +7,51 @@ import { RdDUtility } from "./rdd-utility.js";
|
||||
/* -------------------------------------------- */
|
||||
export class RdDTokenHud {
|
||||
|
||||
static init(){
|
||||
// Integration du TokenHUD
|
||||
static init() {
|
||||
// Integration du TokenHUD
|
||||
Hooks.on('renderTokenHUD', (app, html, data) => { RdDTokenHud.addTokenHudExtensions(app, html, data._id) });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async removeExtensionHud( app, html, tokenId) {
|
||||
let combat = html.find('.control-icon.rdd-combat');
|
||||
combat.remove();
|
||||
let initiative = html.find('.control-icon.rdd-initiative');
|
||||
initiative.remove();
|
||||
static async removeExtensionHud(app, html, tokenId) {
|
||||
html.find('.control-icon.rdd-combat').remove();
|
||||
html.find('.control-icon.rdd-initiative').remove();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async addExtensionHud( app, html, tokenId ) {
|
||||
static async addExtensionHud(app, html, tokenId) {
|
||||
|
||||
let token = canvas.tokens.get(tokenId);
|
||||
let actor = token.actor;
|
||||
let combatant = game.combat.combatants.find(c => Misc.data(c).tokenId == tokenId);
|
||||
app.hasExtension = true;
|
||||
|
||||
let armesList = RdDCombatManager.buildListeActionsCombat(combatant) ;
|
||||
const hudData = { combatant: combatant, armes: armesList,
|
||||
commandes: [{ name: 'Initiative +1', command: 'inc', value: 0.01}, { name: 'Initiative -1',command: 'dec', value: -0.01}] };
|
||||
let armesList = RdDCombatManager.buildListeActionsCombat(combatant);
|
||||
const hudData = {
|
||||
combatant: combatant, armes: armesList,
|
||||
commandes: [{ name: 'Initiative +1', command: 'inc', value: 0.01 }, { name: 'Initiative -1', command: 'dec', value: -0.01 }]
|
||||
};
|
||||
|
||||
const controlIconCombat = html.find('.control-icon[data-action=combat]');
|
||||
// initiative
|
||||
await RdDTokenHud._configureSubMenu(html.find('.control-icon.combat'), 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html', hudData,
|
||||
await RdDTokenHud._configureSubMenu(controlIconCombat, 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html', hudData,
|
||||
(event) => {
|
||||
let initCommand = event.currentTarget.attributes['data-command'].value;
|
||||
let combatantId = event.currentTarget.attributes['data-combatant-id'].value;
|
||||
if ( !initCommand ) {
|
||||
if (!initCommand) {
|
||||
let armeIndex = event.currentTarget.attributes['data-arme-id'].value;
|
||||
let arme = armesList[armeIndex];
|
||||
RdDCombatManager.rollInitiativeCompetence(combatantId, arme);
|
||||
RdDCombatManager.rollInitiativeCompetence(combatantId, arme);
|
||||
} else if (initCommand == 'inc') {
|
||||
RdDCombatManager.incDecInit( combatantId, 0.01 );
|
||||
} else if ( initCommand == 'dec') {
|
||||
RdDCombatManager.incDecInit( combatantId, -0.01 );
|
||||
RdDCombatManager.incDecInit(combatantId, 0.01);
|
||||
} else if (initCommand == 'dec') {
|
||||
RdDCombatManager.incDecInit(combatantId, -0.01);
|
||||
}
|
||||
});
|
||||
|
||||
const controlIconTarget = html.find('.control-icon[data-action=target]');
|
||||
// combat
|
||||
await RdDTokenHud._configureSubMenu(html.find('.control-icon.target'), 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html', hudData,
|
||||
await RdDTokenHud._configureSubMenu(controlIconTarget, 'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html', hudData,
|
||||
(event) => {
|
||||
let armeIndex = event.currentTarget.attributes['data-arme-id'].value;
|
||||
let arme = armesList[armeIndex];
|
||||
@ -59,38 +61,35 @@ export class RdDTokenHud {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async addTokenHudExtensions(app, html, tokenId) {
|
||||
|
||||
html.find('.control-icon.combat').click(event => {
|
||||
if ( event.currentTarget.className.includes('active')) {
|
||||
RdDTokenHud.removeExtensionHud( app, html, tokenId);
|
||||
const controlIconCombat = html.find('.control-icon[data-action=combat]');
|
||||
controlIconCombat.click(event => {
|
||||
if (event.currentTarget.className.includes('active')) {
|
||||
RdDTokenHud.removeExtensionHud(app, html, tokenId);
|
||||
} else {
|
||||
setTimeout( function() { RdDTokenHud.addExtensionHud( app, html, tokenId) } , 200 );
|
||||
setTimeout(function () { RdDTokenHud.addExtensionHud(app, html, tokenId) }, 200);
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
let combatIcon = html.find('.control-icon.combat');
|
||||
if ( combatIcon[0].className.includes('active') ) {
|
||||
RdDTokenHud.addExtensionHud( app, html, tokenId);
|
||||
if (controlIconCombat.length>0 && controlIconCombat[0].className.includes('active')) {
|
||||
RdDTokenHud.addExtensionHud(app, html, tokenId);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async _configureSubMenu(insertionPoint, template, hudData, onMenuItem) {
|
||||
const hud = $(await renderTemplate(template, hudData));
|
||||
const imgHud = hud.find('img.rdd-hud-togglebutton');
|
||||
const list = hud.find('div.rdd-hud-list');
|
||||
|
||||
hud.toggleClass('active');
|
||||
HtmlUtility._showControlWhen(list, hud.hasClass('active'));
|
||||
|
||||
imgHud.click(event => {
|
||||
hud.toggleClass('active');
|
||||
HtmlUtility._showControlWhen(list, hud.hasClass('active'));
|
||||
});
|
||||
|
||||
|
||||
RdDTokenHud._toggleHudListActive(hud, list);
|
||||
|
||||
hud.find('img.rdd-hud-togglebutton').click(event => RdDTokenHud._toggleHudListActive(hud, list));
|
||||
list.find('.rdd-hud-menu').click(onMenuItem);
|
||||
|
||||
insertionPoint.after(hud);
|
||||
}
|
||||
|
||||
static _toggleHudListActive(hud, list) {
|
||||
hud.toggleClass('active');
|
||||
HtmlUtility._showControlWhen(list, hud.hasClass('active'));
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import { ChatUtility } from "./chat-utility.js";
|
||||
import { RdDCombat } from "./rdd-combat.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { TMRUtility } from "./tmr-utility.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// This table starts at 0 -> niveau -10
|
||||
@ -108,8 +109,13 @@ export class RdDUtility {
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor-entite-sheet.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor-vehicule-sheet.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor-sheet-categorie-competences-partial.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor-sheet-oeuvre-partial.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor-liste-blessures-partial.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor-blessure-partial.html',
|
||||
// Conteneur/item in Actor sheet
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-conteneur.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor-sheet-editor-notes-mj.html',
|
||||
//Items
|
||||
'systems/foundryvtt-reve-de-dragon/templates/item-competence-sheet.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/item-competencecreature-sheet.html',
|
||||
@ -172,9 +178,6 @@ export class RdDUtility {
|
||||
'systems/foundryvtt-reve-de-dragon/templates/calendar-template.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/calendar-editor-template.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/heures-select-option.html',
|
||||
// Conteneur/item in Actor sheet
|
||||
'systems/foundryvtt-reve-de-dragon/templates/actor-inventaire-conteneur.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/editor-notes-mj.html',
|
||||
// HUD
|
||||
'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html',
|
||||
@ -208,6 +211,8 @@ export class RdDUtility {
|
||||
Handlebars.registerHelper('un', str => Grammar.articleIndetermine(str));
|
||||
Handlebars.registerHelper('accord', (genre, ...args) => Grammar.accord(genre, args));
|
||||
Handlebars.registerHelper('buildConteneur', (objet) => { return RdDUtility.buildConteneur(objet); });
|
||||
Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord));
|
||||
Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord));
|
||||
|
||||
return loadTemplates(templatePaths);
|
||||
}
|
||||
@ -325,7 +330,7 @@ export class RdDUtility {
|
||||
if (!niveau) niveau = 1;
|
||||
objet.niveau = niveau;
|
||||
//console.log("OBJ:", objet);
|
||||
let str = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-inventaire-conteneur.html']({ item: objet });
|
||||
let str = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-sheet-inventaire-conteneur.html']({ item: objet });
|
||||
if (objet.type == 'conteneur') {
|
||||
//console.log("ITEM DISPLAYED", objet );
|
||||
if (this.getAfficheContenu(objet._id)) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { TMRRencontres } from "./tmr-rencontres.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { Grammar } from "./grammar.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const TMRMapping = {
|
||||
|
@ -26,8 +26,8 @@ export class Pelerinage extends Draconique {
|
||||
return pixiTMR.sprite(this.code(), {
|
||||
zIndex: tmrTokenZIndex.conquete,
|
||||
alpha: 1,
|
||||
taille: tmrConstants.twoThird,
|
||||
decallage: tmrConstants.right
|
||||
taille: tmrConstants.full,
|
||||
decallage: tmrConstants.center
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user