军团:添加邀请红点和演武台功能
This commit is contained in:
@@ -22,6 +22,7 @@ import { getGoldObject } from '../../../pubUtils/itemUtils';
|
|||||||
import { RoleModel } from '../../../db/Role';
|
import { RoleModel } from '../../../db/Role';
|
||||||
import { sendMailToGuildByContent } from '../../../services/mailService';
|
import { sendMailToGuildByContent } from '../../../services/mailService';
|
||||||
import { genAuction } from '../../../services/auctionService';
|
import { genAuction } from '../../../services/auctionService';
|
||||||
|
import { getMedianCe } from '../../../services/guildActivityService';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -61,7 +62,12 @@ export class GuildHandler {
|
|||||||
return resResult(STATUS.GUILD_STRUCTURE_NOT_FOUND);
|
return resResult(STATUS.GUILD_STRUCTURE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
let bossBase = getBossByLv(curStructure.lv);
|
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);
|
let resGuild = await GuildModel.costFund(code, bossBase.opencost);
|
||||||
if (!resGuild) {
|
if (!resGuild) {
|
||||||
res.releaseCallback();
|
res.releaseCallback();
|
||||||
@@ -198,9 +204,11 @@ export class GuildHandler {
|
|||||||
|
|
||||||
let { bossDamage = 0 } = battleRecord.record; // 伤害奖励
|
let { bossDamage = 0 } = battleRecord.record; // 伤害奖励
|
||||||
let dicBossBase = gameData.bossBaseByBossLv.get(bossInstance.bossLv);
|
let dicBossBase = gameData.bossBaseByBossLv.get(bossInstance.bossLv);
|
||||||
let reward = dicBossBase.damageReward.map(({id, count}) => {
|
let { basicReward, damageRewardTotal } = dicBossBase;
|
||||||
return { id, count: Math.floor(count * bossDamage * dicBossBase.ratio / 1000 ) }
|
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);
|
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 { 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 { 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 { 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 { GuildModel, GuildType, GuildUpdateParam } from '../../../db/Guild';
|
||||||
import { RoleModel, RoleType } from '../../../db/Role';
|
import { RoleModel, RoleType } from '../../../db/Role';
|
||||||
import { ARMY } from '../../../pubUtils/dicParam';
|
import { ARMY } from '../../../pubUtils/dicParam';
|
||||||
@@ -424,14 +424,18 @@ export class GuildHandler {
|
|||||||
|
|
||||||
const roleList = await RoleModel.findByRoleIds(roleIds);
|
const roleList = await RoleModel.findByRoleIds(roleIds);
|
||||||
let result = new Array<string>();
|
let result = new Array<string>();
|
||||||
let uids = [];
|
|
||||||
for (let role of roleList) {
|
for (let role of roleList) {
|
||||||
if (!role.hasGuild || role.serverId == serverId) {
|
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);
|
result.push(role.roleId);
|
||||||
let hisInfo = await getRoleOnlineInfo(role.roleId);
|
let hisInfo = await getRoleOnlineInfo(role.roleId);
|
||||||
if (hisInfo.isOnline) {
|
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()));
|
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 });
|
return resResult(STATUS.SUCCESS, { roleIds: result });
|
||||||
|
|
||||||
@@ -451,14 +454,7 @@ export class GuildHandler {
|
|||||||
|
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const { lastApplyCode } = msg;
|
const { lastApplyCode } = msg;
|
||||||
|
let list = await getInvitationList(roleId, 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 resResult(STATUS.SUCCESS, { list });
|
return resResult(STATUS.SUCCESS, { list });
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import { nowSeconds, getZeroPoint } from '../pubUtils/timeUtil';
|
|||||||
import { getGachaList, getVisitedHeroList } from './activity/gachaService';
|
import { getGachaList, getVisitedHeroList } from './activity/gachaService';
|
||||||
import { getSchoolList } from './roleService';
|
import { getSchoolList } from './roleService';
|
||||||
import { addRoleToGuildChannel } from './chatChannelService';
|
import { addRoleToGuildChannel } from './chatChannelService';
|
||||||
import { getMyGuildInfo, getGuildWithRefActive, getUserGuildWithRefActive, getWishPool } from './guildService';
|
import { getMyGuildInfo, getGuildWithRefActive, getUserGuildWithRefActive, getWishPool, getInvitationList } from './guildService';
|
||||||
import { getAuction } from './auctionService';
|
import { getAuction } from './auctionService';
|
||||||
import { getGuildTrainInstance, getTrainBoxRewardsResult } from './guildTrainService';
|
import { getGuildTrainInstance, getTrainBoxRewardsResult } from './guildTrainService';
|
||||||
import { BossInstanceModel } from '../db/BossInstance';
|
import { BossInstanceModel } from '../db/BossInstance';
|
||||||
@@ -107,7 +107,8 @@ async function getModuleData(type: string, data: { role: RoleType, session: Fron
|
|||||||
case 'school':
|
case 'school':
|
||||||
return await getSchoolList(roleId);
|
return await getSchoolList(roleId);
|
||||||
case 'guild':
|
case 'guild':
|
||||||
return await guildResult;
|
let invitation = await getInvitationList(roleId, '');
|
||||||
|
return { ...guildResult, invitation };
|
||||||
case 'auction':
|
case 'auction':
|
||||||
return hasGuild ? await getAuction(guildCode, session) : null;
|
return hasGuild ? await getAuction(guildCode, session) : null;
|
||||||
case 'train':
|
case 'train':
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export function getRaceActivityObj() {
|
|||||||
* 定时任务,获得前一天的活跃玩家中位数武将战力
|
* 定时任务,获得前一天的活跃玩家中位数武将战力
|
||||||
*/
|
*/
|
||||||
export async function setMedianCe() {
|
export async function setMedianCe() {
|
||||||
let servers = await ServerlistModel.getAllServerList();
|
let servers = await ServerlistModel.findByEnv(pinus.app.get('env'));
|
||||||
|
|
||||||
for (let server of servers) {
|
for (let server of servers) {
|
||||||
let medianRole = await RoleModel.getMedianRole(server.id);
|
let medianRole = await RoleModel.getMedianRole(server.id);
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ export async function getBossInstanceInfoByData(bossInstance: BossInstanceType,
|
|||||||
let bossInfo = null;
|
let bossInfo = null;
|
||||||
|
|
||||||
if(bossInstance) {
|
if(bossInstance) {
|
||||||
let { warId, ranks, bossHp, bossLv, encourageCnt } = bossInstance;
|
let { warId, ranks, bossHp, bossTotalHp, bossLv, encourageCnt } = bossInstance;
|
||||||
let dicBossBase = gameData.bossBaseByBossLv.get(bossLv);
|
let dicBossBase = gameData.bossBaseByBossLv.get(bossLv);
|
||||||
let rankInfo = getRanks(ranks, userGuild.roleId);
|
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 }
|
return { status, bossInfo, ...refObj }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -344,4 +344,15 @@ export function setUserGuildSession(session:FrontendOrBackendSession, myUserGuil
|
|||||||
session.push('guildCode', () => {});
|
session.push('guildCode', () => {});
|
||||||
session.push('guildAuth', () => {});
|
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;
|
||||||
}
|
}
|
||||||
@@ -29,6 +29,9 @@ export default class BossInstance extends BaseModel {
|
|||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
bossHp: number;
|
bossHp: number;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
bossTotalHp: number;
|
||||||
|
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
bossLv: number;
|
bossLv: number;
|
||||||
|
|
||||||
@@ -66,7 +69,7 @@ export default class BossInstance extends BaseModel {
|
|||||||
public static async openBossInstance(guildCode: string, bossHp: number, warId: number, bossLv: number) {
|
public static async openBossInstance(guildCode: string, bossHp: number, warId: number, bossLv: number) {
|
||||||
let code = genCode(10);
|
let code = genCode(10);
|
||||||
let doc = new BossInstanceModel();
|
let doc = new BossInstanceModel();
|
||||||
let update = Object.assign(doc.toJSON(), { guildCode, bossHp, bossLv, warId });
|
let update = Object.assign(doc.toJSON(), { guildCode, bossHp, bossTotalHp: bossHp, bossLv, warId });
|
||||||
const bossInstance: BossInstanceType = await BossInstanceModel.findOneAndUpdate({ code },{ $set: update }, {new: true, upsert: true}).lean();
|
const bossInstance: BossInstanceType = await BossInstanceModel.findOneAndUpdate({ code },{ $set: update }, {new: true, upsert: true}).lean();
|
||||||
return bossInstance;
|
return bossInstance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,22 @@ export default class UserGuildApply extends BaseModel {
|
|||||||
// 创建申请或邀请
|
// 创建申请或邀请
|
||||||
public static async createUserGuildApply(role: RoleType, guild: GuildType, type: number) {
|
public static async createUserGuildApply(role: RoleType, guild: GuildType, type: number) {
|
||||||
const applyCode = genCode(10);
|
const applyCode = genCode(10);
|
||||||
const result: UserGuildApplyType = await UserGuildApplyModel.findOneAndUpdate({ roleId: role.roleId, guildCode: guild.code, type }, { $set: { roleId: role.roleId, role: role._id, guildCode: guild.code, guild: guild._id }, $setOnInsert: { applyCode }}, { upsert: true, new: true }).lean();
|
const result: UserGuildApplyType = await UserGuildApplyModel.findOneAndUpdate(
|
||||||
|
{ roleId: role.roleId, guildCode: guild.code, type },
|
||||||
|
{ $set: { roleId: role.roleId, role: role._id, guildCode: guild.code, guild: guild._id }, $setOnInsert: { applyCode }
|
||||||
|
}, { upsert: true, new: true })
|
||||||
|
.select('applyCode guild')
|
||||||
|
.populate({
|
||||||
|
path: 'guild',
|
||||||
|
select: 'code icon name lv memberCnt leader ceLimit',
|
||||||
|
model: 'Guild',
|
||||||
|
populate: {
|
||||||
|
path: 'leader',
|
||||||
|
select: 'roleName',
|
||||||
|
model: 'Role'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.lean();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,9 +61,11 @@ export interface DicBossBase {
|
|||||||
readonly opencost: number;
|
readonly opencost: number;
|
||||||
// 击杀奖励
|
// 击杀奖励
|
||||||
readonly killReward: RewardInter[];
|
readonly killReward: RewardInter[];
|
||||||
// 伤害加成奖励
|
// 伤害加成奖励 参与奖励
|
||||||
readonly damageReward: RewardInter[];
|
readonly basicReward: RewardInter[];
|
||||||
// 伤害加成系数
|
// 伤害加成奖励 伤害贡献奖励
|
||||||
|
readonly damageRewardTotal: RewardInter[];
|
||||||
|
// boss血量系数,boss血量为中位数 * ratio
|
||||||
readonly ratio: number;
|
readonly ratio: number;
|
||||||
// 鼓舞次数
|
// 鼓舞次数
|
||||||
readonly encourageSum: number;
|
readonly encourageSum: number;
|
||||||
@@ -78,7 +80,8 @@ const DicBossKeys: KeysEnum<DicBossBase> = {
|
|||||||
consume: true,
|
consume: true,
|
||||||
opencost: true,
|
opencost: true,
|
||||||
killReward: true,
|
killReward: true,
|
||||||
damageReward: true,
|
basicReward: true,
|
||||||
|
damageRewardTotal: true,
|
||||||
ratio: true,
|
ratio: true,
|
||||||
encourageSum: true
|
encourageSum: true
|
||||||
};
|
};
|
||||||
@@ -214,7 +217,8 @@ export function loadStructure() {
|
|||||||
return { warId: parseInt(warArr[0]), bossHp: parseInt(warArr[1])}
|
return { warId: parseInt(warArr[0]), bossHp: parseInt(warArr[1])}
|
||||||
});
|
});
|
||||||
o.killReward = parseGoodStr(o.killReward);
|
o.killReward = parseGoodStr(o.killReward);
|
||||||
o.damageReward = parseGoodStr(o.damageReward);
|
o.basicReward = parseGoodStr(o.basicReward);
|
||||||
|
o.damageRewardTotal = parseGoodStr(o.damageRewardTotal);
|
||||||
dicBossBase.set(o.level, _.pick(o, Object.keys(DicBossKeys)));
|
dicBossBase.set(o.level, _.pick(o, Object.keys(DicBossKeys)));
|
||||||
dicBossBaseByBossLv.set(o.bossLevel, _.pick(o, Object.keys(DicBossKeys)));
|
dicBossBaseByBossLv.set(o.bossLevel, _.pick(o, Object.keys(DicBossKeys)));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -252,7 +252,7 @@
|
|||||||
{
|
{
|
||||||
"id": 26,
|
"id": 26,
|
||||||
"name": "玉石",
|
"name": "玉石",
|
||||||
"rewardBasicPool": "17052&10",
|
"rewardBasicPool": "17052&10&1",
|
||||||
"totalCount": 1,
|
"totalCount": 1,
|
||||||
"itid": 38,
|
"itid": 38,
|
||||||
"basePrice": "31002&120",
|
"basePrice": "31002&120",
|
||||||
@@ -262,7 +262,7 @@
|
|||||||
{
|
{
|
||||||
"id": 27,
|
"id": 27,
|
||||||
"name": "玉髓",
|
"name": "玉髓",
|
||||||
"rewardBasicPool": "17053&1",
|
"rewardBasicPool": "17053&1&1",
|
||||||
"totalCount": 1,
|
"totalCount": 1,
|
||||||
"itid": 38,
|
"itid": 38,
|
||||||
"basePrice": "31002&40",
|
"basePrice": "31002&40",
|
||||||
@@ -272,7 +272,7 @@
|
|||||||
{
|
{
|
||||||
"id": 28,
|
"id": 28,
|
||||||
"name": "蜀锦",
|
"name": "蜀锦",
|
||||||
"rewardBasicPool": "40006&1",
|
"rewardBasicPool": "40006&1&1",
|
||||||
"totalCount": 1,
|
"totalCount": 1,
|
||||||
"itid": 38,
|
"itid": 38,
|
||||||
"basePrice": "31002&840",
|
"basePrice": "31002&840",
|
||||||
@@ -282,7 +282,7 @@
|
|||||||
{
|
{
|
||||||
"id": 29,
|
"id": 29,
|
||||||
"name": "高级经验书",
|
"name": "高级经验书",
|
||||||
"rewardBasicPool": "11003&1",
|
"rewardBasicPool": "11003&1&1",
|
||||||
"totalCount": 1,
|
"totalCount": 1,
|
||||||
"itid": 38,
|
"itid": 38,
|
||||||
"basePrice": "31002&300",
|
"basePrice": "31002&300",
|
||||||
|
|||||||
Reference in New Issue
Block a user