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 { calculateCE, resResult } from '../../../pubUtils/util';
import {Application, BackendSession, createTcpMailBox} from 'pinus'; import {Application, BackendSession, createTcpMailBox} from 'pinus';
import { COUNTER } from '../../../consts'; import { COUNTER } from '../../../consts';
import { handleCost } from '../../../services/rewardService'
import { getTitle } from '../../../pubUtils/data'
export default function(app: Application) { export default function(app: Application) {
return new RoleHandler(app); 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); let { roleId, roleName, headHid = 1, ce = 0, topFive, topFiveCe = 0 } = await RoleModel.findByRoleId(targetRoleId);
return resResult(STATUS.SUCCESS, { roleId, roleName, headHid, ce, topFive, topFiveCe }); 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 { mergeSameGoods } from '../pubUtils/util';
import { EquipModel } from './../db/Equip';
import { resResult, deepCopy, mergeSameGoods } from '../pubUtils/util';
import { getGoodById } from '../pubUtils/gamedata'; import { getGoodById } from '../pubUtils/gamedata';
import { RoleModel } from '../db/Role'; import { getJewelById } from '../pubUtils/data';
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';
const _ = require('underscore'); const _ = require('underscore');
export function checkMaterialEnough(consumes:Array<{id: number, count: number}>, jewel: number, jewelCount: number) { export function checkMaterialEnough(consumes:Array<{id: number, count: number}>, jewel: number, jewelCount: number) {
+2 -1
View File
@@ -87,7 +87,8 @@ export const FILENAME = {
DIC_STRENGTHEN_COST: 'dic_zyz_enhancementCost', DIC_STRENGTHEN_COST: 'dic_zyz_enhancementCost',
DIC_REFINE: 'dic_zyz_jinglian', DIC_REFINE: 'dic_zyz_jinglian',
DIC_HERO_EQUIP: 'dic_zyz_heroEquip', DIC_HERO_EQUIP: 'dic_zyz_heroEquip',
DIC_SUIT: 'dic_zyz_suit' DIC_SUIT: 'dic_zyz_suit',
DIC_TITLE: 'dic_zyz_title'
} }
export const WAR_RELATE_TABLES = [ export const WAR_RELATE_TABLES = [
+4
View File
@@ -168,6 +168,10 @@ export const STATUS = {
EQUIP_NOT_EQUIPED_HERO: {code: 30507, simStr: '装备不能被该武将穿戴'}, EQUIP_NOT_EQUIPED_HERO: {code: 30507, simStr: '装备不能被该武将穿戴'},
EQUIP_LEVEL_LIMIT: {code: 30508, simStr: '装备穿戴等级限制'}, EQUIP_LEVEL_LIMIT: {code: 30508, simStr: '装备穿戴等级限制'},
EQUIP_NOT_MATCH_JEWEL: {code: 30504, simStr: '装备不能镶嵌该宝石' }, EQUIP_NOT_MATCH_JEWEL: {code: 30504, simStr: '装备不能镶嵌该宝石' },
//全局养成30500-30699
ROLE_REACH_MAX_TITLE_LEVEL: {code: 30500, simStr: '玩家已达到最高的爵位'},
// 社交相关状态 40000 - 49999 // 社交相关状态 40000 - 49999
// 运营模块相关状态 50000 - 59999 // 运营模块相关状态 50000 - 59999
// GM后台相关状态 60000 - 69999 // GM后台相关状态 60000 - 69999
+1 -1
View File
@@ -57,7 +57,7 @@ export default class Item extends BaseModel {
if (!ratio) { if (!ratio) {
rec = await ItemModel.findOneAndUpdate({ roleId, id, count: { $gte: count } }, { $inc: { count: -1 * count } }, { new: true }).lean(lean); rec = await ItemModel.findOneAndUpdate({ roleId, id, count: { $gte: count } }, { $inc: { count: -1 * count } }, { new: true }).lean(lean);
} else { } else {
rec = await ItemModel.findOneAndUpdate({ roleId, id }, { $inc: { count: ratio * count } }, { new: true }).lean(lean); rec = await ItemModel.findOneAndUpdate({ roleId, id }, { $inc: { count: ratio * count } }, { new: true, upsert: true }).lean(lean);
} }
if (!!rec) { if (!!rec) {
let index = _.findIndex(result,{id}) let index = _.findIndex(result,{id})
+7
View File
@@ -13,6 +13,7 @@ interface roleUpdate {
frdCnt?: number; frdCnt?: number;
expeditionPoint?:number; expeditionPoint?:number;
globalCeAttr?:CeAttr; globalCeAttr?:CeAttr;
title?:number;
} }
class TopHero { class TopHero {
@@ -168,6 +169,12 @@ export default class Role extends BaseModel {
@prop({ required: true, type: DungeonHero, default: [] }) @prop({ required: true, type: DungeonHero, default: [] })
dungeonHeroes: Array<DungeonHero>; // 秘境首通使用的武将 dungeonHeroes: Array<DungeonHero>; // 秘境首通使用的武将
// 全局养成
@prop({ required: true, default: 1 })
title: number; //爵位
//神像
public static async findByUid(uid: number, serverId: number, lean = true) { public static async findByUid(uid: number, serverId: number, lean = true) {
const role: RoleType = await RoleModel.findOne({ 'userInfo.uid': uid, serverId }).lean(lean); const role: RoleType = await RoleModel.findOne({ 'userInfo.uid': uid, serverId }).lean(lean);
return role; return role;
+8 -2
View File
@@ -30,7 +30,7 @@ import { dicStrengthenCost } from './dictionary/DicStrengthenCost';
import { dicRefine } from './dictionary/DicRefine'; import { dicRefine } from './dictionary/DicRefine';
import { dicHeroEquip } from './dictionary/DicHeroEquip'; import { dicHeroEquip } from './dictionary/DicHeroEquip';
import { dicSuit } from './dictionary/DicSuit'; import { dicSuit } from './dictionary/DicSuit';
import { dicTitle } from './dictionary/DicTitle'
export const gameData = { export const gameData = {
blurprtCompose: dicBlueprtCompose, blurprtCompose: dicBlueprtCompose,
blueprtPossibility: dicBlueprtPossibility, blueprtPossibility: dicBlueprtPossibility,
@@ -71,7 +71,8 @@ export const gameData = {
refine: dicRefine, refine: dicRefine,
jewels: dicJewel, jewels: dicJewel,
dicHeroEquip: dicHeroEquip, dicHeroEquip: dicHeroEquip,
suit: dicSuit suit: dicSuit,
title: dicTitle
}; };
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据 // 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
@@ -198,3 +199,8 @@ export function getHeroJob(jobId: number) {
const job = gameData.job.get(jobId); const job = gameData.job.get(jobId);
return job; return job;
} }
export function getTitle(titleLv: number) {
const titleInfo = gameData.title.get(titleLv);
return titleInfo;
}
+63
View File
@@ -0,0 +1,63 @@
// 物品表
import { decodeArrayListStr, readJsonFile, parseGoodStr } from '../util'
import { FILENAME} from '../../consts'
const _ = require('lodash');
export interface SpecialMaterial {
readonly ids: number[];
readonly count: number;
}
export interface DicTitle {
// 等级
readonly id: number;
readonly hp: number;
readonly atk: number;
readonly def: number;
readonly mdef: number;
readonly agi: number;
readonly luk: number;
readonly assiAttrValue: Map<number, number>;
// 等级现在
readonly lvLimited: number;
// 升级消耗
readonly material:Array<{id: number, number: number}>;
}
const str = readJsonFile(FILENAME.DIC_TITLE);
let arr = JSON.parse(str);
type KeysEnum<T> = { [P in keyof Required<T>]: true };
const DicTitleKeys: KeysEnum<DicTitle> = {
id: true,
hp: true,
atk: true,
def: true,
mdef: true,
agi: true,
luk: true,
assiAttrValue: true,
lvLimited: true,
material: true
}
export const dicTitle = new Map<number, DicTitle>();
arr.forEach(o => {
o.assiAttrValue = parseAttr(o.assiAttrValue);
o.material = parseGoodStr(o.material);
dicTitle.set(o.id, _.pick(o, Object.keys(DicTitleKeys)));
});
arr = undefined;
function parseAttr(str: string) {
let result = new Array<{id: number, number: number}>();
if(!str) return result;
let decodeArr = decodeArrayListStr(str);
for(let [id, number] of decodeArr) {
if(isNaN(parseInt(id)) || isNaN(parseInt(number))) {
throw new Error('data table format wrong');
}
result.push({id: parseInt(id), number: parseInt(number)});
}
return result
}