✨ feat(gvg): 添加贡献等接口
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user