feat: skill cooldown (3/combat), inventory limit (10), scaled event damage
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,7 @@ type Player struct {
|
||||
Relics []Relic
|
||||
Dead bool
|
||||
Fled bool
|
||||
SkillUses int // remaining skill uses this combat
|
||||
}
|
||||
|
||||
func NewPlayer(name string, class Class) *Player {
|
||||
|
||||
@@ -92,6 +92,11 @@ func (s *GameSession) spawnMonsters() {
|
||||
}
|
||||
s.state.Monsters[i] = m
|
||||
}
|
||||
|
||||
// Reset skill uses for all players at combat start
|
||||
for _, p := range s.state.Players {
|
||||
p.SkillUses = 3
|
||||
}
|
||||
}
|
||||
|
||||
func (s *GameSession) spawnBoss() {
|
||||
@@ -115,11 +120,20 @@ func (s *GameSession) spawnBoss() {
|
||||
boss.DEF = boss.DEF / 2
|
||||
}
|
||||
s.state.Monsters = []*entity.Monster{boss}
|
||||
|
||||
// Reset skill uses for all players at combat start
|
||||
for _, p := range s.state.Players {
|
||||
p.SkillUses = 3
|
||||
}
|
||||
}
|
||||
|
||||
func (s *GameSession) grantTreasure() {
|
||||
floor := s.state.FloorNum
|
||||
for _, p := range s.state.Players {
|
||||
if len(p.Inventory) >= 10 {
|
||||
s.addLog(fmt.Sprintf("%s's inventory is full!", p.Name))
|
||||
continue
|
||||
}
|
||||
if rand.Float64() < 0.5 {
|
||||
bonus := 3 + rand.Intn(6) + floor/3
|
||||
item := entity.Item{
|
||||
@@ -190,11 +204,13 @@ func (s *GameSession) triggerEvent() {
|
||||
continue
|
||||
}
|
||||
if rand.Float64() < 0.5 {
|
||||
dmg := 10 + rand.Intn(11)
|
||||
baseDmg := 10 + s.state.FloorNum
|
||||
dmg := baseDmg + rand.Intn(baseDmg/2+1)
|
||||
p.TakeDamage(dmg)
|
||||
s.addLog(fmt.Sprintf("Trap! %s takes %d damage", p.Name, dmg))
|
||||
} else {
|
||||
heal := 15 + rand.Intn(11)
|
||||
baseHeal := 15 + s.state.FloorNum
|
||||
heal := baseHeal + rand.Intn(baseHeal/2+1)
|
||||
before := p.HP
|
||||
p.Heal(heal)
|
||||
s.addLog(fmt.Sprintf("Blessing! %s heals %d HP", p.Name, p.HP-before))
|
||||
|
||||
@@ -282,6 +282,9 @@ func (s *GameSession) BuyItem(playerID string, itemIdx int) bool {
|
||||
item := s.state.ShopItems[itemIdx]
|
||||
for _, p := range s.state.Players {
|
||||
if p.Fingerprint == playerID && p.Gold >= item.Price {
|
||||
if len(p.Inventory) >= 10 {
|
||||
return false
|
||||
}
|
||||
p.Gold -= item.Price
|
||||
p.Inventory = append(p.Inventory, item)
|
||||
return true
|
||||
|
||||
@@ -97,6 +97,11 @@ func (s *GameSession) resolvePlayerActions() {
|
||||
})
|
||||
intentOwners = append(intentOwners, p.Name)
|
||||
case ActionSkill:
|
||||
if p.SkillUses <= 0 {
|
||||
s.addLog(fmt.Sprintf("%s has no skill uses left!", p.Name))
|
||||
break
|
||||
}
|
||||
p.SkillUses--
|
||||
switch p.Class {
|
||||
case entity.ClassWarrior:
|
||||
for _, m := range s.state.Monsters {
|
||||
|
||||
@@ -124,6 +124,7 @@ func renderHUD(state game.GameState, targetCursor int, moveCursor int) string {
|
||||
case entity.ClassRogue:
|
||||
skillDesc = "Skill: Scout — reveal neighboring rooms"
|
||||
}
|
||||
skillDesc += fmt.Sprintf(" (%d uses left)", p.SkillUses)
|
||||
sb.WriteString(styleSystem.Render(skillDesc))
|
||||
sb.WriteString("\n")
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user