Skip to content

Commit 30503a7

Browse files
committed
fix: bg image again
1 parent c501375 commit 30503a7

File tree

1 file changed

+40
-14
lines changed

1 file changed

+40
-14
lines changed

src/commands/deathbattle.ts

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ async function createBattleImage(
130130

131131
try {
132132
const background = await loadImage(
133-
path.join(process.cwd(), "dist", "deathbattle.png"),
133+
path.join(__dirname, "deathbattle.png")
134134
);
135135
ctx.drawImage(background, 0, 0, 1920, 1080);
136136

@@ -394,19 +394,39 @@ function generateFighter(user: User, displayName: string): Fighter {
394394
return hash;
395395
}
396396

397-
const hash = hashString(displayName);
398-
let seed = hash;
399-
400-
const random = (min: number, max: number) => {
401-
seed = (seed * 9301 + 49297) % 233280;
402-
return min + (seed / 233280) * (max - min);
397+
const nameToLevel: { [key: string]: number } = {
398+
toru: 0,
399+
toru1: 1,
400+
toru2: 2,
401+
toru3: 3,
402+
toru4: 4,
403+
toru5: 5,
404+
toru6: 6,
405+
toru7: 7,
406+
toru8: 8,
407+
toru9: 9,
408+
toru10: 10,
409+
toru11: 11,
403410
};
404411

405-
const baseHp = Math.floor(random(80, 120));
406-
const baseAttack = Math.floor(random(15, 25));
407-
const baseDefense = Math.floor(random(5, 15));
408-
const baseSpeed = Math.floor(random(10, 20));
409-
const critChance = random(0.1, 0.3);
412+
let percentage: number;
413+
414+
if (displayName in nameToLevel) {
415+
const level = nameToLevel[displayName];
416+
percentage = level === 0 ? -100 : level === 11 ? 100 : (level - 1) * 10 + 9;
417+
} else {
418+
const hash = hashString(displayName);
419+
percentage = hash % 101;
420+
}
421+
422+
const auraMultiplier = Math.max(0, (percentage + 100) / 200);
423+
424+
// Base stats + aura bonus
425+
const baseHp = Math.floor(80 + auraMultiplier * 40); // 80-120 HP
426+
const baseAttack = Math.floor(15 + auraMultiplier * 10); // 15-25 ATK
427+
const baseDefense = Math.floor(5 + auraMultiplier * 10); // 5-15 DEF
428+
const baseSpeed = Math.floor(10 + auraMultiplier * 10); // 10-20 SPD
429+
const critChance = 0.1 + auraMultiplier * 0.2; // 0.1-0.3 crit chance
410430

411431
const abilities = [
412432
"Alter Ego Burst",
@@ -429,10 +449,16 @@ function generateFighter(user: User, displayName: string): Fighter {
429449
"Great Will",
430450
];
431451

452+
let seed = Math.abs(percentage) + 1000;
453+
const random = () => {
454+
seed = (seed * 9301 + 49297) % 233280;
455+
return seed / 233280;
456+
};
457+
432458
const selectedAbilities = [];
433459
const abilityPool = [...abilities];
434460
for (let i = 0; i < 2; i++) {
435-
const index = Math.floor(random(0, abilityPool.length));
461+
const index = Math.floor(random() * abilityPool.length);
436462
selectedAbilities.push(abilityPool.splice(index, 1)[0]);
437463
}
438464

@@ -592,7 +618,7 @@ export async function execute(
592618
)
593619
.setImage("attachment://deathbattle-final.png")
594620
.setFooter({
595-
text: `Battle lasted ${turn} turns | The heavens remembers this epic clash`,
621+
text: `Battle lasted ${turn} turns | The heavens shall remember this epic clash`,
596622
})
597623
.setTimestamp();
598624

0 commit comments

Comments
 (0)