任务:添加每日主公经验
This commit is contained in:
@@ -11,6 +11,9 @@ import { getMainTask, refDailyTaskBox, removeHistoryTask, getCurTask, checkTask
|
||||
import { TASK } from "../../../pubUtils/dicParam";
|
||||
import { newHeroGiftPoint } from "../../../services/activity/newHeroGiftsService";
|
||||
import { ActivityTaskPointModel } from "../../../db/ActivityTaskPoint";
|
||||
import { ItemInter } from "../../../pubUtils/interface";
|
||||
import { RoleModel } from "../../../db/Role";
|
||||
import { roleLevelup } from "../../../services/normalBattleService";
|
||||
|
||||
export default function (app: Application) {
|
||||
return new ShopHandler(app);
|
||||
@@ -47,7 +50,7 @@ export class ShopHandler {
|
||||
rec = await UserTaskRecModel.receiveTask(roleId, type, taskType, group, id);
|
||||
|
||||
// 每日、成就增加积分
|
||||
let point = 0, weeklyPoint = 0;
|
||||
let point = 0, weeklyPoint = 0, expItem: ItemInter;
|
||||
if (type == TASK_FUN_TYPE.DAILY) { // 增加积分
|
||||
let userTask = await UserTaskModel.findByRole(roleId);
|
||||
let dic = <DicDailyTask>dicTask;
|
||||
@@ -59,6 +62,8 @@ export class ShopHandler {
|
||||
}
|
||||
point = userTask.dailyTaskPoint;
|
||||
weeklyPoint = userTask.dailyTaskPointWeekly;
|
||||
let { lv } = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
expItem = { id: dic.exp.id, count: dic.exp.count * gameData.taskExp.get(lv)};
|
||||
} else if (type == TASK_FUN_TYPE.ACHIEVEMENT) {
|
||||
let dic = <DicAchievement>dicTask;
|
||||
let userTask = await UserTaskModel.incInfo(roleId, { achievementPoint: dic.point });
|
||||
@@ -74,6 +79,10 @@ export class ShopHandler {
|
||||
}
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, taskReward);
|
||||
if(expItem) {
|
||||
await roleLevelup(roleId, expItem.count, session);
|
||||
goods.push(expItem);
|
||||
}
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
type, id, count: rec.count, received: rec.received.includes(id),
|
||||
|
||||
@@ -4,14 +4,15 @@ import Role, { RoleModel, RoleType } from '../db/Role'
|
||||
import { getLvByExp, getExpByLv, gameData, getDicApByLv } from '../pubUtils/data';
|
||||
import { updateUserInfo } from './redisService';
|
||||
import { switchOnFunc } from './funcSwitchService';
|
||||
import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE } from '../consts';
|
||||
import { BackendSession } from 'pinus';
|
||||
import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE, STATUS } from '../consts';
|
||||
import { BackendSession, pinus } from 'pinus';
|
||||
import { REDIS_KEY } from '../consts';
|
||||
import { Rank } from './rankService';
|
||||
import { checkActivityTask, checkTask } from './taskService';
|
||||
import { accomplishTask } from '../pubUtils/taskUtil';
|
||||
import { RScriptRecordModel } from '../db/RScriptRecord';
|
||||
import { setAp } from './actionPointService';
|
||||
import { resResult } from '../pubUtils/util';
|
||||
|
||||
export async function roleLevelup(roleId: string, kingExp: number, session: BackendSession) {
|
||||
const serverId = session.get('serverId');
|
||||
@@ -65,6 +66,15 @@ export async function roleLevelup(roleId: string, kingExp: number, session: Back
|
||||
await setAp(roleId, i, dicAp.restoreAp, sid, funcs);
|
||||
}
|
||||
}
|
||||
// 推送
|
||||
if(canGetExp && kingExp >= 0) {
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
pinus.app.get('channelService').pushMessageByUids('onPlayerExpChange', resResult(STATUS.SUCCESS, {
|
||||
isLvUp: newLv > lv,
|
||||
lv: newLv,
|
||||
exp: newExp
|
||||
}), uids);
|
||||
}
|
||||
|
||||
return { actordata, lv: newLv, exp: newExp, kingExp: newExp - exp };
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ function sortConsumes(goods: Array<ItemInter>, bags: Array<ItemInter>, currencys
|
||||
} else if (table == ITEM_TABLE.ROLE) {
|
||||
let curname = getCurNameById(goodInfo.good_id);
|
||||
if (!!curname) {
|
||||
if (curname != 'ap') {
|
||||
if (curname != 'ap' && curname != 'kingExp') {
|
||||
currencysMap[curname] = (currencysMap[curname] || 0) + good.count;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user