diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index d20d45e..e685032 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -490,7 +490,7 @@ class FalukantService extends BaseService { { model: RegionData, as: 'region', - attributes: ['name'], + attributes: ['id', 'name'], include: [ { model: Weather, @@ -507,11 +507,27 @@ class FalukantService extends BaseService { attributes: ['id', 'regionId'], order: [['branchTypeId', 'ASC']] }); - return bs.map(b => ({ - ...b.toJSON(), - isMainBranch: u.mainBranchRegionId === b.regionId, - weather: b.region?.weather?.weatherType?.tr || null - })); + + // Lade Wetter explizit für alle Regionen, um sicherzustellen, dass es korrekt geladen wird + const regionIds = [...new Set(bs.map(b => b.regionId))]; + const weathers = await Weather.findAll({ + where: { regionId: { [Op.in]: regionIds } }, + include: [ + { model: WeatherType, as: 'weatherType', attributes: ['tr'] } + ] + }); + const weatherMap = new Map(weathers.map(w => [w.regionId, w.weatherType?.tr || null])); + + return bs.map(b => { + const branchJson = b.toJSON(); + // Verwende das explizit geladene Wetter, falls vorhanden, sonst das aus der Include-Beziehung + const weather = weatherMap.get(b.regionId) || branchJson.region?.weather?.weatherType?.tr || null; + return { + ...branchJson, + isMainBranch: u.mainBranchRegionId === b.regionId, + weather: weather + }; + }); } async createBranch(hashedUserId, cityId, branchTypeId) { diff --git a/frontend/src/i18n/locales/de/falukant.json b/frontend/src/i18n/locales/de/falukant.json index 1d662c2..8666698 100644 --- a/frontend/src/i18n/locales/de/falukant.json +++ b/frontend/src/i18n/locales/de/falukant.json @@ -31,6 +31,19 @@ }, "transport": { "waiting": "Transport wartet" + }, + "random_event": { + "windfall": "Unerwarteter Geldsegen: Du hast {amount} erhalten!", + "theft": "Diebstahl: {amount} wurde aus deinem Lager gestohlen.", + "warehouse_fire": "Lagerfeuer: Ein Feuer hat dein Lager beschädigt. Verluste: {amount}.", + "character_illness": "Krankheit: {characterName} ist erkrankt.", + "character_recovery": "Genesung: {characterName} hat sich von der Krankheit erholt.", + "character_accident": "Unfall: {characterName} hatte einen Unfall.", + "sudden_infant_death": "Tragödie: {characterName} ist plötzlich verstorben.", + "regional_storm": "Regionaler Sturm: Ein schwerer Sturm hat die Region {regionName} getroffen.", + "regional_festival": "Regionales Fest: Ein Fest findet in {regionName} statt.", + "regional_epidemic": "Regionale Epidemie: Eine Epidemie hat {regionName} getroffen.", + "earthquake": "Erdbeben: Ein Erdbeben hat die Region {regionName} erschüttert." } }, "health": { diff --git a/frontend/src/i18n/locales/en/falukant.json b/frontend/src/i18n/locales/en/falukant.json index e96c4f0..b83bd34 100644 --- a/frontend/src/i18n/locales/en/falukant.json +++ b/frontend/src/i18n/locales/en/falukant.json @@ -19,6 +19,22 @@ "notify_election_created": "A new election has been scheduled.", "production": { "overproduction": "Overproduction: your production is {value}% above demand." + }, + "transport": { + "waiting": "Transport waiting" + }, + "random_event": { + "windfall": "Unexpected windfall: You received {amount}!", + "theft": "Theft: {amount} was stolen from your warehouse.", + "warehouse_fire": "Warehouse Fire: A fire has damaged your warehouse. Losses: {amount}.", + "character_illness": "Illness: {characterName} has fallen ill.", + "character_recovery": "Recovery: {characterName} has recovered from the illness.", + "character_accident": "Accident: {characterName} has had an accident.", + "sudden_infant_death": "Tragedy: {characterName} has suddenly passed away.", + "regional_storm": "Regional Storm: A severe storm has hit the region {regionName}.", + "regional_festival": "Regional Festival: A festival is taking place in {regionName}.", + "regional_epidemic": "Regional Epidemic: An epidemic has struck {regionName}.", + "earthquake": "Earthquake: An earthquake has shaken the region {regionName}." } }, "statusbar": {