Füge Validierung für Geschenke in FalukantService hinzu und erstelle Skripte zur Reparatur ungültiger Werte in PromotionalGift

This commit is contained in:
Torsten Schulz (local)
2026-02-14 16:19:31 +01:00
parent be7db6ad96
commit 91637ba7a3
3 changed files with 110 additions and 2 deletions

View File

@@ -3119,8 +3119,18 @@ class FalukantService extends BaseService {
characterTitleOfNobility = reloadChar?.titleOfNobility ?? lowestTitleOfNobility?.id ?? 1;
}
return Promise.all(gifts.map(async gift => {
const value = typeof gift.value === 'number' ? gift.value : (gift.value ? Number(gift.value) : 0);
// Filtere Gifts ohne gültigen 'value' (0 oder fehlend) — solche sollten in der DB korrigiert werden
const validGifts = gifts.filter(g => Number(g.value) > 0);
const skipped = gifts.length - validGifts.length;
if (skipped > 0) {
console.warn(`getGifts: skipped ${skipped} promotional gifts with invalid value`);
for (const g of gifts) {
if (!(Number(g.value) > 0)) console.warn(` skipped gift id=${g.id} name=${g.name} value=${g.value}`);
}
}
return Promise.all(validGifts.map(async gift => {
const value = Number(gift.value);
const cost = await this.getGiftCost(value, characterTitleOfNobility, lowestTitleOfNobility?.id ?? 1);
return {
id: gift.id,