Calcul automatique du niveau des entités

This commit is contained in:
Vincent Vandemeulebrouck 2024-12-18 17:26:28 +01:00
parent 14abfa8e7d
commit 4dce510c91
13 changed files with 120 additions and 98 deletions

View File

@ -1,4 +1,7 @@
# 12.0
## 12.0.30 - le cauchemar d'Astrobazzarh
- calcul automatique du niveau des entités selon leur rêve
## 12.0.29 - L'indexation d'Astrobazzarh
- les liens dans la descriptions des sorts pointent vers les sorts du compendium
- la description du chrasme contient le lien vers son venin plutôt qu'un tableau

View File

@ -37,6 +37,15 @@ export class RdDBaseActorReve extends RdDBaseActor {
this.system.sante.endurance.value = Math.min(this.system.sante.endurance.value, this.system.sante.endurance.max)
}
getCarac() {
return foundry.utils.mergeObject(this.system.carac,
{
'reve-actuel': this.getCaracReveActuel(),
'chance-actuelle': this.getCaracChanceActuelle()
},
{ inplace: false })
}
getCaracChanceActuelle() {
return {
label: 'Chance actuelle',
@ -53,7 +62,6 @@ export class RdDBaseActorReve extends RdDBaseActor {
};
}
getTaille() { return Misc.toInt(this.system.carac.taille?.value) }
getConstitution() { return this.getReve() }
getForce() { return this.getReve() }
@ -306,16 +314,6 @@ export class RdDBaseActorReve extends RdDBaseActor {
});
}
getCarac() {
// TODO: le niveau d'une entité de cauchemar devrait être exclu...
return foundry.utils.mergeObject(this.system.carac,
{
'reve-actuel': this.getCaracReveActuel(),
'chance-actuelle': this.getCaracChanceActuelle()
},
{ inplace: false })
}
/* -------------------------------------------- */
async rollCarac(caracName, jetResistance = undefined) {
if (Grammar.equalsInsensitive(caracName, 'taille')) {
@ -499,7 +497,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
|| entite.isEntiteAccordee(this)) {
return true;
}
const rolled = await RdDResolutionTable.roll(this.getReveActuel(), - Number(entite.system.carac.niveau.value));
const rolled = await RdDResolutionTable.roll(this.getReveActuel(), - Number(entite.getNiveau()));
const rollData = {
alias: this.getAlias(),
rolled: rolled,

View File

@ -15,6 +15,8 @@ export class RdDActorEntiteSheet extends RdDBaseActorReveSheet {
async getData() {
let formData = await super.getData();
formData.niveau = this.actor.getNiveau()
delete formData.system.carac.niveau
formData.resonances = this.actor.system.sante.resonnance.actors.map(actorId => game.actors.get(actorId))
.map(actor => { return { id: actor.id, name: actor.name, img: actor.img } })
return formData
@ -33,10 +35,6 @@ export class RdDActorEntiteSheet extends RdDBaseActorReveSheet {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "carac_value", parseInt(event.target.value));
});
this.html.find('.creature-niveau').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "niveau", parseInt(event.target.value));
})
this.html.find('.creature-dommages').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value));

View File

@ -1,6 +1,7 @@
import { ENTITE_INCARNE, ENTITE_NONINCARNE } from "../constants.js";
import { ITEM_TYPES } from "../item.js";
import { Misc } from "../misc.js";
import { RdDCarac } from "../rdd-carac.js";
import { RdDEncaisser } from "../rdd-roll-encaisser.js";
import { STATUSES } from "../settings/status-effects.js";
import { RdDBaseActorReve } from "./base-actor-reve.js";
@ -18,12 +19,23 @@ export class RdDEntite extends RdDBaseActorReve {
isEntite(typeentite = []) {
return (typeentite.length == 0 || typeentite.includes(this.system.definition.typeentite));
}
isNonIncarnee() { return this.isEntite([ENTITE_NONINCARNE]) }
getReveActuel() {
return Misc.toInt(this.system.carac.reve?.value)
}
getCarac() {
const carac = super.getCarac()
delete carac.niveau
return carac
}
getNiveau() {
const reve = this.getReve()
return RdDCarac.getCaracDerivee(reve).niveau
}
getForce() { return this.getReve() }
getAgilite() { return this.getReve() }
getChance() { return this.getReve() }
@ -64,6 +76,7 @@ export class RdDEntite extends RdDBaseActorReve {
}
return {}
}
async encaisser() {
if (this.isNonIncarnee()) {
return

View File

@ -3,38 +3,38 @@ import { Misc } from "./misc.js";
const TABLE_CARACTERISTIQUES_DERIVEES = {
// xp: coût pour passer du niveau inférieur à ce niveau
1: { xp: 3, poids: "moins de 1kg", poidsMin: 0, poidsMax: 1, plusdom: -5, sconst: 0.5, sust: 0.1 },
2: { xp: 3, poids: "1-5", poidsMin: 1, poidsMax: 5, plusdom: -4, sconst: 0.5, sust: 0.3 },
3: { xp: 4, poids: "6-10", poidsMin: 6, poidsMax: 10, plusdom: -3, sconst: 1, sust: 0.5, beaute: 'hideux' },
4: { xp: 4, poids: "11-20", poidsMin: 11, poidsMax: 20, plusdom: -3, sconst: 1, sust: 1, beaute: 'repoussant' },
5: { xp: 5, poids: "21-30", poidsMin: 21, poidsMax: 30, plusdom: -2, sconst: 1, sust: 1, beaute: 'franchement très laid' },
6: { xp: 5, poids: "31-40", poidsMin: 31, poidsMax: 40, plusdom: -1, sconst: 2, sust: 2, beaute: 'laid' },
7: { xp: 6, poids: "41-50", poidsMin: 41, poidsMax: 50, plusdom: -1, sconst: 2, sust: 2, beaute: 'très désavantagé' },
8: { xp: 6, poids: "51-60", poidsMin: 51, poidsMax: 60, plusdom: 0, sconst: 2, sust: 2, beaute: 'désavantagé' },
9: { xp: 7, poids: "61-65", poidsMin: 61, poidsMax: 65, plusdom: 0, sconst: 3, sust: 2, beaute: 'pas terrible' },
10: { xp: 7, poids: "66-70", poidsMin: 66, poidsMax: 70, plusdom: 0, sconst: 3, sust: 3, beaute: 'commun' },
11: { xp: 8, poids: "71-75", poidsMin: 71, poidsMax: 75, plusdom: 0, sconst: 3, sust: 3, beaute: 'pas mal' },
12: { xp: 8, poids: "76-80", poidsMin: 76, poidsMax: 80, plusdom: +1, sconst: 4, sust: 3, beaute: 'avantagé' },
13: { xp: 9, poids: "81-90", poidsMin: 81, poidsMax: 90, plusdom: +1, sconst: 4, sust: 3, beaute: 'mignon' },
14: { xp: 9, poids: "91-100", poidsMin: 91, poidsMax: 100, plusdom: +2, sconst: 4, sust: 4, beaute: 'beau' },
15: { xp: 10, poids: "101-110", poidsMin: 101, poidsMax: 110, plusdom: +2, sconst: 5, sust: 4, beaute: 'très beau' },
16: { xp: 20, poids: "111-120", poidsMin: 111, poidsMax: 120, plusdom: +3, sconst: 5, sust: 4, beaute: 'éblouissant' },
17: { xp: 30, poids: "121-131", poidsMin: 121, poidsMax: 131, plusdom: +3, sconst: 5, sust: 5 },
18: { xp: 40, poids: "131-141", poidsMin: 131, poidsMax: 141, plusdom: +4, sconst: 6, sust: 5 },
19: { xp: 50, poids: "141-150", poidsMin: 141, poidsMax: 150, plusdom: +4, sconst: 6, sust: 5 },
20: { xp: 60, poids: "151-160", poidsMin: 151, poidsMax: 160, plusdom: +4, sconst: 6, sust: 6 },
21: { xp: 70, poids: "161-180", poidsMin: 161, poidsMax: 180, plusdom: +5, sconst: 7, sust: 6 },
22: { xp: 80, poids: "181-200", poidsMin: 181, poidsMax: 200, plusdom: +5, sconst: 7, sust: 7 },
23: { xp: 90, poids: "201-300", poidsMin: 201, poidsMax: 300, plusdom: +6, sconst: 7, sust: 8 },
24: { xp: 100, poids: "301-400", poidsMin: 301, poidsMax: 400, plusdom: +6, sconst: 8, sust: 9 },
25: { xp: 110, poids: "401-500", poidsMin: 401, poidsMax: 500, plusdom: +7, sconst: 8, sust: 10 },
26: { xp: 120, poids: "501-600", poidsMin: 501, poidsMax: 600, plusdom: +7, sconst: 8, sust: 11 },
27: { xp: 130, poids: "601-700", poidsMin: 601, poidsMax: 700, plusdom: +8, sconst: 9, sust: 12 },
28: { xp: 140, poids: "701-800", poidsMin: 701, poidsMax: 800, plusdom: +8, sconst: 9, sust: 13 },
29: { xp: 150, poids: "801-900", poidsMin: 801, poidsMax: 900, plusdom: +9, sconst: 9, sust: 14 },
30: { xp: 160, poids: "901-1000", poidsMin: 901, poidsMax: 1000, plusdom: +9, sconst: 10, sust: 15 },
31: { xp: 170, poids: "1001-1500", poidsMin: 1001, poidsMax: 1500, plusdom: +10, sconst: 10, sust: 16 },
32: { xp: 180, poids: "1501-2000", poidsMin: 1501, poidsMax: 2000, plusdom: +11, sconst: 10, sust: 17 }
1: { xp: 3, niveau: -5, poids: "moins de 1kg", poidsMin: 0, poidsMax: 1, plusdom: -5, sconst: 0.5, sust: 0.1 },
2: { xp: 3, niveau: -4, poids: "1-5", poidsMin: 1, poidsMax: 5, plusdom: -4, sconst: 0.5, sust: 0.3 },
3: { xp: 4, niveau: -3, poids: "6-10", poidsMin: 6, poidsMax: 10, plusdom: -3, sconst: 1, sust: 0.5, beaute: 'hideux' },
4: { xp: 4, niveau: -2, poids: "11-20", poidsMin: 11, poidsMax: 20, plusdom: -3, sconst: 1, sust: 1, beaute: 'repoussant' },
5: { xp: 5, niveau: -1, poids: "21-30", poidsMin: 21, poidsMax: 30, plusdom: -2, sconst: 1, sust: 1, beaute: 'franchement très laid' },
6: { xp: 5, niveau: 0, poids: "31-40", poidsMin: 31, poidsMax: 40, plusdom: -1, sconst: 2, sust: 2, beaute: 'laid' },
7: { xp: 6, niveau: 0, poids: "41-50", poidsMin: 41, poidsMax: 50, plusdom: -1, sconst: 2, sust: 2, beaute: 'très désavantagé' },
8: { xp: 6, niveau: 0, poids: "51-60", poidsMin: 51, poidsMax: 60, plusdom: 0, sconst: 2, sust: 2, beaute: 'désavantagé' },
9: { xp: 7, niveau: 0, poids: "61-65", poidsMin: 61, poidsMax: 65, plusdom: 0, sconst: 3, sust: 2, beaute: 'pas terrible' },
10: { xp: 7, niveau: 0, poids: "66-70", poidsMin: 66, poidsMax: 70, plusdom: 0, sconst: 3, sust: 3, beaute: 'commun' },
11: { xp: 8, niveau: 1, poids: "71-75", poidsMin: 71, poidsMax: 75, plusdom: 0, sconst: 3, sust: 3, beaute: 'pas mal' },
12: { xp: 8, niveau: 1, poids: "76-80", poidsMin: 76, poidsMax: 80, plusdom: +1, sconst: 4, sust: 3, beaute: 'avantagé' },
13: { xp: 9, niveau: 2, poids: "81-90", poidsMin: 81, poidsMax: 90, plusdom: +1, sconst: 4, sust: 3, beaute: 'mignon' },
14: { xp: 9, niveau: 2, poids: "91-100", poidsMin: 91, poidsMax: 100, plusdom: +2, sconst: 4, sust: 4, beaute: 'beau' },
15: { xp: 10, niveau: 3, poids: "101-110", poidsMin: 101, poidsMax: 110, plusdom: +2, sconst: 5, sust: 4, beaute: 'très beau' },
16: { xp: 20, niveau: 3, poids: "111-120", poidsMin: 111, poidsMax: 120, plusdom: +3, sconst: 5, sust: 4, beaute: 'éblouissant' },
17: { xp: 30, niveau: 4, poids: "121-131", poidsMin: 121, poidsMax: 131, plusdom: +3, sconst: 5, sust: 5 },
18: { xp: 40, niveau: 4, poids: "131-141", poidsMin: 131, poidsMax: 141, plusdom: +4, sconst: 6, sust: 5 },
19: { xp: 50, niveau: 5, poids: "141-150", poidsMin: 141, poidsMax: 150, plusdom: +4, sconst: 6, sust: 5 },
20: { xp: 60, niveau: 5, poids: "151-160", poidsMin: 151, poidsMax: 160, plusdom: +4, sconst: 6, sust: 6 },
21: { xp: 70, niveau: 6, poids: "161-180", poidsMin: 161, poidsMax: 180, plusdom: +5, sconst: 7, sust: 6 },
22: { xp: 80, niveau: 6, poids: "181-200", poidsMin: 181, poidsMax: 200, plusdom: +5, sconst: 7, sust: 7 },
23: { xp: 90, niveau: 7, poids: "201-300", poidsMin: 201, poidsMax: 300, plusdom: +6, sconst: 7, sust: 8 },
24: { xp: 100, niveau: 7, poids: "301-400", poidsMin: 301, poidsMax: 400, plusdom: +6, sconst: 8, sust: 9 },
25: { xp: 110, niveau: 8, poids: "401-500", poidsMin: 401, poidsMax: 500, plusdom: +7, sconst: 8, sust: 10 },
26: { xp: 120, niveau: 8, poids: "501-600", poidsMin: 501, poidsMax: 600, plusdom: +7, sconst: 8, sust: 11 },
27: { xp: 130, niveau: 9, poids: "601-700", poidsMin: 601, poidsMax: 700, plusdom: +8, sconst: 9, sust: 12 },
28: { xp: 140, niveau: 9, poids: "701-800", poidsMin: 701, poidsMax: 800, plusdom: +8, sconst: 9, sust: 13 },
29: { xp: 150, niveau: 10, poids: "801-900", poidsMin: 801, poidsMax: 900, plusdom: +9, sconst: 9, sust: 14 },
30: { xp: 160, niveau: 10, poids: "901-1000", poidsMin: 901, poidsMax: 1000, plusdom: +9, sconst: 10, sust: 15 },
31: { xp: 170, niveau: 11, poids: "1001-1500", poidsMin: 1001, poidsMax: 1500, plusdom: +10, sconst: 10, sust: 16 },
32: { xp: 180, niveau: 11, poids: "1501-2000", poidsMin: 1501, poidsMax: 2000, plusdom: +11, sconst: 10, sust: 17 }
};
export class RdDCarac {

View File

@ -797,6 +797,9 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) {
padding: 0;
overflow-y: auto;
}
.item-list-title{
flex: 0;
}
.foundryvtt-reve-de-dragon .item-list .item-header {
font-weight: bold;

View File

@ -47,8 +47,10 @@
</div>
<div class="grid grid-2col">
<div class="flex-group-left flexcol">
<ul class="carac-list alterne-list">
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-main.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-creature.html"}}
</ul>
</div>
<div class="flex-group-left flexcol competence-column">
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/comp-creature.html"}}

View File

@ -33,8 +33,10 @@
</div>
<div class="grid grid-2col">
<div class="flex-group-left flexcol">
<ul class="carac-list alterne-list">
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-main.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-entitee.html"}}
</ul>
</div>
<div class="flex-group-left flexcol">
<div class="flex-group-left flexcol competence-column">

View File

@ -41,8 +41,10 @@
</div>
<div class="grid grid-2col">
<div class="flex-group-left flexcol">
<ul class="carac-list alterne-list">
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-main.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-total.html"}}
</ul>
</div>
<div class="flex-group-left flexcol" >
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-derivee.html"}}

View File

@ -1,11 +1,10 @@
<ol class="carac-list alterne-list">
{{#each system.attributs as |attr key|}}
{{#if (and (eq key 'plusdom') (eq @root.system.definition.typeentite 'nonincarne'))}}
{{else}}
<li class="caracteristique flexrow list-item" data-attribute="{{key}}">
<span class="carac-label" name="system.attributs.{{key}}.label">{{attr.label}}</span>
{{#if (actor-default @root.type 'attributs' key 'derivee')}}
<input class="caracteristique streched" type="text" name="system.attributs.{{key}}.value"
<input class="carac-value" type="text" name="system.attributs.{{key}}.value"
{{#if (eq key 'plusdom')}}
value="{{numberFormat attr.value decimals=0 sign=true}}"
{{else}}
@ -15,7 +14,7 @@
{{else}}
<input class="caracteristique streched" type="text" name="system.attributs.{{key}}.value" value="{{attr.value}}" data-dtype="{{attr.type}}" {{#unless @root.options.vueDetaillee}}disabled{{/unless}}/>
{{/if}}
<label class="carac-xp"/>
</li>
{{/if}}
{{/each}}
</ol>

View File

@ -1,16 +1,21 @@
<ol class="carac-list alterne-list">
<li class="caracteristique flexrow list-item">
<span class="carac-label" name="catEntite">Catégorie : </span>
<span class="carac-label">Niveau</span>
<label class="carac-value">{{numberFormat niveau decimals=0 sign=true}}
</label>
<label class="carac-xp"/>
</li>
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-creature.html"}}
<li class="caracteristique flexrow list-item">
<span class="carac-label" name="catEntite">Catégorie</span>
<select name="system.definition.categorieentite" value="{{system.definition.categorieentite}}" data-dtype="String" {{#unless @root.options.vueDetaillee}}disabled{{/unless}}>
{{selectOptions (RDD_CONFIG 'categorieEntite') selected=system.definition.categorieentite}}
</select>
<label class="carac-xp"/>
</li>
<li class="caracteristique flexrow list-item">
<span class="carac-label" name="typeEntite">Type d'entité : </span>
<span class="carac-label" name="typeEntite">Type d'entité</span>
<select name="system.definition.typeentite" value="{{system.definition.typeentite}}" data-dtype="String" {{#unless @root.options.vueDetaillee}}disabled{{/unless}}>
{{selectOptions (RDD_CONFIG 'typeEntite') selected=system.definition.typeentite}}
</select>
<label class="carac-xp"/>
</li>
</ol>
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/carac-creature.html"}}

View File

@ -1,8 +1,7 @@
<ul class="carac-list alterne-list">
{{#each system.carac as |carac key|}}
{{#if (and (eq key 'taille') (eq @root.system.definition.typeentite 'nonincarne'))}}
{{else}}
<li class="caracteristique flexrow list-item{{#if carac.isLevelUp}} xp-level-up{{/if}}" data-attribute="{{key}}">
{{#each system.carac as |carac key|}}
{{#if (and (eq key 'taille') (eq @root.system.definition.typeentite 'nonincarne'))}}
{{else}}
<li class="caracteristique flexrow list-item {{#if carac.isLevelUp}}xp-level-up{{/if}}" data-attribute="{{key}}">
{{#if (eq key 'taille')}}
<span class="carac-label" name="system.carac.{{key}}.label">{{carac.label}}</span>
<input class="carac-value" type="text" name="system.carac.{{key}}.value" value="{{carac.value}}" data-dtype="{{carac.type}}" {{#unless @root.options.vueDetaillee}}disabled{{/unless}} />
@ -10,7 +9,7 @@
{{else}}
{{#if (actor-default @root.type 'carac' key 'derivee')}}
<span class="carac-label" name="system.carac.{{key}}.label"><a class="roll-carac" data-carac-name={{key}}>{{carac.label}}</a></span>
<label class="competence-value">{{carac.value}}</label>
<label class="carac-value">{{carac.value}}</label>
<label class="carac-xp"/>
{{else}}
{{#if carac.isLevelUp}}
@ -35,5 +34,4 @@
{{/if}}
</li>
{{/if}}
{{/each}}
</ul>
{{/each}}

View File

@ -1,14 +1,13 @@
<h4>Compétences{{#if @root.options.vueDetaillee}} <a class="competence-add" data-tooltip="Ajouter une compétence">
<h4 class="item-list-title">Compétences{{#if @root.options.vueDetaillee}} <a class="competence-add" data-tooltip="Ajouter une compétence">
<i class="fa-solid fa-books-medical"></i>
</a>{{/if}}</h4>
<ol class="item-list alterne-list">
<ul class="item-list alterne-list">
{{#each (trier competences) as |comp key|}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<a class="competence-label roll-competence">
<img class="sheet-competence-img" src="{{comp.img}}" data-tooltip="{{comp.name}}"/>
<span>{{comp.name}}</span>
</a>
<input class="competence-carac creature-carac" type="text" compname="{{comp.name}}" name="{{comp._id}}.carac"
value="{{comp.system.carac_value}}" data-dtype="number"
{{#unless @root.options.vueDetaillee}}disabled{{/unless}}/>
@ -32,4 +31,4 @@
{{/if}}
</li>
{{/each}}
</ol>
</ul>