Nouveau roll-dialog: mode attaque / defense
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Misc } from "../misc.js"
|
||||
import { ReglesOptionnelles } from "../settings/regles-optionnelles.js"
|
||||
import { StatusEffects } from "../settings/status-effects.js"
|
||||
import { ROLL_MODE_ATTAQUE, ROLL_MODE_DEFENSE } from "./roll-constants.mjs"
|
||||
import { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs"
|
||||
@@ -22,11 +23,6 @@ export class RollPartSign extends RollPart {
|
||||
this.setSaved(targetData, this.getCurrent(rollData))
|
||||
}
|
||||
|
||||
// visible(rollData) {
|
||||
// const current = this.getCurrent(rollData)
|
||||
// return current.surprise != ''
|
||||
// }
|
||||
|
||||
isCombat(rollData) {
|
||||
return [ROLL_MODE_ATTAQUE, ROLL_MODE_DEFENSE].includes(rollData.mode.current) || rollData.mode.isCombat
|
||||
}
|
||||
@@ -42,41 +38,61 @@ export class RollPartSign extends RollPart {
|
||||
const actor = rollData.active.actor;
|
||||
const isCombat = this.isCombat(rollData)
|
||||
const current = this.getCurrent(rollData)
|
||||
current.armeDisparate = isCombat && current.armeDisparate
|
||||
current.forceRequise = current.forceRequise ?? 0
|
||||
current.surprise = actor.getSurprise(isCombat)
|
||||
current.reasons = actor.getEffects(it => StatusEffects.niveauSurprise(it) > 0).map(it => it.name)
|
||||
current.diviseur = 1
|
||||
if (isCombat && actor.isDemiReve()) {
|
||||
current.reasons.push('Demi-rêve en combat')
|
||||
}
|
||||
if (current.surprise == 'demi') {
|
||||
current.diviseur *= 2
|
||||
}
|
||||
|
||||
if (this.isAttaqueFinesse(rollData)) {
|
||||
current.diviseur *= 2
|
||||
current.reasons.push('Attaque en finesse')
|
||||
if (isCombat && actor.isDemiReve()) {
|
||||
current.reasons.push('Demi-rêve en combat')
|
||||
}
|
||||
if (this.isForceInsuffisante(rollData)) {
|
||||
if (this.isParadeArmeDisparate(current)) {
|
||||
current.diviseur *= 2
|
||||
current.reasons.push('Armes disparates')
|
||||
}
|
||||
if (this.isForceInsuffisante(actor, current)) {
|
||||
current.diviseur *= 2
|
||||
current.reasons.push('Force insuffisante')
|
||||
}
|
||||
if (this.isAttaqueFinesse(rollData)) {
|
||||
current.diviseur *= 2
|
||||
current.reasons.push('Particulière en finesse')
|
||||
}
|
||||
|
||||
if (!ReglesOptionnelles.isUsing('tripleSignificative')) {
|
||||
current.diviseur = Math.min(current.diviseur, 4);
|
||||
}
|
||||
|
||||
current.reason = current.reasons.join(', ')
|
||||
}
|
||||
|
||||
isForceInsuffisante(rollData) {
|
||||
//this.isCombat(rollData) && ... arme avec force min
|
||||
return this.isCombat(rollData) && true
|
||||
isAttaqueFinesse(rollData) {
|
||||
return ROLL_MODE_DEFENSE == rollData.mode.current && rollData.attaque.particuliere == 'finesse'
|
||||
}
|
||||
|
||||
isAttaqueFinesse(rollData) {
|
||||
// this.rollData.selected[PART_DEFENSE] && attaquant avec particulière en finesse
|
||||
return ROLL_MODE_DEFENSE == rollData.mode.current && true
|
||||
isForceInsuffisante(actor, current) {
|
||||
if (actor?.isPersonnage()) {
|
||||
const requise = current.forceRequise
|
||||
const force = parseInt(actor.system.carac.force.value)
|
||||
return requise > force
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
isParadeArmeDisparate(current) {
|
||||
return current.armeDisparate
|
||||
}
|
||||
|
||||
getAjustements(rollData) {
|
||||
const current = this.getCurrent(rollData)
|
||||
if (current.surprise == 'demi') {
|
||||
return [{ label: 'Significative requise ' + Misc.getFractionOneN(current.diviseur), diff: undefined }]
|
||||
return [
|
||||
{ label: 'Significative requise ' + Misc.getFractionOneN(current.diviseur), diff: undefined },
|
||||
...current.reasons.map(it => { return { label: '<i class="fa-solid fa-triangle-exclamation"></i> ' + it, diff: undefined } })
|
||||
]
|
||||
}
|
||||
return []
|
||||
}
|
||||
@@ -90,4 +106,9 @@ export class RollPartSign extends RollPart {
|
||||
})
|
||||
}
|
||||
|
||||
setArme(rollData, forceRequise, armeDisparate) {
|
||||
const current = this.getCurrent(rollData)
|
||||
current.armeDisparate = armeDisparate
|
||||
current.forceRequise = forceRequise
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user