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
|
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.competenceByCategory = Misc.classify(formData.data.competences, item => item.data.categorie);
|
||||||
|
|
||||||
formData.calc = {
|
formData.calc = {
|
||||||
@ -93,38 +90,15 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Force empty arme, at least for Esquive
|
// toujours avoir une liste d'armes (pour mettre esquive et corps à corps)
|
||||||
if (formData.itemsByType.arme == undefined) formData.itemsByType.arme = [];
|
formData.data.combat = duplicate(formData.itemsByType.arme ?? []);
|
||||||
for (const arme of formData.itemsByType.arme) {
|
RdDItemArme.computeNiveauArmes(formData.data.combat, formData.data.competences);
|
||||||
arme.data.niveau = 0; // Per default, TODO to be fixed
|
RdDItemArme.ajoutCorpsACorps(formData.data.combat, formData.data.competences, formData.data.carac );
|
||||||
for (const melee of formData.competenceByCategory.melee) {
|
formData.esquive = RdDItemCompetence.getEsquive(formData.data.competences);
|
||||||
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']));
|
|
||||||
formData.data.combat = RdDCombatManager.finalizeArmeList(formData.data.combat, formData.itemsByType.competence, formData.data.carac);
|
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;
|
this.armesList = formData.data.combat;
|
||||||
formData.data.blessures.resume = this.actor.computeResumeBlessure(formData.data.blessures);
|
|
||||||
|
|
||||||
// Mise à jour de l'encombrement total et du prix de l'équipement
|
// 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>"
|
html: "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix(formData.data.sante.fatigue.value, formData.data.sante.endurance.max).html() + "</table>"
|
||||||
}
|
}
|
||||||
|
|
||||||
RdDUtility.filterItemsPerTypeForSheet(formData);
|
formData.hautreve = {
|
||||||
formData.data.sortReserve = formData.data.reve.reserve.list;
|
sortsReserve: formData.data.reve.reserve.list,
|
||||||
formData.data.rencontres = duplicate(formData.data.reve.rencontre.list);
|
rencontres: duplicate(formData.data.reve.rencontre.list),
|
||||||
formData.data.caseSpeciales = formData.itemsByType['casetmr'];
|
casesTmr: formData.itemsByType.casetmr
|
||||||
|
}
|
||||||
|
|
||||||
RdDUtility.buildArbreDeConteneur(this, formData);
|
RdDUtility.buildArbreDeConteneur(this, formData);
|
||||||
formData.data.vehiculesList = this.actor.buildVehiculesList();
|
formData.subacteurs = {
|
||||||
formData.data.monturesList = this.actor.buildMonturesList();
|
vehicules: this.actor.listeVehicules(),
|
||||||
formData.data.suivantsList = this.actor.buildSuivantsList();
|
montures: this.actor.listeMontures(),
|
||||||
|
suivants: this.actor.listeSuivants()
|
||||||
|
}
|
||||||
return formData;
|
return formData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3007,7 +3007,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
buildVehiculesList() {
|
listeVehicules() {
|
||||||
return this._buildActorLinksList(
|
return this._buildActorLinksList(
|
||||||
this.data.data.subacteurs?.vehicules ?? [],
|
this.data.data.subacteurs?.vehicules ?? [],
|
||||||
vehicle => {
|
vehicle => {
|
||||||
@ -3019,12 +3019,12 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
buildSuivantsList() {
|
listeSuivants() {
|
||||||
return this._buildActorLinksList(this.data.data.subacteurs?.suivants ?? []);
|
return this._buildActorLinksList(this.data.data.subacteurs?.suivants ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
buildMonturesList() {
|
listeMontures() {
|
||||||
return this._buildActorLinksList(this.data.data.subacteurs?.montures ?? []);
|
return this._buildActorLinksList(this.data.data.subacteurs?.montures ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { RdDItemCompetenceCreature } from "./item-competencecreature.js"
|
import { RdDItemCompetenceCreature } from "./item-competencecreature.js"
|
||||||
|
import { RdDCombatManager } from "./rdd-combat.js";
|
||||||
|
|
||||||
const nomCategorieParade = {
|
const nomCategorieParade = {
|
||||||
"sans-armes": "Sans arme / armes naturelles",
|
"sans-armes": "Sans arme / armes naturelles",
|
||||||
@ -30,6 +31,17 @@ export class RdDItemArme extends Item {
|
|||||||
return RdDItemArme.mainsNues();
|
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) {
|
static getNomCategorieParade(arme) {
|
||||||
const categorie = arme?.data ? RdDItemArme.getCategorieParade(arme) : arme;
|
const categorie = arme?.data ? RdDItemArme.getCategorieParade(arme) : arme;
|
||||||
@ -148,6 +160,12 @@ export class RdDItemArme extends 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 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 = {}) {
|
static mainsNues(actorData = {}) {
|
||||||
const mainsNues = {
|
const mainsNues = {
|
||||||
name: 'Mains nues',
|
name: 'Mains nues',
|
||||||
|
@ -56,11 +56,15 @@ export class RdDItemCompetence extends Item {
|
|||||||
return categorieCompetences[category].label;
|
return categorieCompetences[category].label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getEsquive(competences) {
|
||||||
|
return { name: 'Esquive', niveau: RdDItemCompetence.findCompetence(competences, 'Esquive')?.data.niveau ?? -6 };
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static isCompetenceArme(competence) {
|
static isCompetenceArme(competence) {
|
||||||
switch (competence.data.categorie) {
|
switch (competence.data.categorie) {
|
||||||
case 'melee':
|
case 'melee':
|
||||||
return competence.name.toLowerCase() != 'esquive';
|
return competence.name != 'Esquive';
|
||||||
case 'tir':
|
case 'tir':
|
||||||
case 'lancer':
|
case 'lancer':
|
||||||
return true;
|
return true;
|
||||||
|
@ -541,6 +541,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{!-- hautreve Tab --}}
|
{{!-- hautreve Tab --}}
|
||||||
|
{{log 'Haut reve' hautreve}}
|
||||||
<div class="tab hautreve " data-group="primary" data-tab="hautreve" style="height:200px">
|
<div class="tab hautreve " data-group="primary" data-tab="hautreve" style="height:200px">
|
||||||
<div>
|
<div>
|
||||||
<h3>Haut rêve:</h3>
|
<h3>Haut rêve:</h3>
|
||||||
@ -599,7 +600,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<h3>Sorts en Réserve:</h3>
|
<h3>Sorts en Réserve:</h3>
|
||||||
<ul class="item-list">
|
<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}}">
|
<li class="item flexrow" data-item-id="{{mysort._id}}" data-attribute="{{key}}">
|
||||||
<span class="sort-label"> {{reserve.sort.name}} - {{reserve.coord}}</span>
|
<span class="sort-label"> {{reserve.sort.name}} - {{reserve.coord}}</span>
|
||||||
</li>
|
</li>
|
||||||
@ -625,7 +626,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<h3>Cases Spéciales:</h3>
|
<h3>Cases Spéciales:</h3>
|
||||||
<ul class="item-list">
|
<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}}">
|
<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>
|
<span class="case-label"><a data-id="{{casetmr._id}}">{{casetmr.name}}</a></span>
|
||||||
<div class="item-controls">
|
<div class="item-controls">
|
||||||
@ -639,9 +640,9 @@
|
|||||||
<div>
|
<div>
|
||||||
<h3>Rencontres présentes:</h3>
|
<h3>Rencontres présentes:</h3>
|
||||||
<ul class="item-list">
|
<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}}">
|
<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">
|
<div class="item-controls">
|
||||||
<a class="item-control rencontre-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
<a class="item-control rencontre-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
||||||
</div>
|
</div>
|
||||||
@ -760,7 +761,7 @@
|
|||||||
|
|
||||||
<span class="item-name"><h4>Montures</h4></span>
|
<span class="item-name"><h4>Montures</h4></span>
|
||||||
<ul class="item-list alterne-list">
|
<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}}">
|
<li class="item flexrow list-item" data-actor-id="{{monture.id}}">
|
||||||
<img class="sheet-competence-img" src="{{monture.img}}" title="{{monture.name}}"/>
|
<img class="sheet-competence-img" src="{{monture.img}}" title="{{monture.name}}"/>
|
||||||
<span class="competence-title subacteur-label"><a>{{monture.name}}</a></span>
|
<span class="competence-title subacteur-label"><a>{{monture.name}}</a></span>
|
||||||
@ -773,7 +774,7 @@
|
|||||||
|
|
||||||
<span class="item-name"><h4>Véhicules</h4></span>
|
<span class="item-name"><h4>Véhicules</h4></span>
|
||||||
<ul class="item-list alterne-list">
|
<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}}">
|
<li class="item flexrow list-item" data-actor-id="{{vehicule.id}}">
|
||||||
<img class="sheet-competence-img" src="{{vehicule.img}}" title="{{vehicule.name}}"/>
|
<img class="sheet-competence-img" src="{{vehicule.img}}" title="{{vehicule.name}}"/>
|
||||||
<span class="competence-title subacteur-label"><a>{{vehicule.name}}</a></span>
|
<span class="competence-title subacteur-label"><a>{{vehicule.name}}</a></span>
|
||||||
@ -788,7 +789,7 @@
|
|||||||
|
|
||||||
<span class="item-name"><h4>Suivants</h4></span>
|
<span class="item-name"><h4>Suivants</h4></span>
|
||||||
<ul class="item-list alterne-list">
|
<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}}">
|
<li class="item flexrow list-item" data-actor-id="{{suivant.id}}">
|
||||||
<img class="sheet-competence-img" src="{{suivant.img}}" title="{{suivant.name}}"/>
|
<img class="sheet-competence-img" src="{{suivant.img}}" title="{{suivant.name}}"/>
|
||||||
<span class="competence-title subacteur-label"><a>{{suivant.name}}</a></span>
|
<span class="competence-title subacteur-label"><a>{{suivant.name}}</a></span>
|
||||||
|
Loading…
Reference in New Issue
Block a user