Version 10.7.6 - L'origine des maux de Sémolosse #640

Merged
uberwald merged 9 commits from VincentVk/foundryvtt-reve-de-dragon:v10 into v10 2023-03-31 07:22:29 +02:00
22 changed files with 248 additions and 239 deletions

View File

@ -117,7 +117,10 @@ export class RdDActorSheet extends RdDBaseActorSheet {
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
this.html.find('.item-action').click(async event => RdDSheetUtility.getItem(event, this.actor)?.actionPrincipale(this.actor));
this.html.find('.item-action').click(async event => {
const item = RdDSheetUtility.getItem(event, this.actor);
item?.actionPrincipale(this.actor, async () => this.render())
});
this.html.find('.subacteur-delete').click(async event => {
const li = RdDSheetUtility.getEventElement(event);

View File

@ -1625,11 +1625,6 @@ export class RdDActor extends RdDBaseActor {
new RdDRollDialogEthylisme(html, rollData, this, r => this.saouler(r.forceAlcool)).render(true);
}
/* -------------------------------------------- */
async actionItem(item, onActionItem = async () => { }) {
item.actionPrincipale(this, onActionItem);
}
async actionNourritureboisson(item, onActionItem) {
switch (item.getUtilisationCuisine()) {
case 'brut': {
@ -1662,9 +1657,9 @@ export class RdDActor extends RdDBaseActor {
await this.rollTache(tache.id);
}
}
async actionHerbe(item) {
async actionHerbe(item, onActionItem = async () => {}) {
if (item.isHerbeAPotion()) {
return this.dialogFabriquerPotion(item);
return DialogFabriquerPotion.create(this, item, onActionItem);
}
return;
}
@ -3209,10 +3204,6 @@ export class RdDActor extends RdDBaseActor {
if (attacker && !await attacker.accorder(this, 'avant-encaissement')) {
return;
}
this.validerEncaissement(rollData, show);
}
async validerEncaissement(rollData, show) {
if (ReglesOptionelles.isUsing('validation-encaissement-gr') && !game.user.isGM) {
RdDBaseActor.remoteActorCall({
actorId: this.id,
@ -3223,18 +3214,18 @@ export class RdDActor extends RdDBaseActor {
}
const armure = await this.computeArmure(rollData);
if (ReglesOptionelles.isUsing('validation-encaissement-gr')) {
DialogValidationEncaissement.validerEncaissement(this, rollData, armure, show, (encaissement, show) => this._appliquerEncaissement(encaissement, show));
DialogValidationEncaissement.validerEncaissement(this, rollData, armure, show, (encaissement, show) => this._appliquerEncaissement(encaissement, show, attacker));
}
else {
let encaissement = await RdDUtility.jetEncaissement(rollData, armure, { showDice: SHOW_DICE });
await this._appliquerEncaissement(encaissement, show)
await this._appliquerEncaissement(encaissement, show, attacker)
}
}
async _appliquerEncaissement(encaissement, show) {
async _appliquerEncaissement(encaissement, show, attacker) {
let santeOrig = duplicate(this.system.sante);
const blessure = await this.ajouterBlessure(encaissement); // Will upate the result table
const blessure = await this.ajouterBlessure(encaissement, attacker); // Will update the result table
const perteVie = this.isEntite()
? { newValue: 0 }
: await this.santeIncDec("vie", -encaissement.vie);
@ -3268,7 +3259,7 @@ export class RdDActor extends RdDBaseActor {
}
/* -------------------------------------------- */
async ajouterBlessure(encaissement) {
async ajouterBlessure(encaissement, attacker = undefined) {
if (this.isEntite()) return; // Une entité n'a pas de blessures
if (encaissement.gravite < 0) return;
if (encaissement.gravite > 0) {
@ -3281,7 +3272,7 @@ export class RdDActor extends RdDBaseActor {
}
}
const endActuelle = Number(this.system.sante.endurance.value);
const blessure = await RdDItemBlessure.createBlessure(this, encaissement.gravite, encaissement.dmg.loc.label);
const blessure = await RdDItemBlessure.createBlessure(this, encaissement.gravite, encaissement.dmg.loc.label, attacker);
if (blessure.isCritique()) {
encaissement.endurance = endActuelle;
}
@ -3534,7 +3525,7 @@ export class RdDActor extends RdDBaseActor {
for (let blessure of blessures) {
if (pointsGuerison >= blessure.system.gravite) {
pointsGuerison -= blessure.system.gravite;
guerisonData.list.push(`1 Blessure ${blessure.system.labelGravite} (${blessure.system.gravite} points)`);
guerisonData.list.push(`1 Blessure ${blessure.system.label} (${blessure.system.gravite} points)`);
ids.push(blessure.id)
}
}
@ -3611,12 +3602,6 @@ export class RdDActor extends RdDBaseActor {
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-repos.html`, potionData)
});
}
/* -------------------------------------------- */
dialogFabriquerPotion(herbe) {
DialogFabriquerPotion.create(this, herbe, {
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-fabriquer-potion-base.html',
}, []);
}
/* -------------------------------------------- */
async fabriquerPotion(herbeData) {

View File

@ -152,6 +152,8 @@ export class RdDBaseActorSheet extends ActorSheet {
const item = this.getItem(event);
RdDSheetUtility.splitItem(item, this.actor);
});
this.html.find('.item-quantite-plus').click(async event => this.actor.itemQuantiteIncDec(this.getItemId(event), 1));
this.html.find('.item-quantite-moins').click(async event => this.actor.itemQuantiteIncDec(this.getItemId(event), -1));
this.html.find('.item-delete').click(async event => RdDUtility.confirmActorItemDelete(this, this.getItem(event)));
this.html.find('.item-vendre').click(async event => this.vendre(this.getItem(event)));
@ -161,12 +163,6 @@ export class RdDBaseActorSheet extends ActorSheet {
this.html.find('.nettoyer-conteneurs').click(async event => {
this.actor.nettoyerConteneurs();
});
this.html.find('.monnaie-plus').click(async event => {
this.actor.monnaieIncDec(this.getItemId(event), 1);
});
this.html.find('.monnaie-moins').click(async event => {
this.actor.monnaieIncDec(this.getItemId(event), -1);
});
}
_rechercherKeyup(event) {

View File

@ -150,11 +150,11 @@ export class RdDBaseActor extends Actor {
}
/* -------------------------------------------- */
async monnaieIncDec(id, value) {
let monnaie = this.getMonnaie(id);
if (monnaie) {
const quantite = Math.max(0, monnaie.system.quantite + value);
await this.updateEmbeddedDocuments('Item', [{ _id: monnaie.id, 'system.quantite': quantite }]);
async itemQuantiteIncDec(id, value) {
let item = this.getItem(id);
if (item && item.isInventaire()) {
const quantite = Math.max(0, item.system.quantite + value);
await this.updateEmbeddedDocuments('Item', [{ _id: item.id, 'system.quantite': quantite }]);
}
}

View File

@ -5,7 +5,7 @@ import { RdDUtility } from "./rdd-utility.js";
export class DialogFabriquerPotion extends Dialog {
/* -------------------------------------------- */
static async create(actor, item, dialogConfig) {
static async create(actor, item, onActionItem) {
const min = DialogFabriquerPotion.nombreBrinsMinimum(item);
if (item.system.quantite < min) {
ui.notifications.warn(`Vous avez ${item.system.quantite} brins de ${item.name}, il en faut au moins ${min} pour faire une potion!`);
@ -13,12 +13,10 @@ export class DialogFabriquerPotion extends Dialog {
}
let potionData = DialogFabriquerPotion.prepareData(actor, item);
const html = await renderTemplate(dialogConfig.html, potionData);
const html = await renderTemplate( 'systems/foundryvtt-reve-de-dragon/templates/dialog-fabriquer-potion-base.html', potionData);
let options = { classes: ["dialogfabriquerpotion"], width: 600, height: 160, 'z-index': 99999 };
mergeObject(options, dialogConfig.options ?? {}, { overwrite: true })
new DialogFabriquerPotion(actor, potionData, html, options).render(true);
new DialogFabriquerPotion(actor, potionData, onActionItem, html, options).render(true);
}
/* -------------------------------------------- */
@ -34,14 +32,14 @@ export class DialogFabriquerPotion extends Dialog {
}
/* -------------------------------------------- */
constructor(actor, potionData, html, options) {
constructor(actor, potionData, onActionItem, html, options) {
const conf = {
title: `Fabriquer une potion de ${potionData.system.categorie}`,
content: html,
default: 'fabriquer',
buttons: {
'fabriquer': {
label: potionData.buttonName, callback: it => this.onFabriquer(html)
label: potionData.buttonName, callback: it => this.onFabriquer()
}
}
};
@ -50,6 +48,7 @@ export class DialogFabriquerPotion extends Dialog {
this.actor = actor;
this.potionData = potionData;
this.onActionItem = onActionItem;
}
/* -------------------------------------------- */
@ -64,10 +63,11 @@ export class DialogFabriquerPotion extends Dialog {
}
/* -------------------------------------------- */
async onFabriquer(html) {
async onFabriquer() {
await this.html.find("[name='nbBrins']").change();
this.actor.fabriquerPotion(this.potionData);
await this.actor.fabriquerPotion(this.potionData);
this.close();
await this.onActionItem()
}
static nombreBrinsMinimum(herbeData) {

View File

@ -23,7 +23,7 @@ export class DialogValidationEncaissement extends Dialog {
constructor(html, actor, rollData, armure, encaissement, show, onEncaisser) {
// Common conf
let buttons = {
"valider": { label: "Valider", callback: html => this.validerEncaissement() },
"valider": { label: "Valider", callback: html => this.onValider() },
"annuler": { label: "Annuler", callback: html => { } },
};
@ -64,7 +64,7 @@ export class DialogValidationEncaissement extends Dialog {
});
}
async validerEncaissement() {
async onValider() {
this.encaissement = await RdDUtility.jetEncaissement(this.rollData, this.armure, { showDice: SHOW_DICE, forceDiceResult: this.forceDiceResult});
this.onEncaisser(this.encaissement, this.show)
}

View File

@ -188,7 +188,7 @@ export class RdDItemSheet extends ItemSheet {
});
this.html.find('.creer-tache-livre').click((event) => this._getEventActor(event).creerTacheDepuisLivre(this.item));
this.html.find('.consommer-potion').click((event) => this._getEventActor(event).consommerPotion(this.item));
this.html.find('.consommer-potion').click((event) => this._getEventActor(event).consommerPotion(this.item, this.getActionRenderItem()));
this.html.find('.creer-potion-base').click((event) => this._getEventActor(event).dialogFabriquerPotion(this.item));
this.html.find('.alchimie-tache a').click((event) => {
@ -203,12 +203,23 @@ export class RdDItemSheet extends ItemSheet {
}
});
this.html.find('.item-split').click(async event => RdDSheetUtility.splitItem(RdDSheetUtility.getItem(event, this.actor), this.actor, async () => this.render(true)));
this.html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true));
this.html.find('.item-delete').click(async event => RdDUtility.confirmActorItemDelete(this, RdDSheetUtility.getItem(event, this.actor)));
this.html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
this.html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItemToChat());
this.html.find('.item-action').click(async event => RdDSheetUtility.getItem(event, this.actor)?.actionPrincipale(this.actor, async () => this.render(true)));
if (this.actor) {
this.html.find('.item-split').click(async event => RdDSheetUtility.splitItem(RdDSheetUtility.getItem(event, this.actor), this.actor, this.getActionRenderItem()));
this.html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true));
this.html.find('.item-delete').click(async event => RdDUtility.confirmActorItemDelete(this, RdDSheetUtility.getItem(event, this.actor)));
this.html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
this.html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItemToChat());
this.html.find('.item-action').click(async event => RdDSheetUtility.getItem(event, this.actor)?.actionPrincipale(this.actor, this.getActionRenderItem()));
this.html.find('.item-quantite-plus').click(async event => {
await this.actor.itemQuantiteIncDec(RdDSheetUtility.getItemId(event), 1)
this.render();
});
this.html.find('.item-quantite-moins').click(async event => {
await this.actor.itemQuantiteIncDec(RdDSheetUtility.getItemId(event), -1)
this.render();
});
}
const updateItemTimestamp = (path, timestamp) => this.item.update({ [path]: duplicate(timestamp) })
@ -216,6 +227,16 @@ export class RdDItemSheet extends ItemSheet {
RdDTimestamp.handleTimestampEditor(this.html, 'system.temporel.fin', updateItemTimestamp);
}
getActionRenderItem() {
return async () => {
let item = this.item;
while (item) {
await item.sheet?.render()
item = this.actor.getContenant(item)
}
}
}
_getEventActor(event) {
let actorId = event.currentTarget.attributes['data-actor-id'].value;
let actor = game.actors.get(actorId);
@ -239,9 +260,8 @@ export class RdDItemSheet extends ItemSheet {
_updateObject(event, formData) {
if (this.item.type == 'sort') {
// Données de bonus de cases ?
formData['system.bonuscase'] = RdDItemSort.buildBonusCaseStringFromFormData(formData.bonusValue, formData.caseValue);
formData['system.bonuscase'] = RdDItemSort.buildBonuscaseFromArrays(formData.bonusValue, formData.caseValue);
}
return this.item.update(formData);
}

View File

@ -1,4 +1,3 @@
/* -------------------------------------------- */
import { Misc } from "./misc.js";
import { TMRUtility } from "./tmr-utility.js";
@ -14,9 +13,9 @@ export class RdDItemSort extends Item {
static isCoutVariable(sort) {
return sort && (sort.system.ptreve.toLowerCase() == "variable" || sort.system.ptreve.indexOf("+") >= 0);
}
/* -------------------------------------------- */
static setCoutReveReel(sort){
static setCoutReveReel(sort) {
if (sort) {
sort.system.ptreve_reel = this.isCoutVariable(sort) ? 1 : sort.system.ptreve;
}
@ -25,94 +24,91 @@ export class RdDItemSort extends Item {
/* -------------------------------------------- */
static getDifficulte(sort, variable) {
if (sort && !RdDItemSort.isDifficulteVariable(sort)) {
return Misc.toInt(sort.system.difficulte);
return Misc.toInt(sort.system.difficulte);
}
return variable;
}
/* -------------------------------------------- */
static buildBonusCaseList( caseBonusString, newCase ) {
if (caseBonusString == undefined) {
return [];
}
let bonusCaseList = [];
let bonusCaseArray = caseBonusString == undefined ? [] : 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;
static buildBonusCaseList(bonuscase, newCase) {
const list = RdDItemSort._bonuscaseStringToList(bonuscase)
if (newCase) {
return list.concat({ case: "Nouvelle", bonus: 0 });
}
/* -------------------------------------------- */
return list;
}
/**
* Retourne une liste de bonus/case pour un item-sheet
* @param {} item
*/
static getBonusCaseList( item, newCase = false ) {
static getBonusCaseList(item, newCase = false) {
// Gestion spéciale case bonus
if ( item.type == 'sort') {
return this.buildBonusCaseList(item.system.bonuscase, newCase );
if (item.type == 'sort') {
return RdDItemSort.buildBonusCaseList(item.system.bonuscase, newCase);
}
return undefined;
}
/* -------------------------------------------- */
/** Met à jour les données de formulaire
* si static des bonus de cases sont présents
* */
static buildBonusCaseStringFromFormData( bonuses, cases ) {
if ( bonuses ) {
let list = [];
let caseCheck = {};
for (let i=0; i<bonuses.length; i++) {
let coord = cases[i]?.toUpperCase() || 'A1';
let bonus = bonuses[i] || 0;
if ( TMRUtility.verifyTMRCoord( coord ) && bonus > 0 && caseCheck[coord] == undefined ) {
static buildBonuscaseFromArrays(bonuses, coords) {
if (bonuses) {
const list = [];
const caseCheck = {};
for (let i = 0; i < bonuses.length && i < coords.length; i++) {
const coord = coords[i] == 'Fleuve' ? 'Fleuve' : (coords[i]?.toUpperCase() ?? 'A1');
const bonus = bonuses[i] || 0;
if (TMRUtility.verifyTMRCoord(coord) && bonus > 0 && caseCheck[coord] == undefined) {
caseCheck[coord] = bonus;
list.push( coord+":"+bonus );
list.push({ case: coord, bonus: bonus });
}
}
return list.toString();
return RdDItemSort._bonuscaseListToString(list);
}
return undefined;
}
/* -------------------------------------------- */
static incrementBonusCase( actor, sort, coord ) {
let bonusCaseList = this.buildBonusCaseList(sort.system.bonuscase, false);
//console.log("ITEMSORT", sort, bonusCaseList);
let found = false;
let StringList = [];
for( let bc of bonusCaseList) {
if (bc.case == coord) { // Case existante
found = true;
bc.bonus = Number(bc.bonus) + 1;
}
StringList.push( bc.case+':'+bc.bonus );
}
if ( !found) { //Nouvelle case, bonus de 1
StringList.push(coord+':1');
}
// Sauvegarde/update
let bonuscase = StringList.toString();
//console.log("Bonus cae :", bonuscase);
actor.updateEmbeddedDocuments('Item', [{ _id: sort._id, 'system.bonuscase': bonuscase }] );
}
/* -------------------------------------------- */
static getCaseBonus( sort, coord) {
let bonusCaseList = this.buildBonusCaseList(sort.system.bonuscase, false);
for( let bc of bonusCaseList) {
if (bc.case == coord) { // Case existante
return Number(bc.bonus);
}
static incrementBonusCase(actor, sort, coord) {
if (TMRUtility.getTMR(coord).type == "fleuve") {
coord = 'Fleuve';
}
return 0;
const list = RdDItemSort.buildBonusCaseList(sort.system.bonuscase, false);
const bonus = Number(list.find(it => it.case == coord)?.bonus ?? 0);
const modified = { case: coord, bonus: bonus + 1 };
const bonuscase = RdDItemSort._bonuscaseListToString(
list.filter(it => it.case != coord).concat(modified)
);
// Sauvegarde/update
actor.updateEmbeddedDocuments('Item', [{ _id: sort._id, 'system.bonuscase': bonuscase }]);
}
/* -------------------------------------------- */
static getCaseBonus(sort, coord) {
const isFleuve = TMRUtility.getTMR(coord).type == "fleuve";
let bc = RdDItemSort.buildBonusCaseList(sort.system.bonuscase, false)
.filter(it => it.case == coord || (isFleuve && it.case == 'Fleuve'))
.find(it => true)
return Number(bc?.bonus ?? 0);
}
static _bonuscaseListToString(list) {
return list.map(it => `${it.case}:${it.bonus}`)
.sort(Misc.ascending())
.join(',');
}
static _bonuscaseStringToList(bonuscase) {
return (bonuscase ?? '').split(',').map(it => {
const b = it.split(':');
return { case: b[0], bonus: b[1] };
});
}
}

View File

@ -411,7 +411,7 @@ export class RdDItem extends Item {
case 'potion': return await actor.consommerPotion(this, onActionItem);
case 'livre': return await actor.actionLire(this);
case 'conteneur': return await this.sheet.render(true);
case 'herbe': return await actor.actionHerbe(this);
case 'herbe': return await actor.actionHerbe(this, onActionItem);
case 'queue': case 'ombre': return await actor.actionRefoulement(this);
}
}

View File

@ -14,11 +14,11 @@ const TACHES_SOIN_BLESSURE = {
}
const definitionsBlessures = [
{ type: "contusion", gravite: 0, labelGravite: 'Contusion/éraflure', max: 100, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/eraflure.webp" },
{ type: "legere", gravite: 2, labelGravite: 'Légère', max: 5, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/blessure.webp" },
{ type: "grave", gravite: 4, labelGravite: 'Grave', max: 2, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/blessure.webp" },
{ type: "critique", gravite: 6, labelGravite: 'Critique', max: 1, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/blessure.webp" },
{ type: "mort", gravite: 8, labelGravite: 'Mort', max: 1, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/mort.webp" }
{ type: "contusion", gravite: 0, label: 'Contusion/éraflure', max: 100, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/eraflure.webp" },
{ type: "legere", gravite: 2, label: 'Légère', max: 5, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/blessure.webp" },
{ type: "grave", gravite: 4, label: 'Grave', max: 2, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/blessure.webp" },
{ type: "critique", gravite: 6, label: 'Critique', max: 1, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/blessure.webp" },
{ type: "mort", gravite: 8, label: 'Mort', max: 1, icon: "systems/foundryvtt-reve-de-dragon/icons/sante/mort.webp" }
]
export class RdDItemBlessure extends RdDItem {
@ -29,7 +29,7 @@ export class RdDItemBlessure extends RdDItem {
prepareDerivedData() {
super.prepareDerivedData();
this.system.labelGravite = this.getLabelGravite()
this.system.label = this.getLabelGravite()
}
static prepareTacheSoin(gravite) {
@ -40,19 +40,19 @@ export class RdDItemBlessure extends RdDItem {
}
return mergeObject(duplicate(BASE_TACHE_SOIN_BLESSURE), tache)
}
static async createBlessure(actor, gravite, localisation = '') {
static async createBlessure(actor, gravite, localisation = '', attacker) {
const definition = RdDItemBlessure.getDefinition(gravite)
const blessure = {
name: definition.labelGravite,
name: definition.label,
type: 'blessure',
img: definition.icon,
system: {
gravite: gravite,
difficulte: - gravite,
localisation: localisation
localisation: localisation,
origine: attacker?.name ?? ""
}
}
const blessures = await actor.createEmbeddedDocuments('Item', [blessure])
return blessures[0]
}
@ -100,12 +100,12 @@ export class RdDItemBlessure extends RdDItem {
const gravite = this.system.gravite;
const graviteMoindre = gravite - 2;
const moindres = blessures.filter(it => it.system.gravite == graviteMoindre, 'blessures').length
const labelGravite = this.getLabelGravite();
const label = this.getLabelGravite();
let rolled = await actor.jetRecuperationConstitution(this.system.soinscomplets.bonus, message);
if (rolled.isETotal) {
message.content += ` -- une blessure ${labelGravite} s'infecte (temps de guérison augmenté de ${gravite} jours, perte de vie)`;
message.content += ` -- une blessure ${label} s'infecte (temps de guérison augmenté de ${gravite} jours, perte de vie)`;
await actor.santeIncDec("vie", -1);
mergeObject(update, {
system: { fin: { indexDate: timestamp.addJours(gravite).indexDate } }
@ -113,13 +113,13 @@ export class RdDItemBlessure extends RdDItem {
}
else {
if (!isMaladeEmpoisonne && rolled.isSuccess && this.peutRetrograder(graviteMoindre, moindres)) {
message.content += ` -- une blessure ${labelGravite} cicatrise`;
message.content += ` -- une blessure ${label} cicatrise`;
mergeObject(update, {
system: { gravite: graviteMoindre, fin: { indexDate: timestamp.addJours(graviteMoindre).indexDate } }
});
}
else {
message.content += ` -- une blessure ${labelGravite} reste stable`;
message.content += ` -- une blessure ${label} reste stable`;
}
}
await this.update(update);
@ -152,7 +152,7 @@ export class RdDItemBlessure extends RdDItem {
}
getLabelGravite() {
return RdDItemBlessure.getDefinition(this.system.gravite).labelGravite
return RdDItemBlessure.getDefinition(this.system.gravite).label
}
static getDefinition(gravite) {
@ -178,4 +178,22 @@ export class RdDItemBlessure extends RdDItem {
isMort() {
return this.system.gravite > 6
}
getProprietes() {
return [
RdDItem.propertyIfDefined('Causée par', this.system.origine, this.system.origine),
`<b>Heure et Date</b>: ${new RdDTimestamp(this.system.temporel.debut).formatDateHeure()}`,
RdDItem.propertyIfDefined('Blessé', this.parent?.name, this.parent),
`<b>Localisation</b>: ${this.system.localisation}`,
`<b>Gravité</b>: ${RdDItemBlessure.getDefinition(this.system.gravite).label}`,
`<b>Difficulté des soins</b>: ${this.system.difficulte}`,
(this.system.soinscomplets.done ?
`<b>Bonus soins complets</b>: ${this.system.soinscomplets.bonus}` :
(this.system.premierssoins.done ?
`<b>Bonus premiers soins</b>: ${this.system.premierssoins.bonus}` :
`<b>Points de tâche</b>: ${this.system.premierssoins.tache}`
)
),
];
}
}

View File

@ -452,8 +452,7 @@ class _10_7_0_MigrationBlessures extends Migration {
fin: { indexDate: datePremiereRecup.indexDate, indexMinute: 0 },
premierssoins: { done: blessure.psdone, bonus: blessure.premiers_soins },
soinscomplets: { done: blessure.scdone, bonus: blessure.soins_complets },
localisation: blessure.localisation,
jours: blessure.jours
localisation: blessure.localisation
}
}
}

View File

@ -85,7 +85,7 @@ export class RdDCalendrier extends Application {
display() {
const pos = this.getSavePosition()
this.render(true, { left: pos.left, top: pos.top});
this.render(true, { left: pos.left, top: pos.top });
return this;
}
@ -110,10 +110,12 @@ export class RdDCalendrier extends Application {
this.render(true)
}
async close() { }
async onUpdateSetting(setting, update, options, id) {
if (setting.key == SYSTEM_RDD + '.' + WORLD_TIMESTAMP_SETTING) {
this.timestamp = RdDTimestamp.getWorldTime();
this.updateDisplay();
this.positionAiguilles()
Hooks.callAll(APP_ASTROLOGIE_REFRESH);
}
}
@ -138,8 +140,6 @@ export class RdDCalendrier extends Application {
async activateListeners(html) {
super.activateListeners(html);
this.html = html;
this.updateDisplay();
this.html.find('.ajout-chronologie').click(ev => DialogChronologie.create());
this.html.find('.toggle-horloge-analogique').click(ev => this.onToggleHorlogeAnalogique())
this.html.find('.calendar-btn').click(ev => this.onCalendarButton(ev));
@ -156,12 +156,19 @@ export class RdDCalendrier extends Application {
ev.preventDefault();
this.showAstrologieEditor();
});
this.positionAiguilles()
}
positionAiguilles() {
const timestamp = this.getTimestamp();
this.html.find(`div.horloge-roue div.horloge-aiguille-heure img`).css(Misc.cssRotation(timestamp.angleHeure));
this.html.find(`div.horloge-roue div.horloge-aiguille-minute img`).css(Misc.cssRotation(timestamp.angleMinute));
}
onToggleHorlogeAnalogique() {
this.horlogeAnalogique = !this.horlogeAnalogique;
this.savePosition()
this.render(true)
this.display()
}
/* -------------------------------------------- */
@ -290,7 +297,7 @@ export class RdDCalendrier extends Application {
}
this.timestamp = newTimestamp;
await this.rebuildNombresAstraux();
this.updateDisplay();
this.positionAiguilles()
this.display();
}
@ -305,9 +312,9 @@ export class RdDCalendrier extends Application {
else if (calendarSet) {
this.positionnerHeure(Number(calendarSet.value));
}
this.updateDisplay();
this.positionAiguilles()
}
/* -------------------------------------------- */
async incrementTime(minutes = 0) {
if (game.user.isGM) {
@ -315,12 +322,12 @@ export class RdDCalendrier extends Application {
Hooks.callAll(APP_ASTROLOGIE_REFRESH);
}
}
/* -------------------------------------------- */
async incrementerJour() {
await this.setNewTimestamp(this.timestamp.nouveauJour());
}
/* -------------------------------------------- */
async positionnerHeure(heure) {
if (game.user.isGM) {
@ -331,7 +338,7 @@ export class RdDCalendrier extends Application {
Hooks.callAll(APP_ASTROLOGIE_REFRESH);
}
}
/* -------------------------------------------- */
getLectureAstrologieDifficulte(dateIndex) {
let indexNow = this.timestamp.indexDate;
@ -405,24 +412,6 @@ export class RdDCalendrier extends Application {
return 0;
}
/* -------------------------------------------- */
updateDisplay() {
const calendrier = this.fillCalendrierData();
for (const heure of document.getElementsByClassName("calendar-heure-texte")) {
heure.innerHTML = calendrier.heure.label;
}
for (const minute of document.getElementsByClassName("calendar-minute-texte")) {
minute.innerHTML = `${calendrier.minute} minutes`;
}
this.postionnerAiguilles()
}
postionnerAiguilles() {
const timestamp = this.getTimestamp();
this.html.find(`div.horloge-roue div.horloge-aiguille-heure img`).css(Misc.cssRotation(timestamp.angleHeure));
this.html.find(`div.horloge-roue div.horloge-aiguille-minute img`).css(Misc.cssRotation(timestamp.angleMinute));
}
/* -------------------------------------------- */
async saveEditeur(calendrierData) {
const newTimestamp = RdDTimestamp.timestamp(

View File

@ -228,6 +228,15 @@ export class RdDTimestamp {
this.indexMinute = indexMinute ?? 0
}
get annee() { return Math.floor(this.indexDate / RDD_JOURS_PAR_AN) }
get mois() { return Math.floor((this.indexDate % RDD_JOURS_PAR_AN) / RDD_JOURS_PAR_MOIS) }
get jour() { return (this.indexDate % RDD_JOURS_PAR_AN) % RDD_JOURS_PAR_MOIS }
get heure() { return Math.floor(this.indexMinute / RDD_MINUTES_PAR_HEURES) }
get minute() { return this.indexMinute % RDD_MINUTES_PAR_HEURES }
get round() { return ROUNDS_PAR_MINUTE * (this.indexMinute - Math.floor(this.indexMinute)) }
get angleHeure() { return this.indexMinute / RDD_MINUTES_PAR_JOUR * 360 - 45 }
get angleMinute() { return this.indexMinute / RDD_MINUTES_PAR_HEURES * 360 + 45 }
/**
* Convertit le timestamp en une structure avec les informations utiles
* pour afficher la date et l'heure
@ -244,15 +253,6 @@ export class RdDTimestamp {
};
}
get annee() { return Math.floor(this.indexDate / RDD_JOURS_PAR_AN) }
get mois() { return Math.floor((this.indexDate % RDD_JOURS_PAR_AN) / RDD_JOURS_PAR_MOIS) }
get jour() { return (this.indexDate % RDD_JOURS_PAR_AN) % RDD_JOURS_PAR_MOIS }
get heure() { return Math.floor(this.indexMinute / RDD_MINUTES_PAR_HEURES) }
get minute() { return this.indexMinute % RDD_MINUTES_PAR_HEURES }
get round() { return ROUNDS_PAR_MINUTE * (this.indexMinute - Math.floor(this.indexMinute)) }
get angleHeure() { return this.indexMinute / RDD_MINUTES_PAR_JOUR * 360 - 45 }
get angleMinute() { return this.indexMinute / RDD_MINUTES_PAR_HEURES * 360 + 45}
formatDate() {
const jour = this.jour + 1;
const mois = RdDTimestamp.definition(this.mois).label;
@ -260,6 +260,10 @@ export class RdDTimestamp {
return `${jour} ${mois}` + (annee ? ' ' + annee : '');
}
formatDateHeure() {
return `${RdDTimestamp.definition(this.heure).label}, ${this.formatDate()}`;
}
nouveauJour() { return new RdDTimestamp({ indexDate: this.indexDate + 1, indexMinute: 0 }) }
nouvelleHeure() {

View File

@ -226,9 +226,6 @@ export const TMRType = {
desolation: { name: "désolation", genre: "f" }
}
/* -------------------------------------------- */
const caseSpecificModes = ["attache", "trounoir", "debordement", "reserve_extensible", "maitrisee"];
/* -------------------------------------------- */
const tmrRandomMovePatten =
[{ name: 'top', col: 0, row: -1 },
@ -239,8 +236,6 @@ const tmrRandomMovePatten =
{ name: 'topleft', col: -1, row: -1 }
]
/* -------------------------------------------- */
/* -------------------------------------------- */
export class TMRUtility {
static init() {
@ -258,32 +253,25 @@ export class TMRUtility {
/* -------------------------------------------- */
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;
return Grammar.equalsInsensitive(coord, 'Fleuve') || TMRUtility.getTMR(coord);
}
/* -------------------------------------------- */
static getTMR(coord) {
return TMRMapping[coord];
return coord == 'Fleuve' ? TMRMapping['D1'] : TMRMapping[coord];
}
static getTMRLabel(coord) {
return TMRMapping[coord]?.label ?? (coord + ": case inconnue");
return TMRUtility.getTMR(coord)?.label ?? (coord + ": case inconnue");
}
static getTMRType(coord) {
const tmr = TMRMapping[coord];
const tmr = TMRUtility.getTMR(coord);
return Misc.upperFirst(TMRType[tmr.type].name);
}
static getTMRDescr(coord) {
const tmr = TMRMapping[coord];
const tmr = TMRUtility.getTMR(coord);
return Grammar.articleDetermine(tmr.type) + ' ' + tmr.label;
}

View File

@ -79,13 +79,13 @@
--gradient-silver-light: linear-gradient(30deg, rgba(61, 55, 93, 0.2), rgba(178, 179, 196, 0.1), rgba(59, 62, 63, 0.2), rgba(206, 204, 199, 0.1), rgba(61, 46, 49, 0.2));
--gradient-daylight: conic-gradient(
from 0deg,
hsla(50, 50%, 80%, 0.7),
hsla(50, 50%, 80%, 0.1) 25%,
hsla(250, 50%, 20%, 0.1) 25%,
hsla(250, 50%, 20%, 0.5) 50%,
hsla(250, 50%, 20%, 0.1) 75%,
hsla(50, 50%, 80%, 0.1) 75%,
hsla(50, 50%, 80%, 0.7)
hsla(50, 100%, 80%, 0.7),
hsla(30, 30%, 40%, 0.1) 25%,
hsla(250, 50%, 40%, 0.1) 25%,
hsla(250, 30%, 30%, 0.7) 50%,
hsla(250, 50%, 40%, 0.1) 75%,
hsla(30, 30%, 40%, 0.1) 75%,
hsla(50, 100%, 80%, 0.7)
);
--background-custom-button: linear-gradient(to bottom, rgba(33, 55, 74, 0.988) 5%, rgba(21, 40, 51, 0.671) 100%);
@ -1631,6 +1631,7 @@ table.table-nombres-astraux tr:hover {
font-family: "GoudyAcc";
pointer-events: none;
}
.window-app.calendar .window-content > div {
pointer-events: all;
}
@ -1644,12 +1645,12 @@ table.table-nombres-astraux tr:hover {
}
.window-app.calendar div.horloge-roue div.horloge-heure {
width: 1rem;
height: 1rem;
width: 1.4rem;
height: 1.4rem;
}
.window-app.calendar div.horloge-roue div.horloge-heure img.horloge-heure-img {
width: 1.6rem;
height: 1.6rem;
width: 1.4rem;
height: 1.4rem;
}
div.horloge-roue div {
@ -1692,23 +1693,24 @@ div.horloge-roue div.horloge-ajustement {
vertical-align: middle;
border-radius: 0.3rem;
}
div.horloge-roue div img {
border: none;
}
.window-app.calendar div.horloge-heure.heure-01 { top: calc(50% - 0.8rem + sin(-180deg) *41%); left: calc(50% - 0.5rem + cos(-180deg) *41%); }
.window-app.calendar div.horloge-heure.heure-02 { top: calc(50% - 0.8rem + sin(-150deg) *41%); left: calc(50% - 0.5rem + cos(-150deg) *41%); }
.window-app.calendar div.horloge-heure.heure-03 { top: calc(50% - 0.8rem + sin(-120deg) *41%); left: calc(50% - 0.5rem + cos(-120deg) *41%); }
.window-app.calendar div.horloge-heure.heure-04 { top: calc(50% - 0.8rem + sin(-90deg) *41%); left: calc(50% - 0.5rem + cos(-90deg) *41%); }
.window-app.calendar div.horloge-heure.heure-05 { top: calc(50% - 0.8rem + sin(-60deg) *41%); left: calc(50% - 0.5rem + cos(-60deg) *41%); }
.window-app.calendar div.horloge-heure.heure-06 { top: calc(50% - 0.8rem + sin(-30deg) *41%); left: calc(50% - 0.5rem + cos(-30deg) *41%); }
.window-app.calendar div.horloge-heure.heure-07 { top: calc(50% - 0.8rem + sin(-0deg) *41%); left: calc(50% - 0.5rem + cos(-0deg) *41%); }
.window-app.calendar div.horloge-heure.heure-08 { top: calc(50% - 0.8rem + sin(30deg) *41%); left: calc(50% - 0.5rem + cos(30deg) *41%); }
.window-app.calendar div.horloge-heure.heure-09 { top: calc(50% - 0.8rem + sin(60deg) *41%); left: calc(50% - 0.5rem + cos(60deg) *41%); }
.window-app.calendar div.horloge-heure.heure-10 { top: calc(50% - 0.8rem + sin(90deg) *41%); left: calc(50% - 0.5rem + cos(90deg) *41%); }
.window-app.calendar div.horloge-heure.heure-11 { top: calc(50% - 0.8rem + sin(120deg) *41%); left: calc(50% - 0.5rem + cos(120deg) *41%); }
.window-app.calendar div.horloge-heure.heure-12 { top: calc(50% - 0.8rem + sin(150deg) *41%); left: calc(50% - 0.5rem + cos(150deg) *41%); }
.window-app.calendar div.horloge-heure.heure-01 { top: calc(50% - 0.7rem + sin(-180deg) *38%); left: calc(50% - 0.7rem + cos(-180deg) *38%); }
.window-app.calendar div.horloge-heure.heure-02 { top: calc(50% - 0.7rem + sin(-150deg) *38%); left: calc(50% - 0.7rem + cos(-150deg) *38%); }
.window-app.calendar div.horloge-heure.heure-03 { top: calc(50% - 0.7rem + sin(-120deg) *38%); left: calc(50% - 0.7rem + cos(-120deg) *38%); }
.window-app.calendar div.horloge-heure.heure-04 { top: calc(50% - 0.7rem + sin(-90deg) *38%); left: calc(50% - 0.7rem + cos(-90deg) *38%); }
.window-app.calendar div.horloge-heure.heure-05 { top: calc(50% - 0.7rem + sin(-60deg) *38%); left: calc(50% - 0.7rem + cos(-60deg) *38%); }
.window-app.calendar div.horloge-heure.heure-06 { top: calc(50% - 0.7rem + sin(-30deg) *38%); left: calc(50% - 0.7rem + cos(-30deg) *38%); }
.window-app.calendar div.horloge-heure.heure-07 { top: calc(50% - 0.7rem + sin(-0deg) *38%); left: calc(50% - 0.7rem + cos(-0deg) *38%); }
.window-app.calendar div.horloge-heure.heure-08 { top: calc(50% - 0.7rem + sin(30deg) *38%); left: calc(50% - 0.7rem + cos(30deg) *38%); }
.window-app.calendar div.horloge-heure.heure-09 { top: calc(50% - 0.7rem + sin(60deg) *38%); left: calc(50% - 0.7rem + cos(60deg) *38%); }
.window-app.calendar div.horloge-heure.heure-10 { top: calc(50% - 0.7rem + sin(90deg) *38%); left: calc(50% - 0.7rem + cos(90deg) *38%); }
.window-app.calendar div.horloge-heure.heure-11 { top: calc(50% - 0.7rem + sin(120deg) *38%); left: calc(50% - 0.7rem + cos(120deg) *38%); }
.window-app.calendar div.horloge-heure.heure-12 { top: calc(50% - 0.7rem + sin(150deg) *38%); left: calc(50% - 0.7rem + cos(150deg) *41%); }
.window-app.calendar-astrologie div.horloge-heure.heure-01 { top: calc(50% - 1rem + sin(-180deg) *41%); left: calc(50% - 1rem + cos(-180deg) *41%); }
.window-app.calendar-astrologie div.horloge-heure.heure-02 { top: calc(50% - 1rem + sin(-150deg) *41%); left: calc(50% - 1rem + cos(-150deg) *41%); }
@ -1751,6 +1753,7 @@ div.horloge-roue div img {
.calendar-boutons-heure .calendar-btn:is(.calendar-lyre,.calendar-vaisseau) img {
color: hsla(0, 0%, 100%, 0.5);
border: none;
vertical-align: bottom;
max-width: 1.2em;
max-height: 1.2em;
@ -1786,6 +1789,9 @@ div.horloge-analogique {
vertical-align: middle;
pointer-events: none;
}
div.horloge-analogique.horloge-analogique-hidden {
visibility: hidden;
}
div.horloge-digitale {
color: #CCC;
background: hsla(0, 0%, 20%, 1);
@ -1793,10 +1799,9 @@ div.horloge-digitale {
width: 100%;
}
div.horloge-digitale .calendar-heure-texte {
font-size: 1.1rem;
}
div.horloge-digitale .calendar-minute-texte {
div.horloge-digitale :is(.calendar-heure-texte,.calendar-minute-texte) {
font-size: 1rem;
pointer-events: all;
margin: 0;
}

View File

@ -1,8 +1,8 @@
{
"id": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"version": "10.7.5",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.7.5.zip",
"version": "10.7.6",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.7.6.zip",
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
"compatibility": {
"minimum": "10",

View File

@ -620,7 +620,7 @@
"bonus": 0
},
"localisation": "",
"jours": 0
"origine": ""
},
"maladie": {
"templates": ["description", "temporel"],

View File

@ -1,8 +1,8 @@
<li class="item item-blessure flexrow list-item blessure-active-{{lowercase system.labelGravite}}" data-item-id="{{id}}">
<li class="item item-blessure flexrow list-item blessure-active-{{lowercase system.label}}" data-item-id="{{id}}">
<span class="blessure-control">
<img class="sheet-competence-img" src="{{img}}" />
<i class="fas fa-skull-crossbones"></i>
{{system.labelGravite}}
{{system.label}}
</span>
{{#if (gt system.gravite 6)}}
<span class="flexrow"></span>
@ -30,7 +30,8 @@
</span>
{{/if}}
<span>
{{system.localisation}}
{{#if system.origine}}<span>Par {{system.origine}}</span>{{/if}}
{{#if system.localisation}}<span>{{system.localisation}}</span>{{/if}}
</span>
<span class="item-controls">
<a class="item-edit" title="Editer"><i class="fas fa-edit"></i></a>

View File

@ -15,7 +15,11 @@
</a>
{{/if}}
</span>
<span class="equipement-detail">{{item.system.quantite}}
<span class="equipement-detail">
{{#if (gt item.system.quantite 1)}}
<a class="item-quantite-moins"><i class="fas fa-minus-square"></i></a>
{{/if}}
{{item.system.quantite}}
{{#if (gt item.system.quantite 1)}}
<a class="item-split" title="Séparer"><i class="fas fa-unlink"></i></a>
{{/if}}

View File

@ -10,7 +10,7 @@
</span>
{{#if @root.options.isOwner}}
<span class="equipement-button item-controls">
<a class="monnaie-moins"><i class="fas fa-minus-square"></i></a>
<a class="item-quantite-moins"><i class="fas fa-minus-square"></i></a>
</span>
{{/if}}
<span class="equipement-detail">
@ -18,7 +18,7 @@
</span>
{{#if @root.options.isOwner}}
<span class="equipement-button item-controls">
<a class="monnaie-plus"><i class="fas fa-plus-square"></i></a>
<a class="item-quantite-plus"><i class="fas fa-plus-square"></i></a>
</span>
{{/if}}
<span class="equipement-actions item-controls">

View File

@ -17,6 +17,10 @@
<label for="system.localisation">Localisation</label>
<input class="attribute-value" type="text" name="system.localisation" value="{{system.localisation}}" data-dtype="String"/>
</div>
<div class="form-group">
<label for="system.origine">Causée par</label>
<input class="attribute-value" type="text" name="system.origine" value="{{system.origine}}" data-dtype="String"/>
</div>
{{#if (lt system.gravite 7)}}
<div class="form-group">
<label for="system.difficulte">Difficulté des soins</label>
@ -35,7 +39,6 @@
<label for="system.premierssoins.tache">Points de tâches</label>
<input class="attribute-value number-x" type="text" name="system.premierssoins.tache" value="{{system.premierssoins.tache}}" data-dtype="Number"/>
{{/if}}
</div>
{{#if system.premierssoins.done}}

View File

@ -1,4 +1,4 @@
<div>
<div class="calendar-horloge">
{{#if isGM}}
<div class="calendar-boutons-heure">
<i class="calendar-btn calendar-1min" data-calendar-avance="1" title="Avancer de 1 minute">+1</i>
@ -8,7 +8,7 @@
<i class="calendar-btn calendar-60min" data-calendar-avance="60" title="Avancer de 60 minutes" >+60</i>
<i class="calendar-btn calendar-1heure" data-calendar-avance="120" title="Avancer d'1 heure" >+1h</i>
<i class="calendar-btn calendar-lyre fas fa-forward" data-calendar-set="6" title="Avancer à Lyre">
<img src="systems/foundryvtt-reve-de-dragon/icons/heures/hd07.svg" alt="Avancer à Lyre"/>
<img src="systems/foundryvtt-reve-de-dragon/icons/heures/hd07.svg" alt="Avancer à Lyre"/>
</i>
<i class="calendar-btn calendar-vaisseau fas fa-forward" data-calendar-set="0" title="Avancer au Vaisseau">
<img src="systems/foundryvtt-reve-de-dragon/icons/heures/hd01.svg" alt="Avancer au Vaisseau"/>
@ -31,12 +31,10 @@
</a>
</span>
{{#if isGM}}
<span class="calendar-minute-texte">{{minute}} minutes</p>
<span class="calendar-minute-texte">{{minute}} minutes</span>
{{/if}}
</div>
</div>
<div class="horloge-analogique">
{{#if horlogeAnalogique}}
{{> 'systems/foundryvtt-reve-de-dragon/templates/time/horloge.hbs' }}
{{/if}}
<div class="horloge-analogique {{#unless horlogeAnalogique}}horloge-analogique-hidden{{/unless}}">
{{> 'systems/foundryvtt-reve-de-dragon/templates/time/horloge.hbs' }}
</div>
</div>