forked from OpenWF/SpaceNinjaServer
		
	feat: noDojoResearchCosts & noDojoResearchTime (#1053)
Closes #1052 Reviewed-on: OpenWF/SpaceNinjaServer#1053 Co-authored-by: Sainan <sainan@calamity.inc> Co-committed-by: Sainan <sainan@calamity.inc>
This commit is contained in:
		
							parent
							
								
									caec5a6cbf
								
							
						
					
					
						commit
						4205364bd8
					
				@ -31,5 +31,7 @@
 | 
			
		||||
  "unlockExilusEverywhere": true,
 | 
			
		||||
  "unlockArcanesEverywhere": true,
 | 
			
		||||
  "noDailyStandingLimits": true,
 | 
			
		||||
  "noDojoResearchCosts": true,
 | 
			
		||||
  "noDojoResearchTime": true,
 | 
			
		||||
  "spoofMasteryRank": -1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,12 @@
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
import { getGuildForRequestEx } from "@/src/services/guildService";
 | 
			
		||||
import { ExportDojoRecipes } from "warframe-public-export-plus";
 | 
			
		||||
import { ExportDojoRecipes, IDojoResearch } from "warframe-public-export-plus";
 | 
			
		||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { addMiscItems, addRecipes, getInventory, updateCurrency } from "@/src/services/inventoryService";
 | 
			
		||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
			
		||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
			
		||||
import { config } from "@/src/services/configService";
 | 
			
		||||
import { ITechProjectDatabase } from "@/src/types/guildTypes";
 | 
			
		||||
 | 
			
		||||
export const guildTechController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
@ -20,15 +22,21 @@ export const guildTechController: RequestHandler = async (req, res) => {
 | 
			
		||||
        const recipe = ExportDojoRecipes.research[data.RecipeType!];
 | 
			
		||||
        guild.TechProjects ??= [];
 | 
			
		||||
        if (!guild.TechProjects.find(x => x.ItemType == data.RecipeType)) {
 | 
			
		||||
            const techProject =
 | 
			
		||||
                guild.TechProjects[
 | 
			
		||||
                    guild.TechProjects.push({
 | 
			
		||||
                        ItemType: data.RecipeType!,
 | 
			
		||||
                ReqCredits: scaleRequiredCount(recipe.price),
 | 
			
		||||
                        ReqCredits: config.noDojoResearchCosts ? 0 : scaleRequiredCount(recipe.price),
 | 
			
		||||
                        ReqItems: recipe.ingredients.map(x => ({
 | 
			
		||||
                            ItemType: x.ItemType,
 | 
			
		||||
                    ItemCount: scaleRequiredCount(x.ItemCount)
 | 
			
		||||
                            ItemCount: config.noDojoResearchCosts ? 0 : scaleRequiredCount(x.ItemCount)
 | 
			
		||||
                        })),
 | 
			
		||||
                        State: 0
 | 
			
		||||
            });
 | 
			
		||||
                    }) - 1
 | 
			
		||||
                ];
 | 
			
		||||
            if (config.noDojoResearchCosts) {
 | 
			
		||||
                processFundedProject(techProject, recipe);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        await guild.save();
 | 
			
		||||
        res.end();
 | 
			
		||||
@ -59,9 +67,8 @@ export const guildTechController: RequestHandler = async (req, res) => {
 | 
			
		||||
 | 
			
		||||
        if (techProject.ReqCredits == 0 && !techProject.ReqItems.find(x => x.ItemCount > 0)) {
 | 
			
		||||
            // This research is now fully funded.
 | 
			
		||||
            techProject.State = 1;
 | 
			
		||||
            const recipe = ExportDojoRecipes.research[data.RecipeType!];
 | 
			
		||||
            techProject.CompletionDate = new Date(new Date().getTime() + recipe.time * 1000);
 | 
			
		||||
            processFundedProject(techProject, recipe);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        await guild.save();
 | 
			
		||||
@ -98,6 +105,11 @@ export const guildTechController: RequestHandler = async (req, res) => {
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const processFundedProject = (techProject: ITechProjectDatabase, recipe: IDojoResearch): void => {
 | 
			
		||||
    techProject.State = 1;
 | 
			
		||||
    techProject.CompletionDate = new Date(new Date().getTime() + (config.noDojoResearchTime ? 0 : recipe.time) * 1000);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
type TGuildTechRequest = {
 | 
			
		||||
    Action: string;
 | 
			
		||||
} & Partial<IGuildTechStartFields> &
 | 
			
		||||
 | 
			
		||||
@ -57,6 +57,8 @@ interface IConfig {
 | 
			
		||||
    unlockExilusEverywhere?: boolean;
 | 
			
		||||
    unlockArcanesEverywhere?: boolean;
 | 
			
		||||
    noDailyStandingLimits?: boolean;
 | 
			
		||||
    noDojoResearchCosts?: boolean;
 | 
			
		||||
    noDojoResearchTime?: boolean;
 | 
			
		||||
    spoofMasteryRank?: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -517,6 +517,14 @@
 | 
			
		||||
                                        <input class="form-check-input" type="checkbox" id="noDailyStandingLimits" />
 | 
			
		||||
                                        <label class="form-check-label" for="noDailyStandingLimits" data-loc="cheats_noDailyStandingLimits"></label>
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                    <div class="form-check">
 | 
			
		||||
                                        <input class="form-check-input" type="checkbox" id="noDojoResearchCosts" />
 | 
			
		||||
                                        <label class="form-check-label" for="noDojoResearchCosts" data-loc="cheats_noDojoResearchCosts"></label>
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                    <div class="form-check">
 | 
			
		||||
                                        <input class="form-check-input" type="checkbox" id="noDojoResearchTime" />
 | 
			
		||||
                                        <label class="form-check-label" for="noDojoResearchTime" data-loc="cheats_noDojoResearchTime"></label>
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                    <div class="form-group mt-2">
 | 
			
		||||
                                        <label class="form-label" for="spoofMasteryRank" data-loc="cheats_spoofMasteryRank"></label>
 | 
			
		||||
                                        <input class="form-control" id="spoofMasteryRank" type="number" min="-1" max="65535" />
 | 
			
		||||
 | 
			
		||||
@ -111,6 +111,8 @@ dict = {
 | 
			
		||||
    cheats_unlockExilusEverywhere: `Exilus Adapters Everywhere`,
 | 
			
		||||
    cheats_unlockArcanesEverywhere: `Arcane Adapters Everywhere`,
 | 
			
		||||
    cheats_noDailyStandingLimits: `No Daily Standing Limits`,
 | 
			
		||||
    cheats_noDojoResearchCosts: `No Dojo Research Costs`,
 | 
			
		||||
    cheats_noDojoResearchTime: `No Dojo Research Time`,
 | 
			
		||||
    cheats_spoofMasteryRank: `Spoofed Mastery Rank (-1 to disable)`,
 | 
			
		||||
    cheats_saveSettings: `Save Settings`,
 | 
			
		||||
    cheats_account: `Account`,
 | 
			
		||||
 | 
			
		||||
@ -112,6 +112,8 @@ dict = {
 | 
			
		||||
    cheats_unlockExilusEverywhere: `Адаптеры Эксилус везде`,
 | 
			
		||||
    cheats_unlockArcanesEverywhere: `Адаптеры для мистификаторов везде`,
 | 
			
		||||
    cheats_noDailyStandingLimits: `Без ежедневных ограничений репутации`,
 | 
			
		||||
    cheats_noDojoResearchCosts: `[UNTRANSLATED] No Dojo Research Costs`,
 | 
			
		||||
    cheats_noDojoResearchTime: `[UNTRANSLATED] No Dojo Research Time`,
 | 
			
		||||
    cheats_spoofMasteryRank: `Подделанный ранг мастерства (-1 для отключения)`,
 | 
			
		||||
    cheats_saveSettings: `Сохранить настройки`,
 | 
			
		||||
    cheats_account: `Аккаунт`,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user