From fcf8c842fbf0ee239e896ce1879a3a9f66dd7a2a Mon Sep 17 00:00:00 2001 From: Leonardo Brandenberger Date: Fri, 26 Nov 2021 11:41:06 +0100 Subject: [PATCH 1/2] getLandsForCorner method created. --- src/ch/zhaw/catan/SiedlerBoard.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/ch/zhaw/catan/SiedlerBoard.java b/src/ch/zhaw/catan/SiedlerBoard.java index b073e13..cb52d1e 100644 --- a/src/ch/zhaw/catan/SiedlerBoard.java +++ b/src/ch/zhaw/catan/SiedlerBoard.java @@ -94,7 +94,22 @@ public class SiedlerBoard extends HexBoard { * @return the list with the adjacent {@link Land}s */ public List 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)); } } From 98316bb566e9c4616b677216bd94e4668d6d47b9 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Fri, 26 Nov 2021 11:44:22 +0100 Subject: [PATCH 2/2] changed Datatype of Road and Settlement in SiedlerBoardTextView --- .idea/misc.xml | 2 +- src/ch/zhaw/catan/SiedlerBoardTextView.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index b573818..c3dfb30 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/ch/zhaw/catan/SiedlerBoardTextView.java b/src/ch/zhaw/catan/SiedlerBoardTextView.java index 68836b1..11a4ed5 100644 --- a/src/ch/zhaw/catan/SiedlerBoardTextView.java +++ b/src/ch/zhaw/catan/SiedlerBoardTextView.java @@ -6,7 +6,7 @@ import ch.zhaw.hexboard.Label; import java.awt.*; -public class SiedlerBoardTextView extends HexBoardTextView { +public class SiedlerBoardTextView extends HexBoardTextView { public SiedlerBoardTextView(SiedlerBoard board) { super(board);