v0.7.0 cli client with readline added, directory structure updated

This commit is contained in:
2025-11-13 08:55:06 -05:00
parent 52868af4ea
commit 6bdc061508
52 changed files with 2260 additions and 157 deletions

View File

@ -0,0 +1,54 @@
// FILE: lixenwraith/chess/internal/client/display/board.go
package display
import (
"fmt"
"strings"
)
// RenderBoard renders an ASCII board with colored pieces
func RenderBoard(asciiBoard string) {
lines := strings.Split(asciiBoard, "\n")
for i, line := range lines {
if strings.TrimSpace(line) == "" {
continue
}
isRankLine := (i == 0) || (i == 9)
// Process each character
for _, char := range line {
switch {
case char >= 'a' && char <= 'h' && isRankLine:
// File letters - Cyan
fmt.Printf("%s%c%s", Cyan, char, Reset)
case char >= 'A' && char <= 'Z':
// White pieces - Blue
fmt.Printf("%s%c%s", Blue, char, Reset)
case char >= 'a' && char <= 'z' && !isRankLine:
// Black pieces - Red
fmt.Printf("%s%c%s", Red, char, Reset)
case char == '.':
// Empty squares
fmt.Printf(".")
case char >= '1' && char <= '8':
// Rank numbers - Cyan
fmt.Printf("%s%c%s", Cyan, char, Reset)
case char == ' ':
fmt.Printf(" ")
default:
fmt.Printf("%c", char)
}
}
fmt.Println()
}
}
// ColorForTurn returns colored turn indicator
func ColorForTurn(turn string) string {
if turn == "w" {
return Blue + "White" + Reset
}
return Red + "Black" + Reset
}

View File

@ -0,0 +1,19 @@
// FILE: lixenwraith/chess/internal/client/display/colors.go
package display
// Terminal color codes
const (
Reset = "\033[0m"
Red = "\033[31m"
Green = "\033[32m"
Yellow = "\033[33m"
Blue = "\033[34m"
Magenta = "\033[35m"
Cyan = "\033[36m"
White = "\033[37m"
)
// Prompt returns a colored prompt string
func Prompt(text string) string {
return Yellow + text + Yellow + " > " + Reset
}

View File

@ -0,0 +1,17 @@
// FILE: lixenwraith/chess/internal/client/display/format.go
package display
import (
"encoding/json"
"fmt"
)
// PrettyPrintJSON prints formatted JSON
func PrettyPrintJSON(v interface{}) {
data, err := json.MarshalIndent(v, "", " ")
if err != nil {
fmt.Printf("%sError formatting JSON: %s%s\n", Red, err.Error(), Reset)
return
}
fmt.Println(string(data))
}