强化
This commit is contained in:
@@ -10,14 +10,8 @@ import { getTeraphAttr, getAtrrNameById } from '../../../consts/constModules/abi
|
||||
const _ = require('underscore');
|
||||
import { SclResultInter, SclPosInter } from '../../../pubUtils/interface';
|
||||
import { SchoolModel } from '../../../db/School';
|
||||
<<<<<<< Updated upstream
|
||||
import { checkMaterialEnough } from '../../../services/roleService'
|
||||
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
|
||||
=======
|
||||
import { checkMaterialEnough } from '../../../services/roleService';
|
||||
import { calAllHeroCe } from '../../../services/playerCeService';
|
||||
import { calPlayerCeAndSave } from '../../../services/playerCeService';
|
||||
>>>>>>> Stashed changes
|
||||
import { HERO_SYSTEM_TYPE } from '../../../consts';
|
||||
|
||||
export default function(app: Application) {
|
||||
@@ -102,8 +96,8 @@ export class RoleHandler {
|
||||
}
|
||||
|
||||
//神像强化
|
||||
async roleTeraphStrengthen(msg: {id: number, type: number}, session: BackendSession){
|
||||
let {id, type} = msg;
|
||||
async roleTeraphStrengthen(msg: {id: number, count: number}, session: BackendSession){
|
||||
let {id, count} = msg;
|
||||
let roleId = session.get('roleId');
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let sid: string = session.get('sid');
|
||||
@@ -123,7 +117,7 @@ export class RoleHandler {
|
||||
}
|
||||
if (!attrs.length)
|
||||
return resResult(STATUS.ROLE_TERAPH_NOT_STRENGTHEN);
|
||||
let {attr, consumes} = checkMaterialEnough(type, attrs, teraphInfo, teraph);
|
||||
let {attr, consumes} = checkMaterialEnough(count, attrs, teraphInfo, teraph);
|
||||
for (let key in attr) {
|
||||
teraph[key] += attr[key];
|
||||
role.globalCeAttr[key].fixUp += attr[key];
|
||||
|
||||
@@ -5,11 +5,7 @@
|
||||
import { pinus } from 'pinus';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
|
||||
<<<<<<< HEAD
|
||||
import { resResult, reduceCe } from '../pubUtils/util';
|
||||
=======
|
||||
import { resResult, reduceCe } from '../pubUtils/util';
|
||||
>>>>>>> cb1f9ea... 战力
|
||||
import { calPlayerCeAndSave as pubCalPlayerCeAndSave, reCalAllHeroCe } from '../pubUtils/playerCe';
|
||||
import { HeroType } from '../db/Hero';
|
||||
const _ = require('underscore');
|
||||
@@ -20,27 +16,19 @@ export async function calPlayerCeAndSave(sid: string, roleId: string, heros: Arr
|
||||
let {role, pushHeros} = await pubCalPlayerCeAndSave(roleId, heros, type, args);
|
||||
//下发战力
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
<<<<<<< HEAD
|
||||
let pushHerosReduced = pushHeros.map(cur => {
|
||||
return { hid: cur.hid, ce: reduceCe(cur.ce), incHeroCe: reduceCe(cur.incHeroCe) }
|
||||
});
|
||||
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce) , heros: pushHerosReduced, topFiveCe: 0 }), uids);
|
||||
=======
|
||||
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce), heros: pushHeros, topFiveCe: 0 }), uids);
|
||||
>>>>>>> cb1f9ea... 战力
|
||||
return heros;
|
||||
}
|
||||
|
||||
export async function calAllHeroCe(sid: string, roleId: string, type?:number, args?:Array<number>) {
|
||||
let {ce, pushHeros}= await reCalAllHeroCe(roleId,type, args);
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
<<<<<<< HEAD
|
||||
let pushHerosReduced = pushHeros.map(cur => {
|
||||
return { hid: cur.hid, ce: reduceCe(cur.ce), incHeroCe: reduceCe(cur.incHeroCe) }
|
||||
});
|
||||
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(ce), heros: pushHerosReduced, topFiveCe: 0 }), uids);
|
||||
=======
|
||||
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(ce), heros: pushHeros, topFiveCe: 0 }), uids);
|
||||
>>>>>>> cb1f9ea... 战力
|
||||
return;
|
||||
}
|
||||
@@ -8,26 +8,33 @@ import { TERAPH_RANDOM } from "../consts/consts";
|
||||
import { getTeraphAttr } from '../consts/constModules/abilityConst';
|
||||
const _ = require('underscore');
|
||||
const TERAPH_STRENGTHEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
export function checkMaterialEnough(type: number, attrs:Array<any>, teraphInfo: any, teraph: any) {
|
||||
export function checkMaterialEnough(count: number, attrs:Array<any>, teraphInfo: any, teraph: any) {
|
||||
let res = {};
|
||||
let consumes = [];
|
||||
let times = 0;
|
||||
if (type == 1) {
|
||||
let num = getRandNum(TERAPH_RANDOM.MIN, TERAPH_RANDOM.MAX);
|
||||
let arr = getRandomArr(attrs, num)
|
||||
let critical = getRandNum(0, 100);
|
||||
let criEffect = 1;
|
||||
if (critical <= teraphInfo.criRate)
|
||||
criEffect = teraphInfo.criEffect;
|
||||
for (let attrName of arr) {
|
||||
let attrNameMax = attrName+'Max';
|
||||
res[attrName] = teraphInfo[attrName] * criEffect;
|
||||
if (teraph[attrName] + res[attrName] > teraphInfo[attrNameMax]) {
|
||||
res[attrName] = teraphInfo[attrNameMax] - teraph[attrName];
|
||||
if (count < 10) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
if (!attrs.length) {
|
||||
break;
|
||||
}
|
||||
let num = getRandNum(TERAPH_RANDOM.MIN, TERAPH_RANDOM.MAX);
|
||||
let arr = getRandomArr(attrs, num)
|
||||
let critical = getRandNum(0, 100);
|
||||
let criEffect = 1;
|
||||
if (critical <= teraphInfo.criRate)
|
||||
criEffect = teraphInfo.criEffect;
|
||||
for (let attrName of arr) {
|
||||
let attrNameMax = attrName+'Max';
|
||||
res[attrName] = teraphInfo[attrName] * criEffect;
|
||||
if (teraph[attrName] + res[attrName] > teraphInfo[attrNameMax]) {
|
||||
res[attrName] = teraphInfo[attrNameMax] - teraph[attrName];
|
||||
let attrIndex = _.indexOf(attrs, attrName);
|
||||
attrs.splice(attrIndex, 1);
|
||||
}
|
||||
}
|
||||
times++;
|
||||
}
|
||||
times++;
|
||||
} else {
|
||||
} else if (count == 10){
|
||||
let criticalArr = getRandomArr(TERAPH_STRENGTHEN, 2);
|
||||
for (let item of TERAPH_STRENGTHEN) {
|
||||
if (!attrs.length) {
|
||||
@@ -45,7 +52,7 @@ export function checkMaterialEnough(type: number, attrs:Array<any>, teraphInfo:
|
||||
let attrNameMax = attrName+'Max';
|
||||
if (teraph[attrName] + res[attrName] > teraphInfo[attrNameMax]) {
|
||||
res[attrName] = teraphInfo[attrNameMax] - teraph[attrName];
|
||||
let attrIndex = _.indexOf(criticalArr, {attrName});
|
||||
let attrIndex = _.indexOf(attrs, attrName);
|
||||
attrs.splice(attrIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,24 +246,3 @@ export function getSuit(id: number) {
|
||||
const suitInfo = gameData.suit.get(id);
|
||||
return suitInfo;
|
||||
}
|
||||
|
||||
export function getSchoolRateByStar(star: number, colorStar: number, quality: number) {
|
||||
const schoolRate = gameData.schoolRate.get(`${star}_${colorStar}_${quality}`);
|
||||
return schoolRate;
|
||||
}
|
||||
|
||||
export function getScollByStar(quality: number, star: number, curQuality: number, colorStar: number) {
|
||||
const heroScroll = gameData.heroScroll.get(`${quality}_${star}_${curQuality}_${colorStar}`);
|
||||
return heroScroll;
|
||||
}
|
||||
|
||||
// 根据存在升星表等的stage字段的id对应17维id
|
||||
export function getFieldByStage(stage: number, jobid: number) {
|
||||
let targetAttrId = ABI_TYPE_TO_STAGE.get(stage);
|
||||
if(typeof targetAttrId === 'number') {
|
||||
return targetAttrId
|
||||
} else {
|
||||
const dicJob = gameData.job.get(jobid);
|
||||
return targetAttrId(dicJob.type);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user