private void AddStep(int x, int y, bool isPawnAtack = false) //isPawnAtack = true in case of a pawn move-attack { if (x < ChessConfig.size && x >= 0 && y < ChessConfig.size && y >= 0) { string newType = ChessConfig.GetFieldType(x, y); //Calculation the difference between the power of the piece before step and after int score = ChessConfig.GetPiecePower(newType) - ChessConfig.GetPiecePower(type); posibleSteps.Add(new StepData(x * 8 + y, this.x * 8 + this.y, score, isPawnAtack)); } }
public static List <StepData> GetRemainningSteps(char color, char[,] currDesk, Field[,] fields) { List <StepData> allSteps = new List <StepData>(); string pieceType; int size = ChessConfig.size; int crutch; int x, y; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { if (currDesk[i, j] == color || currDesk[i, j] == char.ToUpper(color)) { crutch = i * size + j; foreach (StepData sd in fields[i, j].posibleSteps) { pieceType = fields[i, j].type; x = sd.dest / size; y = sd.dest % size; sd.stepType = StepCheck(i, j, x, y, currDesk, pieceType, sd.isPawnAtack); sd.eatScore = 0; if (sd.stepType == " ") { sd.stepType = null; continue; } if (sd.stepType == "eat") { if (currDesk[x, y] == 'R' || currDesk[x, y] == 'B') { sd.eatScore = ChessConfig.GetPiecePower("Main"); } else //points for eating ↓ and the power of the enemy’s piece ↓ { sd.eatScore = ChessConfig.GetPiecePower("ordinary") + ChessConfig.GetPiecePower(fields[x, y].type); } } allSteps.Add(sd); } } } } return(allSteps); }