feat: loc-pin saving #485
@ -36,7 +36,10 @@ import {
|
||||
IPeriodicMissionCompletionDatabase,
|
||||
IPeriodicMissionCompletionResponse,
|
||||
ILoreFragmentScan,
|
||||
IEvolutionProgress
|
||||
IEvolutionProgress,
|
||||
ICustomMarkers,
|
||||
IMarkerInfo,
|
||||
IMarker
|
||||
} from "../../types/inventoryTypes/inventoryTypes";
|
||||
import { IOid } from "../../types/commonTypes";
|
||||
import {
|
||||
@ -578,6 +581,35 @@ const evolutionProgressSchema = new Schema<IEvolutionProgress>(
|
||||
{ _id: false }
|
||||
);
|
||||
|
||||
const markerSchema = new Schema<IMarker>(
|
||||
{
|
||||
anchorName: String,
|
||||
color: Number,
|
||||
label: String,
|
||||
x: Number,
|
||||
y: Number,
|
||||
z: Number,
|
||||
showInHud: Boolean
|
||||
},
|
||||
{ _id: false }
|
||||
);
|
||||
|
||||
const markerInfoSchema = new Schema<IMarkerInfo>(
|
||||
{
|
||||
icon: String,
|
||||
markers: [markerSchema]
|
||||
},
|
||||
{ _id: false }
|
||||
);
|
||||
|
||||
const CustomMarkersSchema = new Schema<ICustomMarkers>(
|
||||
{
|
||||
tag: String,
|
||||
|
|
||||
markerInfos: [markerInfoSchema]
|
||||
},
|
||||
{ _id: false }
|
||||
);
|
||||
|
||||
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
||||
{
|
||||
accountOwnerId: Schema.Types.ObjectId,
|
||||
@ -900,6 +932,9 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
||||
//https://warframe.fandom.com/wiki/Incarnon
|
||||
EvolutionProgress: { type: [evolutionProgressSchema], default: undefined },
|
||||
|
||||
//https://warframe.fandom.com/wiki/Loc-Pin
|
||||
CustomMarkers: { type: [CustomMarkersSchema], default: undefined },
|
||||
|
||||
//Unknown and system
|
||||
DuviriInfo: DuviriInfoSchema,
|
||||
Mailbox: MailboxSchema,
|
||||
|
||||
@ -731,7 +731,11 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques
|
||||
Consumables,
|
||||
Recipes,
|
||||
Missions,
|
||||
FusionTreasures
|
||||
FusionTreasures,
|
||||
AffiliationChanges,
|
||||
EvolutionProgress,
|
||||
LastRegionPlayed,
|
||||
CustomMarkers
|
||||
} = data;
|
||||
const inventory = await getInventory(accountId);
|
||||
|
||||
@ -742,7 +746,7 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques
|
||||
inventory.FusionPoints += FusionPoints || 0;
|
||||
|
||||
// syndicate
|
||||
data.AffiliationChanges?.forEach(affiliation => {
|
||||
AffiliationChanges?.forEach(affiliation => {
|
||||
const syndicate = inventory.Affiliations.find(x => x.Tag == affiliation.Tag);
|
||||
if (syndicate !== undefined) {
|
||||
syndicate.Standing =
|
||||
@ -763,8 +767,8 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques
|
||||
equipmentKeys.forEach(key => addGearExpByCategory(inventory, data[key], key));
|
||||
|
||||
// Incarnon Challenges
|
||||
if (data.EvolutionProgress) {
|
||||
for (const evoProgress of data.EvolutionProgress) {
|
||||
if (EvolutionProgress) {
|
||||
for (const evoProgress of EvolutionProgress) {
|
||||
const entry = inventory.EvolutionProgress
|
||||
? inventory.EvolutionProgress.find(entry => entry.ItemType == evoProgress.ItemType)
|
||||
: undefined;
|
||||
@ -779,8 +783,24 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques
|
||||
}
|
||||
|
||||
// LastRegionPlayed
|
||||
if (data.LastRegionPlayed) {
|
||||
inventory.LastRegionPlayed = data.LastRegionPlayed;
|
||||
if (LastRegionPlayed) {
|
||||
inventory.LastRegionPlayed = LastRegionPlayed;
|
||||
}
|
||||
|
||||
if (CustomMarkers) {
|
||||
CustomMarkers.forEach(markers => {
|
||||
const map = inventory.CustomMarkers
|
||||
? inventory.CustomMarkers.find(entry => entry.tag == markers.tag)
|
||||
: undefined;
|
||||
if (map) {
|
||||
map.markerInfos = markers.markerInfos;
|
||||
inventory.markModified("CustomMarkers");
|
||||
} else {
|
||||
inventory.CustomMarkers ??= [];
|
||||
inventory.CustomMarkers.push(markers);
|
||||
inventory.markModified("CustomMarkers");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// other
|
||||
|
||||
@ -277,6 +277,7 @@ export interface IInventoryResponse {
|
||||
LastInventorySync: IOid;
|
||||
NextRefill: IMongoDate; // Next time argon crystals will have a decay tick
|
||||
FoundToday?: IMiscItem[]; // for Argon Crystals
|
||||
CustomMarkers: ICustomMarkers[];
|
||||
ActiveLandscapeTraps: any[];
|
||||
EvolutionProgress?: IEvolutionProgress[];
|
||||
RepVotes: any[];
|
||||
@ -916,3 +917,23 @@ export interface IEvolutionProgress {
|
||||
Rank: number;
|
||||
ItemType: string;
|
||||
}
|
||||
|
||||
export interface ICustomMarkers {
|
||||
tag: string;
|
||||
markerInfos: IMarkerInfo[];
|
||||
}
|
||||
|
||||
export interface IMarkerInfo {
|
||||
icon: string;
|
||||
markers: IMarker[];
|
||||
}
|
||||
|
||||
export interface IMarker {
|
||||
anchorName: string;
|
||||
color: number;
|
||||
label?: string;
|
||||
x: number;
|
||||
|
🛠️ Refactor suggestion Define a specific type for the The _:hammer_and_wrench: Refactor suggestion_
**Define a specific type for the `icon` property in `IMarkerInfo`**
The `icon` property is typed as `string`. If the icons are selected from a predefined set, consider using a string literal union type or an enum to enforce valid values and improve code reliability.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
y: number;
|
||||
z: number;
|
||||
showInHud: boolean;
|
||||
}
|
||||
|
||||
@ -13,7 +13,8 @@ import {
|
||||
ISeasonChallenge,
|
||||
TSolarMapRegion,
|
||||
TEquipmentKey,
|
||||
IFusionTreasure
|
||||
IFusionTreasure,
|
||||
ICustomMarkers
|
||||
} from "./inventoryTypes/inventoryTypes";
|
||||
|
||||
export interface IArtifactsRequest {
|
||||
@ -70,6 +71,7 @@ export interface IMissionInventoryUpdateRequest {
|
||||
Missions?: IMission;
|
||||
EvolutionProgress?: IEvolutionProgress[];
|
||||
LastRegionPlayed?: TSolarMapRegion;
|
||||
CustomMarkers?: ICustomMarkers[];
|
||||
|
||||
FusionPoints?: number; // Not a part of the request, but we put it in this struct as an intermediate storage.
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user
⚠️ Potential issue
Consider the data type for the 'color' field in 'markerSchema'
The
colorfield inmarkerSchemais defined asNumber. Ifcolorrepresents a hexadecimal color code or a string value, it might be more appropriate to useString. Alternatively, if it represents RGB values, consider defining it as an object withr,g, andbcomponents for clarity.Apply this diff to update the
colorfield:Or, if using RGB components: