handle dojo decos in setPlacedDecoInfo
This commit is contained in:
parent
baf06bbda2
commit
2a09f6a1d1
@ -17,6 +17,7 @@ import {
|
|||||||
} from "@/src/types/guildTypes";
|
} from "@/src/types/guildTypes";
|
||||||
import { Document, Model, model, Schema, Types } from "mongoose";
|
import { Document, Model, model, Schema, Types } from "mongoose";
|
||||||
import { fusionTreasuresSchema, typeCountSchema } from "./inventoryModels/inventoryModel";
|
import { fusionTreasuresSchema, typeCountSchema } from "./inventoryModels/inventoryModel";
|
||||||
|
import { pictureFrameInfoSchema } from "./personalRoomsModel";
|
||||||
|
|
||||||
const dojoDecoSchema = new Schema<IDojoDecoDatabase>({
|
const dojoDecoSchema = new Schema<IDojoDecoDatabase>({
|
||||||
Type: String,
|
Type: String,
|
||||||
@ -26,7 +27,8 @@ const dojoDecoSchema = new Schema<IDojoDecoDatabase>({
|
|||||||
RegularCredits: Number,
|
RegularCredits: Number,
|
||||||
MiscItems: { type: [typeCountSchema], default: undefined },
|
MiscItems: { type: [typeCountSchema], default: undefined },
|
||||||
CompletionTime: Date,
|
CompletionTime: Date,
|
||||||
RushPlatinum: Number
|
RushPlatinum: Number,
|
||||||
|
PictureFrameInfo: pictureFrameInfoSchema
|
||||||
});
|
});
|
||||||
|
|
||||||
const dojoLeaderboardEntrySchema = new Schema<IDojoLeaderboardEntry>(
|
const dojoLeaderboardEntrySchema = new Schema<IDojoLeaderboardEntry>(
|
||||||
|
@ -12,7 +12,7 @@ import {
|
|||||||
} from "@/src/types/shipTypes";
|
} from "@/src/types/shipTypes";
|
||||||
import { Schema, model } from "mongoose";
|
import { Schema, model } from "mongoose";
|
||||||
|
|
||||||
const pictureFrameInfoSchema = new Schema<IPictureFrameInfo>(
|
export const pictureFrameInfoSchema = new Schema<IPictureFrameInfo>(
|
||||||
{
|
{
|
||||||
Image: String,
|
Image: String,
|
||||||
Filter: String,
|
Filter: String,
|
||||||
|
@ -202,7 +202,8 @@ export const getDojoClient = async (
|
|||||||
Type: deco.Type,
|
Type: deco.Type,
|
||||||
Pos: deco.Pos,
|
Pos: deco.Pos,
|
||||||
Rot: deco.Rot,
|
Rot: deco.Rot,
|
||||||
Name: deco.Name
|
Name: deco.Name,
|
||||||
|
PictureFrameInfo: deco.PictureFrameInfo
|
||||||
};
|
};
|
||||||
if (deco.CompletionTime) {
|
if (deco.CompletionTime) {
|
||||||
clientDeco.CompletionTime = toMongoDate(deco.CompletionTime);
|
clientDeco.CompletionTime = toMongoDate(deco.CompletionTime);
|
||||||
|
@ -10,6 +10,9 @@ import { logger } from "@/src/utils/logger";
|
|||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
import { addShipDecorations, getInventory } from "./inventoryService";
|
import { addShipDecorations, getInventory } from "./inventoryService";
|
||||||
import { config } from "./configService";
|
import { config } from "./configService";
|
||||||
|
import { Guild } from "../models/guildModel";
|
||||||
|
import { hasGuildPermission } from "./guildService";
|
||||||
|
import { GuildPermission } from "../types/guildTypes";
|
||||||
|
|
||||||
export const setShipCustomizations = async (
|
export const setShipCustomizations = async (
|
||||||
accountId: string,
|
accountId: string,
|
||||||
@ -154,6 +157,17 @@ export const handleSetShipDecorations = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const handleSetPlacedDecoInfo = async (accountId: string, req: ISetPlacedDecoInfoRequest): Promise<void> => {
|
export const handleSetPlacedDecoInfo = async (accountId: string, req: ISetPlacedDecoInfoRequest): Promise<void> => {
|
||||||
|
if (req.GuildId && req.ComponentId) {
|
||||||
|
const guild = (await Guild.findById(req.GuildId))!;
|
||||||
|
if (await hasGuildPermission(guild, accountId, GuildPermission.Decorator)) {
|
||||||
|
const component = guild.DojoComponents.id(req.ComponentId)!;
|
||||||
|
const deco = component.Decos!.find(x => x._id.equals(req.DecoId))!;
|
||||||
|
deco.PictureFrameInfo = req.PictureFrameInfo;
|
||||||
|
await guild.save();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const personalRooms = await getPersonalRooms(accountId);
|
const personalRooms = await getPersonalRooms(accountId);
|
||||||
|
|
||||||
const room = personalRooms.Ship.Rooms.find(room => room.Name === req.Room);
|
const room = personalRooms.Ship.Rooms.find(room => room.Name === req.Room);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
import { IOid, IMongoDate } from "@/src/types/commonTypes";
|
import { IOid, IMongoDate } from "@/src/types/commonTypes";
|
||||||
import { IFusionTreasure, IMiscItem, ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes";
|
import { IFusionTreasure, IMiscItem, ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
|
import { IPictureFrameInfo } from "./shipTypes";
|
||||||
|
|
||||||
export interface IGuildClient {
|
export interface IGuildClient {
|
||||||
_id: IOid;
|
_id: IOid;
|
||||||
@ -194,6 +195,7 @@ export interface IDojoDecoClient {
|
|||||||
MiscItems?: IMiscItem[];
|
MiscItems?: IMiscItem[];
|
||||||
CompletionTime?: IMongoDate;
|
CompletionTime?: IMongoDate;
|
||||||
RushPlatinum?: number;
|
RushPlatinum?: number;
|
||||||
|
PictureFrameInfo?: IPictureFrameInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDojoDecoDatabase extends Omit<IDojoDecoClient, "id" | "CompletionTime"> {
|
export interface IDojoDecoDatabase extends Omit<IDojoDecoClient, "id" | "CompletionTime"> {
|
||||||
|
@ -127,7 +127,9 @@ export interface ISetPlacedDecoInfoRequest {
|
|||||||
DecoId: string;
|
DecoId: string;
|
||||||
Room: string;
|
Room: string;
|
||||||
PictureFrameInfo: IPictureFrameInfo;
|
PictureFrameInfo: IPictureFrameInfo;
|
||||||
BootLocation: string;
|
BootLocation?: string;
|
||||||
|
ComponentId?: string;
|
||||||
|
GuildId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPictureFrameInfo {
|
export interface IPictureFrameInfo {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user