This commit is contained in:
mamengke01
2020-12-24 16:38:07 +08:00
parent 884e759921
commit 526ed39feb
9 changed files with 418 additions and 324 deletions
@@ -6,7 +6,8 @@ import { EquipModel } from '../../../db/Equip';
import { calculateCE, resResult } from '../../../pubUtils/util';
import {Application, BackendSession, createTcpMailBox} from 'pinus';
import { COUNTER } from '../../../consts';
import { handleCost } from '../../../services/rewardService'
import { getTitle } from '../../../pubUtils/data'
export default function(app: Application) {
return new RoleHandler(app);
}
@@ -68,4 +69,26 @@ export class RoleHandler {
let { roleId, roleName, headHid = 1, ce = 0, topFive, topFiveCe = 0 } = await RoleModel.findByRoleId(targetRoleId);
return resResult(STATUS.SUCCESS, { roleId, roleName, headHid, ce, topFive, topFiveCe });
}
//爵位
async roleTitleLevelUp(msg: {}, session: BackendSession){
let roleId = session.get('roleId');
let role = await RoleModel.findByRoleId(roleId);
let sid: string = session.get('sid');
let titleInfo = getTitle(role.title);
if (!titleInfo)
return resResult(STATUS.DIC_DATA_NOT_FOUND)
let title = ++role.title;
if (!getTitle(title))
return resResult(STATUS.ROLE_REACH_MAX_TITLE_LEVEL)
if (titleInfo.lvLimited > role.lv)
return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH)
let consumes = titleInfo.material;
let result = await handleCost(roleId, sid, consumes);
if (!result)
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
await RoleModel.updateRoleInfo(roleId, { title });
return resResult(STATUS.SUCCESS, { roleId, title });
}
}
+2 -12
View File
@@ -1,16 +1,6 @@
import { ITID, CONSUME_TYPE, getCurNameById, ITEM_TABLE } from './../consts';
import { EquipModel } from './../db/Equip';
import { resResult, deepCopy, mergeSameGoods } from '../pubUtils/util';
import { mergeSameGoods } from '../pubUtils/util';
import { getGoodById } from '../pubUtils/gamedata';
import { RoleModel } from '../db/Role';
import { setAp } from './actionPointService';
import { calAllHeroCe } from './playerCeService';
import { ItemModel } from '../db/Item';
import { STATUS } from '../consts/statusCode';
import { pinus } from 'pinus';
import { addEquips, addBags, addSkins } from '../pubUtils/itemUtils';
import { EquipInter, ItemInter, BagInter } from '../pubUtils/interface';
import { gameData, getJewelById } from '../pubUtils/data';
import { getJewelById } from '../pubUtils/data';
const _ = require('underscore');
export function checkMaterialEnough(consumes:Array<{id: number, count: number}>, jewel: number, jewelCount: number) {