diff --git a/src/config/equips/armor.ts b/src/config/equips/armor.ts index 1fbe0de..02a8be1 100644 --- a/src/config/equips/armor.ts +++ b/src/config/equips/armor.ts @@ -1,128 +1,81 @@ -import { Entry, Quality, EquipBase, Equip } from './bean'; +import { getCategory, createExtraEntry, createBase, createSamples } from './base'; +import { Entry, Quality, EquipBase, Equip, Categorys } from './bean'; import { qualitys, entry_initor, extra_entry_num } from './constant'; const extraEntrys = ['atk', 'hp', 'def', 'defPercent', 'hpPercent', 'dmgReduc', 'critAvoid', 'critDmgReduc']; const coefficient = { shabby: 0.7, ordinary: 1, artifact: 1.5, epic: 1.8, unique: 2, colorful: 2 }; -export const armorColorfulCategorys = [ - { - name: 'baihua', - icon: 'armor/百花内甲.png', - entry: [ +export const armorColorfulCategorys: Categorys[] = [ + new Categorys( + 'baihua', + 'armor/百花内甲.png', + [ { type: 'def', valCoefficient: 1.0 }, { type: 'hp', valCoefficient: 1.4 }, { type: 'atk', valCoefficient: 1.4 }, ], - skill: 'BHXDJC', - }, + 'BHXDJC' + ), ]; -export const armorUniqueCategorys = [ - { - name: 'dispute', - icon: 'U_Armor01.png', - entry: [ - { type: 'def', valCoefficient: 1.0 }, - { type: 'hp', valCoefficient: 1.4 }, - { type: 'atk', valCoefficient: 1.4 }, - ], - }, - { - name: 'jianHao', - icon: 'U_Armor02.png', - entry: [ - { type: 'def', valCoefficient: 2.1 }, - { type: 'hp', valCoefficient: 2.6 }, - ], - }, - { - name: 'samurai', - icon: 'U_Armor03.png', - entry: [ - { type: 'def', valCoefficient: 1.3 }, - { type: 'hp', valCoefficient: 1.7 }, - { type: 'atk', valCoefficient: 0.9 }, - ], - }, - { - name: 'trackers', - icon: 'U_Armor04.png', - entry: [ - { type: 'def', valCoefficient: 0.9 }, - { type: 'critDmg', valCoefficient: 1.7 }, - { type: 'atk', valCoefficient: 1.7 }, - ], - }, - { - name: 'rongYi', - icon: 'U_Armor05.png', - entry: [ - { type: 'hp', valCoefficient: 1.6 }, - { type: 'atk', valCoefficient: 2.4 }, - { type: 'bloc', valCoefficient: 1.2 }, - ], - }, - { - name: 'nightwear', - icon: 'U_Armor06.png', - entry: [ - { type: 'def', valCoefficient: 1.2 }, - { type: 'hp', valCoefficient: 1.5 }, - { type: 'atk', valCoefficient: 1.2 }, - ], - }, - { - name: 'wildDragon', - icon: 'U_Armor07.png', - entry: [ - { type: 'def', valCoefficient: 1.5 }, - { type: 'bloc', valCoefficient: 1.2 }, - { type: 'hp', valCoefficient: 1.4 }, - ], - }, +export const armorUniqueCategorys: Categorys[] = [ + new Categorys('dispute', 'U_Armor01.png', [ + { type: 'def', valCoefficient: 1.0 }, + { type: 'hp', valCoefficient: 1.4 }, + { type: 'atk', valCoefficient: 1.4 }, + ]), + new Categorys('jianHao', 'U_Armor02.png', [ + { type: 'def', valCoefficient: 2.1 }, + { type: 'hp', valCoefficient: 2.6 }, + ]), + new Categorys('samurai', 'U_Armor03.png', [ + { type: 'def', valCoefficient: 1.3 }, + { type: 'hp', valCoefficient: 1.7 }, + { type: 'atk', valCoefficient: 0.9 }, + ]), + new Categorys('trackers', 'U_Armor04.png', [ + { type: 'def', valCoefficient: 0.9 }, + { type: 'critDmg', valCoefficient: 1.7 }, + { type: 'atk', valCoefficient: 1.7 }, + ]), + new Categorys('rongYi', 'U_Armor05.png', [ + { type: 'hp', valCoefficient: 1.6 }, + { type: 'atk', valCoefficient: 2.4 }, + { type: 'bloc', valCoefficient: 1.2 }, + ]), + new Categorys('nightwear', 'U_Armor06.png', [ + { type: 'def', valCoefficient: 1.2 }, + { type: 'hp', valCoefficient: 1.5 }, + { type: 'atk', valCoefficient: 1.2 }, + ]), + new Categorys('wildDragon', 'U_Armor07.png', [ + { type: 'def', valCoefficient: 1.5 }, + { type: 'bloc', valCoefficient: 1.2 }, + { type: 'hp', valCoefficient: 1.4 }, + ]), ]; -export const armorCategorys = [ - { - name: 'guard', - icon: 'A_A2.png', - entry: [ - { type: 'def', valCoefficient: 2 }, - { type: 'hp', valCoefficient: 0.6 }, - ], - }, - { - name: 'redWillow', - icon: 'A_A3.png', - entry: [ - { type: 'def', valCoefficient: 0.9 }, - { type: 'hp', valCoefficient: 1.2 }, - ], - }, - { - name: 'warrior', - icon: 'A_A5.png', - entry: [ - { type: 'def', valCoefficient: 1.1 }, - { type: 'hp', valCoefficient: 0.8 }, - ], - }, - { - name: 'lightArmor', - icon: 'A_A7.png', - entry: [ - { type: 'def', valCoefficient: 0.7 }, - { type: 'hp', valCoefficient: 0.5 }, - { type: 'atk', valCoefficient: 0.5 }, - ], - }, - { - name: 'furryArmor', - icon: 'A_A9.png', - entry: [ - { type: 'def', valCoefficient: 0.8 }, - { type: 'hp', valCoefficient: 0.8 }, - { type: 'atk', valCoefficient: 0.4 }, - ], - }, +export const armorCategorys: Categorys[] = [ + new Categorys('guard', 'A_A2.png', [ + { type: 'def', valCoefficient: 2 }, + { type: 'hp', valCoefficient: 0.6 }, + ]), + new Categorys('redWillow', 'A_A3.png', [ + { type: 'def', valCoefficient: 0.9 }, + { type: 'hp', valCoefficient: 1.2 }, + ]), + new Categorys('warrior', 'A_A5.png', [ + { type: 'def', valCoefficient: 1.1 }, + { type: 'hp', valCoefficient: 0.8 }, + ]), + new Categorys('lightArmor', 'A_A7.png', [ + { type: 'def', valCoefficient: 0.7 }, + { type: 'hp', valCoefficient: 0.5 }, + { type: 'atk', valCoefficient: 0.5 }, + ]), + new Categorys('furryArmor', 'A_A9.png', [ + { type: 'def', valCoefficient: 0.8 }, + { type: 'hp', valCoefficient: 0.8 }, + { type: 'atk', valCoefficient: 0.4 }, + ]), ]; export const initialArmor = () => { @@ -136,69 +89,14 @@ export const initialArmor = () => { export const createArmor = (quality, lv) => { const type = 'armor'; const qualityBean = new Quality(quality, coefficient[quality]); - const category = getCategory(quality); - const base = createBase(quality, lv, category); + const category = getCategory(quality, armorCategorys, armorUniqueCategorys, armorColorfulCategorys); + const base = createBase(quality, lv, category, coefficient); const extraEntry = new Array(); const extraEntryNum = extra_entry_num[quality]; for (let i = 0; i < extraEntryNum; i++) { - extraEntry.push(armorExtraEntry(quality, lv)); + extraEntry.push(createExtraEntry(quality, lv, extraEntrys, coefficient)); } return new Equip(type, lv, qualityBean, base, extraEntry); }; -export const armorExtraEntry = (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 = armorCategorys; - switch (quality) { - case qualitys[4]: - categorys = armorUniqueCategorys; - break; - case qualitys[5]: - categorys = armorColorfulCategorys; - break; - } - return categorys[Math.floor(Math.random() * categorys.length)]; -}; - -const armorSample = (quality, category): Equip => { - const type = 'armor'; - 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 armorSamples = { - colorful: new Array(), - unique: new Array(), - epic: new Array(), - artifact: new Array(), -}; -armorColorfulCategorys.forEach((item) => { - armorSamples.colorful.push(armorSample('colorful', item)); -}); -armorUniqueCategorys.forEach((item) => { - armorSamples.unique.push(armorSample('unique', item)); -}); -armorCategorys.forEach((item) => { - armorSamples.epic.push(armorSample('epic', item)); - armorSamples.artifact.push(armorSample('artifact', item)); -}); -export { armorSamples }; +export const armorSamples = createSamples(armorCategorys, armorUniqueCategorys, armorColorfulCategorys, 'armor', coefficient); diff --git a/src/config/equips/base.ts b/src/config/equips/base.ts new file mode 100644 index 0000000..b603c0c --- /dev/null +++ b/src/config/equips/base.ts @@ -0,0 +1,65 @@ +import { Categorys, Equip, EquipBase, Quality } from './bean'; +import { entry_initor, qualitys } from './constant'; + +export const getCategory = (quality, categorys: Categorys[], uniqueCategorys: Categorys[], colorfulCategorys: Categorys[]) => { + switch (quality) { + case qualitys[4]: + categorys = uniqueCategorys; + break; + case qualitys[5]: + categorys = colorfulCategorys; + break; + } + while (true) { + const category = categorys[Math.floor(Math.random() * categorys.length)]; + if (category.reRoll > 0 && Math.random() < category.reRoll) { + continue; + } + return category; + } +}; + +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(); + return new Equip(type, lv, qualityBean, base, extraEntry); +}; diff --git a/src/config/equips/bean.ts b/src/config/equips/bean.ts index d3a144d..b14073a 100644 --- a/src/config/equips/bean.ts +++ b/src/config/equips/bean.ts @@ -61,3 +61,19 @@ export class Equip { this.extraEntry = extraEntry; } } + +export class Categorys { + name: string; + icon: string; + entry: any[]; + skill?: string; + reRoll: number; + + constructor(name: string, icon: string, entry: any[], skill?: string, reRoll?: number) { + this.name = name; + this.icon = icon; + this.entry = entry; + this.skill = skill; + this.reRoll = reRoll || 0; + } +} diff --git a/src/config/equips/bracers.ts b/src/config/equips/bracers.ts index ed5d8cd..ee7acc1 100644 --- a/src/config/equips/bracers.ts +++ b/src/config/equips/bracers.ts @@ -1,105 +1,70 @@ -import { Entry, Quality, EquipBase, Equip } from './bean'; -import { qualitys, entry_initor, extra_entry_num } from './constant'; +import { getCategory, createExtraEntry, createBase, createSamples } from './base'; +import { Entry, Quality, EquipBase, Equip, Categorys } from './bean'; +import { qualitys, 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: 'xianglong', - icon: 'bracers/降龙.png', - entry: [ +export const bracersColorfulCategorys: Categorys[] = [ + new Categorys( + 'xianglong', + 'bracers/降龙.png', + [ { type: 'critDmg', valCoefficient: 1.2 }, { type: 'atkPercent', valCoefficient: 0.7 }, { type: 'atk', valCoefficient: 1 }, ], - skill: 'Xianglong', - }, + 'Xianglong' + ), ]; -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 bracersUniqueCategorys: Categorys[] = [ + new Categorys('duoqing', 'bracers/多情腕.png', [ + { type: 'atk', valCoefficient: 1 }, + { type: 'hp', valCoefficient: 0.8 }, + { type: 'def', valCoefficient: 0.9 }, + ]), + new Categorys('wano', 'bracers/玩藕.png', [ + { type: 'critDmg', valCoefficient: 1.5 }, + { type: 'crit', valCoefficient: 0.5 }, + { type: 'atk', valCoefficient: 0.8 }, + ]), + new Categorys('rsggu', 'bracers/人参果裹布.png', [ + { type: 'critDmg', valCoefficient: 1.2 }, + { type: 'atkPercent', valCoefficient: 1.0 }, + { type: 'atk', valCoefficient: 0.7 }, + ]), + new Categorys('yingwu', 'bracers/鹦鹉杯.png', [ + { type: 'critDmg', valCoefficient: 1.6 }, + { type: 'atk', valCoefficient: 1.6 }, + ]), + new Categorys('meipusa', 'bracers/美菩萨.png', [ + { 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 bracersCategorys: Categorys[] = [ + new Categorys('guoshi', 'bracers/裹尸布.png', [ + { type: 'def', valCoefficient: 0.9 }, + { type: 'hp', valCoefficient: 0.6 }, + { type: 'atk', valCoefficient: 0.5 }, + ]), + new Categorys('xiuyugu', 'bracers/绣与骨.png', [ + { type: 'crit', valCoefficient: 1.1 }, + { type: 'hp', valCoefficient: 0.5 }, + { type: 'atk', valCoefficient: 0.6 }, + ]), + new Categorys('huoshen', 'bracers/火神腕.png', [ + { type: 'crit', valCoefficient: 1.1 }, + { type: 'hp', valCoefficient: 0.6 }, + { type: 'atk', valCoefficient: 0.5 }, + ]), + new Categorys('heishou', 'bracers/黑手.png', [ + { type: 'crit', valCoefficient: 0.75 }, + { type: 'critDmg', valCoefficient: 0.5 }, + { type: 'hp', valCoefficient: 0.5 }, + ]), ]; export const initialbracers = () => { @@ -113,69 +78,14 @@ export const initialbracers = () => { 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 category = getCategory(quality, bracersCategorys, bracersUniqueCategorys, bracersColorfulCategorys); + const base = createBase(quality, lv, category, coefficient); 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; + extraEntry.push(createExtraEntry(quality, lv, extraEntrys, coefficient)); } - 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 }; +export const bracersSamples = createSamples(bracersCategorys, bracersUniqueCategorys, bracersColorfulCategorys, 'bracers', coefficient); diff --git a/src/config/equips/jewelry.ts b/src/config/equips/jewelry.ts index bb3045b..3cafeb0 100644 --- a/src/config/equips/jewelry.ts +++ b/src/config/equips/jewelry.ts @@ -1,153 +1,118 @@ -import { Entry, Quality, EquipBase, Equip } from './bean'; -import { qualitys, entry_initor, extra_entry_num } from './constant'; +import { getCategory, createExtraEntry, createBase, createSamples } from './base'; +import { Entry, Quality, EquipBase, Equip, Categorys } from './bean'; +import { qualitys, 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: [ +export const jewelryColorfulCategorys: Categorys[] = [ + new Categorys( + 'shuzhuang', + 'jewelry/梳妆镜.png', + [ { type: 'atk', valCoefficient: 1 }, { type: 'hp', valCoefficient: 0.7 }, { type: 'def', valCoefficient: 0.4 }, ], - skill: 'JHSY', - }, - { - name: 'liulipan', - icon: 'jewelry/琉璃盘.png', - entry: [ + 'JHSY' + ), + new Categorys( + 'liulipan', + 'jewelry/琉璃盘.png', + [ { type: 'atk', valCoefficient: 0.6 }, { type: 'hp', valCoefficient: 1.5 }, ], - skill: 'Liulipan', - }, - { - name: 'ghdp', - icon: 'jewelry/勾魂夺魂.png', - entry: [ + 'Liulipan' + ), + new Categorys( + 'ghdp', + 'jewelry/勾魂夺魂.png', + [ { type: 'critDmg', valCoefficient: 1 }, { type: 'crit', valCoefficient: 0.4 }, { type: 'atk', valCoefficient: 0.5 }, ], - skill: 'CritFear', - }, - { - name: 'youerhuan', - icon: 'jewelry/白骨夫人的右耳环.png', - entry: [ + 'CritFear' + ), + new Categorys( + 'youerhuan', + 'jewelry/白骨夫人的右耳环.png', + [ { type: 'critDmg', valCoefficient: 1.5 }, { type: 'atk', valCoefficient: 0.8 }, ], - skill: 'Vampire1', - }, - { - name: 'jingboyu', - icon: 'jewelry/金钵盂.png', - entry: [ + 'Vampire1' + ), + new Categorys( + 'jingboyu', + 'jewelry/金钵盂.png', + [ { type: 'atk', valCoefficient: 0.8 }, { type: 'hp', valCoefficient: 0.6 }, { type: 'def', valCoefficient: 0.6 }, ], - skill: 'Prototype', - }, - { - name: 'zijingboyu', - icon: 'jewelry/紫金钵盂.png', - entry: [ + 'Prototype' + ), + new Categorys( + 'zijingboyu', + 'jewelry/紫金钵盂.png', + [ { type: 'atk', valCoefficient: 0.8 }, { type: 'hp', valCoefficient: 0.6 }, { type: 'def', valCoefficient: 0.6 }, ], - skill: 'Fate', - }, + '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.4 }, - { 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.5 }, - { type: 'def', valCoefficient: 0.9 }, - { type: 'hp', valCoefficient: 1.2 }, - ], - }, +export const jewelryUniqueCategorys: Categorys[] = [ + new Categorys('hanjing', 'jewelry/寒晶佩.png', [ + { type: 'atk', valCoefficient: 1 }, + { type: 'hp', valCoefficient: 0.8 }, + { type: 'def', valCoefficient: 0.9 }, + ]), + new Categorys('ylhm', 'jewelry/月灵幻梦.png', [ + { type: 'critDmg', valCoefficient: 1.5 }, + { type: 'crit', valCoefficient: 0.5 }, + { type: 'atk', valCoefficient: 0.8 }, + ]), + new Categorys('liangren', 'jewelry/月灵良人幻梦.png', [ + { type: 'critDmg', valCoefficient: 1.2 }, + { type: 'dmgPercent', valCoefficient: 0.4 }, + { type: 'atk', valCoefficient: 0.7 }, + ]), + new Categorys('duzhan', 'jewelry/督战.png', [ + { type: 'critDmg', valCoefficient: 1.6 }, + { type: 'atk', valCoefficient: 1.6 }, + ]), + new Categorys('cltx', 'jewelry/赤羚天禧.png', [ + { type: 'dmgPercent', valCoefficient: 0.5 }, + { 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 jewelryCategorys: Categorys[] = [ + new Categorys('weihun', 'jewelry/未婚.png', [ + { type: 'def', valCoefficient: 0.9 }, + { type: 'hp', valCoefficient: 0.6 }, + { type: 'atk', valCoefficient: 0.5 }, + ]), + new Categorys('huangyan', 'jewelry/谎言.png', [ + { type: 'crit', valCoefficient: 1.1 }, + { type: 'hp', valCoefficient: 0.5 }, + { type: 'atk', valCoefficient: 0.6 }, + ]), + new Categorys('zhenjing', 'jewelry/真经.png', [ + { type: 'crit', valCoefficient: 1.1 }, + { type: 'hp', valCoefficient: 0.6 }, + { type: 'atk', valCoefficient: 0.5 }, + ]), + new Categorys('maming', 'jewelry/马鸣玉佩.png', [ + { type: 'crit', valCoefficient: 0.75 }, + { type: 'critDmg', valCoefficient: 0.5 }, + { type: 'hp', valCoefficient: 0.5 }, + ]), ]; export const initialJewelry = () => { @@ -161,69 +126,13 @@ export const initialJewelry = () => { 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 category = getCategory(quality, jewelryCategorys, jewelryUniqueCategorys, jewelryColorfulCategorys); + const base = createBase(quality, lv, category, coefficient); const extraEntry = new Array(); const extraEntryNum = extra_entry_num[quality]; for (let i = 0; i < extraEntryNum; i++) { - extraEntry.push(jewelryExtraEntry(quality, lv)); + extraEntry.push(createExtraEntry(quality, lv, extraEntrys, coefficient)); } 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 }; +export const jewelrySamples = createSamples(jewelryCategorys, jewelryUniqueCategorys, jewelryColorfulCategorys, 'jewelry', coefficient); diff --git a/src/config/equips/neck.ts b/src/config/equips/neck.ts index 0025c94..84e54af 100644 --- a/src/config/equips/neck.ts +++ b/src/config/equips/neck.ts @@ -1,86 +1,55 @@ -import { Entry, Quality, EquipBase, Equip } from './bean'; -import { qualitys, entry_initor, extra_entry_num } from './constant'; +import { getCategory, createExtraEntry, createBase, createSamples } from './base'; +import { Entry, Quality, EquipBase, Equip, Categorys } from './bean'; +import { qualitys, extra_entry_num } from './constant'; const extraEntrys = ['atk', 'crit', 'critDmg', 'hp', 'def', 'bloc']; const coefficient = { shabby: 0.6, ordinary: 0.9, artifact: 1.3, epic: 1.6, unique: 1.8, colorful: 1.8 }; -export const neckColorfulCategorys = []; +export const neckColorfulCategorys: Categorys[] = []; -export const neckUniqueCategorys = [ - { - name: 'demonSlayer', - icon: 'U_neck01.png', - entry: [ - { type: 'atk', valCoefficient: 1.0 }, - { type: 'hp', valCoefficient: 0.8 }, - { type: 'def', valCoefficient: 0.9 }, - ], - }, - { - name: 'darkDragon', - icon: 'U_neck02.png', - entry: [ - { type: 'critDmg', valCoefficient: 1.5 }, - { type: 'crit', valCoefficient: 0.5 }, - { type: 'hp', valCoefficient: 0.8 }, - ], - }, - { - name: 'single', - icon: 'U_neck03.png', - entry: [ - { type: 'critDmg', valCoefficient: 1.5 }, - { type: 'bloc', valCoefficient: 0.7 }, - { type: 'hp', valCoefficient: 0.7 }, - ], - }, - { - name: 'demons', - icon: 'U_neck04.png', - entry: [ - { type: 'critDmg', valCoefficient: 1.6 }, - { type: 'atk', valCoefficient: 1.6 }, - ], - }, - { - name: 'ipaya', - icon: 'U_neck05.png', - entry: [ - { type: 'bloc', valCoefficient: 0.9 }, - { type: 'def', valCoefficient: 0.9 }, - { type: 'hp', valCoefficient: 1.3 }, - ], - }, +export const neckUniqueCategorys: Categorys[] = [ + new Categorys('demonSlayer', 'U_neck01.png', [ + { type: 'atk', valCoefficient: 1.0 }, + { type: 'hp', valCoefficient: 0.8 }, + { type: 'def', valCoefficient: 0.9 }, + ]), + new Categorys('darkDragon', 'U_neck02.png', [ + { type: 'critDmg', valCoefficient: 1.5 }, + { type: 'crit', valCoefficient: 0.5 }, + { type: 'hp', valCoefficient: 0.8 }, + ]), + new Categorys('single', 'U_neck03.png', [ + { type: 'critDmg', valCoefficient: 1.5 }, + { type: 'bloc', valCoefficient: 0.7 }, + { type: 'hp', valCoefficient: 0.7 }, + ]), + new Categorys('demons', 'U_neck04.png', [ + { type: 'critDmg', valCoefficient: 1.6 }, + { type: 'atk', valCoefficient: 1.6 }, + ]), + new Categorys('ipaya', 'U_neck05.png', [ + { type: 'bloc', valCoefficient: 0.9 }, + { type: 'def', valCoefficient: 0.9 }, + { type: 'hp', valCoefficient: 1.3 }, + ]), ]; -export const neckCategorys = [ - { - name: 'crusade', - icon: 'Ac_1.png', - entry: [ - { type: 'def', valCoefficient: 0.9 }, - { type: 'hp', valCoefficient: 0.5 }, - { type: 'bloc', valCoefficient: 0.6 }, - ], - }, - { - name: 'gintamaEyes', - icon: 'Ac_5.png', - entry: [ - { type: 'crit', valCoefficient: 1.1 }, - { type: 'hp', valCoefficient: 0.5 }, - { type: 'atk', valCoefficient: 0.6 }, - ], - }, - { - name: 'iceDragon', - icon: 'Ac_7.png', - entry: [ - { type: 'crit', valCoefficient: 0.75 }, - { type: 'critDmg', valCoefficient: 0.5 }, - { type: 'hp', valCoefficient: 0.5 }, - ], - }, +export const neckCategorys: Categorys[] = [ + new Categorys('crusade', 'Ac_1.png', [ + { type: 'def', valCoefficient: 0.9 }, + { type: 'hp', valCoefficient: 0.5 }, + { type: 'bloc', valCoefficient: 0.6 }, + ]), + new Categorys('gintamaEyes', 'Ac_5.png', [ + { type: 'crit', valCoefficient: 1.1 }, + { type: 'hp', valCoefficient: 0.5 }, + { type: 'atk', valCoefficient: 0.6 }, + ]), + new Categorys('iceDragon', 'Ac_7.png', [ + { type: 'crit', valCoefficient: 0.75 }, + { type: 'critDmg', valCoefficient: 0.5 }, + { type: 'hp', valCoefficient: 0.5 }, + ]), ]; export const initialNeck = () => { @@ -94,69 +63,14 @@ export const initialNeck = () => { export const createNeck = (quality, lv) => { const type = 'neck'; const qualityBean = new Quality(quality, coefficient[quality]); - const category = getCategory(quality); - const base = createBase(quality, lv, category); + const category = getCategory(quality, neckCategorys, neckUniqueCategorys, neckColorfulCategorys); + const base = createBase(quality, lv, category, coefficient); const extraEntry = new Array(); const extraEntryNum = extra_entry_num[quality]; for (let i = 0; i < extraEntryNum; i++) { - extraEntry.push(neckExtraEntry(quality, lv)); + extraEntry.push(createExtraEntry(quality, lv, extraEntrys, coefficient)); } return new Equip(type, lv, qualityBean, base, extraEntry); }; -export const neckExtraEntry = (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); -}; -const getCategory = (quality) => { - let categorys = neckCategorys; - switch (quality) { - case qualitys[4]: - categorys = neckUniqueCategorys; - break; - case qualitys[5]: - categorys = neckColorfulCategorys; - break; - } - return categorys[Math.floor(Math.random() * categorys.length)]; -}; - -const neckSample = (quality, category): Equip => { - const type = 'neck'; - 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 neckSamples = { - colorful: new Array(), - unique: new Array(), - epic: new Array(), - artifact: new Array(), -}; -neckColorfulCategorys.forEach((item) => { - neckSamples.colorful.push(neckSample('colorful', item)); -}); -neckUniqueCategorys.forEach((item) => { - neckSamples.unique.push(neckSample('unique', item)); -}); -neckCategorys.forEach((item) => { - neckSamples.epic.push(neckSample('epic', item)); - neckSamples.artifact.push(neckSample('artifact', item)); -}); -export { neckSamples }; +export const neckSamples = createSamples(neckCategorys, neckUniqueCategorys, neckColorfulCategorys, 'neck', coefficient); diff --git a/src/config/equips/pants.ts b/src/config/equips/pants.ts index 05c8828..db8486b 100644 --- a/src/config/equips/pants.ts +++ b/src/config/equips/pants.ts @@ -1,82 +1,51 @@ -import { Entry, Quality, EquipBase, Equip } from './bean'; -import { qualitys, entry_initor, extra_entry_num } from './constant'; +import { getCategory, createExtraEntry, createBase, createSamples } from './base'; +import { Entry, Quality, EquipBase, Equip, Categorys } from './bean'; +import { qualitys, extra_entry_num } from './constant'; const extraEntrys = ['atk', 'hp', 'def', 'defPercent', 'hpPercent', 'dmgReduc', 'critAvoid', 'critDmgReduc']; const coefficient = { shabby: 0.7, ordinary: 1, artifact: 1.5, epic: 1.8, unique: 2, colorful: 2 }; -export const pantsColorfulCategorys = []; +export const pantsColorfulCategorys: Categorys[] = []; -export const pantsUniqueCategorys = [ - { - name: 'mhlg', - icon: 'pants/梦回龙宫.png', - entry: [ - { type: 'def', valCoefficient: 2 }, - { type: 'hp', valCoefficient: 2.8 }, - ], - }, - { - name: 'longlin', - icon: 'pants/龙鳞胫甲.png', - entry: [ - { type: 'def', valCoefficient: 0.9 }, - { type: 'critDmg', valCoefficient: 1.7 }, - { type: 'atk', valCoefficient: 1.7 }, - ], - }, - { - name: 'qiutu', - icon: 'pants/囚徒.png', - entry: [ - { type: 'hp', valCoefficient: 2 }, - { type: 'atk', valCoefficient: 2 }, - { type: 'bloc', valCoefficient: 1.2 }, - ], - }, - { - name: 'wuwei', - icon: 'pants/五味.png', - entry: [ - { type: 'def', valCoefficient: 1.2 }, - { type: 'hp', valCoefficient: 1.7 }, - { type: 'atk', valCoefficient: 1.0 }, - ], - }, - { - name: 'cangjing', - icon: 'pants/藏经甲.png', - entry: [ - { type: 'def', valCoefficient: 1.5 }, - { type: 'bloc', valCoefficient: 1.2 }, - { type: 'hp', valCoefficient: 1.4 }, - ], - }, +export const pantsUniqueCategorys: Categorys[] = [ + new Categorys('mhlg', 'pants/梦回龙宫.png', [ + { type: 'def', valCoefficient: 2 }, + { type: 'hp', valCoefficient: 2.8 }, + ]), + new Categorys('longlin', 'pants/龙鳞胫甲.png', [ + { type: 'def', valCoefficient: 0.9 }, + { type: 'critDmg', valCoefficient: 1.7 }, + { type: 'atk', valCoefficient: 1.7 }, + ]), + new Categorys('qiutu', 'pants/囚徒.png', [ + { type: 'hp', valCoefficient: 2 }, + { type: 'atk', valCoefficient: 2 }, + { type: 'bloc', valCoefficient: 1.2 }, + ]), + new Categorys('wuwei', 'pants/五味.png', [ + { type: 'def', valCoefficient: 1.2 }, + { type: 'hp', valCoefficient: 1.7 }, + { type: 'atk', valCoefficient: 1.0 }, + ]), + new Categorys('cangjing', 'pants/藏经甲.png', [ + { type: 'def', valCoefficient: 1.5 }, + { type: 'bloc', valCoefficient: 1.2 }, + { type: 'hp', valCoefficient: 1.4 }, + ]), ]; -export const pantsCategorys = [ - { - name: 'qijia', - icon: 'pants/泣甲.png', - entry: [ - { type: 'def', valCoefficient: 2 }, - { type: 'hp', valCoefficient: 0.6 }, - ], - }, - { - name: 'guanjia', - icon: 'pants/管家服.png', - entry: [ - { type: 'def', valCoefficient: 0.8 }, - { type: 'hp', valCoefficient: 1.8 }, - ], - }, - { - name: 'egui', - icon: 'pants/饿鬼.png', - entry: [ - { type: 'def', valCoefficient: 0.8 }, - { type: 'hp', valCoefficient: 0.8 }, - { type: 'atk', valCoefficient: 0.8 }, - ], - }, +export const pantsCategorys: Categorys[] = [ + new Categorys('qijia', 'pants/泣甲.png', [ + { type: 'def', valCoefficient: 2 }, + { type: 'hp', valCoefficient: 0.6 }, + ]), + new Categorys('guanjia', 'pants/管家服.png', [ + { type: 'def', valCoefficient: 0.8 }, + { type: 'hp', valCoefficient: 1.8 }, + ]), + new Categorys('egui', 'pants/饿鬼.png', [ + { type: 'def', valCoefficient: 0.8 }, + { type: 'hp', valCoefficient: 0.8 }, + { type: 'atk', valCoefficient: 0.8 }, + ]), ]; export const initialpants = () => { @@ -90,69 +59,14 @@ export const initialpants = () => { export const createpants = (quality, lv) => { const type = 'pants'; const qualityBean = new Quality(quality, coefficient[quality]); - const category = getCategory(quality); - const base = createBase(quality, lv, category); + const category = getCategory(quality, pantsCategorys, pantsUniqueCategorys, pantsColorfulCategorys); + const base = createBase(quality, lv, category, coefficient); const extraEntry = new Array(); const extraEntryNum = extra_entry_num[quality]; for (let i = 0; i < extraEntryNum; i++) { - extraEntry.push(pantsExtraEntry(quality, lv)); + extraEntry.push(createExtraEntry(quality, lv, extraEntrys, coefficient)); } return new Equip(type, lv, qualityBean, base, extraEntry); }; -export const pantsExtraEntry = (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); -}; - -const getCategory = (quality) => { - let categorys = pantsCategorys; - switch (quality) { - case qualitys[4]: - categorys = pantsUniqueCategorys; - break; - case qualitys[5]: - categorys = pantsColorfulCategorys; - break; - } - return categorys[Math.floor(Math.random() * categorys.length)]; -}; - -const pantsSample = (quality, category): Equip => { - const type = 'pants'; - 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 pantsSamples = { - colorful: new Array(), - unique: new Array(), - epic: new Array(), - artifact: new Array(), -}; -pantsColorfulCategorys.forEach((item) => { - pantsSamples.colorful.push(pantsSample('colorful', item)); -}); -pantsUniqueCategorys.forEach((item) => { - pantsSamples.unique.push(pantsSample('unique', item)); -}); -pantsCategorys.forEach((item) => { - pantsSamples.epic.push(pantsSample('epic', item)); - pantsSamples.artifact.push(pantsSample('artifact', item)); -}); -export { pantsSamples }; +export const pantsSamples = createSamples(pantsCategorys, pantsUniqueCategorys, pantsColorfulCategorys, 'pants', coefficient); diff --git a/src/config/equips/ring.ts b/src/config/equips/ring.ts index 86ab19b..741e9d1 100644 --- a/src/config/equips/ring.ts +++ b/src/config/equips/ring.ts @@ -1,80 +1,49 @@ -import { Entry, Quality, EquipBase, Equip } from './bean'; -import { qualitys, entry_initor, extra_entry_num } from './constant'; +import { getCategory, createExtraEntry, createBase, createSamples } from './base'; +import { Entry, Quality, EquipBase, Equip, Categorys } from './bean'; +import { qualitys, extra_entry_num } from './constant'; const extraEntrys = ['atk', 'crit', 'critDmg', 'hp', 'def']; const coefficient = { shabby: 0.6, ordinary: 0.9, artifact: 1.3, epic: 1.6, unique: 1.8, colorful: 2 }; -export const ringColorfulCategorys = []; +export const ringColorfulCategorys: Categorys[] = []; -export const ringUniqueCategorys = [ - { - name: 'death', - icon: 'U_ring01.png', - entry: [ - { type: 'crit', valCoefficient: 1 }, - { type: 'critDmg', valCoefficient: 0.5 }, - { type: 'hp', valCoefficient: 0.8 }, - ], - }, - { - name: 'realFurryRing', - icon: 'U_ring02.png', - entry: [ - { type: 'critDmg', valCoefficient: 1.2 }, - { type: 'crit', valCoefficient: 0.5 }, - { type: 'atk', valCoefficient: 0.7 }, - ], - }, - { - name: 'pioneer', - icon: 'U_ring03.png', - entry: [ - { type: 'critDmg', valCoefficient: 1 }, - { type: 'crit', valCoefficient: 0.5 }, - { type: 'hp', valCoefficient: 0.7 }, - ], - }, - { - name: 'susan', - icon: 'U_ring04.png', - entry: [ - { type: 'critDmg', valCoefficient: 1.6 }, - { type: 'atk', valCoefficient: 1.1 }, - ], - }, - { - name: 'moonlight', - icon: 'U_ring05.png', - entry: [ - { type: 'critDmg', valCoefficient: 1.5 }, - { type: 'hp', valCoefficient: 1.2 }, - ], - }, +export const ringUniqueCategorys: Categorys[] = [ + new Categorys('death', 'U_ring01.png', [ + { type: 'crit', valCoefficient: 1 }, + { type: 'critDmg', valCoefficient: 0.5 }, + { type: 'hp', valCoefficient: 0.8 }, + ]), + new Categorys('realFurryRing', 'U_ring02.png', [ + { type: 'critDmg', valCoefficient: 1.2 }, + { type: 'crit', valCoefficient: 0.5 }, + { type: 'atk', valCoefficient: 0.7 }, + ]), + new Categorys('pioneer', 'U_ring03.png', [ + { type: 'critDmg', valCoefficient: 1 }, + { type: 'crit', valCoefficient: 0.5 }, + { type: 'hp', valCoefficient: 0.7 }, + ]), + new Categorys('susan', 'U_ring04.png', [ + { type: 'critDmg', valCoefficient: 1.6 }, + { type: 'atk', valCoefficient: 1.1 }, + ]), + new Categorys('moonlight', 'U_ring05.png', [ + { type: 'critDmg', valCoefficient: 1.5 }, + { type: 'hp', valCoefficient: 1.2 }, + ]), ]; export const ringCategorys = [ - { - name: 'life', - icon: 'Ac_9.png', - entry: [{ type: 'hp', valCoefficient: 1.5 }], - }, - { - name: 'imperialSoul', - icon: 'Ac_10.png', - entry: [ - { type: 'hp', valCoefficient: 1 }, - { type: 'atk', valCoefficient: 0.5 }, - ], - }, - { - name: 'furryRing', - icon: 'Ac_11.png', - entry: [ - { type: 'hp', valCoefficient: 0.9 }, - { type: 'atk', valCoefficient: 0.3 }, - { type: 'crit', valCoefficient: 0.8 }, - ], - }, + new Categorys('life', 'Ac_9.png', [{ type: 'hp', valCoefficient: 1.5 }]), + new Categorys('imperialSoul', 'Ac_10.png', [ + { type: 'hp', valCoefficient: 1 }, + { type: 'atk', valCoefficient: 0.5 }, + ]), + new Categorys('furryRing', 'Ac_11.png', [ + { type: 'hp', valCoefficient: 0.9 }, + { type: 'atk', valCoefficient: 0.3 }, + { type: 'crit', valCoefficient: 0.8 }, + ]), ]; export const initialRing = () => { @@ -88,69 +57,14 @@ export const initialRing = () => { export const createRing = (quality, lv) => { const type = 'ring'; const qualityBean = new Quality(quality, coefficient[quality]); - const category = getCategory(quality); - const base = createBase(quality, lv, category); + const category = getCategory(quality, ringCategorys, ringUniqueCategorys, ringColorfulCategorys); + const base = createBase(quality, lv, category, coefficient); const extraEntry = new Array(); const extraEntryNum = extra_entry_num[quality]; for (let i = 0; i < extraEntryNum; i++) { - extraEntry.push(ringExtraEntry(quality, lv)); + extraEntry.push(createExtraEntry(quality, lv, extraEntrys, coefficient)); } return new Equip(type, lv, qualityBean, base, extraEntry); }; -export const ringExtraEntry = (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); -}; - -const getCategory = (quality) => { - let categorys = ringCategorys; - switch (quality) { - case qualitys[4]: - categorys = ringUniqueCategorys; - break; - case qualitys[5]: - categorys = ringColorfulCategorys; - break; - } - return categorys[Math.floor(Math.random() * categorys.length)]; -}; - -const ringSample = (quality, category): Equip => { - const type = 'ring'; - 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 ringSamples = { - colorful: new Array(), - unique: new Array(), - epic: new Array(), - artifact: new Array(), -}; -ringColorfulCategorys.forEach((item) => { - ringSamples.colorful.push(ringSample('colorful', item)); -}); -ringUniqueCategorys.forEach((item) => { - ringSamples.unique.push(ringSample('unique', item)); -}); -ringCategorys.forEach((item) => { - ringSamples.epic.push(ringSample('epic', item)); - ringSamples.artifact.push(ringSample('artifact', item)); -}); -export { ringSamples }; +export const ringSamples = createSamples(ringCategorys, ringUniqueCategorys, ringColorfulCategorys, 'ring', coefficient); diff --git a/src/config/equips/shoes.ts b/src/config/equips/shoes.ts index c39613b..947551e 100644 --- a/src/config/equips/shoes.ts +++ b/src/config/equips/shoes.ts @@ -1,82 +1,51 @@ -import { Entry, Quality, EquipBase, Equip } from './bean'; -import { qualitys, entry_initor, extra_entry_num } from './constant'; +import { getCategory, createExtraEntry, createBase, createSamples } from './base'; +import { Entry, Quality, EquipBase, Equip, Categorys } from './bean'; +import { qualitys, extra_entry_num } from './constant'; const extraEntrys = ['atk', 'hp', 'def', 'moveSpeed', 'dmgReduc']; const coefficient = { shabby: 0.7, ordinary: 1, artifact: 1.3, epic: 1.5, unique: 1.8, colorful: 1.8 }; -export const shoesColorfulCategorys = []; +export const shoesColorfulCategorys: Categorys[] = []; -export const shoesUniqueCategorys = [ - { - name: 'qxzl', - icon: 'shoes/浅夏紫灵.png', - entry: [ - { type: 'moveSpeed', valCoefficient: 1.5 }, - { type: 'atk', valCoefficient: 1.2 }, - { type: 'hp', valCoefficient: 1.4 }, - ], - }, - { - name: 'xuedun', - icon: 'shoes/血遁靴.png', - entry: [ - { type: 'moveSpeed', valCoefficient: 2.8 }, - { type: 'hp', valCoefficient: 1.2 }, - ], - }, - { - name: 'talang', - icon: 'shoes/踏浪.jpg', - entry: [ - { type: 'moveSpeed', valCoefficient: 1.8 }, - { type: 'hp', valCoefficient: 1 }, - { type: 'atk', valCoefficient: 1.2 }, - ], - }, - { - name: 'jiuwanli', - icon: 'shoes/九万里.png', - entry: [ - { type: 'moveSpeed', valCoefficient: 1.9 }, - { type: 'def', valCoefficient: 1 }, - { type: 'hp', valCoefficient: 1.2 }, - ], - }, - { - name: 'hongchen', - icon: 'shoes/红尘.png', - entry: [ - { type: 'moveSpeed', valCoefficient: 1.2 }, - { type: 'def', valCoefficient: 1.5 }, - { type: 'hp', valCoefficient: 1.4 }, - ], - }, +export const shoesUniqueCategorys: Categorys[] = [ + new Categorys('qxzl', 'shoes/浅夏紫灵.png', [ + { type: 'moveSpeed', valCoefficient: 1.5 }, + { type: 'atk', valCoefficient: 1.2 }, + { type: 'hp', valCoefficient: 1.4 }, + ]), + new Categorys('xuedun', 'shoes/血遁靴.png', [ + { type: 'moveSpeed', valCoefficient: 2.8 }, + { type: 'hp', valCoefficient: 1.2 }, + ]), + new Categorys('talang', 'shoes/踏浪.png', [ + { type: 'moveSpeed', valCoefficient: 1.8 }, + { type: 'hp', valCoefficient: 1 }, + { type: 'atk', valCoefficient: 1.2 }, + ]), + new Categorys('jiuwanli', 'shoes/九万里.png', [ + { type: 'moveSpeed', valCoefficient: 1.9 }, + { type: 'def', valCoefficient: 1 }, + { type: 'hp', valCoefficient: 1.2 }, + ]), + new Categorys('hongchen', 'shoes/红尘.png', [ + { type: 'moveSpeed', valCoefficient: 1.2 }, + { type: 'def', valCoefficient: 1.5 }, + { type: 'hp', valCoefficient: 1.4 }, + ]), ]; -export const shoesCategorys = [ - { - name: 'lingguan', - icon: 'shoes/灵官靴.png', - entry: [ - { type: 'moveSpeed', valCoefficient: 0.8 }, - { type: 'def', valCoefficient: 1.8 }, - ], - }, - { - name: 'quanchi', - icon: 'shoes/犬齿鞋.png', - entry: [ - { type: 'moveSpeed', valCoefficient: 0.8 }, - { type: 'hp', valCoefficient: 1.8 }, - ], - }, - { - name: 'kunlun', - icon: 'shoes/昆仑履.png', - entry: [ - { type: 'moveSpeed', valCoefficient: 0.8 }, - { type: 'def', valCoefficient: 0.8 }, - { type: 'hp', valCoefficient: 0.8 }, - ], - }, +export const shoesCategorys: Categorys[] = [ + new Categorys('lingguan', 'shoes/灵官靴.png', [ + { type: 'moveSpeed', valCoefficient: 0.8 }, + { type: 'def', valCoefficient: 1.8 }, + ]), + new Categorys('quanchi', 'shoes/犬齿鞋.png', [ + { type: 'moveSpeed', valCoefficient: 0.8 }, + { type: 'hp', valCoefficient: 1.8 }, + ]), + new Categorys('kunlun', 'shoes/昆仑履.png', [ + { type: 'moveSpeed', valCoefficient: 0.8 }, + { type: 'def', valCoefficient: 0.8 }, + { type: 'hp', valCoefficient: 0.8 }, + ]), ]; export const initialshoes = () => { @@ -90,69 +59,14 @@ export const initialshoes = () => { export const createshoes = (quality, lv) => { const type = 'shoes'; const qualityBean = new Quality(quality, coefficient[quality]); - const category = getCategory(quality); - const base = createBase(quality, lv, category); + const category = getCategory(quality, shoesCategorys, shoesUniqueCategorys, shoesColorfulCategorys); + const base = createBase(quality, lv, category, coefficient); const extraEntry = new Array(); const extraEntryNum = extra_entry_num[quality]; for (let i = 0; i < extraEntryNum; i++) { - extraEntry.push(shoesExtraEntry(quality, lv)); + extraEntry.push(createExtraEntry(quality, lv, extraEntrys, coefficient)); } return new Equip(type, lv, qualityBean, base, extraEntry); }; -export const shoesExtraEntry = (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); -}; - -const getCategory = (quality) => { - let categorys = shoesCategorys; - switch (quality) { - case qualitys[4]: - categorys = shoesUniqueCategorys; - break; - case qualitys[5]: - categorys = shoesColorfulCategorys; - break; - } - return categorys[Math.floor(Math.random() * categorys.length)]; -}; - -const shoesSample = (quality, category): Equip => { - const type = 'shoes'; - 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 shoesSamples = { - colorful: new Array(), - unique: new Array(), - epic: new Array(), - artifact: new Array(), -}; -shoesColorfulCategorys.forEach((item) => { - shoesSamples.colorful.push(shoesSample('colorful', item)); -}); -shoesUniqueCategorys.forEach((item) => { - shoesSamples.unique.push(shoesSample('unique', item)); -}); -shoesCategorys.forEach((item) => { - shoesSamples.epic.push(shoesSample('epic', item)); - shoesSamples.artifact.push(shoesSample('artifact', item)); -}); -export { shoesSamples }; +export const shoesSamples = createSamples(shoesCategorys, shoesUniqueCategorys, shoesColorfulCategorys, 'shoes', coefficient); diff --git a/src/config/equips/weapon.ts b/src/config/equips/weapon.ts index 659c208..ab8f851 100644 --- a/src/config/equips/weapon.ts +++ b/src/config/equips/weapon.ts @@ -1,157 +1,90 @@ -import { Entry, Quality, EquipBase, Equip } from './bean'; -import { qualitys, entry_initor, extra_entry_num } from './constant'; +import { getCategory, createExtraEntry, createBase, createSamples } from './base'; +import { Entry, Quality, EquipBase, Equip, Categorys } from './bean'; +import { qualitys, extra_entry_num } from './constant'; const extraEntrys = ['atk', 'crit', 'critDmg', 'hp', 'def', 'atkPercent', 'defPercent', 'hpPercent', 'dmgPercent']; const coefficient = { shabby: 0.7, ordinary: 1, artifact: 1.5, epic: 1.8, unique: 2, colorful: 2 }; -export const weaponColorfulCategorys = [ - { - name: 'qiuai', - icon: 'weapon/求爱.png', - entry: [ +export const weaponColorfulCategorys: Categorys[] = [ + new Categorys( + 'qiuai', + 'weapon/求爱.png', + [ { type: 'atk', valCoefficient: 1.8 }, { type: 'crit', valCoefficient: 1.5 }, { type: 'critDmg', valCoefficient: 1.3 }, ], - skill: 'IceBlade,SeeRed', - }, + 'IceBlade,SeeRed' + ), ]; -export const weaponUniqueCategorys = [ - { - name: 'creation', - icon: 'U_Sword01.png', - entry: [ - { type: 'atk', valCoefficient: 1.8 }, - { type: 'crit', valCoefficient: 1.5 }, - { type: 'critDmg', valCoefficient: 1.3 }, - ], - }, - { - name: 'nameless', - icon: 'U_Sword02.png', - entry: [ - { type: 'atk', valCoefficient: 2.7 }, - { type: 'crit', valCoefficient: 2.5 }, - ], - }, - { - name: 'scarlet', - icon: 'U_Sword03.png', - entry: [ - { type: 'atk', valCoefficient: 1.8 }, - { type: 'crit', valCoefficient: 1.5 }, - { type: 'critDmg', valCoefficient: 1.3 }, - ], - }, - { - name: 'death', - icon: 'U_Sword04.png', - entry: [ - { type: 'atk', valCoefficient: 1.8 }, - { type: 'crit', valCoefficient: 1.5 }, - { type: 'critDmg', valCoefficient: 1.3 }, - ], - }, - { - name: 'frostDragon', - icon: 'U_Sword05.png', - entry: [ - { type: 'atk', valCoefficient: 1.8 }, - { type: 'crit', valCoefficient: 1.5 }, - { type: 'critDmg', valCoefficient: 1.3 }, - ], - }, - { - name: 'dragon', - icon: 'U_Sword06.png', - entry: [ - { type: 'atk', valCoefficient: 2.8 }, - { type: 'critDmg', valCoefficient: 2.2 }, - ], - }, - { - name: 'adventurer', - icon: 'U_Sword07.png', - entry: [ - { type: 'atk', valCoefficient: 2.4 }, - { type: 'hp', valCoefficient: 1.8 }, - ], - }, - { - name: 'seraphim', - icon: 'U_Sword08.png', - entry: [ - { type: 'atk', valCoefficient: 2.6 }, - { type: 'def', valCoefficient: 1.8 }, - ], - }, - { - name: 'shuzhuwan', - icon: 'U_Sword09.png', - entry: [{ type: 'atk', valCoefficient: 3.9 }], - }, - { - name: 'leibse', - icon: 'U_Sword10.png', - entry: [ - { type: 'atk', valCoefficient: 1.9 }, - { type: 'def', valCoefficient: 1.2 }, - { type: 'bloc', valCoefficient: 0.4 }, - ], - }, +export const weaponUniqueCategorys: Categorys[] = [ + new Categorys('creation', 'U_Sword01.png', [ + { type: 'atk', valCoefficient: 1.8 }, + { type: 'crit', valCoefficient: 1.5 }, + { type: 'critDmg', valCoefficient: 1.3 }, + ]), + new Categorys('nameless', 'U_Sword02.png', [ + { type: 'atk', valCoefficient: 2.7 }, + { type: 'crit', valCoefficient: 2.5 }, + ]), + new Categorys('scarlet', 'U_Sword03.png', [ + { type: 'atk', valCoefficient: 1.8 }, + { type: 'crit', valCoefficient: 1.5 }, + { type: 'critDmg', valCoefficient: 1.3 }, + ]), + new Categorys('death', 'U_Sword04.png', [ + { type: 'atk', valCoefficient: 1.8 }, + { type: 'crit', valCoefficient: 1.5 }, + { type: 'critDmg', valCoefficient: 1.3 }, + ]), + new Categorys('frostDragon', 'U_Sword05.png', [ + { type: 'atk', valCoefficient: 1.8 }, + { type: 'crit', valCoefficient: 1.5 }, + { type: 'critDmg', valCoefficient: 1.3 }, + ]), + new Categorys('dragon', 'U_Sword06.png', [ + { type: 'atk', valCoefficient: 2.8 }, + { type: 'critDmg', valCoefficient: 2.2 }, + ]), + new Categorys('adventurer', 'U_Sword07.png', [ + { type: 'atk', valCoefficient: 2.4 }, + { type: 'hp', valCoefficient: 1.8 }, + ]), + new Categorys('seraphim', 'U_Sword08.png', [ + { type: 'atk', valCoefficient: 2.6 }, + { type: 'def', valCoefficient: 1.8 }, + ]), + new Categorys('shuzhuwan', 'U_Sword09.png', [{ type: 'atk', valCoefficient: 3.9 }]), + new Categorys('leibse', 'U_Sword10.png', [ + { type: 'atk', valCoefficient: 1.9 }, + { type: 'def', valCoefficient: 1.2 }, + { type: 'bloc', valCoefficient: 0.4 }, + ]), ]; -export const weaponCategorys = [ - { - name: 'hellrock', - icon: 'W_Sword016.png', - entry: [ - { type: 'atk', valCoefficient: 1.2 }, - { type: 'crit', valCoefficient: 1.3 }, - ], - }, - { - name: 'warrior', - icon: 'W_Sword007.png', - entry: [ - { type: 'atk', valCoefficient: 1.2 }, - { type: 'def', valCoefficient: 0.5 }, - ], - }, - { - name: 'redWillow', - icon: 'W_Sword019.png', - entry: [ - { type: 'atk', valCoefficient: 1.3 }, - { type: 'hp', valCoefficient: 1.1 }, - ], - }, - { - name: 'sword', - icon: 'W_Sword001.png', - entry: [{ type: 'atk', valCoefficient: 1.7 }], - }, - { - name: 'waveBlade', - icon: 'W_Sword021.png', - entry: [{ type: 'atk', valCoefficient: 1.7 }], - }, - { - name: 'furryPaw', - icon: 'W_Fist003.png', - entry: [ - { type: 'atk', valCoefficient: 2 }, - { type: 'crit', valCoefficient: 0.7 }, - ], - }, - { - name: 'iceCrystals', - icon: 'W_Sword018.png', - entry: [ - { type: 'atk', valCoefficient: 1.4 }, - { type: 'critDmg', valCoefficient: 1.3 }, - ], - }, +export const weaponCategorys: Categorys[] = [ + new Categorys('hellrock', 'W_Sword016.png', [ + { type: 'atk', valCoefficient: 1.2 }, + { type: 'crit', valCoefficient: 1.3 }, + ]), + new Categorys('warrior', 'W_Sword007.png', [ + { type: 'atk', valCoefficient: 1.2 }, + { type: 'def', valCoefficient: 0.5 }, + ]), + new Categorys('redWillow', 'W_Sword019.png', [ + { type: 'atk', valCoefficient: 1.3 }, + { type: 'hp', valCoefficient: 1.1 }, + ]), + new Categorys('sword', 'W_Sword001.png', [{ type: 'atk', valCoefficient: 1.7 }]), + new Categorys('waveBlade', 'W_Sword021.png', [{ type: 'atk', valCoefficient: 1.7 }]), + new Categorys('furryPaw', 'W_Fist003.png', [ + { type: 'atk', valCoefficient: 2 }, + { type: 'crit', valCoefficient: 0.7 }, + ]), + new Categorys('iceCrystals', 'W_Sword018.png', [ + { type: 'atk', valCoefficient: 1.4 }, + { type: 'critDmg', valCoefficient: 1.3 }, + ]), ]; export const initialWeapon = () => { @@ -165,68 +98,14 @@ export const initialWeapon = () => { export const createWeapon = (quality, lv) => { const type = 'weapon'; const qualityBean = new Quality(quality, coefficient[quality]); - const category = getCategory(quality); - const base = createBase(quality, lv, category); + const category = getCategory(quality, weaponCategorys, weaponUniqueCategorys, weaponColorfulCategorys); + const base = createBase(quality, lv, category, coefficient); const extraEntry = new Array(); const extraEntryNum = extra_entry_num[quality]; for (let i = 0; i < extraEntryNum; i++) { - extraEntry.push(weaponExtraEntry(quality, lv)); + extraEntry.push(createExtraEntry(quality, lv, extraEntrys, coefficient)); } return new Equip(type, lv, qualityBean, base, extraEntry); }; -export const weaponExtraEntry = (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 = weaponCategorys; - switch (quality) { - case qualitys[4]: - categorys = weaponUniqueCategorys; - break; - case qualitys[5]: - categorys = weaponColorfulCategorys; - break; - } - return categorys[Math.floor(Math.random() * categorys.length)]; -}; - -const weaponSample = (quality, category): Equip => { - const type = 'weapon'; - 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 weaponSamples = { - colorful: new Array(), - unique: new Array(), - epic: new Array(), - artifact: new Array(), -}; -weaponColorfulCategorys.forEach((item) => { - weaponSamples.colorful.push(weaponSample('colorful', item)); -}); -weaponUniqueCategorys.forEach((item) => { - weaponSamples.unique.push(weaponSample('unique', item)); -}); -weaponCategorys.forEach((item) => { - weaponSamples.epic.push(weaponSample('epic', item)); - weaponSamples.artifact.push(weaponSample('artifact', item)); -}); -export { weaponSamples }; +export const weaponSamples = createSamples(weaponCategorys, weaponUniqueCategorys, weaponColorfulCategorys, 'weapon', coefficient);