package com.dairymoose.modernlife.blocks.gui.chess;

/* loaded from: outputsrg.jar:com/dairymoose/modernlife/blocks/gui/chess/PawnPiece.class */
public class PawnPiece extends Piece {
    public static final int PAWN_STARTING_Y_BOTTOM = 6;
    public static final int PAWN_STARTING_Y_TOP = 1;

    @Override // com.dairymoose.modernlife.blocks.gui.chess.Piece
    public boolean canMove(int x, int y) {
        int xDiff = x - this.f9x;
        int yDiff = y - this.f10y;
        boolean pawnIsAtStartingPosition = (this.top && this.f10y == 1) || (!this.top && this.f10y == 6);
        boolean pawnMovingCorrectDirection = (this.top && y > this.f10y) || (!this.top && y < this.f10y);
        boolean canMoveForward = xDiff == 0 && pawnMovingCorrectDirection && (Math.abs(yDiff) <= 1 || (Math.abs(yDiff) <= 2 && pawnIsAtStartingPosition)) && this.screen.getPieceAt(x, y) == null;
        boolean canAttack = Math.abs(xDiff) == 1 && Math.abs(yDiff) == 1 && pawnMovingCorrectDirection && this.screen.getPieceAt(x, y) != null;
        if ((canMoveForward || canAttack) && !wouldCollide(x, y)) {
            return canDoMove(x, y);
        }
        return false;
    }

    @Override // com.dairymoose.modernlife.blocks.gui.chess.Piece
    public int getId() {
        return PieceIds.PAWN.ordinal();
    }
}
