Tables de compendiums et feuilles de personnages #582

Merged
uberwald merged 14 commits from VincentVk/foundryvtt-reve-de-dragon:v10 into v10 2022-11-30 09:37:49 +01:00
9 changed files with 272 additions and 284 deletions
Showing only changes of commit 4bd2c1c2b4 - Show all commits

View File

@ -3267,10 +3267,9 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async equiperObjet(itemID) {
let item = this.getEmbeddedDocument('Item', itemID);
if (item?.system) {
if (item && ['arme', 'armure'].includes(item.type)) {
const isEquipe = !item.system.equipe;
let update = { _id: item.id, "system.equipe": isEquipe };
await this.updateEmbeddedDocuments('Item', [update]);
await this.updateEmbeddedDocuments('Item', [{ _id: item.id, "system.equipe": isEquipe }]);
this.computeEncombrementTotalEtMalusArmure(); // Mise à jour encombrement
if (isEquipe)
this.verifierForceMin(item);
@ -3569,7 +3568,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
getFortune() {
return this.itemTypes['monnaie']
.map(m => Number(m.system.valeur_deniers) * Number(m.system.quantite))
.map(m => Number(m.system.cout) * Number(m.system.quantite))
.reduce(Misc.sum(), 0);
}

View File

@ -4,22 +4,22 @@ import { LOG_HEAD } from "./constants.js";
const MONNAIE_ETAIN = {
name: "Etain (1 denier)", type: 'monnaie',
img: "systems/foundryvtt-reve-de-dragon/icons/objets/piece_etain_poisson.webp",
system: { quantite: 0, valeur_deniers: 1, encombrement: 0.001, description: "" }
system: { quantite: 0, cout: 1, encombrement: 0.001, description: "" }
};
const MONNAIE_BRONZE = {
name: "Bronze (10 deniers)", type: 'monnaie',
img: "systems/foundryvtt-reve-de-dragon/icons/objets/piece_bronze_epees.webp",
system: { quantite: 0, valeur_deniers: 10, encombrement: 0.002, description: "" }
system: { quantite: 0, cout: 10, encombrement: 0.002, description: "" }
};
const MONNAIE_ARGENT = {
name: "Argent (1 sol)", type: 'monnaie',
img: "systems/foundryvtt-reve-de-dragon/icons/objets/piece_argent_sol.webp",
system: { quantite: 0, valeur_deniers: 100, encombrement: 0.003, description: "" }
system: { quantite: 0, cout: 100, encombrement: 0.003, description: "" }
};
const MONNAIE_OR = {
name: "Or (10 sols)", type: 'monnaie',
img: "systems/foundryvtt-reve-de-dragon/icons/objets/piece_or_sol.webp",
system: { quantite: 0, valeur_deniers: 1000, encombrement: 0.004, description: "" }
system: { quantite: 0, cout: 1000, encombrement: 0.004, description: "" }
};
const MONNAIES_STANDARD = [MONNAIE_ETAIN, MONNAIE_BRONZE, MONNAIE_ARGENT, MONNAIE_OR];
@ -32,7 +32,7 @@ export class Monnaie {
static monnaiesManquantes(actor) {
const disponibles = actor.itemTypes['monnaie'];
const manquantes = MONNAIES_STANDARD.filter(standard => !disponibles.find(disponible => Monnaie.deValeur(disponible, standard.system?.valeur_deniers)));
const manquantes = MONNAIES_STANDARD.filter(standard => !disponibles.find(disponible => Monnaie.deValeur(disponible, standard.system?.cout)));
if (manquantes.length > 0) {
console.error(`${LOG_HEAD} monnaiesManquantes pour ${actor.name}`, manquantes, ' avec monnaies', disponibles, MONNAIES_STANDARD);
}
@ -40,7 +40,7 @@ export class Monnaie {
}
static deValeur(monnaie, valeur) {
return valeur == monnaie.system.valeur_deniers
return valeur == monnaie.system.cout
}
static arrondiDeniers(sols) {
@ -48,7 +48,7 @@ export class Monnaie {
}
static triValeurDenier() {
return Misc.ascending(item => item.system.valeur_deniers)
return Misc.ascending(item => item.system.cout)
}
static async creerMonnaiesStandard(actor) {
@ -69,7 +69,7 @@ export class Monnaie {
let reste = fortune;
let monnaies = actor.itemTypes['monnaie'];
let updates = [];
let parValeur = Misc.classifyFirst(monnaies, it => it.system.valeur_deniers);
let parValeur = Misc.classifyFirst(monnaies, it => it.system.cout);
for (let valeur of [1000, 100, 10, 1]) {
const itemPiece = parValeur[valeur];
if (itemPiece) {

View File

@ -172,7 +172,7 @@ export class RdDItem extends Item {
}
valeurDeniers() {
return Math.max(Math.round(this.system.cout ? (this.system.cout * 100) : (this.system.valeur_deniers ?? 0)), 0)
return Math.max(Math.round(this.system.cout ? (this.system.cout * 100) : (this.system.cout ?? 0)), 0)
}
prepareDerivedData() {
@ -494,7 +494,7 @@ export class RdDItem extends Item {
/* -------------------------------------------- */
_monnaieChatData() {
return [
`<b>Valeur en Deniers</b>: ${this.system.valeur_deniers}`,
`<b>Valeur en Deniers</b>: ${this.system.cout}`,
`<b>Encombrement</b>: ${this.system.encombrement}`
]
}

View File

@ -195,7 +195,8 @@ class _10_2_10_DesirLancinant_IdeeFixe extends Migration {
categorie = 'ideefixe';
name = it.name.replace('Idée fixe : ', '')
}
return { _id: it.id, name: name,
return {
_id: it.id, name: name,
'system.ideefixe': undefined,
'system.lancinant': undefined,
'system.categorie': categorie
@ -206,11 +207,39 @@ class _10_2_10_DesirLancinant_IdeeFixe extends Migration {
await this.applyItemsUpdates(items => items
.filter(it => ['queue', 'ombre'].includes(it.type))
.map(it => this.migrateQueue(it))
//.filter(it => it.system.categorie )
);
}
}
class _10_3_0_Inventaire extends Migration {
get code() { return "migration-equipement-inventaire"; }
get version() { return "10.3.0"; }
async migrate() {
await this.applyItemsUpdates(items => {
return this._updatesMonnaies(items)
.concat(this._updatesNonEquipe(items))
.concat(this._updatesObjets(items))
});
}
_updatesNonEquipe(items) {
return items
.filter(it => ['munition'].includes(it.type))
.map(it => { return { _id: it.id, 'system.equipe': undefined } });
}
_updatesObjets(items) {
return items
.filter(it => ['objet'].includes(it.type))
.map(it => { return { _id: it.id, 'system.resistance': undefined, 'system.equipe': undefined } });
}
_updatesMonnaies(items) {
return items
.filter(it => ['monnaie'].includes(it.type))
.map(it => { return { _id: it.id, 'system.cout': it.system.valeur_deniers, 'system.valeur_deniers': undefined } });
}
}
export class Migrations {
static getMigrations() {
return [
@ -220,6 +249,7 @@ export class Migrations {
new _10_0_33_MigrationNomsDraconic(),
new _10_2_5_ArmesTirLancer(),
new _10_2_10_DesirLancinant_IdeeFixe(),
new _10_3_0_Inventaire()
];
}

View File

@ -890,12 +890,12 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static createMonnaie(name, valeur_deniers, img = "", enc = 0.01) {
static createMonnaie(name, cout, img = "", enc = 0.01) {
let piece = {
name: name, type: 'monnaie', img: img, _id: randomID(16),
dasystemta: {
quantite: 0,
valeur_deniers: valeur_deniers,
cout: cout,
encombrement: enc,
description: ""
}

View File

@ -594,91 +594,17 @@
"description": {
"description": "",
"descriptionmj": ""
},
"equipement": {
"equipe": false
},
"inventaire": {
"encombrement": 0,
"quantite": 1,
"qualite": 0,
"cout": 0
}
},
"possession": {
"templates": [ "description" ],
"typepossession": "",
"possede": false,
"possessionid": "",
"possesseurid": "",
"possedeid": "",
"compteur": 0,
"date": 0
},
"objet": {
"templates": [ "description" ],
"quantite": 1,
"encombrement": 0,
"equipe": false,
"resistance": 0,
"qualite": 0,
"cout": 0
},
"gemme": {
"templates": [ "description" ],
"type": "",
"encombrement": 0,
"quantite": 1,
"cout": 0,
"taille": 0,
"purete": 0,
"inertie": 0,
"enchantabilite": 0,
"qualite": 0
},
"conteneur": {
"templates": [ "description" ],
"capacite": 0,
"encombrement": 0,
"equipe": false,
"qualite": 0,
"contenu": [],
"cout": 0
},
"arme": {
"templates": [ "description" ],
"categorie_parade": "",
"quantite": 1,
"encombrement": 0,
"equipe": false,
"dommages": "0",
"penetration": 0,
"force": "0",
"resistance": 0,
"competence": "",
"lancer": "",
"tir": "",
"cout": 0,
"portee_courte": 0,
"portee_moyenne": 0,
"portee_extreme": 0,
"magique": false,
"ecaille_efficacite": 0,
"resistance_magique": 0,
"rapide": false,
"deuxmains": false,
"unemain": false,
"initpremierround": ""
},
"munition": {
"templates": [ "description" ],
"quantite": 1,
"encombrement": 0,
"equipe": false,
"qualite": 0,
"cout": 0
},
"armure": {
"templates": [ "description" ],
"quantite": 1,
"encombrement": 0,
"equipe": false,
"protection": 0,
"deterioration": 0,
"malus": 0,
"cout": 0
},
"competence": {
"templates": [ "description" ],
"niveau": 0,
@ -702,6 +628,193 @@
"ispossession": false,
"dommages": 0
},
"possession": {
"templates": [ "description" ],
"typepossession": "",
"possede": false,
"possessionid": "",
"possesseurid": "",
"possedeid": "",
"compteur": 0,
"date": 0
},
"maladie": {
"templates": [ "description" ],
"identifie": false,
"malignite": 0,
"periodicite": "",
"remedesconnus": false,
"remedes": "",
"dommages":""
},
"poison": {
"templates": [ "description" ],
"identifie": false,
"malignite": 0,
"periodicite": "",
"remedesconnus": false,
"remedes": "",
"dommages":"",
"active": false
},
"arme": {
"templates": [ "description", "equipement", "inventaire" ],
"resistance": 0,
"categorie_parade": "",
"dommages": "0",
"penetration": 0,
"force": "0",
"competence": "",
"lancer": "",
"tir": "",
"portee_courte": 0,
"portee_moyenne": 0,
"portee_extreme": 0,
"magique": false,
"ecaille_efficacite": 0,
"resistance_magique": 0,
"rapide": false,
"deuxmains": false,
"unemain": false,
"initpremierround": ""
},
"armure": {
"templates": [ "description", "equipement", "inventaire" ],
"protection": 0,
"deterioration": 0,
"malus": 0
},
"conteneur": {
"templates": [ "description", "inventaire" ],
"contenu": [],
"capacite": 0
},
"objet": {
"templates": [ "description", "inventaire"]
},
"monnaie": {
"templates": [ "description", "inventaire" ]
},
"gemme": {
"templates": [ "description", "inventaire" ],
"type": "",
"taille": 0,
"purete": 0,
"inertie": 0,
"enchantabilite": 0
},
"munition": {
"templates": [ "description", "inventaire" ]
},
"nourritureboisson": {
"templates": [ "description", "inventaire" ],
"sust": 0,
"boisson": false,
"desaltere": 0,
"alcoolise": false,
"force": 0,
"exotisme": 0
},
"herbe": {
"templates": [ "description", "inventaire" ],
"niveau": 0,
"base": 0,
"milieu": "",
"rarete": "",
"categorie": ""
},
"ingredient": {
"templates": [ "description", "inventaire" ],
"niveau": 0,
"base": 0,
"milieu": "",
"rarete": "",
"categorie": ""
},
"livre": {
"templates": [ "description", "inventaire" ],
"competence": "",
"auteur": "",
"difficulte": 0,
"points_de_tache": 0,
"xp": "",
"niveau_minimum": 0,
"niveau_maximum": 0
},
"potion": {
"templates": [ "description", "inventaire" ],
"rarete": "",
"categorie": "",
"herbe": "",
"herbebrins": 0,
"herbebonus": 0,
"reposalchimique": false,
"pr": 0,
"prpermanent": false,
"prdate": 0
},
"musique": {
"templates": [ "description" ],
"niveau": "",
"reference": ""
},
"danse": {
"templates": [ "description" ],
"type": "",
"agilite": false,
"apparence": false,
"niveau": "",
"reference": ""
},
"chant": {
"templates": [ "description" ],
"niveau": "",
"reference": ""
},
"jeu": {
"templates": [ "description" ],
"type": "",
"base": "",
"caraccomp": "",
"reference": ""
},
"recettecuisine": {
"templates": [ "description" ],
"niveau": "",
"ingredients": "",
"duree": "",
"sust": 0,
"exotisme": 0,
"reference": ""
},
"oeuvre": {
"templates": [ "description" ],
"default_carac": "",
"competence": "",
"niveau": 0,
"reference": ""
},
"recettealchimique": {
"templates": [ "description" ],
"but": "",
"utilisation": "",
"enchantement": "",
"sureffet": "",
"manipulation": ""
},
"tache": {
"templates": [ "description" ],
"carac": "",
"competence": "",
"periodicite": "",
"fatigue": 1,
"difficulte": 0,
"points_de_tache": 4,
"points_de_tache_courant": 0,
"nb_jet_echec": 0,
"nb_jet_succes": 0,
"cacher_points_de_tache": false
},
"sort": {
"templates": [ "description" ],
"draconic": "",
@ -718,67 +831,13 @@
"isrituel": false,
"coutseuil": 0
},
"herbe": {
"templates": [ "description" ],
"niveau": 0,
"base": 0,
"quantite": 1,
"milieu": "",
"rarete": "",
"categorie": "",
"cout": 0
},
"ingredient": {
"templates": [ "description" ],
"niveau": 0,
"encombrement": 0,
"base": 0,
"quantite": 1,
"milieu": "",
"rarete": "",
"categorie": "",
"cout": 0
},
"tache": {
"templates": [ "description" ],
"carac": "",
"competence": "",
"periodicite": "",
"fatigue": 1,
"difficulte": 0,
"points_de_tache": 4,
"points_de_tache_courant": 0,
"nb_jet_echec": 0,
"nb_jet_succes": 0,
"cacher_points_de_tache": false
},
"livre": {
"templates": [ "description" ],
"competence": "",
"auteur": "",
"quantite": 1,
"difficulte": 0,
"points_de_tache": 0,
"encombrement": 0,
"xp": "",
"niveau_minimum": 0,
"niveau_maximum": 0,
"cout": 0
},
"potion": {
"templates": [ "description" ],
"quantite": 1,
"encombrement": 0,
"rarete": "",
"categorie": "",
"herbe": "",
"herbebrins": 0,
"herbebonus": 0,
"reposalchimique": false,
"pr": 0,
"prpermanent": false,
"prdate": 0,
"cout": 0
"sortreserve": {
"sortid" : "",
"draconic": "",
"coord": "",
"ptreve": 0,
"heurecible": "",
"echectotal": false
},
"rencontre": {
"templates": [ "description" ],
@ -852,23 +911,13 @@
"frequence": 0,
"hautrevant": false
},
"tarot": {
"casetmr": {
"templates": [ "description" ],
"concept":"",
"aspect":"",
"frequence": 1
},
"nombreastral": {
"value": 0,
"istrue": false,
"jourindex": 1,
"jourlabel": ""
},
"monnaie": {
"templates": [ "description" ],
"quantite": "",
"valeur_deniers":0,
"encombrement":0
"coord": "",
"type": "",
"label": "",
"specific": "",
"sourceid":""
},
"meditation": {
"templates": [ "description" ],
@ -882,95 +931,6 @@
"tmr": "",
"malus" : 0
},
"casetmr": {
"templates": [ "description" ],
"coord": "",
"type": "",
"label": "",
"specific": "",
"sourceid":""
},
"recettealchimique": {
"templates": [ "description" ],
"but": "",
"utilisation": "",
"enchantement": "",
"sureffet": "",
"manipulation": ""
},
"musique": {
"templates": [ "description" ],
"niveau": "",
"reference": ""
},
"danse": {
"templates": [ "description" ],
"type": "",
"agilite": false,
"apparence": false,
"niveau": "",
"reference": ""
},
"chant": {
"templates": [ "description" ],
"niveau": "",
"reference": ""
},
"jeu": {
"templates": [ "description" ],
"type": "",
"base": "",
"caraccomp": "",
"reference": ""
},
"recettecuisine": {
"templates": [ "description" ],
"niveau": "",
"ingredients": "",
"duree": "",
"sust": 0,
"exotisme": 0,
"reference": ""
},
"oeuvre": {
"templates": [ "description" ],
"default_carac": "",
"competence": "",
"niveau": 0,
"reference": ""
},
"maladie": {
"templates": [ "description" ],
"identifie": false,
"malignite": 0,
"periodicite": "",
"remedesconnus": false,
"remedes": "",
"dommages":""
},
"poison": {
"templates": [ "description" ],
"identifie": false,
"malignite": 0,
"periodicite": "",
"remedesconnus": false,
"remedes": "",
"dommages":"",
"active": false
},
"nourritureboisson": {
"templates": [ "description" ],
"sust": 0,
"boisson": false,
"desaltere": 0,
"alcoolise": false,
"force": 0,
"qualite": 0,
"exotisme": 0,
"encombrement": 0,
"quantite": 1,
"cout": 0
},
"signedraconique": {
"templates": [ "description" ],
"typesTMR": [],
@ -983,13 +943,17 @@
"part": 10
}
},
"sortreserve": {
"sortid" : "",
"draconic": "",
"coord": "",
"ptreve": 0,
"heurecible": "",
"echectotal": false
"tarot": {
"templates": [ "description" ],
"concept":"",
"aspect":"",
"frequence": 1
},
"nombreastral": {
"value": 0,
"istrue": false,
"jourindex": 1,
"jourlabel": ""
},
"extraitpoetique": {
"extrait": "",
@ -997,4 +961,3 @@
}
}
}

View File

@ -21,14 +21,14 @@
<span class="equipement-detail">{{numberFormat item.system.encTotal decimals=2}}</span>
<span class="equipement-actions item-controls">
{{#unless item.estContenu}}
{{#if (ne item.type 'conteneur')}}
{{#if (or (eq item.type 'arme') (eq item.type 'armure') )}}
<a class="item-equip" title="Equiper">{{#if item.system.equipe}}<i class="fas fa-hand-rock"></i>{{else}}<i class="far fa-hand-paper"></i>{{/if}}</a>
{{/if}}
{{/unless}}
<a class="item-edit" title="Editer"><i class="fas fa-edit"></i></a>
<a class="item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
&nbsp;
{{#if (or (eq item.type 'arme') (eq item.type 'conteneur') item.system.quantite)}}
{{#if (ne item.system.quantite 0)}}
<a class="item-vendre" title="Vendre ou donner"><i class="fas fa-comments-dollar"></i></a>
{{/if}}
<a class="item-montrer" title="Montrer"><i class="fas fa-comment"></i></a>

View File

@ -9,9 +9,9 @@
<div class="form-group">
<label for="xp">Valeur en Deniers</label>
{{#if isGM}}
<input class="attribute-value" type="text" name="system.valeur_deniers" value="{{system.valeur_deniers}}" data-dtype="Number"/>
<input class="attribute-value" type="text" name="system.cout" value="{{system.cout}}" data-dtype="Number"/>
{{else}}
<label for="xp">{{system.valeur_deniers}}</label>
<label for="xp">{{system.cout}}</label>
{{/if}}
</div>
<div class="form-group">

View File

@ -10,10 +10,6 @@
<label>Quantité </label>
<input class="attribute-value" type="text" name="system.quantite" value="{{system.quantite}}" data-dtype="Number" />
</div>
<div class="form-group">
<label for="xp">Résistance</label>
<input class="attribute-value" type="text" name="system.resistance" value="{{system.resistance}}" data-dtype="Number"/>
</div>
<div class="form-group">
<label for="xp">Qualité</label>
<input class="attribute-value" type="text" name="system.qualite" value="{{system.qualite}}" data-dtype="Number"/>