Merge pull request 'Petits fixes et petits conforts' (#543) from VincentVk/foundryvtt-reve-de-dragon:v1.5 into v1.5

Reviewed-on: public/foundryvtt-reve-de-dragon#543
This commit is contained in:
uberwald 2022-07-22 10:45:44 +02:00
commit 6d6843223b
6 changed files with 42 additions and 22 deletions

View File

@ -98,7 +98,6 @@ export class RdDActor extends Actor {
* @param {Object} options (Unused) Additional options which customize the creation workflow. * @param {Object} options (Unused) Additional options which customize the creation workflow.
* *
*/ */
static async create(actorData, options) { static async create(actorData, options) {
// Case of compendium global import // Case of compendium global import
if (actorData instanceof Array) { if (actorData instanceof Array) {
@ -135,13 +134,6 @@ export class RdDActor extends Actor {
this.encTotal = 0; this.encTotal = 0;
this.prixTotalEquipement = 0; this.prixTotalEquipement = 0;
/*
// Auto-resize token
if (this.isToken) {
let tokenSize = actorData.data.carac.taille.value/10;
this.token.update({height: tokenSize, width: tokenSize } );
}*/
// Make separate methods for each Actor type (character, npc, etc.) to keep // Make separate methods for each Actor type (character, npc, etc.) to keep
// things organized. // things organized.
if (actorData.type === 'personnage') this._prepareCharacterData(actorData); if (actorData.type === 'personnage') this._prepareCharacterData(actorData);
@ -3593,7 +3585,7 @@ export class RdDActor extends Actor {
isEntiteCauchemarAccordee(attaquant) { isEntiteCauchemarAccordee(attaquant) {
if (!this.isEntiteCauchemar()) { return true; } if (!this.isEntiteCauchemar()) { return true; }
let resonnance = Misc.templateData(this).sante.resonnance; let resonnance = Misc.templateData(this).sante.resonnance;
return (resonnance.actors.find(it => it == attaquant._id)); return (resonnance.actors.find(it => it == attaquant.id));
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -3603,11 +3595,11 @@ export class RdDActor extends Actor {
return; return;
} }
let resonnance = duplicate(Misc.templateData(this).sante.resonnance); let resonnance = duplicate(Misc.templateData(this).sante.resonnance);
if (resonnance.actors.find(it => it == attaquant._id)) { if (resonnance.actors.find(it => it == attaquant.id)) {
// déjà accordé // déjà accordé
return; return;
} }
resonnance.actors.push(attaquant._id); resonnance.actors.push(attaquant.id);
await this.update({ "data.sante.resonnance": resonnance }); await this.update({ "data.sante.resonnance": resonnance });
return; return;
} }

View File

@ -55,7 +55,7 @@ export class DialogItemAchat extends Dialog {
static prepareVenteData(buttonAcheter, vendeurId, vendeur, acheteur) { static prepareVenteData(buttonAcheter, vendeurId, vendeur, acheteur) {
const jsondata = buttonAcheter.attributes['data-jsondata']?.value; const jsondata = buttonAcheter.attributes['data-jsondata']?.value;
const prixLot = buttonAcheter.attributes['data-prixLot']?.value ?? 0; const prixLot = parseInt(buttonAcheter.attributes['data-prixLot']?.value ?? 0);
let venteData = { let venteData = {
item: JSON.parse(jsondata), item: JSON.parse(jsondata),
vendeurId: vendeurId, vendeurId: vendeurId,

View File

@ -320,7 +320,7 @@ export class RdDCombatManager extends Combat {
initOffset = 10; initOffset = 10;
caracForInit = combatant.actor.getReveActuel(); caracForInit = combatant.actor.getReveActuel();
initInfo = "Possession" initInfo = "Possession"
} else if (action.name == 'autre') { } else if (action.action == 'autre') {
initOffset = 2; initOffset = 2;
initInfo = "Autre Action" initInfo = "Autre Action"
} else if (action.action == 'haut-reve') { } else if (action.action == 'haut-reve') {

View File

@ -1,19 +1,29 @@
import { RdDActor } from "./actor.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDDice } from "./rdd-dice.js"; import { RdDDice } from "./rdd-dice.js";
const words = [ 'pore', 'pre', 'flor', 'lane', 'turlu', 'pin', 'a', 'alph', 'i', 'onse', 'iane', 'ane', 'zach', 'arri', 'ba', 'bo', 'bi', const words = ['pore', 'pre', 'flor', 'lane', 'turlu', 'pin', 'a', 'alph', 'i', 'onse', 'iane', 'ane', 'zach', 'arri', 'ba', 'bo', 'bi',
'alta', 'par', 'pir', 'zor', 'zir', 'de', 'pol', 'tran', 'no', 'la', 'al' , 'pul', 'one', 'ner', 'nur', 'mac', 'mery', 'alta', 'par', 'pir', 'zor', 'zir', 'de', 'pol', 'tran', 'no', 'la', 'al', 'pul', 'one', 'ner', 'nur', 'mac', 'mery',
'cat', 'do', 'di', 'der', 'er', 'el', 'far', 'fer', 'go', 'guer', 'hot', 'jor', 'jar', 'ji', 'kri', 'ket', 'lor', 'hur', 'cat', 'do', 'di', 'der', 'er', 'el', 'far', 'fer', 'go', 'guer', 'hot', 'jor', 'jar', 'ji', 'kri', 'ket', 'lor', 'hur',
'lar', 'lir', 'lu', 'pot', 'pro', 'pra', 'pit', 'qua', 'qui', 're', 'ral', 'sal', 'sen', 'ted', 'to', 'ta', 'lars', 'ver', 'lar', 'lir', 'lu', 'pot', 'pro', 'pra', 'pit', 'qua', 'qui', 're', 'ral', 'sal', 'sen', 'ted', 'to', 'ta', 'lars', 'ver',
'vin', 'ov', 'wal', 'ry', 'ly', '' ]; 'vin', 'ov', 'wal', 'ry', 'ly', ''];
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDNameGen { export class RdDNameGen {
static async getName( msg, params ) { static async getName(msg, params) {
let name = Misc.upperFirst( await RdDDice.rollOneOf(words) + await RdDDice.rollOneOf(words) ) const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-command-nom.html`, {
//console.log(name); nom: Misc.upperFirst(await RdDDice.rollOneOf(words) + await RdDDice.rollOneOf(words))
ChatMessage.create( { content: `Nom : ${name}`, whisper: ChatMessage.getWhisperRecipients("GM") } ); });
ChatMessage.create({ content: html, whisper: ChatMessage.getWhisperRecipients("GM") });
} }
static async onCreerActeur(event) {
const button = event.currentTarget;
await RdDActor.create({
name: button.attributes['data-nom'].value,
type: button.attributes['data-type'].value
},
{renderSheet: true});
}
} }

View File

@ -11,6 +11,7 @@ import { RdDDice } from "./rdd-dice.js";
import { RdDItem } from "./item.js"; import { RdDItem } from "./item.js";
import { Monnaie } from "./item-monnaie.js"; import { Monnaie } from "./item-monnaie.js";
import { RdDPossession } from "./rdd-possession.js"; import { RdDPossession } from "./rdd-possession.js";
import { RdDNameGen } from "./rdd-namegen.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
// This table starts at 0 -> niveau -10 // This table starts at 0 -> niveau -10
@ -704,6 +705,7 @@ export class RdDUtility {
// gestion bouton tchat Acheter // gestion bouton tchat Acheter
html.on("click", '.button-acheter', event => DialogItemAchat.onButtonAcheter(event)); html.on("click", '.button-acheter', event => DialogItemAchat.onButtonAcheter(event));
html.on("click", '.button-creer-acteur', event => RdDNameGen.onCreerActeur(event));
// Gestion du bouton payer // Gestion du bouton payer
html.on("click", '.payer-button', event => { html.on("click", '.payer-button', event => {

View File

@ -0,0 +1,16 @@
<h4>Proposition de nom: {{nom}}</h4>
<span class="chat-card-button-area">
<a class="button-creer-acteur chat-card-button"
data-nom='{{nom}}'
data-type='personnage'
>
Créer un Personnage</a>
</span>
<span class="chat-card-button-area">
<a class="button-creer-acteur chat-card-button"
data-nom='{{nom}}'
data-type='creature'>
Créer une créature</a>
</span>