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
- Les options suivantes peuvent être désactivées:
- La transformation de stress à Château Dormant
- Séparation des véhicules dans leur propre acteur
## v11.0.28 - les fractures de Khrachtchoum
- La gravité de la blessure est affichée dans le résumé de l'encaissement
- 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: split by actor class
// Make separate methods for each Actor type (character, npc, etc.) to keep
// things organized.
// Make separate methods for each Actor type (character, npc, etc.) to keep things organized.
if (this.isPersonnage()) this._prepareCharacterData(this)
if (this.isCreatureEntite()) this._prepareCreatureData(this)
if (this.isVehicule()) this._prepareVehiculeData(this)
this.computeEtatGeneral();
this.recompute();
}
/* -------------------------------------------- */
@ -80,11 +78,6 @@ export class RdDActor extends RdDBaseActor {
this.computeEncTotal();
}
/* -------------------------------------------- */
_prepareVehiculeData(actorData) {
this.computeEncTotal();
}
/* -------------------------------------------- */
/**
* Prepare Character type specific data
@ -114,9 +107,6 @@ export class RdDActor extends RdDBaseActor {
if (this.isEntite()) {
return item.type == 'competencecreature';
}
if (this.isVehicule()) {
return item.isInventaire();
}
if (this.isPersonnage()) {
switch (item.type) {
case 'competencecreature': case 'tarot': case 'service':
@ -153,7 +143,6 @@ export class RdDActor extends RdDBaseActor {
case 'creature':
case 'entite':
return Misc.toInt(this.system.carac.reve?.value)
case 'vehicule':
default:
return 0;
}
@ -1125,7 +1114,7 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */
computeMalusSurEncombrement() {
switch (this.type) {
case 'entite': case 'vehicule':
case 'entite':
return 0;
}
return Math.min(0, Math.floor(this.getEncombrementMax() - this.encTotal));
@ -1138,8 +1127,6 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */
getEncombrementMax() {
switch (this.type) {
case 'vehicule':
return this.system.capacite_encombrement;
case 'entite':
return 0;
default:
@ -1184,29 +1171,40 @@ export class RdDActor extends RdDBaseActor {
return resume;
}
recompute() {
this.computeEtatGeneral();
}
/* -------------------------------------------- */
computeEtatGeneral() {
// Pas d'état général pour les entités forçage à 0
if (this.type == 'vehicule') {
return
}
recompute() {
if (this.type == 'entite') {
// Pas d'état général pour les entités forçage à 0
this.system.compteurs.etat.value = 0;
return
}
// Pour les autres
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);
this.system.compteurs.etat.value = this.$malusVie() + this.$malusFatigue() + this.$malusEthylisme();
}
// 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;
}
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() {
return !this.isEntite() && this.system.sante.vie.value < -this.getSConst()
@ -3772,7 +3759,7 @@ export class RdDActor extends RdDBaseActor {
/* -------------------------------------------- */
async setEffect(statusId, status) {
if (this.isEntite() || this.isVehicule()) {
if (this.isEntite()) {
return;
}
console.log("setEffect", statusId, status)

View File

@ -145,8 +145,11 @@ export class RdDBaseActor extends Actor {
}
getMonnaie(id) { return this.findItemLike(id, 'monnaie'); }
getReveActuel() { return 0 }
computeMalusSurEncombrement() { return 0 }
getEncombrementMax() { return 0 }
recompute() { }
async setEffect(statusId, status) { }
/* -------------------------------------------- */
@ -388,14 +391,6 @@ export class RdDBaseActor extends Actor {
}
/* -------------------------------------------- */
computeMalusSurEncombrement() {
return 0;
}
getEncombrementMax() {
return 0;
}
async computeEncTotal() {
if (!this.pack) {
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) {
if (item.isInventaire('all')) {
return true;
}
return super.canReceive(item);
return item.isInventaire('all');
}
getQuantiteDisponible(item) {

View File

@ -1,8 +1,8 @@
import { RdDUtility } from "./rdd-utility.js";
import { RdDActorSheet } from "./actor-sheet.js";
import { RdDUtility } from "../rdd-utility.js";
import { RdDBaseActorSheet } from "./base-actor-sheet.js";
/* -------------------------------------------- */
export class RdDActorVehiculeSheet extends RdDActorSheet {
export class RdDActorVehiculeSheet extends RdDBaseActorSheet {
/** @override */
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) {
super.activateListeners(html);
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 { RdDBaseActor } from "./actor/base-actor.js";
import { RdDCommerce } from "./actor/commerce.js";
import { RdDVehicule } from "./actor/vehicule.js";
import { RdDActorSheet } from "./actor-sheet.js";
import { RdDCommerceSheet } from "./actor/commerce-sheet.js";
import { RdDActorCreatureSheet } from "./actor-creature-sheet.js";
import { RdDActorVehiculeSheet } from "./actor-vehicule-sheet.js";
import { RdDActorEntiteSheet } from "./actor-entite-sheet.js";
import { RdDActorVehiculeSheet } from "./actor/vehicule-sheet.js";
import { RdDItem } from "./item.js";
import { RdDItemBlessure } from "./item/blessure.js";
@ -94,7 +95,7 @@ export class SystemReveDeDragon {
creature: RdDActor,
entite: RdDActor,
personnage: RdDActor,
vehicule: RdDActor,
vehicule: RdDVehicule,
}
}

View File

@ -28,7 +28,7 @@ const ajustementsEncaissement = Misc.intArray(-10, 26);
/* -------------------------------------------- */
function _buildAllSegmentsFatigue(max) {
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++) {
const ligneFatigue = duplicate(fatigue[i]);
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 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) {
maxEnd = Math.max(maxEnd, 1);
maxEnd = Math.min(maxEnd, fatigueMatrix.length);
return fatigueMatrix[maxEnd];
static getSegmentsFatigue(maxEndurance) {
return fatigueMatrix[Math.min(Math.max(maxEndurance, 1), fatigueMatrix.length)];
}
/* -------------------------------------------- */
@ -491,7 +489,7 @@ export class RdDUtility {
// Build the nice (?) html table used to manage fatigue.
// max should be the endurance max value
static makeHTMLfatigueMatrix(fatigue, maxEndurance) {
let segments = this.getSegmentsFatigue(maxEndurance);
const segments = this.getSegmentsFatigue(maxEndurance);
return this.makeHTMLfatigueMatrixForSegment(fatigue, segments);
}
@ -625,25 +623,6 @@ export class RdDUtility {
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) {
let actor = game.actors.get(callData.id);