XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

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>

afec59e8
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

12 个文件 +57 -35
Modified config.json.example +1 -0
@@ -38,6 +38,7 @@
38 38 "noKimCooldowns": false,
39 39 "instantResourceExtractorDrones": false,
40 40 "noResourceExtractorDronesDamage": false,
41 "skipClanKeyCrafting": false,
41 42 "noDojoRoomBuildStage": false,
42 43 "noDecoBuildStage": false,
43 44 "fastDojoRoomDestruction": false,
Modified src/controllers/api/confirmGuildInvitationController.ts +11 -17
@@ -1,8 +1,14 @@
1 1 import { getJSONfromString } from "@/src/helpers/stringHelpers";
2 2 import { Guild, GuildMember } from "@/src/models/guildModel";
3 3 import { Account } from "@/src/models/loginModel";
4 import { deleteGuild, getGuildClient, hasGuildPermission, removeDojoKeyItems } from "@/src/services/guildService";
5 import { addRecipes, combineInventoryChanges, getInventory } from "@/src/services/inventoryService";
4 import {
5 deleteGuild,
6 getGuildClient,
7 giveClanKey,
8 hasGuildPermission,
9 removeDojoKeyItems
10 } from "@/src/services/guildService";
11 import { getInventory } from "@/src/services/inventoryService";
6 12 import { getAccountForRequest, getAccountIdForRequest, getSuffixedName } from "@/src/services/loginService";
7 13 import { GuildPermission } from "@/src/types/guildTypes";
8 14 import { IInventoryChanges } from "@/src/types/purchaseTypes";
@@ -41,14 +47,7 @@ export const confirmGuildInvitationGetController: RequestHandler = async (req, r
41 47 // Update inventory of new member
42 48 const inventory = await getInventory(account._id.toString(), "GuildId LevelKeys Recipes");
43 49 inventory.GuildId = new Types.ObjectId(req.query.clanId as string);
44 const recipeChanges = [
45 {
46 ItemType: "/Lotus/Types/Keys/DojoKeyBlueprint",
47 ItemCount: 1
48 }
49 ];
50 addRecipes(inventory, recipeChanges);
51 combineInventoryChanges(inventoryChanges, { Recipes: recipeChanges });
50 giveClanKey(inventory, inventoryChanges);
52 51 await inventory.save();
53 52
54 53 const guild = (await Guild.findById(req.query.clanId as string))!;
@@ -96,14 +95,9 @@ export const confirmGuildInvitationPostController: RequestHandler = async (req,
96 95 await GuildMember.deleteMany({ accountId: guildMember.accountId, status: 1 });
97 96
98 97 // Update inventory of new member
99 const inventory = await getInventory(guildMember.accountId.toString(), "GuildId Recipes");
98 const inventory = await getInventory(guildMember.accountId.toString(), "GuildId LevelKeys Recipes");
100 99 inventory.GuildId = new Types.ObjectId(req.query.clanId as string);
101 addRecipes(inventory, [
102 {
103 ItemType: "/Lotus/Types/Keys/DojoKeyBlueprint",
104 ItemCount: 1
105 }
106 ]);
100 giveClanKey(inventory);
107 101 await inventory.save();
108 102
109 103 // Add join to clan log
Modified src/controllers/api/createGuildController.ts +7 -17
@@ -2,8 +2,9 @@ import { RequestHandler } from "express";
2 2 import { getAccountIdForRequest } from "@/src/services/loginService";
3 3 import { getJSONfromString } from "@/src/helpers/stringHelpers";
4 4 import { Guild, GuildMember } from "@/src/models/guildModel";
5 import { createUniqueClanName, getGuildClient } from "@/src/services/guildService";
6 import { addRecipes, getInventory } from "@/src/services/inventoryService";
5 import { createUniqueClanName, getGuildClient, giveClanKey } from "@/src/services/guildService";
6 import { getInventory } from "@/src/services/inventoryService";
7 import { IInventoryChanges } from "@/src/types/purchaseTypes";
7 8
8 9 export const createGuildController: RequestHandler = async (req, res) => {
9 10 const accountId = await getAccountIdForRequest(req);
@@ -26,26 +27,15 @@ export const createGuildController: RequestHandler = async (req, res) => {
26 27 rank: 0
27 28 });
28 29
29 const inventory = await getInventory(accountId, "GuildId Recipes");
30 const inventory = await getInventory(accountId, "GuildId LevelKeys Recipes");
30 31 inventory.GuildId = guild._id;
31 addRecipes(inventory, [
32 {
33 ItemType: "/Lotus/Types/Keys/DojoKeyBlueprint",
34 ItemCount: 1
35 }
36 ]);
32 const inventoryChanges: IInventoryChanges = {};
33 giveClanKey(inventory, inventoryChanges);
37 34 await inventory.save();
38 35
39 36 res.json({
40 37 ...(await getGuildClient(guild, accountId)),
41 InventoryChanges: {
42 Recipes: [
43 {
44 ItemType: "/Lotus/Types/Keys/DojoKeyBlueprint",
45 ItemCount: 1
46 }
47 ]
48 }
38 InventoryChanges: inventoryChanges
49 39 });
50 40 };
51 41
Modified src/services/configService.ts +1 -0
@@ -44,6 +44,7 @@ interface IConfig {
44 44 noKimCooldowns?: boolean;
45 45 instantResourceExtractorDrones?: boolean;
46 46 noResourceExtractorDronesDamage?: boolean;
47 skipClanKeyCrafting?: boolean;
47 48 noDojoRoomBuildStage?: boolean;
48 49 noDojoDecoBuildStage?: boolean;
49 50 fastDojoRoomDestruction?: boolean;
Modified src/services/guildService.ts +27 -1
@@ -1,6 +1,6 @@
1 1 import { Request } from "express";
2 2 import { getAccountIdForRequest } from "@/src/services/loginService";
3 import { getInventory } from "@/src/services/inventoryService";
3 import { addLevelKeys, addRecipes, combineInventoryChanges, getInventory } from "@/src/services/inventoryService";
4 4 import { Alliance, AllianceMember, Guild, GuildAd, GuildMember, TGuildDatabaseDocument } from "@/src/models/guildModel";
5 5 import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
6 6 import {
@@ -657,6 +657,32 @@ export const checkClanAscensionHasRequiredContributors = async (guild: TGuildDat
657 657 }
658 658 };
659 659
660 export const giveClanKey = (inventory: TInventoryDatabaseDocument, inventoryChanges?: IInventoryChanges): void => {
661 if (config.skipClanKeyCrafting) {
662 const levelKeyChanges = [
663 {
664 ItemType: "/Lotus/Types/Keys/DojoKey",
665 ItemCount: 1
666 }
667 ];
668 addLevelKeys(inventory, levelKeyChanges);
669 if (inventoryChanges) {
670 combineInventoryChanges(inventoryChanges, { LevelKeys: levelKeyChanges });
671 }
672 } else {
673 const recipeChanges = [
674 {
675 ItemType: "/Lotus/Types/Keys/DojoKeyBlueprint",
676 ItemCount: 1
677 }
678 ];
679 addRecipes(inventory, recipeChanges);
680 if (inventoryChanges) {
681 combineInventoryChanges(inventoryChanges, { Recipes: recipeChanges });
682 }
683 }
684 };
685
660 686 export const removeDojoKeyItems = (inventory: TInventoryDatabaseDocument): IInventoryChanges => {
661 687 const inventoryChanges: IInventoryChanges = {};
662 688
Modified static/webui/index.html +4 -0
@@ -674,6 +674,10 @@
674 674 <input class="form-check-input" type="checkbox" id="noResourceExtractorDronesDamage" />
675 675 <label class="form-check-label" for="noResourceExtractorDronesDamage" data-loc="cheats_noResourceExtractorDronesDamage"></label>
676 676 </div>
677 <div class="form-check">
678 <input class="form-check-input" type="checkbox" id="skipClanKeyCrafting" />
679 <label class="form-check-label" for="skipClanKeyCrafting" data-loc="cheats_skipClanKeyCrafting"></label>
680 </div>
677 681 <div class="form-check">
678 682 <input class="form-check-input" type="checkbox" id="noDojoRoomBuildStage" />
679 683 <label class="form-check-label" for="noDojoRoomBuildStage" data-loc="cheats_noDojoRoomBuildStage"></label>
Modified static/webui/translations/de.js +1 -0
@@ -154,6 +154,7 @@ dict = {
154 154 cheats_noKimCooldowns: `Keine Wartezeit bei KIM`,
155 155 cheats_instantResourceExtractorDrones: `Sofortige Ressourcen-Extraktor-Drohnen`,
156 156 cheats_noResourceExtractorDronesDamage: `Kein Schaden für Ressourcen-Extraktor-Drohnen`,
157 cheats_skipClanKeyCrafting: `[UNTRANSLATED] Skip Clan Key Crafting`,
157 158 cheats_noDojoRoomBuildStage: `Kein Dojo-Raum-Bauvorgang`,
158 159 cheats_noDojoDecoBuildStage: `Kein Dojo-Deko-Bauvorgang`,
159 160 cheats_fastDojoRoomDestruction: `Schnelle Dojo-Raum-Zerstörung`,
Modified static/webui/translations/en.js +1 -0
@@ -153,6 +153,7 @@ dict = {
153 153 cheats_noKimCooldowns: `No KIM Cooldowns`,
154 154 cheats_instantResourceExtractorDrones: `Instant Resource Extractor Drones`,
155 155 cheats_noResourceExtractorDronesDamage: `No Resource Extractor Drones Damage`,
156 cheats_skipClanKeyCrafting: `Skip Clan Key Crafting`,
156 157 cheats_noDojoRoomBuildStage: `No Dojo Room Build Stage`,
157 158 cheats_noDojoDecoBuildStage: `No Dojo Deco Build Stage`,
158 159 cheats_fastDojoRoomDestruction: `Fast Dojo Room Destruction`,
Modified static/webui/translations/es.js +1 -0
@@ -154,6 +154,7 @@ dict = {
154 154 cheats_noKimCooldowns: `Sin tiempo de espera para conversaciones KIM`,
155 155 cheats_instantResourceExtractorDrones: `Drones de extracción de recursos instantáneos`,
156 156 cheats_noResourceExtractorDronesDamage: `Sin daño a los drones extractores de recursos`,
157 cheats_skipClanKeyCrafting: `[UNTRANSLATED] Skip Clan Key Crafting`,
157 158 cheats_noDojoRoomBuildStage: `Sin etapa de construcción de sala del dojo`,
158 159 cheats_noDojoDecoBuildStage: `Sin etapa de construcción de decoraciones del dojo`,
159 160 cheats_fastDojoRoomDestruction: `Destrucción rápida de salas del dojo`,
Modified static/webui/translations/fr.js +1 -0
@@ -154,6 +154,7 @@ dict = {
154 154 cheats_noKimCooldowns: `Aucun cooldown sur le KIM`,
155 155 cheats_instantResourceExtractorDrones: `Ressources de drones d'extraction instantannées`,
156 156 cheats_noResourceExtractorDronesDamage: `Aucun dégâts aux drones d'extraction de resources`,
157 cheats_skipClanKeyCrafting: `[UNTRANSLATED] Skip Clan Key Crafting`,
157 158 cheats_noDojoRoomBuildStage: `Aucune attente (construction des salles)`,
158 159 cheats_noDojoDecoBuildStage: `Aucune attente (construction des décorations)`,
159 160 cheats_fastDojoRoomDestruction: `Destruction de salle instantanée (Dojo)`,
Modified static/webui/translations/ru.js +1 -0
@@ -154,6 +154,7 @@ dict = {
154 154 cheats_noKimCooldowns: `Чаты KIM без кулдауна`,
155 155 cheats_instantResourceExtractorDrones: `Мгновенные Экстракторы Ресурсов`,
156 156 cheats_noResourceExtractorDronesDamage: `Без урона по дронам-сборщикам`,
157 cheats_skipClanKeyCrafting: `[UNTRANSLATED] Skip Clan Key Crafting`,
157 158 cheats_noDojoRoomBuildStage: `Мгновенное Строительтво Комнат Додзё`,
158 159 cheats_noDojoDecoBuildStage: `Мгновенное Строительтво Декораций Додзё`,
159 160 cheats_fastDojoRoomDestruction: `Мгновенные Уничтожение Комнат Додзё`,
Modified static/webui/translations/zh.js +1 -0
@@ -154,6 +154,7 @@ dict = {
154 154 cheats_noKimCooldowns: `[UNTRANSLATED] No KIM Cooldowns`,
155 155 cheats_instantResourceExtractorDrones: `即时资源采集无人机`,
156 156 cheats_noResourceExtractorDronesDamage: `[UNTRANSLATED] No Resource Extractor Drones Damage`,
157 cheats_skipClanKeyCrafting: `[UNTRANSLATED] Skip Clan Key Crafting`,
157 158 cheats_noDojoRoomBuildStage: `无视道场房间建造阶段`,
158 159 cheats_noDojoDecoBuildStage: `[UNTRANSLATED] No Dojo Deco Build Stage`,
159 160 cheats_fastDojoRoomDestruction: `快速拆除道场房间`,