Files
Catacombs/entity/monster.go
tolelom f85775dd3e feat: replace all hardcoded constants with config values
Replace hardcoded game constants with values from the config system:
- GameSession now receives *config.Config from Lobby
- TurnTimeout, MaxFloors, SkillUses, InventoryLimit use config values
- combat.AttemptFlee accepts fleeChance param
- combat.ResolveAttacks accepts coopBonus param
- entity.NewMonster accepts scaling param
- Solo HP/DEF reduction uses config SoloHPReduction
- Lobby JoinRoom uses config MaxPlayers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 13:08:52 +09:00

96 lines
2.0 KiB
Go

package entity
import "math"
type MonsterType int
const (
MonsterSlime MonsterType = iota
MonsterSkeleton
MonsterOrc
MonsterDarkKnight
MonsterBoss5
MonsterBoss10
MonsterBoss15
MonsterBoss20
)
type monsterBase struct {
Name string
HP, ATK, DEF int
MinFloor int
IsBoss bool
}
var monsterDefs = map[MonsterType]monsterBase{
MonsterSlime: {"Slime", 20, 5, 1, 1, false},
MonsterSkeleton: {"Skeleton", 35, 10, 4, 3, false},
MonsterOrc: {"Orc", 55, 14, 6, 6, false},
MonsterDarkKnight: {"Dark Knight", 80, 18, 10, 12, false},
MonsterBoss5: {"Guardian", 150, 15, 8, 5, true},
MonsterBoss10: {"Warden", 250, 22, 12, 10, true},
MonsterBoss15: {"Overlord", 400, 30, 16, 15, true},
MonsterBoss20: {"Archlich", 600, 40, 20, 20, true},
}
type BossPattern int
const (
PatternNone BossPattern = iota
PatternAoE // every 3 turns AoE
PatternPoison // applies poison
PatternBurn // applies burn to random player
PatternHeal // heals self
)
type Monster struct {
Name string
Type MonsterType
HP, MaxHP int
ATK, DEF int
IsBoss bool
TauntTarget bool
TauntTurns int
Pattern BossPattern
}
func NewMonster(mt MonsterType, floor int, scaling float64) *Monster {
base := monsterDefs[mt]
scale := 1.0
if !base.IsBoss && floor > base.MinFloor {
scale = math.Pow(scaling, float64(floor-base.MinFloor))
}
hp := int(math.Round(float64(base.HP) * scale))
atk := int(math.Round(float64(base.ATK) * scale))
def := int(math.Round(float64(base.DEF) * scale))
return &Monster{
Name: base.Name,
Type: mt,
HP: hp,
MaxHP: hp,
ATK: atk,
DEF: def,
IsBoss: base.IsBoss,
}
}
func (m *Monster) TakeDamage(dmg int) {
m.HP -= dmg
if m.HP < 0 {
m.HP = 0
}
}
func (m *Monster) IsDead() bool {
return m.HP <= 0
}
func (m *Monster) TickTaunt() {
if m.TauntTurns > 0 {
m.TauntTurns--
if m.TauntTurns == 0 {
m.TauntTarget = false
}
}
}