add monster images, fix level up calc
BIN
assets/images/monsters/Arcane Crystal.png
Normal file
After Width: | Height: | Size: 100 KiB |
BIN
assets/images/monsters/Blue Slime.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
assets/images/monsters/Drakelor.png
Normal file
After Width: | Height: | Size: 105 KiB |
BIN
assets/images/monsters/Ghost.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
assets/images/monsters/Illusion.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
assets/images/monsters/Raven.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
assets/images/monsters/Red Slime.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
assets/images/monsters/Scamp.png
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
assets/images/monsters/Scorpion.png
Normal file
After Width: | Height: | Size: 54 KiB |
BIN
assets/images/monsters/Shade.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
assets/images/monsters/Shadow.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
assets/images/monsters/Silver Slime.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
data/dk.db
@ -32,19 +32,16 @@ func (r *FightResult) EndFightWithVictory(monster *monsters.Monster, user *users
|
||||
r.FightUpdates["reward_gold"] = rewardGold
|
||||
r.FightUpdates["reward_exp"] = rewardExp
|
||||
|
||||
newLevel, newStr, newDex, newExp := user.CalculateLevelUp(rewardExp)
|
||||
|
||||
r.UserUpdates = map[string]any{
|
||||
"fight_id": 0,
|
||||
"currently": "Exploring",
|
||||
"gold": user.Gold + rewardGold,
|
||||
"exp": user.Exp + rewardExp,
|
||||
}
|
||||
|
||||
// Handle level up
|
||||
newLevel, newStats := calculateLevelUp(user.Level, user.Exp+rewardExp, user.Strength, user.Dexterity)
|
||||
if newLevel > user.Level {
|
||||
r.UserUpdates["level"] = newLevel
|
||||
r.UserUpdates["strength"] = newStats.Strength
|
||||
r.UserUpdates["dexterity"] = newStats.Dexterity
|
||||
"exp": newExp,
|
||||
"level": newLevel,
|
||||
"strength": newStr,
|
||||
"dexterity": newDex,
|
||||
}
|
||||
|
||||
r.Ended = true
|
||||
@ -295,17 +292,11 @@ func calculateRewards(monster *monsters.Monster, user *users.User) (int, int) {
|
||||
// More generous reward range: 90-100% of max instead of 83-100%
|
||||
minExp := (monster.MaxExp * 9) / 10
|
||||
maxExp := monster.MaxExp
|
||||
exp := rand.Intn(maxExp-minExp+1) + minExp
|
||||
if exp < 1 {
|
||||
exp = 1 // Guaranteed minimum
|
||||
}
|
||||
exp := max(rand.Intn(maxExp-minExp+1)+minExp, 1)
|
||||
|
||||
minGold := (monster.MaxGold * 9) / 10
|
||||
maxGold := monster.MaxGold
|
||||
gold := rand.Intn(maxGold-minGold+1) + minGold
|
||||
if gold < 1 {
|
||||
gold = 1 // Guaranteed minimum
|
||||
}
|
||||
gold := max(rand.Intn(maxGold-minGold+1)+minGold, 1)
|
||||
|
||||
// Apply bonuses
|
||||
expBonus := (user.ExpBonus * exp) / 100
|
||||
|
@ -279,29 +279,42 @@ func (u *User) ExpNeededForNextLevel() int {
|
||||
return exp.Calc(u.Level + 1)
|
||||
}
|
||||
|
||||
func (u *User) GrantExp(expAmount int) {
|
||||
u.Exp += expAmount
|
||||
u.checkLevelUp()
|
||||
func (u *User) GrantExp(expAmount int) map[string]any {
|
||||
newLevel, newStr, newDex, newExp := u.CalculateLevelUp(expAmount)
|
||||
|
||||
updates := map[string]any{
|
||||
"exp": newExp,
|
||||
}
|
||||
|
||||
// Only include level/stats if they actually changed
|
||||
if newLevel > u.Level {
|
||||
updates["level"] = newLevel
|
||||
updates["strength"] = newStr
|
||||
updates["dexterity"] = newDex
|
||||
}
|
||||
|
||||
return updates
|
||||
}
|
||||
|
||||
func (u *User) checkLevelUp() {
|
||||
expNeeded := u.ExpNeededForNextLevel()
|
||||
func (u *User) CalculateLevelUp(expGain int) (newLevel, newStr, newDex, newExp int) {
|
||||
level := u.Level
|
||||
str := u.Strength
|
||||
dex := u.Dexterity
|
||||
totalExp := u.Exp + expGain
|
||||
|
||||
if u.Exp >= expNeeded {
|
||||
// Level up
|
||||
u.Level++
|
||||
u.Strength++
|
||||
u.Dexterity++
|
||||
|
||||
// Reset exp and carry over excess
|
||||
excessExp := u.Exp - expNeeded
|
||||
u.Exp = 0
|
||||
|
||||
// Recursive level up if enough excess exp
|
||||
if excessExp > 0 {
|
||||
u.GrantExp(excessExp)
|
||||
for {
|
||||
expNeeded := exp.Calc(level + 1)
|
||||
if totalExp < expNeeded {
|
||||
break
|
||||
}
|
||||
|
||||
level++
|
||||
str++
|
||||
dex++
|
||||
totalExp -= expNeeded
|
||||
}
|
||||
|
||||
return level, str, dex, totalExp
|
||||
}
|
||||
|
||||
func (u *User) ExpProgress() float64 {
|
||||
|
@ -5,7 +5,7 @@
|
||||
<h2>{monster.Name}</h2>
|
||||
<h3>Level {monster.Level}</h3>
|
||||
|
||||
<img id="monster-image" src="/assets/images/monsters/{monster.Name}.png" alt="{monster.Name}" title="{monster.Name}">
|
||||
<img id="monster-image" src="/assets/images/monsters/{monster.Name}.png" alt="{monster.Name}" title="{monster.Name}" onerror="this.onerror=null; this.src='/assets/images/monsters/Arcane Crystal.png';">
|
||||
</div>
|
||||
|
||||
<div>{action}</div>
|
||||
|