Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func (j judgment) plural() string {
return [...]string{"", "Inaccuracies", "Mistakes", "Blunders"}[j]
}

// nag is the judgment's annotation symbol (NAG) for the board: ?! ? ??.
func (j judgment) nag() moveGlyph {
return [...]moveGlyph{0, 6, 2, 4}[j]
}

// colour is the tag the move list and summary use for a judgment (Lichess's
// colours).
func (j judgment) colour() string {
Expand Down
21 changes: 20 additions & 1 deletion pkg/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ func TestAnalysisPanel(t *testing.T) {
t.Errorf("table has no %q:\n%s", want, table)
}
}
b := Root.pgame.postGame.Board
b.mu.Lock()
sq, g := b.glyphSq, b.glyph
b.mu.Unlock()
if sq != chess.G5 || g.text() != "??" {
t.Errorf("board glyph %v on %v, want ?? on g5", g.text(), sq)
}
if !strings.Contains(p.history.GetText(true), "Ng5??") {
t.Errorf("move list not marked:\n%s", p.history.GetText(true))
}
Expand All @@ -169,5 +176,17 @@ func TestAnalysisPanel(t *testing.T) {
t.Errorf("graph %d rows, want 9", gh)
}
})
onUI(func() { gotoWelcome() })
// a move without a judgment: no symbol
onUI(func() { Root.pgame.postGame.Board.ShowPly(2) })
waitFor(t, "the note for e5", func() bool { return strings.Contains(p.note.GetText(true), "1… e5") })
onUI(func() {
b := Root.pgame.postGame.Board
b.mu.Lock()
g := b.glyph
b.mu.Unlock()
if g != 0 {
t.Errorf("e5 shows %v on the board", g.text())
}
gotoWelcome()
})
}
18 changes: 14 additions & 4 deletions pkg/analysis_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ func (p *analysisPanel) reset() {
for _, it := range []cv.Primitive{p.graph, p.table, p.note} {
p.side.ResizeItem(it, 0, 0)
}
p.board.SetGlyph(chess.NoSquare, 0)
}

// start analyses the game with the local Stockfish; status reports
Expand Down Expand Up @@ -289,7 +290,7 @@ func (p *analysisPanel) start(positions []*chess.Position, moves []*chess.Move,
// finished shows the numbers once every position is analysed.
func (p *analysisPanel) finished() {
a := p.a
p.setT("Computer analysis · Stockfish")
p.setT("Stockfish analysis") // short: the sidebar can be 30 wide
p.table.SetText(analysisTable(a))
p.side.ResizeItem(p.table, strings.Count(p.table.GetText(false), "\n"), 0)
p.side.ResizeItem(p.note, 2, 0)
Expand All @@ -300,9 +301,18 @@ func (p *analysisPanel) finished() {
p.shown(ply)
}

// shown updates the note for the move the board is showing.
// shown updates the note for the move the board is showing, and marks the
// square it went to with its ?! ? or ?? (as studies show their symbols).
func (p *analysisPanel) shown(ply int) {
if p.a != nil {
p.note.SetText(moveNote(p.a, ply))
if p.a == nil {
return
}
p.note.SetText(moveNote(p.a, ply))
if p.a.complete() && ply >= 1 && ply <= len(p.a.moves) {
if j := p.a.judged[ply-1]; j != judgeNone {
p.board.SetGlyph(p.a.moves[ply-1].S2(), j.nag())
return
}
}
p.board.SetGlyph(chess.NoSquare, 0)
}
Loading