simplification/organisation RdDActorSheet.getData
This commit is contained in:
parent
dcc450db63
commit
17d863482d
@ -62,9 +62,6 @@ export class RdDActorSheet extends ActorSheet {
|
||||
|
||||
if (this.actor.data.type == 'creature') return formData; // Shortcut
|
||||
|
||||
// toujours avoir une liste d'armes (pour mettre esquive et corps à corps)
|
||||
formData.itemsByType.arme = formData.itemsByType.arme ?? [];
|
||||
|
||||
formData.competenceByCategory = Misc.classify(formData.data.competences, item => item.data.categorie);
|
||||
|
||||
formData.calc = {
|
||||
@ -93,38 +90,15 @@ export class RdDActorSheet extends ActorSheet {
|
||||
});
|
||||
|
||||
|
||||
// Force empty arme, at least for Esquive
|
||||
if (formData.itemsByType.arme == undefined) formData.itemsByType.arme = [];
|
||||
for (const arme of formData.itemsByType.arme) {
|
||||
arme.data.niveau = 0; // Per default, TODO to be fixed
|
||||
for (const melee of formData.competenceByCategory.melee) {
|
||||
if (melee.name == arme.data.competence)
|
||||
arme.data.niveau = melee.data.niveau
|
||||
}
|
||||
for (const tir of formData.competenceByCategory.tir) {
|
||||
if (tir.name == arme.data.competence)
|
||||
arme.data.niveau = tir.data.niveau
|
||||
}
|
||||
for (const lancer of formData.competenceByCategory.lancer) {
|
||||
if (lancer.name == arme.data.competence)
|
||||
arme.data.niveau = lancer.data.niveau
|
||||
}
|
||||
}
|
||||
|
||||
// To avoid armour and so on...
|
||||
formData.data.combat = duplicate(RdDUtility.checkNull(formData.itemsByType['arme']));
|
||||
// toujours avoir une liste d'armes (pour mettre esquive et corps à corps)
|
||||
formData.data.combat = duplicate(formData.itemsByType.arme ?? []);
|
||||
RdDItemArme.computeNiveauArmes(formData.data.combat, formData.data.competences);
|
||||
RdDItemArme.ajoutCorpsACorps(formData.data.combat, formData.data.competences, formData.data.carac );
|
||||
formData.esquive = RdDItemCompetence.getEsquive(formData.data.competences);
|
||||
formData.data.combat = RdDCombatManager.finalizeArmeList(formData.data.combat, formData.itemsByType.competence, formData.data.carac);
|
||||
|
||||
formData.esquive = { name: "Esquive", niveau: formData.competenceByCategory?.melee.find(it => it.name == 'Esquive')?.data.niveau ?? -6 };
|
||||
let corpsACorps = formData.competenceByCategory?.melee.find(it => it.name == 'Corps à corps');
|
||||
if (corpsACorps) {
|
||||
let cc_init = RdDCombatManager.calculInitiative(corpsACorps.data.niveau, formData.data.carac['melee'].value);
|
||||
formData.data.combat.push(RdDItemArme.mainsNues({ niveau: corpsACorps.data.niveau, initiative: cc_init }));
|
||||
}
|
||||
this.armesList = duplicate(formData.data.combat);
|
||||
|
||||
formData.data.carac.taille.isTaille = true; // To avoid button link;
|
||||
formData.data.blessures.resume = this.actor.computeResumeBlessure(formData.data.blessures);
|
||||
this.armesList = formData.data.combat;
|
||||
|
||||
// Mise à jour de l'encombrement total et du prix de l'équipement
|
||||
|
||||
@ -140,14 +114,18 @@ export class RdDActorSheet extends ActorSheet {
|
||||
html: "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix(formData.data.sante.fatigue.value, formData.data.sante.endurance.max).html() + "</table>"
|
||||
}
|
||||
|
||||
RdDUtility.filterItemsPerTypeForSheet(formData);
|
||||
formData.data.sortReserve = formData.data.reve.reserve.list;
|
||||
formData.data.rencontres = duplicate(formData.data.reve.rencontre.list);
|
||||
formData.data.caseSpeciales = formData.itemsByType['casetmr'];
|
||||
formData.hautreve = {
|
||||
sortsReserve: formData.data.reve.reserve.list,
|
||||
rencontres: duplicate(formData.data.reve.rencontre.list),
|
||||
casesTmr: formData.itemsByType.casetmr
|
||||
}
|
||||
|
||||
RdDUtility.buildArbreDeConteneur(this, formData);
|
||||
formData.data.vehiculesList = this.actor.buildVehiculesList();
|
||||
formData.data.monturesList = this.actor.buildMonturesList();
|
||||
formData.data.suivantsList = this.actor.buildSuivantsList();
|
||||
formData.subacteurs = {
|
||||
vehicules: this.actor.listeVehicules(),
|
||||
montures: this.actor.listeMontures(),
|
||||
suivants: this.actor.listeSuivants()
|
||||
}
|
||||
return formData;
|
||||
}
|
||||
|
||||
|
@ -3007,7 +3007,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
buildVehiculesList() {
|
||||
listeVehicules() {
|
||||
return this._buildActorLinksList(
|
||||
this.data.data.subacteurs?.vehicules ?? [],
|
||||
vehicle => {
|
||||
@ -3019,12 +3019,12 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
buildSuivantsList() {
|
||||
listeSuivants() {
|
||||
return this._buildActorLinksList(this.data.data.subacteurs?.suivants ?? []);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
buildMonturesList() {
|
||||
listeMontures() {
|
||||
return this._buildActorLinksList(this.data.data.subacteurs?.montures ?? []);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { RdDItemCompetenceCreature } from "./item-competencecreature.js"
|
||||
import { RdDCombatManager } from "./rdd-combat.js";
|
||||
|
||||
const nomCategorieParade = {
|
||||
"sans-armes": "Sans arme / armes naturelles",
|
||||
@ -30,6 +31,17 @@ export class RdDItemArme extends Item {
|
||||
return RdDItemArme.mainsNues();
|
||||
}
|
||||
|
||||
static computeNiveauArmes(armes, competences) {
|
||||
for (const arme of armes) {
|
||||
arme.data.niveau = RdDItemArme.niveauCompetenceArme(arme, competences);
|
||||
}
|
||||
}
|
||||
|
||||
static niveauCompetenceArme(arme, competences) {
|
||||
const compArme = competences.find(it => it.name == arme.data.competence);
|
||||
return compArme?.data.niveau ?? -8;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getNomCategorieParade(arme) {
|
||||
const categorie = arme?.data ? RdDItemArme.getCategorieParade(arme) : arme;
|
||||
@ -38,7 +50,7 @@ export class RdDItemArme extends Item {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static needArmeResist(armeAttaque, armeParade) {
|
||||
if (!armeAttaque || !armeParade){
|
||||
if (!armeAttaque || !armeParade) {
|
||||
return false;
|
||||
}
|
||||
// Epées parant une arme de bois (cf. page 115 ), une résistance est nécessaire
|
||||
@ -54,7 +66,7 @@ export class RdDItemArme extends Item {
|
||||
return arme.data.categorie_parade;
|
||||
}
|
||||
// pour compatibilité avec des personnages existants
|
||||
if (arme.type == 'competencecreature' || arme.data.categorie == 'creature' ) {
|
||||
if (arme.type == 'competencecreature' || arme.data.categorie == 'creature') {
|
||||
return arme.data.categorie_parade || (arme.data.isparade ? 'sans-armes' : '');
|
||||
}
|
||||
if (!arme.type.match(/arme|competencecreature/)) {
|
||||
@ -86,7 +98,7 @@ export class RdDItemArme extends Item {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static needParadeSignificative(armeAttaque, armeParade) {
|
||||
if (!armeAttaque || !armeParade){
|
||||
if (!armeAttaque || !armeParade) {
|
||||
return false;
|
||||
}
|
||||
// categories d'armes à la parade (cf. page 115 )
|
||||
@ -145,10 +157,16 @@ export class RdDItemArme extends Item {
|
||||
}
|
||||
|
||||
static isArmeUtilisable(item) {
|
||||
return item.type == 'arme' && item.data.equipe && (item.data.resistance > 0 || item.data.portee_courte>0);
|
||||
return item.type == 'arme' && item.data.equipe && (item.data.resistance > 0 || item.data.portee_courte > 0);
|
||||
}
|
||||
|
||||
static mainsNues(actorData={}) {
|
||||
static ajoutCorpsACorps(armes, competences, carac) {
|
||||
let corpsACorps = competences.find(it => it.name == 'Corps à corps') ?? { data: { niveau: -6 } };
|
||||
let init = RdDCombatManager.calculInitiative(corpsACorps.data.niveau, carac['melee'].value);
|
||||
armes.push(RdDItemArme.mainsNues({ niveau: corpsACorps.data.niveau, initiative: init }));
|
||||
}
|
||||
|
||||
static mainsNues(actorData = {}) {
|
||||
const mainsNues = {
|
||||
name: 'Mains nues',
|
||||
data: {
|
||||
@ -163,8 +181,8 @@ export class RdDItemArme extends Item {
|
||||
}
|
||||
};
|
||||
if (actorData) {
|
||||
mergeObject( mainsNues.data, actorData, {overwrite:false});
|
||||
mergeObject(mainsNues.data, actorData, { overwrite: false });
|
||||
}
|
||||
return mainsNues
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,11 +56,15 @@ export class RdDItemCompetence extends Item {
|
||||
return categorieCompetences[category].label;
|
||||
}
|
||||
|
||||
static getEsquive(competences) {
|
||||
return { name: 'Esquive', niveau: RdDItemCompetence.findCompetence(competences, 'Esquive')?.data.niveau ?? -6 };
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static isCompetenceArme(competence) {
|
||||
switch (competence.data.categorie) {
|
||||
case 'melee':
|
||||
return competence.name.toLowerCase() != 'esquive';
|
||||
return competence.name != 'Esquive';
|
||||
case 'tir':
|
||||
case 'lancer':
|
||||
return true;
|
||||
|
@ -541,6 +541,7 @@
|
||||
</div>
|
||||
|
||||
{{!-- hautreve Tab --}}
|
||||
{{log 'Haut reve' hautreve}}
|
||||
<div class="tab hautreve " data-group="primary" data-tab="hautreve" style="height:200px">
|
||||
<div>
|
||||
<h3>Haut rêve:</h3>
|
||||
@ -599,7 +600,7 @@
|
||||
<div>
|
||||
<h3>Sorts en Réserve:</h3>
|
||||
<ul class="item-list">
|
||||
{{#each data.sortReserve as |reserve key|}}
|
||||
{{#each hautreve.sortsReserve as |reserve key|}}
|
||||
<li class="item flexrow" data-item-id="{{mysort._id}}" data-attribute="{{key}}">
|
||||
<span class="sort-label"> {{reserve.sort.name}} - {{reserve.coord}}</span>
|
||||
</li>
|
||||
@ -625,7 +626,7 @@
|
||||
<div>
|
||||
<h3>Cases Spéciales:</h3>
|
||||
<ul class="item-list">
|
||||
{{#each data.caseSpeciales as |casetmr key|}}
|
||||
{{#each hautreve.casesTmr as |casetmr key|}}
|
||||
<li class="item flexrow" data-item-id="{{casetmr._id}}" data-attribute="{{key}}">
|
||||
<span class="case-label"><a data-id="{{casetmr._id}}">{{casetmr.name}}</a></span>
|
||||
<div class="item-controls">
|
||||
@ -639,9 +640,9 @@
|
||||
<div>
|
||||
<h3>Rencontres présentes:</h3>
|
||||
<ul class="item-list">
|
||||
{{#each data.rencontres as |rencontre key|}}
|
||||
{{#each hautreve.rencontres as |rencontre key|}}
|
||||
<li class="item flexrow" data-item-id="{{key}}" data-attribute="{{key}}">
|
||||
<span class="case-label"><a data-id="{{key}}">{{rencontre.rencontre.name}} - {{rencontre.coord}} ({{rencontre.rencontre.date}} - {{rencontre.rencontre.heure}})</a></span>
|
||||
<span class="case-label"><a data-id="{{key}}">{{rencontre.rencontre.name}} - {{rencontre.coord}} {{#if rencontre.rencontre.date}}({{rencontre.rencontre.date}} - {{rencontre.rencontre.heure}}){{/if}}</a></span>
|
||||
<div class="item-controls">
|
||||
<a class="item-control rencontre-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
@ -760,7 +761,7 @@
|
||||
|
||||
<span class="item-name"><h4>Montures</h4></span>
|
||||
<ul class="item-list alterne-list">
|
||||
{{#each data.monturesList as |monture id|}}
|
||||
{{#each subacteurs.montures as |monture id|}}
|
||||
<li class="item flexrow list-item" data-actor-id="{{monture.id}}">
|
||||
<img class="sheet-competence-img" src="{{monture.img}}" title="{{monture.name}}"/>
|
||||
<span class="competence-title subacteur-label"><a>{{monture.name}}</a></span>
|
||||
@ -773,7 +774,7 @@
|
||||
|
||||
<span class="item-name"><h4>Véhicules</h4></span>
|
||||
<ul class="item-list alterne-list">
|
||||
{{#each data.vehiculesList as |vehicule id|}}
|
||||
{{#each subacteurs.vehicules as |vehicule id|}}
|
||||
<li class="item flexrow list-item" data-actor-id="{{vehicule.id}}">
|
||||
<img class="sheet-competence-img" src="{{vehicule.img}}" title="{{vehicule.name}}"/>
|
||||
<span class="competence-title subacteur-label"><a>{{vehicule.name}}</a></span>
|
||||
@ -788,7 +789,7 @@
|
||||
|
||||
<span class="item-name"><h4>Suivants</h4></span>
|
||||
<ul class="item-list alterne-list">
|
||||
{{#each data.suivantsList as |suivant id|}}
|
||||
{{#each subacteurs.suivants as |suivant id|}}
|
||||
<li class="item flexrow list-item" data-actor-id="{{suivant.id}}">
|
||||
<img class="sheet-competence-img" src="{{suivant.img}}" title="{{suivant.name}}"/>
|
||||
<span class="competence-title subacteur-label"><a>{{suivant.name}}</a></span>
|
||||
|
Loading…
Reference in New Issue
Block a user