aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_colortable.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-27 16:50:41 -0400
committerhistoria <[not public]>2026-06-27 16:50:41 -0400
commit988b006a5bb9edb6465653566e7bdf8175347b8c (patch)
tree3a1fceff2ee80c11b5dafcc49c13ababe021e880 /internal/game/cmd_colortable.go
parent1cab9ca20e24742f770a676f84e4ed9f1636f297 (diff)
downloadthehouseoficarus-988b006a5bb9edb6465653566e7bdf8175347b8c.tar.gz
feat: one-way map links, blocked paths on map, map grid startup validation, user colors for maps
Diffstat (limited to 'internal/game/cmd_colortable.go')
-rw-r--r--internal/game/cmd_colortable.go79
1 files changed, 3 insertions, 76 deletions
diff --git a/internal/game/cmd_colortable.go b/internal/game/cmd_colortable.go
index baa30e8..d228a34 100644
--- a/internal/game/cmd_colortable.go
+++ b/internal/game/cmd_colortable.go
@@ -15,44 +15,18 @@ func (g *Game) doColortable(sess *net.Session) {
return
}
- p := sess.Player
- unicode := p.OptionBool("unicode")
-
- sess.WriteLine(fmt.Sprintf("Color mode: %s", mode))
-
- sess.WriteLine("")
- writeSectionHeader(sess, "Foreground Colors", unicode)
writeColorBlock(sess, mode, true)
-
sess.WriteLine("")
- writeSectionHeader(sess, "Background Colors", unicode)
writeColorBlock(sess, mode, false)
-
- sess.WriteLine("")
- writeSectionHeader(sess, "Combinations", unicode)
- writeCombinations(sess, mode)
-
- sess.WriteLine("")
- writeSectionHeader(sess, "ANSI Mode (16 colors)", unicode)
- writeANSITable(sess, mode)
}
func (g *Game) executeColortable(sess *net.Session, args []string, rawInput string) {
g.doColortable(sess)
}
-func writeSectionHeader(sess *net.Session, title string, unicode bool) {
- if unicode {
- sess.WriteLine(fmt.Sprintf("── %s ──", title))
- } else {
- sess.WriteLine(fmt.Sprintf("-- %s --", title))
- }
-}
-
func writeColorBlock(sess *net.Session, mode string, fg bool) {
- sess.WriteLine("Standard:")
+ sess.WriteLine("ANSI 16 Colors:")
writeColorRow(sess, mode, 0, 8, fg)
- sess.WriteLine("Bright:")
writeColorRow(sess, mode, 8, 16, fg)
sess.WriteLine("Color cube:")
@@ -72,7 +46,7 @@ func writeColorBlock(sess *net.Session, mode string, fg bool) {
sb.WriteString(color.ContrastFg(mode, idx))
sb.WriteString(color.BgCode(mode, idx))
}
- sb.WriteString(fmt.Sprintf("%4d", idx))
+ sb.WriteString(fmt.Sprintf(" %02X", idx))
sb.WriteString(color.Reset)
}
if block < 2 {
@@ -100,55 +74,8 @@ func writeColorRow(sess *net.Session, mode string, start, end int, fg bool) {
sb.WriteString(color.ContrastFg(mode, i))
sb.WriteString(color.BgCode(mode, i))
}
- sb.WriteString(fmt.Sprintf("%4d", i))
+ sb.WriteString(fmt.Sprintf(" %02X", i))
sb.WriteString(color.Reset)
}
sess.WriteLine(sb.String())
}
-
-func writeCombinations(sess *net.Session, mode string) {
- type combo struct {
- fg int
- bg int
- desc string
- }
- combos := []combo{
- {15, 0, "white on black"},
- {208, 0, "orange on black"},
- {0, 178, "black on gold"},
- {15, 24, "white on dark blue"},
- {0, 15, "black on white"},
- {15, 88, "white on dark red"},
- {178, 52, "gold on brown"},
- {14, 0, "bright cyan on black"},
- {0, 228, "black on pale yellow"},
- {15, 22, "white on dark green"},
- {9, 0, "bright red on black"},
- {11, 17, "bright yellow on navy"},
- }
- for _, c := range combos {
- spec := color.ColorSpec{Fg: c.fg, Bg: c.bg}
- sample := color.Render(mode, spec, fmt.Sprintf(" %3d on %3d ", c.fg, c.bg))
- sess.WriteLine(fmt.Sprintf(" %s %s", sample, c.desc))
- }
-}
-
-func writeANSITable(sess *net.Session, mode string) {
- names := [16]string{
- "black", "red", "green", "yellow",
- "blue", "magenta", "cyan", "white",
- "brt black", "brt red", "brt green", "brt yellow",
- "brt blue", "brt magenta", "brt cyan", "brt white",
- }
- for row := 0; row < 2; row++ {
- var sb strings.Builder
- for col := 0; col < 8; col++ {
- idx := row*8 + col
- sb.WriteString(color.FgCode(mode, idx))
- sb.WriteString(fmt.Sprintf("%3d", idx))
- sb.WriteString(color.Reset)
- sb.WriteString(fmt.Sprintf(" %-12s", names[idx]))
- }
- sess.WriteLine(sb.String())
- }
-}