Nouveau roll-dialog: mode attaque
This commit is contained in:
104
module/actor.js
104
module/actor.js
@@ -170,60 +170,59 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
/* -------------------------------------------- */
|
||||
/** 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 actions = []
|
||||
const uniques = []
|
||||
|
||||
const armes = this.itemTypes[ITEM_TYPES.arme]
|
||||
const addAttaque = (arme, main) => {
|
||||
const dommages = arme.system.dommages.toString()
|
||||
const tableauDommages = dommages.includes("/") ? dommages.split("/") : [dommages, dommages]
|
||||
const dommagesArme = parseInt(main == '(2 mains)' ? tableauDommages[1] : tableauDommages[0])
|
||||
const magieEfficacite = arme.system.magique ? arme.system.ecaille_efficacite : 0;
|
||||
|
||||
const comp = this.getCompetence(RdDActor.$getCompetenceAction(arme, main))
|
||||
const unique = [comp.id, arme.name, dommagesArme, magieEfficacite].join('|');
|
||||
if (uniques.includes(unique)) {
|
||||
return
|
||||
}
|
||||
uniques.push(unique);
|
||||
|
||||
const caracCode = RdDActor.$getCaracAction(comp, main)
|
||||
const caracValue = this.system.carac[caracCode].value
|
||||
|
||||
// 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 niveau = comp?.system.niveau ?? (['(lancer)', '(tir)'].includes(main) ? -8 : -6)
|
||||
const ajustement = (arme.parent?.getEtatGeneral() ?? 0) + magieEfficacite
|
||||
|
||||
actions.push({
|
||||
name: arme.name + (main ? ' ' + main : ''),
|
||||
action: 'attaque',
|
||||
initOnly: false,
|
||||
arme: arme,
|
||||
comp: comp,
|
||||
main: main,
|
||||
carac: { key: caracCode, value: caracValue },
|
||||
equipe: arme.system.equipe,
|
||||
dommagesArme: dommagesArme,
|
||||
initiative: RdDInitiative.calculInitiative(niveau, caracValue, ajustement)
|
||||
})
|
||||
}
|
||||
|
||||
addAttaque(RdDItemArme.empoignade(this))
|
||||
addAttaque(RdDItemArme.corpsACorps(this))
|
||||
|
||||
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)
|
||||
}
|
||||
.sort(Misc.ascending(it => it.name))
|
||||
.forEach(arme => {
|
||||
if (arme.system.unemain && arme.system.competence) { addAttaque(arme, '(1 main)') }
|
||||
if (arme.system.deuxmains && arme.system.competence) { addAttaque(arme, '(2 mains)') }
|
||||
if (arme.system.lancer) { addAttaque(arme, '(lancer)') }
|
||||
if (arme.system.tir) { addAttaque(arme, '(tir)') }
|
||||
})
|
||||
return actions
|
||||
}
|
||||
|
||||
static $getCaracAction(comp, main) {
|
||||
@@ -3249,3 +3248,4 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user