diff --git a/game-server/app/servers/role/handler/taskHandler.ts b/game-server/app/servers/role/handler/taskHandler.ts index e7be466ca..aeaf60ada 100644 --- a/game-server/app/servers/role/handler/taskHandler.ts +++ b/game-server/app/servers/role/handler/taskHandler.ts @@ -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 = 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 = 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), diff --git a/game-server/app/services/normalBattleService.ts b/game-server/app/services/normalBattleService.ts index 43d76f1a5..baaed87fd 100644 --- a/game-server/app/services/normalBattleService.ts +++ b/game-server/app/services/normalBattleService.ts @@ -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 }; } diff --git a/game-server/app/services/rewardService.ts b/game-server/app/services/rewardService.ts index dca03ab83..a7b41687d 100644 --- a/game-server/app/services/rewardService.ts +++ b/game-server/app/services/rewardService.ts @@ -87,7 +87,7 @@ function sortConsumes(goods: Array, bags: Array, 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; diff --git a/shared/consts/constModules/itemConst.ts b/shared/consts/constModules/itemConst.ts index cfa0165dd..b459b1b8b 100644 --- a/shared/consts/constModules/itemConst.ts +++ b/shared/consts/constModules/itemConst.ts @@ -147,6 +147,7 @@ const itid_array = [ { id: 55, name: '回复体力道具', table: 'item', type: CONSUME_TYPE.AP }, { id: 56, name: '普通骰子', table: 'item', type: CONSUME_TYPE.DICE }, { id: 57, name: '天机骰子', table: 'item', type: CONSUME_TYPE.DICE }, + { id: 58, name: '主公经验', table: 'role' }, ]; @@ -162,12 +163,13 @@ export const CURRENCY_TYPE = { TREASURE_POINT: "treasurePoint", EXPEDITION_POINT: "expeditionPoint", DUNGEON_POINT: "dungeonPoint", - FRIEND_POINT: "friendPoint", + FRIEND_POINT: "frdCnt", HONOUR: "honour", SKIN_COIN: "skinCoin", DUNGEON: "dungeon", NORMAL_DICE: "normalDice", - SPECIAL_DICE: "specialDice" + SPECIAL_DICE: "specialDice", + KING_EXP: 'kingExp' } @@ -187,7 +189,8 @@ const currencyArr = [ { "gid": 40006, "name": "蜀锦", "type": CURRENCY_TYPE.SKIN_COIN }, { "gid": 40007, "name": "秘境币", "type": CURRENCY_TYPE.DUNGEON }, { "gid": 72011, "name": "普通骰子", "type": CURRENCY_TYPE.NORMAL_DICE }, - { "gid": 72021, "name": "天机骰子", "type": CURRENCY_TYPE.SPECIAL_DICE } + { "gid": 72021, "name": "天机骰子", "type": CURRENCY_TYPE.SPECIAL_DICE }, + { "gid": 72030, "name": "主公经验", "type": CURRENCY_TYPE.KING_EXP } ]; export const CURRENCY = new Map(); export const CURRENCY_BY_TYPE = new Map(); @@ -196,6 +199,14 @@ for (let obj of currencyArr) { CURRENCY_BY_TYPE.set(obj.type, obj.gid); } +export function getCurNameById(gid: number) { + let currency = CURRENCY.get(gid); + if (!currency) { + return ''; + } + return currency.name; +} + export enum QUALITY_TYPE { BLUE = 1, // 蓝 PURPLE = 2, // 紫 @@ -225,27 +236,6 @@ export enum HERO_QUALITY_TYPE { export const FIX_ATTRIBUTES_RAN = 20; // 固定属性值+-20%随机 - -export function getCurNameById(gid) { - let currency = CURRENCY.get(gid); - if (!currency) { - return; - } - if (currency.type == CURRENCY_TYPE.COIN) { - return 'coin'; - } else if (currency.type == CURRENCY_TYPE.GOLD) { - return 'gold'; - } else if (currency.type == CURRENCY_TYPE.ACTION_POINT) { - return 'ap'; - } else if (currency.type == CURRENCY_TYPE.FRIEND_POINT) { - return 'frdCnt'; - } else if (currency.type == CURRENCY_TYPE.EXPEDITION_POINT) { - return 'expeditionPoint'; - } else if (currency.type == CURRENCY_TYPE.HONOUR) { - return 'honour' - } -} - export function getDropItems() { let items = [ { id: 25, count: 1 }, { id: 225, count: 1 }, { id: 625, count: 1 }, { id: 2025, count: 1 }, { id: 3025, count: 1 }, { id: 4025, count: 1 }, { id: 5025, count: 1 }, { id: 6025, count: 1 }, diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index 88569e46b..58c4df58f 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -452,7 +452,8 @@ export const FILENAME = { DIC_GK_FES: 'dic_zyz_gk_activity_festival', DIC_AP: 'dic_zyz_ap', DIC_AP_BUY_COST: 'dic_zyz_daliyAP', - DIC_GK_NEWHERO: 'dic_zyz_gk_newhero' + DIC_GK_NEWHERO: 'dic_zyz_gk_newhero', + DIC_TASK_EXP: 'dic_zyz_mainTaskExp' } export const WAR_RELATE_TABLES = [ diff --git a/shared/pubUtils/data.ts b/shared/pubUtils/data.ts index c5e9aa811..af0adbb16 100644 --- a/shared/pubUtils/data.ts +++ b/shared/pubUtils/data.ts @@ -87,6 +87,7 @@ import { dicTaskTypeDesc, loadTaskType } from './dictionary/DicTaskType'; import { dicServerName, dicServerGroupName, loadServerName } from "./dictionary/DicServerName"; import { dicAp, loadAp, dicApMaxLevel } from './dictionary/DicAp'; import { dicApBuy, dicApMaxBuyTimes, loadApBuy } from "./dictionary/DicApBuy"; +import { dicTaskExp, loadTskExp} from './dictionary/DicTaskExp'; export const gameData = { blurprtCompose: dicBlueprtCompose, @@ -213,7 +214,8 @@ export const gameData = { ap: dicAp, apMaxLevel: dicApMaxLevel, apBuy: dicApBuy, - apMaxBuyTimes: dicApMaxBuyTimes + apMaxBuyTimes: dicApMaxBuyTimes, + taskExp: dicTaskExp }; // 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据 @@ -815,6 +817,7 @@ function loadDatas() { loadServerName(); loadAp(); loadApBuy(); + loadTskExp(); } // 重载dicParam diff --git a/shared/pubUtils/dictionary/DicTask.ts b/shared/pubUtils/dictionary/DicTask.ts index a0d26339c..4983bcf0c 100644 --- a/shared/pubUtils/dictionary/DicTask.ts +++ b/shared/pubUtils/dictionary/DicTask.ts @@ -52,7 +52,7 @@ export interface DicDailyTask extends DicTaskBase { // 活跃 readonly point: number; // 经验基数 - readonly exp: number; + readonly exp: RewardInter; // 获得积分关联的活动id readonly addPointActivityId: number; } @@ -112,6 +112,7 @@ export function loadTask() { arrDailyTask.forEach(o => { o.taskParam = parseNumberList(o.taskParam); o.taskReward = parseGoodStr(o.taskReward); + o.exp = parseExp(o.exp); dicDailyTask.set(o.id, _.pick(o, Object.keys(DicDailyTaskKeys))); pushDicTaskType(o.taskType, TASK_FUN_TYPE.DAILY, o); }); @@ -133,4 +134,9 @@ function pushDicTaskType(taskType: number, type: number, o: any) { let newObj = _.pick(o, Object.keys(DicTaskKeys)); newObj.type = type; dicTaskType.get(taskType).push(newObj) +} + +function parseExp(exp: string) { + let [ id, count ] = parseNumberList(exp); + return {id, count} } \ No newline at end of file diff --git a/shared/pubUtils/dictionary/DicTaskExp.ts b/shared/pubUtils/dictionary/DicTaskExp.ts new file mode 100644 index 000000000..afb8ae7f7 --- /dev/null +++ b/shared/pubUtils/dictionary/DicTaskExp.ts @@ -0,0 +1,20 @@ +// 任务奖励主公经验 +import {readFileAndParse, parseGoodStr} from '../util' +import { FILENAME, TASK_FUN_TYPE } from '../../consts' + +export interface DicTaskExp { + // 主公等级 + readonly lv: number; + // 主公经验 + readonly exp: number; +} + +export const dicTaskExp = new Map(); +export function loadTskExp() { + + let arr1 = readFileAndParse(FILENAME.DIC_TASK_EXP); + arr1.forEach(o => { + dicTaskExp.set(o.lv, o.exp); + }); + arr1 = undefined; +} \ No newline at end of file