forked from OpenWF/SpaceNinjaServer
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			943574bf3a
			...
			c3aa619652
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					c3aa619652 | ||
| 
						 | 
					f8ecd49fd6 | 
@ -17,81 +17,99 @@ 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;
 | 
			
		||||
        syndicate.Initiated = true;
 | 
			
		||||
    } else {
 | 
			
		||||
        sacrifice = manifest.titles?.find(x => x.level == data.SacrificeLevel)?.sacrifice;
 | 
			
		||||
    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
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (sacrifice) {
 | 
			
		||||
        res.InventoryChanges = { ...updateCurrency(inventory, sacrifice.credits, false) };
 | 
			
		||||
    const needProcess: _HandleItem[] = [];
 | 
			
		||||
 | 
			
		||||
        const miscItemChanges = sacrifice.items.map(x => ({
 | 
			
		||||
    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 {
 | 
			
		||||
        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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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);
 | 
			
		||||
        res.InventoryChanges.MiscItems = miscItemChanges;
 | 
			
		||||
            if (res.InventoryChanges.MiscItems === undefined) {
 | 
			
		||||
                res.InventoryChanges.MiscItems = [];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
    syndicate.Title ??= 0;
 | 
			
		||||
    syndicate.Title += 1;
 | 
			
		||||
 | 
			
		||||
    if (reward) {
 | 
			
		||||
        combineInventoryChanges(
 | 
			
		||||
            res.InventoryChanges,
 | 
			
		||||
            (await handleStoreItemAcquisition(reward, inventory)).InventoryChanges
 | 
			
		||||
        );
 | 
			
		||||
            res.InventoryChanges.MiscItems.push(...miscItemChanges);
 | 
			
		||||
            combineInventoryChanges(res.InventoryChanges, changes);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    // 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;
 | 
			
		||||
        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 {
 | 
			
		||||
                rewardType = toStoreItem(title.reward!.ItemType);
 | 
			
		||||
                rewardCount = title.reward!.ItemCount;
 | 
			
		||||
            }
 | 
			
		||||
            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);
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        if (syndicate.Title > 0 && manifest.favours.find(x => x.rankUpReward && x.requiredLevel == syndicate.Title)) {
 | 
			
		||||
        manifest.favours.filter(x => x.rankUpReward && x.requiredLevel <= newLevel).forEach(x => {
 | 
			
		||||
            syndicate.FreeFavorsEarned ??= [];
 | 
			
		||||
            if (!syndicate.FreeFavorsEarned.includes(syndicate.Title)) {
 | 
			
		||||
                syndicate.FreeFavorsEarned.push(syndicate.Title);
 | 
			
		||||
            if (!syndicate.FreeFavorsEarned.includes(x.requiredLevel)) {
 | 
			
		||||
                syndicate.FreeFavorsEarned.push(x.requiredLevel);
 | 
			
		||||
            }
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    syndicate.Title = newLevel;
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
 | 
			
		||||
    response.json(res);
 | 
			
		||||
 | 
			
		||||
@ -64,6 +64,7 @@ interface IConfig {
 | 
			
		||||
        lockTime?: number;
 | 
			
		||||
        nightwaveOverride?: string;
 | 
			
		||||
    };
 | 
			
		||||
    nightwaveStandingMultliplier?: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const configPath = path.join(repoDir, "config.json");
 | 
			
		||||
 | 
			
		||||
@ -1772,13 +1772,18 @@ export const addChallenges = (
 | 
			
		||||
                            }) - 1
 | 
			
		||||
                        ];
 | 
			
		||||
                }
 | 
			
		||||
                affiliation.Standing += meta.standing!;
 | 
			
		||||
 | 
			
		||||
                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 += meta.standing!;
 | 
			
		||||
                    affiliationMods[0].Standing += standingToAdd;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -722,6 +722,10 @@
 | 
			
		||||
                                        <label class="form-label" for="spoofMasteryRank" data-loc="cheats_spoofMasteryRank"></label>
 | 
			
		||||
                                        <input class="form-control" id="spoofMasteryRank" type="number" min="-1" max="65535" />
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                    <div class="form-group mt-2">
 | 
			
		||||
                                        <label class="form-label" for="nightwaveStandingMultliplier" data-loc="cheats_nightwaveStandingMultliplier"></label>
 | 
			
		||||
                                        <input class="form-control" id="nightwaveStandingMultliplier" type="number" min="1" max="1000000" value="1" />
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                    <button class="btn btn-primary mt-3" type="submit" data-loc="cheats_saveSettings"></button>
 | 
			
		||||
                                </form>
 | 
			
		||||
                            </div>
 | 
			
		||||
 | 
			
		||||
@ -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`,
 | 
			
		||||
 | 
			
		||||
@ -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`,
 | 
			
		||||
 | 
			
		||||
@ -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`,
 | 
			
		||||
 | 
			
		||||
@ -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`,
 | 
			
		||||
 | 
			
		||||
@ -163,6 +163,7 @@ dict = {
 | 
			
		||||
    cheats_noDojoResearchTime: `Мгновенные Исследование Додзё`,
 | 
			
		||||
    cheats_fastClanAscension: `Мгновенное Вознесение Клана`,
 | 
			
		||||
    cheats_spoofMasteryRank: `Подделанный ранг мастерства (-1 для отключения)`,
 | 
			
		||||
    cheats_nightwaveStandingMultliplier: `Множитель репутации Ночной Волны`,
 | 
			
		||||
    cheats_saveSettings: `Сохранить настройки`,
 | 
			
		||||
    cheats_account: `Аккаунт`,
 | 
			
		||||
    cheats_unlockAllFocusSchools: `Разблокировать все школы фокуса`,
 | 
			
		||||
 | 
			
		||||
@ -163,6 +163,7 @@ dict = {
 | 
			
		||||
    cheats_noDojoResearchTime: `无视道场研究时间`,
 | 
			
		||||
    cheats_fastClanAscension: `快速升级氏族`,
 | 
			
		||||
    cheats_spoofMasteryRank: `伪造精通段位(-1为禁用)`,
 | 
			
		||||
    cheats_nightwaveStandingMultliplier: `午夜电波声望倍率`,
 | 
			
		||||
    cheats_saveSettings: `保存设置`,
 | 
			
		||||
    cheats_account: `账户`,
 | 
			
		||||
    cheats_unlockAllFocusSchools: `解锁所有专精学派`,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user