军团:如果强退没有拿,第二天刷新的时候发送到邮箱
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Application, BackendSession, pinus, HandlerService, } from 'pinus';
|
||||
import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
|
||||
import { AUCTION_SOURCE, DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON, MAIL_TYPE, PUSH_ROUTE, STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { AUCTION_SOURCE, DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON, MAIL_TYPE, PUSH_ROUTE, STATUS, TASK_TYPE, WAR_TYPE } from '../../../consts';
|
||||
import { BossInstanceModel } from '../../../db/BossInstance';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { nowSeconds, getZeroPoint, getSeconds } from '../../../pubUtils/timeUtil';
|
||||
@@ -111,7 +111,7 @@ export class GuildHandler {
|
||||
const battleCode = genCode(8); // 关卡唯一值
|
||||
await BattleRecordModel.updateBattleRecordByCode(battleCode, {
|
||||
$set: {
|
||||
roleId, roleName, battleId: warId,
|
||||
roleId, roleName, battleId: warId, warType: WAR_TYPE.BOSS,
|
||||
status: 0,
|
||||
record: { heroes: [], bossInstanceCode: bossCode, bossHp: zoomOutDamage(bossHp), encourageCnt },
|
||||
}
|
||||
@@ -126,6 +126,7 @@ export class GuildHandler {
|
||||
let { myChallengeCnt: newMyChallengeCnt } = await refreshUserGuildOfBoss(userGuild, 0, 1);
|
||||
// 任务
|
||||
await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_BOSS);
|
||||
await addActive(roleId, serverId, GUILD_POINT_WAYS.BOSS_WAR);//获得活跃值
|
||||
|
||||
return resResult(STATUS.SUCCESS, { battleCode, bossCode: bossInstance.code, myChallengeCnt: newMyChallengeCnt });
|
||||
}
|
||||
@@ -229,8 +230,6 @@ export class GuildHandler {
|
||||
let reward = [...basicReward, ...damageReward];
|
||||
|
||||
let battleGoods = await addItems(roleId, roleName, sid, reward, ITEM_CHANGE_REASON.BOSS_BATTLE_END);
|
||||
|
||||
await addActive(roleId, serverId, GUILD_POINT_WAYS.BOSS_WAR);//获得活跃值
|
||||
|
||||
let result = await getBossInstanceInfoByData(bossInstance, userGuild);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { gameData, getGuildActiveWeekReward, getGuildActiveByIdAndType, getGoodById } from "../pubUtils/data";
|
||||
import { GuildModel, GuildType, GuildUpdateParam } from "../db/Guild";
|
||||
import { resResult, shouldRefresh } from "../pubUtils/util";
|
||||
import { STATUS, MAIL_TYPE, GUILD_AUTH, GUILD_JOB, REDIS_KEY, CHAT_SERVER, TASK_TYPE, COUNTER, GUILD_REC_TYPE, PUSH_ROUTE } from "../consts";
|
||||
import { STATUS, MAIL_TYPE, GUILD_AUTH, GUILD_JOB, REDIS_KEY, CHAT_SERVER, TASK_TYPE, COUNTER, GUILD_REC_TYPE, PUSH_ROUTE, WAR_TYPE } from "../consts";
|
||||
import { RoleModel, RoleType } from "../db/Role";
|
||||
import { UserGuildModel, UserGuildType, WishGood } from "../db/UserGuild";
|
||||
import { UserGuildApplyModel } from "../db/UserGuildApply";
|
||||
@@ -26,6 +26,8 @@ import { delGuildChannel, leaveGuildChannel } from "./chatChannelService";
|
||||
import { GuildActiveModel, } from "../db/GuildActive";
|
||||
import { RewardInter } from "../pubUtils/interface";
|
||||
import { getGuildFundByRefTime } from "./donateService";
|
||||
import { BattleRecordModel } from "../db/BattleRecord";
|
||||
import { BossInstanceModel } from "../db/BossInstance";
|
||||
|
||||
export async function getMyGuildInfo(roleId: string, sid: string, userGuild: UserGuildType, guild: GuildType, serverId: number, session: FrontendOrBackendSession) {
|
||||
|
||||
@@ -225,6 +227,7 @@ export async function refreshUserGuild(userGuild: UserGuildType, roleId: string)
|
||||
await sendUnreceivedWishPool(wishGoods, roleId);
|
||||
await sendUnreceivedActiveBox(roleId, userGuild.guildCode, refTimeDaily, receivedActive);
|
||||
await sendUnreceivedDonateBox(roleId, userGuild.guildCode, refTimeDaily, receiveBoxs);
|
||||
await sendUnreceivedBossWar(roleId, refTimeDaily);
|
||||
receivedActive = []; refTimeDaily = now; activeDaily = 0; activeRecord = []; wishGoods = []; receivedWishPool = [], receiveBoxs = [];
|
||||
let wishDntCnt = 0, donateCnt = 0;
|
||||
userGuild = await UserGuildModel.updateInfo(roleId, { receivedActive, refTimeDaily, activeDaily, activeRecord, wishGoods, receiveBoxs, wishDntCnt, donateCnt, receivedWishPool }, {});
|
||||
@@ -275,6 +278,32 @@ async function sendUnreceivedDonateBox(roleId: string, guildCode: string, refTim
|
||||
}
|
||||
}
|
||||
|
||||
async function sendUnreceivedBossWar(roleId: string, refTimeDaily: Date) {
|
||||
let beginTime = getZeroPointOfTime(refTimeDaily);
|
||||
let endTime = beginTime + 24 * 60 * 60;
|
||||
let battleRecords = await BattleRecordModel.findByWarTypeAndStatus(roleId, WAR_TYPE.BOSS, 0, new Date(beginTime * 1000), new Date(endTime * 1000));
|
||||
for(let { battleCode, record = {} } of battleRecords) {
|
||||
let { bossDamage = 0, bossInstanceCode } = record;
|
||||
if(bossDamage > 0) {
|
||||
let bossInstance = await BossInstanceModel.findByCode(bossInstanceCode);
|
||||
if(!bossInstance) continue;
|
||||
|
||||
let dicBossBase = gameData.bossBaseByBossLv.get(bossInstance.bossLv);
|
||||
let { basicReward, damageRewardTotal } = dicBossBase;
|
||||
let damageReward = damageRewardTotal.map(cur => {
|
||||
return { id: cur.id, count: Math.ceil(cur.count * bossDamage / bossInstance.bossTotalHp )}
|
||||
})
|
||||
let goods = [...basicReward, ...damageReward];
|
||||
|
||||
if(goods.length > 0) {
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BOSS, roleId, { goods });
|
||||
}
|
||||
await BattleRecordModel.updateBattleRecordByCode(battleCode, { $set: { status: 1 } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 每周结算上周公会周功勋和 活跃并发奖励(未完)
|
||||
*
|
||||
|
||||
@@ -52,6 +52,7 @@ export enum MAIL_TYPE {
|
||||
TIME_LIMIT_RANK = 23, // 限时排行榜
|
||||
GUILD_DAILY_BOX = 24, // 军团每日活跃宝箱补领
|
||||
GUILD_FUND_BOX = 25, // 军团每日捐献宝箱补领
|
||||
GUILD_BOSS = 26, // 军团boss奖励
|
||||
};
|
||||
|
||||
export const SEND_NAME = '系统';
|
||||
|
||||
@@ -103,6 +103,11 @@ export default class BattleRecord extends BaseModel {
|
||||
let result: BattleRecordType = await BattleRecordModel.findOneAndUpdate({ battleCode }, { $inc: { regretCnt: count } }, { new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findByWarTypeAndStatus(roleId: string, warType: number, status: number, beginTime: Date, endTime: Date) {
|
||||
let result: BattleRecordType[] = await BattleRecordModel.find({ roleId, warType, status, createdAt: { $gte: beginTime, $lt: endTime } }).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const BattleRecordModel = getModelForClass(BattleRecord);
|
||||
|
||||
@@ -180,5 +180,12 @@
|
||||
"sendName": "&",
|
||||
"content": "您昨日的军团捐献所宝箱奖励没有领取,现已发送至您的邮箱,请查收",
|
||||
"time": 720
|
||||
},
|
||||
{
|
||||
"id": 26,
|
||||
"title": "&",
|
||||
"sendName": "&",
|
||||
"content": "感谢您昨日为军团演武台所做的贡献,且有奖励尚未领取,现已发送至您的邮箱,请查收",
|
||||
"time": 720
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user