属性随机使用既有方法
This commit is contained in:
@@ -6,7 +6,7 @@ import { EquipModel, RandSe, Holes } from './../db/Equip';
|
||||
import { BagInter, EquipInter } from './interface';
|
||||
import { gameData } from './data';
|
||||
import { RANDOM_SE_COUNT, FIX_ATTRIBUTES_RAN, ITID } from '../consts';
|
||||
import { getRandomByLen } from './util';
|
||||
import { getRandValueByMinMax, getRandEelm } from './util';
|
||||
|
||||
const _ = require('underscore');
|
||||
|
||||
@@ -35,24 +35,22 @@ export async function addEquips(roleId: string, roleName: string, weapon: EquipI
|
||||
let {type} = ITID.get(itid);
|
||||
|
||||
let randomNum = RANDOM_SE_COUNT.get(quality);
|
||||
let pool = randomEffect.map(cur => gameData.randomEffectPool.get(cur));
|
||||
let chosen = new Array<number>();
|
||||
let randSe = new Array<RandSe>();
|
||||
for(let i = 0; i < randomNum; i++) {
|
||||
pool = pool.filter(cur => !chosen.includes(cur.id));
|
||||
let random = getRandomByLen(pool);
|
||||
if(!random) break;
|
||||
chosen.push(random.id);
|
||||
let randomResult: number[] = getRandEelm(randomEffect, randomNum);
|
||||
|
||||
let randSe: Array<RandSe> = randomResult.map((id: number, i: number) => {
|
||||
let random = gameData.randomEffectPool.get(id)
|
||||
let rand = 0;
|
||||
if(random.id > 0) rand = Math.floor(Math.random() * (random.Max - random.Min) + random.Min);
|
||||
randSe.push({
|
||||
if(random.id > 0) rand = getRandValueByMinMax(random.Min, random.Max, 0);
|
||||
return {
|
||||
id: i + 1,
|
||||
seid: random.id,
|
||||
rand,
|
||||
locked: false
|
||||
});
|
||||
}
|
||||
let randRange = Math.floor(Math.random() * FIX_ATTRIBUTES_RAN * 2) - FIX_ATTRIBUTES_RAN;
|
||||
};
|
||||
});
|
||||
|
||||
let randRange = getRandValueByMinMax(0 - FIX_ATTRIBUTES_RAN, FIX_ATTRIBUTES_RAN, 0);
|
||||
|
||||
let holes = new Array<Holes>();
|
||||
for(let i = 0; i < hole; i++) {
|
||||
holes.push({id: i+1, isOpen: false, jewel: 0})
|
||||
|
||||
Reference in New Issue
Block a user