package bagaturchess.bitboard.bughouse.eval;

import bagaturchess.bitboard.common.Utils;
import bagaturchess.bitboard.impl.Constants;

public class KingAttackEvalI implements IBughouseBoardEval {

    int scaling, otherPieceScaling;
    BughouseAttackWeightEval bughouseAttackWeightEval;

    int[] BASE_PAWN_EVAL = Utils.reverseSpecial(new int[]{
            0, 0, 0, 0, 0, 0, 0, 0,
            5, 6, 6, 5, 6, 7, 8, 7,
            2, 3, 4, 5, 5, 5, 6, 6,
            1, 1, 2, 3, 3, 2, 2, 1,
            0, 1, 2, 2, 2, 2, 2, 1,
            0, 1, 1, 1, 1, 1, 1, 0,
            0, 0, 1, 1, 1, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0,
    });


    public KingAttackEvalI(int scalingVal, String fen) {
        this.scaling = scalingVal;
        this.bughouseAttackWeightEval = new BughouseAttackWeightEval(fen);
    }


    @Override
    public int getEval() {
        return 0;
    }


    @Override
    public int getPieceEval(int piece, int tileNumber) throws UnsupportedOperationException {
        switch(piece) {
            case (Constants.PID_W_PAWN):
                return BASE_PAWN_EVAL[tileNumber] * getCurrentScaling();
            case (Constants.PID_W_BISHOP):
                return BASE_BISHOP_EVAL[tileNumber]
                        * bughouseAttackWeightEval.getBughouseWeightedEvalBishop(tileNumber);
            case (Constants.PID_W_KNIGHT):
                return BASE_KNIGHT_EVAL[tileNumber]
                        * bughouseAttackWeightEval.getBughouseWeightedEvalKnight(tileNumber);
            case (Constants.PID_W_QUEEN):
                return BASE_QUEEN_EVAL[tileNumber]
                        * bughouseAttackWeightEval.getBughouseWeightedEvalQueen(tileNumber);
            case (Constants.PID_W_ROOK):
                return BASE_ROOK_EVAL[tileNumber]
                        * bughouseAttackWeightEval.getBughouseWeightedEvalRook(tileNumber);
            case (Constants.PID_W_KING):
                return 0;
            case (Constants.PID_B_PAWN):
                return -BASE_PAWN_EVAL[tileNumber] * getCurrentScaling();
            case (Constants.PID_B_BISHOP):
                return -BASE_BISHOP_EVAL[tileNumber]
                        * bughouseAttackWeightEval.getBughouseWeightedEvalBishop(tileNumber);
            case (Constants.PID_B_KNIGHT):
                return -BASE_KNIGHT_EVAL[tileNumber]
                        * bughouseAttackWeightEval.getBughouseWeightedEvalKnight(tileNumber);
            case (Constants.PID_B_QUEEN):
                return -BASE_QUEEN_EVAL[tileNumber]
                        * bughouseAttackWeightEval.getBughouseWeightedEvalQueen(tileNumber);
            case (Constants.PID_B_ROOK):
                return -BASE_ROOK_EVAL[tileNumber]
                        * bughouseAttackWeightEval.getBughouseWeightedEvalRook(tileNumber);
            case (Constants.PID_B_KING):
                return 0;
            default:
                throw new UnsupportedOperationException("Unknown piece found");
        }
    }

    private void setScaling(int updatedScaling) {
        this.scaling = updatedScaling;
    }

    private int getCurrentScaling() {
        return scaling;
    }

    private void setBasicPawnScaling() {
        this.scaling = 1;
    }

    private void setBasicOtherPieceScaling(int otherPieceScalingUpdated) {
        this.otherPieceScaling = otherPieceScalingUpdated;
    }

    private void setOtherPieceScaling() {
        this.otherPieceScaling = 1;
    }






}
