Enhance weather data handling in FalukantService and update localization files
- Modified the FalukantService to explicitly load weather data for all regions, ensuring accurate weather information is associated with branches. - Updated the return logic to utilize the newly loaded weather data, improving data accuracy in branch responses. - Added new random event messages in both German and English localization files, enhancing user experience with richer event descriptions.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user