奇遇:修复多次创建奇遇bug
This commit is contained in:
@@ -45,9 +45,9 @@ Filter.prototype.before = async function (routeRecord: RouteRecord, msg: any, se
|
|||||||
next(null);
|
next(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
Filter.prototype.after = function (err: Error, routeRecord: RouteRecord, msg: any, session: FrontendOrBackendSession, resp: any, next: HandlerCallback) {
|
Filter.prototype.after = async function (err: Error, routeRecord: RouteRecord, msg: any, session: FrontendOrBackendSession, resp: any, next: HandlerCallback) {
|
||||||
//刷新
|
//刷新
|
||||||
refresh(session);
|
await refresh(session);
|
||||||
// return checkEvent(session).then(()=>{
|
// return checkEvent(session).then(()=>{
|
||||||
// next(err);
|
// next(err);
|
||||||
// }).catch(e => {
|
// }).catch(e => {
|
||||||
|
|||||||
@@ -83,16 +83,19 @@ export function getEventTime(now: Date) {
|
|||||||
*/
|
*/
|
||||||
export async function startEvent(session: FrontendOrBackendSession) {
|
export async function startEvent(session: FrontendOrBackendSession) {
|
||||||
|
|
||||||
// console.log('*******setEventStatus')
|
const funcs = session.get('funcs');
|
||||||
let roleId = session.get('roleId');
|
const eventStatus = session.get('eventStatus')||EVENT_STATUS.WAITING;
|
||||||
let roleName = session.get('roleName');
|
if(funcs && funcs.includes(FUNCS_ID.EVENT) && eventStatus == EVENT_STATUS.WAITING) {
|
||||||
let sid = session.get('sid');
|
// console.log('*******setEventStatus')
|
||||||
let event = await refreshEvent(1, roleId, roleName, 0, []); // 刷新初始的一件
|
let roleId = session.get('roleId');
|
||||||
await RoleModel.setEventStatus(roleId, EVENT_STATUS.STARTING);
|
let roleName = session.get('roleName');
|
||||||
session.set('eventStatus', EVENT_STATUS.STARTING);
|
let sid = session.get('sid');
|
||||||
session.push('eventStatus', () => {});
|
let event = await refreshEvent(1, roleId, roleName, 0, []); // 刷新初始的一件
|
||||||
pushEventMsg(sid, roleId, { event }); // 推送
|
await RoleModel.setEventStatus(roleId, EVENT_STATUS.STARTING);
|
||||||
|
session.set('eventStatus', EVENT_STATUS.STARTING);
|
||||||
|
session.push('eventStatus', () => {});
|
||||||
|
pushEventMsg(sid, roleId, { event }); // 推送
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,15 +14,11 @@ import { startEvent } from "./eventSercive";
|
|||||||
export async function refresh(session: FrontendOrBackendSession) {
|
export async function refresh(session: FrontendOrBackendSession) {
|
||||||
const roleId = session.get('roleId');
|
const roleId = session.get('roleId');
|
||||||
const sid = session.get('sid');
|
const sid = session.get('sid');
|
||||||
const funcs = session.get('funcs');
|
|
||||||
const eventStatus = session.get('eventStatus')||EVENT_STATUS.WAITING;
|
|
||||||
|
|
||||||
let uids = [{uid: roleId, sid}];
|
let uids = [{uid: roleId, sid}];
|
||||||
pinus.app.get('channelService').pushMessageByUids('onPushCurrentTime', resResult(STATUS.SUCCESS, {time: Date.now()}), uids);
|
pinus.app.get('channelService').pushMessageByUids('onPushCurrentTime', resResult(STATUS.SUCCESS, {time: Date.now()}), uids);
|
||||||
await refreshDaily(session);
|
await refreshDaily(session);
|
||||||
if(funcs && funcs.includes(FUNCS_ID.EVENT) && eventStatus == EVENT_STATUS.WAITING) {
|
await startEvent(session);
|
||||||
await startEvent(session);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1054,11 +1054,9 @@ function calTitle(role: RoleType, update: RoleUpdate) {
|
|||||||
|
|
||||||
let dicOldTitle = gameData.title.get(oldTitle)||{ mainAttrValue: new Map(), assiAttrValue: new Map() };
|
let dicOldTitle = gameData.title.get(oldTitle)||{ mainAttrValue: new Map(), assiAttrValue: new Map() };
|
||||||
let dicNewTitle = gameData.title.get(newTitle);
|
let dicNewTitle = gameData.title.get(newTitle);
|
||||||
console.log('***** oldTitle, newTitle', oldTitle, newTitle);
|
|
||||||
|
|
||||||
for (let i = ABI_TYPE.ABI_HP; i < ABI_TYPE.ABI_MAX; i++) {
|
for (let i = ABI_TYPE.ABI_HP; i < ABI_TYPE.ABI_MAX; i++) {
|
||||||
if (dicNewTitle.mainAttrValue.has(i) || dicOldTitle.mainAttrValue.has(i)) {
|
if (dicNewTitle.mainAttrValue.has(i) || dicOldTitle.mainAttrValue.has(i)) {
|
||||||
console.log()
|
|
||||||
let fixUp = ((dicNewTitle.mainAttrValue.get(i) || 0) - (dicOldTitle.mainAttrValue.get(i) || 0)) * HERO_CE_RATIO;
|
let fixUp = ((dicNewTitle.mainAttrValue.get(i) || 0) - (dicOldTitle.mainAttrValue.get(i) || 0)) * HERO_CE_RATIO;
|
||||||
updateRoleAttr(roleAttrs, i, { inc: { fixUp } });
|
updateRoleAttr(roleAttrs, i, { inc: { fixUp } });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user