WIP: feat: player skill gains #554

Closed
VampireKitten wants to merge 4 commits from fix-player-skill-gains into main
2 changed files with 29 additions and 3 deletions

View File

@ -17,7 +17,8 @@ import {
IWeaponSkinClient, IWeaponSkinClient,
TEquipmentKey, TEquipmentKey,
equipmentKeys, equipmentKeys,
IFusionTreasure IFusionTreasure,
IPlayerSkills
} from "@/src/types/inventoryTypes/inventoryTypes"; } from "@/src/types/inventoryTypes/inventoryTypes";
import { IGenericUpdate } from "../types/genericUpdate"; import { IGenericUpdate } from "../types/genericUpdate";
import { import {
@ -721,6 +722,27 @@ const addMissionComplete = (inventory: IInventoryDatabaseDocument, { Tag, Comple
} }
}; };
const addPlayerSkillGains = (inventory: IInventoryDatabaseDocument, PlayerSkillGains: IPlayerSkills | undefined) => {
if (PlayerSkillGains) {
inventory.PlayerSkills ??= {
LPP_SPACE: 0,
LPP_DRIFTER: 0,
LPS_NONE: 0,
LPS_PILOTING: 0,
LPS_GUNNERY: 0,
LPS_TACTICAL: 0,
LPS_ENGINEERING: 0,
LPS_COMMAND: 0,
LPS_DRIFT_COMBAT: 0,
LPS_DRIFT_RIDING: 0,
LPS_DRIFT_OPPORTUNITY: 0,
LPS_DRIFT_ENDURANCE: 0
};
inventory.PlayerSkills.LPP_SPACE += PlayerSkillGains.LPP_SPACE;
inventory.PlayerSkills.LPP_DRIFTER += PlayerSkillGains.LPP_DRIFTER;
}
};
export const missionInventoryUpdate = async (data: IMissionInventoryUpdateRequest, accountId: string) => { export const missionInventoryUpdate = async (data: IMissionInventoryUpdateRequest, accountId: string) => {
const { const {
RawUpgrades, RawUpgrades,
@ -731,7 +753,8 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques
Consumables, Consumables,
coderabbitai[bot] commented 2024-10-15 13:30:15 -07:00 (Migrated from github.com)
Review

⚠️ Potential issue

Good implementation, but type definition is missing.

The addPlayerSkillGains function looks well-implemented and addresses the issue of player skill gains not being saved. However, there's a missing type definition that needs to be addressed.

The type IPlayerSkills is not defined, which is causing static analysis errors. Please add the type definition or import it from the appropriate file.

Consider adding comments to explain the purpose of this function and the different skill types (LPP and LPS) for better code documentation.

Example:

/**
 * Adds player skill gains to the inventory.
 * @param inventory The player's inventory document
 * @param PlayerSkillGains The skill gains to be added
 * 
 * LPP: Likely "Player Progress" skills
 * LPS: Likely "Player Specific" skills
 */
const addPlayerSkillGains = (inventory: IInventoryDatabaseDocument, PlayerSkillGains: IPlayerSkills | undefined) => {
    // ... (rest of the function)
}
🧰 Tools
🪛 GitHub Check: build (22)

[failure] 724-724:
Cannot find name 'IPlayerSkills'.

🪛 GitHub Check: build (20)

[failure] 724-724:
Cannot find name 'IPlayerSkills'.

🪛 GitHub Check: build (18)

[failure] 724-724:
Cannot find name 'IPlayerSkills'.

_:warning: Potential issue_ **Good implementation, but type definition is missing.** The `addPlayerSkillGains` function looks well-implemented and addresses the issue of player skill gains not being saved. However, there's a missing type definition that needs to be addressed. The type `IPlayerSkills` is not defined, which is causing static analysis errors. Please add the type definition or import it from the appropriate file. Consider adding comments to explain the purpose of this function and the different skill types (LPP and LPS) for better code documentation. Example: ```typescript /** * Adds player skill gains to the inventory. * @param inventory The player's inventory document * @param PlayerSkillGains The skill gains to be added * * LPP: Likely "Player Progress" skills * LPS: Likely "Player Specific" skills */ const addPlayerSkillGains = (inventory: IInventoryDatabaseDocument, PlayerSkillGains: IPlayerSkills | undefined) => { // ... (rest of the function) } ``` <details> <summary>🧰 Tools</summary> <details> <summary>🪛 GitHub Check: build (22)</summary><blockquote> [failure] 724-724: Cannot find name 'IPlayerSkills'. </blockquote></details> <details> <summary>🪛 GitHub Check: build (20)</summary><blockquote> [failure] 724-724: Cannot find name 'IPlayerSkills'. </blockquote></details> <details> <summary>🪛 GitHub Check: build (18)</summary><blockquote> [failure] 724-724: Cannot find name 'IPlayerSkills'. </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit -->
Recipes, Recipes,
Missions, Missions,
FusionTreasures FusionTreasures,
PlayerSkillGains
} = data; } = data;
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
@ -793,6 +816,7 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques
if (Missions) { if (Missions) {
addMissionComplete(inventory, Missions); addMissionComplete(inventory, Missions);
} }
addPlayerSkillGains(inventory, PlayerSkillGains);
const changedInventory = await inventory.save(); const changedInventory = await inventory.save();
return changedInventory.toJSON(); return changedInventory.toJSON();

View File

@ -13,7 +13,8 @@ import {
ISeasonChallenge, ISeasonChallenge,
TSolarMapRegion, TSolarMapRegion,
TEquipmentKey, TEquipmentKey,
IFusionTreasure IFusionTreasure,
IPlayerSkills
} from "./inventoryTypes/inventoryTypes"; } from "./inventoryTypes/inventoryTypes";
export interface IArtifactsRequest { export interface IArtifactsRequest {
@ -70,6 +71,7 @@ export interface IMissionInventoryUpdateRequest {
Missions?: IMission; Missions?: IMission;
EvolutionProgress?: IEvolutionProgress[]; EvolutionProgress?: IEvolutionProgress[];
LastRegionPlayed?: TSolarMapRegion; LastRegionPlayed?: TSolarMapRegion;
PlayerSkillGains?: IPlayerSkills;
FusionPoints?: number; // Not a part of the request, but we put it in this struct as an intermediate storage. FusionPoints?: number; // Not a part of the request, but we put it in this struct as an intermediate storage.
} }