You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
175 lines
6.5 KiB
Go
175 lines
6.5 KiB
Go
package model
|
|
|
|
type EnemyType string
|
|
|
|
const (
|
|
EnemyWolf EnemyType = "wolf"
|
|
EnemyBoar EnemyType = "boar"
|
|
EnemyZombie EnemyType = "zombie"
|
|
EnemySpider EnemyType = "spider"
|
|
EnemyOrc EnemyType = "orc"
|
|
EnemySkeletonArcher EnemyType = "skeleton_archer"
|
|
EnemyBattleLizard EnemyType = "battle_lizard"
|
|
EnemyFireDemon EnemyType = "fire_demon"
|
|
EnemyIceGuardian EnemyType = "ice_guardian"
|
|
EnemySkeletonKing EnemyType = "skeleton_king"
|
|
EnemyWaterElement EnemyType = "water_element"
|
|
EnemyForestWarden EnemyType = "forest_warden"
|
|
EnemyLightningTitan EnemyType = "lightning_titan"
|
|
)
|
|
|
|
type SpecialAbility string
|
|
|
|
const (
|
|
AbilityBurn SpecialAbility = "burn" // DoT fire damage
|
|
AbilitySlow SpecialAbility = "slow" // -40% movement speed (Water Element)
|
|
AbilityCritical SpecialAbility = "critical" // chance for double damage
|
|
AbilityPoison SpecialAbility = "poison" // DoT poison damage
|
|
AbilityFreeze SpecialAbility = "freeze" // -50% attack speed (generic)
|
|
AbilityIceSlow SpecialAbility = "ice_slow" // -20% attack speed (Ice Guardian per spec)
|
|
AbilityStun SpecialAbility = "stun" // no attacks for 2 sec
|
|
AbilityDodge SpecialAbility = "dodge" // chance to avoid incoming damage
|
|
AbilityRegen SpecialAbility = "regen" // regenerate HP over time
|
|
AbilityBurst SpecialAbility = "burst" // every Nth attack deals multiplied damage
|
|
AbilityChainLightning SpecialAbility = "chain_lightning" // 3x damage after 5 attacks
|
|
AbilitySummon SpecialAbility = "summon" // summons minions
|
|
)
|
|
|
|
type Enemy struct {
|
|
ID int64 `json:"id"`
|
|
Type EnemyType `json:"type"`
|
|
Name string `json:"name"`
|
|
HP int `json:"hp"`
|
|
MaxHP int `json:"maxHp"`
|
|
Attack int `json:"attack"`
|
|
Defense int `json:"defense"`
|
|
Speed float64 `json:"speed"` // attacks per second
|
|
CritChance float64 `json:"critChance"` // 0.0 to 1.0
|
|
MinLevel int `json:"minLevel"`
|
|
MaxLevel int `json:"maxLevel"`
|
|
XPReward int64 `json:"xpReward"`
|
|
GoldReward int64 `json:"goldReward"`
|
|
SpecialAbilities []SpecialAbility `json:"specialAbilities,omitempty"`
|
|
IsElite bool `json:"isElite"`
|
|
AttackCount int `json:"-"` // tracks attacks for burst/chain abilities
|
|
}
|
|
|
|
// IsAlive returns true if the enemy has HP remaining.
|
|
func (e *Enemy) IsAlive() bool {
|
|
return e.HP > 0
|
|
}
|
|
|
|
// HasAbility checks if the enemy possesses a given special ability.
|
|
func (e *Enemy) HasAbility(a SpecialAbility) bool {
|
|
for _, ab := range e.SpecialAbilities {
|
|
if ab == a {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// EnemyTemplates defines base stats for each enemy type.
|
|
// These are used when spawning new enemies; actual instances may have scaled stats.
|
|
var EnemyTemplates = map[EnemyType]Enemy{
|
|
// --- Basic enemies ---
|
|
EnemyWolf: {
|
|
Type: EnemyWolf, Name: "Forest Wolf",
|
|
MaxHP: 60, Attack: 11, Defense: 5, Speed: 1.8, CritChance: 0.05,
|
|
MinLevel: 1, MaxLevel: 5,
|
|
XPReward: 1, GoldReward: 1,
|
|
},
|
|
EnemyBoar: {
|
|
Type: EnemyBoar, Name: "Wild Boar",
|
|
MaxHP: 74, Attack: 19, Defense: 8, Speed: 0.8, CritChance: 0.08,
|
|
MinLevel: 2, MaxLevel: 6,
|
|
XPReward: 1, GoldReward: 1,
|
|
},
|
|
EnemyZombie: {
|
|
Type: EnemyZombie, Name: "Rotting Zombie",
|
|
MaxHP: 108, Attack: 17, Defense: 8, Speed: 0.5,
|
|
MinLevel: 3, MaxLevel: 8,
|
|
XPReward: 1, GoldReward: 1,
|
|
SpecialAbilities: []SpecialAbility{AbilityPoison},
|
|
},
|
|
EnemySpider: {
|
|
Type: EnemySpider, Name: "Cave Spider",
|
|
MaxHP: 44, Attack: 17, Defense: 4, Speed: 2.0, CritChance: 0.15,
|
|
MinLevel: 4, MaxLevel: 9,
|
|
XPReward: 1, GoldReward: 1,
|
|
SpecialAbilities: []SpecialAbility{AbilityCritical},
|
|
},
|
|
EnemyOrc: {
|
|
Type: EnemyOrc, Name: "Orc Warrior",
|
|
MaxHP: 118, Attack: 22, Defense: 13, Speed: 1.0, CritChance: 0.05,
|
|
MinLevel: 5, MaxLevel: 12,
|
|
XPReward: 1, GoldReward: 1,
|
|
SpecialAbilities: []SpecialAbility{AbilityBurst},
|
|
},
|
|
EnemySkeletonArcher: {
|
|
Type: EnemySkeletonArcher, Name: "Skeleton Archer",
|
|
MaxHP: 96, Attack: 24, Defense: 11, Speed: 1.3, CritChance: 0.06,
|
|
MinLevel: 6, MaxLevel: 14,
|
|
XPReward: 1, GoldReward: 1,
|
|
SpecialAbilities: []SpecialAbility{AbilityDodge},
|
|
},
|
|
EnemyBattleLizard: {
|
|
Type: EnemyBattleLizard, Name: "Battle Lizard",
|
|
MaxHP: 148, Attack: 25, Defense: 19, Speed: 0.7, CritChance: 0.03,
|
|
MinLevel: 7, MaxLevel: 15,
|
|
XPReward: 1, GoldReward: 1,
|
|
SpecialAbilities: []SpecialAbility{AbilityRegen},
|
|
},
|
|
|
|
// --- Elite enemies ---
|
|
EnemyFireDemon: {
|
|
Type: EnemyFireDemon, Name: "Fire Demon",
|
|
MaxHP: 128, Attack: 24, Defense: 13, Speed: 1.2, CritChance: 0.10,
|
|
MinLevel: 10, MaxLevel: 20,
|
|
XPReward: 1, GoldReward: 1, IsElite: true,
|
|
SpecialAbilities: []SpecialAbility{AbilityBurn},
|
|
},
|
|
EnemyIceGuardian: {
|
|
Type: EnemyIceGuardian, Name: "Ice Guardian",
|
|
MaxHP: 245, Attack: 28, Defense: 26, Speed: 0.7, CritChance: 0.04,
|
|
MinLevel: 12, MaxLevel: 22,
|
|
XPReward: 1, GoldReward: 1, IsElite: true,
|
|
SpecialAbilities: []SpecialAbility{AbilityIceSlow},
|
|
},
|
|
EnemySkeletonKing: {
|
|
Type: EnemySkeletonKing, Name: "Skeleton King",
|
|
MaxHP: 365, Attack: 42, Defense: 28, Speed: 0.9, CritChance: 0.08,
|
|
MinLevel: 15, MaxLevel: 25,
|
|
XPReward: 1, GoldReward: 1, IsElite: true,
|
|
SpecialAbilities: []SpecialAbility{AbilityRegen, AbilitySummon},
|
|
},
|
|
EnemyWaterElement: {
|
|
Type: EnemyWaterElement, Name: "Water Element",
|
|
MaxHP: 455, Attack: 37, Defense: 22, Speed: 0.8, CritChance: 0.05,
|
|
MinLevel: 18, MaxLevel: 28,
|
|
XPReward: 2, GoldReward: 1, IsElite: true,
|
|
SpecialAbilities: []SpecialAbility{AbilitySlow},
|
|
},
|
|
EnemyForestWarden: {
|
|
Type: EnemyForestWarden, Name: "Forest Warden",
|
|
MaxHP: 610, Attack: 34, Defense: 37, Speed: 0.5, CritChance: 0.03,
|
|
MinLevel: 20, MaxLevel: 30,
|
|
XPReward: 2, GoldReward: 1, IsElite: true,
|
|
SpecialAbilities: []SpecialAbility{AbilityRegen},
|
|
},
|
|
EnemyLightningTitan: {
|
|
Type: EnemyLightningTitan, Name: "Lightning Titan",
|
|
MaxHP: 565, Attack: 49, Defense: 28, Speed: 1.5, CritChance: 0.12,
|
|
MinLevel: 25, MaxLevel: 35,
|
|
XPReward: 3, GoldReward: 2, IsElite: true,
|
|
SpecialAbilities: []SpecialAbility{AbilityStun, AbilityChainLightning},
|
|
},
|
|
}
|
|
|
|
func SetEnemyTemplates(next map[EnemyType]Enemy) {
|
|
if len(next) == 0 {
|
|
return
|
|
}
|
|
EnemyTemplates = next
|
|
}
|