#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.
|
// things organized.
|
||||||
if (actorData.type === 'personnage') this._prepareCharacterData(actorData);
|
if (actorData.type === 'personnage') this._prepareCharacterData(actorData);
|
||||||
if (actorData.type === 'creature') this.computeEtatGeneral(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);
|
RdDUtility.computeCarac(actorData.data);
|
||||||
this.computeEncombrementTotalEtMalusArmure();
|
this.computeEncombrementTotalEtMalusArmure();
|
||||||
this.computeEtatGeneral();
|
this.computeEtatGeneral();
|
||||||
|
this.checkMonnaiePresence();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async ajouterMonnaie( items ) {
|
checkMonnaiePresence( ) { // Ajout opportuniste si les pièces n'existent pas.
|
||||||
let etain = { name: "Etain (1 denier)", type: 'monnaie', _id: randomID(),
|
let piece = this.data.items.find( item => item.type =='monnaie' && Number(item.data.valeur_deniers) == 1);
|
||||||
data: {
|
if (!piece) {
|
||||||
quantite: 0,
|
let piece = RdDUtility.createMonnaie("Etain (1 denier)", 1);
|
||||||
valeur_deniers: 1,
|
this.createOwnedItem( piece );
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
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() {
|
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) {
|
static afficherDemandePayer(som1, som2) {
|
||||||
som1 = (som1) ? som1.toLowerCase() : "0d";
|
som1 = (som1) ? som1.toLowerCase() : "0d";
|
||||||
|
Loading…
Reference in New Issue
Block a user