getLandsForCorner method created.
This commit is contained in:
		
							parent
							
								
									8b61927eae
								
							
						
					
					
						commit
						fcf8c842fb
					
				| 
						 | 
				
			
			@ -94,7 +94,22 @@ public class SiedlerBoard extends HexBoard<Land, String, String, String> {
 | 
			
		|||
     * @return the list with the adjacent {@link Land}s
 | 
			
		||||
     */
 | 
			
		||||
    public List<Land> getLandsForCorner(Point corner) {
 | 
			
		||||
        //TODO: Implement.
 | 
			
		||||
        return Collections.emptyList();
 | 
			
		||||
        Point above = new Point(corner.x, corner.y + 2);
 | 
			
		||||
        Point below = new Point(corner.x, corner.y -2);
 | 
			
		||||
        Land[] lands = new Land[3];
 | 
			
		||||
        if (hasField(above)) {
 | 
			
		||||
            lands[0] = getField(above);
 | 
			
		||||
            lands[1] = getField(new Point(corner.x + 1, corner.y - 1));
 | 
			
		||||
            lands[2] = getField(new Point(corner.x - 1, corner.y - 1));
 | 
			
		||||
        }
 | 
			
		||||
        else if (hasField(below)) {
 | 
			
		||||
            lands[0] = getField(below);
 | 
			
		||||
            lands[1] = getField(new Point(corner.x + 1, corner.y + 1));
 | 
			
		||||
            lands[2] = getField(new Point(corner.x - 1, corner.y + 1));
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            return Collections.emptyList();
 | 
			
		||||
        }
 | 
			
		||||
        return Collections.unmodifiableList(Arrays.asList(lands));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue