Improve getGuild response so game knows we have all permissions
This commit is contained in:
parent
9aa8213f7b
commit
056d7364c0
@ -2,7 +2,7 @@ import { RequestHandler } from "express";
|
|||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
||||||
import { Guild } from "@/src/models/guildModel";
|
import { Guild } from "@/src/models/guildModel";
|
||||||
import { IGuild, ICreateGuildRequest } from "@/src/types/guildTypes";
|
import { ICreateGuildRequest } from "@/src/types/guildTypes";
|
||||||
|
|
||||||
const createGuildController: RequestHandler = async (req, res) => {
|
const createGuildController: RequestHandler = async (req, res) => {
|
||||||
const payload: ICreateGuildRequest = getJSONfromString(req.body.toString());
|
const payload: ICreateGuildRequest = getJSONfromString(req.body.toString());
|
||||||
@ -10,7 +10,7 @@ const createGuildController: RequestHandler = async (req, res) => {
|
|||||||
// Create guild on database
|
// Create guild on database
|
||||||
const guild = new Guild({
|
const guild = new Guild({
|
||||||
Name: payload.guildName
|
Name: payload.guildName
|
||||||
} satisfies IGuild);
|
});
|
||||||
await guild.save();
|
await guild.save();
|
||||||
|
|
||||||
// Update inventory
|
// Update inventory
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
||||||
import { Guild } from "@/src/models/guildModel";
|
import { Guild } from "@/src/models/guildModel";
|
||||||
|
import { toOid } from "@/src/helpers/inventoryHelpers";
|
||||||
|
|
||||||
const getGuildController: RequestHandler = async (req, res) => {
|
const getGuildController: RequestHandler = async (req, res) => {
|
||||||
if (!req.query.accountId) {
|
if (!req.query.accountId) {
|
||||||
@ -15,7 +16,56 @@ const getGuildController: RequestHandler = async (req, res) => {
|
|||||||
if (inventory.GuildId) {
|
if (inventory.GuildId) {
|
||||||
const guild = await Guild.findOne({ _id: inventory.GuildId });
|
const guild = await Guild.findOne({ _id: inventory.GuildId });
|
||||||
if (guild) {
|
if (guild) {
|
||||||
res.json(guild);
|
res.json({
|
||||||
|
_id: toOid(guild._id),
|
||||||
|
Name: guild.Name,
|
||||||
|
Members: [
|
||||||
|
{
|
||||||
|
_id: { $oid: req.query.accountId },
|
||||||
|
Rank: 0,
|
||||||
|
Status: 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
Ranks: [
|
||||||
|
{
|
||||||
|
Name: "/Lotus/Language/Game/Rank_Creator",
|
||||||
|
Permissions: 16351
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "/Lotus/Language/Game/Rank_Warlord",
|
||||||
|
Permissions: 14303
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "/Lotus/Language/Game/Rank_General",
|
||||||
|
Permissions: 4318
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "/Lotus/Language/Game/Rank_Officer",
|
||||||
|
Permissions: 4314
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "/Lotus/Language/Game/Rank_Leader",
|
||||||
|
Permissions: 4106
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "/Lotus/Language/Game/Rank_Sage",
|
||||||
|
Permissions: 4304
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "/Lotus/Language/Game/Rank_Soldier",
|
||||||
|
Permissions: 4098
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "/Lotus/Language/Game/Rank_Initiate",
|
||||||
|
Permissions: 4096
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "/Lotus/Language/Game/Rank_Utility",
|
||||||
|
Permissions: 4096
|
||||||
|
}
|
||||||
|
],
|
||||||
|
Tier: 1
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { IGuildDatabase, IDojoComponentDatabase } from "@/src/types/guildTypes";
|
import { IGuildDatabase, IDojoComponentDatabase } from "@/src/types/guildTypes";
|
||||||
import { model, Schema } from "mongoose";
|
import { model, Schema } from "mongoose";
|
||||||
import { toOid } from "@/src/helpers/inventoryHelpers";
|
|
||||||
|
|
||||||
const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
|
const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
|
||||||
pf: { type: String, required: true },
|
pf: { type: String, required: true },
|
||||||
@ -16,12 +15,4 @@ const guildSchema = new Schema<IGuildDatabase>(
|
|||||||
{ id: false }
|
{ id: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
guildSchema.set("toJSON", {
|
|
||||||
virtuals: true,
|
|
||||||
transform(_document, guild) {
|
|
||||||
guild._id = toOid(guild._id);
|
|
||||||
delete guild.__v;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export const Guild = model<IGuildDatabase>("Guild", guildSchema);
|
export const Guild = model<IGuildDatabase>("Guild", guildSchema);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user