fix: use correct tick value for combatants joining later
This commit is contained in:
parent
a578cbff0d
commit
704798cc27
5 changed files with 100 additions and 103 deletions
|
@ -20,12 +20,8 @@
|
||||||
"minimum": "10.290",
|
"minimum": "10.290",
|
||||||
"verified": "10"
|
"verified": "10"
|
||||||
},
|
},
|
||||||
"esmodules": [
|
"esmodules": ["tickwerk.js"],
|
||||||
"tickwerk.js"
|
"styles": ["styles/tickwerk.css"],
|
||||||
],
|
|
||||||
"styles": [
|
|
||||||
"styles/tickwerk.css"
|
|
||||||
],
|
|
||||||
"languages": [
|
"languages": [
|
||||||
{
|
{
|
||||||
"lang": "en",
|
"lang": "en",
|
||||||
|
|
|
@ -42,7 +42,7 @@ const CombatantMixin = (BaseCombatant) => {
|
||||||
*/
|
*/
|
||||||
toggleWaiting() {
|
toggleWaiting() {
|
||||||
const update = { [`flags.${packageId}.waiting`]: !this.waiting };
|
const update = { [`flags.${packageId}.waiting`]: !this.waiting };
|
||||||
if (this.parent?.started && this.waiting) update.initiative = this.parent?.round;
|
if (this.parent?.started && this.waiting) update.initiative = this.parent?.tickValue;
|
||||||
return this.update(update);
|
return this.update(update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,8 @@ const CombatantMixin = (BaseCombatant) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.update({ initiative: this.initiative + ticks });
|
await this.update({ initiative: this.initiative + ticks });
|
||||||
const advanceTime = ticks * CONFIG.time.roundTime;
|
const tickTime = CONFIG.tickwerk?.tickTime;
|
||||||
|
const advanceTime = tickTime !== undefined ? ticks * tickTime : undefined;
|
||||||
if (advanceTime !== 0) {
|
if (advanceTime !== 0) {
|
||||||
await this.combat?.update(undefined, { diff: false, advanceTime });
|
await this.combat?.update(undefined, { diff: false, advanceTime });
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { getGame } from '../helpers';
|
||||||
|
|
||||||
export const registerDS4SpecificFunctionality = () => {
|
export const registerDS4SpecificFunctionality = () => {
|
||||||
if (CONFIG.tickwerk === undefined) CONFIG.tickwerk = {};
|
if (CONFIG.tickwerk === undefined) CONFIG.tickwerk = {};
|
||||||
foundry.utils.mergeObject(CONFIG.tickwerk, { getTiebreaker, getInitiativeFormula });
|
foundry.utils.mergeObject(CONFIG.tickwerk, { getTiebreaker, getInitiativeFormula, tickTime: 0.5 });
|
||||||
|
|
||||||
registerRollItemSetting();
|
registerRollItemSetting();
|
||||||
Hooks.on('ds4.rollItem', onRollItem);
|
Hooks.on('ds4.rollItem', onRollItem);
|
||||||
|
@ -71,7 +71,7 @@ const getTiebreaker = async (combatant, combatants) => {
|
||||||
const getInitiativeFormula = (combatant) => {
|
const getInitiativeFormula = (combatant) => {
|
||||||
const started = combatant.combat?.started ?? false;
|
const started = combatant.combat?.started ?? false;
|
||||||
if (!started) return '-@combatValues.initiative.total';
|
if (!started) return '-@combatValues.initiative.total';
|
||||||
const tickValue = combatant.combat?.round ?? 0;
|
const tickValue = combatant.combat?.tickValue ?? 0;
|
||||||
return `max(${tickValue} + 10 - @combatValues.initiative.total, ${tickValue})`;
|
return `max(${tickValue} + 10 - @combatValues.initiative.total, ${tickValue})`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ function bumpVersion(release) {
|
||||||
|
|
||||||
console.log(`Bumping version number to '${targetVersion}'`);
|
console.log(`Bumping version number to '${targetVersion}'`);
|
||||||
packageJson.version = targetVersion;
|
packageJson.version = targetVersion;
|
||||||
fs.writeJSONSync('package.json', packageJson, { spaces: 4 });
|
fs.writeJSONSync('package.json', packageJson, { spaces: 2 });
|
||||||
manifest.version = targetVersion;
|
manifest.version = targetVersion;
|
||||||
manifest.url = repositoryURL;
|
manifest.url = repositoryURL;
|
||||||
manifest.manifest = getManifestUrl(getChannel(targetVersion));
|
manifest.manifest = getManifestUrl(getChannel(targetVersion));
|
||||||
|
@ -90,7 +90,7 @@ function bumpVersion(release) {
|
||||||
manifest.changelog = getChangelogURL(targetVersion);
|
manifest.changelog = getChangelogURL(targetVersion);
|
||||||
manifest.readme = getReadmeURL(targetVersion);
|
manifest.readme = getReadmeURL(targetVersion);
|
||||||
manifest.license = getLicenseURL(targetVersion);
|
manifest.license = getLicenseURL(targetVersion);
|
||||||
fs.writeJSONSync(manifestPath, manifest, { spaces: 4 });
|
fs.writeJSONSync(manifestPath, manifest, { spaces: 2 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const argv = yargs(hideBin(process.argv)).usage('Usage: $0').option('release', {
|
const argv = yargs(hideBin(process.argv)).usage('Usage: $0').option('release', {
|
||||||
|
|
Loading…
Reference in a new issue