aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_attack.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-15 02:57:35 -0400
committerhistoria <[not public]>2026-06-15 02:58:50 -0400
commit4cc1ddcd185509080b4b3e15d1646567edd51c9d (patch)
tree2a564846ad4fd159a2d7e55451bfa9569fe8c0b8 /internal/game/cmd_attack.go
parent445c4612cc5cf2c226f85894b6ad1e2419a374e2 (diff)
downloadthehouseoficarus-4cc1ddcd185509080b4b3e15d1646567edd51c9d.tar.gz
removed game speed for being broken and an antifeature anyway. added color support.
Diffstat (limited to 'internal/game/cmd_attack.go')
-rw-r--r--internal/game/cmd_attack.go36
1 files changed, 23 insertions, 13 deletions
diff --git a/internal/game/cmd_attack.go b/internal/game/cmd_attack.go
index ca5bc4c..08780c3 100644
--- a/internal/game/cmd_attack.go
+++ b/internal/game/cmd_attack.go
@@ -6,7 +6,9 @@ import (
"strconv"
"strings"
+ "thirdcollapse/internal/color"
"thirdcollapse/internal/combat"
+ "thirdcollapse/internal/engine"
"thirdcollapse/internal/net"
"thirdcollapse/internal/object"
"thirdcollapse/internal/player"
@@ -130,10 +132,11 @@ func (g *Game) startCombat(sess *net.Session, p *player.Player, mob *world.MobIn
if len(styleParts) > 0 {
styleStr = " Style: " + string(p.AttackStyle) + " (" + strings.Join(styleParts, ", ") + ")"
}
- sess.WriteLine(fmt.Sprintf("\nYou attack %s!%s", mobDisplayName(mob, true), styleStr))
+ mode := g.colorMode(sess)
+ sess.WriteLine(fmt.Sprintf("\nYou attack %s!%s", color.Wrap(mode, "bright_red", mobDisplayName(mob, true)), styleStr))
p.ActionState = &ActionState{Type: ActionCombating, TargetName: mob.Name}
- g.Ticks.Subscribe(g.computeTicks(playerSpeed), func() bool {
+ g.Ticks.Subscribe(engine.ToTicks(playerSpeed), func() bool {
cs := combat.GetCombat(p.Name)
if cs == nil || !cs.Active {
return false
@@ -151,7 +154,7 @@ func (g *Game) startCombat(sess *net.Session, p *player.Player, mob *world.MobIn
return true
})
- g.Ticks.Subscribe(g.computeTicks(mob.Speed), func() bool {
+ g.Ticks.Subscribe(engine.ToTicks(mob.Speed), func() bool {
cs := combat.GetCombat(p.Name)
if cs == nil || !cs.Active {
return false
@@ -182,6 +185,8 @@ func (g *Game) playerAttack(sess *net.Session, p *player.Player, mob *world.MobI
}
}
+ mode := g.colorMode(sess)
+
attRoll := combat.AttackRoll(p.Level(player.Attack), attBonus, equipAtt)
defRoll := combat.DefenseRoll(mob.Defense, 0, 0)
@@ -199,7 +204,7 @@ func (g *Game) playerAttack(sess *net.Session, p *player.Player, mob *world.MobI
gains, leveled := g.awardCombatXP(p, dmg)
for _, skill := range leveled {
- sess.WriteLine(fmt.Sprintf("*** You are now level %d %s! ***", p.Level(skill), skill))
+ sess.WriteLine(color.Wrap(mode, "bright_yellow", fmt.Sprintf("*** You are now level %d %s! ***", p.Level(skill), skill)))
}
mobName := mobDisplayName(mob, true)
@@ -212,7 +217,7 @@ func (g *Game) playerAttack(sess *net.Session, p *player.Player, mob *world.MobI
w = w2
}
g.combatPadWidth = w
- prefix := fmt.Sprintf(" You hit %s for %d damage.", mobName, dmg)
+ prefix := fmt.Sprintf(" You hit %s for %s damage.", color.Wrap(mode, "bright_red", mobName), color.Wrap(mode, "red", fmt.Sprint(dmg)))
hpPart := fmt.Sprintf("[%d/%dhp]", mob.HP, mob.MaxHP)
line := fmt.Sprintf("%-*s %s", g.combatPadWidth, prefix, hpPart)
if p.OptionBool("xp_drops") && len(gains) > 0 {
@@ -220,11 +225,11 @@ func (g *Game) playerAttack(sess *net.Session, p *player.Player, mob *world.MobI
for _, gain := range gains {
parts = append(parts, fmt.Sprintf("+%dxp %s", gain.XP, player.SkillAbbr[player.SkillName(gain.Skill)]))
}
- line += " (" + strings.Join(parts, ", ") + ")"
+ line += color.Wrap(mode, "yellow", " ("+strings.Join(parts, ", ")+")")
}
sess.WriteLine(line)
} else {
- sess.WriteLine(fmt.Sprintf(" You miss %s.", mobDisplayName(mob, true)))
+ sess.WriteLine(color.Wrap(mode, "dim", fmt.Sprintf(" You miss %s.", mobDisplayName(mob, true))))
}
}
@@ -242,6 +247,8 @@ func (g *Game) mobAttack(sess *net.Session, p *player.Player, mob *world.MobInst
attRoll := combat.AttackRoll(mob.Attack, 0, 0)
defRoll := combat.DefenseRoll(p.Level(player.Defense), defBonus, equipDef)
+ mode := g.colorMode(sess)
+
if combat.HitCheck(attRoll, defRoll) {
maxHit := combat.MaxHit(mob.Strength, 0, 0)
dmg := combat.RollDamage(maxHit)
@@ -263,7 +270,7 @@ func (g *Game) mobAttack(sess *net.Session, p *player.Player, mob *world.MobInst
w = w2
}
g.combatPadWidth = w
- prefix := fmt.Sprintf(" %s hits you for %d damage.", attacker, dmg)
+ prefix := fmt.Sprintf(" %s hits you for %s damage.", color.Wrap(mode, "bright_red", attacker), color.Wrap(mode, "red", fmt.Sprint(dmg)))
hpPart := fmt.Sprintf("[%d/%dhp]", p.HP, p.MaxHP())
sess.WriteLine(fmt.Sprintf("%-*s %s", g.combatPadWidth, prefix, hpPart))
} else {
@@ -271,7 +278,7 @@ func (g *Game) mobAttack(sess *net.Session, p *player.Player, mob *world.MobInst
if !mob.Unique {
attacker = "The " + mob.Name
}
- sess.WriteLine(fmt.Sprintf(" %s misses you.", attacker))
+ sess.WriteLine(color.Wrap(mode, "dim", fmt.Sprintf(" %s misses you.", attacker)))
}
}
@@ -279,9 +286,10 @@ func (g *Game) endCombat(sess *net.Session, p *player.Player, mob *world.MobInst
g.combatPadWidth = 0
combat.LeaveCombat(p.Name)
p.ActionState = nil
+ mode := g.colorMode(sess)
if p.HP <= 0 {
- sess.WriteLine("\nOh dear, you are dead!")
+ sess.WriteLine(color.Wrap(mode, "red", "\nOh dear, you are dead!"))
g.dropItemsOnDeath(p)
p.HP = p.MaxHP()
p.RoomID = 1
@@ -290,11 +298,12 @@ func (g *Game) endCombat(sess *net.Session, p *player.Player, mob *world.MobInst
g.Hub.EnterRoom(sess, p.RoomID)
}
g.doLook(sess)
+ g.writePrompt(sess)
return
}
if mob != nil && mob.HP <= 0 {
- sess.WriteLine(fmt.Sprintf("\nYou have defeated %s!", mobDisplayName(mob, true)))
+ sess.WriteLine(color.Wrap(mode, "green", fmt.Sprintf("\nYou have defeated %s!", mobDisplayName(mob, true))))
if g.Hub != nil {
for _, other := range g.Hub.PlayersInRoom(p.RoomID) {
if other != sess && other.Player != nil {
@@ -342,15 +351,16 @@ func (g *Game) endCombat(sess *net.Session, p *player.Player, mob *world.MobInst
}
}
- respawnTicks := g.computeTicks(mob.RespawnTicks)
+ respawnTicks := engine.ToTicks(mob.RespawnTicks)
if respawnTicks <= 0 {
- respawnTicks = g.computeTicks(30)
+ respawnTicks = engine.ToTicks(30)
}
instanceID := mob.InstanceID
g.Ticks.Subscribe(respawnTicks, func() bool {
g.respawnMob(instanceID)
return false
})
+ g.writePrompt(sess)
}
}