✨ feat(每周结算): 新增对演武台boss的伤害排名获得活跃值
This commit is contained in:
@@ -9,7 +9,7 @@ import { findWhere } from 'underscore'
|
||||
import { GUILD_STRUCTURE, GUILD_BOSS_STATUS, GUILD_POINT_WAYS } from '../../../consts/constModules/guildConst';
|
||||
import { DATA_NAME } from '../../../consts/dataName';
|
||||
import { UserGuildModel } from '../../../db/UserGuild';
|
||||
import { addActive } from '../../../services/guildService';
|
||||
import { addActive, getBossWarExtendActive } from '../../../services/guildService';
|
||||
import { GuildModel } from '../../../db/Guild';
|
||||
import { gameData, getBossByLv } from '../../../pubUtils/data';
|
||||
import { lockData } from '../../../services/redLockService';
|
||||
@@ -197,6 +197,8 @@ export class GuildHandler {
|
||||
await pushBossStatus(guildCode, result);
|
||||
pushGuildBossSucMsg(roleId, roleName, guildCode, bossInstance);
|
||||
|
||||
await addActive(roleId, serverId, GUILD_POINT_WAYS.BOSS_WAR_EXTEND, null, await getBossWarExtendActive(bossCode, roleId));//获得活跃值
|
||||
|
||||
res.releaseCallback();//解锁
|
||||
return resResult(STATUS.SUCCESS, { bossHp: 0 });
|
||||
} else {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -13,13 +13,13 @@ export enum GUILD_STRUCTURE {
|
||||
|
||||
// 建筑名
|
||||
export const GUILD_STRUCTURE_NAME = new Map([
|
||||
[ GUILD_STRUCTURE.ARMY_CENTER, '中军大帐'],
|
||||
[ GUILD_STRUCTURE.EQUIP_PRODUCE, '炼器堂'],
|
||||
[ GUILD_STRUCTURE.BOSS, '演武台'],
|
||||
[ GUILD_STRUCTURE.TRAIN, '练兵场'],
|
||||
[ GUILD_STRUCTURE.DONATE, '捐献所'],
|
||||
[ GUILD_STRUCTURE.WISH_POOL, '许愿池'],
|
||||
[ GUILD_STRUCTURE.STORE, '商店']
|
||||
[GUILD_STRUCTURE.ARMY_CENTER, '中军大帐'],
|
||||
[GUILD_STRUCTURE.EQUIP_PRODUCE, '炼器堂'],
|
||||
[GUILD_STRUCTURE.BOSS, '演武台'],
|
||||
[GUILD_STRUCTURE.TRAIN, '练兵场'],
|
||||
[GUILD_STRUCTURE.DONATE, '捐献所'],
|
||||
[GUILD_STRUCTURE.WISH_POOL, '许愿池'],
|
||||
[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 }[]>();
|
||||
for(let {route, operate, type} of GUILD_ROUTE_OPERATE) {
|
||||
if(!GUILD_ROUTE_TO_OPERATE.has(route)) {
|
||||
for (let { route, operate, type } of GUILD_ROUTE_OPERATE) {
|
||||
if (!GUILD_ROUTE_TO_OPERATE.has(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, // 训练场
|
||||
BOSS_WAR = 4, // 演武台
|
||||
ACTIVITY = 5, // 军团活动
|
||||
BOSS_WAR_EXTEND = 6, //演舞台额外
|
||||
|
||||
}
|
||||
|
||||
// 军团活动id
|
||||
|
||||
@@ -653,6 +653,7 @@ export const FILENAME = {
|
||||
DIC_AUTHORS_BOOK_POINT: 'dic_zyz_authorsBookPoint',
|
||||
DIC_AUTHORS_BOOK_SUB: 'dic_zyz_authorsBookSub',
|
||||
DIC_AUTHORS_GOODID: 'dic_zyz_authorsGoodId',
|
||||
DIC_BOSS_RANK_ACTIVE_POINT:'dic_zyz_bossRank_activePoint',
|
||||
}
|
||||
|
||||
export const WAR_RELATE_TABLES = [
|
||||
|
||||
@@ -140,6 +140,7 @@ import { dicAuthorsBookGoodId, loadAuthorsBookGoodId } from "./dictionary/DicAut
|
||||
import { dicAuthorsBookMaxProgress, dicAuthorsBookSubs, dicAuthorsBookSubStar, loadAuthorsBookSub } from "./dictionary/DicAuthorsBookSub";
|
||||
import { dicAuthorsBookPoint, loadAuthorsBookPoint } from "./dictionary/DicAuthorsBookPoint";
|
||||
import { dicAuthorsBook, loadAuthorsBook } from './dictionary/DicAuthorsBook';
|
||||
import { dicBossRankActivePoint, loadBossRankActivePoint } from "./dictionary/DicBossRankActivePoint";
|
||||
|
||||
export const gameData = {
|
||||
daily: dicDaily,
|
||||
@@ -358,7 +359,8 @@ export const gameData = {
|
||||
authorBookSubStar: dicAuthorsBookSubStar,
|
||||
authorBookSubs: dicAuthorsBookSubs,
|
||||
authorBookPoint: dicAuthorsBookPoint,
|
||||
authorBookMaxProgress: dicAuthorsBookMaxProgress
|
||||
authorBookMaxProgress: dicAuthorsBookMaxProgress,
|
||||
bossRankActivePoint: dicBossRankActivePoint,
|
||||
};
|
||||
|
||||
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
||||
@@ -1670,6 +1672,8 @@ function loadDatas(type?: string) {
|
||||
if (type == undefined || type == 'loadAuthorsBook')
|
||||
loadAuthorsBook();
|
||||
|
||||
if (type == undefined || type == 'loadBossRankActivePoint')
|
||||
loadBossRankActivePoint();
|
||||
console.log('loadDatas type: ', type || 'all');
|
||||
}
|
||||
|
||||
|
||||
31
shared/pubUtils/dictionary/DicBossRankActivePoint.ts
Normal file
31
shared/pubUtils/dictionary/DicBossRankActivePoint.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user