feat: syndicates #269

Merged
janisslsm merged 4 commits from feat-syndicate into main 2024-06-02 08:35:06 -07:00
5 changed files with 27 additions and 17 deletions
Showing only changes of commit d0e6d4f0d5 - Show all commits

View File

@ -11,4 +11,4 @@ const setSupportedSyndicateController: RequestHandler = async (request, response
Review

This file isn't needed.

This file isn't needed.
Review

This file isn't needed.

This file isn't needed.
response.json({}); response.json({});
}; };
export { setSupportedSyndicateController }; export { setSupportedSyndicateController };
Review

This file isn't needed.

This file isn't needed.
Review

This file isn't needed.

This file isn't needed.

Review

This file isn't needed.

This file isn't needed.
Review

This file isn't needed.

This file isn't needed.

View File

@ -5,7 +5,6 @@ import { RequestHandler } from "express";
Review

Should use getAccountIdForRequest so nonce is validated here

import { getAccountIdForRequest } from "@/src/services/loginService";
Should use getAccountIdForRequest so nonce is validated here ```ts import { getAccountIdForRequest } from "@/src/services/loginService"; ```
Review

Should use getAccountIdForRequest so nonce is validated here

import { getAccountIdForRequest } from "@/src/services/loginService";
Should use getAccountIdForRequest so nonce is validated here ```ts import { getAccountIdForRequest } from "@/src/services/loginService"; ```
// eslint-disable-next-line @typescript-eslint/no-misused-promises // eslint-disable-next-line @typescript-eslint/no-misused-promises
const syndicateSacrificeController: RequestHandler = async (request, response) => { const syndicateSacrificeController: RequestHandler = async (request, response) => {
Review

Should use getAccountIdForRequest so nonce is validated here

import { getAccountIdForRequest } from "@/src/services/loginService";
Should use getAccountIdForRequest so nonce is validated here ```ts import { getAccountIdForRequest } from "@/src/services/loginService"; ```
const accountId = request.query.accountId as string; const accountId = request.query.accountId as string;
const body = getJSONfromString(request.body); const body = getJSONfromString(request.body);
let reply = {}; let reply = {};
@ -23,4 +22,4 @@ const syndicateSacrificeController: RequestHandler = async (request, response) =
Review

Should use getAccountIdForRequest so nonce is validated here

import { getAccountIdForRequest } from "@/src/services/loginService";
Should use getAccountIdForRequest so nonce is validated here ```ts import { getAccountIdForRequest } from "@/src/services/loginService"; ```
Review

Should use getAccountIdForRequest so nonce is validated here

import { getAccountIdForRequest } from "@/src/services/loginService";
Should use getAccountIdForRequest so nonce is validated here ```ts import { getAccountIdForRequest } from "@/src/services/loginService"; ```
response.json(reply); response.json(reply);
}; };
export { syndicateSacrificeController }; export { syndicateSacrificeController };
Review

Should use getAccountIdForRequest so nonce is validated here

import { getAccountIdForRequest } from "@/src/services/loginService";
Should use getAccountIdForRequest so nonce is validated here ```ts import { getAccountIdForRequest } from "@/src/services/loginService"; ```
Review

Should use getAccountIdForRequest so nonce is validated here

import { getAccountIdForRequest } from "@/src/services/loginService";
Should use getAccountIdForRequest so nonce is validated here ```ts import { getAccountIdForRequest } from "@/src/services/loginService"; ```

Review

Should use getAccountIdForRequest so nonce is validated here

import { getAccountIdForRequest } from "@/src/services/loginService";
Should use getAccountIdForRequest so nonce is validated here ```ts import { getAccountIdForRequest } from "@/src/services/loginService"; ```
Review

Should use getAccountIdForRequest so nonce is validated here

import { getAccountIdForRequest } from "@/src/services/loginService";
Should use getAccountIdForRequest so nonce is validated here ```ts import { getAccountIdForRequest } from "@/src/services/loginService"; ```

View File

@ -17,7 +17,12 @@ import {
ITypeCount ITypeCount
} from "@/src/types/inventoryTypes/inventoryTypes"; } from "@/src/types/inventoryTypes/inventoryTypes";
import { IGenericUpdate } from "../types/genericUpdate"; import { IGenericUpdate } from "../types/genericUpdate";
import { IArtifactsRequest, IMissionInventoryUpdateRequest, IThemeUpdateRequest, IUpdateChallengeProgressRequest } from "../types/requestTypes"; import {
IArtifactsRequest,
IMissionInventoryUpdateRequest,
IThemeUpdateRequest,
IUpdateChallengeProgressRequest
} from "../types/requestTypes";
import { logger } from "@/src/utils/logger"; import { logger } from "@/src/utils/logger";
import { WeaponTypeInternal } from "@/src/services/itemDataService"; import { WeaponTypeInternal } from "@/src/services/itemDataService";
import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes"; import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes";
@ -166,7 +171,10 @@ export const updateTheme = async (data: IThemeUpdateRequest, accountId: string)
await inventory.save(); await inventory.save();
}; };
export const syndicateSacrifice = async (data: ISyndicateSacrifice, accountId: string): Promise<ISyndicateSacrificeResponse> => { export const syndicateSacrifice = async (
data: ISyndicateSacrifice,
accountId: string
): Promise<ISyndicateSacrificeResponse> => {
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
const syndicate = inventory.Affiliations.find(x => x.Tag == data.AffiliationTag); const syndicate = inventory.Affiliations.find(x => x.Tag == data.AffiliationTag);
const level = data.SacrificeLevel - (syndicate?.Title ?? 0); const level = data.SacrificeLevel - (syndicate?.Title ?? 0);
@ -176,8 +184,8 @@ export const syndicateSacrifice = async (data: ISyndicateSacrifice, accountId: s
Level: data.SacrificeLevel, Level: data.SacrificeLevel,
LevelIncrease: level <= 0 ? 1 : level, LevelIncrease: level <= 0 ? 1 : level,
NewEpisodeReward: syndicate?.Tag == "RadioLegionIntermission9Syndicate" NewEpisodeReward: syndicate?.Tag == "RadioLegionIntermission9Syndicate"
} };
if (syndicate?.Title !== undefined) syndicate.Title += 1; if (syndicate?.Title !== undefined) syndicate.Title += 1;
await inventory.save(); await inventory.save();
@ -327,7 +335,10 @@ export const updateChallengeProgress = async (challenges: IUpdateChallengeProgre
await inventory.save(); await inventory.save();
}; };
export const addSeasonalChallengeHistory = (inventory: IInventoryDatabaseDocument, itemsArray: ISeasonChallengeHistory[] | undefined) => { export const addSeasonalChallengeHistory = (
inventory: IInventoryDatabaseDocument,
itemsArray: ISeasonChallengeHistory[] | undefined
) => {
const category = inventory.SeasonChallengeHistory; const category = inventory.SeasonChallengeHistory;
itemsArray?.forEach(({ challenge, id }) => { itemsArray?.forEach(({ challenge, id }) => {
@ -383,9 +394,10 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques
// syndicate // syndicate
data.AffiliationChanges?.forEach(affiliation => { data.AffiliationChanges?.forEach(affiliation => {
const syndicate = inventory.Affiliations.find(x => x.Tag == affiliation.Tag); const syndicate = inventory.Affiliations.find(x => x.Tag == affiliation.Tag);
if (syndicate !== undefined) { if (syndicate !== undefined) {
syndicate.Standing = syndicate.Standing === undefined ? affiliation.Standing : syndicate.Standing + affiliation.Standing; syndicate.Standing =
syndicate.Standing === undefined ? affiliation.Standing : syndicate.Standing + affiliation.Standing;
syndicate.Title = syndicate.Title === undefined ? affiliation.Title : syndicate.Title + affiliation.Title; syndicate.Title = syndicate.Title === undefined ? affiliation.Title : syndicate.Title + affiliation.Title;
} else { } else {
inventory.Affiliations.push({ inventory.Affiliations.push({
@ -396,7 +408,7 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques
FreeFavorsUsed: [] FreeFavorsUsed: []
}); });
} }
}) });
// Gear XP // Gear XP
gearKeys.forEach(key => addGearExpByCategory(inventory, data[key], key)); gearKeys.forEach(key => addGearExpByCategory(inventory, data[key], key));

View File

@ -27,11 +27,10 @@ export interface IThemeUpdateRequest {
Sounds?: string; Sounds?: string;
} }
export interface IAffiliationChange export interface IAffiliationChange {
{ Tag: string;
Tag: string, Standing: number;
Standing: number, Title: number;
Title: number
} }
export interface IUpdateChallengeProgressRequest { export interface IUpdateChallengeProgressRequest {

View File

@ -10,4 +10,4 @@ export interface ISyndicateSacrificeResponse {
LevelIncrease: number; LevelIncrease: number;
InventoryChanges: any[]; InventoryChanges: any[];
NewEpisodeReward: boolean; NewEpisodeReward: boolean;
} }