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

193 lines
5.3 KiB

import {
initialWeapon,
initialArmor,
initialNeck,
initialRing,
initialJewelry,
initialpants,
initialshoes,
initialbracers,
Equip,
piont_arrts,
} from '@/config';
export const type_monster = 'monster';
export const type_boss = 'boss';
export const difficultys = ['normal', 'hard', 'pain', 'xiaomi', 'dami'];
export const show_lv_df = ['normal', 'hard', 'pain'];
const base_attr_factor = { normal: 1, hard: 1.15, pain: 1.4, xiaomi: 2, dami: 3 };
const extra_factor = { normal: 0, hard: 0, pain: 0, xiaomi: 1, dami: 2 };
const rate_factor = { normal: 1, hard: 2, pain: 3, xiaomi: 4, dami: 5 };
export class Attribute {
lv: number = 1;
coins: number = 0;
curHp: number = 200;
hp: number = 200;
hpPercent: number = 0;
baseAtk: number = 0;
atk: number = 0;
atkPercent: number = 0;
def: number = 0;
defPercent: number = 0;
reducPercent: number = 0;
bloc: number = 0;
blocPercent: number = 0;
eva: number = 0;
crit: number = 0; //暴击率
critDmg: number = 150; // 初始暴击伤害150%
dmgPercent: number = 0; //伤害加成
dmgReduc: number = 0; //伤害减免
critAvoid: number = 0; //暴击避免
critDmgReduc: number = 0; //暴击伤害减免
moveSpeed: number = 0; //移动速度
dps: number = 0;
skill: string = 'Attack';
constructor(base?: Attribute) {
if (base) {
piont_arrts.forEach((attr) => {
if (this[attr] != undefined) {
this[attr] += base[attr];
}
});
}
}
copy(attr: Attribute) {
Object.keys(attr).forEach((key) => {
this[key] = attr[key];
});
}
}
export class Player {
lv: number = 1;
layer: number = 1;
coins: number = 0;
weapon: Equip = initialWeapon();
armor: Equip = initialArmor();
neck: Equip = initialNeck();
ring: Equip = initialRing();
jewelry: Equip = initialJewelry();
pants: Equip = initialpants();
shoes: Equip = initialshoes();
bracers: Equip = initialbracers();
attribute: Attribute = new Attribute();
}
export class BaseAttribute extends Attribute {
curHp: number = 0;
hp: number = 0;
critDmg: number = 0;
battleSpeed: number = 0;
}
export class Points extends BaseAttribute {
total: number = 0;
has: number = 0;
}
export class Monster extends Attribute {
difficulty: string;
type: string = type_monster;
equipRates: number[];
extraRate: number[];
df: number;
ef: number;
lf: number;
constructor(lv, difficulty: string, layer: number) {
super();
this.lv = lv;
this.difficulty = difficulty;
this.df = base_attr_factor[this.difficulty];
this.ef = extra_factor[difficulty];
if (layer == 0) {
this.lf = 1;
} else {
this.lf = ((this.lv + layer - 1) / this.lv) ** 2;
}
this.callAtk(2.5);
this.callHp(17);
this.callCoins(11);
this.callCrit(0.5);
this.callDef();
this.equipRates = [0.2 * this.df, 0.08 * this.df, 0.03 * this.df];
this.extraRate = [0, 0];
}
callAtk = (variable) => {
this.baseAtk = Math.ceil(this.lv ** 2.1 * (Math.random() * 0.2 + variable) * this.df * this.lf);
this.atk = this.baseAtk;
};
callHp = (variable) => {
this.hp = Math.ceil(this.lv ** 2.1 * (Math.random() * 3 + variable) * this.df * this.lf);
};
callCoins = (variable) => {
this.coins = Math.ceil(this.lv ** 1.16 * (Math.random() * 5 + variable) * this.df * this.lf ** 0.5);
};
callDef = () => {
this.def = Math.ceil(100 + 100 * (this.ef - 1) * this.lf);
};
callCrit = (factor) => {
this.crit = Math.ceil((15 + 10 * (this.ef - 1) * this.lf) * factor);
this.critDmg = Math.ceil(150 + 50 * this.ef * this.lf);
this.critAvoid = Math.ceil((10 + 10 * (this.ef - 1) * this.lf) * factor);
this.critDmgReduc = Math.ceil(100 + 100 * (this.ef - 1) * this.lf);
};
}
export class BossMonster extends Monster {
type: string = type_boss;
constructor(lv, difficulty, layer: number) {
super(lv, difficulty, layer);
this.callAtk(3.5);
this.callHp(31);
this.callCoins(30.5);
this.callCrit(1);
const rf = rate_factor[difficulty];
this.equipRates = [0.25 - 0.05 * rf, 0.55 - 0.1 * rf, 0.15 + 0.1 * rf, 0.05 + 0.05 * rf];
let uniqueRate = 0.02 * ((rf - 1) * 5 + 1);
const colorfulRate = 0.02 * (rf - 3) * this.lf;
if (uniqueRate + colorfulRate > 1) {
uniqueRate = 1 - colorfulRate;
}
this.extraRate = [uniqueRate, colorfulRate];
}
}
export class Dungeon {
lv: number;
difficulty: string;
monsters?: Monster[] = new Array();
needDps?: number;
left: string = '';
right: string = '';
top: string = '';
layer: number;
points: number = 0;
constructor(lv: number, difficulty: string, layer?: number) {
this.lv = lv;
this.difficulty = difficulty;
this.layer = layer || 0;
this.setDifficulty(difficulty);
}
setDifficulty(difficulty: string) {
const lv = this.lv;
this.difficulty = difficulty;
this.monsters = new Array();
for (let i = 0; i < 4; i++) {
this.monsters.push(new Monster(lv, this.difficulty, this.layer));
}
const boss = new BossMonster(lv, difficulty, this.layer);
this.monsters.push(boss);
this.points = Math.floor(boss.ef * boss.lf);
this.needDps = Math.ceil(lv * lv ** 1.1 * 32.5 * base_attr_factor[this.difficulty]);
}
setLayer = (layer) => {
this.layer = layer;
this.setDifficulty(this.difficulty);
};
}
export const createdDungeons = () => {};