✨ feat(gvg): 添加贡献等接口
This commit is contained in:
@@ -33,7 +33,7 @@ import { loadGmDb } from './app/db';
|
||||
import { loadActivities } from './app/services/activity/activityRemoteService';
|
||||
import { checkAndSetApiIsClose } from './app/services/chatService';
|
||||
import { initGuildActivityIndexInPinus, resetJoinWoodenHorse } from './app/services/guildActivity/guildActivityService';
|
||||
import { setGVGServerGroup } from './app/services/gvg/gvgService';
|
||||
import { setGVGConfig, setGVGServerGroup } from './app/services/gvg/gvgService';
|
||||
|
||||
const filePath = (_pinus as any).FILEPATH;
|
||||
filePath.MASTER = '/config/master';
|
||||
@@ -201,8 +201,11 @@ async function treatStartLogic(app: _pinus.Application) {
|
||||
if(app.getServerType() != 'systimer') {
|
||||
timeTaskService.initHiddenData();
|
||||
}
|
||||
if(app.getServerType() == 'battle'|| app.getServerType() == 'chat'|| app.getServerType() == 'connector') {
|
||||
if(app.getServerType() == 'guild'|| app.getServerType() == 'chat'|| app.getServerType() == 'connector') {
|
||||
setGVGServerGroup();
|
||||
if(app.getServerType() == 'guild') {
|
||||
setGVGConfig();
|
||||
}
|
||||
}
|
||||
|
||||
if(app.isMaster()) {
|
||||
|
||||
@@ -313,7 +313,8 @@ export class GmHandler {
|
||||
if(teamTime > prepareTime || prepareTime > battleTime || battleTime > scheduleTime) {
|
||||
return resResult(STATUS.GM_GVG_TIME_ERR);
|
||||
}
|
||||
await GVGConfigModel.updateConfig(configId, teamTime, prepareTime, battleTime, scheduleTime);
|
||||
const config = await GVGConfigModel.updateConfig(configId, teamTime, prepareTime, battleTime, scheduleTime);
|
||||
await pinus.app.rpc.guild.guildRemote.setGVGConfig.broadcast(config);
|
||||
await pinus.app.rpc.systimer.systimerRemote.initGVGConfigSchedule.broadcast();
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
import { Application, BackendSession, ChannelService, HandlerService, pinus } from "pinus";
|
||||
import { GVG_PERIOD, GVG_SERVER_TYPE, STATUS } from "../../../consts";
|
||||
import { GVG_PERIOD, GVG_SERVER_TYPE, LEAGUE_JOB, STATUS } from "../../../consts";
|
||||
import { GVGLeagueModel } from "../../../db/GVGLeague";
|
||||
import { GVGLeaguePrepareModel } from "../../../db/GVGLeaguePrepare";
|
||||
import { GVGMainData } from "../../../domain/gvgField/returnData";
|
||||
import { GVGMainData, LeagueDistributeInfo, LeagueMemberDistributeInfo, LeagueMemberListInfo } from "../../../domain/gvgField/returnData";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { getGVGConfig, getGVGPeriodData, getGVGServerType } from "../../../services/gvg/gvgService";
|
||||
import { autoCreateLeague, checkCanChooseJob, checkCanPrepare, getMyAuth } from "../../../services/gvg/gvgTeamService";
|
||||
import { getAllServerName } from "../../../services/redisService";
|
||||
import { GVGUserDataModel } from "../../../db/GVGUserData";
|
||||
import { Distribute, GVGUserDataModel } from "../../../db/GVGUserData";
|
||||
import { GVGUserItemModel } from "../../../db/GVGUserItem";
|
||||
import { GVGUserTaskModel } from "../../../db/GVGUserTask";
|
||||
import { GVG } from "../../../pubUtils/dicParam";
|
||||
import { RoleModel } from "../../../db/Role";
|
||||
import { calProduce } from "../../../services/gvg/gvgPrepareService";
|
||||
import { nowSeconds } from "../../../pubUtils/timeUtil";
|
||||
import { GVGUserDailyDistributeModel } from "../../../db/GVGUserDailyDistribute";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -54,6 +59,107 @@ export class GVGHandler {
|
||||
return resResult(STATUS.SUCCESS, data)
|
||||
}
|
||||
|
||||
// TODO 获取动态
|
||||
async getRec(msg: {}, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
return resResult(STATUS.SUCCESS, { recs: [] });
|
||||
}
|
||||
|
||||
// 选择职能
|
||||
async chooseJob(msg: { job: number }, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
const guildCode = session.get('guildCode');
|
||||
const { job } = msg;
|
||||
|
||||
let { configId, period } = getGVGPeriodData();
|
||||
if(period != GVG_PERIOD.PREPARE) return resResult(STATUS.GVG_NOT_PREPARE_PERIOD);
|
||||
|
||||
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||
if(!myLeague) return resResult(STATUS.GVG_LEAGUE_NOT_EXIST);
|
||||
|
||||
// 是否已经选过
|
||||
let myUserData = await GVGUserDataModel.findByRole(configId, myLeague.leagueCode, roleId);
|
||||
if(myUserData && myUserData.job) return resResult(STATUS.GVG_HAS_CHOOSE_JOB);
|
||||
|
||||
let leaguePrepare = await GVGLeaguePrepareModel.findByLeague(configId, myLeague.leagueCode);
|
||||
if(!leaguePrepare) return resResult(STATUS.GVG_NOT_PREPARE_PERIOD);
|
||||
|
||||
// 是否超过人数
|
||||
let limit = Math.floor(leaguePrepare.maxMemberCnt * GVG.GVG_ROLE_TOTAL_RATIO);
|
||||
if(leaguePrepare.fighterCnt + leaguePrepare.producerCnt >= limit) return resResult(STATUS.GVG_JOB_LIMIT);
|
||||
let cnt = job == LEAGUE_JOB.FIGHTER? leaguePrepare.fighterCnt: leaguePrepare.producerCnt;
|
||||
if(cnt >= Math.floor(limit * GVG.GVG_ROLE_RATIO / 2)) return resResult(STATUS.GVG_JOB_LIMIT);
|
||||
|
||||
// 更新userData
|
||||
myUserData = await GVGUserDataModel.chooseJob(configId, myLeague.leagueCode, roleId, job);
|
||||
// 更新prepare
|
||||
leaguePrepare = await GVGLeaguePrepareModel.chooseJob(configId, myLeague.leagueCode, job);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
leagueCode: myLeague.leagueCode,
|
||||
job: myUserData.job,
|
||||
producerCnt: leaguePrepare.producerCnt,
|
||||
fighterCnt: leaguePrepare.fighterCnt
|
||||
});
|
||||
}
|
||||
|
||||
// 查看贡献
|
||||
async getDistribute(msg: {}, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
const guildCode = session.get('guildCode');
|
||||
|
||||
let { configId, period } = getGVGPeriodData();
|
||||
if(period != GVG_PERIOD.PREPARE) return resResult(STATUS.GVG_NOT_PREPARE_PERIOD);
|
||||
|
||||
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||
if(!myLeague) return resResult(STATUS.GVG_LEAGUE_NOT_EXIST);
|
||||
|
||||
const members = myLeague.members||[];
|
||||
const roleIds = members.map(member => member.roleId);
|
||||
const roles = await RoleModel.findByRoleIds(roleIds);
|
||||
const serverNames = await getAllServerName();
|
||||
|
||||
const myUserData = await GVGUserDataModel.findByRole(configId, myLeague.leagueCode, roleId);
|
||||
const { distribute = new Distribute(), box = [] } = myUserData||{};
|
||||
const userDatas = await GVGUserDataModel.findByRoles(configId, myLeague.leagueCode, roleIds);
|
||||
|
||||
const result: LeagueDistributeInfo[] = [];
|
||||
for(let curJob of [LEAGUE_JOB.PRODUCER, LEAGUE_JOB.FIGHTER]) {
|
||||
const memberResult: LeagueMemberDistributeInfo[] = [];
|
||||
for(let member of members) {
|
||||
let role = roles.find(role => role.roleId == member.roleId);
|
||||
if(!role) continue;
|
||||
let userData = userDatas.find(userData => userData.roleId == member.roleId);
|
||||
let obj = new LeagueMemberDistributeInfo(role, serverNames);
|
||||
obj.setByUserData(userData);
|
||||
if(curJob == LEAGUE_JOB.PRODUCER && calProduce(obj) > 0) memberResult.push(obj);
|
||||
if(curJob == LEAGUE_JOB.FIGHTER && obj.score > 0) memberResult.push(obj);
|
||||
}
|
||||
|
||||
memberResult.sort((a, b) => {
|
||||
return curJob == LEAGUE_JOB.PRODUCER? calProduce(b) - calProduce(a): b.score - a.score;
|
||||
});
|
||||
let sumDistribute = curJob == LEAGUE_JOB.FIGHTER? calProduce(distribute): distribute.score;
|
||||
let curBox = box.find(cur => cur.job == curJob);
|
||||
let disObj = new LeagueDistributeInfo(curJob, sumDistribute, curBox?.received||[] );
|
||||
disObj.setMembers(memberResult);
|
||||
result.push(disObj)
|
||||
}
|
||||
|
||||
const myDistribute = await GVGUserDailyDistributeModel.findByRole(configId, myLeague.leagueCode, roleId);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
myDistribute: {
|
||||
food: myDistribute?.food||0,
|
||||
mineral: myDistribute?.mineral||0,
|
||||
wood: myDistribute?.wood||0,
|
||||
score: myDistribute?.score||0,
|
||||
},
|
||||
list: result
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async test(msg: { }, session: BackendSession) {
|
||||
const time = getGVGConfig();
|
||||
return resResult(STATUS.SUCCESS, { time });
|
||||
|
||||
@@ -211,6 +211,8 @@ export class GVGManageHandler {
|
||||
let data = new LeagueGuildInfo(guild, serverNames);
|
||||
let hasInvited = !!invitations.find(cur => cur.guildCode == guild.code);
|
||||
data.setHasInvited(hasInvited);
|
||||
// TODO
|
||||
// data.setActive
|
||||
return data
|
||||
});
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ export class GuildRemote {
|
||||
|
||||
public async setGVGConfig(config: GVGConfigType) {
|
||||
try {
|
||||
setGVGConfig(config);
|
||||
await setGVGConfig(config);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { isArray, isBoolean, isNumber, isString } from "underscore";
|
||||
import { BLOCK_OPEATE, DEBUG_MAGIC_WORD, GM_MAIL_TYPE, GUILD_AUTH, GUILD_STRUCTURE, LINEUP_NUM, MSG_TYPE } from "../consts";
|
||||
import { BLOCK_OPEATE, DEBUG_MAGIC_WORD, GM_MAIL_TYPE, GUILD_AUTH, GUILD_STRUCTURE, LEAGUE_JOB, LINEUP_NUM, MSG_TYPE } from "../consts";
|
||||
import { pvpEndParamInter } from "../pubUtils/interface";
|
||||
import { isDevelopEnv } from "./utilService";
|
||||
|
||||
@@ -1224,6 +1224,12 @@ export function checkRouteParam(route: string, msg: any) {
|
||||
if(!checkNaturalStrings(msg.id)) return false;
|
||||
break;
|
||||
}
|
||||
case "guild.gvgHandler.chooseJob":
|
||||
{
|
||||
if(msg.job != LEAGUE_JOB.FIGHTER && msg.job != LEAGUE_JOB.PRODUCER) return false;
|
||||
break;
|
||||
}
|
||||
|
||||
case "order.orderHandler.applyOrder":
|
||||
{
|
||||
let { productID, payType, activityId, paramStr, useVoucher } = msg;
|
||||
|
||||
5
game-server/app/services/gvg/gvgPrepareService.ts
Normal file
5
game-server/app/services/gvg/gvgPrepareService.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
export function calProduce(obj: { food: number, mineral: number, wood: number }) {
|
||||
let { food = 0, mineral = 0, wood = 0 } = obj||{};
|
||||
return food + mineral + wood;
|
||||
}
|
||||
@@ -16,11 +16,15 @@ import { GuildType } from "../../db/Guild";
|
||||
export async function createNewGVGConfig() {
|
||||
let { teamTime, prepareTime, battleTime, scheduleTime } = getPeriodTime();
|
||||
const config = await GVGConfigModel.createNewConfig(teamTime, prepareTime, battleTime, scheduleTime);
|
||||
setGVGConfigToRemote(config);
|
||||
try {
|
||||
await pinus.app.rpc.guild.guildRemote.setGVGConfig.broadcast(config);
|
||||
await pinus.app.rpc.guild.guildRemote.setGVGServerGroup.broadcast();
|
||||
await pinus.app.rpc.chat.chatRemote.setGVGServerGroup.broadcast();
|
||||
await pinus.app.rpc.connector.connectorRemote.setGVGServerGroup.broadcast();
|
||||
} catch(e) {
|
||||
console.log('remote未初始完');
|
||||
}
|
||||
// TODO 每周自动解散一些联军
|
||||
await pinus.app.rpc.guild.guildRemote.setGVGServerGroup.broadcast();
|
||||
await pinus.app.rpc.chat.chatRemote.setGVGServerGroup.broadcast();
|
||||
await pinus.app.rpc.connector.connectorRemote.setGVGServerGroup.broadcast();
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -53,13 +57,11 @@ export async function getGVGConfigFromRemote() {
|
||||
return await pinus.app.rpc.guild.guildRemote.getGVGConfig.toServer(server.id);
|
||||
}
|
||||
|
||||
export function setGVGConfigToRemote(config: GVGConfigType) {
|
||||
if(!config) return null
|
||||
pinus.app.rpc.guild.guildRemote.setGVGConfig.broadcast(config);
|
||||
}
|
||||
|
||||
export function setGVGConfig(config: GVGConfigType) {
|
||||
if(!config) return null
|
||||
export async function setGVGConfig(config?: GVGConfigType) {
|
||||
if(!config) {
|
||||
config = await GVGConfigModel.findConfig();
|
||||
}
|
||||
console.log('##### setGVGConfig', config)
|
||||
pinus.app.set('gvgConfigId', config.configId);
|
||||
pinus.app.set('gvgTeamTime', config.teamTime);
|
||||
pinus.app.set('gvgPrepareTime', config.prepareTime);
|
||||
@@ -100,6 +102,7 @@ export async function getGVGServerType(serverId: number) {
|
||||
|
||||
export function getGVGPeriodData() {
|
||||
let { configId, teamTime, prepareTime, battleTime, scheduleTime } = getGVGConfig();
|
||||
console.log('#### getGVGPeriodData', configId, teamTime, prepareTime, battleTime, scheduleTime)
|
||||
let period = getCurPeriod();
|
||||
let countdownTime = teamTime;
|
||||
switch(period) {
|
||||
@@ -129,11 +132,11 @@ export function getCurPeriod() {
|
||||
}
|
||||
|
||||
export async function initLeaguePrepare() {
|
||||
const { configId } = getGVGConfig();
|
||||
|
||||
const config = await GVGConfigModel.findConfig();
|
||||
if(!config) return;
|
||||
const leagues = await GVGLeagueModel.findAllLeague();
|
||||
for(let { leagueCode, memberCnt } of leagues) {
|
||||
await GVGLeaguePrepareModel.initData(configId, leagueCode, memberCnt);
|
||||
await GVGLeaguePrepareModel.initData(config.configId, leagueCode, memberCnt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +162,7 @@ export async function getServersOfSameGroup(type: GVG_SERVER_TYPE, id: number) {
|
||||
if(type == GVG_SERVER_TYPE.SINGLE) return [id];
|
||||
|
||||
let groupId = await getGroupIdOfServer(id);
|
||||
console.log('###### getServersOfSameGroup', type, groupId, id);
|
||||
return await getServersByGroupId(groupId);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import { getGroupShopTimers, refundGroupShop, setGroupShopToSetSum } from './act
|
||||
import { HiddenDataModel, HiddenDataModelType } from '../db/HiddenData';
|
||||
import { setHiddenData, setHiddenDataToMemory } from './dataService';
|
||||
import { GVGConfigModel } from '../db/GVGConfig';
|
||||
import { createNewGVGConfig, initLeaguePrepare, setGVGConfigToRemote } from './gvg/gvgService';
|
||||
import { createNewGVGConfig, initLeaguePrepare } from './gvg/gvgService';
|
||||
|
||||
const PER_SECOND = 1 * 1000;
|
||||
const PER_DAY = 24 * 60 * 60;
|
||||
@@ -899,18 +899,13 @@ export async function initHiddenDataSchedule(isInit: boolean, data?: HiddenDataM
|
||||
// —————————————— gvg start —————————————— //
|
||||
export async function initGVGConfigSchedule() {
|
||||
let config = await GVGConfigModel.findConfig();
|
||||
if(!config) {
|
||||
if(!config || nowSeconds() > config.scheduleTime) {
|
||||
config = await createNewGVGConfig();
|
||||
} else {
|
||||
setGVGConfigToRemote(config);
|
||||
}
|
||||
|
||||
if(nowSeconds() > config.scheduleTime) {
|
||||
config = await createNewGVGConfig();
|
||||
} else {
|
||||
scheduleJob(`gvgConfig`, config.scheduleTime * 1000, createNewGVGConfig);
|
||||
}
|
||||
|
||||
scheduleJob(`gvgConfig`, config.scheduleTime * 1000, createNewGVGConfig);
|
||||
|
||||
console.log('##### initGVGConfigSchedule', nowSeconds(), config.prepareTime)
|
||||
if(nowSeconds() > config.prepareTime) {
|
||||
initLeaguePrepare();
|
||||
} else {
|
||||
|
||||
@@ -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