Using foundry's isNewer function rather than custom one

This commit is contained in:
WBHarry 2025-08-23 15:48:31 +02:00
parent 482adabae4
commit 9b332c3681
3 changed files with 4 additions and 17 deletions

View file

@ -1,7 +1,7 @@
import { emitAsGM, GMUpdateEvent } from '../systemRegistration/socket.mjs';
import { LevelOptionType } from '../data/levelTier.mjs';
import DHFeature from '../data/item/feature.mjs';
import { damageKeyToNumber, versionCompare } from '../helpers/utils.mjs';
import { damageKeyToNumber } from '../helpers/utils.mjs';
import DhCompanionLevelUp from '../applications/levelup/companionLevelup.mjs';
export default class DhpActor extends Actor {
@ -759,7 +759,7 @@ export default class DhpActor extends Actor {
}
const parsedJSON = JSON.parse(json);
if (versionCompare(parsedJSON._stats.systemVersion, '1.1.0')) {
if (foundry.utils.isNewerVersion('1.1.0', parsedJSON._stats.systemVersion)) {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.localize('DAGGERHEART.ACTORS.Character.InvalidOldCharacterImportTitle')

View file

@ -420,14 +420,3 @@ export async function createEmbeddedItemsWithEffects(actor, baseData) {
export const slugify = name => {
return name.toLowerCase().replaceAll(' ', '-').replaceAll('.', '');
};
export const versionCompare = (current, target) => {
const currentSplit = current.split('.').map(x => Number.parseInt(x));
const targetSplit = target.split('.').map(x => Number.parseInt(x));
for (var i = 0; i < currentSplit.length; i++) {
if (currentSplit[i] < targetSplit[i]) return true;
if (currentSplit[i] > targetSplit[i]) return false;
}
return false;
};

View file

@ -1,10 +1,8 @@
import { versionCompare } from '../helpers/utils.mjs';
export async function runMigrations() {
let lastMigrationVersion = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion);
if (!lastMigrationVersion) lastMigrationVersion = '1.0.6';
if (versionCompare(lastMigrationVersion, '1.1.0')) {
if (foundry.utils.isNewerVersion('1.1.0', lastMigrationVersion)) {
const compendiumActors = [];
for (let pack of game.packs) {
const documents = await pack.getDocuments();
@ -37,7 +35,7 @@ export async function runMigrations() {
lastMigrationVersion = '1.1.0';
}
if (versionCompare(lastMigrationVersion, '1.1.1')) {
if (foundry.utils.isNewerVersion('1.1.1', lastMigrationVersion)) {
const compendiumClasses = [];
for (let pack of game.packs) {
const documents = await pack.getDocuments();