Füge Validierung für Geschenke in FalukantService hinzu und erstelle Skripte zur Reparatur ungültiger Werte in PromotionalGift
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user