军团捐献,许愿池,装备,养成 注释
This commit is contained in:
@@ -4,18 +4,25 @@ import { getRandNum, getRandomArr } from '../pubUtils/util';
|
||||
import { TERAPH_RANDOM } from "../consts/consts";
|
||||
import { indexOf } from 'underscore';
|
||||
const TERAPH_STRENGTHEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
export function checkMaterialEnough(count: number, attrs:Array<any>, teraphInfo: any, teraph: any) {
|
||||
/**
|
||||
* 计算强化次数和消耗
|
||||
* @param count 强化次数
|
||||
* @param attrNames 可以强化的属性名字
|
||||
* @param teraphInfo 字典表对应的神像信息
|
||||
* @param teraph
|
||||
*/
|
||||
export function checkTeraphMaterialEnough(count: number, attrNames:Array<any>, teraphInfo: any, teraph: any) {
|
||||
let res = {};
|
||||
let consumes = [];
|
||||
let times = 0;
|
||||
if (count < 10) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
if (!attrs.length) {
|
||||
if (!attrNames.length) {
|
||||
break;
|
||||
}
|
||||
let num = getRandNum(TERAPH_RANDOM.MIN, TERAPH_RANDOM.MAX);
|
||||
let arr = getRandomArr(attrs, num)
|
||||
let critical = getRandNum(0, 100);
|
||||
let arr = getRandomArr(attrNames, num)
|
||||
let critical = getRandNum(0, 100);//属性暴击率
|
||||
let criEffect = 1;
|
||||
if (critical <= teraphInfo.criRate)
|
||||
criEffect = teraphInfo.criEffect;
|
||||
@@ -24,43 +31,48 @@ export function checkMaterialEnough(count: number, attrs:Array<any>, teraphInfo:
|
||||
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);
|
||||
let attrIndex = indexOf(attrNames, attrName);
|
||||
attrNames.splice(attrIndex, 1);
|
||||
}
|
||||
}
|
||||
times++;
|
||||
}
|
||||
} else if (count == 10){
|
||||
let criticalArr = getRandomArr(TERAPH_STRENGTHEN, 2);
|
||||
let criticalArrTimes = getRandomArr(TERAPH_STRENGTHEN, 2);//10次中随机2次发生暴击
|
||||
for (let item of TERAPH_STRENGTHEN) {
|
||||
if (!attrs.length) {
|
||||
if (!attrNames.length) {
|
||||
break;
|
||||
}
|
||||
let criEffect = 1;
|
||||
let index = indexOf(criticalArr, {item});
|
||||
let index = indexOf(criticalArrTimes, {item});
|
||||
if (index > 0) {
|
||||
criEffect = teraphInfo.criEffect;
|
||||
criEffect = teraphInfo.criEffect;//本次是暴击 item 在 criticalArrTimes 中
|
||||
}
|
||||
let num = getRandNum(TERAPH_RANDOM.MIN, TERAPH_RANDOM.MAX);
|
||||
let arr = getRandomArr(attrs, num);
|
||||
let arr = getRandomArr(attrNames, 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(attrs, attrName);
|
||||
attrs.splice(attrIndex, 1);
|
||||
let attrIndex = indexOf(attrNames, attrName);
|
||||
attrNames.splice(attrIndex, 1);
|
||||
}
|
||||
}
|
||||
times++;
|
||||
}
|
||||
}
|
||||
//计算消耗
|
||||
for (let {id, count} of teraphInfo.upMaterial) {
|
||||
consumes.push({ id, count: count*times});
|
||||
}
|
||||
return {attr: res, consumes};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param channel
|
||||
* @param user
|
||||
*/
|
||||
export function addUserToChannel(channel: Channel, user: ChannelUser) {
|
||||
const users = channel.getMembers();
|
||||
const { uid, sid } = user;
|
||||
|
||||
Reference in New Issue
Block a user