Préparation roll-dialog attaques
Les attaques ne sont plus des armes modifiées
This commit is contained in:
@@ -45,6 +45,7 @@ import { DialogSelect } from "./dialog-select.js";
|
||||
import { PAS_DE_DRACONIC, POSSESSION_SANS_DRACONIC } from "./item/base-items.js";
|
||||
|
||||
import { RdDRollResult } from "./rdd-roll-result.js";
|
||||
import { RdDInitiative } from "./initiative.mjs";
|
||||
|
||||
export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre']
|
||||
|
||||
@@ -131,19 +132,13 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
.reduce(Misc.sum(), 0);
|
||||
}
|
||||
|
||||
listActionsCombat() {
|
||||
listActions({ isAttaque = false, isEquipe = false }) {
|
||||
// Recupération des armes
|
||||
const actions = RdDCombatManager.listActionsArmes(
|
||||
this.itemTypes[ITEM_TYPES.arme]
|
||||
.filter(it => RdDItemArme.isAttaque(it))
|
||||
.concat(RdDItemArme.corpsACorps(this))
|
||||
.concat(RdDItemArme.empoignade(this))
|
||||
,
|
||||
this.itemTypes[ITEM_TYPES.competence],
|
||||
this.system.carac)
|
||||
const actions = this.listActionsAttaque()
|
||||
.filter(it => !isEquipe || it.arme.system.equipe)
|
||||
|
||||
if (this.system.attributs.hautrevant.value) {
|
||||
actions.push({ name: "Draconic", action: 'haut-reve', system: { initOnly: true, competence: "Draconic" } });
|
||||
if (!isAttaque && this.system.attributs.hautrevant.value) {
|
||||
actions.push({ name: "Draconic", action: 'haut-reve', initOnly: true })
|
||||
}
|
||||
return actions
|
||||
}
|
||||
@@ -168,6 +163,86 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
.find(it => true)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** Retourne une liste triée d'actions d'armes avec le split arme1 main / arme 2 main / lancer */
|
||||
listActionsAttaque() {
|
||||
let actions = [
|
||||
this.$prepareAttaqueArme(RdDItemArme.empoignade(this)),
|
||||
this.$prepareAttaqueArme(RdDItemArme.corpsACorps(this)),
|
||||
]
|
||||
|
||||
const armes = this.itemTypes[ITEM_TYPES.arme]
|
||||
.filter(it => RdDItemArme.isAttaque(it))
|
||||
.sort(Misc.ascending(it => it.name));
|
||||
|
||||
for (const arme of armes) {
|
||||
if (arme.system.unemain && arme.system.competence) {
|
||||
actions.push(this.$prepareAttaqueArme(arme, '(1 main)'))
|
||||
}
|
||||
if (arme.system.deuxmains && arme.system.competence) {
|
||||
actions.push(this.$prepareAttaqueArme(arme, '(2 mains)'))
|
||||
}
|
||||
if (arme.system.lancer) {
|
||||
actions.push(this.$prepareAttaqueArme(arme, '(lancer)'))
|
||||
}
|
||||
if (arme.system.tir) {
|
||||
actions.push(this.$prepareAttaqueArme(arme, '(tir)'))
|
||||
}
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
$prepareAttaqueArme(arme, main) {
|
||||
const comp = this.getCompetence(RdDActor.$getCompetenceAction(arme, main))
|
||||
const caracCode = RdDActor.$getCaracAction(comp, main)
|
||||
const caracValue = this.system.carac[caracCode].value
|
||||
const dommages = arme.system.dommages.toString()
|
||||
|
||||
// TODO: déplacer sur RdDItemArme
|
||||
if (arme.system.unemain && arme.system.deuxmains && !dommages.includes("/")) {
|
||||
ui.notifications.info(`Les dommages de l'arme à 1/2 mains ${arme.name} ne sont pas corrects (ie sous la forme X/Y)`)
|
||||
}
|
||||
const tableauDommages = dommages.includes("/") ? dommages.split("/") : [dommages, dommages]
|
||||
const dmg = main == '(2 mains)' ? tableauDommages[1] : tableauDommages[0]
|
||||
const niveau = comp?.system.niveau ?? (['(lancer)', '(tir)'].includes(main) ? -8 : -6)
|
||||
const ajustement = (arme.parent?.getEtatGeneral() ?? 0) + (arme.system.magique) ? arme.system.ecaille_efficacite : 0
|
||||
|
||||
return {
|
||||
name: arme.name + (main ? ' ' + main : ''),
|
||||
action: 'attaque',
|
||||
initOnly: false,
|
||||
arme: arme,
|
||||
comp: comp,
|
||||
main: main,
|
||||
carac: { key: caracCode, value: caracValue },
|
||||
equipe: arme.system.equipe,
|
||||
dmg: dmg,
|
||||
initiative: RdDInitiative.calculInitiative(niveau, caracValue, ajustement)
|
||||
}
|
||||
}
|
||||
|
||||
static $getCaracAction(comp, main) {
|
||||
if (comp?.system.defaut_carac) {
|
||||
return comp.system.defaut_carac
|
||||
}
|
||||
switch (main) {
|
||||
case '(lancer)': return 'lancer'
|
||||
case '(tir)': return 'tir'
|
||||
default: return 'melee'
|
||||
}
|
||||
}
|
||||
|
||||
static $getCompetenceAction(arme, main) {
|
||||
switch (main) {
|
||||
case '(1 main)': return arme.competence1Mains()
|
||||
case '(2 mains)': return arme.competence2Mains()
|
||||
case '(lancer)': return arme.system.lancer
|
||||
case '(tir)': return arme.system.tir
|
||||
default: return arme.system.competence
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async $perteReveEnchantementsChateauDormants() {
|
||||
const toUpdate = this.items.filter(it => [ITEM_TYPES.potion, ITEM_TYPES.gemme].includes(it.type))
|
||||
|
Reference in New Issue
Block a user