Compare commits

..

No commits in common. "7a3ebf90062c6769bc9da0b6eda61aabcec86270" and "5f41236a70da2ef78d6916d806d91a6e00652e85" have entirely different histories.

10 changed files with 82 additions and 106 deletions

View File

@ -59,9 +59,6 @@ export class CombatActionDialog extends HandlebarsApplicationMixin(ApplicationV2
this._defenseManeuverId = null this._defenseManeuverId = null
this._actionManager = new ActionManager(this._actor) this._actionManager = new ActionManager(this._actor)
CombatActionDialog._instance = this CombatActionDialog._instance = this
if (!game.scenes.current?.grid.units) {
this._targetId = actor._id
}
} }
static _instance = null static _instance = null
@ -109,7 +106,7 @@ export class CombatActionDialog extends HandlebarsApplicationMixin(ApplicationV2
const maneuver = CombatActionDialog._instance.#evaluateManeuvers().find(p => p.id === this._defenseManeuverId) const maneuver = CombatActionDialog._instance.#evaluateManeuvers().find(p => p.id === this._defenseManeuverId)
const weapon = this._actor.itemTypes["Equipment"].find(p => p._id === this._weaponId) 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 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) ?? this._actor const target = game.actors.get(game.scenes.current.tokens.find(p => p._id === this._targetId).actorId)
if (maneuver.cost !== ActionManager.CONTINUING) { if (maneuver.cost !== ActionManager.CONTINUING) {
this._actor.rollAttack({ this._actor.rollAttack({
weapon: this._weaponId, weapon: this._weaponId,
@ -126,15 +123,10 @@ export class CombatActionDialog extends HandlebarsApplicationMixin(ApplicationV2
return true return true
} else { // push into cooldown queue } else { // push into cooldown queue
const cooldowns = this._actor.system.cooldowns 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 */ /** @type Cooldown */
const newCooldown = { const newCooldown = {
start: maneuver.cooldown({weapon, skill, target, mod: this._mod}), start: maneuver.cooldown({weapon, skill, target, mod: this._mod}),
current: currentCooldown, current: 0,
data: { data: {
cssClass: "Kampf", cssClass: "Kampf",
weapon: this._weaponId, weapon: this._weaponId,
@ -146,7 +138,6 @@ export class CombatActionDialog extends HandlebarsApplicationMixin(ApplicationV2
circumstance: this._circumstance, circumstance: this._circumstance,
penalty: this._penalty, penalty: this._penalty,
targetNumber: this._targetNumber, targetNumber: this._targetNumber,
castingTime: maneuver.cooldown({weapon, skill, target, mod: this._mod}),
modDescription: maneuver?.modDescription?.replace("{}", "" + this._mod) ?? "" modDescription: maneuver?.modDescription?.replace("{}", "" + this._mod) ?? ""
} }
} }
@ -270,7 +261,7 @@ export class CombatActionDialog extends HandlebarsApplicationMixin(ApplicationV2
const manager = this._actionManager const manager = this._actionManager
const weapon = this._actor.itemTypes["Equipment"].find(p => p._id === this._weaponId) 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 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) ?? this._actor const target = game.actors.get(game.scenes.current.tokens.find(p => p._id === this._targetId).actorId)
this._maneuvers = manager.evaluate({ this._maneuvers = manager.evaluate({
target, target,
weapon, weapon,
@ -302,48 +293,47 @@ export class CombatActionDialog extends HandlebarsApplicationMixin(ApplicationV2
if (context.distanceUnit && this._actor.getActiveTokens()[0]?.id) { if (context.distanceUnit && this._actor.getActiveTokens()[0]?.id) {
context.tokenDistances = this.#evaluateDistances() context.tokenDistances = this.#evaluateDistances()
context.hasTokens = true 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
} else { } else {
context.tokenDistances = [] ui.notifications.error(`Feature funktioniert nur wenn der Akteur ein Token auf der aktuellen Szene hat`);
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) { #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 { const {
ApplicationV2, ApplicationV2,
@ -236,42 +236,49 @@ export class DefenseActionDialog extends HandlebarsApplicationMixin(ApplicationV
const context = await super._prepareContext(options) const context = await super._prepareContext(options)
context.actor = this._actor context.actor = this._actor
context.distanceUnit = game.scenes.current.grid.units
context.weapons = this.#evaluateWeapons() if (this._actor.getActiveTokens()[0]?.id) {
if (this._skillId) { context.weapons = this.#evaluateWeapons()
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 if (this._skillId) {
context.maneuver = this.#evaluateManeuvers()
}
const maneuver = this._maneuvers?.find(p => p.id === this._defenseManeuverId)
if (maneuver) {
context.canMod = maneuver.mod != undefined
}
// TODO get W/M of weapon NOW context.targetNumber = context.weapons.find(p => ((this._weaponId != "") || p.weaponId === this._weaponId) && p.skillId === this._skillId)?.combatStatistics.pa
if (this._weaponId && this._skillId && this._defenseManeuverId) { // TODO get W/M of weapon NOW
context.ready = true
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 { } else {
context.notReadyReason = `<em>${game.i18n.format("COMBAT_DIALOG.notReadyReason.title")}</em><ul>` ui.notifications.error(`Feature funktioniert nur wenn der Akteur ein Token auf der aktuellen Szene hat`);
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) { #update(context) {

View File

@ -157,7 +157,6 @@ export class LiturgyDialog extends HandlebarsApplicationMixin(ApplicationV2) {
eigenschaft3: "ch" eigenschaft3: "ch"
}).evaluate("publicroll").then(result => { }).evaluate("publicroll").then(result => {
const context = { const context = {
...data,
liturgy: data.title, liturgy: data.title,
lkw: data.taw, lkw: data.taw,
mod: data.mod, mod: data.mod,
@ -186,14 +185,9 @@ export class LiturgyDialog extends HandlebarsApplicationMixin(ApplicationV2) {
}) })
} }
let currentCooldown = 0
if (game.combats.size === 0) { // no combat started
currentCooldown = castingTime
}
cooldowns.push({ cooldowns.push({
start: castingTime, start: castingTime,
current: currentCooldown, current: 0,
data: { data: {
cssClass: "Karmal", cssClass: "Karmal",
title: this._liturgy.name, title: this._liturgy.name,
@ -211,7 +205,6 @@ export class LiturgyDialog extends HandlebarsApplicationMixin(ApplicationV2) {
eigenschaft2: "in", eigenschaft2: "in",
eigenschaft3: "ch", eigenschaft3: "ch",
circumstance: circumstance, circumstance: circumstance,
castingTime: castingTime,
maneuver: m.toString() maneuver: m.toString()
} }

View File

@ -209,7 +209,7 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
} }
let message = this._spell.system.wirkung let message = this._spell.system.wirkung
if (this._activeVariants?.length > 0 ?? false) { if (this._activeVariants.length > 0) {
message += "<hr/>" message += "<hr/>"
message += this._activeVariants.map(v => v.name).join(", ") message += this._activeVariants.map(v => v.name).join(", ")
} }
@ -231,14 +231,9 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
message += "<hr/>" + this.zfp + " ZfP*<br/>" + this._spell.system.zfw + " ZfW" 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({ cooldowns.push({
start: this.castingTime, start: this.castingTime,
current: currentCooldown, current: 0,
data: { data: {
cssClass: "Magisch", cssClass: "Magisch",
title: this._spell.name, title: this._spell.name,
@ -247,7 +242,6 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
actorId: this._actor._id, actorId: this._actor._id,
spellId: this._spell._id, spellId: this._spell._id,
message, message,
castingTime: this.castingTime,
maneuver: m.toString() maneuver: m.toString()
} }
@ -276,7 +270,6 @@ export class SpellDialog extends HandlebarsApplicationMixin(ApplicationV2) {
const context = { const context = {
spell: this._spell, spell: this._spell,
castingTime : this.castingTime,
zfp: result.tap, zfp: result.tap,
ergebnis: [ ergebnis: [

View File

@ -493,7 +493,6 @@ export class Character extends Actor {
}) })
const context = { const context = {
...data,
weapon: weapon.name, weapon: weapon.name,
maneuver, maneuver,
target: this.name, target: this.name,
@ -540,7 +539,6 @@ export class Character extends Actor {
}) })
const context = { const context = {
...data,
weapon: weapon.name, weapon: weapon.name,
maneuver, maneuver,
target: target.name, 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) weapon = this.document.itemTypes["Equipment"].find(p => p._id === cooldown.data.weapon)
tooltip += `<br/>Waffe: ${weapon.name}` tooltip += `<br/>Waffe: ${weapon.name}`
} }
if (cooldown.data.target && game.scenes.current.tokens.length > 0) { if (cooldown.data.target) {
target = game.actors.get(game.scenes.current.tokens.find(p => p._id === cooldown.data.target).actorId) target = game.actors.get(game.scenes.current.tokens.find(p => p._id === cooldown.data.target).actorId)
tooltip += `<br/>Ziel: ${target.name}` tooltip += `<br/>Ziel: ${target.name}`
} }

View File

@ -5,7 +5,6 @@
<div>Gewürfelt: {{die}}</div> <div>Gewürfelt: {{die}}</div>
<div>Erschwernis: {{circumstance}}</div> <div>Erschwernis: {{circumstance}}</div>
<div>Modifikation: {{mod}}</div> <div>Modifikation: {{mod}}</div>
<div>Dauer in Aktionen: {{castingTime}}</div>
<hr> <hr>
{{#if missing}} {{#if missing}}
<div>Gefehlt: {{missing}} {{#if fumble}}Patzer{{/if}}</div> <div>Gefehlt: {{missing}} {{#if fumble}}Patzer{{/if}}</div>

View File

@ -3,7 +3,6 @@
<div> <div>
<div>{{liturgy}} (LkP*: {{lkp}})</div> <div>{{liturgy}} (LkP*: {{lkp}})</div>
<div>Modifiziert: {{mod}}</div> <div>Modifiziert: {{mod}}</div>
<div>Dauer in Aktionen: {{castingTime}}</div>
<div>Gewürfelt:</div> <div>Gewürfelt:</div>
<hr> <hr>
{{#if missing}} {{#if missing}}

View File

@ -3,7 +3,6 @@
<div> <div>
<div>{{spell.name}} (ZfP*: {{zfp}})</div> <div>{{spell.name}} (ZfP*: {{zfp}})</div>
<div>Modifiziert: {{mod}}</div> <div>Modifiziert: {{mod}}</div>
<div>Zauberdauer: {{castingTime}}</div>
<div>Gewürfelt:</div> <div>Gewürfelt:</div>
<section class="die"> <section class="die">
{{#each ergebnis}} {{#each ergebnis}}

View File

@ -1,8 +1,6 @@
<section> <section>
{{#if hasTokens}}
<fieldset> <fieldset>
<legend>Ziel auswählen</legend> <legend>Ziel auswählen</legend>
<ul> <ul>
@ -15,7 +13,7 @@
</ul> </ul>
</fieldset> </fieldset>
{{/if}}
<fieldset> <fieldset>
<legend>Waffe auswählen</legend> <legend>Waffe auswählen</legend>
<ul> <ul>