mirror of
https://github.com/Earth-Genesis-Games/Ajedrez_Purgatorio.git
synced 2026-09-11 09:47:35 +00:00
- Fix 9 CS0101 duplicate classes between Mono/ and Mono/Classic/ - BoardManager -> ClassicBoardManager, SquareClick -> ClassicSquareClick - Delete duplicate Piece/Pawn/King/Queen/Rook/Bishop/Knight from Classic/ - Merge GetAttackSquares into Piece base class with overrides - Fix King castling: reject castling through/while in check - Assign URP pipeline to QualitySettings (6 levels) and GraphicsSettings - Fix template identifiers (DefaultCompany -> EarthGenesisGames) - Delete orphaned SampleScene.unity and duplicate URP assets - Fix test assembly reference (Assembly-CSharp -> AjedrezPurgatorio.Runtime) - Remove 11 unused packages (multiplayer, visualscripting, terrain, etc.) - Update BoardInputSystemSpike for ClassicSquareClick - Write unit tests: CheckDetector, DrawDetector, MoveValidator - Fix BalanceConfig JSON structure to match C# class fields - Update stale documentation (~30 files) - architecture.md, ADR-0001, roadmap, gate-check, EPIC.md - PROJECT_STATUS.md, BLOQUEADORES_JUGABILIDAD.md - tech-debt-register.md - Add Unity Editor setup guide (production/UNITY_EDITOR_SETUP.md)
81 lines
3.2 KiB
C#
81 lines
3.2 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Pawn : Piece
|
|
{
|
|
public override List<Vector2Int> GetAvailableMoves(Piece[,] board)
|
|
{
|
|
List<Vector2Int> moves = new List<Vector2Int>();
|
|
int direction = isWhite ? 1 : -1;
|
|
|
|
// Movimiento hacia adelante
|
|
Vector2Int forward = new Vector2Int(currentPos.x, currentPos.y + direction);
|
|
if (IsInsideBoard(forward) && board[forward.x, forward.y] == null)
|
|
{
|
|
moves.Add(forward);
|
|
|
|
// Doble movimiento desde fila inicial
|
|
Vector2Int doubleForward = new Vector2Int(currentPos.x, currentPos.y + 2 * direction);
|
|
if ((isWhite && currentPos.y == 1) || (!isWhite && currentPos.y == 6))
|
|
{
|
|
if (board[doubleForward.x, doubleForward.y] == null)
|
|
moves.Add(doubleForward);
|
|
}
|
|
}
|
|
|
|
// Capturas diagonales normales
|
|
Vector2Int diagLeft = new Vector2Int(currentPos.x - 1, currentPos.y + direction);
|
|
Vector2Int diagRight = new Vector2Int(currentPos.x + 1, currentPos.y + direction);
|
|
|
|
if (IsInsideBoard(diagLeft) && board[diagLeft.x, diagLeft.y] != null && board[diagLeft.x, diagLeft.y].isWhite != isWhite)
|
|
moves.Add(diagLeft);
|
|
|
|
if (IsInsideBoard(diagRight) && board[diagRight.x, diagRight.y] != null && board[diagRight.x, diagRight.y].isWhite != isWhite)
|
|
moves.Add(diagRight);
|
|
|
|
// EN PASSANT
|
|
if (GameManager.Instance != null)
|
|
{
|
|
Piece lastMoved = GameManager.Instance.lastMovedPiece;
|
|
|
|
// Verificar si el último movimiento fue un peón enemigo avanzando 2 casillas
|
|
if (lastMoved != null && lastMoved is Pawn && lastMoved.isWhite != isWhite)
|
|
{
|
|
Vector2Int lastFrom = GameManager.Instance.lastMoveFrom;
|
|
Vector2Int lastTo = GameManager.Instance.lastMoveTo;
|
|
|
|
// Verificar que avanzó 2 casillas
|
|
if (Mathf.Abs(lastTo.y - lastFrom.y) == 2)
|
|
{
|
|
// Verificar que está en la misma fila (lado a lado)
|
|
if (lastTo.y == currentPos.y && Mathf.Abs(lastTo.x - currentPos.x) == 1)
|
|
{
|
|
// La casilla de captura en passant está "detrás" del peón enemigo
|
|
Vector2Int enPassantCapture = new Vector2Int(lastTo.x, currentPos.y + direction);
|
|
if (IsInsideBoard(enPassantCapture))
|
|
{
|
|
moves.Add(enPassantCapture);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return moves;
|
|
}
|
|
|
|
public override List<Vector2Int> GetAttackSquares(Piece[,] board)
|
|
{
|
|
List<Vector2Int> attacks = new List<Vector2Int>();
|
|
int direction = isWhite ? 1 : -1;
|
|
|
|
Vector2Int diagLeft = new Vector2Int(currentPos.x - 1, currentPos.y + direction);
|
|
Vector2Int diagRight = new Vector2Int(currentPos.x + 1, currentPos.y + direction);
|
|
|
|
if (IsInsideBoard(diagLeft)) attacks.Add(diagLeft);
|
|
if (IsInsideBoard(diagRight)) attacks.Add(diagRight);
|
|
|
|
return attacks;
|
|
}
|
|
}
|