#88 Ajout auto ds pièces si manquantes
This commit is contained in:
parent
2355406546
commit
d5c4b69e1d
@ -91,7 +91,6 @@ export class RdDActor extends Actor {
|
||||
// things organized.
|
||||
if (actorData.type === 'personnage') this._prepareCharacterData(actorData);
|
||||
if (actorData.type === 'creature') this.computeEtatGeneral(actorData);
|
||||
if (actorData.type === 'humanoide') this.computeEtatGeneral(actorData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -103,38 +102,47 @@ export class RdDActor extends Actor {
|
||||
RdDUtility.computeCarac(actorData.data);
|
||||
this.computeEncombrementTotalEtMalusArmure();
|
||||
this.computeEtatGeneral();
|
||||
this.checkMonnaiePresence();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async ajouterMonnaie( items ) {
|
||||
let etain = { name: "Etain (1 denier)", type: 'monnaie', _id: randomID(),
|
||||
data: {
|
||||
quantite: 0,
|
||||
valeur_deniers: 1,
|
||||
encombrement: 0.01,
|
||||
description: ""
|
||||
}
|
||||
}
|
||||
items.push(etain);
|
||||
|
||||
let bronze = duplicate(etain);
|
||||
bronze.id = randomID();
|
||||
bronze.name = "Bronze (10 deniers)";
|
||||
bronze.data.valeur_deniers = 10;
|
||||
items.push(bronze);
|
||||
|
||||
let argent = duplicate(etain);
|
||||
argent.id = randomID();
|
||||
argent.name = "Argent (1 sol)";
|
||||
argent.data.valeur_deniers = 100;
|
||||
items.push(argent);
|
||||
|
||||
let or = duplicate(argent);
|
||||
or.id = randomID();
|
||||
or.name = "Or (10 sols)";
|
||||
or.data.valeur_deniers = 1000;
|
||||
items.push(or);
|
||||
/* -------------------------------------------- */
|
||||
checkMonnaiePresence( ) { // Ajout opportuniste si les pièces n'existent pas.
|
||||
let piece = this.data.items.find( item => item.type =='monnaie' && Number(item.data.valeur_deniers) == 1);
|
||||
if (!piece) {
|
||||
let piece = RdDUtility.createMonnaie("Etain (1 denier)", 1);
|
||||
this.createOwnedItem( piece );
|
||||
}
|
||||
piece = this.data.items.find( item => item.type =='monnaie' && Number(item.data.valeur_deniers) == 10);
|
||||
if (!piece) {
|
||||
let piece = RdDUtility.createMonnaie("Bronze (10 deniers)", 10);
|
||||
this.createOwnedItem( piece );
|
||||
}
|
||||
piece = this.data.items.find( item => item.type =='monnaie' && Number(item.data.valeur_deniers) == 100);
|
||||
if (!piece) {
|
||||
let piece = RdDUtility.createMonnaie("Argent (1 sol)", 100);
|
||||
this.createOwnedItem( piece );
|
||||
}
|
||||
piece = this.data.items.find( item => item.type =='monnaie' && Number(item.data.valeur_deniers) == 1000);
|
||||
if (!piece) {
|
||||
let piece = RdDUtility.createMonnaie("Or (10 sols)", 1000);
|
||||
this.createOwnedItem( piece );
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async ajouterMonnaie( items ) { // Creation auto à la création du personnage
|
||||
let etain = RdDUtility.createMonnaie("Etain (1 denier)", 1);
|
||||
items.push(etain);
|
||||
|
||||
let bronze = RdDUtility.createMonnaie("Bronze (10 deniers)", 10);
|
||||
items.push(bronze);
|
||||
|
||||
let argent = RdDUtility.createMonnaie("Argent (1 sol)", 100);
|
||||
items.push(argent);
|
||||
|
||||
let or = RdDUtility.createMonnaie("Or (10 sols)", 1000);
|
||||
items.push(or);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
isCreature() {
|
||||
|
@ -891,6 +891,19 @@ export class RdDUtility {
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static createMonnaie( name, valeur_deniers, enc = 0.01) {
|
||||
let piece = { name: name, type: 'monnaie', _id: randomID(),
|
||||
data: {
|
||||
quantite: 0,
|
||||
valeur_deniers: valeur_deniers,
|
||||
encombrement: enc,
|
||||
description: ""
|
||||
}
|
||||
}
|
||||
return piece;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static afficherDemandePayer(som1, som2) {
|
||||
som1 = (som1) ? som1.toLowerCase() : "0d";
|
||||
|
Loading…
Reference in New Issue
Block a user