You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.9 KiB
49 lines
1.9 KiB
import { Categorys, Equip, EquipBase, Quality } from './bean'; |
|
import { entry_initor, extra_entry_num, qualitys } from './constant'; |
|
|
|
export const createBase = (quality, lv, category, coefficient) => { |
|
const entry = new Array(); |
|
category.entry.forEach((item) => { |
|
const initor = entry_initor[item.type]; |
|
const qualityCoefficient = coefficient[quality]; |
|
entry.push(initor(lv, qualityCoefficient, item.valCoefficient)); |
|
}); |
|
return new EquipBase(category.name, category.icon, entry, category.skill); |
|
}; |
|
|
|
export const createExtraEntry = (quality, lv, extraEntrys, coefficient) => { |
|
const type = extraEntrys[Math.floor(Math.random() * extraEntrys.length)]; |
|
const initor = entry_initor[type]; |
|
const qualityCoefficient = coefficient[quality]; |
|
const entry = initor(lv, qualityCoefficient); |
|
return entry; |
|
}; |
|
|
|
export const createSamples = (categorys: Categorys[], uniqueCategorys: Categorys[], colorfulCategorys: Categorys[], type, coefficient) => { |
|
const samples = { |
|
colorful: new Array(), |
|
unique: new Array(), |
|
epic: new Array(), |
|
artifact: new Array(), |
|
}; |
|
colorfulCategorys.forEach((item) => { |
|
samples.colorful.push(createSample('colorful', item, type, coefficient)); |
|
}); |
|
uniqueCategorys.forEach((item) => { |
|
samples.unique.push(createSample('unique', item, type, coefficient)); |
|
}); |
|
categorys.forEach((item) => { |
|
samples.epic.push(createSample('epic', item, type, coefficient)); |
|
samples.artifact.push(createSample('artifact', item, type, coefficient)); |
|
}); |
|
return samples; |
|
}; |
|
const createSample = (quality, category, type, coefficient): Equip => { |
|
const lv = 100; |
|
const qualityBean = new Quality(quality, coefficient[quality]); |
|
const base = createBase(quality, lv, category, coefficient); |
|
const extraEntry = new Array(); |
|
const sample = new Equip(type, lv, qualityBean, base, extraEntry); |
|
sample.reRoll = category.reRoll; |
|
return sample; |
|
};
|
|
|