private void movecontrol_King(King t) { int po_x = t.getX(); int po_y = t.getY(); possiblemove.Clear(); for (int i = 0; i < 8; i++) { if (po_x + King_move[i].X < 8 && po_x + King_move[i].X >= 0 && po_y + King_move[i].Y >= 0 && po_y + King_move[i].Y < 8) { if (t_map[getIndex(po_x + King_move[i].X, po_y + King_move[i].Y)] != null) { if (t_map[getIndex(po_x + King_move[i].X, po_y + King_move[i].Y)].getSide() != tokenChosed.getSide()) { possiblemove.Add(new Point(po_x + King_move[i].X, po_y + King_move[i].Y)); } } else { possiblemove.Add(new Point(po_x + King_move[i].X, po_y + King_move[i].Y)); } } } if(!ischeck(t_map,t.getSide()) && t.isFirstmove()) { try { if (t_map[getIndex(0, po_y)].getType() == "Castle" && t_map[getIndex(0, po_y)].getSide()==t.getSide() && t_map[getIndex(0, po_y)].isFirstmove()) { bool block = false; for (int i = 1; i < po_x; i++) { if (t_map[getIndex(i, po_y)] != null) { block = true; break; } } if (!block) { Token[] map = map_clone(t_map); Token temp=tokenChosed; Token tempEnPassant=enPassant; tokenChosed=map[getIndex(po_x,po_y)]; move(map, po_x - 1, po_y); if (!ischeck(map,t.getSide())) { possiblemove.Add(new Point(po_x - 2, po_y)); } enPassant = tempEnPassant; tokenChosed = temp; } } } catch { } try { if (t_map[getIndex(7, po_y)].getType() == "Castle" && t_map[getIndex(0, po_y)].getSide() == t.getSide() && t_map[getIndex(7, po_y)].isFirstmove()) { bool block = false; for (int i = po_x + 1; i < 7; i++) { if (t_map[getIndex(i, po_y)] != null) { block = true; break; } } if (!block) { Token[] map = map_clone(t_map); Token temp = tokenChosed; Token tempEnPassant = enPassant; tokenChosed = map[getIndex(po_x, po_y)]; move(map, po_x + 1, po_y); if (!ischeck(map,t.getSide())) { possiblemove.Add(new Point(po_x + 2, po_y)); } enPassant = tempEnPassant; tokenChosed = temp; } } } catch { } } }
private void initTokens() { for (int i = 0; i < 64; i++) { t_map[i] = null; } //castle t_map[getIndex(0, 0)] = new Castle(0, 0, "b", Resources.Castle_b_l, Resources.Castle_b_d, Resources.Castle_b_l_p, Resources.Castle_b_d_p, Resources.Castle_b_l_s, Resources.Castle_b_d_s); t_map[getIndex(7, 0)] = new Castle(7, 0, "b", Resources.Castle_b_l, Resources.Castle_b_d, Resources.Castle_b_l_p, Resources.Castle_b_d_p, Resources.Castle_b_l_s, Resources.Castle_b_d_s); t_map[getIndex(0, 7)] = new Castle(0, 7, "w", Resources.Castle_w_l, Resources.Castle_w_d, Resources.Castle_w_l_p, Resources.Castle_w_d_p, Resources.Castle_w_l_s, Resources.Castle_w_d_s); t_map[getIndex(7, 7)] = new Castle(7, 7, "w", Resources.Castle_w_l, Resources.Castle_w_d, Resources.Castle_w_l_p, Resources.Castle_w_d_p, Resources.Castle_w_l_s, Resources.Castle_w_d_s); //Knight t_map[getIndex(1, 0)] = new Knight(1, 0, "b", Resources.Knight_b_l, Resources.Knight_b_d, Resources.Knight_b_l_p, Resources.Knight_b_d_p, Resources.Knight_b_l_s, Resources.Knight_b_d_s); t_map[getIndex(6, 0)] = new Knight(6, 0, "b", Resources.Knight_b_l, Resources.Knight_b_d, Resources.Knight_b_l_p, Resources.Knight_b_d_p, Resources.Knight_b_l_s, Resources.Knight_b_d_s); t_map[getIndex(1, 7)] = new Knight(1, 7, "w", Resources.Knight_w_l, Resources.Knight_w_d, Resources.Knight_w_l_p, Resources.Knight_w_d_p, Resources.Knight_w_l_s, Resources.Knight_w_d_s); t_map[getIndex(6, 7)] = new Knight(6, 7, "w", Resources.Knight_w_l, Resources.Knight_w_d, Resources.Knight_w_l_p, Resources.Knight_w_d_p, Resources.Knight_w_l_s, Resources.Knight_w_d_s); //Bishop t_map[getIndex(2, 0)] = new Bishop(2, 0, "b", Resources.Bishop_b_l, Resources.Bishop_b_d, Resources.Bishop_b_l_p, Resources.Bishop_b_d_p, Resources.Bishop_b_l_s, Resources.Bishop_b_d_s); t_map[getIndex(5, 0)] = new Bishop(5, 0, "b", Resources.Bishop_b_l, Resources.Bishop_b_d, Resources.Bishop_b_l_p, Resources.Bishop_b_d_p, Resources.Bishop_b_l_s, Resources.Bishop_b_d_s); t_map[getIndex(2, 7)] = new Bishop(2, 7, "w", Resources.Bishop_w_l, Resources.Bishop_w_d, Resources.Bishop_w_l_p, Resources.Bishop_w_d_p, Resources.Bishop_w_l_s, Resources.Bishop_w_d_s); t_map[getIndex(5, 7)] = new Bishop(5, 7, "w", Resources.Bishop_w_l, Resources.Bishop_w_d, Resources.Bishop_w_l_p, Resources.Bishop_w_d_p, Resources.Bishop_w_l_s, Resources.Bishop_w_d_s); //Queen t_map[getIndex(3, 0)] = new Queen(3, 0, "b", Resources.Queen_b_l, Resources.Queen_b_d, Resources.Queen_b_l_p, Resources.Queen_b_d_p, Resources.Queen_b_l_s, Resources.Queen_b_d_s); t_map[getIndex(3, 7)] = new Queen(3, 7, "w", Resources.Queen_w_l, Resources.Queen_w_d, Resources.Queen_w_l_p, Resources.Queen_w_d_p, Resources.Queen_w_l_s, Resources.Queen_w_d_s); //King t_map[getIndex(4, 0)] = new King(4, 0, "b", Resources.King_b_l, Resources.King_b_d, Resources.King_b_l_p, Resources.King_b_d_p, Resources.King_b_l_s, Resources.King_b_d_s); t_map[getIndex(4, 7)] = new King(4, 7, "w", Resources.King_w_l, Resources.King_w_d, Resources.King_w_l_p, Resources.King_w_d_p, Resources.King_w_l_s, Resources.King_w_d_s); //Pawn for (int i = 0; i < 8; i++) { t_map[getIndex(i, 1)] = new Pawn(i, 1, "b", Resources.Pawn_b_l, Resources.Pawn_b_d, Resources.Pawn_b_l_p, Resources.Pawn_b_d_p, Resources.Pawn_b_l_s, Resources.Pawn_b_d_s); t_map[getIndex(i, 6)] = new Pawn(i, 6, "w", Resources.Pawn_w_l, Resources.Pawn_w_d, Resources.Pawn_w_l_p, Resources.Pawn_w_d_p, Resources.Pawn_w_l_s, Resources.Pawn_w_d_s); } }