✨ feat(gvg): 准备期征战中原初始
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import { Application, BackendSession, ChannelService, HandlerService } from "pinus";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GVGProduceHandler(app);
|
||||
}
|
||||
|
||||
export class GVGProduceHandler {
|
||||
channelService: ChannelService;
|
||||
constructor(private app: Application) {
|
||||
this.channelService = app.get('channelService');
|
||||
}
|
||||
|
||||
// 领取排行榜获得的每日奖励
|
||||
async receiveBox(msg: { vestigeId: number }, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 遗迹页面
|
||||
async getVestige(msg: { vestigeId: number }, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 编辑阵容
|
||||
async saveLineup(msg: { vestigeId: number, lineup: [{ actorId: number, dataId: number, order: number }] }, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 获取对手阵容消息
|
||||
async getOppLineup(msg: { vestigeId: number, roleId: string, rank: number }, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 刷新对手
|
||||
async refreshOpp(msg: {}, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 选择对手
|
||||
async chooseOpp(msg: { vestigeId: number, rank: number, myRank: number }, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 出战界面撤退
|
||||
async giveupCheck(msg: { battleCode: string }, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 获取对手具体战场数据
|
||||
async getOppData(msg: { battleCode: string }, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 布完阵开始挑战
|
||||
async checkBattle(msg: { battleCode: string, heroes: [{ actorId: number, dataId: number, order: number }] }, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 挑战结算
|
||||
async battleEnd(msg: { battleCode: string, isSuccess: boolean }, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 征战中原简单小排行榜
|
||||
async getLeagueRank(msg: {}, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 联军详细排名
|
||||
async getLeagueDetailRank(msg: {}, session: BackendSession) {
|
||||
|
||||
}
|
||||
|
||||
// 玩家排行
|
||||
async getPlayerRank(msg: { vestigeId: number }, session: BackendSession) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,10 @@ import { gameData } from "../../../pubUtils/data";
|
||||
import { lockLeagueData } from "../../../services/redLockService";
|
||||
import { addGVGReward, handleGVGCost } from "../../../services/gvg/gvgItemService";
|
||||
import { RewardInter } from "../../../pubUtils/interface";
|
||||
import { getGVGCities } from "../../../services/gvg/gvgBattleService";
|
||||
import { getGVGCities, getGVGCitiesInfo } from "../../../services/gvg/gvgBattleService";
|
||||
import { GVGRecModel } from "../../../db/GVGRec";
|
||||
import { checkGVGTask } from "../../../services/task/taskService";
|
||||
import { getFightTimeByPeriod, getVestiges } from "../../../services/gvg/gvgFightService";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -75,6 +76,26 @@ export class GVGHandler {
|
||||
return resResult(STATUS.SUCCESS, data)
|
||||
}
|
||||
|
||||
async getMap(msg: {}, session: BackendSession) {
|
||||
const serverId = session.get('serverId');
|
||||
const guildCode = session.get('guildCode');
|
||||
|
||||
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||
if(!myLeague) return resResult(STATUS.GVG_LEAGUE_NOT_EXIST);
|
||||
|
||||
let { configId, period, countdownTime } = getGVGPeriodData();
|
||||
let { startFightTime, endFightTime } = getFightTimeByPeriod(period);
|
||||
|
||||
let cities = await getGVGCitiesInfo(myLeague);
|
||||
let vestiges = await getVestiges(serverId);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
configId, period, countdownTime, startFightTime, endFightTime,
|
||||
cities,
|
||||
vestiges
|
||||
});
|
||||
}
|
||||
|
||||
// 获取动态
|
||||
async getRec(msg: {}, session: BackendSession) {
|
||||
const guildCode = session.get('guildCode');
|
||||
|
||||
@@ -7,4 +7,12 @@ import { GVGLeagueType } from "../../db/GVGLeague";
|
||||
*/
|
||||
export async function getGVGCities(league: GVGLeagueType) {
|
||||
return []
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 获取当前城池状态
|
||||
* @returns [{cityId: number, guardLeagueName: string, teamCnt: number }]
|
||||
*/
|
||||
export async function getGVGCitiesInfo(league: GVGLeagueType): Promise<{cityId: number, guardLeagueName: string, teamCnt: number }[]> {
|
||||
return [];
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// 征战中原相关
|
||||
|
||||
import { GVG_PERIOD } from "../../consts";
|
||||
import { GVGVestigeModel } from "../../db/GVGVestige";
|
||||
import { gameData } from "../../pubUtils/data";
|
||||
import { getTimeFun } from "../../pubUtils/timeUtil";
|
||||
import { getRandEelm } from "../../pubUtils/util";
|
||||
import { getGroupIdOfServer, getGVGServerType } from "./gvgService";
|
||||
|
||||
// 备战期的遗迹和激战期的开始结束战斗时间
|
||||
export function getFightTimeByPeriod(period: GVG_PERIOD) {
|
||||
let dicPeriod = gameData.gvgPeriod.get(period);
|
||||
if(!dicPeriod) return { startFightTime: 0, endFightTime: 0 };
|
||||
|
||||
return {
|
||||
startFightTime: <number>getTimeFun().getTimeWithHour(dicPeriod.startHour, dicPeriod.startMinute, dicPeriod.startSecond),
|
||||
endFightTime: <number>getTimeFun().getTimeWithHour(dicPeriod.endHour, dicPeriod.endMinute, dicPeriod.endSecond),
|
||||
}
|
||||
}
|
||||
|
||||
// 征战中原每天随机的遗迹点
|
||||
export async function getVestiges(serverId: number) {
|
||||
let groupId = await getGroupIdOfServer(serverId);
|
||||
let serverType = await getGVGServerType(serverId);
|
||||
let vestige = await GVGVestigeModel.getVestigate(groupId);
|
||||
if(!vestige) {
|
||||
let dicGVGVestige = gameData.gvgVestigeByServerType.get(serverType)||[];
|
||||
let cnt = gameData.gvgVestigeCntByServerType.get(serverType)||0;
|
||||
let randResult = getRandEelm(dicGVGVestige, cnt);
|
||||
vestige = await GVGVestigeModel.initTodayVestigate(groupId, serverType, randResult);
|
||||
}
|
||||
return vestige.vestiges||[];
|
||||
}
|
||||
@@ -38,9 +38,9 @@ export function getPeriodTime() {
|
||||
let battleConfig = gameData.gvgPeriod.get(GVG_PERIOD.BATTLE);
|
||||
|
||||
// 如果现在是周日,那么就是本周期的组队开始时间,如果是其他日子(启动初始化),就是下周期的组队开始时间
|
||||
let _teamTime = <number>getTimeFun().getTimeWithWeek(teamConfig.startDay, teamConfig.startHour, teamConfig.startMinute, teamConfig.startSecond);
|
||||
let _prepareTime = <number>getTimeFun().getTimeWithWeek(prepareConfig.startDay, prepareConfig.startHour, prepareConfig.startMinute, prepareConfig.startSecond);
|
||||
let _battleTime = <number>getTimeFun().getTimeWithWeek(battleConfig.startDay, battleConfig.startHour, battleConfig.startMinute, battleConfig.startSecond);
|
||||
let _teamTime = <number>getTimeFun().getTimeWithWeek(teamConfig.startDay);
|
||||
let _prepareTime = <number>getTimeFun().getTimeWithWeek(prepareConfig.startDay);
|
||||
let _battleTime = <number>getTimeFun().getTimeWithWeek(battleConfig.startDay);
|
||||
console.log('_teamTime: ', _teamTime);
|
||||
|
||||
let teamTime = curDay == 0? _teamTime: _teamTime - 7 * 86400;
|
||||
@@ -61,7 +61,6 @@ 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);
|
||||
@@ -99,14 +98,12 @@ function getCurrentTeamTime(time: number) {
|
||||
}
|
||||
|
||||
export async function getGVGServerType(serverId: number) {
|
||||
console.log('#### serverId', serverId)
|
||||
let openTime = await getServerCreateTime(serverId);
|
||||
return getServerTypeByTime(openTime)
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -166,7 +163,6 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -196,7 +196,6 @@ export class CheckSingleTask {
|
||||
|
||||
// 联军任务
|
||||
let dicGVGTasks = getGVGTasksByType(taskType);
|
||||
console.log('#####', taskType, dicGVGTasks)
|
||||
for(let { taskId, taskType, taskParam } of dicGVGTasks) {
|
||||
let taskUpdateParam = await this.checkIsMatch(taskParam, async () => []);
|
||||
if (taskUpdateParam) {
|
||||
|
||||
Reference in New Issue
Block a user