Castling that gives check or mate is written without + or #

Aberta Para iniciantes
#145 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
90/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
javascript
Domínio
backend

Direção de pesquisa

Leia js/notation.js ao redor de writeSAN e a lógica compartilhada dos sufixos de xeque e mate nas linhas 62–65. Em seguida, examine os testes de notação em tests/unit/import.test.js ou tests/unit/rules.test.js e execute npm test. O trabalho está concluído quando você verificar que os roques incluem + ou #, conforme apropriado, e que o PGN resultante é importado novamente como a mesma partida.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug good first issue severity: low

Summary

writeSAN returns early for castling, before the check suffix is added. So a castling move that gives check is written "O-O" instead of "O-O+", and a castling move that mates is written "O-O" instead of "O-O#".

Where

  • js/notation.js:19-21 (writeSAN)
  • js/notation.js:62-65 (the shared check and mate suffix code that castling skips)

Details

if (move.isCastling) {
    return move.to.col > move.from.col ? 'O-O' : 'O-O-O';
}
...
if (isInCheck(positionAfter, opponent)) { notation += ... '#' : '+'; }

The move record still has isCheck and isCheckmate set correctly. Only the notation text is wrong.

Impact

The move list, Copy PGN and Save PGN all drop the + or # after a checking castle. An exported game that ends in a castling mate does not show the mate.

Steps to reproduce

  1. Set up { e1:'wk', h1:'wr', f8:'bk', e7:'bp', g7:'bp', e8:'br', g8:'br' } with White to move. The FEN is 4rkr1/4p1p1/8/8/8/8/8/4K2R w K - 0 1.
  2. Play e1g1 (O-O). The status says "Checkmate! White wins.", but the move list shows O-O and the PGN movetext is 1. O-O 1-0.

Suggested fix

Assign the castling string to notation and let it fall through to the shared check and mate suffix code. Skip only the disambiguation and capture parts.

Acceptance criteria

  • A castling move that gives check is written O-O+ / O-O-O+
  • A castling move that mates is written O-O#
  • The resulting PGN imports back to the same game

Getting started

  • Relevant files: js/notation.js, tests in tests/unit/import.test.js or tests/unit/rules.test.js
  • How to run tests: npm ci && npm test

Filed by repo-audit/full-audit at 73cd279. Severity: low. Effort: S. audit-key: bug|js/notation.js|writeSAN

Linguagem predominante
JavaScript
Estrelas
4
Forks
2
Merge médio
6h 13min
PRs com merge (30d)
4

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de TMHSDigital/Static_Chess

Todas as issues de TMHSDigital/Static_Chess

Issues semelhantes

Mais issues de JavaScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.