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: bounty rewards (#1549)

Re #388. This only handles reward manifests and only those given in the worldState. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1549 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

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

代码差异

4 个文件 +34 -8
Modified src/controllers/api/missionInventoryUpdateController.ts +2 -1
@@ -55,7 +55,8 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
55 55 const inventory = await getInventory(accountId);
56 56 const inventoryUpdates = await addMissionInventoryUpdates(inventory, missionReport);
57 57
58 if (missionReport.MissionStatus !== "GS_SUCCESS") {
58 // skip mission rewards if not GS_SUCCESS and not a bounty (by presence of jobId, as there's a reward every stage but only the last stage has GS_SUCCESS)
59 if (missionReport.MissionStatus !== "GS_SUCCESS" && !missionReport.RewardInfo?.jobId) {
59 60 await inventory.save();
60 61 const inventoryResponse = await getInventoryResponse(inventory, true);
61 62 res.json({
Modified src/services/missionInventoryUpdateService.ts +16 -2
@@ -50,6 +50,7 @@ import conservationAnimals from "@/static/fixed_responses/conservationAnimals.js
50 50 import { getInfNodes } from "@/src/helpers/nemesisHelpers";
51 51 import { Loadout } from "../models/inventoryModels/loadoutModel";
52 52 import { ILoadoutConfigDatabase } from "../types/saveLoadoutTypes";
53 import { getWorldState } from "./worldStateService";
53 54
54 55 const getRotations = (rotationCount: number, tierOverride: number | undefined): number[] => {
55 56 if (rotationCount === 0) return [0];
@@ -806,13 +807,23 @@ function getRandomMissionDrops(RewardInfo: IRewardInfo, tierOverride: number | u
806 807 const drops: IMissionReward[] = [];
807 808 if (RewardInfo.node in ExportRegions) {
808 809 const region = ExportRegions[RewardInfo.node];
809 const rewardManifests: string[] =
810 let rewardManifests: string[] =
810 811 RewardInfo.periodicMissionTag == "EliteAlert" || RewardInfo.periodicMissionTag == "EliteAlertB"
811 812 ? ["/Lotus/Types/Game/MissionDecks/EliteAlertMissionRewards/EliteAlertMissionRewards"]
812 813 : region.rewardManifests;
813 814
814 815 let rotations: number[] = [];
815 if (RewardInfo.VaultsCracked) {
816 if (RewardInfo.jobId) {
817 if (RewardInfo.JobTier! >= 0) {
818 const id = RewardInfo.jobId.split("_")[3];
819 const syndicateInfo = getWorldState().SyndicateMissions.find(x => x._id.$oid == id);
820 if (syndicateInfo) {
821 const jobInfo = syndicateInfo.Jobs![RewardInfo.JobTier!];
822 rewardManifests = [jobInfo.rewards];
823 rotations = [RewardInfo.JobStage!];
824 }
825 }
826 } else if (RewardInfo.VaultsCracked) {
816 827 // For Spy missions, e.g. 3 vaults cracked = A, B, C
817 828 for (let i = 0; i != RewardInfo.VaultsCracked; ++i) {
818 829 rotations.push(i);
@@ -821,6 +832,9 @@ function getRandomMissionDrops(RewardInfo: IRewardInfo, tierOverride: number | u
821 832 const rotationCount = RewardInfo.rewardQualifications?.length || 0;
822 833 rotations = getRotations(rotationCount, tierOverride);
823 834 }
835 if (rewardManifests.length != 0) {
836 logger.debug(`generating random mission rewards`, { rewardManifests, rotations });
837 }
824 838 rewardManifests
825 839 .map(name => ExportRewards[name])
826 840 .forEach(table => {
Modified src/types/requestTypes.ts +3 -3
@@ -145,10 +145,10 @@ export interface IRewardInfo {
145 145 periodicMissionTag?: string;
146 146
147 147 // for bounties, only EOM_AFK and node are given from above, plus:
148 JobTier?: string;
148 JobTier?: number;
149 149 jobId?: string;
150 JobStage?: string;
151 Q?: boolean; // always false?
150 JobStage?: number;
151 Q?: boolean; // likely indicates that the bonus objective for this stage was completed
152 152 CheckpointCounter?: number; // starts at 1, is incremented with each job stage upload, and does not reset when starting a new job
153 153 }
154 154
Modified src/types/worldStateTypes.ts +13 -2
@@ -5,7 +5,7 @@ export interface IWorldState {
5 5 BuildLabel: string;
6 6 Time: number;
7 7 Goals: IGoal[];
8 SyndicateMissions: ISyndicateMission[];
8 SyndicateMissions: ISyndicateMissionInfo[];
9 9 GlobalUpgrades: IGlobalUpgrade[];
10 10 Sorties: ISortie[];
11 11 LiteSorties: ILiteSortie[];
@@ -39,13 +39,24 @@ export interface IGoal {
39 39 Node: string;
40 40 }
41 41
42 export interface ISyndicateMission {
42 export interface ISyndicateMissionInfo {
43 43 _id: IOid;
44 44 Activation: IMongoDate;
45 45 Expiry: IMongoDate;
46 46 Tag: string;
47 47 Seed: number;
48 48 Nodes: string[];
49 Jobs?: {
50 jobType?: string;
51 rewards: string;
52 masteryReq: number;
53 minEnemyLevel: number;
54 maxEnemyLevel: number;
55 xpAmounts: number[];
56 endless?: boolean;
57 locationTag?: string;
58 isVault?: boolean;
59 }[];
49 60 }
50 61
51 62 export interface IGlobalUpgrade {