diff --git a/src/controllers/api/syndicateSacrificeController.ts b/src/controllers/api/syndicateSacrificeController.ts index 8b1a9c7a..ac362e39 100644 --- a/src/controllers/api/syndicateSacrificeController.ts +++ b/src/controllers/api/syndicateSacrificeController.ts @@ -17,81 +17,103 @@ export const syndicateSacrificeController: RequestHandler = async (request, resp if (!syndicate) { syndicate = inventory.Affiliations[inventory.Affiliations.push({ Tag: data.AffiliationTag, Standing: 0 }) - 1]; } - - const level = data.SacrificeLevel - (syndicate.Title ?? 0); const res: ISyndicateSacrificeResponse = { AffiliationTag: data.AffiliationTag, InventoryChanges: {}, - Level: data.SacrificeLevel, - LevelIncrease: level <= 0 ? 1 : level, + Level: 0, // the new level after the sacrifice + LevelIncrease: 0, // the amount of levels gained from the sacrifice NewEpisodeReward: false }; - const manifest = ExportSyndicates[data.AffiliationTag]; - let sacrifice: ISyndicateSacrifice | undefined; - let reward: string | undefined; - if (data.SacrificeLevel == 0) { - sacrifice = manifest.initiationSacrifice; - reward = manifest.initiationReward; + const isNightwave = manifest.dailyChallenges !== undefined; + + const titles = manifest.titles; + const oldLevel = syndicate.Title ?? 0; + const currentStanding = syndicate.Standing ?? 0; + let newLevel = oldLevel; + + interface _HandleItem { + sacrifice?: ISyndicateSacrifice; + reward?: { + type: string; + count?: number; // default 1 + }; + } + + const needProcess: _HandleItem[] = []; + + if (!syndicate.Initiated) { + needProcess.push({ + sacrifice: manifest.initiationSacrifice, + reward: manifest.initiationReward ? { type: manifest.initiationReward } : undefined + }); syndicate.Initiated = true; + } + + if (titles == undefined) { + // ummm then just trust what the client says? + newLevel = res.Level = data.SacrificeLevel; + res.LevelIncrease = data.SacrificeLevel - oldLevel; } else { - sacrifice = manifest.titles?.find(x => x.level == data.SacrificeLevel)?.sacrifice; + titles + .filter(x => x.level > oldLevel && x.minStanding <= currentStanding) + .forEach(x => { + if (x.level > newLevel) newLevel = x.level; + const item: _HandleItem = {}; + if (x.sacrifice) { + item.sacrifice = x.sacrifice; + } + if (x.storeItemReward) { + item.reward = { type: x.storeItemReward, count: 1 }; + } else if (x.reward) { + item.reward = { type: toStoreItem(x.reward.ItemType), count: x.reward.ItemCount }; + } + if (item.sacrifice || item.reward) { + needProcess.push(item); + } + }); + res.Level = newLevel; + res.LevelIncrease = newLevel - oldLevel; } - if (sacrifice) { - res.InventoryChanges = { ...updateCurrency(inventory, sacrifice.credits, false) }; - - const miscItemChanges = sacrifice.items.map(x => ({ - ItemType: x.ItemType, - ItemCount: x.ItemCount * -1 - })); - addMiscItems(inventory, miscItemChanges); - res.InventoryChanges.MiscItems = miscItemChanges; - } - - syndicate.Title ??= 0; - syndicate.Title += 1; - - if (reward) { - combineInventoryChanges( - res.InventoryChanges, - (await handleStoreItemAcquisition(reward, inventory)).InventoryChanges - ); - } - - // Quacks like a nightwave syndicate? - if (manifest.dailyChallenges) { - const title = manifest.titles!.find(x => x.level == syndicate.Title); - if (title) { - res.NewEpisodeReward = true; - let rewardType: string; - let rewardCount: number; - if (title.storeItemReward) { - rewardType = title.storeItemReward; - rewardCount = 1; - } else { - rewardType = toStoreItem(title.reward!.ItemType); - rewardCount = title.reward!.ItemCount; + for (const item of needProcess) { + if (item.sacrifice) { + const changes = updateCurrency(inventory, item.sacrifice.credits, false); + const miscItemChanges = item.sacrifice.items.map(x => ({ + ItemType: x.ItemType, + ItemCount: x.ItemCount * -1 + })); + addMiscItems(inventory, miscItemChanges); + if (res.InventoryChanges.MiscItems === undefined) { + res.InventoryChanges.MiscItems = []; } - const rewardInventoryChanges = (await handleStoreItemAcquisition(rewardType, inventory, rewardCount)) - .InventoryChanges; - if (Object.keys(rewardInventoryChanges).length == 0) { - logger.debug(`nightwave rank up reward did not seem to get added, giving 50 creds instead`); - const nightwaveCredsItemType = manifest.titles![0].reward!.ItemType; - rewardInventoryChanges.MiscItems = [{ ItemType: nightwaveCredsItemType, ItemCount: 50 }]; - addMiscItems(inventory, rewardInventoryChanges.MiscItems); - } - combineInventoryChanges(res.InventoryChanges, rewardInventoryChanges); + res.InventoryChanges.MiscItems.push(...miscItemChanges); + combineInventoryChanges(res.InventoryChanges, changes); } - } else { - if (syndicate.Title > 0 && manifest.favours.find(x => x.rankUpReward && x.requiredLevel == syndicate.Title)) { - syndicate.FreeFavorsEarned ??= []; - if (!syndicate.FreeFavorsEarned.includes(syndicate.Title)) { - syndicate.FreeFavorsEarned.push(syndicate.Title); + if (item.reward) { + const rewardChanges = await handleStoreItemAcquisition(item.reward.type, inventory, item.reward.count ?? 1); + if (isNightwave && Object.keys(rewardChanges.InventoryChanges).length == 0) { + logger.debug(`syndicate sacrifice reward did not seem to get added, giving 50 creds instead`); + const syndicateCredsItemType = manifest.titles![0].reward!.ItemType; + rewardChanges.InventoryChanges.MiscItems = [{ ItemType: syndicateCredsItemType, ItemCount: 50 }]; + addMiscItems(inventory, rewardChanges.InventoryChanges.MiscItems); } + combineInventoryChanges(res.InventoryChanges, rewardChanges.InventoryChanges); } } - + if (isNightwave) { + res.NewEpisodeReward = needProcess.length > 0; + } else { + manifest.favours + .filter(x => x.rankUpReward && x.requiredLevel <= newLevel) + .forEach(x => { + syndicate.FreeFavorsEarned ??= []; + if (!syndicate.FreeFavorsEarned.includes(x.requiredLevel)) { + syndicate.FreeFavorsEarned.push(x.requiredLevel); + } + }); + } + syndicate.Title = newLevel; await inventory.save(); response.json(res); diff --git a/src/services/configService.ts b/src/services/configService.ts index dc8a78bc..701fbada 100644 --- a/src/services/configService.ts +++ b/src/services/configService.ts @@ -65,6 +65,7 @@ interface IConfig { vallisOverride?: string; nightwaveOverride?: string; }; + nightwaveStandingMultliplier?: number; } export const configPath = path.join(repoDir, "config.json"); diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 6060f1e9..e27501df 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -1772,13 +1772,18 @@ export const addChallenges = ( }) - 1 ]; } - affiliation.Standing += meta.standing!; - if (affiliationMods.length == 0) { - affiliationMods.push({ Tag: nightwaveSyndicateTag }); + let standingToAdd = meta.standing ?? 0; + if (standingToAdd >= 0) { + standingToAdd *= config.nightwaveStandingMultliplier ?? 1; + affiliation.Standing += standingToAdd; + + if (affiliationMods.length == 0) { + affiliationMods.push({ Tag: nightwaveSyndicateTag }); + } + affiliationMods[0].Standing ??= 0; + affiliationMods[0].Standing += standingToAdd; } - affiliationMods[0].Standing ??= 0; - affiliationMods[0].Standing += meta.standing!; } } } diff --git a/static/webui/index.html b/static/webui/index.html index 1b42793e..6ad7fb4a 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -722,6 +722,10 @@ +
+ + +
diff --git a/static/webui/translations/de.js b/static/webui/translations/de.js index eb721391..683a8001 100644 --- a/static/webui/translations/de.js +++ b/static/webui/translations/de.js @@ -163,6 +163,7 @@ dict = { cheats_noDojoResearchTime: `Keine Dojo-Forschungszeit`, cheats_fastClanAscension: `Schneller Clan-Aufstieg`, cheats_spoofMasteryRank: `Gefälschter Meisterschaftsrang (-1 zum deaktivieren)`, + cheats_nightwaveStandingMultliplier: `Nightwave-Ansehen-Multiplikator`, cheats_saveSettings: `Einstellungen speichern`, cheats_account: `Account`, cheats_unlockAllFocusSchools: `Alle Fokus-Schulen freischalten`, diff --git a/static/webui/translations/en.js b/static/webui/translations/en.js index cd718917..7f34351e 100644 --- a/static/webui/translations/en.js +++ b/static/webui/translations/en.js @@ -162,6 +162,7 @@ dict = { cheats_noDojoResearchTime: `No Dojo Research Time`, cheats_fastClanAscension: `Fast Clan Ascension`, cheats_spoofMasteryRank: `Spoofed Mastery Rank (-1 to disable)`, + cheats_nightwaveStandingMultliplier: `Nightwave Standing Multiplier`, cheats_saveSettings: `Save Settings`, cheats_account: `Account`, cheats_unlockAllFocusSchools: `Unlock All Focus Schools`, diff --git a/static/webui/translations/es.js b/static/webui/translations/es.js index 652a850c..bfe65958 100644 --- a/static/webui/translations/es.js +++ b/static/webui/translations/es.js @@ -163,6 +163,7 @@ dict = { cheats_noDojoResearchTime: `Sin tiempo de investigación del dojo`, cheats_fastClanAscension: `Ascenso rápido del clan`, cheats_spoofMasteryRank: `Rango de maestría simulado (-1 para desactivar)`, + cheats_nightwaveStandingMultliplier: `Multiplicador de reputación de Onda Nocturna`, cheats_saveSettings: `Guardar configuración`, cheats_account: `Cuenta`, cheats_unlockAllFocusSchools: `Desbloquear todas las escuelas de enfoque`, diff --git a/static/webui/translations/fr.js b/static/webui/translations/fr.js index 5a61111e..029dbbd0 100644 --- a/static/webui/translations/fr.js +++ b/static/webui/translations/fr.js @@ -163,6 +163,7 @@ dict = { cheats_noDojoResearchTime: `Aucun temps de recherche (Dojo)`, cheats_fastClanAscension: `Ascension de clan rapide`, cheats_spoofMasteryRank: `Rang de maîtrise personnalisé (-1 pour désactiver)`, + cheats_nightwaveStandingMultliplier: `Multiplicateur de standing Ondes Nocturnes`, cheats_saveSettings: `Sauvegarder les paramètres`, cheats_account: `Compte`, cheats_unlockAllFocusSchools: `Débloquer toutes les écoles de focus`, diff --git a/static/webui/translations/ru.js b/static/webui/translations/ru.js index 445c519a..909d536e 100644 --- a/static/webui/translations/ru.js +++ b/static/webui/translations/ru.js @@ -163,6 +163,7 @@ dict = { cheats_noDojoResearchTime: `Мгновенные Исследование Додзё`, cheats_fastClanAscension: `Мгновенное Вознесение Клана`, cheats_spoofMasteryRank: `Подделанный ранг мастерства (-1 для отключения)`, + cheats_nightwaveStandingMultliplier: `Множитель репутации Ночной Волны`, cheats_saveSettings: `Сохранить настройки`, cheats_account: `Аккаунт`, cheats_unlockAllFocusSchools: `Разблокировать все школы фокуса`, diff --git a/static/webui/translations/zh.js b/static/webui/translations/zh.js index d46ce77d..f37120a7 100644 --- a/static/webui/translations/zh.js +++ b/static/webui/translations/zh.js @@ -163,6 +163,7 @@ dict = { cheats_noDojoResearchTime: `无视道场研究时间`, cheats_fastClanAscension: `快速升级氏族`, cheats_spoofMasteryRank: `伪造精通段位(-1为禁用)`, + cheats_nightwaveStandingMultliplier: `午夜电波声望倍率`, cheats_saveSettings: `保存设置`, cheats_account: `账户`, cheats_unlockAllFocusSchools: `解锁所有专精学派`,