一个全随机的刷装备小游戏
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.

230 lines
6.3 KiB

import { Entry, Quality, EquipBase, Equip } from './bean';
import { qualitys, entry_initor, extra_entry_num } from './constant';
const extraEntrys = ['atk', 'crit', 'critDmg', 'hp', 'def', 'atkPercent', 'defPercent', 'hpPercent'];
const coefficient = { shabby: 0.6, ordinary: 0.9, artifact: 1.3, epic: 1.6, unique: 1.8, colorful: 1.8 };
export const bracersColorfulCategorys = [
{
name: 'shuzhuang',
icon: 'bracers/梳妆镜.png',
entry: [
{ type: 'atk', valCoefficient: 1 },
{ type: 'hp', valCoefficient: 0.7 },
{ type: 'def', valCoefficient: 0.4 },
],
skill: 'JHSY',
},
{
name: 'liulipan',
icon: 'bracers/琉璃盘.png',
entry: [
{ type: 'atk', valCoefficient: 0.6 },
{ type: 'hp', valCoefficient: 1.5 },
],
skill: 'Liulipan',
},
{
name: 'ghdp',
icon: 'bracers/勾魂夺魂.png',
entry: [
{ type: 'critDmg', valCoefficient: 1 },
{ type: 'crit', valCoefficient: 0.4 },
{ type: 'atk', valCoefficient: 0.5 },
],
skill: 'CritFear',
},
{
name: 'youerhuan',
icon: 'bracers/白骨夫人的右耳环.png',
entry: [
{ type: 'critDmg', valCoefficient: 1.5 },
{ type: 'atk', valCoefficient: 0.8 },
],
skill: 'Vampire1',
},
{
name: 'jingboyu',
icon: 'bracers/金钵盂.png',
entry: [
{ type: 'atk', valCoefficient: 0.8 },
{ type: 'hp', valCoefficient: 0.6 },
{ type: 'def', valCoefficient: 0.6 },
],
skill: 'Prototype',
},
{
name: 'zijingboyu',
icon: 'bracers/紫金钵盂.png',
entry: [
{ type: 'atk', valCoefficient: 0.8 },
{ type: 'hp', valCoefficient: 0.6 },
{ type: 'def', valCoefficient: 0.6 },
],
skill: 'Fate',
},
];
export const bracersUniqueCategorys = [
{
name: 'duoqing',
icon: 'bracers/多情腕.png',
entry: [
{ type: 'atk', valCoefficient: 1 },
{ type: 'hp', valCoefficient: 0.8 },
{ type: 'def', valCoefficient: 0.9 },
],
},
{
name: 'wano',
icon: 'bracers/玩藕.png',
entry: [
{ type: 'critDmg', valCoefficient: 1.5 },
{ type: 'crit', valCoefficient: 0.5 },
{ type: 'atk', valCoefficient: 0.8 },
],
},
{
name: 'rsggu',
icon: 'bracers/人参果裹布.png',
entry: [
{ type: 'critDmg', valCoefficient: 1.2 },
{ type: 'atkPercent', valCoefficient: 1.0 },
{ type: 'atk', valCoefficient: 0.7 },
],
},
{
name: 'yingwu',
icon: 'bracers/鹦鹉杯.png',
entry: [
{ type: 'critDmg', valCoefficient: 1.6 },
{ type: 'atk', valCoefficient: 1.6 },
],
},
{
name: 'meipusa',
icon: 'bracers/美菩萨.png',
entry: [
{ type: 'atkPercent', valCoefficient: 1.2 },
{ type: 'def', valCoefficient: 0.9 },
{ type: 'hp', valCoefficient: 1.2 },
],
},
];
export const bracersCategorys = [
{
name: 'guoshi',
icon: 'bracers/裹尸布.png',
entry: [
{ type: 'def', valCoefficient: 0.9 },
{ type: 'hp', valCoefficient: 0.6 },
{ type: 'atk', valCoefficient: 0.5 },
],
},
{
name: 'xiuyugu',
icon: 'bracers/绣与骨.png',
entry: [
{ type: 'crit', valCoefficient: 1.1 },
{ type: 'hp', valCoefficient: 0.5 },
{ type: 'atk', valCoefficient: 0.6 },
],
},
{
name: 'huoshen',
icon: 'bracers/火神腕.png',
entry: [
{ type: 'crit', valCoefficient: 1.1 },
{ type: 'hp', valCoefficient: 0.6 },
{ type: 'atk', valCoefficient: 0.5 },
],
},
{
name: 'heishou',
icon: 'bracers/黑手.png',
entry: [
{ type: 'crit', valCoefficient: 0.75 },
{ type: 'critDmg', valCoefficient: 0.5 },
{ type: 'hp', valCoefficient: 0.5 },
],
},
];
export const initialbracers = () => {
const type = 'bracers';
const qualityBean = new Quality(qualitys[0], coefficient[qualitys[0]]);
const base = new EquipBase('shiwangsy', 'bracers/新手.png', [new Entry('atk', 1, '+1', 1, 1)]);
const extraEntry = [new Entry('hp', 20, '+20', 20, 20)];
return new Equip(type, 1, qualityBean, base, extraEntry);
};
export const createbracers = (quality, lv): Equip => {
const type = 'bracers';
const qualityBean = new Quality(quality, coefficient[quality]);
const category = getCategory(quality);
const base = createBase(quality, lv, category);
const extraEntry = new Array();
const extraEntryNum = extra_entry_num[quality];
for (let i = 0; i < extraEntryNum; i++) {
extraEntry.push(bracersExtraEntry(quality, lv));
}
return new Equip(type, lv, qualityBean, base, extraEntry);
};
export const bracersExtraEntry = (quality, lv) => {
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;
};
const createBase = (quality, lv, category) => {
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);
};
const getCategory = (quality) => {
let categorys = bracersCategorys;
switch (quality) {
case qualitys[4]:
categorys = bracersUniqueCategorys;
break;
case qualitys[5]:
categorys = bracersColorfulCategorys;
break;
}
return categorys[Math.floor(Math.random() * categorys.length)];
};
const bracersSample = (quality, category): Equip => {
const type = 'bracers';
const lv = 100;
const qualityBean = new Quality(quality, coefficient[quality]);
const base = createBase(quality, lv, category);
const extraEntry = new Array();
return new Equip(type, lv, qualityBean, base, extraEntry);
};
const bracersSamples = {
colorful: new Array(),
unique: new Array(),
epic: new Array(),
artifact: new Array(),
};
bracersColorfulCategorys.forEach((item) => {
bracersSamples.colorful.push(bracersSample('colorful', item));
});
bracersUniqueCategorys.forEach((item) => {
bracersSamples.unique.push(bracersSample('unique', item));
});
bracersCategorys.forEach((item) => {
bracersSamples.epic.push(bracersSample('epic', item));
bracersSamples.artifact.push(bracersSample('artifact', item));
});
export { bracersSamples };