mirror of
https://github.com/imjasonh/chessh
synced 2026-07-07 00:33:53 +00:00
simplify UI
Signed-off-by: Jason Hall <jason@chainguard.dev>
This commit is contained in:
parent
14fc47012c
commit
36c03525a9
3 changed files with 3 additions and 45 deletions
1
go.mod
1
go.mod
|
|
@ -50,7 +50,6 @@ require (
|
|||
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||
github.com/muesli/termenv v0.16.0 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/sethvargo/go-envconfig v1.3.0 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.2.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.63.0 // indirect
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -96,8 +96,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
|||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/sethvargo/go-envconfig v1.3.0 h1:gJs+Fuv8+f05omTpwWIu6KmuseFAXKrIaOZSh8RMt0U=
|
||||
github.com/sethvargo/go-envconfig v1.3.0/go.mod h1:JLd0KFWQYzyENqnEPWWZ49i4vzZo/6nRidxI8YvGiHw=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
||||
|
|
|
|||
45
main.go
45
main.go
|
|
@ -307,9 +307,10 @@ func (m model) View() string {
|
|||
}
|
||||
|
||||
if m.isMyTurn {
|
||||
s.WriteString("YOUR TURN - Use arrow keys to move cursor, ENTER/SPACE to select/move, ESC to deselect, Q to quit\n\n")
|
||||
s.WriteString("YOUR TURN - Use arrow keys to move cursor\n")
|
||||
s.WriteString("SPACE to select, ESC to deselect, Q to quit\n\n")
|
||||
} else {
|
||||
s.WriteString("OPPONENT'S TURN - Please wait for your opponent to move\n\n")
|
||||
s.WriteString("OPPONENT'S TURN - Please wait\n\n\n")
|
||||
}
|
||||
|
||||
status := m.game.GameStatus()
|
||||
|
|
@ -417,46 +418,6 @@ func (m model) getInfoLines() []string {
|
|||
|
||||
lines = append(lines, "│ │")
|
||||
|
||||
if m.selected != nil {
|
||||
lines = append(lines, "├─────────────────────┤")
|
||||
selectedPiece := m.game.Board.At(*m.selected)
|
||||
selectedName := m.getPieceName(selectedPiece)
|
||||
lines = append(lines, fmt.Sprintf("│ Selected: %-10s │", selectedName))
|
||||
lines = append(lines, fmt.Sprintf("│ At: %-15s │", m.selected.String()))
|
||||
|
||||
if len(m.validMoves) > 0 {
|
||||
lines = append(lines, "│ │")
|
||||
lines = append(lines, "│ Valid moves: │")
|
||||
|
||||
// Show up to 6 valid moves
|
||||
moveCount := len(m.validMoves)
|
||||
if moveCount > 6 {
|
||||
moveCount = 6
|
||||
}
|
||||
|
||||
for i := 0; i < moveCount; i += 2 {
|
||||
var moveLine strings.Builder
|
||||
moveLine.WriteString("│ ")
|
||||
moveLine.WriteString(m.validMoves[i].String())
|
||||
|
||||
if i+1 < moveCount {
|
||||
moveLine.WriteString(fmt.Sprintf(" %s", m.validMoves[i+1].String()))
|
||||
}
|
||||
|
||||
// Pad to fit box width
|
||||
for moveLine.Len() < 20 {
|
||||
moveLine.WriteString(" ")
|
||||
}
|
||||
moveLine.WriteString(" │")
|
||||
|
||||
lines = append(lines, moveLine.String())
|
||||
}
|
||||
|
||||
if len(m.validMoves) > 6 {
|
||||
lines = append(lines, fmt.Sprintf("│ ... and %d more │", len(m.validMoves)-6))
|
||||
}
|
||||
}
|
||||
}
|
||||
lines = append(lines, "└─────────────────────┘")
|
||||
|
||||
if len(m.game.MoveHistory) > 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue