军团:添加邀请红点和演武台功能
This commit is contained in:
@@ -22,6 +22,7 @@ import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { sendMailToGuildByContent } from '../../../services/mailService';
|
||||
import { genAuction } from '../../../services/auctionService';
|
||||
import { getMedianCe } from '../../../services/guildActivityService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -61,7 +62,12 @@ export class GuildHandler {
|
||||
return resResult(STATUS.GUILD_STRUCTURE_NOT_FOUND);
|
||||
}
|
||||
let bossBase = getBossByLv(curStructure.lv);
|
||||
let { bossHp, warId } = getRandSingleEelm(bossBase.wars);
|
||||
let { bossHp: minBossHp, warId } = getRandSingleEelm(bossBase.wars);
|
||||
let medianCe = await getMedianCe(serverId);
|
||||
let bossHp = Math.ceil(medianCe * bossBase.ratio);
|
||||
|
||||
console.log('******* openBossInstance', medianCe, bossHp, minBossHp)
|
||||
if(bossHp < minBossHp) bossHp = minBossHp;
|
||||
let resGuild = await GuildModel.costFund(code, bossBase.opencost);
|
||||
if (!resGuild) {
|
||||
res.releaseCallback();
|
||||
@@ -198,9 +204,11 @@ export class GuildHandler {
|
||||
|
||||
let { bossDamage = 0 } = battleRecord.record; // 伤害奖励
|
||||
let dicBossBase = gameData.bossBaseByBossLv.get(bossInstance.bossLv);
|
||||
let reward = dicBossBase.damageReward.map(({id, count}) => {
|
||||
return { id, count: Math.floor(count * bossDamage * dicBossBase.ratio / 1000 ) }
|
||||
});
|
||||
let { basicReward, damageRewardTotal } = dicBossBase;
|
||||
let damageReward = damageRewardTotal.map(cur => {
|
||||
return { id: cur.id, count: Math.ceil(cur.count * bossDamage / bossInstance.bossTotalHp )}
|
||||
})
|
||||
let reward = [...basicReward, ...damageReward];
|
||||
|
||||
let battleGoods = await addItems(roleId, roleName, sid, reward, ITEM_CHANGE_REASON.BOSS_BATTLE_END);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Application, BackendSession, ChannelService, HandlerService, } from 'pi
|
||||
import { resResult, getRandEelm, shouldRefresh, sortArrRandom } from '../../../pubUtils/util';
|
||||
import { STATUS, GUILD_OPERATE, GUILD_AUTH, GUILD_JOB, GUILD_APPLY_TYPE, GUILD_STRUCTURE, GUILD_REC_TYPE, GUILD_STRUCTURE_NAME, MAIL_TYPE, REDIS_KEY, GUILD_SELECT, USER_GUILD_SELECT, TASK_TYPE, DEBUG_MAGIC_WORD, CHANNEL_PREFIX, MSG_TYPE, MSG_SOURCE, ITEM_CHANGE_REASON, TA_EVENT, GUILD_DISMISS_WAY, GUILD_MASTER_CHANGE_WAY, GUILD_QUIT_WAY } from '../../../consts';
|
||||
import { UserGuildModel, UserGuildType } from '../../../db/UserGuild';
|
||||
import { checkAuth, joinGuild, getGuildWithRefActive, getUserGuildWithRefActive, addActive, settleGuildWeekly, getMyGuildInfo, refreshUserGuild, setUserGuildSession } from '../../../services/guildService';
|
||||
import { checkAuth, joinGuild, getGuildWithRefActive, getUserGuildWithRefActive, addActive, settleGuildWeekly, getMyGuildInfo, refreshUserGuild, setUserGuildSession, getInvitationList } from '../../../services/guildService';
|
||||
import { GuildModel, GuildType, GuildUpdateParam } from '../../../db/Guild';
|
||||
import { RoleModel, RoleType } from '../../../db/Role';
|
||||
import { ARMY } from '../../../pubUtils/dicParam';
|
||||
@@ -424,14 +424,18 @@ export class GuildHandler {
|
||||
|
||||
const roleList = await RoleModel.findByRoleIds(roleIds);
|
||||
let result = new Array<string>();
|
||||
let uids = [];
|
||||
|
||||
for (let role of roleList) {
|
||||
if (!role.hasGuild || role.serverId == serverId) {
|
||||
await UserGuildApplyModel.createUserGuildApply(role, guild, GUILD_APPLY_TYPE.INVITE);
|
||||
let apply = await UserGuildApplyModel.createUserGuildApply(role, guild, GUILD_APPLY_TYPE.INVITE);
|
||||
result.push(role.roleId);
|
||||
let hisInfo = await getRoleOnlineInfo(role.roleId);
|
||||
if (hisInfo.isOnline) {
|
||||
uids.push({ uid: role.roleId, sid: hisInfo.sid })
|
||||
let uids = [{ uid: role.roleId, sid: hisInfo.sid }];
|
||||
let guild = <GuildType>apply.guild;
|
||||
let leader = <RoleType>guild.leader;
|
||||
let invitation = { applyCode: apply.applyCode, ...guild, leader: leader.roleName };
|
||||
this.channelService.pushMessageByUids('onGuildInvite', resResult(STATUS.SUCCESS, { invitation }), uids);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -440,7 +444,6 @@ export class GuildHandler {
|
||||
}
|
||||
|
||||
await GuildModel.recordInvitedMember(code, serverId, roleIds, shouldRefresh(guild.inviteTime, new Date()));
|
||||
this.channelService.pushMessageByUids('onGuildInvite', resResult(STATUS.SUCCESS, { code }), uids);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { roleIds: result });
|
||||
|
||||
@@ -451,14 +454,7 @@ export class GuildHandler {
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const { lastApplyCode } = msg;
|
||||
|
||||
const result = await UserGuildApplyModel.findInviteByRole(roleId, lastApplyCode);
|
||||
const list = result.map(cur => {
|
||||
let guild = <GuildType>cur.guild;
|
||||
let leader = <RoleType>guild.leader;
|
||||
delete cur.guild;
|
||||
return { applyCode: cur.applyCode, ...guild, leader: leader.roleName };
|
||||
});
|
||||
let list = await getInvitationList(roleId, lastApplyCode);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { list });
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import { nowSeconds, getZeroPoint } from '../pubUtils/timeUtil';
|
||||
import { getGachaList, getVisitedHeroList } from './activity/gachaService';
|
||||
import { getSchoolList } from './roleService';
|
||||
import { addRoleToGuildChannel } from './chatChannelService';
|
||||
import { getMyGuildInfo, getGuildWithRefActive, getUserGuildWithRefActive, getWishPool } from './guildService';
|
||||
import { getMyGuildInfo, getGuildWithRefActive, getUserGuildWithRefActive, getWishPool, getInvitationList } from './guildService';
|
||||
import { getAuction } from './auctionService';
|
||||
import { getGuildTrainInstance, getTrainBoxRewardsResult } from './guildTrainService';
|
||||
import { BossInstanceModel } from '../db/BossInstance';
|
||||
@@ -107,7 +107,8 @@ async function getModuleData(type: string, data: { role: RoleType, session: Fron
|
||||
case 'school':
|
||||
return await getSchoolList(roleId);
|
||||
case 'guild':
|
||||
return await guildResult;
|
||||
let invitation = await getInvitationList(roleId, '');
|
||||
return { ...guildResult, invitation };
|
||||
case 'auction':
|
||||
return hasGuild ? await getAuction(guildCode, session) : null;
|
||||
case 'train':
|
||||
|
||||
@@ -54,7 +54,7 @@ export function getRaceActivityObj() {
|
||||
* 定时任务,获得前一天的活跃玩家中位数武将战力
|
||||
*/
|
||||
export async function setMedianCe() {
|
||||
let servers = await ServerlistModel.getAllServerList();
|
||||
let servers = await ServerlistModel.findByEnv(pinus.app.get('env'));
|
||||
|
||||
for (let server of servers) {
|
||||
let medianRole = await RoleModel.getMedianRole(server.id);
|
||||
|
||||
@@ -38,10 +38,10 @@ export async function getBossInstanceInfoByData(bossInstance: BossInstanceType,
|
||||
let bossInfo = null;
|
||||
|
||||
if(bossInstance) {
|
||||
let { warId, ranks, bossHp, bossLv, encourageCnt } = bossInstance;
|
||||
let { warId, ranks, bossHp, bossTotalHp, bossLv, encourageCnt } = bossInstance;
|
||||
let dicBossBase = gameData.bossBaseByBossLv.get(bossLv);
|
||||
let rankInfo = getRanks(ranks, userGuild.roleId);
|
||||
bossInfo = { warId, ...rankInfo, bossHp, bossLv, encourageCnt, encourageMax: dicBossBase.encourageSum };
|
||||
bossInfo = { warId, ...rankInfo, bossHp, bossTotalHp, bossLv, encourageCnt, encourageMax: dicBossBase.encourageSum };
|
||||
}
|
||||
return { status, bossInfo, ...refObj }
|
||||
}
|
||||
|
||||
@@ -344,4 +344,15 @@ export function setUserGuildSession(session:FrontendOrBackendSession, myUserGuil
|
||||
session.push('guildCode', () => {});
|
||||
session.push('guildAuth', () => {});
|
||||
}
|
||||
}
|
||||
|
||||
export async function getInvitationList(roleId: string, lastApplyCode = '') {
|
||||
const result = await UserGuildApplyModel.findInviteByRole(roleId, lastApplyCode);
|
||||
const list = result.map(cur => {
|
||||
let guild = <GuildType>cur.guild;
|
||||
let leader = <RoleType>guild.leader;
|
||||
delete cur.guild;
|
||||
return { applyCode: cur.applyCode, ...guild, leader: leader.roleName };
|
||||
});
|
||||
return list;
|
||||
}
|
||||
Reference in New Issue
Block a user