✨ feat(gvg): 添加贡献等接口
This commit is contained in:
@@ -33,4 +33,9 @@ export enum LEAGUE_MANAGE_TYPE {
|
||||
SET_INFO = 8, // 设置信息
|
||||
RERUIT = 9, // 招募
|
||||
SEND_MAIL = 9, // 招募
|
||||
}
|
||||
|
||||
export enum LEAGUE_JOB {
|
||||
PRODUCER = 1, // 贤臣
|
||||
FIGHTER = 2, // 猛将
|
||||
}
|
||||
@@ -305,6 +305,9 @@ export const STATUS = {
|
||||
LEAGUE_CODE_ERR: { code: 31314, simStr: '不能解散其他联军' },
|
||||
GVG_HE_HAS_NO_AUTH: { code: 21300, simStr: '对方权限不足' },
|
||||
LEAGUE_NAME_DUP: { code: 21301, simStr: '联军名重复' },
|
||||
GVG_HAS_CHOOSE_JOB: { code: 21302, simStr: '已经选择过职能' },
|
||||
GVG_NOT_PREPARE_PERIOD: { code: 21303, simStr: '您只能在准备期进行该操作' },
|
||||
GVG_JOB_LIMIT: { code: 21304, simStr: '职能选择达到上限' },
|
||||
|
||||
// 通用 30000 - 30099
|
||||
DIC_DATA_NOT_FOUND: { code: 30000, simStr: '数据表未找到' },
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, } from '@typegoose/typegoose';
|
||||
import { LEAGUE_JOB } from '../consts';
|
||||
|
||||
class Tech {
|
||||
@prop({ required: true, default: 0 })
|
||||
@@ -72,6 +73,16 @@ export default class GVGLeaguePrepare extends BaseModel {
|
||||
const result: GVGLeaguePrepareType = await GVGLeaguePrepareModel.findOne({ configId, leagueCode }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async chooseJob(configId: number, leagueCode: string, job: LEAGUE_JOB) {
|
||||
if(job == LEAGUE_JOB.FIGHTER) {
|
||||
const result: GVGLeaguePrepareType = await GVGLeaguePrepareModel.findOneAndUpdate({ configId, leagueCode }, { $inc: { fighterCnt: 1 } }, { new: true }).lean();
|
||||
return result;
|
||||
} else {
|
||||
const result: GVGLeaguePrepareType = await GVGLeaguePrepareModel.findOneAndUpdate({ configId, leagueCode }, { $inc: { producerCnt: 1 } }, { new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const GVGLeaguePrepareModel = getModelForClass(GVGLeaguePrepare);
|
||||
|
||||
47
shared/db/GVGUserDailyDistribute.ts
Normal file
47
shared/db/GVGUserDailyDistribute.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, } from '@typegoose/typegoose';
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
|
||||
@index({ leagueCode: 1, roleId: 1, configId: 1, time: 1 })
|
||||
export default class GVGUserDailyDistribute extends BaseModel {
|
||||
|
||||
@prop({ required: true })
|
||||
roleId: string; // 玩家
|
||||
|
||||
@prop({ required: true })
|
||||
configId: number; // 赛季信息
|
||||
|
||||
@prop({ required: true })
|
||||
leagueCode: string; // 所属联军
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
job: number; // 职能 1-贤臣 2-猛将
|
||||
|
||||
// 贡献
|
||||
@prop({ required: true, default: 0 })
|
||||
food: number; // 粮食
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
mineral: number; // 矿物
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
wood: number; // 木材
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
score: number; // 据点积分
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
time: number = 0; // 据点积分
|
||||
|
||||
public static async findByRole(configId: number, leagueCode: string, roleId: string) {
|
||||
const result: GVGUserDailyDistributeType = await GVGUserDailyDistributeModel.findOne({ configId, leagueCode, roleId, time: nowSeconds() }).select('food mineral wood score').lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const GVGUserDailyDistributeModel = getModelForClass(GVGUserDailyDistribute);
|
||||
|
||||
export interface GVGUserDailyDistributeType extends Pick<DocumentType<GVGUserDailyDistribute>, keyof GVGUserDailyDistribute> {
|
||||
id: number;
|
||||
};
|
||||
export type GVGUserDailyDistributeUpdate = Partial<GVGUserDailyDistributeType>; // 将所有字段变成可选项
|
||||
@@ -12,11 +12,22 @@ class ActiveRec {
|
||||
|
||||
class Box {
|
||||
@prop({ required: true, default: 0 })
|
||||
score: number; // 宝箱积分
|
||||
job: number; // 宝箱积分
|
||||
@prop({ required: true, default: [], type: Number })
|
||||
received: number[]; // 领取记录
|
||||
}
|
||||
|
||||
export class Distribute {
|
||||
@prop({ required: true, default: 0 })
|
||||
food: number = 0; // 粮食
|
||||
@prop({ required: true, default: 0 })
|
||||
mineral: number = 0; // 矿物
|
||||
@prop({ required: true, default: 0 })
|
||||
wood: number = 0; // 木材
|
||||
@prop({ required: true, default: 0 })
|
||||
score: number = 0; // 据点积分
|
||||
}
|
||||
|
||||
@index({ leagueCode: 1, roleId: 1, configId: 1, status: 1 })
|
||||
export default class GVGUserData extends BaseModel {
|
||||
|
||||
@@ -45,11 +56,15 @@ export default class GVGUserData extends BaseModel {
|
||||
@prop({ required: true, default: 0 })
|
||||
receiveCurrencyTime: number; // 领取内政令&征战令时间
|
||||
|
||||
@prop({ required: true, default: { score: 0, received: []}, type: Box, _id: false })
|
||||
box: Box;
|
||||
@prop({ required: true, default: [], type: Box, _id: false })
|
||||
box: Box[];
|
||||
|
||||
@prop({ required: true, default: {}, _id: false })
|
||||
distribute: Distribute;
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
sendFightRewardTime: number; // 发送征战奖励的时间
|
||||
|
||||
// 激战期
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
@@ -71,6 +86,11 @@ export default class GVGUserData extends BaseModel {
|
||||
const result: GVGUserDataType[] = await GVGUserDataModel.find({ configId, leagueCode, roleId: { $in: roleIds } }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async chooseJob(configId: number, leagueCode: string, roleId: string, job: number) {
|
||||
const result: GVGUserDataType = await GVGUserDataModel.findOneAndUpdate({ configId, leagueCode, roleId }, { $set: { job } }, { new: true, upsert: true}).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const GVGUserDataModel = getModelForClass(GVGUserData);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { RoleType } from "../../db/Role";
|
||||
import { GVGLeagueType } from "../../db/GVGLeague";
|
||||
import { GVGLeaguePrepareType } from "../../db/GVGLeaguePrepare";
|
||||
import { GVGUserDataType } from "../../db/GVGUserData";
|
||||
import { Distribute, GVGUserDataType } from "../../db/GVGUserData";
|
||||
import { GuildType } from "../../db/Guild";
|
||||
import { LEAGUE_JOB } from "../../consts";
|
||||
|
||||
class LeagueLeaderInfo {
|
||||
name: string; // 盟主名
|
||||
@@ -158,6 +159,7 @@ export class LeagueSimpleInfo extends LeagueListInfo {
|
||||
|
||||
export class LeagueGuildInfo {
|
||||
guildCode: string; // 军团唯一id
|
||||
icon: number;
|
||||
name: string; // 军团名
|
||||
serverName: string; // 区服名
|
||||
lv: number; // 军团等级
|
||||
@@ -165,10 +167,12 @@ export class LeagueGuildInfo {
|
||||
leaderName: string; // 大将军的姓名
|
||||
guildCe: number; // 军团战力
|
||||
hasInvited: boolean; // 是否邀请过了
|
||||
active: number;
|
||||
|
||||
constructor(guild: GuildType, serverNames: any) {
|
||||
if(!guild) return;
|
||||
this.guildCode = guild.code;
|
||||
this.icon = guild.icon;
|
||||
this.name = guild.name;
|
||||
this.serverName = serverNames[guild.serverId];
|
||||
this.lv = guild.lv;
|
||||
@@ -181,6 +185,10 @@ export class LeagueGuildInfo {
|
||||
setHasInvited(hasInvited: boolean) {
|
||||
this.hasInvited = hasInvited;
|
||||
}
|
||||
|
||||
setActive(active: number) {
|
||||
this.active = active;
|
||||
}
|
||||
}
|
||||
|
||||
export class LeagueMemberListInfo {
|
||||
@@ -189,6 +197,7 @@ export class LeagueMemberListInfo {
|
||||
lv: number; // 玩家等级
|
||||
head: number; // 玩家头像
|
||||
frame: number; // 玩家相框
|
||||
title: number; // 爵位
|
||||
guildName: string; // 所处军团名
|
||||
serverName: string; // 所处小区名
|
||||
job: number = 0; // 官职 1-贤臣 2-猛将
|
||||
@@ -205,6 +214,7 @@ export class LeagueMemberListInfo {
|
||||
this.lv = role.lv;
|
||||
this.head = role.head;
|
||||
this.frame = role.frame;
|
||||
this.title = role.title;
|
||||
this.guildName = role.guildName;
|
||||
this.serverName = serverNames[role.serverId];
|
||||
this.ce = role.ce;
|
||||
@@ -221,4 +231,38 @@ export class LeagueMemberListInfo {
|
||||
setAuth(auth: number) {
|
||||
this.auth = auth;
|
||||
}
|
||||
}
|
||||
|
||||
export class LeagueMemberDistributeInfo extends LeagueMemberListInfo{
|
||||
food: number = 0;
|
||||
mineral: number = 0;
|
||||
wood: number = 0;
|
||||
score: number = 0;
|
||||
|
||||
setByUserData(data: GVGUserDataType) {
|
||||
if(!data) return;
|
||||
this.active = data.active;
|
||||
this.job = data.job;
|
||||
this.food = data.distribute?.food||0;
|
||||
this.mineral = data.distribute?.mineral||0;
|
||||
this.wood = data.distribute?.wood||0;
|
||||
this.score = data.distribute?.score||0
|
||||
}
|
||||
}
|
||||
|
||||
export class LeagueDistributeInfo {
|
||||
job: number; // 1-内政 2-外政
|
||||
sumDistribute: number; // 总贡献(宝箱显示)
|
||||
receivedBox: number[]; // 已领取的宝箱id
|
||||
members: LeagueMemberDistributeInfo[];
|
||||
|
||||
constructor(job: number, sumDistribute: number, receivedBox: number[]) {
|
||||
this.job = job;
|
||||
this.sumDistribute = sumDistribute||0;
|
||||
this.receivedBox = receivedBox||[];
|
||||
}
|
||||
|
||||
setMembers(members: LeagueMemberDistributeInfo[]) {
|
||||
this.members = members;
|
||||
}
|
||||
}
|
||||
@@ -1,84 +1,84 @@
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"Type": 1,
|
||||
"job": 1,
|
||||
"boxPoint": 100000,
|
||||
"boxReward": "31002&500",
|
||||
"boxLeagueReward": "12&500"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"Type": 1,
|
||||
"job": 1,
|
||||
"boxPoint": 150000,
|
||||
"boxReward": "31002&500",
|
||||
"boxLeagueReward": "12&500"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"Type": 1,
|
||||
"job": 1,
|
||||
"boxPoint": 200000,
|
||||
"boxReward": "31002&500",
|
||||
"boxLeagueReward": "12&500"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"Type": 1,
|
||||
"job": 1,
|
||||
"boxPoint": 250000,
|
||||
"boxReward": "31002&500",
|
||||
"boxLeagueReward": "12&500"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"Type": 1,
|
||||
"job": 1,
|
||||
"boxPoint": 300000,
|
||||
"boxReward": "31002&500",
|
||||
"boxLeagueReward": "12&500"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"Type": 1,
|
||||
"job": 1,
|
||||
"boxPoint": 350000,
|
||||
"boxReward": "31002&500",
|
||||
"boxLeagueReward": "12&500"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"Type": 2,
|
||||
"job": 2,
|
||||
"boxPoint": 50000,
|
||||
"boxReward": "31002&500",
|
||||
"boxLeagueReward": "12&500"
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"Type": 2,
|
||||
"job": 2,
|
||||
"boxPoint": 100000,
|
||||
"boxReward": "31002&500",
|
||||
"boxLeagueReward": "12&500"
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"Type": 2,
|
||||
"job": 2,
|
||||
"boxPoint": 150000,
|
||||
"boxReward": "31002&500",
|
||||
"boxLeagueReward": "12&500"
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"Type": 2,
|
||||
"job": 2,
|
||||
"boxPoint": 200000,
|
||||
"boxReward": "31002&500",
|
||||
"boxLeagueReward": "12&500"
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"Type": 2,
|
||||
"job": 2,
|
||||
"boxPoint": 250000,
|
||||
"boxReward": "31002&500",
|
||||
"boxLeagueReward": "12&500"
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"Type": 2,
|
||||
"job": 2,
|
||||
"boxPoint": 300000,
|
||||
"boxReward": "31002&500",
|
||||
"boxLeagueReward": "12&500"
|
||||
|
||||
@@ -33,6 +33,6 @@
|
||||
"DEBUG_TIME": 1,
|
||||
"CHECK_WORD": 1,
|
||||
"CAN_PAY": 1,
|
||||
"SKIP_ENCODE": 0,
|
||||
"SKIP_ENCODE": 1,
|
||||
"NEED_REBATE": 0
|
||||
}
|
||||
Reference in New Issue
Block a user