From afec59e8a6731429283985605f50c3ec86385bf2 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Sun, 27 Apr 2025 12:38:55 -0700 Subject: [PATCH] feat: skipClanKeyCrafting cheat (#1883) Closes #1843 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1883 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- config.json.example | 1 + .../api/confirmGuildInvitationController.ts | 28 ++++++++----------- src/controllers/api/createGuildController.ts | 24 +++++----------- src/services/configService.ts | 1 + src/services/guildService.ts | 28 ++++++++++++++++++- static/webui/index.html | 4 +++ static/webui/translations/de.js | 1 + static/webui/translations/en.js | 1 + static/webui/translations/es.js | 1 + static/webui/translations/fr.js | 1 + static/webui/translations/ru.js | 1 + static/webui/translations/zh.js | 1 + 12 files changed, 57 insertions(+), 35 deletions(-) diff --git a/config.json.example b/config.json.example index 4eb30783..e8c32ed1 100644 --- a/config.json.example +++ b/config.json.example @@ -38,6 +38,7 @@ "noKimCooldowns": false, "instantResourceExtractorDrones": false, "noResourceExtractorDronesDamage": false, + "skipClanKeyCrafting": false, "noDojoRoomBuildStage": false, "noDecoBuildStage": false, "fastDojoRoomDestruction": false, diff --git a/src/controllers/api/confirmGuildInvitationController.ts b/src/controllers/api/confirmGuildInvitationController.ts index 9f43b893..b4a10b98 100644 --- a/src/controllers/api/confirmGuildInvitationController.ts +++ b/src/controllers/api/confirmGuildInvitationController.ts @@ -1,8 +1,14 @@ import { getJSONfromString } from "@/src/helpers/stringHelpers"; import { Guild, GuildMember } from "@/src/models/guildModel"; import { Account } from "@/src/models/loginModel"; -import { deleteGuild, getGuildClient, hasGuildPermission, removeDojoKeyItems } from "@/src/services/guildService"; -import { addRecipes, combineInventoryChanges, getInventory } from "@/src/services/inventoryService"; +import { + deleteGuild, + getGuildClient, + giveClanKey, + hasGuildPermission, + removeDojoKeyItems +} from "@/src/services/guildService"; +import { getInventory } from "@/src/services/inventoryService"; import { getAccountForRequest, getAccountIdForRequest, getSuffixedName } from "@/src/services/loginService"; import { GuildPermission } from "@/src/types/guildTypes"; import { IInventoryChanges } from "@/src/types/purchaseTypes"; @@ -41,14 +47,7 @@ export const confirmGuildInvitationGetController: RequestHandler = async (req, r // Update inventory of new member const inventory = await getInventory(account._id.toString(), "GuildId LevelKeys Recipes"); inventory.GuildId = new Types.ObjectId(req.query.clanId as string); - const recipeChanges = [ - { - ItemType: "/Lotus/Types/Keys/DojoKeyBlueprint", - ItemCount: 1 - } - ]; - addRecipes(inventory, recipeChanges); - combineInventoryChanges(inventoryChanges, { Recipes: recipeChanges }); + giveClanKey(inventory, inventoryChanges); await inventory.save(); const guild = (await Guild.findById(req.query.clanId as string))!; @@ -96,14 +95,9 @@ export const confirmGuildInvitationPostController: RequestHandler = async (req, await GuildMember.deleteMany({ accountId: guildMember.accountId, status: 1 }); // Update inventory of new member - const inventory = await getInventory(guildMember.accountId.toString(), "GuildId Recipes"); + const inventory = await getInventory(guildMember.accountId.toString(), "GuildId LevelKeys Recipes"); inventory.GuildId = new Types.ObjectId(req.query.clanId as string); - addRecipes(inventory, [ - { - ItemType: "/Lotus/Types/Keys/DojoKeyBlueprint", - ItemCount: 1 - } - ]); + giveClanKey(inventory); await inventory.save(); // Add join to clan log diff --git a/src/controllers/api/createGuildController.ts b/src/controllers/api/createGuildController.ts index 9b5bc768..bbaecc19 100644 --- a/src/controllers/api/createGuildController.ts +++ b/src/controllers/api/createGuildController.ts @@ -2,8 +2,9 @@ import { RequestHandler } from "express"; import { getAccountIdForRequest } from "@/src/services/loginService"; import { getJSONfromString } from "@/src/helpers/stringHelpers"; import { Guild, GuildMember } from "@/src/models/guildModel"; -import { createUniqueClanName, getGuildClient } from "@/src/services/guildService"; -import { addRecipes, getInventory } from "@/src/services/inventoryService"; +import { createUniqueClanName, getGuildClient, giveClanKey } from "@/src/services/guildService"; +import { getInventory } from "@/src/services/inventoryService"; +import { IInventoryChanges } from "@/src/types/purchaseTypes"; export const createGuildController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); @@ -26,26 +27,15 @@ export const createGuildController: RequestHandler = async (req, res) => { rank: 0 }); - const inventory = await getInventory(accountId, "GuildId Recipes"); + const inventory = await getInventory(accountId, "GuildId LevelKeys Recipes"); inventory.GuildId = guild._id; - addRecipes(inventory, [ - { - ItemType: "/Lotus/Types/Keys/DojoKeyBlueprint", - ItemCount: 1 - } - ]); + const inventoryChanges: IInventoryChanges = {}; + giveClanKey(inventory, inventoryChanges); await inventory.save(); res.json({ ...(await getGuildClient(guild, accountId)), - InventoryChanges: { - Recipes: [ - { - ItemType: "/Lotus/Types/Keys/DojoKeyBlueprint", - ItemCount: 1 - } - ] - } + InventoryChanges: inventoryChanges }); }; diff --git a/src/services/configService.ts b/src/services/configService.ts index 3fe35bcb..26a5008d 100644 --- a/src/services/configService.ts +++ b/src/services/configService.ts @@ -44,6 +44,7 @@ interface IConfig { noKimCooldowns?: boolean; instantResourceExtractorDrones?: boolean; noResourceExtractorDronesDamage?: boolean; + skipClanKeyCrafting?: boolean; noDojoRoomBuildStage?: boolean; noDojoDecoBuildStage?: boolean; fastDojoRoomDestruction?: boolean; diff --git a/src/services/guildService.ts b/src/services/guildService.ts index 80efc7b5..61e64465 100644 --- a/src/services/guildService.ts +++ b/src/services/guildService.ts @@ -1,6 +1,6 @@ import { Request } from "express"; import { getAccountIdForRequest } from "@/src/services/loginService"; -import { getInventory } from "@/src/services/inventoryService"; +import { addLevelKeys, addRecipes, combineInventoryChanges, getInventory } from "@/src/services/inventoryService"; import { Alliance, AllianceMember, Guild, GuildAd, GuildMember, TGuildDatabaseDocument } from "@/src/models/guildModel"; import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel"; import { @@ -657,6 +657,32 @@ export const checkClanAscensionHasRequiredContributors = async (guild: TGuildDat } }; +export const giveClanKey = (inventory: TInventoryDatabaseDocument, inventoryChanges?: IInventoryChanges): void => { + if (config.skipClanKeyCrafting) { + const levelKeyChanges = [ + { + ItemType: "/Lotus/Types/Keys/DojoKey", + ItemCount: 1 + } + ]; + addLevelKeys(inventory, levelKeyChanges); + if (inventoryChanges) { + combineInventoryChanges(inventoryChanges, { LevelKeys: levelKeyChanges }); + } + } else { + const recipeChanges = [ + { + ItemType: "/Lotus/Types/Keys/DojoKeyBlueprint", + ItemCount: 1 + } + ]; + addRecipes(inventory, recipeChanges); + if (inventoryChanges) { + combineInventoryChanges(inventoryChanges, { Recipes: recipeChanges }); + } + } +}; + export const removeDojoKeyItems = (inventory: TInventoryDatabaseDocument): IInventoryChanges => { const inventoryChanges: IInventoryChanges = {}; diff --git a/static/webui/index.html b/static/webui/index.html index 5210cd66..2297c8e6 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -674,6 +674,10 @@ +
+ + +
diff --git a/static/webui/translations/de.js b/static/webui/translations/de.js index 7b21eac2..12ffdd25 100644 --- a/static/webui/translations/de.js +++ b/static/webui/translations/de.js @@ -154,6 +154,7 @@ dict = { cheats_noKimCooldowns: `Keine Wartezeit bei KIM`, cheats_instantResourceExtractorDrones: `Sofortige Ressourcen-Extraktor-Drohnen`, cheats_noResourceExtractorDronesDamage: `Kein Schaden für Ressourcen-Extraktor-Drohnen`, + cheats_skipClanKeyCrafting: `[UNTRANSLATED] Skip Clan Key Crafting`, cheats_noDojoRoomBuildStage: `Kein Dojo-Raum-Bauvorgang`, cheats_noDojoDecoBuildStage: `Kein Dojo-Deko-Bauvorgang`, cheats_fastDojoRoomDestruction: `Schnelle Dojo-Raum-Zerstörung`, diff --git a/static/webui/translations/en.js b/static/webui/translations/en.js index a2c3f312..01a4a23f 100644 --- a/static/webui/translations/en.js +++ b/static/webui/translations/en.js @@ -153,6 +153,7 @@ dict = { cheats_noKimCooldowns: `No KIM Cooldowns`, cheats_instantResourceExtractorDrones: `Instant Resource Extractor Drones`, cheats_noResourceExtractorDronesDamage: `No Resource Extractor Drones Damage`, + cheats_skipClanKeyCrafting: `Skip Clan Key Crafting`, cheats_noDojoRoomBuildStage: `No Dojo Room Build Stage`, cheats_noDojoDecoBuildStage: `No Dojo Deco Build Stage`, cheats_fastDojoRoomDestruction: `Fast Dojo Room Destruction`, diff --git a/static/webui/translations/es.js b/static/webui/translations/es.js index d8e3f2aa..fbc0acc5 100644 --- a/static/webui/translations/es.js +++ b/static/webui/translations/es.js @@ -154,6 +154,7 @@ dict = { cheats_noKimCooldowns: `Sin tiempo de espera para conversaciones KIM`, cheats_instantResourceExtractorDrones: `Drones de extracción de recursos instantáneos`, cheats_noResourceExtractorDronesDamage: `Sin daño a los drones extractores de recursos`, + cheats_skipClanKeyCrafting: `[UNTRANSLATED] Skip Clan Key Crafting`, cheats_noDojoRoomBuildStage: `Sin etapa de construcción de sala del dojo`, cheats_noDojoDecoBuildStage: `Sin etapa de construcción de decoraciones del dojo`, cheats_fastDojoRoomDestruction: `Destrucción rápida de salas del dojo`, diff --git a/static/webui/translations/fr.js b/static/webui/translations/fr.js index e8c6f369..1dab80e6 100644 --- a/static/webui/translations/fr.js +++ b/static/webui/translations/fr.js @@ -154,6 +154,7 @@ dict = { cheats_noKimCooldowns: `Aucun cooldown sur le KIM`, cheats_instantResourceExtractorDrones: `Ressources de drones d'extraction instantannées`, cheats_noResourceExtractorDronesDamage: `Aucun dégâts aux drones d'extraction de resources`, + cheats_skipClanKeyCrafting: `[UNTRANSLATED] Skip Clan Key Crafting`, cheats_noDojoRoomBuildStage: `Aucune attente (construction des salles)`, cheats_noDojoDecoBuildStage: `Aucune attente (construction des décorations)`, cheats_fastDojoRoomDestruction: `Destruction de salle instantanée (Dojo)`, diff --git a/static/webui/translations/ru.js b/static/webui/translations/ru.js index 919dc13b..d02f54a5 100644 --- a/static/webui/translations/ru.js +++ b/static/webui/translations/ru.js @@ -154,6 +154,7 @@ dict = { cheats_noKimCooldowns: `Чаты KIM без кулдауна`, cheats_instantResourceExtractorDrones: `Мгновенные Экстракторы Ресурсов`, cheats_noResourceExtractorDronesDamage: `Без урона по дронам-сборщикам`, + cheats_skipClanKeyCrafting: `[UNTRANSLATED] Skip Clan Key Crafting`, cheats_noDojoRoomBuildStage: `Мгновенное Строительтво Комнат Додзё`, cheats_noDojoDecoBuildStage: `Мгновенное Строительтво Декораций Додзё`, cheats_fastDojoRoomDestruction: `Мгновенные Уничтожение Комнат Додзё`, diff --git a/static/webui/translations/zh.js b/static/webui/translations/zh.js index 4148d86b..2699f0a8 100644 --- a/static/webui/translations/zh.js +++ b/static/webui/translations/zh.js @@ -154,6 +154,7 @@ dict = { cheats_noKimCooldowns: `[UNTRANSLATED] No KIM Cooldowns`, cheats_instantResourceExtractorDrones: `即时资源采集无人机`, cheats_noResourceExtractorDronesDamage: `[UNTRANSLATED] No Resource Extractor Drones Damage`, + cheats_skipClanKeyCrafting: `[UNTRANSLATED] Skip Clan Key Crafting`, cheats_noDojoRoomBuildStage: `无视道场房间建造阶段`, cheats_noDojoDecoBuildStage: `[UNTRANSLATED] No Dojo Deco Build Stage`, cheats_fastDojoRoomDestruction: `快速拆除道场房间`,