Gestion attaques v2 et initiative
This commit is contained in:
@@ -1,7 +1,65 @@
|
||||
export const MAP_PHASE = {
|
||||
possession: { label: "possession", rang: 10 },
|
||||
draconic: { label: "draconic", rang: 9 },
|
||||
tir: { label: "tir", rang: 8 },
|
||||
lancer: { label: "lancer", rang: 7 },
|
||||
arme: { label: "mêlée", rang: 5 },
|
||||
pugilat: { label: "pugilat", rang: 4 },
|
||||
naturelle: { label: "créature", rang: 4 },
|
||||
empoignade: { label: "empoignade", rang: 3 },
|
||||
autre: { label: "autre action", rang: 2 },
|
||||
demi: { label: "demi-surprise", rang: 0 },
|
||||
totale: { label: "surprise totale", rang: -1 },
|
||||
}
|
||||
export const PHASE = Object.values(MAP_PHASE)
|
||||
|
||||
export class RdDInitiative {
|
||||
|
||||
static calculInitiative(niveau, caracValue, bonus = 0) {
|
||||
let base = niveau + Math.floor(caracValue / 2) + bonus;
|
||||
return "1d6" + (base >= 0 ? "+" : "") + base;
|
||||
static getRollInitiative(caracValue, niveau, bonus = 0) {
|
||||
const base = RdDInitiative.ajustementInitiative(caracValue, niveau, bonus)
|
||||
return "1d6" + (base >= 0 ? "+" : "") + base
|
||||
}
|
||||
|
||||
static ajustementInitiative(caracValue, niveau, bonus) {
|
||||
return niveau + Math.floor(caracValue / 2) + bonus
|
||||
}
|
||||
|
||||
static formule(phase, carac, niveau, bonusMalus) {
|
||||
const ajustement = RdDInitiative.ajustementInitiative(carac, niveau, bonusMalus)
|
||||
return { phase, ajustement }
|
||||
}
|
||||
|
||||
static phaseArme(categorie, arme) {
|
||||
switch (categorie) {
|
||||
case "tir":
|
||||
case "lancer":
|
||||
return MAP_PHASE[categorie]
|
||||
default:
|
||||
switch (arme.system.cac) {
|
||||
case "empoignade":
|
||||
case "pugilat":
|
||||
case "naturelle":
|
||||
return MAP_PHASE[arme.system.cac]
|
||||
default:
|
||||
return MAP_PHASE['arme']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static phase(keyOrRang) {
|
||||
return MAP_PHASE[keyOrRang] ?? PHASE.find(it => it.rang == keyOrRang) ?? MAP_PHASE.autre
|
||||
}
|
||||
|
||||
static async roll(formule) {
|
||||
const sign = formule.ajustement >= 0 ? "+" : ""
|
||||
const roll = new Roll(`1d6 + ${sign} + ${formule.ajustement}`)
|
||||
await roll.evaluate()
|
||||
const value = Math.max(roll.total, 0)
|
||||
return {
|
||||
roll: roll,
|
||||
value: value,
|
||||
init: formule.phase.rang + value / 100,
|
||||
label: formule.phase.label
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user