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

229 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', 'dmgPercent'];
const coefficient = { shabby: 0.6, ordinary: 0.9, artifact: 1.3, epic: 1.6, unique: 1.8, colorful: 1.8 };
export const jewelryColorfulCategorys = [
{
name: 'shuzhuang',
icon: 'jewelry/梳妆镜.png',
entry: [
{ type: 'atk', valCoefficient: 1 },
{ type: 'hp', valCoefficient: 0.7 },
{ type: 'def', valCoefficient: 0.4 },
],
skill: 'JHSY',
},
{
name: 'liulipan',
icon: 'jewelry/琉璃盘.png',
entry: [
{ type: 'atk', valCoefficient: 0.6 },
{ type: 'hp', valCoefficient: 1.5 },
],
skill: 'Liulipan',
},
{
name: 'ghdp',
icon: 'jewelry/勾魂夺魂.png',
entry: [
{ type: 'critDmg', valCoefficient: 1 },
{ type: 'crit', valCoefficient: 0.4 },
{ type: 'atk', valCoefficient: 0.5 },
],
skill: 'CritFear',
},
{
name: 'youerhuan',
icon: 'jewelry/白骨夫人的右耳环.png',
entry: [
{ type: 'critDmg', valCoefficient: 1.5 },
{ type: 'atk', valCoefficient: 0.8 },
],
skill: 'Vampire1',
},
{
name: 'jingboyu',
icon: 'jewelry/金钵盂.png',
entry: [
{ type: 'atk', valCoefficient: 0.8 },
{ type: 'hp', valCoefficient: 0.6 },
{ type: 'def', valCoefficient: 0.6 },
],
skill: 'Prototype',
},
{
name: 'zijingboyu',
icon: 'jewelry/紫金钵盂.png',
entry: [
{ type: 'atk', valCoefficient: 0.8 },
{ type: 'hp', valCoefficient: 0.6 },
{ type: 'def', valCoefficient: 0.6 },
],
skill: 'Fate',
},
];
export const jewelryUniqueCategorys = [
{
name: 'hanjing',
icon: 'jewelry/寒晶佩.png',
entry: [
{ type: 'atk', valCoefficient: 1 },
{ type: 'hp', valCoefficient: 0.8 },
{ type: 'def', valCoefficient: 0.9 },
],
},
{
name: 'ylhm',
icon: 'jewelry/月灵幻梦.png',
entry: [
{ type: 'critDmg', valCoefficient: 1.5 },
{ type: 'crit', valCoefficient: 0.5 },
{ type: 'atk', valCoefficient: 0.8 },
],
},
{
name: 'liangren',
icon: 'jewelry/良人.png',
entry: [
{ type: 'critDmg', valCoefficient: 1.2 },
{ type: 'dmgPercent', valCoefficient: 0.5 },
{ type: 'atk', valCoefficient: 0.7 },
],
},
{
name: 'duzhan',
icon: 'jewelry/督战.png',
entry: [
{ type: 'critDmg', valCoefficient: 1.6 },
{ type: 'atk', valCoefficient: 1.6 },
],
},
{
name: 'cltx',
icon: 'jewelry/赤羚天禧.png',
entry: [
{ type: 'dmgPercent', valCoefficient: 0.6 },
{ type: 'def', valCoefficient: 0.9 },
{ type: 'hp', valCoefficient: 1.2 },
],
},
];
export const jewelryCategorys = [
{
name: 'weihun',
icon: 'jewelry/未婚.png',
entry: [
{ type: 'def', valCoefficient: 0.9 },
{ type: 'hp', valCoefficient: 0.6 },
{ type: 'atk', valCoefficient: 0.5 },
],
},
{
name: 'huangyan',
icon: 'jewelry/谎言.png',
entry: [
{ type: 'crit', valCoefficient: 1.1 },
{ type: 'hp', valCoefficient: 0.5 },
{ type: 'atk', valCoefficient: 0.6 },
],
},
{
name: 'zhenjing',
icon: 'jewelry/真经.png',
entry: [
{ type: 'crit', valCoefficient: 1.1 },
{ type: 'hp', valCoefficient: 0.6 },
{ type: 'atk', valCoefficient: 0.5 },
],
},
{
name: 'maming',
icon: 'jewelry/马鸣玉佩.png',
entry: [
{ type: 'crit', valCoefficient: 0.75 },
{ type: 'critDmg', valCoefficient: 0.5 },
{ type: 'hp', valCoefficient: 0.5 },
],
},
];
export const initialJewelry = () => {
const type = 'jewelry';
const qualityBean = new Quality(qualitys[0], coefficient[qualitys[0]]);
const base = new EquipBase('shiwangsy', 'jewelry/狮王手印.png', [new Entry('hp', 20, '+20', 20, 20)]);
const extraEntry = [new Entry('crit', 10, '+10%', 10, 10)];
return new Equip(type, 1, qualityBean, base, extraEntry);
};
export const createJewelry = (quality, lv): Equip => {
const type = 'jewelry';
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(jewelryExtraEntry(quality, lv));
}
return new Equip(type, lv, qualityBean, base, extraEntry);
};
export const jewelryExtraEntry = (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 = jewelryCategorys;
switch (quality) {
case qualitys[4]:
categorys = jewelryUniqueCategorys;
break;
case qualitys[5]:
categorys = jewelryColorfulCategorys;
break;
}
return categorys[Math.floor(Math.random() * categorys.length)];
};
const jewelrySample = (quality, category): Equip => {
const type = 'jewelry';
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 jewelrySamples = {
colorful: new Array(),
unique: new Array(),
epic: new Array(),
artifact: new Array(),
};
jewelryColorfulCategorys.forEach((item) => {
jewelrySamples.colorful.push(jewelrySample('colorful', item));
});
jewelryUniqueCategorys.forEach((item) => {
jewelrySamples.unique.push(jewelrySample('unique', item));
});
jewelryCategorys.forEach((item) => {
jewelrySamples.epic.push(jewelrySample('epic', item));
jewelrySamples.artifact.push(jewelrySample('artifact', item));
});
export { jewelrySamples };