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: blood of perita event emails (#3763)

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

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

代码差异

10 个文件 +80 -51
Modified src/controllers/api/inboxController.ts +12 -1
@@ -258,6 +258,18 @@ const createNewEventMessages = async (account: TAccountDocument): Promise<void>
258 258 goalTag: "GalleonRobbery"
259 259 });
260 260 }
261 if (config.worldState?.bloodOfPerita && !account.receivedEventMessage_bloodOfPerita) {
262 account.receivedEventMessage_bloodOfPerita = true;
263 newEventMessages.push({
264 sndr: "/Lotus/Language/1999/MessengerRoatheName",
265 sub: "/Lotus/Language/TauPrequel/TauPrequelFinal/RoathesValorIntroInboxTitle",
266 msg: "/Lotus/Language/TauPrequel/TauPrequelFinal/RoathesValorIntroInbox",
267 icon: "/Lotus/Interface/Icons/Npcs/Roathe.png",
268 startDate: new Date(),
269 transmission: "/Lotus/Sounds/Dialog/Tau/RoatheEventOutroInbox/DRoatheEventIntroInbox0010Roathe",
270 QuestReq: "/Lotus/Types/Keys/TauPrequel/TauPrequelQuestKeyChain"
271 });
272 }
261 273 if (config.worldState?.longShadow && !account.receivedEventMessage_longShadow) {
262 274 account.receivedEventMessage_longShadow = true;
263 275 newEventMessages.push({
@@ -269,7 +281,6 @@ const createNewEventMessages = async (account: TAccountDocument): Promise<void>
269 281 goalTag: "NightwatchTacAlert"
270 282 });
271 283 }
272
273 284 if (config.worldState?.operationAtramentum && !account.receivedEventMessage_operationAtramentum) {
274 285 account.receivedEventMessage_operationAtramentum = true;
275 286 newEventMessages.push({
Modified src/controllers/arbiter/hubController.ts +2 -2
@@ -1,6 +1,6 @@
1 1 import type { RequestHandler } from "express";
2 import { config, getReflexiveAddress, type IHubServer } from "../../services/configService.ts";
3 import { hubInstances, pickHubServer, type TRegionId } from "../../services/arbiterService.ts";
2 import { config, getReflexiveAddress, type IHubServer, type TRegionId } from "../../services/configService.ts";
3 import { hubInstances, pickHubServer } from "../../services/arbiterService.ts";
4 4
5 5 export const hubController: RequestHandler = (req, res) => {
6 6 const arr = (req.query.level as string).split("_");
Modified src/controllers/arbiter/statsController.ts +2 -7
@@ -1,11 +1,6 @@
1 1 import type { RequestHandler } from "express";
2 import {
3 getAllHubServerStats,
4 hubInstances,
5 type IHubServerStats,
6 type TRegionId
7 } from "../../services/arbiterService.ts";
8 import { config } from "../../services/configService.ts";
2 import { getAllHubServerStats, hubInstances, type IHubServerStats } from "../../services/arbiterService.ts";
3 import { config, type TRegionId } from "../../services/configService.ts";
9 4
10 5 export const statsController: RequestHandler = (_req, res) => {
11 6 const response: IArbiterStatsResponse = {
Modified src/controllers/custom/configController.ts +2 -1
@@ -1,5 +1,6 @@
1 1 import type { RequestHandler } from "express";
2 import { config, syncConfigWithDatabase } from "../../services/configService.ts";
2 import { config } from "../../services/configService.ts";
3 import { syncConfigWithDatabase } from "../../services/configWatcherService.ts";
3 4 import { getAccountForRequest, isAdministrator } from "../../services/loginService.ts";
4 5 import { saveConfig } from "../../services/configWriterService.ts";
5 6 import { sendWsBroadcastEx, sendWsBroadcast } from "../../services/wsService.ts";
Modified src/index.ts +2 -2
@@ -1,5 +1,5 @@
1 1 // First, init config.
2 import { config, configPath, loadConfig, syncConfigWithDatabase } from "./services/configService.ts";
2 import { config, configPath, loadConfig } from "./services/configService.ts";
3 3 import fs from "fs";
4 4 try {
5 5 loadConfig();
@@ -22,7 +22,7 @@ import path from "path";
22 22 import child_process from "child_process";
23 23 import { JSONStringify } from "json-with-bigint";
24 24 import { startWebServer } from "./services/webService.ts";
25 import { validateConfig } from "./services/configWatcherService.ts";
25 import { syncConfigWithDatabase, validateConfig } from "./services/configWatcherService.ts";
26 26 import { updateWorldStateCollections } from "./services/worldStateService.ts";
27 27 import { repoDir } from "./helpers/pathHelper.ts";
28 28 import { MongoMemoryServer } from "mongodb-memory-server-core";
Modified src/models/loginModel.ts +1 -0
@@ -34,6 +34,7 @@ const databaseAccountSchema = new Schema<IDatabaseAccountJson>(
34 34 receivedEventMessage_affinityBoost: Boolean,
35 35 receivedEventMessage_resourceBoost: Boolean,
36 36 receivedEventMessage_galleonOfGhouls: Boolean,
37 receivedEventMessage_bloodOfPerita: Boolean,
37 38 receivedEventMessage_longShadow: Boolean,
38 39 receivedEventMessage_operationAtramentum: Boolean
39 40 },
Modified src/services/arbiterService.ts +1 -3
@@ -1,9 +1,7 @@
1 1 import { packHubDatagram } from "../helpers/udp.ts";
2 import { config, type IHubServer } from "./configService.ts";
2 import { config, type IHubServer, type TRegionId } from "./configService.ts";
3 3 import dgram from "node:dgram";
4 4
5 export type TRegionId = "ASIA" | "OCEANIA" | "EUROPE" | "RUSSIA" | "NORTH_AMERICA" | "SOUTH_AMERICA";
6
7 5 export interface IHubInstance {
8 6 Players: number;
9 7 Hub: string;
Modified src/services/configService.ts +2 -34
@@ -2,10 +2,9 @@ import fs from "fs";
2 2 import path from "path";
3 3 import { repoDir } from "../helpers/pathHelper.ts";
4 4 import { args } from "../helpers/commandLineArguments.ts";
5 import { Inbox } from "../models/inboxModel.ts";
6 5 import type { Request } from "express";
7 import { Account } from "../models/loginModel.ts";
8 import type { TRegionId } from "./arbiterService.ts";
6
7 export type TRegionId = "ASIA" | "OCEANIA" | "EUROPE" | "RUSSIA" | "NORTH_AMERICA" | "SOUTH_AMERICA";
9 8
10 9 export interface IHubServer {
11 10 address: string;
@@ -230,37 +229,6 @@ export const loadConfig = (): void => {
230 229 Object.assign(config, newConfig);
231 230 };
232 231
233 export const syncConfigWithDatabase = (): void => {
234 // Event messages are deleted after endDate. Since we don't use beginDate/endDate and instead have config toggles, we need to delete the messages once those bools are false.
235 // Also, for some reason, I can't just do `Inbox.deleteMany(...)`; - it needs this whole circus.
236 if (!config.worldState?.creditBoost) {
237 void Account.updateMany({}, { $unset: { receivedEventMessage_creditBoost: 1 } }).then(() => {});
238 void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666672" }).then(() => {});
239 }
240 if (!config.worldState?.affinityBoost) {
241 void Account.updateMany({}, { $unset: { receivedEventMessage_affinityBoost: 1 } }).then(() => {});
242 void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666673" }).then(() => {});
243 }
244 if (!config.worldState?.resourceBoost) {
245 void Account.updateMany({}, { $unset: { receivedEventMessage_resourceBoost: 1 } }).then(() => {});
246 void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666674" }).then(() => {});
247 }
248 if (!config.worldState?.galleonOfGhouls) {
249 void Account.updateMany({}, { $unset: { receivedEventMessage_galleonOfGhouls: 1 } }).then(() => {});
250 void Inbox.deleteMany({ goalTag: "GalleonRobbery" }).then(() => {});
251 }
252 if (!config.worldState?.longShadow) {
253 void Account.updateMany({}, { $unset: { receivedEventMessage_longShadow: 1 } }).then(() => {});
254 void Inbox.deleteMany({ goalTag: "NightwatchTacAlert" }).then(() => {});
255 }
256 if (!config.worldState?.operationAtramentum) {
257 void Account.updateMany({}, { $unset: { receivedEventMessage_operationAtramentum: 1 } }).then(() => {});
258 void Inbox.deleteMany({
259 transmission: "/Lotus/Sounds/Dialog/Shadowgrapher/Vendor/DSGInbox0011AspirantZorba"
260 }).then(() => {});
261 }
262 };
263
264 232 export const getReflexiveAddress = (request: Request): { myAddress: string; myUrlBase: string } => {
265 233 let myAddress: string;
266 234 let myUrlBase: string = request.protocol + "://";
Modified src/services/configWatcherService.ts +55 -1
@@ -7,7 +7,6 @@ import {
7 7 configRemovedOptionsKeys,
8 8 getWebServerParams,
9 9 loadConfig,
10 syncConfigWithDatabase,
11 10 type IConfig
12 11 } from "./configService.ts";
13 12 import { saveConfig, shouldReloadConfig } from "./configWriterService.ts";
@@ -21,6 +20,9 @@ import {
21 20 } from "./wsService.ts";
22 21 import varzia from "../constants/varzia.ts";
23 22 import { getTunablesForClient } from "./tunablesService.ts";
23 import { Account } from "../models/loginModel.ts";
24 import { Inbox } from "../models/inboxModel.ts";
25 import { createMessage } from "./inboxService.ts";
24 26
25 27 chokidar.watch(configPath).on("change", () => {
26 28 if (shouldReloadConfig()) {
@@ -172,3 +174,55 @@ export const validateConfig = (): void => {
172 174 void saveConfig();
173 175 }
174 176 };
177
178 export const syncConfigWithDatabase = (): void => {
179 // Event messages are deleted after endDate. Since we don't use beginDate/endDate and instead have config toggles, we need to delete the messages once those bools are false.
180 // Also, for some reason, I can't just do `Inbox.deleteMany(...)`; - it needs this whole circus.
181 if (!config.worldState?.creditBoost) {
182 void Account.updateMany({}, { $unset: { receivedEventMessage_creditBoost: 1 } }).then(() => {});
183 void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666672" }).then(() => {});
184 }
185 if (!config.worldState?.affinityBoost) {
186 void Account.updateMany({}, { $unset: { receivedEventMessage_affinityBoost: 1 } }).then(() => {});
187 void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666673" }).then(() => {});
188 }
189 if (!config.worldState?.resourceBoost) {
190 void Account.updateMany({}, { $unset: { receivedEventMessage_resourceBoost: 1 } }).then(() => {});
191 void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666674" }).then(() => {});
192 }
193 if (!config.worldState?.galleonOfGhouls) {
194 void Account.updateMany({}, { $unset: { receivedEventMessage_galleonOfGhouls: 1 } }).then(() => {});
195 void Inbox.deleteMany({ goalTag: "GalleonRobbery" }).then(() => {});
196 }
197 if (!config.worldState?.longShadow) {
198 void Account.updateMany({}, { $unset: { receivedEventMessage_longShadow: 1 } }).then(() => {});
199 void Inbox.deleteMany({ goalTag: "NightwatchTacAlert" }).then(() => {});
200 }
201 if (!config.worldState?.bloodOfPerita) {
202 void Account.find({ receivedEventMessage_bloodOfPerita: { $exists: true } }, "_id").then(accounts => {
203 for (const account of accounts) {
204 void createMessage(account._id, [
205 {
206 sndr: "/Lotus/Language/1999/MessengerRoatheName",
207 sub: "/Lotus/Language/TauPrequel/TauPrequelFinal/RoathesValorOutroInboxTitle",
208 msg: "/Lotus/Language/TauPrequel/TauPrequelFinal/RoathesValorOutroInbox",
209 icon: "/Lotus/Interface/Icons/Npcs/Roathe.png",
210 // startDate & endDate would be present with the event dates but MongoDB would delete the message if we set an endDate in the past.
211 transmission: "/Lotus/Sounds/Dialog/Tau/RoatheEventOutroInbox/DRoatheEventOutroInbox0020Roathe",
212 QuestReq: "/Lotus/Types/Keys/TauPrequel/TauPrequelQuestKeyChain"
213 }
214 ]);
215 }
216 void Account.updateMany({}, { $unset: { receivedEventMessage_bloodOfPerita: 1 } }).then(() => {});
217 });
218 void Inbox.deleteMany({
219 transmission: "/Lotus/Sounds/Dialog/Tau/RoatheEventOutroInbox/DRoatheEventIntroInbox0010Roathe"
220 }).then(() => {});
221 }
222 if (!config.worldState?.operationAtramentum) {
223 void Account.updateMany({}, { $unset: { receivedEventMessage_operationAtramentum: 1 } }).then(() => {});
224 void Inbox.deleteMany({
225 transmission: "/Lotus/Sounds/Dialog/Shadowgrapher/Vendor/DSGInbox0011AspirantZorba"
226 }).then(() => {});
227 }
228 };
Modified src/types/loginTypes.ts +1 -0
@@ -39,6 +39,7 @@ export interface IDatabaseAccount extends IDatabaseAccountRequiredFields {
39 39 receivedEventMessage_affinityBoost?: boolean;
40 40 receivedEventMessage_resourceBoost?: boolean;
41 41 receivedEventMessage_galleonOfGhouls?: boolean;
42 receivedEventMessage_bloodOfPerita?: boolean;
42 43 receivedEventMessage_longShadow?: boolean;
43 44 receivedEventMessage_operationAtramentum?: boolean;
44 45 }