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

SpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/SpaceNinjaServer

feat: retroactive clan research cheats (#3716)

Closes #3713 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3716 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

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

代码差异

2 个文件 +37 -7
Modified src/controllers/custom/retroactivelyApplyGuildCheatController.ts +1 -1
@@ -12,7 +12,7 @@ export const retroactivelyApplyGuildCheatController: RequestHandler = async (req
12 12 const member = await GuildMember.findOne({ accountId: accountId, guildId: guild._id });
13 13 if (member && member.rank <= 1) {
14 14 const meta = clanLockCheats[req.query.cheat as string as keyof IGuildCheats]!;
15 const msgs = meta.cleanupGuild(guild);
15 const msgs = await meta.cleanupGuild(guild);
16 16 if (!meta.isGuildInIdealState(guild)) {
17 17 throw new Error(`cleanupGuild for ${req.query.cheat as string} does not satsify its isGuildInIdealState`);
18 18 }
Modified src/services/clanCheatsService.ts +36 -6
@@ -1,9 +1,10 @@
1 1 import type { TGuildDatabaseDocument } from "../models/guildModel.ts";
2 2 import type { IGuildCheats } from "../types/guildTypes.ts";
3 import { processGuildTechProjectContributionsUpdate } from "./guildService.ts";
3 4
4 5 interface IClanLockCheat {
5 6 isGuildInIdealState: (guild: TGuildDatabaseDocument) => boolean;
6 cleanupGuild: (guild: TGuildDatabaseDocument) => string[];
7 cleanupGuild: (guild: TGuildDatabaseDocument) => Promise<string[]>;
7 8 }
8 9
9 10 export const clanLockCheats: Partial<Record<keyof IGuildCheats, IClanLockCheat>> = {
@@ -18,9 +19,9 @@ export const clanLockCheats: Partial<Record<keyof IGuildCheats, IClanLockCheat>>
18 19 component.CompletionTime = new Date();
19 20 }
20 21 }
21 return [
22 return Promise.resolve([
22 23 `{"from":"000000000000000000000000","to":"dojo","msg":{"dojoMsgType":1,"n":1,"a":false,"f":false,"u":""}}`
23 ];
24 ]);
24 25 }
25 26 },
26 27 fastDojoRoomDestruction: {
@@ -34,9 +35,9 @@ export const clanLockCheats: Partial<Record<keyof IGuildCheats, IClanLockCheat>>
34 35 component.DestructionTime = new Date();
35 36 }
36 37 }
37 return [
38 return Promise.resolve([
38 39 `{"from":"000000000000000000000000","to":"dojo","msg":{"dojoMsgType":1,"n":1,"a":false,"f":false,"u":""}}`
39 ];
40 ]);
40 41 }
41 42 },
42 43 noDojoDecoBuildStage: {
@@ -64,7 +65,36 @@ export const clanLockCheats: Partial<Record<keyof IGuildCheats, IClanLockCheat>>
64 65 }
65 66 }
66 67 }
67 return msgs;
68 return Promise.resolve(msgs);
69 }
70 },
71 noDojoResearchCosts: {
72 isGuildInIdealState: (guild: TGuildDatabaseDocument) => (guild.TechProjects ?? []).every(x => x.CompletionDate),
73 cleanupGuild: async (guild: TGuildDatabaseDocument) => {
74 for (const techProject of guild.TechProjects!) {
75 techProject.ReqCredits = 0;
76 for (const item of techProject.ReqItems) {
77 item.ItemCount = 0;
78 }
79 await processGuildTechProjectContributionsUpdate(guild, techProject);
80 }
81 // The client sends this message when contributing to guild research, but it doesn't seem to cause it to refresh the UI. :/
82 //return [`{"from":"000000000000000000000000","to":"clan","msg":{"dojoMsgType":3,"g":true,"a":false}}`];
83 return [];
84 }
85 },
86 noDojoResearchTime: {
87 isGuildInIdealState: (guild: TGuildDatabaseDocument) =>
88 (guild.TechProjects ?? []).every(x => !x.CompletionDate || x.CompletionDate.getTime() <= Date.now()),
89 cleanupGuild: (guild: TGuildDatabaseDocument) => {
90 for (const techProject of guild.TechProjects!) {
91 if (techProject.CompletionDate && techProject.CompletionDate.getTime() > Date.now()) {
92 techProject.CompletionDate = new Date();
93 }
94 }
95 return Promise.resolve([
96 //`{"from":"000000000000000000000000","to":"clan","msg":{"dojoMsgType":3,"g":true,"a":false}}`
97 ]);
68 98 }
69 99 }
70 100 };