adds combat-awareness to attacks/defenses/spells/liturgies
parent
f8d101bfe3
commit
469025ca05
|
|
@ -59,6 +59,9 @@ export class CombatActionDialog extends HandlebarsApplicationMixin(ApplicationV2
|
|||
this._defenseManeuverId = null
|
||||
this._actionManager = new ActionManager(this._actor)
|
||||
CombatActionDialog._instance = this
|
||||
if (!game.scenes.current?.grid.units) {
|
||||
this._targetId = actor._id
|
||||
}
|
||||
}
|
||||
|
||||
static _instance = null
|
||||
|
|
@ -106,7 +109,7 @@ export class CombatActionDialog extends HandlebarsApplicationMixin(ApplicationV2
|
|||
const maneuver = CombatActionDialog._instance.#evaluateManeuvers().find(p => p.id === this._defenseManeuverId)
|
||||
const weapon = this._actor.itemTypes["Equipment"].find(p => p._id === this._weaponId)
|
||||
const skill = this._actor.itemTypes["Skill"].find(p => p._id === this._skillId)
|
||||
const target = game.actors.get(game.scenes.current.tokens.find(p => p._id === this._targetId).actorId)
|
||||
const target = game.actors.get(game.scenes.current.tokens.find(p => p._id === this._targetId)?.actorId) ?? this._actor
|
||||
if (maneuver.cost !== ActionManager.CONTINUING) {
|
||||
this._actor.rollAttack({
|
||||
weapon: this._weaponId,
|
||||
|
|
@ -123,10 +126,15 @@ export class CombatActionDialog extends HandlebarsApplicationMixin(ApplicationV2
|
|||
return true
|
||||
} else { // push into cooldown queue
|
||||
const cooldowns = this._actor.system.cooldowns
|
||||
let currentCooldown = 0
|
||||
if (game.combats.size === 0) { // no combat started
|
||||
currentCooldown = maneuver.cooldown({weapon, skill, target, mod: this._mod})
|
||||
}
|
||||
|
||||
/** @type Cooldown */
|
||||
const newCooldown = {
|
||||
start: maneuver.cooldown({weapon, skill, target, mod: this._mod}),
|
||||
current: 0,
|
||||
current: currentCooldown,
|
||||
data: {
|
||||
cssClass: "Kampf",
|
||||
weapon: this._weaponId,
|
||||
|
|
@ -138,6 +146,7 @@ export class CombatActionDialog extends HandlebarsApplicationMixin(ApplicationV2
|
|||
circumstance: this._circumstance,
|
||||
penalty: this._penalty,
|
||||
targetNumber: this._targetNumber,
|
||||
castingTime: maneuver.cooldown({weapon, skill, target, mod: this._mod}),
|
||||
modDescription: maneuver?.modDescription?.replace("{}", "" + this._mod) ?? ""
|
||||
}
|
||||
}
|
||||
|
|
@ -261,7 +270,7 @@ export class CombatActionDialog extends HandlebarsApplicationMixin(ApplicationV2
|
|||
const manager = this._actionManager
|
||||
const weapon = this._actor.itemTypes["Equipment"].find(p => p._id === this._weaponId)
|
||||
const skill = this._actor.itemTypes["Skill"].find(p => p._id === this._skillId)
|
||||
const target = game.actors.get(game.scenes.current.tokens.find(p => p._id === this._targetId).actorId)
|
||||
const target = game.actors.get(game.scenes.current.tokens.find(p => p._id === this._targetId)?.actorId) ?? this._actor
|
||||
this._maneuvers = manager.evaluate({
|
||||
target,
|
||||
weapon,
|
||||
|
|
@ -293,9 +302,14 @@ export class CombatActionDialog extends HandlebarsApplicationMixin(ApplicationV2
|
|||
if (context.distanceUnit && this._actor.getActiveTokens()[0]?.id) {
|
||||
|
||||
context.tokenDistances = this.#evaluateDistances()
|
||||
context.hasTokens = true
|
||||
} else {
|
||||
context.tokenDistances = []
|
||||
context.hasTokens = false
|
||||
}
|
||||
context.weapons = this.#evaluateWeapons()
|
||||
|
||||
if (this._targetId && this._weaponId && this._skillId) {
|
||||
if ( (this._targetId || !context.hasTokens) && this._weaponId && this._skillId) {
|
||||
context.maneuver = this.#evaluateManeuvers()
|
||||
}
|
||||
const maneuver = this._maneuvers?.find(p => p.id === this._defenseManeuverId)
|
||||
|
|
@ -330,10 +344,6 @@ export class CombatActionDialog extends HandlebarsApplicationMixin(ApplicationV2
|
|||
context.ready = false
|
||||
}
|
||||
return context
|
||||
} else {
|
||||
ui.notifications.error(`Feature funktioniert nur wenn der Akteur ein Token auf der aktuellen Szene hat`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#update(context) {
|
||||
|
|
|
|||
|
|
@ -236,9 +236,6 @@ export class DefenseActionDialog extends HandlebarsApplicationMixin(ApplicationV
|
|||
const context = await super._prepareContext(options)
|
||||
|
||||
context.actor = this._actor
|
||||
context.distanceUnit = game.scenes.current.grid.units
|
||||
|
||||
if (this._actor.getActiveTokens()[0]?.id) {
|
||||
|
||||
context.weapons = this.#evaluateWeapons()
|
||||
|
||||
|
|
@ -275,10 +272,6 @@ export class DefenseActionDialog extends HandlebarsApplicationMixin(ApplicationV
|
|||
}
|
||||
|
||||
return context
|
||||
} else {
|
||||
ui.notifications.error(`Feature funktioniert nur wenn der Akteur ein Token auf der aktuellen Szene hat`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#update(context) {
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ export class LiturgyDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
eigenschaft3: "ch"
|
||||
}).evaluate("publicroll").then(result => {
|
||||
const context = {
|
||||
...data,
|
||||
liturgy: data.title,
|
||||
lkw: data.taw,
|
||||
mod: data.mod,
|
||||
|
|
@ -185,9 +186,14 @@ export class LiturgyDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
|
||||
})
|
||||
}
|
||||
|
||||
let currentCooldown = 0
|
||||
if (game.combats.size === 0) { // no combat started
|
||||
currentCooldown = castingTime
|
||||
}
|
||||
cooldowns.push({
|
||||
start: castingTime,
|
||||
current: 0,
|
||||
current: currentCooldown,
|
||||
data: {
|
||||
cssClass: "Karmal",
|
||||
title: this._liturgy.name,
|
||||
|
|
@ -205,6 +211,7 @@ export class LiturgyDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
eigenschaft2: "in",
|
||||
eigenschaft3: "ch",
|
||||
circumstance: circumstance,
|
||||
castingTime: castingTime,
|
||||
maneuver: m.toString()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
}
|
||||
|
||||
let message = this._spell.system.wirkung
|
||||
if (this._activeVariants.length > 0) {
|
||||
if (this._activeVariants?.length > 0 ?? false) {
|
||||
message += "<hr/>"
|
||||
message += this._activeVariants.map(v => v.name).join(", ")
|
||||
}
|
||||
|
|
@ -231,9 +231,14 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
|
||||
message += "<hr/>" + this.zfp + " ZfP*<br/>" + this._spell.system.zfw + " ZfW"
|
||||
|
||||
let currentCooldown = 0
|
||||
if (game.combats.size === 0) { // no combat started
|
||||
currentCooldown = this.castingTime
|
||||
}
|
||||
|
||||
cooldowns.push({
|
||||
start: this.castingTime,
|
||||
current: 0,
|
||||
current: currentCooldown,
|
||||
data: {
|
||||
cssClass: "Magisch",
|
||||
title: this._spell.name,
|
||||
|
|
@ -242,6 +247,7 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
actorId: this._actor._id,
|
||||
spellId: this._spell._id,
|
||||
message,
|
||||
castingTime: this.castingTime,
|
||||
maneuver: m.toString()
|
||||
}
|
||||
|
||||
|
|
@ -270,6 +276,7 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
|
||||
const context = {
|
||||
spell: this._spell,
|
||||
castingTime : this.castingTime,
|
||||
zfp: result.tap,
|
||||
|
||||
ergebnis: [
|
||||
|
|
|
|||
|
|
@ -493,6 +493,7 @@ export class Character extends Actor {
|
|||
})
|
||||
|
||||
const context = {
|
||||
...data,
|
||||
weapon: weapon.name,
|
||||
maneuver,
|
||||
target: this.name,
|
||||
|
|
@ -539,6 +540,7 @@ export class Character extends Actor {
|
|||
})
|
||||
|
||||
const context = {
|
||||
...data,
|
||||
weapon: weapon.name,
|
||||
maneuver,
|
||||
target: target.name,
|
||||
|
|
|
|||
|
|
@ -595,7 +595,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
|||
weapon = this.document.itemTypes["Equipment"].find(p => p._id === cooldown.data.weapon)
|
||||
tooltip += `<br/>Waffe: ${weapon.name}`
|
||||
}
|
||||
if (cooldown.data.target) {
|
||||
if (cooldown.data.target && game.scenes.current.tokens.length > 0) {
|
||||
target = game.actors.get(game.scenes.current.tokens.find(p => p._id === cooldown.data.target).actorId)
|
||||
tooltip += `<br/>Ziel: ${target.name}`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<div>Gewürfelt: {{die}}</div>
|
||||
<div>Erschwernis: {{circumstance}}</div>
|
||||
<div>Modifikation: {{mod}}</div>
|
||||
<div>Dauer in Aktionen: {{castingTime}}</div>
|
||||
<hr>
|
||||
{{#if missing}}
|
||||
<div>Gefehlt: {{missing}} {{#if fumble}}Patzer{{/if}}</div>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
<div>
|
||||
<div>{{liturgy}} (LkP*: {{lkp}})</div>
|
||||
<div>Modifiziert: {{mod}}</div>
|
||||
<div>Dauer in Aktionen: {{castingTime}}</div>
|
||||
<div>Gewürfelt:</div>
|
||||
<hr>
|
||||
{{#if missing}}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
<div>
|
||||
<div>{{spell.name}} (ZfP*: {{zfp}})</div>
|
||||
<div>Modifiziert: {{mod}}</div>
|
||||
<div>Zauberdauer: {{castingTime}}</div>
|
||||
<div>Gewürfelt:</div>
|
||||
<section class="die">
|
||||
{{#each ergebnis}}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
<section>
|
||||
|
||||
{{#if hasTokens}}
|
||||
<fieldset>
|
||||
|
||||
<legend>Ziel auswählen</legend>
|
||||
|
||||
<ul>
|
||||
|
|
@ -13,7 +15,7 @@
|
|||
</ul>
|
||||
|
||||
</fieldset>
|
||||
|
||||
{{/if}}
|
||||
<fieldset>
|
||||
<legend>Waffe auswählen</legend>
|
||||
<ul>
|
||||
|
|
|
|||
Loading…
Reference in New Issue