#97 particulière pour armes lentes

Pas de particulières en rapidité pour les armes lentes.

Le corps à corps est considéré comme rapide.

Standardise le corps à corps:  centraliser la construction d'un objet
pour le corps à corps

Convertion de compétences de créature en arme

Petit fix sur HUD: le click est sur le div uniquement (au lieu
du label avant, ou d'un mix avec un fix précédent...)
This commit is contained in:
Vincent Vandemeulebrouck
2021-01-04 00:17:22 +01:00
parent 3d98d57fb5
commit 3ac2be74fd
11 changed files with 124 additions and 91 deletions

View File

@ -5,6 +5,9 @@ import { ChatUtility } from "./chat-utility.js";
import { RdDItemCompetence } from "./item-competence.js";
import { RdDCombat } from "./rdd-combat.js";
import { RdDRollResolutionTable } from "./rdd-roll-resolution-table.js";
import { RdDItem } from "./item.js";
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
import { RdDItemArme } from "./item-arme.js";
/* -------------------------------------------- */
const level_category = {
@ -464,11 +467,10 @@ export class RdDUtility {
/* -------------------------------------------- */
/** Retourne une liste triée d'armes avec le split arme1 main / arme 2 main */
static finalizeArmeList( armeList, competenceList, carac ) {
static _finalizeArmeList( armes, competenceList, carac ) {
// Gestion des armes 1/2 mains
let arme2mains = []; // Tableau contenant la duplication des armes 1m/2m
let armesEquipe = [];
for (const arme of armeList) {
for (const arme of armes) {
if (arme.data.equipe) {
armesEquipe.push( arme );
let comp = competenceList.find(c => c.name == arme.data.competence);
@ -491,9 +493,13 @@ export class RdDUtility {
}
}
}
//armeList = armeList.concat(arme2mains); // Merge all cases
armesEquipe = armesEquipe.sort((a, b) => { if ( a.name > b.name) return 1; else return -1; } );
return armesEquipe
return armesEquipe.sort((a, b) => {
const nameA = a.name + (a.data.mainInfo ?? '');
const nameB = b.name + (b.data.mainInfo ?? '');
if ( nameA > nameB) return 1;
if ( nameA < nameB) return -1;
return 0;
} );
}
/* -------------------------------------------- */
@ -796,20 +802,6 @@ export class RdDUtility {
}
}
/* -------------------------------------------- */
static buildItemsClassification( items ) {
let itemsByType = {};
for (const item of items) {
let list = itemsByType[item.type];
if (!list) {
list = [];
itemsByType[item.type] = list;
}
list.push(item);
}
return itemsByType;
}
/* -------------------------------------------- */
static rollInitiativeCompetence( combatantId, arme ) {
const combatant = game.combat.getCombatant(combatantId);
@ -843,33 +835,36 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static buildArmeList( combatant ) {
static buildListeActionsCombat( combatant ) {
const actor = combatant.actor; // Easy access
let armesList = [];
if ( actor.data.type == 'creature' || actor.data.type == 'entite') {
for (const competenceItem of actor.data.items) {
if ( competenceItem.data.iscombat) { // Seul un item de type arme
armesList.push( { name: competenceItem.name, data: { niveau: competenceItem.data.niveau, competence: competenceItem.name } } );
}
}
let items = actor.data.items;
let actions = []
if ( actor.isCreature()) {
actions = actions.concat(items.filter(it => it.type =='competencecreature' && it.data.iscombat)
.map(competence => RdDItemCompetenceCreature.toArme(competence)));
} else {
// Recupération des items 'arme'
let itemsByType = RdDUtility.buildItemsClassification( combatant.actor.data.items );
armesList = itemsByType['arme'];
armesList = this.finalizeArmeList( armesList, itemsByType['competence'], actor.data.data.carac );
// Force corps à corps et Draconic
let cc = RdDUtility.findCompetence( combatant.actor.data.items, "Corps à corps");
armesList.push( { name: "Corps à corps", data: { niveau: cc.data.niveau, description: "", force: 6, competence: "Corps à corps", dommages: combatant.actor.data.data.attributs.plusdom.value } } );
armesList.push( { name: "Draconic", data: { initOnly: true, competence: "Draconic" } } );
let armes = items.filter(it => it.type =='arme')
.map(arme => duplicate(arme)) /* pas de changements aux armes d'origine */
.concat(RdDItemArme.mainsNues());
let competences = items.filter(it => it.type == 'competence');
actions = actions.concat(this._finalizeArmeList( armes, competences, actor.data.data.carac ));
actions.push( { name: "Draconic", data: { initOnly: true, competence: "Draconic" } } );
}
armesList.push( { name: "Autre action", data: { initOnly: true, competence: "Autre action" } } );
return armesList;
actions.push( { name: "Autre action", data: { initOnly: true, competence: "Autre action" } } );
for (let index = 0; index < actions.length; index++) {
actions[index].index = index;
}
return actions;
}
/* -------------------------------------------- */
static displayInitiativeMenu( html, combatantId) {
const combatant = game.combat.getCombatant(combatantId);
let armesList = this.buildArmeList( combatant );
let armesList = this.buildListeActionsCombat( combatant );
// Build the relevant submenu
if ( armesList ) {