mirror of
				https://github.com/lov3b/Schack.git
				synced 2025-11-04 07:00:21 +01:00 
			
		
		
		
	minskat if-satser
This commit is contained in:
		@@ -65,8 +65,8 @@ public abstract class Piece {
 | 
				
			|||||||
     * Ger tillbaks alla ställen pjäsen kan attackera
 | 
					     * Ger tillbaks alla ställen pjäsen kan attackera
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param pieces
 | 
					     * @param pieces
 | 
				
			||||||
     * @param shouldNotCareIfAttackSpaceIsEmptyOrNot För bönder ifall den ska kolla ifall det är något i möjliga attackrutor
 | 
					     * @param shouldNotCareIfAttackSpaceIsEmptyOrNot För bönder ifall den ska
 | 
				
			||||||
     * ifall
 | 
					     * kolla ifall det är något i möjliga attackrutor ifall
 | 
				
			||||||
     * @return Alla lämpliga attackMoves
 | 
					     * @return Alla lämpliga attackMoves
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public ArrayList<Point> validAttacks(Piece[][] pieces, boolean shouldNotCareIfAttackSpaceIsEmptyOrNot) {
 | 
					    public ArrayList<Point> validAttacks(Piece[][] pieces, boolean shouldNotCareIfAttackSpaceIsEmptyOrNot) {
 | 
				
			||||||
@@ -123,14 +123,9 @@ public abstract class Piece {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Detta är en tom plats
 | 
					        // Detta är en tom plats
 | 
				
			||||||
        if (pieceToCheck == null) {
 | 
					        if (pieceToCheck == null) {
 | 
				
			||||||
            if (!isSelected) {
 | 
					            if (!isSelected || !isInSchack(pieces, pos)) {
 | 
				
			||||||
                movable.add(pos);
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                if (!isInSchack(pieces, pos)) {
 | 
					 | 
				
			||||||
                movable.add(pos);
 | 
					                movable.add(pos);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            // Fortsätt att gå
 | 
					 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -139,18 +134,9 @@ public abstract class Piece {
 | 
				
			|||||||
         * längre Ifall det är samma färg som oss betyder det att vi inte kan
 | 
					         * längre Ifall det är samma färg som oss betyder det att vi inte kan
 | 
				
			||||||
         * lägga till den
 | 
					         * lägga till den
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        if (pieceToCheck.isWhite() != this.isWhite()) {
 | 
					        if ((pieceToCheck.isWhite() != this.isWhite())
 | 
				
			||||||
            /**
 | 
					                && ((isSelected && !isInSchack(pieces, pos)) || !isSelected)) {
 | 
				
			||||||
             * Detta betyder att det är en motsatts pjäs här, vi kan ta men inte
 | 
					 | 
				
			||||||
             * gå längre
 | 
					 | 
				
			||||||
             */
 | 
					 | 
				
			||||||
            if (!isSelected) {
 | 
					 | 
				
			||||||
            movable.add(pos);
 | 
					            movable.add(pos);
 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                if (!isInSchack(pieces, pos)) {
 | 
					 | 
				
			||||||
                    movable.add(pos);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user