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

fix: better handling of assassination missions in sorties (#1930)

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

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

代码差异

2 个文件 +27 -34
Modified src/services/rngService.ts +3 -3
@@ -6,7 +6,7 @@ export interface IRngResult {
6 6 probability: number;
7 7 }
8 8
9 export const getRandomElement = <T>(arr: T[]): T | undefined => {
9 export const getRandomElement = <T>(arr: readonly T[]): T | undefined => {
10 10 return arr[Math.floor(Math.random() * arr.length)];
11 11 };
12 12
@@ -113,7 +113,7 @@ export class CRng {
113 113 return min;
114 114 }
115 115
116 randomElement<T>(arr: T[]): T | undefined {
116 randomElement<T>(arr: readonly T[]): T | undefined {
117 117 return arr[Math.floor(this.random() * arr.length)];
118 118 }
119 119
@@ -145,7 +145,7 @@ export class SRng {
145 145 return min;
146 146 }
147 147
148 randomElement<T>(arr: T[]): T | undefined {
148 randomElement<T>(arr: readonly T[]): T | undefined {
149 149 return arr[this.randomInt(0, arr.length - 1)];
150 150 }
151 151
Modified src/services/worldStateService.ts +24 -31
@@ -33,9 +33,11 @@ const sortieBosses = [
33 33 "SORTIE_BOSS_LEPHANTIS",
34 34 "SORTIE_BOSS_INFALAD",
35 35 "SORTIE_BOSS_CORRUPTED_VOR"
36 ];
36 ] as const;
37
38 type TSortieBoss = (typeof sortieBosses)[number];
37 39
38 const sortieBossToFaction: Record<string, string> = {
40 const sortieBossToFaction: Record<TSortieBoss, string> = {
39 41 SORTIE_BOSS_HYENA: "FC_CORPUS",
40 42 SORTIE_BOSS_KELA: "FC_GRINEER",
41 43 SORTIE_BOSS_VOR: "FC_GRINEER",
@@ -74,21 +76,22 @@ const sortieFactionToSpecialMissionTileset: Record<string, string> = {
74 76 FC_INFESTATION: "CorpusShipTileset"
75 77 };
76 78
77 const sortieBossNode: Record<string, string> = {
79 const sortieBossNode: Record<Exclude<TSortieBoss, "SORTIE_BOSS_CORRUPTED_VOR">, string> = {
80 SORTIE_BOSS_ALAD: "SolNode53",
81 SORTIE_BOSS_AMBULAS: "SolNode51",
82 SORTIE_BOSS_HEK: "SolNode24",
78 83 SORTIE_BOSS_HYENA: "SolNode127",
84 SORTIE_BOSS_INFALAD: "SolNode166",
85 SORTIE_BOSS_JACKAL: "SolNode104",
79 86 SORTIE_BOSS_KELA: "SolNode193",
80 SORTIE_BOSS_VOR: "SolNode108",
81 SORTIE_BOSS_RUK: "SolNode32",
82 SORTIE_BOSS_HEK: "SolNode24",
83 87 SORTIE_BOSS_KRIL: "SolNode99",
84 SORTIE_BOSS_TYL: "SolNode105",
85 SORTIE_BOSS_JACKAL: "SolNode104",
86 SORTIE_BOSS_ALAD: "SolNode53",
87 SORTIE_BOSS_AMBULAS: "SolNode51",
88 SORTIE_BOSS_LEPHANTIS: "SolNode712",
88 89 SORTIE_BOSS_NEF: "SettlementNode20",
90 SORTIE_BOSS_PHORID: "SolNode171",
89 91 SORTIE_BOSS_RAPTOR: "SolNode210",
90 SORTIE_BOSS_LEPHANTIS: "SolNode712",
91 SORTIE_BOSS_INFALAD: "SolNode705"
92 SORTIE_BOSS_RUK: "SolNode32",
93 SORTIE_BOSS_TYL: "SolNode105",
94 SORTIE_BOSS_VOR: "SolNode108"
92 95 };
93 96
94 97 const eidolonJobs = [
@@ -270,6 +273,7 @@ const pushSortieIfRelevant = (worldState: IWorldState, day: number): void => {
270 273 key in sortieTilesets
271 274 ) {
272 275 if (
276 value.missionIndex != 0 && // Assassination will be decided independently
273 277 value.missionIndex != 5 && // Sorties do not have capture missions
274 278 !availableMissionIndexes.includes(value.missionIndex)
275 279 ) {
@@ -310,28 +314,17 @@ const pushSortieIfRelevant = (worldState: IWorldState, day: number): void => {
310 314 sortieFactionToSpecialMissionTileset[sortieBossToFaction[boss]]
311 315 );
312 316
313 if (i == 2 && rng.randomInt(0, 2) == 2) {
317 if (i == 2 && boss != "SORTIE_BOSS_CORRUPTED_VOR" && rng.randomInt(0, 2) == 2) {
314 318 const filteredModifiers = modifiers.filter(mod => mod !== "SORTIE_MODIFIER_MELEE_ONLY");
315 319 const modifierType = rng.randomElement(filteredModifiers)!;
316 320
317 if (boss == "SORTIE_BOSS_PHORID") {
318 selectedNodes.push({
319 missionType: "MT_ASSASSINATION",
320 modifierType,
321 node,
322 tileset: sortieTilesets[node as keyof typeof sortieTilesets]
323 });
324 nodes.splice(randomIndex, 1);
325 continue;
326 } else if (sortieBossNode[boss]) {
327 selectedNodes.push({
328 missionType: "MT_ASSASSINATION",
329 modifierType,
330 node: sortieBossNode[boss],
331 tileset: sortieTilesets[sortieBossNode[boss] as keyof typeof sortieTilesets]
332 });
333 continue;
334 }
321 selectedNodes.push({
322 missionType: "MT_ASSASSINATION",
323 modifierType,
324 node: sortieBossNode[boss],
325 tileset: sortieTilesets[sortieBossNode[boss] as keyof typeof sortieTilesets]
326 });
327 continue;
335 328 }
336 329
337 330 const missionType = eMissionType[missionIndex].tag;