mirror of
				https://github.com/lov3b/Schack.git
				synced 2025-10-31 13:20:21 +01:00 
			
		
		
		
	Uppdaterade kommentarer igen
This commit is contained in:
		| @@ -62,19 +62,18 @@ public abstract class Piece extends Component { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected boolean checkMove(Point pos, LinkedHashSet movable, Piece[][] pieces) { |     protected boolean checkMove(Point pos, LinkedHashSet movable, Piece[][] pieces) { | ||||||
|  |  | ||||||
|         // Instead of checking index and null, try-catch |         // Instead of checking index and null, try-catch | ||||||
|         try { |         try { | ||||||
|             // Ifall vi kollar utanför brädet kommer detta att faila |             // Ifall vi kollar utanför brädet kommer detta att faila | ||||||
|             Piece p = pieces[pos.x][pos.y]; |             Piece p = pieces[pos.x][pos.y]; | ||||||
|  |  | ||||||
|             // Ifall pjäsen här har samma färg som oss, skip |             // Ifall pjäsen här har samma färg som oss, break | ||||||
|             // Ifall det inte är någon pjäs här kommer det att gå ner till |             // Ifall det inte är någon pjäs här kommer det att gå ner till | ||||||
|             // catch(NullPointerException) och då lägger vi till detta drag i listan |             // catch(NullPointerException) och då lägger vi till detta drag i listan | ||||||
|             if (p.isWhite == this.isWhite) { |             if (p.isWhite == this.isWhite) { | ||||||
|                 return true; |                 return true; | ||||||
|             } else { |             } else { | ||||||
|                 // Detta betyder att vi har en med motsatts plats här |                 // Detta betyder att det är en med motsatts pjäs här | ||||||
|                 // Vi kan ta men inte gå längre. |                 // Vi kan ta men inte gå längre. | ||||||
|                 movable.add(pos); |                 movable.add(pos); | ||||||
|                 return true; |                 return true; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 lov3b
					lov3b