Merge branch 'v1.4-fix-achat' into 'v1.4'
fix achat quelle que soit l'origine de l'objet See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!246
This commit is contained in:
commit
270c082032
@ -3454,13 +3454,11 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (acheteur) {
|
if (acheteur) {
|
||||||
// TODO: achat depuis un compendium
|
|
||||||
const itemData = Misc.data(vendeur?.getObjet(itemId) ?? game.items.get(itemId));
|
|
||||||
const achat = {
|
const achat = {
|
||||||
type: itemData.type,
|
type: venteData.item.type,
|
||||||
img: itemData.img,
|
img: venteData.item.img,
|
||||||
name: itemData.name,
|
name: venteData.item.name,
|
||||||
data: itemData.data
|
data: venteData.item.data
|
||||||
}
|
}
|
||||||
achat.data.quantite = venteData.quantiteTotal;
|
achat.data.quantite = venteData.quantiteTotal;
|
||||||
await acheteur.createEmbeddedDocuments("Item", [achat]);
|
await acheteur.createEmbeddedDocuments("Item", [achat]);
|
||||||
|
@ -73,7 +73,7 @@ export class RdDCalendrier extends Application {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
_loadListNombreAstral() {
|
_loadListNombreAstral() {
|
||||||
const listeNombreAstraux = game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral");
|
const listeNombreAstraux = game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral");
|
||||||
return Object.values(listeNombreAstraux);
|
return listeNombreAstraux ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -130,7 +130,7 @@ export class RdDCalendrier extends Application {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async ajouterNombreAstral(index) {
|
async ajouterNombreAstral(index) {
|
||||||
const nombreAstral = await RdDDice.rollTotal("1dh");
|
const nombreAstral = await RdDDice.rollTotal("1dh", { showDice: true, rollMode: "selfroll" });
|
||||||
return {
|
return {
|
||||||
nombreAstral: nombreAstral,
|
nombreAstral: nombreAstral,
|
||||||
valeursFausses: [],
|
valeursFausses: [],
|
||||||
@ -163,22 +163,26 @@ export class RdDCalendrier extends Application {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rebuildListeNombreAstral() {
|
async rebuildListeNombreAstral() {
|
||||||
|
if (game.user.isGM) {
|
||||||
let jourCourant = this.getCurrentDayIndex();
|
let jourCourant = this.getCurrentDayIndex();
|
||||||
let jourFin = jourCourant + 12;
|
let jourFin = jourCourant + 12;
|
||||||
|
|
||||||
let newList = [];
|
let newList = [];
|
||||||
for (let i=0; i<12; i++) {
|
|
||||||
newList.push(await this.ajouterNombreAstral(jourCourant + i));
|
|
||||||
}
|
|
||||||
if (this.listeNombreAstral) {
|
|
||||||
for (const na of this.listeNombreAstral) {
|
for (const na of this.listeNombreAstral) {
|
||||||
if (na && na.index >= jourCourant && na.index < jourFin) {
|
let index = na?.index;
|
||||||
newList[na.index - jourCourant] = na;
|
if (index && index >= jourCourant && index < jourFin) {
|
||||||
|
newList[index - jourCourant] = na;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (let i = 0; i < 12; i++) {
|
||||||
|
if (newList[i] == undefined) {
|
||||||
|
newList[i] = await this.ajouterNombreAstral(jourCourant + i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.listeNombreAstral = newList;
|
this.listeNombreAstral = newList;
|
||||||
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
|
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async onCalendarButton(ev) {
|
async onCalendarButton(ev) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
@ -233,7 +237,7 @@ export class RdDCalendrier extends Application {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async positionnerHeure(indexHeure) {
|
async positionnerHeure(indexHeure) {
|
||||||
if (indexHeure <= this.calendrier.heureRdD){
|
if (indexHeure <= this.calendrier.heureRdD) {
|
||||||
await this.incrementerJour();
|
await this.incrementerJour();
|
||||||
}
|
}
|
||||||
this.calendrier.heureRdD = indexHeure;
|
this.calendrier.heureRdD = indexHeure;
|
||||||
@ -288,7 +292,7 @@ export class RdDCalendrier extends Application {
|
|||||||
request.isValid = true;
|
request.isValid = true;
|
||||||
if (!request.rolled.isSuccess) {
|
if (!request.rolled.isSuccess) {
|
||||||
request.isValid = false;
|
request.isValid = false;
|
||||||
nbAstral = await RdDDice.rollTotal("1dhr" + nbAstral);
|
nbAstral = await RdDDice.rollTotal("1dhr" + nbAstral, { showDice: true, rollMode: "selfroll" });
|
||||||
// Mise à jour des nombres astraux du joueur
|
// Mise à jour des nombres astraux du joueur
|
||||||
let astralData = this.listeNombreAstral.find((nombreAstral, i) => nombreAstral.index == request.date);
|
let astralData = this.listeNombreAstral.find((nombreAstral, i) => nombreAstral.index == request.date);
|
||||||
astralData.valeursFausses.push({ actorId: request.id, nombreAstral: nbAstral });
|
astralData.valeursFausses.push({ actorId: request.id, nombreAstral: nbAstral });
|
||||||
|
@ -124,13 +124,13 @@ export class RdDDice {
|
|||||||
CONFIG.Dice.terms[DeHeure.DENOMINATION] = DeHeure;
|
CONFIG.Dice.terms[DeHeure.DENOMINATION] = DeHeure;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async roll(formula, options = { showDice: false }) {
|
static async roll(formula, options = { showDice: false, rollMode: undefined}) {
|
||||||
const roll = new Roll(formula);
|
const roll = new Roll(formula);
|
||||||
await roll.evaluate({ async: true });
|
await roll.evaluate({ async: true });
|
||||||
if (options.showDice) {
|
if (options.showDice) {
|
||||||
roll.showDice = options.showDice;
|
roll.showDice = options.showDice;
|
||||||
}
|
}
|
||||||
await RdDDice.show(roll, game.settings.get("core", "rollMode"));
|
await RdDDice.show(roll, options.rollMode ?? game.settings.get("core", "rollMode"));
|
||||||
return roll;
|
return roll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user