强化
This commit is contained in:
@@ -10,14 +10,8 @@ import { getTeraphAttr, getAtrrNameById } from '../../../consts/constModules/abi
|
|||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
import { SclResultInter, SclPosInter } from '../../../pubUtils/interface';
|
import { SclResultInter, SclPosInter } from '../../../pubUtils/interface';
|
||||||
import { SchoolModel } from '../../../db/School';
|
import { SchoolModel } from '../../../db/School';
|
||||||
<<<<<<< Updated upstream
|
|
||||||
import { checkMaterialEnough } from '../../../services/roleService'
|
import { checkMaterialEnough } from '../../../services/roleService'
|
||||||
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
|
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';
|
import { HERO_SYSTEM_TYPE } from '../../../consts';
|
||||||
|
|
||||||
export default function(app: Application) {
|
export default function(app: Application) {
|
||||||
@@ -102,8 +96,8 @@ export class RoleHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//神像强化
|
//神像强化
|
||||||
async roleTeraphStrengthen(msg: {id: number, type: number}, session: BackendSession){
|
async roleTeraphStrengthen(msg: {id: number, count: number}, session: BackendSession){
|
||||||
let {id, type} = msg;
|
let {id, count} = msg;
|
||||||
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');
|
||||||
@@ -123,7 +117,7 @@ export class RoleHandler {
|
|||||||
}
|
}
|
||||||
if (!attrs.length)
|
if (!attrs.length)
|
||||||
return resResult(STATUS.ROLE_TERAPH_NOT_STRENGTHEN);
|
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) {
|
for (let key in attr) {
|
||||||
teraph[key] += attr[key];
|
teraph[key] += attr[key];
|
||||||
role.globalCeAttr[key].fixUp += attr[key];
|
role.globalCeAttr[key].fixUp += attr[key];
|
||||||
|
|||||||
@@ -5,11 +5,7 @@
|
|||||||
import { pinus } from 'pinus';
|
import { pinus } from 'pinus';
|
||||||
import { STATUS } from '../consts/statusCode';
|
import { STATUS } from '../consts/statusCode';
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
import { resResult, reduceCe } from '../pubUtils/util';
|
import { resResult, reduceCe } from '../pubUtils/util';
|
||||||
=======
|
|
||||||
import { resResult, reduceCe } from '../pubUtils/util';
|
|
||||||
>>>>>>> cb1f9ea... 战力
|
|
||||||
import { calPlayerCeAndSave as pubCalPlayerCeAndSave, reCalAllHeroCe } from '../pubUtils/playerCe';
|
import { calPlayerCeAndSave as pubCalPlayerCeAndSave, reCalAllHeroCe } from '../pubUtils/playerCe';
|
||||||
import { HeroType } from '../db/Hero';
|
import { HeroType } from '../db/Hero';
|
||||||
const _ = require('underscore');
|
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 {role, pushHeros} = await pubCalPlayerCeAndSave(roleId, heros, type, args);
|
||||||
//下发战力
|
//下发战力
|
||||||
let uids = [{ uid: roleId, sid }];
|
let uids = [{ uid: roleId, sid }];
|
||||||
<<<<<<< HEAD
|
|
||||||
let pushHerosReduced = pushHeros.map(cur => {
|
let pushHerosReduced = pushHeros.map(cur => {
|
||||||
return { hid: cur.hid, ce: reduceCe(cur.ce), incHeroCe: reduceCe(cur.incHeroCe) }
|
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: 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;
|
return heros;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function calAllHeroCe(sid: string, roleId: string, type?:number, args?:Array<number>) {
|
export async function calAllHeroCe(sid: string, roleId: string, type?:number, args?:Array<number>) {
|
||||||
let {ce, pushHeros}= await reCalAllHeroCe(roleId,type, args);
|
let {ce, pushHeros}= await reCalAllHeroCe(roleId,type, args);
|
||||||
let uids = [{ uid: roleId, sid }];
|
let uids = [{ uid: roleId, sid }];
|
||||||
<<<<<<< HEAD
|
|
||||||
let pushHerosReduced = pushHeros.map(cur => {
|
let pushHerosReduced = pushHeros.map(cur => {
|
||||||
return { hid: cur.hid, ce: reduceCe(cur.ce), incHeroCe: reduceCe(cur.incHeroCe) }
|
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: pushHerosReduced, topFiveCe: 0 }), uids);
|
||||||
=======
|
|
||||||
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(ce), heros: pushHeros, topFiveCe: 0 }), uids);
|
|
||||||
>>>>>>> cb1f9ea... 战力
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -8,26 +8,33 @@ import { TERAPH_RANDOM } from "../consts/consts";
|
|||||||
import { getTeraphAttr } from '../consts/constModules/abilityConst';
|
import { getTeraphAttr } from '../consts/constModules/abilityConst';
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
const TERAPH_STRENGTHEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
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 res = {};
|
||||||
let consumes = [];
|
let consumes = [];
|
||||||
let times = 0;
|
let times = 0;
|
||||||
if (type == 1) {
|
if (count < 10) {
|
||||||
let num = getRandNum(TERAPH_RANDOM.MIN, TERAPH_RANDOM.MAX);
|
for (let i = 0; i < count; i++) {
|
||||||
let arr = getRandomArr(attrs, num)
|
if (!attrs.length) {
|
||||||
let critical = getRandNum(0, 100);
|
break;
|
||||||
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 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 if (count == 10){
|
||||||
} else {
|
|
||||||
let criticalArr = getRandomArr(TERAPH_STRENGTHEN, 2);
|
let criticalArr = getRandomArr(TERAPH_STRENGTHEN, 2);
|
||||||
for (let item of TERAPH_STRENGTHEN) {
|
for (let item of TERAPH_STRENGTHEN) {
|
||||||
if (!attrs.length) {
|
if (!attrs.length) {
|
||||||
@@ -45,7 +52,7 @@ export function checkMaterialEnough(type: number, attrs:Array<any>, teraphInfo:
|
|||||||
let attrNameMax = attrName+'Max';
|
let attrNameMax = attrName+'Max';
|
||||||
if (teraph[attrName] + res[attrName] > teraphInfo[attrNameMax]) {
|
if (teraph[attrName] + res[attrName] > teraphInfo[attrNameMax]) {
|
||||||
res[attrName] = teraphInfo[attrNameMax] - teraph[attrName];
|
res[attrName] = teraphInfo[attrNameMax] - teraph[attrName];
|
||||||
let attrIndex = _.indexOf(criticalArr, {attrName});
|
let attrIndex = _.indexOf(attrs, attrName);
|
||||||
attrs.splice(attrIndex, 1);
|
attrs.splice(attrIndex, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,24 +246,3 @@ export function getSuit(id: number) {
|
|||||||
const suitInfo = gameData.suit.get(id);
|
const suitInfo = gameData.suit.get(id);
|
||||||
return suitInfo;
|
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