Merge v1.5

This commit is contained in:
sladecraven 2022-07-22 22:53:48 +02:00
commit 5f3361ecc6
10 changed files with 117 additions and 79 deletions

View File

@ -33,7 +33,8 @@ import { RollDataAjustements } from "./rolldata-ajustements.js";
import { DialogItemAchat } from "./dialog-item-achat.js"; import { DialogItemAchat } from "./dialog-item-achat.js";
import { RdDItem } from "./item.js"; import { RdDItem } from "./item.js";
import { RdDPossession } from "./rdd-possession.js"; import { RdDPossession } from "./rdd-possession.js";
import { SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; import { ENTITE_BLURETTE, ENTITE_INCARNE, ENTITE_NONINCARNE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
/** /**
@ -98,7 +99,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) {
@ -134,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 (this.type === 'personnage') this._prepareCharacterData(this) if (this.type === 'personnage') this._prepareCharacterData(this)
@ -245,7 +238,7 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getForce() { getForce() {
if (this.isEntiteCauchemar()) { if (this.isEntite()) {
return Misc.toInt(this.system.carac.reve?.value); return Misc.toInt(this.system.carac.reve?.value);
} }
return Misc.toInt(this.system.carac.force?.value); return Misc.toInt(this.system.carac.force?.value);
@ -616,7 +609,11 @@ export class RdDActor extends Actor {
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name), whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
content: "Remise à neuf de " + this.name content: "Remise à neuf de " + this.name
}; };
if (this.isEntiteCauchemar()) { const actorData = Misc.data(this);
if (this.isEntite([ENTITE_NONINCARNE])) {
return;
}
if (this.isEntite([ENTITE_INCARNE, ENTITE_BLURETTE])) {
await this.santeIncDec("endurance", this.system.sante.endurance.max - this.system.sante.endurance.value); await this.santeIncDec("endurance", this.system.sante.endurance.max - this.system.sante.endurance.value);
} }
else { else {
@ -1620,7 +1617,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async setSonne(sonne = true) { async setSonne(sonne = true) {
if (this.isEntiteCauchemar()) { if (this.isEntite()) {
return; return;
} }
if (!game.combat && sonne) { if (!game.combat && sonne) {
@ -1632,7 +1629,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
getSConst() { getSConst() {
if (this.isEntiteCauchemar()) { if (this.isEntite()) {
return 0; return 0;
} }
return RdDCarac.calculSConst(this.system.carac.constitution.value) return RdDCarac.calculSConst(this.system.carac.constitution.value)
@ -1747,7 +1744,7 @@ export class RdDActor extends Actor {
result.newValue = Math.max(minValue, Math.min(compteur.value + inc, compteur.max)); result.newValue = Math.max(minValue, Math.min(compteur.value + inc, compteur.max));
//console.log("New value ", inc, minValue, result.newValue); //console.log("New value ", inc, minValue, result.newValue);
let fatigue = 0; let fatigue = 0;
if (name == "endurance" && !this.isEntiteCauchemar()) { if (name == "endurance" && !this.isEntite()) {
if (result.newValue == 0 && inc < 0 && !isCritique) { // perte endurance et endurance devient 0 (sauf critique) -> -1 vie if (result.newValue == 0 && inc < 0 && !isCritique) { // perte endurance et endurance devient 0 (sauf critique) -> -1 vie
sante.vie.value--; sante.vie.value--;
result.perteVie = true; result.perteVie = true;
@ -1784,7 +1781,7 @@ export class RdDActor extends Actor {
} }
isDead() { isDead() {
return !this.isEntiteCauchemar() && this.system.sante.vie.value < -this.getSConst() return !this.isEntite() && this.system.sante.vie.value < -this.getSConst()
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -3325,7 +3322,7 @@ export class RdDActor extends Actor {
let encaissement = await this.jetEncaissement(rollData); let encaissement = await this.jetEncaissement(rollData);
this.ajouterBlessure(encaissement); // Will upate the result table this.ajouterBlessure(encaissement); // Will upate the result table
const perteVie = this.isEntiteCauchemar() const perteVie = this.isEntite()
? { newValue: 0 } ? { newValue: 0 }
: await this.santeIncDec("vie", - encaissement.vie); : await this.santeIncDec("vie", - encaissement.vie);
const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance, encaissement.critiques > 0); const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance, encaissement.critiques > 0);
@ -3339,7 +3336,7 @@ export class RdDActor extends Actor {
sonne: perteEndurance.sonne, sonne: perteEndurance.sonne,
jetEndurance: perteEndurance.jetEndurance, jetEndurance: perteEndurance.jetEndurance,
endurance: santeOrig.endurance.value - perteEndurance.newValue, endurance: santeOrig.endurance.value - perteEndurance.newValue,
vie: this.isEntiteCauchemar() ? 0 : (santeOrig.vie.value - perteVie.newValue), vie: this.isEntite() ? 0 : (santeOrig.vie.value - perteVie.newValue),
show: defenderRoll?.show ?? {} show: defenderRoll?.show ?? {}
}); });
@ -3528,8 +3525,8 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async accorder(entite, when = 'avant-encaissement') { async accorder(entite, when = 'avant-encaissement') {
if (when != game.settings.get(SYSTEM_RDD, "accorder-entite-cauchemar") if (when != game.settings.get(SYSTEM_RDD, "accorder-entite-cauchemar")
|| !entite.isEntiteCauchemar() || !entite.isEntite([ENTITE_INCARNE])
|| entite.isEntiteCauchemarAccordee(this)) { || entite.isEntiteAccordee(this)) {
return true; return true;
} }
const tplData = this.system; const tplData = this.system;
@ -3553,29 +3550,29 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
isEntiteCauchemar() { isEntite(typeentite = []) {
return this.type == 'entite'; return this.type == 'entite' && (typeentite.length == 0 || typeentite.includes(this.system.typeentite));
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
isEntiteCauchemarAccordee(attaquant) { isEntiteAccordee(attaquant) {
if (!this.isEntiteCauchemar()) { return true; } if (!this.isEntite([ENTITE_INCARNE])) { return true; }
let resonnance = this.system.sante.resonnance; let resonnance = this.system.sante.resonnance;
return (resonnance.actors.find(it => it == attaquant._id)); return (resonnance.actors.find(it => it == attaquant.id));
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async setEntiteReveAccordee(attaquant) { async setEntiteReveAccordee(attaquant) {
if (!this.isEntiteCauchemar()) { if (!this.isEntite([ENTITE_INCARNE])) {
ui.notifications.error("Impossible de s'accorder à " + this.name + ": ce n'est pas une entite de cauchemer/rêve"); ui.notifications.error("Impossible de s'accorder à " + this.name + ": ce n'est pas une entite de cauchemer/rêve");
return; return;
} }
let resonnance = duplicate(this.system.sante.resonnance); let resonnance = duplicate(this.system.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({ "system.sante.resonnance": resonnance }); await this.update({ "system.sante.resonnance": resonnance });
return; return;
} }
@ -3671,7 +3668,8 @@ export class RdDActor extends Actor {
RdDActor.remoteActorCall({ RdDActor.remoteActorCall({
userId: Misc.connectedGMOrUser(), userId: Misc.connectedGMOrUser(),
actorId: this.id, actorId: this.id,
method: 'ajouterDeniers', args: [gain, fromActorId] }); method: 'ajouterDeniers', args: [gain, fromActorId]
});
} }
else { else {
const fromActor = game.actors.get(fromActorId) const fromActor = game.actors.get(fromActorId)
@ -3706,7 +3704,8 @@ export class RdDActor extends Actor {
RdDActor.remoteActorCall({ RdDActor.remoteActorCall({
actorId: achat.vendeurId ?? achat.acheteurId, actorId: achat.vendeurId ?? achat.acheteurId,
method: 'achatVente', method: 'achatVente',
args: [achat] }, args: [achat]
},
); );
return; return;
} }
@ -4125,7 +4124,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async setStatusEffect(label, status, updates = {}) { async setStatusEffect(label, status, updates = {}) {
if (this.isEntiteCauchemar() || this.type == 'vehicule') { if (this.isEntite() || this.type == 'vehicule') {
return; return;
} }
console.log("setStatusEffect", label, status, updates) console.log("setStatusEffect", label, status, updates)

View File

@ -3,3 +3,7 @@ export const SYSTEM_SOCKET_ID = 'system.foundryvtt-reve-de-dragon';
export const HIDE_DICE = 'hide'; export const HIDE_DICE = 'hide';
export const SHOW_DICE = 'show'; export const SHOW_DICE = 'show';
export const ENTITE_INCARNE = 'incarne';
export const ENTITE_NONINCARNE = 'nonincarne';
export const ENTITE_BLURETTE = 'blurette';

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

@ -1,5 +1,5 @@
import { ChatUtility } from "./chat-utility.js"; import { ChatUtility } from "./chat-utility.js";
import { HIDE_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; import { ENTITE_INCARNE, ENTITE_NONINCARNE, HIDE_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { RdDItemArme } from "./item-arme.js"; import { RdDItemArme } from "./item-arme.js";
import { RdDItemCompetence } from "./item-competence.js"; import { RdDItemCompetence } from "./item-competence.js";
@ -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') {
@ -455,9 +455,9 @@ export class RdDCombat {
: "Vous devez choisir une cible à attaquer!"); : "Vous devez choisir une cible à attaquer!");
} }
else { else {
const defender = target?.actor const defender = target?.actor;
const defenderTokenId = target?.id const defenderTokenId = target?.id;
if ( defender.type == 'entite' && defender.system.definition.typeentite == 'nonincarne') { if ( defender.type == 'entite' && defender.system.definition.typeentite == ENTITE_NONINCARNE) {
ui.notifications.warn("Vous ne pouvez pas cibler une entité non incarnée !!!!"); ui.notifications.warn("Vous ne pouvez pas cibler une entité non incarnée !!!!");
} else { } else {
return this.create(attacker, defender, defenderTokenId, target) return this.create(attacker, defender, defenderTokenId, target)
@ -799,7 +799,7 @@ export class RdDCombat {
async _onAttaqueNormale(attackerRoll) { async _onAttaqueNormale(attackerRoll) {
console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll); console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll);
attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker.getBonusDegat(), this.defender.isEntiteCauchemar()); attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker.getBonusDegat(), this.defender.isEntite());
let defenderRoll = { attackerRoll: attackerRoll, passeArme: attackerRoll.passeArme, show: {} } let defenderRoll = { attackerRoll: attackerRoll, passeArme: attackerRoll.passeArme, show: {} }
attackerRoll.show = { attackerRoll.show = {
cible: this.target ? this.defender.system.name : 'la cible', cible: this.target ? this.defender.system.name : 'la cible',
@ -1248,8 +1248,8 @@ export class RdDCombat {
async accorderEntite(when = 'avant-encaissement') { async accorderEntite(when = 'avant-encaissement') {
if (when != game.settings.get(SYSTEM_RDD, "accorder-entite-cauchemar") if (when != game.settings.get(SYSTEM_RDD, "accorder-entite-cauchemar")
|| this.defender == undefined || this.defender == undefined
|| !this.defender.isEntiteCauchemar() || !this.defender.isEntite([ENTITE_INCARNE])
|| this.defender.isEntiteCauchemarAccordee(this.attacker)) { || this.defender.isEntiteAccordee(this.attacker)) {
return true; return true;
} }

View File

@ -1,3 +1,4 @@
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";
@ -11,9 +12,18 @@ const words = [ 'pore', 'pre', 'flor', 'lane', 'turlu', 'pin', 'a', 'alph', 'i',
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

@ -1,3 +1,5 @@
import { ENTITE_BLURETTE, ENTITE_INCARNE, ENTITE_NONINCARNE } from "./constants";
/** /**
* Extend the base Dialog entity by defining a custom window to perform roll. * Extend the base Dialog entity by defining a custom window to perform roll.
* @extends {Dialog} * @extends {Dialog}
@ -7,15 +9,19 @@ export class RdDEncaisser extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
constructor(html, actor) { constructor(html, actor) {
// Common conf // Common conf
const buttonsCreatures = { let buttons = {};
if (!actor.isEntite()){
buttons = {
"mortel": { label: "Mortel", callback: html => this.performEncaisser("mortel") }, "mortel": { label: "Mortel", callback: html => this.performEncaisser("mortel") },
"non-mortel": { label: "Non-mortel", callback: html => this.performEncaisser("non-mortel") }, "non-mortel": { label: "Non-mortel", callback: html => this.performEncaisser("non-mortel") },
"sonne": { label: "Sonné", callback: html => this.actor.setSonne() }, "sonne": { label: "Sonné", callback: html => this.actor.setSonne() },
}; };
const buttonsEntitesCauchemar = { }
else if (actor.isEntite([ENTITE_BLURETTE, ENTITE_INCARNE])){
buttons = {
"cauchemar": { label: "cauchemar", callback: html => this.performEncaisser("cauchemar") } "cauchemar": { label: "cauchemar", callback: html => this.performEncaisser("cauchemar") }
}; }
const buttons = actor.isEntiteCauchemar() ? buttonsEntitesCauchemar : buttonsCreatures; }
let dialogConf = { let dialogConf = {
title: "Jet d'Encaissement", title: "Jet d'Encaissement",

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
@ -703,6 +704,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

@ -32,7 +32,7 @@
"url": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/", "url": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/",
"license": "LICENSE.txt", "license": "LICENSE.txt",
"flags": {}, "flags": {},
"version": "10.0.5", "version": "10.0.6",
"scripts": [], "scripts": [],
"esmodules": [ "esmodules": [
"module/rdd-main.js" "module/rdd-main.js"
@ -500,7 +500,7 @@
"relationships": {}, "relationships": {},
"socket": true, "socket": true,
"manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json",
"download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.0.5.zip", "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.0.6.zip",
"protected": false, "protected": false,
"gridDistance": 1, "gridDistance": 1,
"gridUnits": "m", "gridUnits": "m",

View File

@ -65,6 +65,7 @@
{{#select data.definition.typeentite}} {{#select data.definition.typeentite}}
<option value="incarne">Incarnée</option> <option value="incarne">Incarnée</option>
<option value="nonincarne">Non Incarnée</option> <option value="nonincarne">Non Incarnée</option>
<option value="blurette">Blurete</option>
{{/select}} {{/select}}
</select> </select>
</li> </li>

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>