装备
This commit is contained in:
@@ -13,6 +13,7 @@ import { calPlayerCeAndSave } from "../../../services/playerCeService";
|
|||||||
import { getHeroJob, getGoodById, gameData, getJewelById, getHeroEquipByClassId } from "../../../pubUtils/data";
|
import { getHeroJob, getGoodById, gameData, getJewelById, getHeroEquipByClassId } from "../../../pubUtils/data";
|
||||||
import { EQUIP } from "../../../pubUtils/dicParam";
|
import { EQUIP } from "../../../pubUtils/dicParam";
|
||||||
import { ITID, SPEICAL_ITEM, RANDOM_SE_COUNT } from "../../../consts/constModules/itemConst";
|
import { ITID, SPEICAL_ITEM, RANDOM_SE_COUNT } from "../../../consts/constModules/itemConst";
|
||||||
|
import { changeEquip } from "../../../services/equipService";
|
||||||
|
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
|
|
||||||
@@ -426,8 +427,8 @@ export class EquipHandler {
|
|||||||
if (!hero)
|
if (!hero)
|
||||||
return resResult(STATUS.HERO_NOT_FIND);
|
return resResult(STATUS.HERO_NOT_FIND);
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
if (!!equip.hid)
|
if (equip.hid == hid)
|
||||||
return resResult(STATUS.EQUIP_IS_EQUIPED);
|
return resResult(STATUS.WRONG_PARMS);
|
||||||
if (goodInfo.lvLimited > hero.lv)
|
if (goodInfo.lvLimited > hero.lv)
|
||||||
return resResult(STATUS.EQUIP_LEVEL_LIMIT);
|
return resResult(STATUS.EQUIP_LEVEL_LIMIT);
|
||||||
let { jobid } = gameData.hero.get(hid);
|
let { jobid } = gameData.hero.get(hid);
|
||||||
@@ -439,12 +440,11 @@ export class EquipHandler {
|
|||||||
if (index < 0)
|
if (index < 0)
|
||||||
return resResult(STATUS.WRONG_PARMS);
|
return resResult(STATUS.WRONG_PARMS);
|
||||||
let objectId = <string>hero.ePlace[index].equip;
|
let objectId = <string>hero.ePlace[index].equip;
|
||||||
if (!!objectId) {
|
let curEquip = await changeEquip(roleId, sid, objectId, equip.hid, id, eid);
|
||||||
let {seqId, ePlaceId} = await EquipModel.updateEquipInfobyObjectId(objectId, { hid: 0, ePlaceId: 0 });
|
if (!!curEquip)
|
||||||
curEquips.push({ seqId, hid, ePlaceId });
|
curEquips.push(curEquip);
|
||||||
}
|
hero = await HeroModel.addEquip(roleId, hid, id, equip._id);
|
||||||
await HeroModel.addEquip(roleId, hid, id, equip._id);
|
await calPlayerCeAndSave(sid, roleId, [hero]);
|
||||||
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EQUIP, []);
|
|
||||||
curEquips.push({ seqId: eid, hid, ePlaceId:id});
|
curEquips.push({ seqId: eid, hid, ePlaceId:id});
|
||||||
} else if (type == 2) {
|
} else if (type == 2) {
|
||||||
if (!equip.hid)
|
if (!equip.hid)
|
||||||
@@ -453,9 +453,8 @@ export class EquipHandler {
|
|||||||
if (index < 0)
|
if (index < 0)
|
||||||
return resResult(STATUS.WRONG_PARMS);
|
return resResult(STATUS.WRONG_PARMS);
|
||||||
hero.ePlace[index].equip = null;
|
hero.ePlace[index].equip = null;
|
||||||
//await HeroModel.updateHeroInfo(roleId, hid, { ePlace: hero.ePlace });
|
|
||||||
let {seqId, ePlaceId} = await EquipModel.updateEquipInfo(eid, { hid: 0, ePlaceId: 0 });
|
let {seqId, ePlaceId} = await EquipModel.updateEquipInfo(eid, { hid: 0, ePlaceId: 0 });
|
||||||
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EQUIP, []);
|
await calPlayerCeAndSave(sid, roleId, [hero]);
|
||||||
curEquips.push({ seqId, hid, ePlaceId });
|
curEquips.push({ seqId, hid, ePlaceId });
|
||||||
}
|
}
|
||||||
return resResult(STATUS.SUCCESS, { curEquips: curEquips });
|
return resResult(STATUS.SUCCESS, { curEquips: curEquips });
|
||||||
|
|||||||
@@ -6,8 +6,12 @@ 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 { handleCost } from '../../../services/rewardService';
|
||||||
import { getTitle } from '../../../pubUtils/data'
|
import { getTitle, getTeraph } from '../../../pubUtils/data';
|
||||||
|
import { SSL_OP_SSLEAY_080_CLIENT_DH_BUG } from 'constants';
|
||||||
|
import { getTeraphAttr } from '../../../consts/constModules/abilityConst'
|
||||||
|
const _ = require('underscore');
|
||||||
|
|
||||||
export default function(app: Application) {
|
export default function(app: Application) {
|
||||||
return new RoleHandler(app);
|
return new RoleHandler(app);
|
||||||
}
|
}
|
||||||
@@ -75,12 +79,10 @@ export class RoleHandler {
|
|||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
let role = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
let sid: string = session.get('sid');
|
let sid: string = session.get('sid');
|
||||||
|
let title = ++role.title;
|
||||||
let titleInfo = getTitle(role.title);
|
let titleInfo = getTitle(role.title);
|
||||||
if (!titleInfo)
|
if (!titleInfo)
|
||||||
return resResult(STATUS.DIC_DATA_NOT_FOUND)
|
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)
|
if (titleInfo.lvLimited > role.lv)
|
||||||
return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH)
|
return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH)
|
||||||
let consumes = titleInfo.material;
|
let consumes = titleInfo.material;
|
||||||
@@ -91,4 +93,75 @@ export class RoleHandler {
|
|||||||
return resResult(STATUS.SUCCESS, { roleId, title });
|
return resResult(STATUS.SUCCESS, { roleId, title });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//神像强化
|
||||||
|
async roleTeraphStrengthen(msg: {id: number, type: number}, session: BackendSession){
|
||||||
|
let {id, type} = msg;
|
||||||
|
let roleId = session.get('roleId');
|
||||||
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
|
let sid: string = session.get('sid');
|
||||||
|
let index = _.findIndex(role.teraphs, {id});
|
||||||
|
if (index < 0)
|
||||||
|
return resResult(STATUS.WRONG_PARMS);
|
||||||
|
let teraph = role.teraphs[index];
|
||||||
|
let teraphInfo = getTeraph(id, teraph.grade);
|
||||||
|
if (!teraphInfo)
|
||||||
|
return resResult(STATUS.DIC_DATA_NOT_FOUND)
|
||||||
|
let falg = true;
|
||||||
|
for (let attrName in getTeraphAttr()) {
|
||||||
|
if (teraph[attrName] != teraphInfo[attrName]) {
|
||||||
|
falg = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!!falg)
|
||||||
|
return resResult(STATUS.ROLE_TERAPH_NOT_STRENGTHEN);
|
||||||
|
//TODO强化属性
|
||||||
|
let consumes;
|
||||||
|
if (type == 1) {
|
||||||
|
consumes = teraphInfo.upMaterial;
|
||||||
|
} else if (type == 2) {
|
||||||
|
consumes = teraphInfo.upMaterial;
|
||||||
|
} else {
|
||||||
|
return resResult(STATUS.WRONG_PARMS);
|
||||||
|
}
|
||||||
|
let result = await handleCost(roleId, sid, consumes);
|
||||||
|
if (!result)
|
||||||
|
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||||
|
await RoleModel.updateRoleInfo(roleId, { teraphs: role.teraphs });
|
||||||
|
return resResult(STATUS.SUCCESS, { roleId, teraphs: role.teraphs });
|
||||||
|
}
|
||||||
|
|
||||||
|
//神像进阶
|
||||||
|
async roleTeraphQualityUp(msg: {id: number}, session: BackendSession){
|
||||||
|
let {id} = msg;
|
||||||
|
let roleId = session.get('roleId');
|
||||||
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
|
let sid: string = session.get('sid');
|
||||||
|
let index = _.findIndex(role.teraphs, {id});
|
||||||
|
if (index < 0)
|
||||||
|
return resResult(STATUS.WRONG_PARMS);
|
||||||
|
let teraph = role.teraphs[index];
|
||||||
|
let teraphInfo = getTeraph(id, teraph.grade);
|
||||||
|
if (!teraphInfo)
|
||||||
|
return resResult(STATUS.DIC_DATA_NOT_FOUND)
|
||||||
|
for (let attrName in getTeraphAttr()) {
|
||||||
|
if (teraph[attrName] != teraphInfo[attrName])
|
||||||
|
return resResult(STATUS.ROLE_TERAPH_NOT_QUILITY);
|
||||||
|
}
|
||||||
|
teraph.grade++;
|
||||||
|
teraph.atk = 0;
|
||||||
|
teraph.agi = 0;
|
||||||
|
teraph.def = 0;
|
||||||
|
teraph.hp = 0;
|
||||||
|
teraph.luk = 0;
|
||||||
|
teraph.mdef = 0;
|
||||||
|
if (getTeraph(index, teraph.grade))
|
||||||
|
return resResult(STATUS.DIC_DATA_NOT_FOUND)
|
||||||
|
let consumes = teraphInfo.upGradeMaterial;
|
||||||
|
let result = await handleCost(roleId, sid, consumes);
|
||||||
|
if (!result)
|
||||||
|
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||||
|
await RoleModel.updateRoleInfo(roleId, { teraphs: role.teraphs });
|
||||||
|
return resResult(STATUS.SUCCESS, { roleId, teraphs: role.teraphs });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import { mergeSameGoods } from '../pubUtils/util';
|
import { mergeSameGoods } from '../pubUtils/util';
|
||||||
import { getGoodById } from '../pubUtils/gamedata';
|
import { EquipModel } from "../db/Equip";
|
||||||
import { getJewelById } from '../pubUtils/data';
|
import { HeroModel, EPlace } from "../db/Hero";
|
||||||
|
import { ITID } from "../consts/constModules/itemConst";
|
||||||
|
import { getHeroJob, getGoodById, gameData, getJewelById, getHeroEquipByClassId } from "../pubUtils/data";
|
||||||
|
import { calPlayerCeAndSave } from "./playerCeService";
|
||||||
|
import { HERO_SYSTEM_TYPE } from "../consts";
|
||||||
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) {
|
||||||
@@ -33,3 +37,47 @@ export function checkMaterialEnough(consumes:Array<{id: number, count: number}>,
|
|||||||
return false;
|
return false;
|
||||||
return needConsumes;
|
return needConsumes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function changeEquip(roleId: string, sid: string, objectId: string, hid: number, id: number, seqId: number) {
|
||||||
|
let hero;
|
||||||
|
if (!!hid)
|
||||||
|
hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||||
|
if (!!objectId) {
|
||||||
|
let equip = await EquipModel.getEquipByObjectId(objectId);
|
||||||
|
if (!!hero) {
|
||||||
|
let goodInfo = getGoodById(equip.id);
|
||||||
|
let obj = ITID.get(goodInfo.itid);
|
||||||
|
let ePlaceId = obj.type;
|
||||||
|
if (goodInfo.lvLimited > hero.lv)
|
||||||
|
return takeOffEquip(objectId);
|
||||||
|
let { jobid } = gameData.hero.get(hid);
|
||||||
|
let { job_class } = getHeroJob(jobid);
|
||||||
|
let { classId } = getHeroEquipByClassId(goodInfo.itid);
|
||||||
|
if (_.indexOf(classId, job_class) < 0)
|
||||||
|
return takeOffEquip(objectId);
|
||||||
|
hero = await HeroModel.addEquip(roleId, hero.hid, ePlaceId, objectId);
|
||||||
|
// await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EQUIP, []);
|
||||||
|
if (!!hero) {
|
||||||
|
await calPlayerCeAndSave(sid, roleId, [hero]);
|
||||||
|
let ePlaces = <EPlace>hero.ePlace;
|
||||||
|
let ePlace= _.findWhere(ePlaces,{ id: ePlaceId });
|
||||||
|
return {seqId: ePlace.equip.seqId, hid, ePlaceId};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return takeOffEquip(objectId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!!hero) {
|
||||||
|
let index = _.findIndex(hero.ePlace, { id });
|
||||||
|
if (index < 0)
|
||||||
|
return;
|
||||||
|
hero.ePlace[index].equip = null;
|
||||||
|
await EquipModel.updateEquipInfo(seqId, { hid: 0, ePlaceId: 0 });
|
||||||
|
await calPlayerCeAndSave(sid, roleId, [hero]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function takeOffEquip(objectId: string) {
|
||||||
|
let {seqId, ePlaceId} = await EquipModel.updateEquipInfobyObjectId(objectId, { hid: 0, ePlaceId: 0 });
|
||||||
|
return { seqId, hid: 0, ePlaceId};
|
||||||
|
}
|
||||||
@@ -125,7 +125,14 @@ export const JEWEL_ATTR = {
|
|||||||
5: "agi",
|
5: "agi",
|
||||||
6: "luk"
|
6: "luk"
|
||||||
}
|
}
|
||||||
|
const BASE_ATTR = {
|
||||||
|
'hp' : 1 ,
|
||||||
|
'atk' : 2,
|
||||||
|
'def' : 3,
|
||||||
|
'mdef' : 4,
|
||||||
|
'agi' : 5,
|
||||||
|
'luk' : 6
|
||||||
|
}
|
||||||
export const ABI_TYPE_TO_STAGE = new Map<number, number | ((jobType: number) => number)>([
|
export const ABI_TYPE_TO_STAGE = new Map<number, number | ((jobType: number) => number)>([
|
||||||
[ABI_STAGE.HP, ABI_TYPE.ABI_HP],
|
[ABI_STAGE.HP, ABI_TYPE.ABI_HP],
|
||||||
[ABI_STAGE.ATK, (jobType:number) => { return jobType == JOB_TYPE.PHYSIC?ABI_TYPE.ABI_ATK: ABI_TYPE.ABI_MATK}],
|
[ABI_STAGE.ATK, (jobType:number) => { return jobType == JOB_TYPE.PHYSIC?ABI_TYPE.ABI_ATK: ABI_TYPE.ABI_MATK}],
|
||||||
@@ -140,10 +147,13 @@ export function getAtrrNameById(attrId: number):string {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function getAttrCeRatio(attr: string):number {
|
export function getAttrCeRatio(attr: string):number {
|
||||||
return CE_RATIO[attr];
|
return ;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getAttrNameByJobStage(jobStage: number) {
|
export function getAttrNameByJobStage(jobStage: number) {
|
||||||
return HEROTARIN[jobStage];
|
return HEROTARIN[jobStage];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function getTeraphAttr() {
|
||||||
|
return BASE_ATTR;
|
||||||
|
};
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ export const CONSUME_TYPE = {
|
|||||||
JEWEL: 9, //宝石
|
JEWEL: 9, //宝石
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export enum ROLE_TERAPH {
|
||||||
|
START = 1,
|
||||||
|
END = 4
|
||||||
|
}
|
||||||
|
|
||||||
export enum EQUIP_TYPE {
|
export enum EQUIP_TYPE {
|
||||||
START = 1,
|
START = 1,
|
||||||
WEAPON = 1, // 神兵(武器)
|
WEAPON = 1, // 神兵(武器)
|
||||||
|
|||||||
@@ -88,7 +88,8 @@ export const FILENAME = {
|
|||||||
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'
|
DIC_TITLE: 'dic_zyz_title',
|
||||||
|
DIC_TERAPH: 'dic_zyz_teraph',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WAR_RELATE_TABLES = [
|
export const WAR_RELATE_TABLES = [
|
||||||
|
|||||||
@@ -288,6 +288,7 @@ export const COM_TEAM_STATUS = {
|
|||||||
LOOSE: 3
|
LOOSE: 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 寻宝配置常量
|
// 寻宝配置常量
|
||||||
export const COM_BTL_CONST = {
|
export const COM_BTL_CONST = {
|
||||||
ENABLE_LV: 1, // 功能开启等级
|
ENABLE_LV: 1, // 功能开启等级
|
||||||
|
|||||||
@@ -170,7 +170,8 @@ export const STATUS = {
|
|||||||
EQUIP_NOT_MATCH_JEWEL: {code: 30504, simStr: '装备不能镶嵌该宝石' },
|
EQUIP_NOT_MATCH_JEWEL: {code: 30504, simStr: '装备不能镶嵌该宝石' },
|
||||||
//全局养成30500-30699
|
//全局养成30500-30699
|
||||||
ROLE_REACH_MAX_TITLE_LEVEL: {code: 30500, simStr: '玩家已达到最高的爵位'},
|
ROLE_REACH_MAX_TITLE_LEVEL: {code: 30500, simStr: '玩家已达到最高的爵位'},
|
||||||
|
ROLE_TERAPH_NOT_STRENGTHEN: {code: 30501, simStr: '玩家神像不能强化'},
|
||||||
|
ROLE_TERAPH_NOT_QUILITY: {code: 30502, simStr: '玩家神像不能进阶'},
|
||||||
|
|
||||||
// 社交相关状态 40000 - 49999
|
// 社交相关状态 40000 - 49999
|
||||||
// 运营模块相关状态 50000 - 59999
|
// 运营模块相关状态 50000 - 59999
|
||||||
|
|||||||
@@ -134,6 +134,11 @@ export default class Equip extends BaseModel {
|
|||||||
let result: EquipType = await EquipModel.findOneAndUpdate({_id}, {$set: equipUpdate}, {new: true}).lean(lean);
|
let result: EquipType = await EquipModel.findOneAndUpdate({_id}, {$set: equipUpdate}, {new: true}).lean(lean);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async getEquipByObjectId(_id: string) {
|
||||||
|
let equip: EquipType = await EquipModel.findOne({ _id });
|
||||||
|
return equip;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const EquipModel = getModelForClass(Equip);
|
export const EquipModel = getModelForClass(Equip);
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ export default class Hero extends BaseModel {
|
|||||||
const hero: HeroType = await HeroModel.findOneAndUpdate(
|
const hero: HeroType = await HeroModel.findOneAndUpdate(
|
||||||
{ roleId, hid, 'ePlace.id': ePlaceId },
|
{ roleId, hid, 'ePlace.id': ePlaceId },
|
||||||
{$set: {'ePlace.$.equip': equipId, 'ePlace.$.hid':hid, 'ePlace.$.ePlaceId':ePlaceId}},
|
{$set: {'ePlace.$.equip': equipId, 'ePlace.$.hid':hid, 'ePlace.$.ePlaceId':ePlaceId}},
|
||||||
{new: true}).lean(lean);
|
{new: true}).populate('ePlace.equip').lean(lean);
|
||||||
if (hero) {
|
if (hero) {
|
||||||
await Equip.putOn(hero.hid, equipId);
|
await Equip.putOn(hero.hid, equipId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { HANG_UP_CONSTS } from './../consts';
|
import { HANG_UP_CONSTS, ROLE_TERAPH } from './../consts';
|
||||||
import BaseModel from './BaseModel';
|
import BaseModel from './BaseModel';
|
||||||
import { CeAttr } from './generalField';
|
import { CeAttr } from './generalField';
|
||||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||||
@@ -14,6 +14,7 @@ interface roleUpdate {
|
|||||||
expeditionPoint?:number;
|
expeditionPoint?:number;
|
||||||
globalCeAttr?:CeAttr;
|
globalCeAttr?:CeAttr;
|
||||||
title?:number;
|
title?:number;
|
||||||
|
teraphs?: Teraph[];
|
||||||
}
|
}
|
||||||
|
|
||||||
class TopHero {
|
class TopHero {
|
||||||
@@ -47,6 +48,41 @@ class WarStar {
|
|||||||
star: number; // 星级
|
star: number; // 星级
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Teraph{
|
||||||
|
@prop({ required: true, default: 1 })
|
||||||
|
id: number; // 神像的id
|
||||||
|
@prop({ required: true, default: 1 })
|
||||||
|
grade: number; // 等级
|
||||||
|
@prop({ required: true, default: 0 })
|
||||||
|
hp: number;
|
||||||
|
@prop({ required: true, default: 0 })
|
||||||
|
atk: number;
|
||||||
|
@prop({ required: true, default: 0 })
|
||||||
|
def: number;
|
||||||
|
@prop({ required: true, default: 0 })
|
||||||
|
mdef: number;
|
||||||
|
@prop({ required: true, default: 0 })
|
||||||
|
agi: number;
|
||||||
|
@prop({ required: true, default: 0 })
|
||||||
|
luk: number;
|
||||||
|
}
|
||||||
|
// 初始化
|
||||||
|
function getInitialTeraph() {
|
||||||
|
let teraphs = new Array<Teraph>();
|
||||||
|
for(let i = ROLE_TERAPH.START; i <= ROLE_TERAPH.END; i++) {
|
||||||
|
let p = new Teraph();
|
||||||
|
p.id = i;
|
||||||
|
p.grade = 1;
|
||||||
|
p.hp = 0;
|
||||||
|
p.atk = 0;
|
||||||
|
p.def = 0;
|
||||||
|
p.mdef = 0;
|
||||||
|
p.agi = 0;
|
||||||
|
p.luk = 0;
|
||||||
|
teraphs.push(p);
|
||||||
|
}
|
||||||
|
return teraphs;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 角色字段接口
|
* 角色字段接口
|
||||||
*/
|
*/
|
||||||
@@ -173,7 +209,8 @@ export default class Role extends BaseModel {
|
|||||||
@prop({ required: true, default: 1 })
|
@prop({ required: true, default: 1 })
|
||||||
title: number; //爵位
|
title: number; //爵位
|
||||||
//神像
|
//神像
|
||||||
|
@prop({ required: true, type: Teraph, default: getInitialTeraph() })
|
||||||
|
teraphs:Array<Teraph>;
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ 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'
|
import { dicTitle } from './dictionary/DicTitle';
|
||||||
|
import { dicTeraph } from './dictionary/DicTeraph';
|
||||||
export const gameData = {
|
export const gameData = {
|
||||||
blurprtCompose: dicBlueprtCompose,
|
blurprtCompose: dicBlueprtCompose,
|
||||||
blueprtPossibility: dicBlueprtPossibility,
|
blueprtPossibility: dicBlueprtPossibility,
|
||||||
@@ -72,7 +73,8 @@ export const gameData = {
|
|||||||
jewels: dicJewel,
|
jewels: dicJewel,
|
||||||
dicHeroEquip: dicHeroEquip,
|
dicHeroEquip: dicHeroEquip,
|
||||||
suit: dicSuit,
|
suit: dicSuit,
|
||||||
title: dicTitle
|
title: dicTitle,
|
||||||
|
teraphs: dicTeraph
|
||||||
};
|
};
|
||||||
|
|
||||||
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
||||||
@@ -204,3 +206,8 @@ export function getTitle(titleLv: number) {
|
|||||||
const titleInfo = gameData.title.get(titleLv);
|
const titleInfo = gameData.title.get(titleLv);
|
||||||
return titleInfo;
|
return titleInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getTeraph(id: number, grade: number) {
|
||||||
|
const teraphInfo = gameData.teraphs.get(id +'_'+ grade);
|
||||||
|
return teraphInfo;
|
||||||
|
}
|
||||||
90
shared/pubUtils/dictionary/DicTeraph.ts
Normal file
90
shared/pubUtils/dictionary/DicTeraph.ts
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
// 物品表
|
||||||
|
import { decodeArrayListStr, readJsonFile, parseGoodStr } from '../util'
|
||||||
|
import { FILENAME} from '../../consts'
|
||||||
|
const _ = require('lodash');
|
||||||
|
|
||||||
|
export interface SpecialMaterial {
|
||||||
|
readonly ids: number[];
|
||||||
|
readonly count: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DicTeraph {
|
||||||
|
// 等级
|
||||||
|
readonly id: number;
|
||||||
|
readonly index: number;
|
||||||
|
readonly grade: number;
|
||||||
|
readonly hpMax: number;
|
||||||
|
readonly atkMax: number;
|
||||||
|
readonly defMax: number;
|
||||||
|
readonly mdefMax: number;
|
||||||
|
readonly agiMax: number;
|
||||||
|
readonly lukMax: number;
|
||||||
|
|
||||||
|
readonly hp;
|
||||||
|
readonly atk;
|
||||||
|
readonly def;
|
||||||
|
readonly mdef;
|
||||||
|
readonly agi;
|
||||||
|
readonly luk;
|
||||||
|
readonly criRate;
|
||||||
|
readonly criEffect;
|
||||||
|
readonly upMaterial:Array<{id: number, number: number}>;
|
||||||
|
|
||||||
|
readonly assiAttrValue: Map<number, number>;
|
||||||
|
readonly upGradeMaterial:Array<{id: number, number: number}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const str = readJsonFile(FILENAME.DIC_TERAPH);
|
||||||
|
let arr = JSON.parse(str);
|
||||||
|
|
||||||
|
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||||
|
const DicTeraphKeys: KeysEnum<DicTeraph> = {
|
||||||
|
id: true,
|
||||||
|
index: true,
|
||||||
|
grade: true,
|
||||||
|
hpMax: true,
|
||||||
|
atkMax: true,
|
||||||
|
defMax: true,
|
||||||
|
mdefMax: true,
|
||||||
|
agiMax: true,
|
||||||
|
lukMax: true,
|
||||||
|
hp: true,
|
||||||
|
atk: true,
|
||||||
|
def: true,
|
||||||
|
mdef: true,
|
||||||
|
agi: true,
|
||||||
|
luk: true,
|
||||||
|
criRate: true,
|
||||||
|
criEffect: true,
|
||||||
|
upMaterial: true,
|
||||||
|
assiAttrValue: true,
|
||||||
|
upGradeMaterial: true,
|
||||||
|
}
|
||||||
|
export const dicTeraph = new Map<string, DicTeraph>();
|
||||||
|
arr.forEach(o => {
|
||||||
|
o.assiAttrValue = parseAttr(o.assiAttrValue);
|
||||||
|
o.upGradeMaterial = parseGoodStr(o.upGradeMaterial);
|
||||||
|
o.upMaterial = parseGoodStr(o.upMaterial);
|
||||||
|
o.hp = o.hpUp;
|
||||||
|
o.atk = o.atkUp;
|
||||||
|
o.def = o.defUp;
|
||||||
|
o.mdef = o.mdefUp;
|
||||||
|
o.agi = o.agiUp;
|
||||||
|
o.luk = o.lukUp;
|
||||||
|
dicTeraph.set(o.index + '_' + o.grade, _.pick(o, Object.keys(DicTeraphKeys)));
|
||||||
|
});
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -52,7 +52,7 @@ export function calPlayerCe(globalCeAttr: CeAttr, hero: HeroType, type: number,
|
|||||||
} else if (type == HERO_SYSTEM_TYPE.JEWEL_OFF) {//宝石卸下
|
} else if (type == HERO_SYSTEM_TYPE.JEWEL_OFF) {//宝石卸下
|
||||||
reIncAttr = calHeroCeWhenJewelOff(hero, args);
|
reIncAttr = calHeroCeWhenJewelOff(hero, args);
|
||||||
} else {
|
} else {
|
||||||
reIncAttr = hero.ceAttr;
|
return incCe;
|
||||||
}
|
}
|
||||||
|
|
||||||
addSeidEffect(reIncAttr, hero.ceAttr, addSeidList, removeSeidList); // 处理加值
|
addSeidEffect(reIncAttr, hero.ceAttr, addSeidList, removeSeidList); // 处理加值
|
||||||
|
|||||||
Reference in New Issue
Block a user