武将战力计算(进阶,穿戴,羁绊,好感)加道具
This commit is contained in:
@@ -287,7 +287,7 @@ export class HeroHandler {
|
||||
}
|
||||
hero.jobStage = hero.jobStage ++;
|
||||
//重算战力并下发
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero]);
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.TRAIN);
|
||||
return resResult(STATUS.SUCCESS, { hid : heros[0].hid, job : heros[0].job, jobStage : heros[0].jobStage});
|
||||
}
|
||||
|
||||
@@ -299,11 +299,12 @@ export class HeroHandler {
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId, false);
|
||||
if (!hero)
|
||||
return resResult(STATUS.HERO_NOT_FIND);
|
||||
let heroJob = getJobInfoById(hero.job);
|
||||
let curJob = hero.job;
|
||||
let heroJob = getJobInfoById(curJob);
|
||||
let nextHeroJob = getJobByGradeAndClass(heroJob.job_class, heroJob.grade + 1);
|
||||
if (nextHeroJob.unlockLevel > hero.lv)
|
||||
return resResult(STATUS.NOT_REACH_UNLOCK_LEVEL);
|
||||
if (hero.job >= getMaxGradeByjobClass(heroJob.job_class))
|
||||
if (curJob >= getMaxGradeByjobClass(heroJob.job_class))
|
||||
return resResult(STATUS.HERO_JOB_REACH_MAX_STAGE);
|
||||
let cousumeGoods = getItems(heroJob.upGradeConsume);
|
||||
let result = await handleCost(roleId, sid, cousumeGoods);
|
||||
@@ -313,7 +314,7 @@ export class HeroHandler {
|
||||
hero.job = nextHeroJob.jobid;
|
||||
hero.jobStage = 0;
|
||||
//重算战力并下发
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero]);
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.STAGEUP, [curJob]);
|
||||
return resResult(STATUS.SUCCESS, { hid : heros[0].hid, job : heros[0].job, jobStage : heros[0].jobStage});
|
||||
}
|
||||
|
||||
@@ -330,7 +331,7 @@ export class HeroHandler {
|
||||
return resResult(STATUS.HERO_NOT_FIND);
|
||||
let flag = true;
|
||||
let level = 1;
|
||||
for (let conection of hero.conections) {
|
||||
for (let conection of hero.connections) {
|
||||
if (conection.shipId == shipId ) {
|
||||
if (conection.level >= shipHidAndLevel.level) {
|
||||
return resResult(STATUS.HERO_CONECTION_IS_MAX_LEVEL);
|
||||
@@ -342,7 +343,7 @@ export class HeroHandler {
|
||||
}
|
||||
}
|
||||
if (!!flag) {
|
||||
hero.conections.push({shipId,level});
|
||||
hero.connections.push({shipId, level});
|
||||
}
|
||||
let friendShip = getFriendShipById(shipId, level);
|
||||
if (hero.star < friendShip.level)
|
||||
@@ -362,8 +363,8 @@ export class HeroHandler {
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
}
|
||||
//重算战力并下发
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero]);
|
||||
return resResult(STATUS.SUCCESS, { hid : heros[0].hid, conections : heros[0].conections});
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.CONNECT, [shipId, level]);
|
||||
return resResult(STATUS.SUCCESS, { hid : heros[0].hid, connections : heros[0].connections});
|
||||
}
|
||||
|
||||
//赠送(包括一键赠送)
|
||||
@@ -372,6 +373,7 @@ export class HeroHandler {
|
||||
let sid: string = session.get('sid');
|
||||
let { hid, items } = msg;
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId, false);
|
||||
let lastLv = hero.favourLv;
|
||||
if (!hero)
|
||||
return resResult(STATUS.HERO_NOT_FIND);
|
||||
let friendShipLevels = getFriendShipLevels();
|
||||
@@ -401,8 +403,12 @@ export class HeroHandler {
|
||||
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
}
|
||||
//重算战力并下发
|
||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero]);
|
||||
return resResult(STATUS.SUCCESS, { hid : heros[0].hid, favour : heros[0].favour, favourLv : heros[0].favourLv});
|
||||
if (lastLv != hero.favourLv) {
|
||||
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.FAVOUR, [lastLv]);
|
||||
} else {
|
||||
await HeroModel.updateHeroInfo(roleId, hero.hid, hero);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { hid : hero.hid, favour : hero.favour, favourLv : hero.favourLv});
|
||||
}
|
||||
|
||||
//穿带时装
|
||||
@@ -417,18 +423,25 @@ export class HeroHandler {
|
||||
if (!hero)
|
||||
return resResult(STATUS.HERO_NOT_FIND);
|
||||
let result = false;
|
||||
let lastSkinId;
|
||||
for (let skin of hero.skins) {
|
||||
if (skin.id == id) {
|
||||
if (!!skin.enable) {
|
||||
return resResult(STATUS.HERO_SKIN_IS_EQUIPED);
|
||||
}
|
||||
skin.enable = true;
|
||||
result = true;
|
||||
} else {
|
||||
if (!!skin.enable) {
|
||||
lastSkinId = skin.id;
|
||||
}
|
||||
skin.enable = false;
|
||||
}
|
||||
}
|
||||
if (!result) {
|
||||
return resResult(STATUS.HERO_SKIN_NOT_FIND);
|
||||
}
|
||||
await calPlayerCeAndSave(sid, roleId, [hero]);
|
||||
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.SKIN, [id, lastSkinId]);
|
||||
return resResult(STATUS.SUCCESS, { hid : hero.hid, skins : hero.skins});
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,15 @@ import { HERO_SYSTEM_TYPE } from '../consts/consts';
|
||||
import { pinus } from 'pinus';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
|
||||
import { resResult } from '../pubUtils/util';
|
||||
import { resResult, deepCopy } from '../pubUtils/util';
|
||||
import Hero from '../db/Hero';
|
||||
import { RoleModel } from '../db/Role';
|
||||
import { CeAttrData, CeAttr } from '../db/BaseModel';
|
||||
import { getJobInfoById, getJobByGradeAndClass, getHeroInfoById, getHeroStar, getHeroWake, getFiendShipLevel, getFriendShipById, getHeroSkillById, getSeidById } from '../pubUtils/gamedata';
|
||||
import { getFashionsById, getJobInfoById, getJobByGradeAndClass, getHeroInfoById, getHeroStar, getHeroWake, getFiendShipLevel, getFriendShipById, getHeroSkillById, getSeidById } from '../pubUtils/gamedata';
|
||||
import { getAttrNameByJobStage, getAttrCeRatio, getAtrrNameById, ABI_TYPE_TO_STAGE, ABI_STAGE, SEID_TYPE, HERO_ATTR} from '../consts/abilityConst';
|
||||
import { SSL_OP_SSLEAY_080_CLIENT_DH_BUG } from 'constants';
|
||||
const HERO_CE_RATIO = 100;
|
||||
const _ = require('underscore');
|
||||
//战力计算TODO
|
||||
export function calPlayerCe(hero: any, type: number, args: Array<number>) {
|
||||
let incCe = 0;
|
||||
@@ -26,6 +28,14 @@ export function calPlayerCe(hero: any, type: number, args: Array<number>) {
|
||||
reIncAttr = calHeroStarIncAttr(hero, args, addSeidList, removeSeidList); // args: 升的星盘
|
||||
} else if (type == HERO_SYSTEM_TYPE.TRAIN) {
|
||||
reIncAttr = calHeroTrainIncAttr(hero);
|
||||
} else if (type == HERO_SYSTEM_TYPE.STAGEUP) {
|
||||
reIncAttr = calHeroJobStageUpIncAttr(hero, args, addSeidList, removeSeidList )
|
||||
} else if (type == HERO_SYSTEM_TYPE.SKIN) {
|
||||
reIncAttr = calWaerHeroSkinIncAttr(hero, args);
|
||||
} else if (type == HERO_SYSTEM_TYPE.FAVOUR) {
|
||||
reIncAttr = calHeroFavourUpIncAttr(hero, args);
|
||||
} else if (type == HERO_SYSTEM_TYPE.CONNECT) {
|
||||
reIncAttr = calHeroConectIncAttr(hero, args);
|
||||
}
|
||||
|
||||
addSeidEffect(reIncAttr, addSeidList, removeSeidList); // 处理加值
|
||||
@@ -123,7 +133,7 @@ export function getAllAttrStage () {
|
||||
};
|
||||
return attrs;
|
||||
}
|
||||
|
||||
//训练
|
||||
export function calHeroTrainIncAttr(hero: any) {
|
||||
let res = {};
|
||||
let attrName: string = getAttrNameByJobStage(hero.jobStage);
|
||||
@@ -138,25 +148,82 @@ export function calHeroTrainIncAttr(hero: any) {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
export function calHeroJobStageUpIncAttr(hero: any) {
|
||||
//进阶
|
||||
export function calHeroJobStageUpIncAttr(hero: any, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number> ) {
|
||||
let res = {};
|
||||
|
||||
let lastJob = getJobInfoById(args[0]);
|
||||
let currentJob = getJobInfoById(hero.job);
|
||||
addSeidList.concat(deepCopy(currentJob.seids));
|
||||
for (let seid of lastJob.seids) {
|
||||
let index = _.indexOf(currentJob.seids, seid);
|
||||
if (index > 0) {
|
||||
addSeidList.splice(index, 1);
|
||||
} else {
|
||||
removeSeidList.push(seid);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
//穿戴时装
|
||||
export function calWaerHeroSkinIncAttr(hero: any, args: Array<number>) {
|
||||
let res = {};
|
||||
let addSkin = getFashionsById(args[0]);
|
||||
let delSkin = getFashionsById(args[1]);
|
||||
let attrName;
|
||||
for (let attr of delSkin.actorAttrs) {
|
||||
attrName = getAtrrNameById(attr.id);
|
||||
res[attrName] = {fixUp: hero.CeAttr[attrName].fixUp, base: hero.CeAttr[attrName].base, ratioUp: hero.CeAttr[attrName].ratioUp};
|
||||
res[attrName].fixUp += attr.number * HERO_CE_RATIO;
|
||||
}
|
||||
for (let attr of addSkin.actorAttrs) {
|
||||
attrName = getAtrrNameById(attr.id);
|
||||
res[attrName] = {fixUp: hero.CeAttr[attrName].fixUp, base: hero.CeAttr[attrName].base, ratioUp: hero.CeAttr[attrName].ratioUp};
|
||||
res[attrName].fixUp -= attr.number * HERO_CE_RATIO;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
export function calWaerHeroSkinIncAttr(hero: any) {
|
||||
//羁绊解锁
|
||||
export function calHeroConectIncAttr(hero: any, args: Array<number>) {
|
||||
let res = {};
|
||||
let friendShipLevel = getFiendShipLevel(hero.favourLv);
|
||||
hero.conections.forEach(element => {
|
||||
let reFriendShip = getFriendShipById(element.shipId, element.level);
|
||||
if (reFriendShip)
|
||||
getAtrrNameById(reFriendShip);
|
||||
});
|
||||
if (hero.favourLv > 1) {
|
||||
|
||||
} else {
|
||||
let fiendShipLevel = getFiendShipLevel(hero.favourLv);
|
||||
let shipId = args[0];//当前升级的羁绊序号
|
||||
let level = args[1];//当前升级的羁绊等级
|
||||
let attrName;
|
||||
let currentShip = getFriendShipById(shipId, level);
|
||||
for (let attr of currentShip.attributes) {
|
||||
attrName = getAtrrNameById(attr.id);
|
||||
res[attrName] = {fixUp: hero.CeAttr[attrName].fixUp, base: hero.CeAttr[attrName].base, ratioUp: hero.CeAttr[attrName].ratioUp};
|
||||
res[attrName].fixUp += attr.number * (HERO_CE_RATIO + fiendShipLevel.add);
|
||||
}
|
||||
if (level > 1) {
|
||||
let lastShip = getFriendShipById(shipId, level - 1);
|
||||
for (let attr of lastShip.attributes) {
|
||||
attrName = getAtrrNameById(attr.id);
|
||||
res[attrName] = {fixUp: hero.CeAttr[attrName].fixUp, base: hero.CeAttr[attrName].base, ratioUp: hero.CeAttr[attrName].ratioUp};
|
||||
res[attrName].fixUp -= attr.number * (HERO_CE_RATIO + fiendShipLevel.add);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
//好感升级
|
||||
export function calHeroFavourUpIncAttr(hero: any, args: Array<number>) {
|
||||
let res = {};
|
||||
let currentFiendShipLevel = getFiendShipLevel(hero.favourLv);
|
||||
let difAdd = currentFiendShipLevel.add;
|
||||
if (!!args[0]) {
|
||||
let lastFiendShipLevel = getFiendShipLevel(args[0]);
|
||||
difAdd -= lastFiendShipLevel.add;
|
||||
}
|
||||
let attrName;
|
||||
for (let connect of hero.conections) {
|
||||
let heroShip = getFriendShipById(connect.shipId, connect.level);
|
||||
for (let attr of heroShip.attributes) {
|
||||
attrName = getAtrrNameById(attr.id);
|
||||
res[attrName] = {fixUp: hero.CeAttr[attrName].fixUp, base: hero.CeAttr[attrName].base, ratioUp: hero.CeAttr[attrName].ratioUp};
|
||||
res[attrName].fixUp += attr.number * (HERO_CE_RATIO + difAdd);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { setAp } from './actionPointService';
|
||||
import { ItemModel } from '../db/Item';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
import { pinus } from 'pinus';
|
||||
const _ = require('underscore');
|
||||
|
||||
export async function handleFixedReward(roleId: string, roleName: string, rewardStr: string, multi: number) {
|
||||
let reward = decodeStr('fixReward', rewardStr);
|
||||
@@ -83,7 +84,7 @@ async function rewardItems (roleId: string, roleName: string, dicGood: any, type
|
||||
|
||||
let goods = new Array();
|
||||
let {id, cnt} = data;
|
||||
|
||||
|
||||
let result = await ItemModel.increaseItem(roleId, id, cnt, {roleId, roleName, itemName: dicGood.name, id, type, hid: dicGood.hid||0});
|
||||
|
||||
if(result) {
|
||||
@@ -174,5 +175,34 @@ export async function handleCost(roleId: string, sid: string, goods: Array<{id:
|
||||
let uids = [{uid: roleId, sid}];
|
||||
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, {goods: resultGoods, gold, coin} ), uids);
|
||||
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function addItems(roleId: string, sid: string, goods: Array<{id: number, count: number}>) {
|
||||
let showItems = [];
|
||||
let equips = [];
|
||||
let currencys = [];
|
||||
for (let good of goods) {
|
||||
let goodInfo = getGoodById(good.id);
|
||||
if (goodInfo.goodType == GOOD_TYPE.EQUIP) { // 装备
|
||||
equips.push({
|
||||
id: good.id,
|
||||
name: goodInfo.name,
|
||||
quality: goodInfo.lv,
|
||||
type: goodInfo.goodType
|
||||
});
|
||||
} else if (goodInfo.goodType == GOOD_TYPE.CONSUMES|| goodInfo.goodType == GOOD_TYPE.SCRIPT) {
|
||||
let {type, isCurrency} = ITID.get(goodInfo.itid);
|
||||
if (!!isCurrency) { // 货币
|
||||
let index = _.indexOf(currencys, {id: good.id});
|
||||
if (index > 0) {
|
||||
currencys[index].count = currencys[index].count + good.count;
|
||||
} else {
|
||||
currencys.push(good);
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,10 @@ export const ACTION_POIN = {
|
||||
export const HERO_SYSTEM_TYPE = {
|
||||
STAR: 1,
|
||||
TRAIN: 5,
|
||||
STAGEUP:6,
|
||||
SKIN:7,
|
||||
FAVOUR:8,
|
||||
CONNECT:9
|
||||
};
|
||||
|
||||
export const BATTLE_REWARD_TYPE = {
|
||||
@@ -228,9 +232,9 @@ export const EXPEDITION_CONST = {
|
||||
|
||||
export const EVENT_QUIZ_NUM = 3;
|
||||
|
||||
export const DEFAULT_HEROES = [ 12, 14, 11, 9, 15];
|
||||
export const DEFAULT_HEROES = [12, 14, 11, 9, 15];
|
||||
|
||||
export const FIX_SMS_CODE_TELS = ['18855953630', '13911134885', '15167549151', '15618654010', '15167549151'];
|
||||
export const FIX_SMS_CODE_TELS = ['18855953630', '13911134885', '15167549151', '15618654010', '15167549151', '18342915387'];
|
||||
|
||||
export const GONGSHI = {
|
||||
"TOWER_HANG_UP_SPEED_COST": "50",
|
||||
|
||||
@@ -138,6 +138,7 @@ export const STATUS = {
|
||||
NOT_REACH_UNLOCK_LEVEL: {code: 30302, simStr: '未达到解锁等级'},
|
||||
HERO_SKIN_NOT_FIND: {code: 30303, simStr: '时装不存在'},
|
||||
HERO_SKIN_IS_EXIST: {code: 30304, simStr: '时装已存在'},
|
||||
HERO_SKIN_IS_EQUIPED: {code: 30305, simStr: '时装已穿戴'},
|
||||
HERO_CONECTION_IS_MAX_LEVEL: {code: 30306, simStr: '羁绊已达到最大等级'},
|
||||
HERO_CONECTION_IS_NOT_EXIT: {code: 30307, simStr: '羁绊不存在'},
|
||||
ROLE_SHORT_HERO_CONECTION:{code: 30308, simStr: '未拥有羁绊武将'},
|
||||
|
||||
@@ -90,7 +90,7 @@ export default class Hero extends BaseModel {
|
||||
@prop({ required: true, default: 1 })
|
||||
favourLv: number; // 好感等级
|
||||
@prop({ required: true, type:Connect, default: [] })
|
||||
conections: Connect[]; // 羁绊
|
||||
connections: Connect[]; // 羁绊
|
||||
@prop({ required: true, default: [] })
|
||||
skins: Skin[]; // 皮肤
|
||||
|
||||
|
||||
@@ -120,6 +120,8 @@ function parseJobData() {
|
||||
const jobsData = gamedata['jsons'][jobFile] || [];
|
||||
jobsData.forEach(elem => {
|
||||
if (elem && elem.jobid) {
|
||||
elem.seids = elem.seid.split('&');
|
||||
delete elem.seid;
|
||||
jobInfos.set(elem.jobid, elem);
|
||||
let jobClass = jobClassMaxGrades.get(elem.job_class);
|
||||
if (!!jobClass && jobClass.grade < elem.grade) {
|
||||
@@ -269,6 +271,15 @@ function parseFashions() {
|
||||
const data = gamedata['jsons'][file] || [];
|
||||
data.forEach(elem => {
|
||||
if (elem && elem.id) {
|
||||
elem.actorAttrs = [];
|
||||
let actorAttrs = elem.actorAttr.split('|');
|
||||
for (let attr of actorAttrs) {
|
||||
let attrArr = attr.split('&');
|
||||
elem.actorAttrs.push({
|
||||
id: parseInt(attrArr[0]),
|
||||
number: parseInt(attrArr[1]),
|
||||
});
|
||||
}
|
||||
fashions.set(elem.id, elem);
|
||||
}
|
||||
});
|
||||
@@ -279,8 +290,16 @@ function parseFiendShips() {
|
||||
const data = gamedata['jsons'][file] || [];
|
||||
data.forEach(elem => {
|
||||
if (elem && elem.id) {
|
||||
let hids = elem.memberId.split('&');
|
||||
elem.hids = hids;
|
||||
elem.attributes = [];
|
||||
elem.hids = elem.memberId.split('&');
|
||||
let attributes = elem.attribute.split('|');
|
||||
for (let attr of attributes) {
|
||||
let attrArr = attr.split('&');
|
||||
elem.attributes.push({
|
||||
id: parseInt(attrArr[0]),
|
||||
number: parseInt(attrArr[1]),
|
||||
});
|
||||
}
|
||||
delete elem.memberId;
|
||||
fiendShips.set(elem.shipId + '_' + elem.level, elem);
|
||||
let fiendShipHidAandId = fiendShipHidAandIds.get(elem.shipId);
|
||||
|
||||
@@ -410,4 +410,28 @@ export function getItems(str:string) {
|
||||
});
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
|
||||
export function deepCopy (obj) {
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return obj;
|
||||
}
|
||||
var target;
|
||||
if (obj instanceof Array) {
|
||||
target = [];
|
||||
obj.forEach(element => {
|
||||
target.push(deepCopy(element));
|
||||
});
|
||||
} else {
|
||||
target = {};
|
||||
for (const key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
const element = obj[key];
|
||||
if (!!element || element == 0) {
|
||||
target[key] = deepCopy(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
};
|
||||
Reference in New Issue
Block a user