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:
parent
eb753648ea
commit
9c3cb904ee
@ -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)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user