From 834c935ced54239233bde1c7422e9e1b2f84b643 Mon Sep 17 00:00:00 2001 From: mengyxu Date: Thu, 15 May 2025 22:18:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=9E=E6=80=A7=E8=AE=A1=E7=AE=97=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/equips/base.ts | 11 +-- src/config/equips/bean.ts | 2 +- src/config/equips/constant.ts | 179 +++++++++++++++------------------- 3 files changed, 86 insertions(+), 106 deletions(-) diff --git a/src/config/equips/base.ts b/src/config/equips/base.ts index 9504003..f9518f4 100644 --- a/src/config/equips/base.ts +++ b/src/config/equips/base.ts @@ -1,22 +1,21 @@ import { Categorys, Equip, EquipBase, Quality } from './bean'; -import { entry_initor, extra_entry_num, qualitys } from './constant'; +import { entry_initor, EntryInitor, 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 initor: EntryInitor = entry_initor[item.type]; const qualityCoefficient = coefficient[quality]; - entry.push(initor(lv, qualityCoefficient, item.valCoefficient)); + entry.push(initor.init(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 initor: EntryInitor = entry_initor[type]; const qualityCoefficient = coefficient[quality]; - const entry = initor(lv, qualityCoefficient); - return entry; + return initor.init(lv, qualityCoefficient); }; export const createSamples = (categorys: Categorys[], uniqueCategorys: Categorys[], colorfulCategorys: Categorys[], type, coefficient) => { diff --git a/src/config/equips/bean.ts b/src/config/equips/bean.ts index bf01645..0bc2e0f 100644 --- a/src/config/equips/bean.ts +++ b/src/config/equips/bean.ts @@ -14,7 +14,7 @@ export class Entry { this.showVal = showVal; this.max = max; this.min = min; - this.percent = Math.round(((value - min) / (max - min)) * 100); + this.percent = value == max ? 100 : Math.round(((value - min) / (max - min)) * 100); } } diff --git a/src/config/equips/constant.ts b/src/config/equips/constant.ts index 2184aad..3f7a6fb 100644 --- a/src/config/equips/constant.ts +++ b/src/config/equips/constant.ts @@ -2,6 +2,9 @@ import { Entry } from './bean'; //装备质量 export const qualitys = ['shabby', 'ordinary', 'artifact', 'epic', 'unique', 'colorful']; +export const extra_quality = ['yuangu', 'taigu']; +export const extra_quality_rate = [0.1, 0.1]; +export const extra_quality_lv = 20; //装备颜色 export const quality_collor = { @@ -42,104 +45,82 @@ export const attr_unitys = { export const strengthen_rates = [1, 1, 1, 1, 1, 1, 0.8, 0.65, 0.45, 0.3, 0.2]; export const strengthen_factor = { shabby: 1, ordinary: 1, artifact: 1, epic: 1, unique: 1.5, colorful: 2 }; -export const entry_initor = { - atk: (lv: number, qualityCoefficient: number, valCoefficient?: number) => { - valCoefficient = valCoefficient || 1; - const value = Math.round((lv * valCoefficient + ((Math.random() * lv) / 2 + 1)) * qualityCoefficient) || 1; - const max = Math.round((lv * valCoefficient + (lv / 2 + 1)) * qualityCoefficient) || 1; - const min = Math.round((lv * valCoefficient + 1) * qualityCoefficient) || 1; - return new Entry('atk', value, '+' + value, max, min); - }, - atkPercent: (lv: number, qualityCoefficient: number) => { - const value = Math.round((lv * 0.11 + ((Math.random() * lv) / 10 + 4)) * qualityCoefficient) || 1; - const max = Math.round((lv * 0.11 + (lv / 10 + 4)) * qualityCoefficient) || 1; - const min = Math.round((lv * 0.11 + 4) * qualityCoefficient) || 1; - return new Entry('atkPercent', value, '+' + value + '%', max, min); - }, - hp: (lv: number, qualityCoefficient: number, valCoefficient?: number) => { - valCoefficient = valCoefficient || 0.3; - const value = Math.round(lv * valCoefficient * 10 + ((Math.random() * lv) / 2 + 1) * qualityCoefficient) || 1; - const max = Math.round(lv * valCoefficient * 10 + (lv / 2 + 1) * qualityCoefficient) || 1; - const min = Math.round(lv * valCoefficient * 10 + qualityCoefficient) || 1; - return new Entry('hp', value, '+' + value, max, min); - }, - hpPercent: (lv: number, qualityCoefficient: number) => { - const value = Math.round((lv * 0.1 + ((Math.random() * lv) / 10 + 4)) * qualityCoefficient) || 1; - const max = Math.round((lv * 0.1 + (lv / 10 + 4)) * qualityCoefficient) || 1; - const min = Math.round((lv * 0.1 + 4) * qualityCoefficient) || 1; - return new Entry('hpPercent', value, '+' + value + '%', max, min); - }, - def: (lv: number, qualityCoefficient: number, valCoefficient?: number) => { - valCoefficient = valCoefficient || 0.2; - const value = Math.round((lv * valCoefficient + ((Math.random() * lv) / 2 + 1)) * qualityCoefficient) || 1; - const max = Math.round((lv * valCoefficient + (lv / 2 + 1)) * qualityCoefficient) || 1; - const min = Math.round((lv * valCoefficient + 1) * qualityCoefficient) || 1; - return new Entry('def', value, '+' + value, max, min); - }, - defPercent: (lv: number, qualityCoefficient: number) => { - const value = Math.round((lv * 0.13 + (Math.random() * lv) / 10 + 4) * qualityCoefficient) || 1; - const max = Math.round((lv * 0.13 + lv / 10 + 4) * qualityCoefficient) || 1; - const min = Math.round((lv * 0.13 + 4) * qualityCoefficient) || 1; - return new Entry('defPercent', value, '+' + value + '%', max, min); - }, - bloc: (lv: number, qualityCoefficient: number, valCoefficient?: number) => { - valCoefficient = valCoefficient || 0.6; - const value = Math.round((lv * valCoefficient) / 2 + ((Math.random() * lv) / 3 + 1) * qualityCoefficient) || 1; - const max = Math.round((lv * valCoefficient) / 2 + (lv / 3 + 1) * qualityCoefficient) || 1; - const min = Math.round((lv * valCoefficient) / 2 + 1 * qualityCoefficient) || 1; - return new Entry('bloc', value, '+' + value, max, min); - }, - blocPercent: (lv: number, qualityCoefficient: number) => { - const value = Math.round((lv * 0.1 + ((Math.random() * lv) / 10 + 4)) * qualityCoefficient) || 1; - const max = Math.round((lv * 0.1 + (lv / 10 + 4)) * qualityCoefficient) || 1; - const min = Math.round((lv * 0.1 + 4) * qualityCoefficient) || 1; - return new Entry('blocPercent', value, '+' + value + '%', max, min); - }, - crit: (lv: number, qualityCoefficient: number, valCoefficient?: number) => { - valCoefficient = valCoefficient || 0; - const value = Math.round(((0.5 * lv) / 100 + 0.5) * (Math.random() * 5 + 5 + 2 * valCoefficient) * qualityCoefficient) || 1; - const max = Math.round(((0.5 * lv) / 100 + 0.5) * (5 + 5 + 2 * valCoefficient) * qualityCoefficient) || 1; - const min = Math.round(((0.5 * lv) / 100 + 0.5) * (5 + 2 * valCoefficient) * qualityCoefficient) || 1; - return new Entry('crit', value, '+' + value + '%', max, min); - }, - critDmg: (lv: number, qualityCoefficient: number, valCoefficient?: number) => { - valCoefficient = valCoefficient || 0; - const value = Math.round(((0.5 * lv) / 100 + 0.5) * (Math.random() * (12 + 6 * valCoefficient) + 20) * qualityCoefficient) || 1; - const max = Math.round(((0.5 * lv) / 100 + 0.5) * (12 + 6 * valCoefficient + 20) * qualityCoefficient) || 1; - const min = Math.round(((0.5 * lv) / 100 + 0.5) * 20 * qualityCoefficient) || 1; - return new Entry('critDmg', value, '+' + value + '%', max, min); - }, - dmgPercent: (lv: number, qualityCoefficient: number, valCoefficient?: number) => { +export interface EntryInitor { + init(lv: number, qualityCoefficient: number, valCoefficient?: number, extraQuality?: string): Entry; +} +class BaseInitor implements EntryInitor { + type: string; + factor1: number; + factor2: number; + constant: number; + defCoefficient: number = 1; + constructor(type: string, factor1: number, factor2: number, constant: number) { + this.type = type; + this.factor1 = factor1; + this.factor2 = factor2; + this.constant = constant; + } + init(lv: number, qualityCoefficient: number, valCoefficient?: number, extraQuality?: string): Entry { + valCoefficient = valCoefficient || this.defCoefficient; + const num1 = lv * valCoefficient * this.factor1; + const num2 = Math.random() * lv * this.factor2 + this.constant; + const manNum2 = lv * this.factor2 + this.constant; + const minNum2 = this.constant; + const value = Math.round((num1 + num2) * qualityCoefficient) || 1; + const max = Math.round((num1 + manNum2) * qualityCoefficient) || 1; + const min = Math.round((num1 + minNum2) * qualityCoefficient) || 1; + return new Entry(this.type, value, '+' + value, max, min); + } +} +class PercentInitor extends BaseInitor { + init(lv: number, qualityCoefficient: number, valCoefficient?: number, extraQuality?: string): Entry { + const entry = super.init(lv, qualityCoefficient, valCoefficient, extraQuality); + entry.showVal += '%'; + return entry; + } +} +class CritInitor extends BaseInitor { + constructor(type: string, factor1: number, factor2: number, constant: number) { + super(type, factor1, factor2, constant); + this.defCoefficient = 0; + } + init(lv: number, qualityCoefficient: number, valCoefficient?: number, extraQuality?: string): Entry { + valCoefficient = valCoefficient || this.defCoefficient; + const value = this.call(Math.random() * this.factor1, lv, valCoefficient, qualityCoefficient); + const max = this.call(this.factor1, lv, valCoefficient, qualityCoefficient); + const min = this.call(0, lv, valCoefficient, qualityCoefficient); + return new Entry(this.type, value, '+' + value + '%', max, min); + } + call(num1, lv, valCoefficient, qualityCoefficient): number { + const lvFactor = (0.5 * lv) / 100 + 0.5; + const num2 = this.factor2 * valCoefficient + this.constant; + return Math.round(lvFactor * (num1 + num2) * qualityCoefficient) || 1; + } +} +class DmgInitor extends BaseInitor { + init(lv: number, qualityCoefficient: number, valCoefficient?: number, extraQuality?: string): Entry { valCoefficient = valCoefficient || 1; - const value = Math.round(((Math.random() + 1) * lv * 0.05 + 3) * valCoefficient * qualityCoefficient) || 1; - const max = Math.round((lv * 0.1 + 3) * valCoefficient * qualityCoefficient) || 1; - const min = Math.round((lv * 0.05 + 3) * valCoefficient * qualityCoefficient) || 1; - return new Entry('dmgPercent', value, '+' + value + '%', max, min); - }, - dmgReduc: (lv: number, qualityCoefficient: number) => { - const value = Math.round((Math.random() * lv * 0.05 + 6) * qualityCoefficient) || 1; - const max = Math.round((lv * 0.05 + 6) * qualityCoefficient) || 1; - const min = Math.round(6 * qualityCoefficient) || 1; - return new Entry('dmgReduc', value, '+' + value + '%', max, min); - }, - critAvoid: (lv: number, qualityCoefficient: number) => { - const value = Math.round(((0.5 * lv) / 100 + 0.5) * (Math.random() * 5 + 5 + 2) * qualityCoefficient) || 1; - const max = Math.round(((0.5 * lv) / 100 + 0.5) * (5 + 5 + 2) * qualityCoefficient) || 1; - const min = Math.round(((0.5 * lv) / 100 + 0.5) * (5 + 2) * qualityCoefficient) || 1; - return new Entry('critAvoid', value, '+' + value + '%', max, min); - }, - critDmgReduc: (lv: number, qualityCoefficient: number, valCoefficient?: number) => { - valCoefficient = valCoefficient || 0; - const value = Math.round(((0.5 * lv) / 100 + 0.5) * (Math.random() * (12 + 6 * valCoefficient) + 20) * qualityCoefficient) || 1; - const max = Math.round(((0.5 * lv) / 100 + 0.5) * (12 + 6 * valCoefficient + 20) * qualityCoefficient) || 1; - const min = Math.round(((0.5 * lv) / 100 + 0.5) * 20 * qualityCoefficient) || 1; - return new Entry('critDmgReduc', value, '+' + value + '%', max, min); - }, - moveSpeed: (lv: number, qualityCoefficient: number, valCoefficient?: number) => { - valCoefficient = valCoefficient || 0; - const value = Math.round(((0.5 * lv) / 100 + 0.5) * (Math.random() * (5 + 6 * valCoefficient) + 20) * qualityCoefficient) || 1; - const max = Math.round(((0.5 * lv) / 100 + 0.5) * (5 + 6 * valCoefficient + 20) * qualityCoefficient) || 1; - const min = Math.round(((0.5 * lv) / 100 + 0.5) * 20 * qualityCoefficient) || 1; - return new Entry('moveSpeed', value, '+' + value + '%', max, min); - }, + const value = Math.round((lv * this.factor1 * (Math.random() + this.factor2) + this.constant) * qualityCoefficient * valCoefficient) || 1; + const max = Math.round((lv * this.factor1 * (1 + this.factor2) + this.constant) * qualityCoefficient * valCoefficient) || 1; + const min = Math.round((lv * this.factor1 * this.factor2 + this.constant) * qualityCoefficient * valCoefficient) || 1; + return new Entry(this.type, value, '+' + value + '%', max, min); + } +} + +export const entry_initor = { + atk: new BaseInitor('atk', 1, 0.5, 1), + atkPercent: new PercentInitor('atkPercent', 0.11, 0.1, 4), + hp: new BaseInitor('hp', 5, 0.5, 1), + hpPercent: new PercentInitor('hpPercent', 0.1, 0.1, 4), + def: new BaseInitor('def', 1, 0.5, 1), + defPercent: new PercentInitor('defPercent', 0.13, 0.1, 4), + bloc: new BaseInitor('bloc', 0.25, 1 / 3, 1), + blocPercent: new PercentInitor('blocPercent', 0.1, 0.1, 4), + crit: new CritInitor('crit', 5, 2, 5), + critDmg: new CritInitor('critDmg', 15, 7, 16), + critAvoid: new CritInitor('critAvoid', 5, 0, 7), + critDmgReduc: new CritInitor('critDmgReduc', 15, 7, 16), + dmgPercent: new DmgInitor('dmgPercent', 0.05, 1, 3), + dmgReduc: new DmgInitor('dmgReduc', 0.05, 0, 6), + moveSpeed: new CritInitor('moveSpeed', 8, 6, 17), };