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:
2026-03-24 13:46:17 +09:00
parent 9ed71eeccd
commit 15199bd26f
5 changed files with 28 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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))

View File

@@ -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

View File

@@ -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 {

View File

@@ -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