diff options
| author | historia <[not public]> | 2026-06-16 01:59:27 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-16 01:59:27 -0400 |
| commit | 43f21aabae8924f35c12c8485e690aeefe0089fb (patch) | |
| tree | b5fbadb89df3cf4ffec86503bb8e2d7e52b27454 /internal/game/action_gather.go | |
| parent | 4cc1ddcd185509080b4b3e15d1646567edd51c9d (diff) | |
| download | thehouseoficarus-43f21aabae8924f35c12c8485e690aeefe0089fb.tar.gz | |
feat: overhauled ansi color, added prompt options
Diffstat (limited to 'internal/game/action_gather.go')
| -rw-r--r-- | internal/game/action_gather.go | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/internal/game/action_gather.go b/internal/game/action_gather.go index 08d2589..e3ea105 100644 --- a/internal/game/action_gather.go +++ b/internal/game/action_gather.go @@ -6,7 +6,6 @@ import ( "strings" "thirdcollapse/internal/action" - "thirdcollapse/internal/color" "thirdcollapse/internal/engine" "thirdcollapse/internal/net" "thirdcollapse/internal/object" @@ -178,7 +177,6 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { wait := p.Action.Data["effective_wait"].(float64) instanceKey := p.Action.Data["instance_key"].(string) _, shared := p.Action.Data["deplete_timer"] - mode := g.colorMode(sess) if step == 0 { if cfg.Bait != "" { @@ -187,12 +185,12 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { if def, err := g.ItemStore.Load(cfg.Bait); err == nil { baitName = def.Name } - sess.WriteLine(color.Wrap(mode, "red", fmt.Sprintf("You've run out of %s.", baitName))) + sess.WriteLine(g.colorize(sess, "error", fmt.Sprintf("You've run out of %s.", baitName))) g.CancelAction(p) return } } - sess.WriteLine(fmt.Sprintf("\n%s", color.Tag(mode, cfg.GatherMsg))) + sess.WriteLine(fmt.Sprintf("\n%s", cfg.GatherMsg)) p.Action.Data["step"] = 1 p.Action.WaitLeft = engine.ToTicks(wait) return @@ -205,7 +203,7 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { return } if cfg.RespawnMsg != "" { - sess.WriteLine(fmt.Sprintf("\n%s", color.Tag(mode, cfg.RespawnMsg))) + sess.WriteLine(fmt.Sprintf("\n%s", cfg.RespawnMsg)) } p.Action.Data["step"] = 0 p.Action.WaitLeft = engine.ToTicks(wait) @@ -218,7 +216,7 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { if def, err := g.ItemStore.Load(cfg.Bait); err == nil { baitName = def.Name } - sess.WriteLine(color.Wrap(mode, "red", fmt.Sprintf("You've run out of %s.", baitName))) + sess.WriteLine(g.colorize(sess, "error", fmt.Sprintf("You've run out of %s.", baitName))) g.CancelAction(p) return } @@ -234,7 +232,7 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { if drop != nil { freeSlot := p.FirstFreeSlot() if freeSlot == -1 { - sess.WriteLine(color.Wrap(mode, "red", "Your inventory is too full!")) + sess.WriteLine(g.colorize(sess, "error", "Your inventory is too full!")) g.CancelAction(p) return } @@ -245,8 +243,9 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { } itemName := drop.ItemID - if def, err := g.ItemStore.Load(drop.ItemID); err == nil { - itemName = def.Name + itemDef, _ := g.ItemStore.Load(drop.ItemID) + if itemDef != nil { + itemName = itemDef.Name } p.SetInvSlot(freeSlot, &player.InventorySlot{ItemID: drop.ItemID, Quantity: qty}) @@ -256,19 +255,17 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { } if xp > 0 { if newLevel := p.AddSkillXP(player.SkillName(cfg.Skill), xp); newLevel > 0 { - sess.WriteLine(color.Wrap(mode, "bright_yellow", fmt.Sprintf("*** You are now level %d %s! ***", newLevel, cfg.Skill))) + sess.WriteLine(g.colorize(sess, "level_up", fmt.Sprintf("*** You are now level %d %s! ***", newLevel, cfg.Skill))) } } g.AccountStore.SaveCharacter(p) msg := drop.Message if msg == "" { - msg = fmt.Sprintf("You manage to get some %s.", color.Wrap(mode, "green", itemName)) - } else { - msg = color.Tag(mode, msg) + msg = fmt.Sprintf("You manage to get some %s.", g.itemColorize(sess, itemDef, itemName)) } if xp > 0 && p.OptionBool("xp_drops") { - msg += color.Wrap(mode, "yellow", fmt.Sprintf(" (+%dxp %s)", xp, player.SkillAbbr[player.SkillName(cfg.Skill)])) + msg += g.colorize(sess, "xp", fmt.Sprintf(" (+%dxp %s)", xp, player.SkillAbbr[player.SkillName(cfg.Skill)])) } sess.WriteLine(msg) @@ -309,7 +306,7 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { continue } if op.Action.Data["instance_key"] == instanceKey { - other.WriteLine(fmt.Sprintf("\nThe %s was depleted by %s!", color.Wrap(mode, "green", p.Action.TargetName), color.Wrap(mode, "bright_white", p.Name))) + other.WriteLine(fmt.Sprintf("\nThe %s was depleted by %s!", g.colorize(sess, "item", p.Action.TargetName), g.colorize(sess, "player_name", p.Name))) g.CancelAction(op) g.writePrompt(other) } @@ -321,7 +318,7 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { } if p.FirstFreeSlot() == -1 { - sess.WriteLine(color.Wrap(mode, "red", "Your inventory is too full!")) + sess.WriteLine(g.colorize(sess, "error", "Your inventory is too full!")) g.CancelAction(p) return } @@ -331,9 +328,9 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { } } - sess.WriteLine(color.Tag(mode, cfg.FailMsg)) + sess.WriteLine(cfg.FailMsg) if p.FirstFreeSlot() == -1 { - sess.WriteLine(color.Wrap(mode, "red", "Your inventory is too full!")) + sess.WriteLine(g.colorize(sess, "error", "Your inventory is too full!")) g.CancelAction(p) return } |
