✨ feat(gvg): 添加联军频道
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user