mirror of
				https://github.com/lov3b/Schack.git
				synced 2025-11-04 15:10:21 +01:00 
			
		
		
		
	Ändringar nicklas snyggt
This commit is contained in:
		@@ -78,7 +78,7 @@ public class Pawn extends PieceKnownIfMoved {
 | 
				
			|||||||
        if (piece == null) {
 | 
					        if (piece == null) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        } else if (piece.isWhite() != this.isWhite()) {
 | 
					        } else if (piece.isWhite() != this.isWhite()) {
 | 
				
			||||||
            tryToMoveAndCheckIfCheck(pieces, movable, pos);
 | 
					            movable.addAll(tryToMoveAndCheckIfCheck(pieces, pos));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -107,7 +107,7 @@ public class Pawn extends PieceKnownIfMoved {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        } catch (NullPointerException npe) {
 | 
					        } catch (NullPointerException npe) {
 | 
				
			||||||
            // This is an empty spot
 | 
					            // This is an empty spot
 | 
				
			||||||
            tryToMoveAndCheckIfCheck(pieces, movable, pos);
 | 
					            movable.addAll(tryToMoveAndCheckIfCheck(pieces, pos));
 | 
				
			||||||
        } catch (IndexOutOfBoundsException ioobe) {
 | 
					        } catch (IndexOutOfBoundsException ioobe) {
 | 
				
			||||||
            // This means that the player is at the edge
 | 
					            // This means that the player is at the edge
 | 
				
			||||||
            System.out.println(pos);
 | 
					            System.out.println(pos);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -123,7 +123,7 @@ public abstract class Piece {
 | 
				
			|||||||
            if (!isSelected) {
 | 
					            if (!isSelected) {
 | 
				
			||||||
                movable.add(pos);
 | 
					                movable.add(pos);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                tryToMoveAndCheckIfCheck(pieces, movable, pos);
 | 
					                movable.addAll(tryToMoveAndCheckIfCheck(pieces, pos));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            // Fortsätt att gå
 | 
					            // Fortsätt att gå
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
@@ -142,14 +142,15 @@ public abstract class Piece {
 | 
				
			|||||||
            if (!isSelected) {
 | 
					            if (!isSelected) {
 | 
				
			||||||
                movable.add(pos);
 | 
					                movable.add(pos);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                tryToMoveAndCheckIfCheck(pieces, movable, pos);
 | 
					                movable.addAll(tryToMoveAndCheckIfCheck(pieces, pos));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void tryToMoveAndCheckIfCheck(Piece[][] pieces, ArrayList movable, Point pos) {
 | 
					    ArrayList<Point> tryToMoveAndCheckIfCheck(Piece[][] pieces, Point pos) {
 | 
				
			||||||
 | 
					        ArrayList<Point> movable = new ArrayList<>();
 | 
				
			||||||
        // Kom ihåg vart vi var
 | 
					        // Kom ihåg vart vi var
 | 
				
			||||||
        Point previousPosition = new Point(this.position);
 | 
					        Point previousPosition = new Point(this.position);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -171,6 +172,7 @@ public abstract class Piece {
 | 
				
			|||||||
        if (!inSchack) {
 | 
					        if (!inSchack) {
 | 
				
			||||||
            movable.add(pos);
 | 
					            movable.add(pos);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        return movable;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    boolean checkIfSchack(Point pos, Piece[][] pieces) {
 | 
					    boolean checkIfSchack(Point pos, Piece[][] pieces) {
 | 
				
			||||||
@@ -198,7 +200,6 @@ public abstract class Piece {
 | 
				
			|||||||
                attacks.addAll(piece.validAttacks(pieces));
 | 
					                attacks.addAll(piece.validAttacks(pieces));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }*/
 | 
					        }*/
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        // Kollar ifall kungen står i schack just nu
 | 
					        // Kollar ifall kungen står i schack just nu
 | 
				
			||||||
        for (Point attack : attacks) {
 | 
					        for (Point attack : attacks) {
 | 
				
			||||||
            Piece attacked = pieces[attack.x][attack.y];
 | 
					            Piece attacked = pieces[attack.x][attack.y];
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user