✨ feat(gvg): 添加联军频道
This commit is contained in:
@@ -2,11 +2,12 @@ import { CHANNEL_PREFIX, MSG_SOURCE, getChannelType } from './../../../consts/co
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { DEFAULT_MSG_PER_PAGE, STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { createAccuseData, createGroupMsg, createPrivateMsg, getPrivateMessages, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadInfo, recentPrivateChatInfos, recentWorldMsgs, recentSysMsgs, recentGuildMsgs, updatePrivateMsgIsTop, delPrivateMsg, recentServerGroupMsgs } from '../../../services/chatService';
|
||||
import { createAccuseData, createGroupMsg, createPrivateMsg, getPrivateMessages, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadInfo, recentPrivateChatInfos, recentWorldMsgs, recentSysMsgs, recentGuildMsgs, updatePrivateMsgIsTop, delPrivateMsg, recentServerGroupMsgs, recentLeagueMsgs } from '../../../services/chatService';
|
||||
import { getSimpleRoleInfo } from '../../../services/roleService';
|
||||
import { checkTask } from '../../../services/task/taskService';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { getFriendRelationType } from '../../../services/friendService';
|
||||
import { GVGLeagueModel } from '../../../db/GVGLeague';
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
@@ -36,6 +37,11 @@ export class ChatHandler {
|
||||
let channelId = '';
|
||||
if (channel === CHANNEL_PREFIX.WORLD) channelId = `${serverId}`;
|
||||
if (channel === CHANNEL_PREFIX.GUILD) channelId = guildCode;
|
||||
if (channel == CHANNEL_PREFIX.LEAGUE) {
|
||||
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||
if(!myLeague) return resResult(STATUS.GVG_NOT_JOIN_LEAGUE);
|
||||
channelId = myLeague.leagueCode;
|
||||
}
|
||||
const msgData = await createGroupMsg(roleId, roleName, channel, channelId, type, MSG_SOURCE.ROLE_SEND_TEXT, content, targetRoleId, targetMsgCode);
|
||||
if (!msgData) return resResult(STATUS.WRONG_PARMS);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
@@ -108,8 +114,9 @@ export class ChatHandler {
|
||||
const sysMsgs = await recentSysMsgs(serverId);
|
||||
const guildMsgs = await recentGuildMsgs(guildCode);
|
||||
const gvgMsgs = await recentServerGroupMsgs(serverId);
|
||||
const leagueMsgs = await recentLeagueMsgs(guildCode);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { worldMsgs, sysMsgs, guildMsgs, gvgMsgs })
|
||||
return resResult(STATUS.SUCCESS, { worldMsgs, sysMsgs, guildMsgs, gvgMsgs, leagueMsgs })
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -599,11 +599,11 @@ export class GVGBattleHandler {
|
||||
|
||||
// 获取战报
|
||||
// type: 战报类型
|
||||
async getRecs(msg: { type: number, cityId: number }, session: BackendSession) {
|
||||
async getRecs(msg: { type: number }, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
const guildCode = session.get('guildCode');
|
||||
const { type, cityId } = msg;
|
||||
const { type } = msg;
|
||||
// 根据 type 获取战报
|
||||
let { configId, period } = getGVGPeriodData();
|
||||
let groupKey = await getGroupKey(serverId);
|
||||
@@ -613,7 +613,7 @@ export class GVGBattleHandler {
|
||||
|
||||
let recs: GVGRecType[] = [];
|
||||
if(type == GVG_REC_TYPE.BATTLE_BY_CITY) {
|
||||
recs = await GVGRecModel.findBattleRecByCity(configId, groupKey, cityId);
|
||||
recs = await GVGRecModel.findBattleRecByGroup(configId, groupKey);
|
||||
} else if (type == GVG_REC_TYPE.BATTLE_BY_LEAGUE) {
|
||||
recs = await GVGRecModel.findBattleRecByLeague(configId, myLeague.leagueCode);
|
||||
} else if (type == GVG_REC_TYPE.BATTLE_BY_ROLE) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import { checkGVGTask } from "../../../services/task/taskService";
|
||||
import { getFightTimeByPeriod, getMyVestiges, getVestiges } from "../../../services/gvg/gvgFightService";
|
||||
import { getSeconds } from "../../../pubUtils/timeUtil";
|
||||
import { GVGVestigeRankModel } from "../../../db/GVGVestigeRank";
|
||||
import { addTechActivateMessage, addTechUnlockMessage } from "../../../services/gvg/gvgRecService";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -344,6 +345,7 @@ export class GVGHandler {
|
||||
// 千机阁解锁
|
||||
async unlockTech(msg: { techId: number }, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const guildCode = session.get('guildCode');
|
||||
const { techId } = msg;
|
||||
|
||||
@@ -383,6 +385,8 @@ export class GVGHandler {
|
||||
}
|
||||
|
||||
res.releaseCallback();
|
||||
addTechUnlockMessage(roleId, roleName, myLeague, techId);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
queue: leaguePrepare?.techQueue||[]
|
||||
});
|
||||
@@ -392,6 +396,7 @@ export class GVGHandler {
|
||||
async activate(msg: { techId: number, battleFeats: number }, session: BackendSession) {
|
||||
const serverId = session.get('serverId');
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const guildCode = session.get('guildCode');
|
||||
const sid = session.get('sid');
|
||||
const { techId, battleFeats } = msg;
|
||||
@@ -436,6 +441,7 @@ export class GVGHandler {
|
||||
await addGVGReward(roleId, '', myLeague.leagueCode, null, [{ id: GVG_ITEM.KNIFE, count: dicTech.param[1] }], [], ITEM_CHANGE_REASON.GVG_TECH_SEND_KNIFE);
|
||||
}
|
||||
}
|
||||
addTechActivateMessage(roleId, roleName, myLeague, techId);
|
||||
}
|
||||
|
||||
// 添加 活跃
|
||||
|
||||
@@ -16,7 +16,7 @@ import { GVGLeaguePrepareModel } from "../../../db/GVGLeaguePrepare";
|
||||
import { createGroupMsg, pushGroupMsgToRoom } from "../../../services/chatService";
|
||||
import { sendMailByContent, sendMailToGuildByContent, sendMailToLeagueByContent } from "../../../services/mailService";
|
||||
import { getGVGCities } from "../../../services/gvg/gvgBattleService";
|
||||
import { guildQuitLeagueRecord } from "../../../services/gvg/gvgRecService";
|
||||
import { changeNoticeMessage, guildQuitLeagueRecord } from "../../../services/gvg/gvgRecService";
|
||||
import { LeagueLeader } from "../../../domain/rank";
|
||||
|
||||
export default function (app: Application) {
|
||||
@@ -587,6 +587,7 @@ export class GVGManageHandler {
|
||||
// 设置联军信息
|
||||
async setLeagueInfo(msg: { leagueCode: string, name: string, notice: string, icon: number }, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const guildCode = session.get('guildCode');
|
||||
|
||||
const { leagueCode: targetLeagueCode, name, notice, icon } = msg;
|
||||
@@ -611,6 +612,9 @@ export class GVGManageHandler {
|
||||
if(icon != undefined) {
|
||||
await updateUserInfo(REDIS_KEY.LEAGUE_INFO, myLeague.leagueCode, [{ field: 'icon', value: name }]);
|
||||
}
|
||||
if(notice != undefined) {
|
||||
await changeNoticeMessage(roleId, roleName, myLeague, notice);
|
||||
}
|
||||
|
||||
// 返回
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
|
||||
@@ -227,7 +227,7 @@ export class GVGProduceHandler {
|
||||
// 计算产量
|
||||
const { foodSum, rewardSum, leagueRewardSum, activeSum } = await sumOutputByResults(myResultFields);
|
||||
// 资源
|
||||
let resourceResult = await addResource(myLeague.leagueCode, roleId, roleName, GVG_RESOURCE_TYPE.FOOD, foodSum)||{};
|
||||
let resourceResult = await addResource(myLeague, roleId, roleName, GVG_RESOURCE_TYPE.FOOD, foodSum)||{};
|
||||
// 相关物品
|
||||
let leagueGoods = await addGVGReward(roleId, roleName, myLeague.leagueCode, sid, leagueRewardSum, rewardSum, ITEM_CHANGE_REASON.HARVEST)
|
||||
// 活跃
|
||||
@@ -282,7 +282,7 @@ export class GVGProduceHandler {
|
||||
// 计算产量
|
||||
const { foodSum, rewardSum, leagueRewardSum, activeSum } = await sumOutputByResults(resultField);
|
||||
// 资源
|
||||
await addResource(myLeague.leagueCode, targetRoleId, resultField[0].lockRoleName, GVG_RESOURCE_TYPE.FOOD, foodSum)||{};
|
||||
await addResource(myLeague, targetRoleId, resultField[0].lockRoleName, GVG_RESOURCE_TYPE.FOOD, foodSum)||{};
|
||||
await sendMailByContent(MAIL_TYPE.HELP_HARVEST, targetRoleId, { sendName: roleName, goods: rewardSum });
|
||||
// 相关物品
|
||||
await addGVGReward(targetRoleId, roleName, myLeague.leagueCode, targetOnlineInfo.sid, leagueRewardSum, [], ITEM_CHANGE_REASON.HARVEST)
|
||||
@@ -368,7 +368,7 @@ export class GVGProduceHandler {
|
||||
let { reward, leagueReward, leagueConsume } = dicGVGItem;
|
||||
let produceCoin = getProduceCoinCnt(leagueConsume);
|
||||
// 资源
|
||||
let resourceResult = await addResource(myLeague.leagueCode, roleId, roleName, GVG_RESOURCE_TYPE.MINERAL, output)||{};
|
||||
let resourceResult = await addResource(myLeague, roleId, roleName, GVG_RESOURCE_TYPE.MINERAL, output)||{};
|
||||
// 相关物品
|
||||
let leagueGoods = await addGVGReward(roleId, roleName, myLeague.leagueCode, sid, leagueReward, reward, ITEM_CHANGE_REASON.HARVEST)
|
||||
// 活跃
|
||||
@@ -489,7 +489,7 @@ export class GVGProduceHandler {
|
||||
let { reward, leagueReward, leagueConsume } = dicGVGItem;
|
||||
let produceCoin = getProduceCoinCnt(leagueConsume);
|
||||
// 资源
|
||||
let resourceResult = await addResource(myLeague.leagueCode, roleId, roleName, GVG_RESOURCE_TYPE.WOOD, output)||{};
|
||||
let resourceResult = await addResource(myLeague, roleId, roleName, GVG_RESOURCE_TYPE.WOOD, output)||{};
|
||||
// 相关物品
|
||||
let leagueGoods = await addGVGReward(roleId, roleName, myLeague.leagueCode, sid, leagueReward, reward, ITEM_CHANGE_REASON.HARVEST)
|
||||
// 活跃
|
||||
@@ -514,7 +514,7 @@ export class GVGProduceHandler {
|
||||
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||
if(!myLeague) return resResult(STATUS.GVG_LEAGUE_NOT_EXIST);
|
||||
|
||||
let resourceResult = await addResource(myLeague.leagueCode, roleId, roleName, type, count);
|
||||
let resourceResult = await addResource(myLeague, roleId, roleName, type, count);
|
||||
if(!resourceResult) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
return resResult(STATUS.SUCCESS, resourceResult);
|
||||
|
||||
@@ -18,6 +18,7 @@ import { comBtlLvInvalid } from './comBattleService';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { RegionModel } from '../db/Region';
|
||||
import { getGroupIdOfServer, getServersByGroupId } from './gvg/gvgService';
|
||||
import { GVGLeagueModel } from '../db/GVGLeague';
|
||||
|
||||
export * from './chatChannelService';
|
||||
export * from './sysChatService';
|
||||
@@ -75,8 +76,8 @@ async function createPrivateMsgData(roleId: string, roleName: string, type: numb
|
||||
/**
|
||||
* @description 生成群聊消息数据
|
||||
*/
|
||||
async function createGroupMsgData(roleId: string, roleName: string, channel: string, channelId: string, type: number, source: number, content: string, targetRoleId: string, targetMsgCode: string) {
|
||||
const result: GroupMessageParam = {roleId, roleName, channel, channelId, type, source, content, targetRoleId, targetMsgCode};
|
||||
async function createGroupMsgData(roleId: string, roleName: string, channel: string, channelId: string, type: number, source: number, content: string, targetRoleId: string, targetMsgCode: string, otherInfo = '') {
|
||||
const result: GroupMessageParam = {roleId, roleName, channel, channelId, type, source, content, targetRoleId, targetMsgCode, otherInfo };
|
||||
result.roomId = groupRoomId(channel, channelId);
|
||||
await setupBaseMsgParm(result);
|
||||
return result;
|
||||
@@ -120,8 +121,8 @@ export async function createPrivateMsg(roleId: string, roleName: string, type: n
|
||||
* @param {string} targetMsgCode
|
||||
* @returns
|
||||
*/
|
||||
export async function createGroupMsg(roleId: string, roleName: string, channel: string, channelId: string, type: number, source: number, content: string, targetRoleId: string, targetMsgCode: string) {
|
||||
const msgData: GroupMessageParam = await createGroupMsgData(roleId, roleName, channel, channelId, type, source, content, targetRoleId, targetMsgCode);
|
||||
export async function createGroupMsg(roleId: string, roleName: string, channel: string, channelId: string, type: number, source: number, content: string, targetRoleId: string, targetMsgCode: string, otherInfo = '') {
|
||||
const msgData: GroupMessageParam = await createGroupMsgData(roleId, roleName, channel, channelId, type, source, content, targetRoleId, targetMsgCode, otherInfo);
|
||||
const result: GroupMessageType = await GroupMessageModel.createMsg(msgData);
|
||||
return result;
|
||||
}
|
||||
@@ -170,7 +171,12 @@ export async function pushGroupMsgToRoom(msg: GroupMessageType) {
|
||||
for(let serverId of serverIds) {
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.GROUP_MSG, { ...msg, roleInfo });
|
||||
}
|
||||
}
|
||||
} else if (msg.channel == CHANNEL_PREFIX.LEAGUE) {
|
||||
let guildCodes = msg.otherInfo? msg.otherInfo.split('|'): [];
|
||||
for(let guildCode of guildCodes) {
|
||||
await sendMessageToGuildWithSuc(guildCode, PUSH_ROUTE.GROUP_MSG, { ...msg, roleInfo });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function pushGroupMsgToAll(msg: GroupMessageType, filterCb?: ({ lv, topLineupCe }) => boolean) {
|
||||
@@ -231,7 +237,6 @@ async function recentGroupMsgs(roomId: string, count?: number) {
|
||||
*/
|
||||
export async function recentServerGroupMsgs(serverId: number, count?: number) {
|
||||
let groupId = await getGroupIdOfServer(serverId);
|
||||
console.log('####', groupId);
|
||||
const result = await recentGroupMsgs(groupRoomId(CHANNEL_PREFIX.GVG, groupId), count);
|
||||
return result;
|
||||
}
|
||||
@@ -273,6 +278,21 @@ export async function recentGuildMsgs(guildCode: string, count?: number) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取最近的联军聊天消息
|
||||
* @export
|
||||
* @param {string} guildCode 用区服编号做房间标识
|
||||
* @param {number} [count]
|
||||
* @returns
|
||||
*/
|
||||
export async function recentLeagueMsgs(guildCode: string, count?: number) {
|
||||
if(!guildCode) return [];
|
||||
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||
if(!myLeague) return [];
|
||||
const result = await recentGroupMsgs(groupRoomId(CHANNEL_PREFIX.LEAGUE, myLeague.leagueCode), count);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 创建新的私聊记录
|
||||
* @param {boolean} sender 给发送者还是接收者创建,发送者发消息的时候也阅读了消息
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* entry触发后引起的下发
|
||||
*/
|
||||
import { getMails } from './mailService';
|
||||
import { recentGuildMsgs, recentPrivateChatInfos, recentServerGroupMsgs, recentSysMsgs, recentWorldMsgs } from './chatService';
|
||||
import { recentGuildMsgs, recentLeagueMsgs, recentPrivateChatInfos, recentServerGroupMsgs, recentSysMsgs, recentWorldMsgs } from './chatService';
|
||||
import { getCurTask, getPvpTask } from './task/taskService';
|
||||
|
||||
import { RoleType } from '../db/Role';
|
||||
@@ -204,8 +204,9 @@ export async function getModuleData(type: string, data: { role: RoleType, sessio
|
||||
const sysMsgs = await recentSysMsgs(serverId);
|
||||
const guildMsgs = await recentGuildMsgs(guildCode);
|
||||
const gvgMsgs = await recentServerGroupMsgs(serverId);
|
||||
const leagueMsgs = await recentLeagueMsgs(guildCode);
|
||||
const recentPrivateChats = await recentPrivateChatInfos(roleId, roleName);
|
||||
return { worldMsgs, sysMsgs, guildMsgs, gvgMsgs, recentPrivateChats };
|
||||
return { worldMsgs, sysMsgs, guildMsgs, gvgMsgs, leagueMsgs, recentPrivateChats };
|
||||
case 'event':
|
||||
return await getEvent(role.eventStatus, roleId, roleName);
|
||||
case 'battle':
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { GVGTeamMem } from "../../domain/battleField/gvgBattle";
|
||||
import { GVGLeagueType } from "../../db/GVGLeague";
|
||||
import { GVGLeagueModel, GVGLeagueType } from "../../db/GVGLeague";
|
||||
import { GVGTeamModel, GVGTeamType, GVGTeamUpdate } from "../../db/GVGTeam";
|
||||
import { GVGCityModel, GVGCityType } from "../../db/GVGCity";
|
||||
import { gameData, getGVGBattleRankReward } from "../../pubUtils/data";
|
||||
@@ -20,6 +20,7 @@ import { findKeys, getAllServerName } from "../redisService";
|
||||
import { sendMessageToGVGAreaByTeamWithSuc, sendMessageToGVGAreaWithSuc, sendMessageToGVGCityWithSuc } from "../pushService";
|
||||
import { sendMailToLeagueByContent } from "../mailService";
|
||||
import { GVGCityAreaPointModel } from "../../db/GVGCityAreaPoint";
|
||||
import { addCityGuardMessage } from "./gvgRecService";
|
||||
|
||||
|
||||
/**
|
||||
@@ -380,7 +381,9 @@ export async function gvgBattleEnd() {
|
||||
if(cnt < GVG.GVG_CITY_OCCUPIED_NUMBER) {
|
||||
await GVGCityModel.guardCity(configId, groupKey, cityId, rankInfo);
|
||||
let dicCityAdd = gameData.gvgCityAdd.get(dicCity.cityType);
|
||||
await sendMailToLeagueByContent(MAIL_TYPE.GVG_GUARD_CITY_REWARD, rankInfo.code, { params: [dicCity.cityName], goods: dicCityAdd.occupyReward });
|
||||
let league = await GVGLeagueModel.findByCodeWithoutPopulate(rankInfo.code);
|
||||
await sendMailToLeagueByContent(MAIL_TYPE.GVG_GUARD_CITY_REWARD, rankInfo.code, { params: [dicCity.cityName], goods: dicCityAdd.occupyReward }, league);
|
||||
await addCityGuardMessage(league, cityId);
|
||||
guardLeagueCnt.set(rankInfo.code, cnt + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ import { getHeroesAttributes } from "../playerCeService";
|
||||
import { Rank } from "../rankService";
|
||||
import { findKeys, getAllServerName, redisClient } from "../redisService";
|
||||
import { combinePushItem } from "./gvgItemService";
|
||||
import { addVestigeLeagueRankRec } from "./gvgRecService";
|
||||
import { getGroupIdOfServer, getGroupKey, getGVGServerType } from "./gvgService";
|
||||
import { addVestigeLeagueRankRec, addVestigeRankMessage } from "./gvgRecService";
|
||||
import { getGroupIdOfServer, getGroupKey, getGVGServerType, getPeriodByTime } from "./gvgService";
|
||||
|
||||
// 备战期的遗迹和激战期的开始结束战斗时间
|
||||
export function getFightTimeByPeriod(period: GVG_PERIOD, time?: number) {
|
||||
@@ -390,6 +390,8 @@ export async function getVestigeRank(redisKey: REDIS_KEY, isSimple: boolean, key
|
||||
// systimer 服
|
||||
export async function saveVestigeRankSchedule() {
|
||||
let config = await GVGConfigModel.findConfig();
|
||||
let period = getPeriodByTime(config.teamTime, config.prepareTime, config.battleTime, config.scheduleTime);
|
||||
if(period != GVG_PERIOD.PREPARE) return;
|
||||
let day = getDayKeyInfo();
|
||||
let keys = await findKeys(`${REDIS_KEY.GVG_VESTIGE_LEAGUE}:${day}:`);
|
||||
for(let key of keys) {
|
||||
@@ -398,6 +400,7 @@ export async function saveVestigeRankSchedule() {
|
||||
let ranks = await r.getRankByRangeRaw();
|
||||
await GVGVestigeLeagueRankModel.saveRank(groupKey, ranks);
|
||||
await addVestigeLeagueRankRec(config.configId, groupKey, ranks);
|
||||
await addVestigeRankMessage(ranks);
|
||||
}
|
||||
|
||||
let memberKeys = await findKeys(`${REDIS_KEY.GVG_VESTIGE_MEMBER_ALL}:${day}:`);
|
||||
@@ -416,14 +419,14 @@ export function calVestigeLeagueBoxRewards(canReceiveRanks: GVGVestigeLeagueRank
|
||||
for(let { rank } of canReceiveRanks) {
|
||||
let dicRank = getGVGVestigeLeagueRank(rank);
|
||||
if(!dicRank) { console.error('dic_zyz_GVGVestigeLeagueRank error'); continue; }
|
||||
console.log('###### league', rank, dicRank)
|
||||
// console.log('###### league', rank, dicRank)
|
||||
combinePushItem(rewards, dicRank.rankReward);
|
||||
combinePushItem(leagueReward, dicRank.rankLeagueReward);
|
||||
}
|
||||
for(let { rank } of canReceivePlayerRanks) {
|
||||
let dicRank = getGVGVestigePlayerRank(rank);
|
||||
if(!dicRank) { console.error('dic_zyz_GVGVestigPlayerRank error'); continue; }
|
||||
console.log('###### player', rank, dicRank)
|
||||
// console.log('###### player', rank, dicRank)
|
||||
combinePushItem(rewards, dicRank.rankPlayerReward);
|
||||
combinePushItem(leagueReward, dicRank.rankPlayerLeagueReward);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ import { addGVGReward } from "./gvgItemService";
|
||||
import { getGVGConfig } from "./gvgService";
|
||||
import { getProduceCoinCnt } from "./gvgItemService";
|
||||
import { GVGVestigeRankModel } from "../../db/GVGVestigeRank";
|
||||
import { addResourceRecord } from "./gvgRecService";
|
||||
import { addLeagueLvUpMessage, addResourceRecord } from "./gvgRecService";
|
||||
import { GVGLeagueType } from "../../db/GVGLeague";
|
||||
|
||||
export function checkPreTech(techId: number, activeQueue: number[], techQueue: Tech[]) {
|
||||
const dicTech = gameData.gvgTech.get(techId);
|
||||
@@ -116,7 +117,8 @@ export function getMyContribute(userDailyData: GVGUserDailyDataType, myRanks: {v
|
||||
* @param count 数量
|
||||
* @returns
|
||||
*/
|
||||
export async function addResource(leagueCode: string, roleId: string, roleName: string, resourceType: GVG_RESOURCE_TYPE, count: number) {
|
||||
export async function addResource(myLeague: GVGLeagueType, roleId: string, roleName: string, resourceType: GVG_RESOURCE_TYPE, count: number) {
|
||||
let { leagueCode } = myLeague;
|
||||
let { configId } = getGVGConfig();
|
||||
let resources = getResourceCnt(resourceType, count);
|
||||
if(!resources) return false;
|
||||
@@ -124,6 +126,7 @@ export async function addResource(leagueCode: string, roleId: string, roleName:
|
||||
|
||||
// 联军更新资源
|
||||
let league = await GVGLeaguePrepareModel.addResource(configId, leagueCode, food, mineral, wood);
|
||||
let originLv = league?.lv||1;
|
||||
// 联军升级
|
||||
let lv = calLeagueLv(league.resources);
|
||||
league = await GVGLeaguePrepareModel.setLv(configId, leagueCode, lv);
|
||||
@@ -135,6 +138,7 @@ export async function addResource(leagueCode: string, roleId: string, roleName:
|
||||
|
||||
let myContribute = getMyContribute(userDailyData, myRanks);
|
||||
addResourceRecord(roleId, roleName, leagueCode, resourceType, count);
|
||||
if(lv > originLv) addLeagueLvUpMessage(roleId, roleName, myLeague, lv);
|
||||
|
||||
return { resources: league.resources, leagueLv: league.lv, myContribute }
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
|
||||
// 动态
|
||||
import { GVG_REC_ID, GVG_REC_TYPE, GVG_RESOURCE_TYPE } from "../../consts";
|
||||
import { CHANNEL_PREFIX, GVG_REC_ID, GVG_REC_TYPE, GVG_RESOURCE_TYPE, MSG_SOURCE, MSG_TYPE } from "../../consts";
|
||||
import { GVGBattleRecType } from "../../db/GVGBattleRec";
|
||||
import { GVGLeagueModel, GVGLeagueType } from "../../db/GVGLeague";
|
||||
import { GVGRecModel } from "../../db/GVGRec";
|
||||
import { GVGTeamType } from "../../db/GVGTeam";
|
||||
import { GVGVestigeRecType } from "../../db/GVGVestigeRec";
|
||||
import { gameData } from "../../pubUtils/data";
|
||||
import { nowSeconds } from "../../pubUtils/timeUtil";
|
||||
import { createGroupMsg, pushGroupMsgToRoom } from "../chatService";
|
||||
import { getGVGConfig } from "./gvgService";
|
||||
|
||||
// 加入军团
|
||||
@@ -114,4 +116,47 @@ export async function addTeamSettleRec(team: GVGTeamType) {
|
||||
export async function addTeamLeaveRec(team: GVGTeamType, pointId: number) {
|
||||
let { roleId, roleName, leagueCode, configId, cityId, groupKey } = team;
|
||||
await GVGRecModel.addRec({ roleId, leagueCode, configId, cityId, groupKey, type: GVG_REC_TYPE.BATTLE_BY_LEAGUE, recId: GVG_REC_ID.LEAGUE_TEAM_LEAVE, createTime: nowSeconds(), params: [`${roleName}`, getPointName(pointId)] });
|
||||
}
|
||||
|
||||
|
||||
// —————— 频道消息 ——————
|
||||
export async function addLeagueLvUpMessage(roleId: string, roleName: string, myLeague: GVGLeagueType, lv: number) {
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.LEAGUE, myLeague.leagueCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GVG_LV_UP, JSON.stringify({ leagueCode: myLeague.leagueCode, name: myLeague.name, lv }), '', '', getGuildCodeString(myLeague));
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
}
|
||||
|
||||
export async function changeNoticeMessage(roleId: string, roleName: string, myLeague: GVGLeagueType, notice: string) {
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GVG, myLeague.leagueCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GVG_NOTICE, JSON.stringify({ leagueCode: myLeague.leagueCode, name: myLeague.name, notice }), '', '', getGuildCodeString(myLeague));
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
}
|
||||
|
||||
export function getGuildCodeString(myLeague: GVGLeagueType) {
|
||||
let guildCodes = myLeague?.guildCodes||[];
|
||||
return guildCodes.join('|')
|
||||
}
|
||||
|
||||
export async function addTechActivateMessage(roleId: string, roleName: string, myLeague: GVGLeagueType, techId: number) {
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.LEAGUE, myLeague.leagueCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GVG_LV_UP, JSON.stringify({ leagueCode: myLeague.leagueCode, name: myLeague.name, techId }), '', '', getGuildCodeString(myLeague));
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
}
|
||||
|
||||
export async function addTechUnlockMessage(roleId: string, roleName: string, myLeague: GVGLeagueType, techId: number) {
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.LEAGUE, myLeague.leagueCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GVG_LV_UP, JSON.stringify({ leagueCode: myLeague.leagueCode, name: myLeague.name, techId }), '', '', getGuildCodeString(myLeague));
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
}
|
||||
|
||||
export async function addVestigeRankMessage(ranks: { rank: number, field: string }[]) {
|
||||
let leagueCodes = ranks.map(cur => cur.field);
|
||||
let leagues = await GVGLeagueModel.findByCodesWithoutPopulate(leagueCodes, 'leagueCode name guildCodes');
|
||||
for(let { rank, field: leagueCode } of ranks) {
|
||||
let league = leagues.find(cur => cur.leagueCode == leagueCode);
|
||||
if(!league) continue;
|
||||
const msgData = await createGroupMsg('', '', CHANNEL_PREFIX.LEAGUE, leagueCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GVG_LV_UP, JSON.stringify({ leagueCode: league.leagueCode, name: league.name, rank }), '', '', getGuildCodeString(league));
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
export async function addCityGuardMessage(myLeague: GVGLeagueType, cityId: number) {
|
||||
const msgData = await createGroupMsg('', '', CHANNEL_PREFIX.LEAGUE, myLeague.leagueCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GVG_LV_UP, JSON.stringify({ leagueCode: myLeague.leagueCode, name: myLeague.name, cityId }), '', '', getGuildCodeString(myLeague));
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
}
|
||||
@@ -148,6 +148,10 @@ export function getGVGPeriodData() {
|
||||
|
||||
export function getCurPeriod() {
|
||||
let { teamTime, prepareTime, battleTime, scheduleTime } = getGVGConfig();
|
||||
return getPeriodByTime(teamTime, prepareTime, battleTime, scheduleTime)
|
||||
}
|
||||
|
||||
export function getPeriodByTime(teamTime: number, prepareTime: number, battleTime: number, scheduleTime: number) {
|
||||
let now = nowSeconds();
|
||||
if(now >= teamTime && now < prepareTime) {
|
||||
return GVG_PERIOD.TEAM;
|
||||
|
||||
Reference in New Issue
Block a user