1
0
mirror of https://github.com/maaslalani/gambit.git synced 2024-11-21 16:46:50 +02:00

feat: auto promote to queen

This commit is contained in:
Maas Lalani 2023-11-21 09:48:54 -05:00
parent eb753648ea
commit 9c3cb904ee
2 changed files with 6 additions and 1 deletions

View File

@ -221,7 +221,7 @@ func (m *Game) Select(square string) (tea.Model, tea.Cmd) {
to := square
for _, move := range m.pieceMoves {
if move.String() == from+to {
if move.String() == from+to || (move.Promote() > 1 && move.String() == from+to+"q") {
var cmds []tea.Cmd
m.board.Apply(move)

View File

@ -13,6 +13,11 @@ func IsLegal(legalMoves []dt.Move, destination string) bool {
if strings.HasSuffix(move.String(), destination) {
return true
}
if move.Promote() > 1 && strings.HasSuffix(move.String(), destination+"q") {
return true
}
}
return false
}