✨ feat(每周结算): 新增对演武台boss的伤害排名获得活跃值
This commit is contained in:
@@ -22,7 +22,7 @@ import { changeGuildActivity } from "./activity/guildPayService";
|
||||
import { GuildRecModel } from "../db/GuildRec";
|
||||
import { sendMessageToGuildWithSuc, sendMessageToUserWithSuc } from "./pushService";
|
||||
import { delGuildChannel, leaveGuildChannel } from "./chatChannelService";
|
||||
import { GuildActiveModel, } from "../db/GuildActive";
|
||||
import { GuildActiveModel, } from "../db/GuildActive";
|
||||
import { RewardInter } from "../pubUtils/interface";
|
||||
import { getGuildFundByRefTime } from "./donateService";
|
||||
import { BattleRecordModel } from "../db/BattleRecord";
|
||||
@@ -63,8 +63,8 @@ export async function getMyGuildInfo(roleId: string, sid: string, userGuild: Use
|
||||
* @param func 操作id
|
||||
* @param auth 权限
|
||||
*/
|
||||
export async function checkAuth(func: number, targetCode: string, guildAuth: number, myGuildCode = targetCode ) {
|
||||
if(targetCode != myGuildCode || !guildAuth) {
|
||||
export async function checkAuth(func: number, targetCode: string, guildAuth: number, myGuildCode = targetCode) {
|
||||
if (targetCode != myGuildCode || !guildAuth) {
|
||||
guildAuth = GUILD_AUTH.OTHERS;
|
||||
}
|
||||
const dicGuildAuth = gameData.guildAuth.get(func);
|
||||
@@ -134,7 +134,7 @@ export async function joinGuild(code: string, guildName: string, lv: number, rol
|
||||
const { sid } = await getRoleOnlineInfo(roleId);
|
||||
if (sid) {
|
||||
await addRoleToGuildChannel(roleId, sid, code);
|
||||
await pinus.app.rpc.connector.connectorRemote.setOtherUserGuildSession.toServer(sid,[{ roleId, userGuild }]);
|
||||
await pinus.app.rpc.connector.connectorRemote.setOtherUserGuildSession.toServer(sid, [{ roleId, userGuild }]);
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.MEMBER_JOIN_GUILD, { hasGuild: true, code }, sid);
|
||||
session.set('guildCode', code);
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.AUCTION_UPDATE, {}, sid);
|
||||
@@ -157,7 +157,29 @@ export async function getTodayGuildActive(guildCode: string) {
|
||||
|
||||
export async function getGuildActiveByRefTime(guildCode: string, refTime: Date) {
|
||||
let guildActive = await GuildActiveModel.getActive(guildCode, refTime);
|
||||
return guildActive? guildActive.active: 0;
|
||||
return guildActive ? guildActive.active : 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取伤害排名
|
||||
* @param code
|
||||
* @param roleId
|
||||
* @returns
|
||||
*/
|
||||
export async function getBossWarExtendActive(code: string, roleId: string) {
|
||||
const bossInstance = await BossInstanceModel.findByCode(code);
|
||||
if (!bossInstance || !bossInstance.ranks || bossInstance.ranks.length == 0) return 0;
|
||||
let ranks = bossInstance.ranks;
|
||||
ranks.sort((obj1, obj2) => obj2.score - obj1.score);
|
||||
const index = ranks.findIndex((obj) => obj.roleId == roleId) + 1;
|
||||
|
||||
const dicBossRankActivePoint = gameData.bossRankActivePoint;
|
||||
const foundEntry = dicBossRankActivePoint.find(
|
||||
(entry) => index >= entry.bossRankMin && index <= entry.bossRankMax
|
||||
);
|
||||
|
||||
return foundEntry ? foundEntry.activePoint : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,7 +199,7 @@ export async function addActive(roleId: string, serverId: number, id: number, ty
|
||||
if (!active) {
|
||||
active = getGuildActiveByIdAndType(id, type);
|
||||
}
|
||||
|
||||
|
||||
let userGuild = await getUserGuildWithRefActive(roleId, 'activeRecord receivedActive activeDaily activeWeekly guildCode');
|
||||
if (!userGuild) return { status: 0, resResult: resResult(STATUS.GUILD_NOT_FOUND) };
|
||||
|
||||
@@ -228,15 +250,15 @@ export async function getUserGuildWithRefActive(roleId: string, select?: string)
|
||||
userGuild = await UserGuildModel.resetDailyInfoByRefTimeDaily(roleId, refTimeDaily);
|
||||
if (refTimeDaily && userGuild) {
|
||||
await sendUnreceivedWishPool(wishGoods, roleId);
|
||||
await sendUnreceivedActiveBox(roleId, guildCode, refTimeDaily, receivedActive||[]);
|
||||
await sendUnreceivedDonateBox(roleId, guildCode, refTimeDaily, receiveBoxs||[]);
|
||||
await sendUnreceivedActiveBox(roleId, guildCode, refTimeDaily, receivedActive || []);
|
||||
await sendUnreceivedDonateBox(roleId, guildCode, refTimeDaily, receiveBoxs || []);
|
||||
await sendUnreceivedBossWar(roleId, refTimeDaily);
|
||||
}
|
||||
if (!userGuild) {
|
||||
userGuild = await UserGuildModel.getMyGuild(roleId, select ? select + ' wishGoods +refTimeDaily' : '+refTimeDaily');
|
||||
if (!userGuild) return false;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
return userGuild;
|
||||
@@ -297,24 +319,24 @@ async function sendUnreceivedActiveBox(roleId: string, guildCode: string, refTim
|
||||
let refTime = getZeroPointOfTimeD(refTimeDaily);
|
||||
let guildActive = await getGuildActiveByRefTime(guildCode, refTime);
|
||||
let goods: RewardInter[] = [];
|
||||
for(let [id, { activeDayPoint, reward }] of gameData.guildActiveDayReward) {
|
||||
if(guildActive >= activeDayPoint && receiveActiveBox.indexOf(id) == -1) goods.push(...reward);
|
||||
for (let [id, { activeDayPoint, reward }] of gameData.guildActiveDayReward) {
|
||||
if (guildActive >= activeDayPoint && receiveActiveBox.indexOf(id) == -1) goods.push(...reward);
|
||||
}
|
||||
if(goods.length > 0) {
|
||||
if (goods.length > 0) {
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_DAILY_BOX, roleId, { goods });
|
||||
}
|
||||
}
|
||||
|
||||
async function sendUnreceivedDonateBox(roleId: string, guildCode: string, refTimeDaily: Date, receiveBoxs: number[]) {
|
||||
let refTime = getZeroPointOfTime(refTimeDaily);
|
||||
let { fund: guildFund, donationLv } = await getGuildFundByRefTime(guildCode, refTime);
|
||||
let { fund: guildFund, donationLv } = await getGuildFundByRefTime(guildCode, refTime);
|
||||
let goods: RewardInter[] = [];
|
||||
for(let [id, { boxRewards, fund, level }] of gameData.armyDonateBox) {
|
||||
if(level == donationLv && guildFund >= fund && receiveBoxs.indexOf(id) == -1) {
|
||||
if(boxRewards) goods.push(...boxRewards);
|
||||
for (let [id, { boxRewards, fund, level }] of gameData.armyDonateBox) {
|
||||
if (level == donationLv && guildFund >= fund && receiveBoxs.indexOf(id) == -1) {
|
||||
if (boxRewards) goods.push(...boxRewards);
|
||||
}
|
||||
}
|
||||
if(goods.length > 0) {
|
||||
if (goods.length > 0) {
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_FUND_BOX, roleId, { goods });
|
||||
}
|
||||
}
|
||||
@@ -323,20 +345,20 @@ 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) {
|
||||
for (let { battleCode, record = {} } of battleRecords) {
|
||||
let { bossDamage = 0, bossInstanceCode } = record;
|
||||
if(bossDamage > 0) {
|
||||
if (bossDamage > 0) {
|
||||
let bossInstance = await BossInstanceModel.findByCode(bossInstanceCode);
|
||||
if(!bossInstance) continue;
|
||||
|
||||
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 )}
|
||||
return { id: cur.id, count: Math.ceil(cur.count * bossDamage / bossInstance.bossTotalHp) }
|
||||
})
|
||||
let goods = [...basicReward, ...damageReward];
|
||||
|
||||
if(goods.length > 0) {
|
||||
if (goods.length > 0) {
|
||||
await sendMailByContent(MAIL_TYPE.GUILD_BOSS, roleId, { goods });
|
||||
}
|
||||
await BattleRecordModel.updateBattleRecordByCode(battleCode, { $set: { status: 1 } });
|
||||
@@ -433,17 +455,17 @@ export async function getWishPool(userGuild: UserGuildType) {
|
||||
return { list, wishDntCnt: wishDntCnt || 0, wishGoods, receivedWishPool };
|
||||
}
|
||||
|
||||
export function setUserGuildSession(session:FrontendOrBackendSession, myUserGuild: UserGuildType) {
|
||||
if(myUserGuild) {
|
||||
export function setUserGuildSession(session: FrontendOrBackendSession, myUserGuild: UserGuildType) {
|
||||
if (myUserGuild) {
|
||||
session.set('guildCode', myUserGuild.guildCode);
|
||||
session.set('guildAuth', myUserGuild.auth);
|
||||
session.push('guildCode', () => {});
|
||||
session.push('guildAuth', () => {});
|
||||
session.push('guildCode', () => { });
|
||||
session.push('guildAuth', () => { });
|
||||
} else {
|
||||
session.set('guildCode', null);
|
||||
session.set('guildAuth', null);
|
||||
session.push('guildCode', () => {});
|
||||
session.push('guildAuth', () => {});
|
||||
session.push('guildCode', () => { });
|
||||
session.push('guildAuth', () => { });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,8 +531,8 @@ export async function getGuildQuitCdTime(serverId: number) {
|
||||
let serverTime = await getServerCreateTime(serverId);
|
||||
let todayIndex = deltaDays(moment(serverTime * 1000).toDate(), new Date) + 1;
|
||||
let result = 0;
|
||||
for(let { day, minute } of gameData.guildQuitCd) {
|
||||
if(todayIndex > day) result = minute;
|
||||
for (let { day, minute } of gameData.guildQuitCd) {
|
||||
if (todayIndex > day) result = minute;
|
||||
}
|
||||
console.log('####', serverId, serverTime, todayIndex, result)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user