feat(每周结算): 新增对演武台boss的伤害排名获得活跃值

This commit is contained in:
zhangxk
2023-07-21 11:23:39 +08:00
committed by luying
parent 0060343504
commit 667a429dc9
6 changed files with 105 additions and 43 deletions

View File

@@ -9,7 +9,7 @@ import { findWhere } from 'underscore'
import { GUILD_STRUCTURE, GUILD_BOSS_STATUS, GUILD_POINT_WAYS } from '../../../consts/constModules/guildConst'; import { GUILD_STRUCTURE, GUILD_BOSS_STATUS, GUILD_POINT_WAYS } from '../../../consts/constModules/guildConst';
import { DATA_NAME } from '../../../consts/dataName'; import { DATA_NAME } from '../../../consts/dataName';
import { UserGuildModel } from '../../../db/UserGuild'; import { UserGuildModel } from '../../../db/UserGuild';
import { addActive } from '../../../services/guildService'; import { addActive, getBossWarExtendActive } from '../../../services/guildService';
import { GuildModel } from '../../../db/Guild'; import { GuildModel } from '../../../db/Guild';
import { gameData, getBossByLv } from '../../../pubUtils/data'; import { gameData, getBossByLv } from '../../../pubUtils/data';
import { lockData } from '../../../services/redLockService'; import { lockData } from '../../../services/redLockService';
@@ -197,6 +197,8 @@ export class GuildHandler {
await pushBossStatus(guildCode, result); await pushBossStatus(guildCode, result);
pushGuildBossSucMsg(roleId, roleName, guildCode, bossInstance); pushGuildBossSucMsg(roleId, roleName, guildCode, bossInstance);
await addActive(roleId, serverId, GUILD_POINT_WAYS.BOSS_WAR_EXTEND, null, await getBossWarExtendActive(bossCode, roleId));//获得活跃值
res.releaseCallback();//解锁 res.releaseCallback();//解锁
return resResult(STATUS.SUCCESS, { bossHp: 0 }); return resResult(STATUS.SUCCESS, { bossHp: 0 });
} else { } else {

View File

@@ -22,7 +22,7 @@ import { changeGuildActivity } from "./activity/guildPayService";
import { GuildRecModel } from "../db/GuildRec"; import { GuildRecModel } from "../db/GuildRec";
import { sendMessageToGuildWithSuc, sendMessageToUserWithSuc } from "./pushService"; import { sendMessageToGuildWithSuc, sendMessageToUserWithSuc } from "./pushService";
import { delGuildChannel, leaveGuildChannel } from "./chatChannelService"; import { delGuildChannel, leaveGuildChannel } from "./chatChannelService";
import { GuildActiveModel, } from "../db/GuildActive"; import { GuildActiveModel, } from "../db/GuildActive";
import { RewardInter } from "../pubUtils/interface"; import { RewardInter } from "../pubUtils/interface";
import { getGuildFundByRefTime } from "./donateService"; import { getGuildFundByRefTime } from "./donateService";
import { BattleRecordModel } from "../db/BattleRecord"; import { BattleRecordModel } from "../db/BattleRecord";
@@ -63,8 +63,8 @@ export async function getMyGuildInfo(roleId: string, sid: string, userGuild: Use
* @param func 操作id * @param func 操作id
* @param auth 权限 * @param auth 权限
*/ */
export async function checkAuth(func: number, targetCode: string, guildAuth: number, myGuildCode = targetCode ) { export async function checkAuth(func: number, targetCode: string, guildAuth: number, myGuildCode = targetCode) {
if(targetCode != myGuildCode || !guildAuth) { if (targetCode != myGuildCode || !guildAuth) {
guildAuth = GUILD_AUTH.OTHERS; guildAuth = GUILD_AUTH.OTHERS;
} }
const dicGuildAuth = gameData.guildAuth.get(func); 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); const { sid } = await getRoleOnlineInfo(roleId);
if (sid) { if (sid) {
await addRoleToGuildChannel(roleId, sid, code); 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); sendMessageToUserWithSuc(roleId, PUSH_ROUTE.MEMBER_JOIN_GUILD, { hasGuild: true, code }, sid);
session.set('guildCode', code); session.set('guildCode', code);
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.AUCTION_UPDATE, {}, sid); 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) { export async function getGuildActiveByRefTime(guildCode: string, refTime: Date) {
let guildActive = await GuildActiveModel.getActive(guildCode, refTime); 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) { if (!active) {
active = getGuildActiveByIdAndType(id, type); active = getGuildActiveByIdAndType(id, type);
} }
let userGuild = await getUserGuildWithRefActive(roleId, 'activeRecord receivedActive activeDaily activeWeekly guildCode'); let userGuild = await getUserGuildWithRefActive(roleId, 'activeRecord receivedActive activeDaily activeWeekly guildCode');
if (!userGuild) return { status: 0, resResult: resResult(STATUS.GUILD_NOT_FOUND) }; 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); userGuild = await UserGuildModel.resetDailyInfoByRefTimeDaily(roleId, refTimeDaily);
if (refTimeDaily && userGuild) { if (refTimeDaily && userGuild) {
await sendUnreceivedWishPool(wishGoods, roleId); await sendUnreceivedWishPool(wishGoods, roleId);
await sendUnreceivedActiveBox(roleId, guildCode, refTimeDaily, receivedActive||[]); await sendUnreceivedActiveBox(roleId, guildCode, refTimeDaily, receivedActive || []);
await sendUnreceivedDonateBox(roleId, guildCode, refTimeDaily, receiveBoxs||[]); await sendUnreceivedDonateBox(roleId, guildCode, refTimeDaily, receiveBoxs || []);
await sendUnreceivedBossWar(roleId, refTimeDaily); await sendUnreceivedBossWar(roleId, refTimeDaily);
} }
if (!userGuild) { if (!userGuild) {
userGuild = await UserGuildModel.getMyGuild(roleId, select ? select + ' wishGoods +refTimeDaily' : '+refTimeDaily'); userGuild = await UserGuildModel.getMyGuild(roleId, select ? select + ' wishGoods +refTimeDaily' : '+refTimeDaily');
if (!userGuild) return false; if (!userGuild) return false;
}; };
} }
return userGuild; return userGuild;
@@ -297,24 +319,24 @@ async function sendUnreceivedActiveBox(roleId: string, guildCode: string, refTim
let refTime = getZeroPointOfTimeD(refTimeDaily); let refTime = getZeroPointOfTimeD(refTimeDaily);
let guildActive = await getGuildActiveByRefTime(guildCode, refTime); let guildActive = await getGuildActiveByRefTime(guildCode, refTime);
let goods: RewardInter[] = []; let goods: RewardInter[] = [];
for(let [id, { activeDayPoint, reward }] of gameData.guildActiveDayReward) { for (let [id, { activeDayPoint, reward }] of gameData.guildActiveDayReward) {
if(guildActive >= activeDayPoint && receiveActiveBox.indexOf(id) == -1) goods.push(...reward); 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 }); await sendMailByContent(MAIL_TYPE.GUILD_DAILY_BOX, roleId, { goods });
} }
} }
async function sendUnreceivedDonateBox(roleId: string, guildCode: string, refTimeDaily: Date, receiveBoxs: number[]) { async function sendUnreceivedDonateBox(roleId: string, guildCode: string, refTimeDaily: Date, receiveBoxs: number[]) {
let refTime = getZeroPointOfTime(refTimeDaily); let refTime = getZeroPointOfTime(refTimeDaily);
let { fund: guildFund, donationLv } = await getGuildFundByRefTime(guildCode, refTime); let { fund: guildFund, donationLv } = await getGuildFundByRefTime(guildCode, refTime);
let goods: RewardInter[] = []; let goods: RewardInter[] = [];
for(let [id, { boxRewards, fund, level }] of gameData.armyDonateBox) { for (let [id, { boxRewards, fund, level }] of gameData.armyDonateBox) {
if(level == donationLv && guildFund >= fund && receiveBoxs.indexOf(id) == -1) { if (level == donationLv && guildFund >= fund && receiveBoxs.indexOf(id) == -1) {
if(boxRewards) goods.push(...boxRewards); if (boxRewards) goods.push(...boxRewards);
} }
} }
if(goods.length > 0) { if (goods.length > 0) {
await sendMailByContent(MAIL_TYPE.GUILD_FUND_BOX, roleId, { goods }); 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 beginTime = getZeroPointOfTime(refTimeDaily);
let endTime = beginTime + 24 * 60 * 60; let endTime = beginTime + 24 * 60 * 60;
let battleRecords = await BattleRecordModel.findByWarTypeAndStatus(roleId, WAR_TYPE.BOSS, 0, new Date(beginTime * 1000), new Date(endTime * 1000)); 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; let { bossDamage = 0, bossInstanceCode } = record;
if(bossDamage > 0) { if (bossDamage > 0) {
let bossInstance = await BossInstanceModel.findByCode(bossInstanceCode); let bossInstance = await BossInstanceModel.findByCode(bossInstanceCode);
if(!bossInstance) continue; if (!bossInstance) continue;
let dicBossBase = gameData.bossBaseByBossLv.get(bossInstance.bossLv); let dicBossBase = gameData.bossBaseByBossLv.get(bossInstance.bossLv);
let { basicReward, damageRewardTotal } = dicBossBase; let { basicReward, damageRewardTotal } = dicBossBase;
let damageReward = damageRewardTotal.map(cur => { 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]; let goods = [...basicReward, ...damageReward];
if(goods.length > 0) { if (goods.length > 0) {
await sendMailByContent(MAIL_TYPE.GUILD_BOSS, roleId, { goods }); await sendMailByContent(MAIL_TYPE.GUILD_BOSS, roleId, { goods });
} }
await BattleRecordModel.updateBattleRecordByCode(battleCode, { $set: { status: 1 } }); await BattleRecordModel.updateBattleRecordByCode(battleCode, { $set: { status: 1 } });
@@ -433,17 +455,17 @@ export async function getWishPool(userGuild: UserGuildType) {
return { list, wishDntCnt: wishDntCnt || 0, wishGoods, receivedWishPool }; return { list, wishDntCnt: wishDntCnt || 0, wishGoods, receivedWishPool };
} }
export function setUserGuildSession(session:FrontendOrBackendSession, myUserGuild: UserGuildType) { export function setUserGuildSession(session: FrontendOrBackendSession, myUserGuild: UserGuildType) {
if(myUserGuild) { if (myUserGuild) {
session.set('guildCode', myUserGuild.guildCode); session.set('guildCode', myUserGuild.guildCode);
session.set('guildAuth', myUserGuild.auth); session.set('guildAuth', myUserGuild.auth);
session.push('guildCode', () => {}); session.push('guildCode', () => { });
session.push('guildAuth', () => {}); session.push('guildAuth', () => { });
} else { } else {
session.set('guildCode', null); session.set('guildCode', null);
session.set('guildAuth', null); session.set('guildAuth', null);
session.push('guildCode', () => {}); session.push('guildCode', () => { });
session.push('guildAuth', () => {}); session.push('guildAuth', () => { });
} }
} }
@@ -509,8 +531,8 @@ export async function getGuildQuitCdTime(serverId: number) {
let serverTime = await getServerCreateTime(serverId); let serverTime = await getServerCreateTime(serverId);
let todayIndex = deltaDays(moment(serverTime * 1000).toDate(), new Date) + 1; let todayIndex = deltaDays(moment(serverTime * 1000).toDate(), new Date) + 1;
let result = 0; let result = 0;
for(let { day, minute } of gameData.guildQuitCd) { for (let { day, minute } of gameData.guildQuitCd) {
if(todayIndex > day) result = minute; if (todayIndex > day) result = minute;
} }
console.log('####', serverId, serverTime, todayIndex, result) console.log('####', serverId, serverTime, todayIndex, result)
return result return result

View File

@@ -13,13 +13,13 @@ export enum GUILD_STRUCTURE {
// 建筑名 // 建筑名
export const GUILD_STRUCTURE_NAME = new Map([ export const GUILD_STRUCTURE_NAME = new Map([
[ GUILD_STRUCTURE.ARMY_CENTER, '中军大帐'], [GUILD_STRUCTURE.ARMY_CENTER, '中军大帐'],
[ GUILD_STRUCTURE.EQUIP_PRODUCE, '炼器堂'], [GUILD_STRUCTURE.EQUIP_PRODUCE, '炼器堂'],
[ GUILD_STRUCTURE.BOSS, '演武台'], [GUILD_STRUCTURE.BOSS, '演武台'],
[ GUILD_STRUCTURE.TRAIN, '练兵场'], [GUILD_STRUCTURE.TRAIN, '练兵场'],
[ GUILD_STRUCTURE.DONATE, '捐献所'], [GUILD_STRUCTURE.DONATE, '捐献所'],
[ GUILD_STRUCTURE.WISH_POOL, '许愿池'], [GUILD_STRUCTURE.WISH_POOL, '许愿池'],
[ GUILD_STRUCTURE.STORE, '商店'] [GUILD_STRUCTURE.STORE, '商店']
]) ])
// 权限 // 权限
@@ -169,11 +169,11 @@ export const GUILD_ROUTE_OPERATE = [
]; ];
export const GUILD_ROUTE_TO_OPERATE = new Map<string, { operate: GUILD_OPERATE, type: number }[]>(); export const GUILD_ROUTE_TO_OPERATE = new Map<string, { operate: GUILD_OPERATE, type: number }[]>();
for(let {route, operate, type} of GUILD_ROUTE_OPERATE) { for (let { route, operate, type } of GUILD_ROUTE_OPERATE) {
if(!GUILD_ROUTE_TO_OPERATE.has(route)) { if (!GUILD_ROUTE_TO_OPERATE.has(route)) {
GUILD_ROUTE_TO_OPERATE.set(route, []); GUILD_ROUTE_TO_OPERATE.set(route, []);
} }
GUILD_ROUTE_TO_OPERATE.get(route).push({ operate, type}); GUILD_ROUTE_TO_OPERATE.get(route).push({ operate, type });
} }
// 军团状态 // 军团状态
@@ -235,6 +235,8 @@ export enum GUILD_POINT_WAYS {
TRAIN = 3, // 训练场 TRAIN = 3, // 训练场
BOSS_WAR = 4, // 演武台 BOSS_WAR = 4, // 演武台
ACTIVITY = 5, // 军团活动 ACTIVITY = 5, // 军团活动
BOSS_WAR_EXTEND = 6, //演舞台额外
} }
// 军团活动id // 军团活动id

View File

@@ -653,6 +653,7 @@ export const FILENAME = {
DIC_AUTHORS_BOOK_POINT: 'dic_zyz_authorsBookPoint', DIC_AUTHORS_BOOK_POINT: 'dic_zyz_authorsBookPoint',
DIC_AUTHORS_BOOK_SUB: 'dic_zyz_authorsBookSub', DIC_AUTHORS_BOOK_SUB: 'dic_zyz_authorsBookSub',
DIC_AUTHORS_GOODID: 'dic_zyz_authorsGoodId', DIC_AUTHORS_GOODID: 'dic_zyz_authorsGoodId',
DIC_BOSS_RANK_ACTIVE_POINT:'dic_zyz_bossRank_activePoint',
} }
export const WAR_RELATE_TABLES = [ export const WAR_RELATE_TABLES = [

View File

@@ -140,6 +140,7 @@ import { dicAuthorsBookGoodId, loadAuthorsBookGoodId } from "./dictionary/DicAut
import { dicAuthorsBookMaxProgress, dicAuthorsBookSubs, dicAuthorsBookSubStar, loadAuthorsBookSub } from "./dictionary/DicAuthorsBookSub"; import { dicAuthorsBookMaxProgress, dicAuthorsBookSubs, dicAuthorsBookSubStar, loadAuthorsBookSub } from "./dictionary/DicAuthorsBookSub";
import { dicAuthorsBookPoint, loadAuthorsBookPoint } from "./dictionary/DicAuthorsBookPoint"; import { dicAuthorsBookPoint, loadAuthorsBookPoint } from "./dictionary/DicAuthorsBookPoint";
import { dicAuthorsBook, loadAuthorsBook } from './dictionary/DicAuthorsBook'; import { dicAuthorsBook, loadAuthorsBook } from './dictionary/DicAuthorsBook';
import { dicBossRankActivePoint, loadBossRankActivePoint } from "./dictionary/DicBossRankActivePoint";
export const gameData = { export const gameData = {
daily: dicDaily, daily: dicDaily,
@@ -358,7 +359,8 @@ export const gameData = {
authorBookSubStar: dicAuthorsBookSubStar, authorBookSubStar: dicAuthorsBookSubStar,
authorBookSubs: dicAuthorsBookSubs, authorBookSubs: dicAuthorsBookSubs,
authorBookPoint: dicAuthorsBookPoint, authorBookPoint: dicAuthorsBookPoint,
authorBookMaxProgress: dicAuthorsBookMaxProgress authorBookMaxProgress: dicAuthorsBookMaxProgress,
bossRankActivePoint: dicBossRankActivePoint,
}; };
// 在此提供一些原先在gamedata中提供的方法以便更方便获取gameData数据 // 在此提供一些原先在gamedata中提供的方法以便更方便获取gameData数据
@@ -1670,6 +1672,8 @@ function loadDatas(type?: string) {
if (type == undefined || type == 'loadAuthorsBook') if (type == undefined || type == 'loadAuthorsBook')
loadAuthorsBook(); loadAuthorsBook();
if (type == undefined || type == 'loadBossRankActivePoint')
loadBossRankActivePoint();
console.log('loadDatas type: ', type || 'all'); console.log('loadDatas type: ', type || 'all');
} }

View File

@@ -0,0 +1,31 @@
import { readFileAndParse } from '../util'
import { FILENAME } from '../../consts'
export interface DicBossRankActivePoint {
readonly id: number;
readonly bossRankMin: number;
readonly bossRankMax: number;
readonly activePoint: number;
}
// const DicBossRankActivePointKeys: KeysEnum<DicBossRankActivePoint> = {
// id: true,
// bossRankMin: true,
// bossRankMax: true,
// activePoint: true,
// };
export const dicBossRankActivePoint = new Array<DicBossRankActivePoint>();
export function loadBossRankActivePoint() {
dicBossRankActivePoint.splice(0, dicBossRankActivePoint.length);
let arr = readFileAndParse(FILENAME.DIC_BOSS_RANK_ACTIVE_POINT);
arr.forEach(o => {
dicBossRankActivePoint.push(o);
});
arr = undefined;
}