Compare commits

..

2 Commits

10 changed files with 110 additions and 86 deletions

View File

@ -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,47 +302,48 @@ export class CombatActionDialog extends HandlebarsApplicationMixin(ApplicationV2
if (context.distanceUnit && this._actor.getActiveTokens()[0]?.id) {
context.tokenDistances = this.#evaluateDistances()
context.weapons = this.#evaluateWeapons()
if (this._targetId && this._weaponId && this._skillId) {
context.maneuver = this.#evaluateManeuvers()
}
const maneuver = this._maneuvers?.find(p => p.id === this._defenseManeuverId)
if (maneuver) {
context.canMod = maneuver.mod != undefined
}
context.targetNumber = context.weapons.find(p => p.weaponId === this._weaponId && p.skillId === this._skillId)?.combatStatistics.at
// TODO get W/M of weapon NOW
if (this._targetNumber >= 0 && this._targetId && this._weaponId && this._skillId && maneuver) {
context.ready = true
} else {
context.notReadyReason = `<em>${game.i18n.format("COMBAT_DIALOG.notReadyReason.title")}</em><ul>`
if (!this._targetId) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.noTarget")}</li>`
}
if (!this._weaponId) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.noWeapon")}</li>`
}
if (!this._skillId) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.noSkill")}</li>`
}
if (!maneuver) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.noManeuver")}</li>`
}
if (!this._targetNumber < 0) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.impossible")}</li>`
}
context.notReadyReason += "</ul>"
context.ready = false
}
return context
context.hasTokens = true
} else {
ui.notifications.error(`Feature funktioniert nur wenn der Akteur ein Token auf der aktuellen Szene hat`);
context.tokenDistances = []
context.hasTokens = false
}
context.weapons = this.#evaluateWeapons()
if ( (this._targetId || !context.hasTokens) && this._weaponId && this._skillId) {
context.maneuver = this.#evaluateManeuvers()
}
const maneuver = this._maneuvers?.find(p => p.id === this._defenseManeuverId)
if (maneuver) {
context.canMod = maneuver.mod != undefined
}
context.targetNumber = context.weapons.find(p => p.weaponId === this._weaponId && p.skillId === this._skillId)?.combatStatistics.at
// TODO get W/M of weapon NOW
if (this._targetNumber >= 0 && this._targetId && this._weaponId && this._skillId && maneuver) {
context.ready = true
} else {
context.notReadyReason = `<em>${game.i18n.format("COMBAT_DIALOG.notReadyReason.title")}</em><ul>`
if (!this._targetId) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.noTarget")}</li>`
}
if (!this._weaponId) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.noWeapon")}</li>`
}
if (!this._skillId) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.noSkill")}</li>`
}
if (!maneuver) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.noManeuver")}</li>`
}
if (!this._targetNumber < 0) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.impossible")}</li>`
}
context.notReadyReason += "</ul>"
context.ready = false
}
return context
}
#update(context) {

View File

@ -1,4 +1,4 @@
import {ActionManager} from "../sheets/actions/action-manager.mjs";
import {ActionManager} from "../sheets/actions/action-manager.mjs";
const {
ApplicationV2,
@ -236,49 +236,42 @@ 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()
context.weapons = this.#evaluateWeapons()
if (this._skillId) {
context.maneuver = this.#evaluateManeuvers()
}
const maneuver = this._maneuvers?.find(p => p.id === this._defenseManeuverId)
if (maneuver) {
context.canMod = maneuver.mod != undefined
}
context.targetNumber = context.weapons.find(p => ((this._weaponId != "") || p.weaponId === this._weaponId) && p.skillId === this._skillId)?.combatStatistics.pa
// TODO get W/M of weapon NOW
if (this._weaponId && this._skillId && this._defenseManeuverId) {
context.ready = true
} else {
context.notReadyReason = `<em>${game.i18n.format("COMBAT_DIALOG.notReadyReason.title")}</em><ul>`
if (!this._weaponId) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.noWeapon")}</li>`
}
if (!this._skillId) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.noSkill")}</li>`
}
if (!maneuver) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.noManeuver")}</li>`
}
if (!this._targetNumber < 0) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.impossible")}</li>`
}
context.notReadyReason += "</ul>"
context.ready = false
}
return context
} else {
ui.notifications.error(`Feature funktioniert nur wenn der Akteur ein Token auf der aktuellen Szene hat`);
if (this._skillId) {
context.maneuver = this.#evaluateManeuvers()
}
const maneuver = this._maneuvers?.find(p => p.id === this._defenseManeuverId)
if (maneuver) {
context.canMod = maneuver.mod != undefined
}
context.targetNumber = context.weapons.find(p => ((this._weaponId != "") || p.weaponId === this._weaponId) && p.skillId === this._skillId)?.combatStatistics.pa
// TODO get W/M of weapon NOW
if (this._weaponId && this._skillId && this._defenseManeuverId) {
context.ready = true
} else {
context.notReadyReason = `<em>${game.i18n.format("COMBAT_DIALOG.notReadyReason.title")}</em><ul>`
if (!this._weaponId) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.noWeapon")}</li>`
}
if (!this._skillId) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.noSkill")}</li>`
}
if (!maneuver) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.noManeuver")}</li>`
}
if (!this._targetNumber < 0) {
context.notReadyReason += `<li>${game.i18n.format("COMBAT_DIALOG.notReadyReason.impossible")}</li>`
}
context.notReadyReason += "</ul>"
context.ready = false
}
return context
}
#update(context) {

View File

@ -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()
}

View File

@ -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: [

View File

@ -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,

View File

@ -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}`
}

View File

@ -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>

View File

@ -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}}

View File

@ -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}}

View File

@ -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>