v11.1.0 - Les choix de Werther de Zloth #676

Merged
uberwald merged 15 commits from VincentVk/foundryvtt-reve-de-dragon:v11 into v11 2023-11-04 23:57:27 +01:00
8 changed files with 98 additions and 93 deletions
Showing only changes of commit ece9ab6f64 - Show all commits

View File

@ -2,6 +2,8 @@
## v11.0.29 - Les choix de Krachtoum ## v11.0.29 - Les choix de Krachtoum
- Les options suivantes peuvent être désactivées: - Les options suivantes peuvent être désactivées:
- La transformation de stress à Château Dormant - La transformation de stress à Château Dormant
- Séparation des véhicules dans leur propre acteur
## v11.0.28 - les fractures de Khrachtchoum ## v11.0.28 - les fractures de Khrachtchoum
- La gravité de la blessure est affichée dans le résumé de l'encaissement - La gravité de la blessure est affichée dans le résumé de l'encaissement
- Lors du changement d'acteur pendant le round - Lors du changement d'acteur pendant le round

View File

@ -67,12 +67,10 @@ export class RdDActor extends RdDBaseActor {
// TODO: separate derived/base data preparation // TODO: separate derived/base data preparation
// TODO: split by actor class // TODO: split by actor class
// 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.isPersonnage()) this._prepareCharacterData(this) if (this.isPersonnage()) this._prepareCharacterData(this)
if (this.isCreatureEntite()) this._prepareCreatureData(this) if (this.isCreatureEntite()) this._prepareCreatureData(this)
if (this.isVehicule()) this._prepareVehiculeData(this) this.recompute();
this.computeEtatGeneral();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -80,11 +78,6 @@ export class RdDActor extends RdDBaseActor {
this.computeEncTotal(); this.computeEncTotal();
} }
/* -------------------------------------------- */
_prepareVehiculeData(actorData) {
this.computeEncTotal();
}
/* -------------------------------------------- */ /* -------------------------------------------- */
/** /**
* Prepare Character type specific data * Prepare Character type specific data
@ -114,9 +107,6 @@ export class RdDActor extends RdDBaseActor {
if (this.isEntite()) { if (this.isEntite()) {
return item.type == 'competencecreature'; return item.type == 'competencecreature';
} }
if (this.isVehicule()) {
return item.isInventaire();
}
if (this.isPersonnage()) { if (this.isPersonnage()) {
switch (item.type) { switch (item.type) {
case 'competencecreature': case 'tarot': case 'service': case 'competencecreature': case 'tarot': case 'service':
@ -153,7 +143,6 @@ export class RdDActor extends RdDBaseActor {
case 'creature': case 'creature':
case 'entite': case 'entite':
return Misc.toInt(this.system.carac.reve?.value) return Misc.toInt(this.system.carac.reve?.value)
case 'vehicule':
default: default:
return 0; return 0;
} }
@ -709,11 +698,11 @@ export class RdDActor extends RdDBaseActor {
jetsReve.push(-1); jetsReve.push(-1);
return 'eveil'; return 'eveil';
} }
else { else {
await this.reveActuelIncDec(reve); await this.reveActuelIncDec(reve);
jetsReve.push(reve); jetsReve.push(reve);
}
} }
}
return 'dort'; return 'dort';
} }
@ -1125,7 +1114,7 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */ /* -------------------------------------------- */
computeMalusSurEncombrement() { computeMalusSurEncombrement() {
switch (this.type) { switch (this.type) {
case 'entite': case 'vehicule': case 'entite':
return 0; return 0;
} }
return Math.min(0, Math.floor(this.getEncombrementMax() - this.encTotal)); return Math.min(0, Math.floor(this.getEncombrementMax() - this.encTotal));
@ -1138,8 +1127,6 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */ /* -------------------------------------------- */
getEncombrementMax() { getEncombrementMax() {
switch (this.type) { switch (this.type) {
case 'vehicule':
return this.system.capacite_encombrement;
case 'entite': case 'entite':
return 0; return 0;
default: default:
@ -1184,29 +1171,40 @@ export class RdDActor extends RdDBaseActor {
return resume; return resume;
} }
recompute() {
this.computeEtatGeneral();
}
/* -------------------------------------------- */ /* -------------------------------------------- */
computeEtatGeneral() { recompute() {
// Pas d'état général pour les entités forçage à 0
if (this.type == 'vehicule') {
return
}
if (this.type == 'entite') { if (this.type == 'entite') {
// Pas d'état général pour les entités forçage à 0
this.system.compteurs.etat.value = 0; this.system.compteurs.etat.value = 0;
return return
} }
// Pour les autres this.system.compteurs.etat.value = this.$malusVie() + this.$malusFatigue() + this.$malusEthylisme();
let state = Math.min(this.system.sante.vie.value - this.system.sante.vie.max, 0); }
if (ReglesOptionnelles.isUsing("appliquer-fatigue") && this.system.sante.fatigue) {
state += RdDUtility.currentFatigueMalus(this.system.sante.fatigue.value, this.system.sante.endurance.max);
}
// Ajout de l'éthylisme
state += Math.min(0, (this.system.compteurs.ethylisme?.value ?? 0));
this.system.compteurs.etat.value = state; $malusVie() {
return Math.min(this.system.sante.vie.value - this.system.sante.vie.max, 0);
}
$malusEthylisme() {
return Math.min(0, (this.system.compteurs.ethylisme?.value ?? 0));
}
/* -------------------------------------------- */
$malusFatigue() {
if (ReglesOptionnelles.isUsing("appliquer-fatigue") && this.system.sante.fatigue) {
const max = Math.max(1, Math.min(this.system.sante.endurance.max, 60));
let fatigueTab = RdDUtility.getSegmentsFatigue(max);
let reste = Math.min(max * 2, Math.max(0, this.system.sante.fatigue.value));
for (let idx = 0; idx < fatigueTab.length; idx++) {
reste -= fatigueTab[idx];
if (reste <= 0) {
return fatigueMalus[idx];
}
}
return -7; // This is the max !
}
return 0;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -1579,17 +1577,6 @@ export class RdDActor extends RdDBaseActor {
return result; return result;
} }
async vehicleIncDec(name, inc) {
if (!this.isVehicule() || !['resistance', 'structure'].includes(name)) {
return
}
const value = this.system.etat[name].value;
const max = this.system.etat[name].max;
const newValue = value + inc;
if (0 <= newValue && newValue <= max) {
await this.update({ [`system.etat.${name}.value`]: newValue })
}
}
isDead() { isDead() {
return !this.isEntite() && this.system.sante.vie.value < -this.getSConst() return !this.isEntite() && this.system.sante.vie.value < -this.getSConst()
@ -3772,7 +3759,7 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async setEffect(statusId, status) { async setEffect(statusId, status) {
if (this.isEntite() || this.isVehicule()) { if (this.isEntite()) {
return; return;
} }
console.log("setEffect", statusId, status) console.log("setEffect", statusId, status)

View File

@ -145,8 +145,11 @@ export class RdDBaseActor extends Actor {
} }
getMonnaie(id) { return this.findItemLike(id, 'monnaie'); } getMonnaie(id) { return this.findItemLike(id, 'monnaie'); }
getReveActuel() { return 0 }
computeMalusSurEncombrement() { return 0 }
getEncombrementMax() { return 0 }
recompute() { } recompute() { }
async setEffect(statusId, status) { }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -388,14 +391,6 @@ export class RdDBaseActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
computeMalusSurEncombrement() {
return 0;
}
getEncombrementMax() {
return 0;
}
async computeEncTotal() { async computeEncTotal() {
if (!this.pack) { if (!this.pack) {
this.encTotal = this.items.map(it => it.getEncTotal()).reduce(Misc.sum(), 0); this.encTotal = this.items.map(it => it.getEncTotal()).reduce(Misc.sum(), 0);

View File

@ -15,10 +15,7 @@ export class RdDCommerce extends RdDBaseActor {
} }
canReceive(item) { canReceive(item) {
if (item.isInventaire('all')) { return item.isInventaire('all');
return true;
}
return super.canReceive(item);
} }
getQuantiteDisponible(item) { getQuantiteDisponible(item) {

View File

@ -1,8 +1,8 @@
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "../rdd-utility.js";
import { RdDActorSheet } from "./actor-sheet.js"; import { RdDBaseActorSheet } from "./base-actor-sheet.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDActorVehiculeSheet extends RdDActorSheet { export class RdDActorVehiculeSheet extends RdDBaseActorSheet {
/** @override */ /** @override */
static get defaultOptions() { static get defaultOptions() {
@ -18,6 +18,22 @@ export class RdDActorVehiculeSheet extends RdDActorSheet {
}); });
} }
/* -------------------------------------------- */
async getData() {
let formData = await super.getData();
mergeObject(formData,
{
editable: this.isEditable,
cssClass: this.isEditable ? "editable" : "locked",
effects: this.actor.effects.map(e => foundry.utils.deepClone(e)),
limited: this.actor.limited,
owner: this.actor.isOwner,
});
this.timerRecherche = undefined;
return formData;
}
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
if (!this.options.editable) return; if (!this.options.editable) return;

28
module/actor/vehicule.js Normal file
View File

@ -0,0 +1,28 @@
import { RdDBaseActor } from "./base-actor.js";
export class RdDVehicule extends RdDBaseActor {
static get defaultIcon() {
return "systems/foundryvtt-reve-de-dragon/icons/vehicules/charette.webp";
}
isVehicule() { return true }
canReceive(item) {
return item.isInventaire();
}
getEncombrementMax() {
return this.system.capacite_encombrement;
}
async vehicleIncDec(name, inc) {
if (!['resistance', 'structure'].includes(name)) {
return
}
const newValue = this.system.etat[name].value + inc;
if (0 <= newValue && newValue <= this.system.etat[name].max) {
await this.update({ [`system.etat.${name}.value`]: newValue })
}
}
}

View File

@ -29,11 +29,12 @@ import { Environnement } from "./environnement.js";
import { RdDActor } from "./actor.js"; import { RdDActor } from "./actor.js";
import { RdDBaseActor } from "./actor/base-actor.js"; import { RdDBaseActor } from "./actor/base-actor.js";
import { RdDCommerce } from "./actor/commerce.js"; import { RdDCommerce } from "./actor/commerce.js";
import { RdDVehicule } from "./actor/vehicule.js";
import { RdDActorSheet } from "./actor-sheet.js"; import { RdDActorSheet } from "./actor-sheet.js";
import { RdDCommerceSheet } from "./actor/commerce-sheet.js"; import { RdDCommerceSheet } from "./actor/commerce-sheet.js";
import { RdDActorCreatureSheet } from "./actor-creature-sheet.js"; import { RdDActorCreatureSheet } from "./actor-creature-sheet.js";
import { RdDActorVehiculeSheet } from "./actor-vehicule-sheet.js";
import { RdDActorEntiteSheet } from "./actor-entite-sheet.js"; import { RdDActorEntiteSheet } from "./actor-entite-sheet.js";
import { RdDActorVehiculeSheet } from "./actor/vehicule-sheet.js";
import { RdDItem } from "./item.js"; import { RdDItem } from "./item.js";
import { RdDItemBlessure } from "./item/blessure.js"; import { RdDItemBlessure } from "./item/blessure.js";
@ -94,7 +95,7 @@ export class SystemReveDeDragon {
creature: RdDActor, creature: RdDActor,
entite: RdDActor, entite: RdDActor,
personnage: RdDActor, personnage: RdDActor,
vehicule: RdDActor, vehicule: RdDVehicule,
} }
} }

View File

@ -28,7 +28,7 @@ const ajustementsEncaissement = Misc.intArray(-10, 26);
/* -------------------------------------------- */ /* -------------------------------------------- */
function _buildAllSegmentsFatigue(max) { function _buildAllSegmentsFatigue(max) {
const cycle = [5, 2, 4, 1, 3, 0]; const cycle = [5, 2, 4, 1, 3, 0];
let fatigue = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]; const fatigue = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
for (let i = 0; i <= max; i++) { for (let i = 0; i <= max; i++) {
const ligneFatigue = duplicate(fatigue[i]); const ligneFatigue = duplicate(fatigue[i]);
const caseIncrementee = cycle[i % 6]; const caseIncrementee = cycle[i % 6];
@ -55,7 +55,7 @@ function _cumulSegmentsFatigue(matrix) {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
const fatigueMatrix = _buildAllSegmentsFatigue(60); export const fatigueMatrix = _buildAllSegmentsFatigue(60);
const cumulFatigueMatrix = _cumulSegmentsFatigue(fatigueMatrix); const cumulFatigueMatrix = _cumulSegmentsFatigue(fatigueMatrix);
const fatigueMalus = [0, 0, 0, -1, -1, -1, -2, -3, -4, -5, -6, -7]; // Provides the malus for each segment of fatigue const fatigueMalus = [0, 0, 0, -1, -1, -1, -2, -3, -4, -5, -6, -7]; // Provides the malus for each segment of fatigue
@ -460,10 +460,8 @@ export class RdDUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static getSegmentsFatigue(maxEnd) { static getSegmentsFatigue(maxEndurance) {
maxEnd = Math.max(maxEnd, 1); return fatigueMatrix[Math.min(Math.max(maxEndurance, 1), fatigueMatrix.length)];
maxEnd = Math.min(maxEnd, fatigueMatrix.length);
return fatigueMatrix[maxEnd];
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -491,7 +489,7 @@ export class RdDUtility {
// Build the nice (?) html table used to manage fatigue. // Build the nice (?) html table used to manage fatigue.
// max should be the endurance max value // max should be the endurance max value
static makeHTMLfatigueMatrix(fatigue, maxEndurance) { static makeHTMLfatigueMatrix(fatigue, maxEndurance) {
let segments = this.getSegmentsFatigue(maxEndurance); const segments = this.getSegmentsFatigue(maxEndurance);
return this.makeHTMLfatigueMatrixForSegment(fatigue, segments); return this.makeHTMLfatigueMatrixForSegment(fatigue, segments);
} }
@ -625,25 +623,6 @@ export class RdDUtility {
return perte.total; return perte.total;
} }
/* -------------------------------------------- */
static currentFatigueMalus(value, max) {
if (ReglesOptionnelles.isUsing("appliquer-fatigue")) {
max = Math.max(1, Math.min(max, 60));
value = Math.min(max * 2, Math.max(0, value));
let fatigueTab = fatigueMatrix[max];
let fatigueRem = value;
for (let idx = 0; idx < fatigueTab.length; idx++) {
fatigueRem -= fatigueTab[idx];
if (fatigueRem <= 0) {
return fatigueMalus[idx];
}
}
return -7; // This is the max !
}
return 0;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static async responseNombreAstral(callData) { static async responseNombreAstral(callData) {
let actor = game.actors.get(callData.id); let actor = game.actors.get(callData.id);