神像强化十次
This commit is contained in:
59
game-server/app/services/roleService.ts
Normal file
59
game-server/app/services/roleService.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { getRandNum, getRandomArr } from '../pubUtils/util';
|
||||
import { EquipModel } from "../db/Equip";
|
||||
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 { 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) {
|
||||
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];
|
||||
}
|
||||
}
|
||||
times++;
|
||||
} else {
|
||||
let criticalArr = getRandomArr(TERAPH_STRENGTHEN, 2);
|
||||
for (let item of TERAPH_STRENGTHEN) {
|
||||
if (!attrs.length) {
|
||||
break;
|
||||
}
|
||||
let criEffect = 1;
|
||||
let index = _.indexOf(criticalArr, {item});
|
||||
if (index > 0) {
|
||||
criEffect = teraphInfo.criEffect;
|
||||
}
|
||||
let num = getRandNum(TERAPH_RANDOM.MIN, TERAPH_RANDOM.MAX);
|
||||
let arr = getRandomArr(attrs, num);
|
||||
for (let attrName of arr) {
|
||||
res[attrName] = (res[attrName]||0) + teraphInfo[attrName] * criEffect;
|
||||
let attrNameMax = attrName+'Max';
|
||||
if (teraph[attrName] + res[attrName] > teraphInfo[attrNameMax]) {
|
||||
res[attrName] = teraphInfo[attrNameMax] - teraph[attrName];
|
||||
let attrIndex = _.indexOf(criticalArr, {attrName});
|
||||
attrs.splice(attrIndex, 1);
|
||||
}
|
||||
}
|
||||
times++;
|
||||
}
|
||||
}
|
||||
for (let {id, count} of teraphInfo.upMaterial) {
|
||||
consumes.push({ id, count: count*times});
|
||||
}
|
||||
return {attr: res, consumes};
|
||||
}
|
||||
Reference in New Issue
Block a user