强化
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user