修复:诸侯混战宣战,邮件领取,名将谱去除好感,镇念塔层级下降,求贤若渴碎片,pvp,秘境首通
This commit is contained in:
@@ -39,17 +39,36 @@ export class MailHandler {
|
||||
public async readMail(msg: { id: string, mailType: number }, session: BackendSession) {
|
||||
let roleId: string = session.get('roleId');
|
||||
let { id, mailType } = msg;
|
||||
let mail;
|
||||
let mails = [];
|
||||
if (mailType == GM_MAIL_TYPE.SINGLE) {
|
||||
mail = await MailModel.updateStatusWithCondition(id, MAIL_STATUS.READ, [MAIL_STATUS.CREATE]);
|
||||
let mail = await MailModel.getMailById(id);
|
||||
if(mail && mail.status == MAIL_STATUS.CREATE) {
|
||||
mail = await MailModel.updateStatusWithCondition(id, MAIL_STATUS.READ);
|
||||
mails.push({ id, status: MAIL_STATUS.READ, mailType });
|
||||
}
|
||||
|
||||
} else if (mailType == GM_MAIL_TYPE.GROUP) {
|
||||
mail = await GroupMailModel.updateStatusWithCondition(id, roleId, MAIL_STATUS.READ, [MAIL_STATUS.CREATE]);
|
||||
let mail = await GroupMailModel.getMailById(id);
|
||||
if(mail) {
|
||||
let myStatus = mail.roleStatus.find(cur => cur.roleId == roleId);
|
||||
if(myStatus && myStatus.status == MAIL_STATUS.CREATE) {
|
||||
mail = await GroupMailModel.updateStatusWithCondition(id, roleId, MAIL_STATUS.READ);
|
||||
mails.push({ id, status: MAIL_STATUS.READ, mailType });
|
||||
}
|
||||
}
|
||||
} else if (mailType == GM_MAIL_TYPE.SERVER) {
|
||||
mail = await ServerMailModel.updateStatusWithCondition(id, roleId, MAIL_STATUS.READ, [MAIL_STATUS.CREATE])
|
||||
let mail = await ServerMailModel.getMailById(id);
|
||||
if(mail) {
|
||||
let myStatus = mail.roleStatus.find(cur => cur.roleId == roleId);
|
||||
if(!myStatus || myStatus.status == MAIL_STATUS.CREATE) {
|
||||
mail = await ServerMailModel.updateStatusWithCondition(id, roleId, MAIL_STATUS.READ);
|
||||
mails.push({ id, status: MAIL_STATUS.READ, mailType });
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (!mail)
|
||||
// return resResult(STATUS.WRONG_PARMS);
|
||||
return resResult(STATUS.SUCCESS, { mails: mail?[{ id, status: MAIL_STATUS.READ, mailType }]:[] });
|
||||
return resResult(STATUS.SUCCESS, { mails });
|
||||
}
|
||||
|
||||
public async delMails(msg: { id: string, mailType: number, type: number }, session: BackendSession) {
|
||||
@@ -99,26 +118,40 @@ export class MailHandler {
|
||||
let mail: MailType|GroupMailType|ServerMailType;
|
||||
if (mailType == GM_MAIL_TYPE.SINGLE) {
|
||||
mail = await MailModel.getMailById(id);
|
||||
if (!mail) return resResult(STATUS.WRONG_PARMS);
|
||||
if(mail.status != MAIL_STATUS.READ && mail.status != MAIL_STATUS.CREATE) return resResult(STATUS.WRONG_PARMS);
|
||||
} else if (mailType == GM_MAIL_TYPE.GROUP) {
|
||||
mail = await GroupMailModel.getMailById(id);
|
||||
if (!mail) return resResult(STATUS.WRONG_PARMS);
|
||||
let myStatus = mail.roleStatus.find(cur => cur.roleId == roleId);
|
||||
if(!myStatus) return resResult(STATUS.WRONG_PARMS);
|
||||
if(myStatus.status != MAIL_STATUS.READ && myStatus.status != MAIL_STATUS.CREATE) return resResult(STATUS.WRONG_PARMS);
|
||||
} else if (mailType == GM_MAIL_TYPE.SERVER) {
|
||||
mail = await ServerMailModel.getMailById(id);
|
||||
if (!mail) return resResult(STATUS.WRONG_PARMS);
|
||||
let myStatus = mail.roleStatus.find(cur => cur.roleId == roleId);
|
||||
if(myStatus && myStatus.status != MAIL_STATUS.READ && myStatus.status != MAIL_STATUS.CREATE) return resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
if (!mail) return resResult(STATUS.WRONG_PARMS);
|
||||
originMails.push({ mailType, mail });
|
||||
} else {//一键领取
|
||||
let singlemails = await MailModel.findRewardsMails(roleId);
|
||||
for(let mail of singlemails) {
|
||||
if(mail.status != MAIL_STATUS.READ && mail.status != MAIL_STATUS.CREATE) continue;
|
||||
originMails.push({ mailType: GM_MAIL_TYPE.SINGLE, mail });
|
||||
}
|
||||
let groupMails = await GroupMailModel.findRewardsMails(roleId);
|
||||
for(let mail of groupMails) {
|
||||
let myStatus = mail.roleStatus.find(cur => cur.roleId == roleId);
|
||||
if(!myStatus) continue;
|
||||
if(myStatus.status != MAIL_STATUS.READ && myStatus.status != MAIL_STATUS.CREATE) continue;
|
||||
originMails.push({ mailType: GM_MAIL_TYPE.GROUP, mail })
|
||||
}
|
||||
let servermails = await ServerMailModel.findRewardsMails(serverId, roleId);
|
||||
[
|
||||
{ mails: singlemails, mailType: GM_MAIL_TYPE.SINGLE },
|
||||
{ mails: groupMails, mailType: GM_MAIL_TYPE.GROUP },
|
||||
{ mails: servermails, mailType: GM_MAIL_TYPE.SERVER },
|
||||
].forEach(({ mails, mailType }) => {
|
||||
mails.forEach((mail: MailType|GroupMailType|ServerMailType) => {
|
||||
originMails.push({ mailType, mail })
|
||||
});
|
||||
});
|
||||
for(let mail of servermails) {
|
||||
let myStatus = mail.roleStatus.find(cur => cur.roleId == roleId);
|
||||
if(myStatus && myStatus.status != MAIL_STATUS.READ && myStatus.status != MAIL_STATUS.CREATE) continue;
|
||||
originMails.push({ mailType: GM_MAIL_TYPE.SERVER, mail })
|
||||
}
|
||||
}
|
||||
|
||||
let mailGoods: ItemInter[] = [], mails: MailParam[] = [];
|
||||
@@ -134,11 +167,11 @@ export class MailHandler {
|
||||
equipCount = newEquipCount;
|
||||
|
||||
if(mailType == GM_MAIL_TYPE.SINGLE) {
|
||||
mail = await MailModel.updateStatusWithCondition(mail._id, MAIL_STATUS.RECEIVED, [MAIL_STATUS.READ, MAIL_STATUS.CREATE]);
|
||||
mail = await MailModel.updateStatusWithCondition(mail._id, MAIL_STATUS.RECEIVED);
|
||||
} else if (mailType == GM_MAIL_TYPE.GROUP) {
|
||||
mail = await GroupMailModel.updateStatusWithCondition(mail._id, roleId, MAIL_STATUS.RECEIVED, [MAIL_STATUS.READ, MAIL_STATUS.CREATE]);
|
||||
mail = await GroupMailModel.updateStatusWithCondition(mail._id, roleId, MAIL_STATUS.RECEIVED);
|
||||
} else if (mailType == GM_MAIL_TYPE.SERVER) {
|
||||
mail = await ServerMailModel.updateStatusWithCondition(mail._id, roleId, MAIL_STATUS.RECEIVED, [MAIL_STATUS.READ, MAIL_STATUS.CREATE]);
|
||||
mail = await ServerMailModel.updateStatusWithCondition(mail._id, roleId, MAIL_STATUS.RECEIVED, <ServerMailType>mail);
|
||||
}
|
||||
if(!mail) return resResult(STATUS.MAIL_HAS_RECEIVE);
|
||||
|
||||
|
||||
@@ -325,14 +325,6 @@ export class RoleHandler {
|
||||
update.scrollStar = dicHero.initialStars;
|
||||
update.scrollQuality = dicHero.quality;
|
||||
update.scrollColorStar = 0;
|
||||
|
||||
// 获取一定好感度
|
||||
let maxLv = gameData.maxFriendShipLv.max;
|
||||
if (maxLv > favourLv) {
|
||||
|
||||
update.favour += SCROLL.SCROLL_ACTIVE_FAVOUR;
|
||||
update.favourLv = getFriendLvByExp(update.favour);
|
||||
}
|
||||
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_UNLOCK, 1, { dicHeroes: [dicHero] })
|
||||
} else {
|
||||
if (star > scrollStar) { // 可以升星
|
||||
@@ -351,16 +343,10 @@ export class RoleHandler {
|
||||
let dicHeroScroll = getScollByStar(dicHero.quality, update.scrollStar, update.scrollQuality, update.scrollColorStar);
|
||||
update.scrollId = dicHeroScroll ? dicHeroScroll.id : 0;
|
||||
|
||||
let hero = curHero;
|
||||
if(curHero.favourLv != update.favourLv) {
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.FAVOUR, sid, roleId, curHero, update); // 更新单个武将战力
|
||||
} else {
|
||||
hero = await HeroModel.updateHeroInfo(roleId, hid, update);
|
||||
}
|
||||
let hero = await HeroModel.updateHeroInfo(roleId, hid, update);
|
||||
await calAllHeroCe(HERO_SYSTEM_TYPE.SCROLL, sid, roleId, {}, [hid]); // 全局增加战力
|
||||
|
||||
// 任务
|
||||
if (favourLv != hero.favourLv) await checkTaskWithHero(roleId, sid, TASK_TYPE.HERO_FAVOUR_LV, hero, [favourLv]);
|
||||
if (!scrollActive) await checkTask(roleId, sid, TASK_TYPE.ROLE_SCROLL_ACTIVE, 1, true, {});
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
|
||||
Reference in New Issue
Block a user