add updateInventoryForConfirmedGuildJoin
This commit is contained in:
parent
dccb88db6d
commit
4ba1adb2e3
@ -1,9 +1,8 @@
|
|||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
|
||||||
import { Guild, GuildMember } from "@/src/models/guildModel";
|
import { Guild, GuildMember } from "@/src/models/guildModel";
|
||||||
import { addRecipes } from "@/src/services/inventoryService";
|
import { updateInventoryForConfirmedGuildJoin } from "@/src/services/guildService";
|
||||||
|
|
||||||
export const createGuildController: RequestHandler = async (req, res) => {
|
export const createGuildController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
@ -23,22 +22,7 @@ export const createGuildController: RequestHandler = async (req, res) => {
|
|||||||
rank: 0
|
rank: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update inventory
|
await updateInventoryForConfirmedGuildJoin(accountId, guild._id);
|
||||||
const inventory = await Inventory.findOne({ accountOwnerId: accountId });
|
|
||||||
if (inventory) {
|
|
||||||
// Set GuildId
|
|
||||||
inventory.GuildId = guild._id;
|
|
||||||
|
|
||||||
// Give clan key blueprint
|
|
||||||
addRecipes(inventory, [
|
|
||||||
{
|
|
||||||
ItemType: "/Lotus/Types/Keys/DojoKeyBlueprint",
|
|
||||||
ItemCount: 1
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
|
|
||||||
await inventory.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
res.json(guild);
|
res.json(guild);
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Request } from "express";
|
import { Request } from "express";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { getInventory } from "@/src/services/inventoryService";
|
import { addRecipes, getInventory } from "@/src/services/inventoryService";
|
||||||
import { Guild, TGuildDatabaseDocument } from "@/src/models/guildModel";
|
import { Guild, TGuildDatabaseDocument } from "@/src/models/guildModel";
|
||||||
import { Inventory, TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
|
import { Inventory, TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
|
||||||
import {
|
import {
|
||||||
@ -196,12 +196,27 @@ export const processDojoBuildMaterialsGathered = (guild: TGuildDatabaseDocument,
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const fillInInventoryDataForGuildMember = async (member: IGuildMemberClient): Promise<void> => {
|
export const fillInInventoryDataForGuildMember = async (member: IGuildMemberClient): Promise<void> => {
|
||||||
const inventory = (await Inventory.findOne(
|
const inventory = await getInventory(member._id.$oid, "PlayerLevel ActiveAvatarImageType");
|
||||||
{
|
|
||||||
accountOwnerId: member._id.$oid
|
|
||||||
},
|
|
||||||
"PlayerLevel ActiveAvatarImageType"
|
|
||||||
))!;
|
|
||||||
member.PlayerLevel = config.spoofMasteryRank == -1 ? inventory.PlayerLevel : config.spoofMasteryRank;
|
member.PlayerLevel = config.spoofMasteryRank == -1 ? inventory.PlayerLevel : config.spoofMasteryRank;
|
||||||
member.ActiveAvatarImageType = inventory.ActiveAvatarImageType;
|
member.ActiveAvatarImageType = inventory.ActiveAvatarImageType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const updateInventoryForConfirmedGuildJoin = async (
|
||||||
|
accountId: string,
|
||||||
|
guildId: Types.ObjectId
|
||||||
|
): Promise<void> => {
|
||||||
|
const inventory = await getInventory(accountId);
|
||||||
|
|
||||||
|
// Set GuildId
|
||||||
|
inventory.GuildId = guildId;
|
||||||
|
|
||||||
|
// Give clan key blueprint
|
||||||
|
addRecipes(inventory, [
|
||||||
|
{
|
||||||
|
ItemType: "/Lotus/Types/Keys/DojoKeyBlueprint",
|
||||||
|
ItemCount: 1
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
await inventory.save();
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user