Corrections imports et ajouts sorts en réserve #731

Merged
uberwald merged 7 commits from VincentVk/foundryvtt-reve-de-dragon:v11 into v11 2024-12-14 16:48:39 +01:00
13 changed files with 132 additions and 86 deletions

View File

@ -1,4 +1,7 @@
# 12.0
## 12.0.28 - Les réserves d'Astrobazzarh
- possibilité de mettre en réserve depuis un sort connu
## 12.0.27 - Les vêtements d'Astrobazzarh
- Ajout de la liste des armures dans l'onglet caractéristiques
- Ajout d'une option pour choisir une carte des TMR alternatives
@ -115,11 +118,9 @@
- encodage de l'export en windows-1252
- export de l'esquive avec armure et sans armure
## 12.0.10 - Le scriptorium d'Astrobazzarh
## 12.0.9 - 12.0.10 - Le scriptorium d'Astrobazzarh
- corrections de l'export scriptarium
## 12.0.9 - Le scriptorium d'Astrobazzarh
- ajout d'une fonction avancée pour exporter les personnages dans un format csv
- ajout d'une fonction avancée pour un exporter "scriptarium" des personnages
## 12.0.8 - La quincaillerie d'Astrobazzarh
- le propriétaire est indiqué dans les feuilles d'équipements/compétences/...

View File

@ -183,7 +183,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
// Equip Inventory Item
this.html.find('.item-equip').click(async event => this.actor.equiperObjet(RdDSheetUtility.getItemId(event)))
this.html.find('.chance-actuelle').click(async event => this.actor.rollCarac('chance-actuelle'))
this.html.find('.roll-chance-actuelle').click(async event => this.actor.rollCarac('chance-actuelle'))
this.html.find('.button-appel-chance').click(async event => this.actor.rollAppelChance())
@ -214,7 +214,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
// Boutons spéciaux MJs
this.html.find('.forcer-tmr-aleatoire').click(async event => this.actor.reinsertionAleatoire("Action MJ"))
this.html.find('.don-de-haut-reve').click(async event => this.actor.addDonDeHautReve())
this.html.find('.nouveau-sort-reserve').click(async event => this.actor.addSortReserve())
this.html.find('.sortreserve-add').click(async event => this.actor.addSortReserve(RdDSheetUtility.getItemId(event)))
this.html.find('.afficher-tmr').click(async event => this.actor.changeTMRVisible())
}
@ -284,6 +284,8 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
this.html.find('.ptreve-actuel-plus').click(async event => this.actor.reveActuelIncDec(1))
this.html.find('.ptreve-actuel-moins').click(async event => this.actor.reveActuelIncDec(-1))
this.html.find('.chance-actuelle-plus').click(async event => this.actor.chanceActuelleIncDec(1))
this.html.find('.chance-actuelle-moins').click(async event => this.actor.chanceActuelleIncDec(-1))
this.html.find('.fatigue-plus').click(async event => this.actor.santeIncDec("fatigue", 1))
this.html.find('.fatigue-moins').click(async event => this.actor.santeIncDec("fatigue", -1))
}

View File

@ -95,11 +95,14 @@ export class RdDActor extends RdDBaseActorSang {
isHautRevant() { return this.system.attributs.hautrevant.value != "" }
/* -------------------------------------------- */
getAgilite() { return this.system.carac.agilite?.value ?? 0 }
getChance() { return this.system.carac.chance?.value ?? 0 }
getAgilite() { return Misc.toInt(this.system.carac.agilite?.value ?? 0) }
getChance() { return Misc.toInt(this.system.carac.chance?.value ?? 0) }
getReveActuel() { return this.system.reve?.reve?.value ?? this.carac.reve.value ?? 0 }
getChanceActuel() { return this.system.compteurs.chance?.value ?? 10 }
getReveActuel() { return Misc.toInt(this.system.reve?.reve?.value) ?? this.carac.reve.value ?? 0 }
getChanceActuel() {
return Number.isNumeric(this.system.compteurs.chance.value) ?
Misc.toInt(this.system.compteurs.chance.value) : this.getChance()
}
getMoralTotal() { return this.system.compteurs.moral?.value ?? 0 }
getEnduranceMax() { return Math.max(1, Math.max(this.getTaille() + this.getConstitution(), this.getVieMax() + this.getVolonte())) }
@ -991,13 +994,23 @@ export class RdDActor extends RdDBaseActorSang {
}
}
async addSortReserve() {
async addSortReserve(itemId) {
if (itemId) {
const item = this.items.get(itemId)
if (item.type == ITEM_TYPES.sort && !item.system.isrituel) {
this.$createSortReserve(item)
return
}
}
const selectSortReserve = {
title: "Créer un sort en réserve",
label: "Choisir un sort",
list: this.itemTypes[ITEM_TYPES.sort].filter(it => !it.system.isrituel)
}
DialogSelect.select(selectSortReserve, sort =>
DialogSelect.select(selectSortReserve, sort => this.$createSortReserve(sort))
}
$createSortReserve(sort) {
this.createEmbeddedDocuments("Item",
[{
type: ITEM_TYPES.sortreserve,
@ -1005,7 +1018,7 @@ export class RdDActor extends RdDBaseActorSang {
img: sort.img,
system: { sortid: sort.id, draconic: sort.system.draconic, ptreve: Number(sort.system.ptreve.match(/\d+/)), coord: 'A1', heurecible: 'Vaisseau' }
}],
{ renderSheet: true }))
{ renderSheet: true })
}
/* -------------------------------------------- */
async reinsertionAleatoire(raison, accessible = tmr => true) {
@ -1070,6 +1083,11 @@ export class RdDActor extends RdDBaseActorSang {
await this.update({ "system.reve.reve.value": reve });
}
async chanceActuelleIncDec(value) {
const chance = Math.min(this.getChance(), Math.max(this.getChanceActuel() + value, 0));
await this.update({ "system.compteurs.chance.value": chance });
}
/* -------------------------------------------- */
async regainPointDeSeuil() {
const seuil = Misc.toInt(this.system.reve.seuil.value);
@ -2254,12 +2272,6 @@ export class RdDActor extends RdDBaseActorSang {
}
}
/* -------------------------------------------- */
async chanceActuelleIncDec(value) {
const chance = Math.min(this.getChance(), Math.max(this.getChanceActuel() + value, 0));
await this.updateCompteurValue("chance", chance);
}
/* -------------------------------------------- */
async appelDestinee(onSuccess = () => { }, onEchec = () => { }) {
let destinee = this.system.compteurs.destinee?.value ?? 0;

View File

@ -48,6 +48,19 @@ export class RdDBaseActorReveSheet extends RdDBaseActorSheet {
}], { renderSheet: true })
)
if (this.options.vueDetaillee) {
// On carac change
this.html.find('.carac-value').change(async event => {
let caracName = event.currentTarget.name.replace(".value", "").replace("system.carac.", "");
this.actor.updateCarac(caracName, parseInt(event.target.value));
});
// On competence change
this.html.find('.competence-value').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
//console.log("Competence changed :", compName);
this.actor.updateCompetence(compName, parseInt(event.target.value));
});
}
}
}

View File

@ -177,21 +177,6 @@ export class RdDBaseActorSheet extends ActorSheet {
this.options.vueDetaillee = !this.options.vueDetaillee;
this.render(true);
});
if (this.options.vueDetaillee) {
// On carac change
this.html.find('.carac-value').change(async event => {
let caracName = event.currentTarget.name.replace(".value", "").replace("system.carac.", "");
this.actor.updateCarac(caracName, parseInt(event.target.value));
});
// On competence change
this.html.find('.competence-value').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
//console.log("Competence changed :", compName);
this.actor.updateCompetence(compName, parseInt(event.target.value));
});
}
}
_rechercherKeyup(event) {

View File

@ -83,6 +83,7 @@ const MAPPING_BASE = [
{ column: "protectionarmure", colName: 'Protection', getter: (actor, context) => Mapping.getProtectionArmure(actor, context) },
{ column: "malus_armure", getter: (actor, context) => Mapping.getMalusArmure(actor, context) },
{ column: "reve_actuel", rollClass: 'roll-reve-actuel', colName: 'Rêve actuel', getter: (actor, context) => actor.system.reve.reve.value },
{ column: "chance_actuel", rollClass: 'roll-chance-actuelle', colName: 'Chance actuelle', getter: (actor, context) => actor.system.compteurs.chance.value },
{ column: "vie_actuel", rollClass: 'jet-vie', getter: (actor, context) => actor.system.sante.vie.value },
{ column: "endurance_actuel", rollClass: 'jet-endurance', getter: (actor, context) => actor.system.sante.endurance.value },
{ column: "esquive", getter: (actor, context) => Mapping.getEsquive(context) },

View File

@ -26,7 +26,7 @@ const MANIEMENTS = {
'de lancer': (weapon) => { return { name: weapon.system.lancer, categorie: 'lancer' } },
'de jet': (weapon) => { return { name: weapon.system.lancer, categorie: 'lancer' } },
'à une main': (weapon) => { return { name: weapon.system.competence, categorie: 'melee' } },
'à deux main': (weapon) => { return { name: weapon.system.competence.replace("à 1 main", "à 2 main"), categorie: 'melee' } },
'à deux mains': (weapon) => { return { name: weapon.system.competence.replace("à 1 main", "à 2 mains"), categorie: 'melee' } },
'mêlée': (weapon) => { return { name: weapon.system.competence, categorie: 'melee' } },
}
const XREGEXP_WEAPON_MANIEMENT = "(?<maniement>(" + Misc.join(Object.keys(MANIEMENTS), '|') + "))"
@ -267,7 +267,7 @@ export class RdDStatBlockParser {
}
let weapMatch = XRegExp.exec(statString, XRegExp(weapon.name
+ "(\\s*" + XREGEXP_WEAPON_MANIEMENT + ")?"
+ "\\s+(?<value>\\+\\d+)", 'giu'));
+ "\\s+(?<value>[\\+\\-]?\\d+)", 'giu'));
if (weapMatch) {
weapon = weapon.toObject();
weapon.system.equipe = 'true';
@ -479,12 +479,12 @@ export class RdDStatBlockParser {
let namePersonnage = "Importé"
if (statString.includes(", né")) {
// Name is all string before first comma ','
namePersonnage = XRegExp.exec(statString, XRegExp("(?<value>[\\p{Letter}\\s\\d]+),", 'giu'));
namePersonnage = XRegExp.exec(statString, XRegExp("(?<value>[\\p{Letter}\\-\\s\\d]+),", 'giu'));
} else {
namePersonnage = XRegExp.exec(statString, XRegExp("(?<value>[\\p{Letter}\\s\\d]+)\\s+TAILLE", 'giu'));
namePersonnage = XRegExp.exec(statString, XRegExp("(?<value>[\\p{Letter}\\-\\s\\d]+)\\s+TAILLE", 'giu'));
}
if (namePersonnage?.value) {
return Misc.upperFirst(namePersonnage?.value);
return Misc.upperFirst(namePersonnage?.value.toLowerCase());
}
}
const name = XRegExp.exec(statString, XRegExp("(?<value>.+)\\s+taille", 'giu'));

View File

@ -262,7 +262,24 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/chat-signe-draconique-actor.html'
];
// foundry et options
Handlebars.registerHelper('RDD_CONFIG', path => RDD_CONFIG[path])
Handlebars.registerHelper('linkCompendium', (pack, id, name) => RdDUtility.linkCompendium(pack, id, name));
Handlebars.registerHelper('regle-optionnelle', (option) => ReglesOptionnelles.isUsing(option));
Handlebars.registerHelper('plusMoins', diff => (diff > 0 ? '+' : '') + Math.round(diff))
// Handle v12 removal of this helper
Handlebars.registerHelper('select', function (selected, options) {
const escapedValue = RegExp.escape(Handlebars.escapeExpression(selected));
const rgx = new RegExp(' value=[\"\']' + escapedValue + '[\"\']');
const html = options.fn(this);
return html.replace(rgx, "$& selected");
})
// logic
Handlebars.registerHelper('either', (a, b) => a ?? b);
// string manipulation
Handlebars.registerHelper('upperFirst', str => Misc.upperFirst(str ?? 'Null'));
Handlebars.registerHelper('lowerFirst', str => Misc.lowerFirst(str ?? 'Null'));
Handlebars.registerHelper('uppercase', str => str?.toUpperCase() ?? '');
@ -272,47 +289,52 @@ export class RdDUtility {
Handlebars.registerHelper('grammar-un', str => Grammar.articleIndetermine(str));
Handlebars.registerHelper('grammar-accord', (genre, ...args) => Grammar.accord(genre, args));
Handlebars.registerHelper('RDD_CONFIG', path => RDD_CONFIG[path])
// math
Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1)));
Handlebars.registerHelper('repeat', function(n, block) {
let accum = '';
for(let i = 0; i < n; ++i){
accum += block.fn(i)
}
return accum
})
// tableaux, listes
Handlebars.registerHelper('array-includes', (array, value) => array.includes(value));
Handlebars.registerHelper('isLastIndex', (index, list) => index + 1 >= list.length);
Handlebars.registerHelper('trier', list => list.sort((a, b) => a.name.localeCompare(b.name)));
// table de résolution
Handlebars.registerHelper('computeResolutionScore', (row, col) => RdDResolutionTable.computePercentage(row, col));
Handlebars.registerHelper('computeResolutionChances', (row, col) => RdDResolutionTable.computeChances(row, col));
Handlebars.registerHelper('buildLigneInventaire', (item, options) => { return new Handlebars.SafeString(RdDUtility.buildLigneInventaire(item, options)); });
Handlebars.registerHelper('buildInventaireConteneur', (actorId, itemId, options) => { return new Handlebars.SafeString(RdDUtility.buildInventaireConteneur(actorId, itemId, options)); });
Handlebars.registerHelper('buildContenuConteneur', (item, options) => { return new Handlebars.SafeString(RdDUtility.buildContenuConteneur(item, options)); });
Handlebars.registerHelper('calculerPrixCommercant', item => item.calculerPrixCommercant());
Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord));
Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord));
Handlebars.registerHelper('typeTmr-name', type => TMRUtility.typeTmrName(type));
Handlebars.registerHelper('effetRencontre-name', coord => TMRUtility.typeTmrName(coord));
// gestion des dates et heures
Handlebars.registerHelper('timestamp-imgSigneHeure', (heure) => { return new Handlebars.SafeString(RdDTimestamp.imgSigneHeure(heure)) });
Handlebars.registerHelper('timestamp-imgSigne', (heure) => { return new Handlebars.SafeString(RdDTimestamp.imgSigne(heure)) });
Handlebars.registerHelper('timestamp-extract', timestamp => new RdDTimestamp(timestamp).toCalendrier());
Handlebars.registerHelper('timestamp-formulesDuree', () => RdDTimestamp.formulesDuree());
Handlebars.registerHelper('timestamp-formulesPeriode', () => RdDTimestamp.formulesPeriode());
// informations sur les acteurs
Handlebars.registerHelper('actor-default', (actorType, ...path) => RdDBaseActor.getDefaultValue(actorType, path.slice(0, -1)));
Handlebars.registerHelper('array-includes', (array, value) => array.includes(value));
Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1)));
Handlebars.registerHelper('isLastIndex', (index, list) => index + 1 >= list.length);
Handlebars.registerHelper('regle-optionnelle', (option) => ReglesOptionnelles.isUsing(option));
Handlebars.registerHelper('trier', list => list.sort((a, b) => a.name.localeCompare(b.name)));
Handlebars.registerHelper('filtreTriCompetences', competences => RdDItemCompetence.triVisible(competences));
Handlebars.registerHelper('linkCompendium', (pack, id, name) => RdDUtility.linkCompendium(pack, id, name));
Handlebars.registerHelper('uniteQuantite', (itemId, actorId) => RdDUtility.getItem(itemId, actorId)?.getUniteQuantite());
Handlebars.registerHelper('isFieldInventaireModifiable', (type, field) => RdDItem.isFieldInventaireModifiable(type, field));
Handlebars.registerHelper('rarete-getChamp', (rarete, field) => RdDRaretes.getChamp(rarete, field));
Handlebars.registerHelper('plusMoins', diff => (diff > 0 ? '+' : '') + Math.round(diff))
Handlebars.registerHelper('experienceLog-topic', topic => ExperienceLog.labelTopic(topic));
// Handle v12 removal of this helper
Handlebars.registerHelper('select', function (selected, options) {
const escapedValue = RegExp.escape(Handlebars.escapeExpression(selected));
const rgx = new RegExp(' value=[\"\']' + escapedValue + '[\"\']');
const html = options.fn(this);
return html.replace(rgx, "$& selected");
});
// inventaire et marchands
Handlebars.registerHelper('buildLigneInventaire', (item, options) => { return new Handlebars.SafeString(RdDUtility.buildLigneInventaire(item, options)); });
Handlebars.registerHelper('buildInventaireConteneur', (actorId, itemId, options) => { return new Handlebars.SafeString(RdDUtility.buildInventaireConteneur(actorId, itemId, options)); });
Handlebars.registerHelper('buildContenuConteneur', (item, options) => { return new Handlebars.SafeString(RdDUtility.buildContenuConteneur(item, options)); });
Handlebars.registerHelper('calculerPrixCommercant', item => item.calculerPrixCommercant());
Handlebars.registerHelper('uniteQuantite', (itemId, actorId) => RdDUtility.getItem(itemId, actorId)?.getUniteQuantite());
Handlebars.registerHelper('isFieldInventaireModifiable', (type, field) => RdDItem.isFieldInventaireModifiable(type, field));
// Items
Handlebars.registerHelper('rarete-getChamp', (rarete, field) => RdDRaretes.getChamp(rarete, field));
// TMRs
Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord));
Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord));
Handlebars.registerHelper('typeTmr-name', type => TMRUtility.typeTmrName(type));
Handlebars.registerHelper('effetRencontre-name', coord => TMRUtility.typeTmrName(coord));
return loadTemplates(templatePaths);
}

View File

@ -816,12 +816,12 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) {
.competence-list .item-controls.hidden-controls {
display: none !important;
}
.item-controls i:is(.fas, .fa, .fa-solid) {
.item-controls i:is(.fas, .fa, .fa-solid, .fa-regular) {
font-size: 0.8em;
color: var(--color-controls);
}
.item-controls i:is(.fas, .far, .fa-solid):hover {
opacity: 0.7 ;
.item-controls i:is(.fas, .far, .fa-solid, .fa-regular):hover {
opacity: 0.6;
}
.rdd-roll-dialog .description-sort {

View File

@ -37,7 +37,7 @@
<input class="derivee-value" type="number" name="system.compteurs.dissolution.value" value="{{system.compteurs.dissolution.value}}" data-dtype="number"/>
</li>
<li class="caracteristique flexrow list-item">
<label class="derivee-label chance-actuelle" data-tooltip="Jet de chance actuelle"><a>Chance actuelle</a></label>
<label class="derivee-label chance-actuelle" data-tooltip="Jet de chance actuelle"><a class="roll-chance-actuelle">Chance actuelle</a></label>
<input class="derivee-value" type="number" name="system.compteurs.chance.value" value="{{system.compteurs.chance.value}}" data-dtype="number"/>
</li>
<li class="caracteristique flexrow list-item">

View File

@ -54,7 +54,7 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac.hbs" carac=export.empathie}}
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac.hbs" carac=export.intellect}}
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac-compteur.hbs" carac=export.reve actuel=export.reve_actuel button-name='ptreve-actuel'}}
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac.hbs" carac=export.chance}}
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac-compteur.hbs" carac=export.chance actuel=export.chance_actuel button-name='chance-actuelle'}}
</div>
<div class="flexcol flex-group-top">
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac-derivee.hbs" carac=export.melee}}

View File

@ -1,5 +1,6 @@
{{#if sortsReserve.length}}
<h3>Sorts en Réserve{{#if options.isGM}} <a class="nouveau-sort-reserve"><i class="fa-solid fa-sparkles"></i>
<h3>Sorts en Réserve{{#if options.isGM}} <a class="sortreserve-add">
<i class="fa-solid fa-sparkles"></i>
</a>{{/if}}
</h3>
<ul class="item-list alterne-list">

View File

@ -5,8 +5,12 @@
<li class="item list-item flexrow" data-item-id="{{sort._id}}" data-attribute="{{key}}" data-tooltip="{{#if sort.system.isrituel}}Rituel{{else}}Sort{{/if}}: {{sort.name}}">
<img class="sheet-competence-img" src="{{sort.img}}"/>
<span class="flex-shrink">{{itemSort-shortDraconic sort.system.draconic}}</span>
<span class="item-edit flex-grow-3">{{sort.name}}{{#if sort.system.isrituel}}
<i class="fa-regular fa-book-sparkles"></i>{{/if}}</span>
<span class="item-edit flex-grow-3">{{sort.name}}
{{#if sort.system.isrituel}}<i class="fa-solid fa-book-sparkles"></i>{{/if}}
{{#if sort.system.coutseuil}}
{{#repeat sort.system.coutseuil}}<i class="fa-solid fa-star-sharp" data-tooltip="coût de seuil: {{sort.system.coutseuil}}"></i>{{/repeat}}
{{/if}}
</span>
<span class="flex-grow-2">
{{#if sort.system.caseTMRspeciale}}{{sort.system.caseTMRspeciale}}{{else}}{{upperFirst sort.system.caseTMR}}{{/if}}
</span>
@ -15,6 +19,11 @@
<a class="item-edit" data-tooltip="Modifier"><i class="fas fa-edit"></i></a>
<a class="item-delete" data-tooltip="Supprimer"><i class="fas fa-trash"></i></a>
<a class="item-montrer" data-tooltip="Montrer"><i class="fas fa-comment"></i></a>
{{#if (and @root.options.isGM (not sort.system.isrituel))}}
<a class="sortreserve-add" data-tooltip="Ajouter ce sort en réserve">
<i class="fa-solid fa-sparkles"></i>
</a>
{{/if}}
</div>
</li>
{{/each}}