Compare commits

..

No commits in common. "5d8e34ce5fa6240e46ee64b2e7f4b398e3f32909" and "753b934534aa33acdd602d932c5f83b2f0cdec6a" have entirely different histories.

5 changed files with 21 additions and 37 deletions

View file

@ -1,8 +1,7 @@
{
"compilerOptions": {
"module": "es2022",
"target": "ES2022",
"strict": true
"target": "ES2022"
},
"exclude": ["node_modules", "dist"],
"include": ["src", "client", "common"]

View file

@ -11,35 +11,23 @@
}
],
"url": "https://git.f3l.de/dungeonslayers/tickwerk",
"license": "https://git.f3l.de/dungeonslayers/tickwerk/raw/tag/1.3.4/LICENSE.md",
"readme": "https://git.f3l.de/dungeonslayers/tickwerk/raw/tag/1.3.4/README.md",
"license": "https://git.f3l.de/dungeonslayers/tickwerk/raw/tag/1.3.3/LICENSE.md",
"readme": "https://git.f3l.de/dungeonslayers/tickwerk/raw/tag/1.3.3/README.md",
"bugs": "https://git.f3l.de/dungeonslayers/tickwerk/issues",
"changelog": "https://git.f3l.de/dungeonslayers/tickwerk/releases/tag/1.3.4",
"version": "1.3.4",
"changelog": "https://git.f3l.de/dungeonslayers/tickwerk/releases/tag/1.3.3",
"version": "1.3.3",
"flags": {
"hotReload": {
"extensions": [
"css",
"hbs",
"json"
],
"paths": [
"templates",
"css",
"lang"
]
"extensions": ["css", "hbs", "json"],
"paths": ["templates", "css", "lang"]
}
},
"compatibility": {
"minimum": "10.290",
"verified": "11"
"verified": "10"
},
"esmodules": [
"tickwerk.js"
],
"styles": [
"styles/tickwerk.css"
],
"esmodules": ["tickwerk.js"],
"styles": ["styles/tickwerk.css"],
"languages": [
{
"lang": "en",
@ -53,6 +41,6 @@
}
],
"manifest": "https://git.f3l.de/api/packages/dungeonslayers/generic/tickwerk/latest/module.json",
"download": "https://git.f3l.de/dungeonslayers/tickwerk/releases/download/1.3.4/tickwerk.zip",
"download": "https://git.f3l.de/dungeonslayers/tickwerk/releases/download/1.3.3/tickwerk.zip",
"manifestPlusVersion": "1.2.0"
}

View file

@ -2,7 +2,7 @@
"private": true,
"name": "tickwerk",
"description": "A tick based combat system for Foundry Virtual Tabletop",
"version": "1.3.4",
"version": "1.3.3",
"license": "https://git.f3l.de/dungeonslayers/tickwerk#licensing",
"homepage": "https://git.f3l.de/dungeonslayers/tickwerk",
"repository": {

View file

@ -112,16 +112,14 @@ const CombatantMixin = (BaseCombatant) => {
* @param {object} data The data of the creation / update
*/
async #updateTiebreakerData(data) {
const waiting = data.flags?.[packageId]?.waiting;
if ('initiative' in data || waiting !== undefined) {
const newInitiative = data.initiative ?? this.initiative;
if ('initiative' in data) {
const combatantsWithSameTickValue =
this.parent?.combatants.filter((combatant) => {
const otherInitiative =
combatant._newInitiative !== undefined ? combatant._newInitiative : combatant.initiative;
return otherInitiative === newInitiative && combatant !== this;
return otherInitiative === data.initiative;
}) ?? [];
const tiebreaker = await this.#getTiebreaker(combatantsWithSameTickValue, waiting);
const tiebreaker = await this.#getTiebreaker(combatantsWithSameTickValue);
foundry.utils.setProperty(data, `flags.${packageId}.tiebreaker`, tiebreaker);
this._newInitiative = data.initiative;
this._newTiebreaker = tiebreaker;
@ -131,12 +129,11 @@ const CombatantMixin = (BaseCombatant) => {
/**
* Get a tiebreaker between this combatant and the given other combatants.
* @param {TickwerkCombatant[]} combatants The other combatants among which to find a tiebreaker
* @param {boolean | undefined} waiting The change of the waiting state of the combatanmt
* @returns {Promise<number>} A promise that resolves to the tiebreaker
*/
async #getTiebreaker(combatants, waiting) {
async #getTiebreaker(combatants) {
const getTiebreaker = CONFIG.tickwerk?.getTiebreaker ?? defaultGetTiebreaker;
return getTiebreaker(this, combatants, waiting);
return getTiebreaker(this, combatants);
}
/** @override */
@ -182,14 +179,14 @@ const CombatantMixin = (BaseCombatant) => {
/**
* A function to get a tiebreaker for a combatant
* @typedef {(combatant: TickwerkCombatant, combatants: TickwerkCombatant[], waiting: boolean | undefined) => Promise<number>} GetTiebreaker
* @typedef {(combatant: TickwerkCombatant, combatants: TickwerkCombatant[]) => Promise<number>} GetTiebreaker
*/
/**
* Default implementation to get a tiebreaker for a combatant.
* @type {GetTiebreaker}
*/
export const defaultGetTiebreaker = async (combatant, combatants) => {
const defaultGetTiebreaker = async (combatant, combatants) => {
if (combatants.length === 0) return 0;
const tiebreakers = combatants.map((combatant) => {
return (

View file

@ -14,7 +14,7 @@ export const registerDS4SpecificFunctionality = () => {
};
/** @type {import("../data/documents/combatant").GetTiebreaker} */
const getTiebreaker = async (combatant, combatants, waiting) => {
const getTiebreaker = async (combatant, combatants) => {
if (combatants.length === 0) return 0;
/** @type {number[]} */
@ -26,7 +26,7 @@ const getTiebreaker = async (combatant, combatants, waiting) => {
for (const other of combatants) {
const tiebreaker = other._newTiebreaker ?? other.getFlag(packageId, 'tiebreaker') ?? 0;
if (getInitiative(other) > getInitiative(combatant) || waiting === false) {
if (getInitiative(other) > getInitiative(combatant)) {
lowerBounds.push(tiebreaker);
} else if (getInitiative(other) < getInitiative(combatant)) {
upperBounds.push(tiebreaker);