From 456ea5356f0b8e71ec4dee95433493ecf36af2e3 Mon Sep 17 00:00:00 2001 From: Andrin Fassbind Date: Fri, 26 Nov 2021 10:43:04 +0100 Subject: [PATCH] Settlement.java and changes SiedlerGame buildRoad Method --- src/ch/zhaw/catan/Road.java | 6 +++++- src/ch/zhaw/catan/Settlement.java | 20 ++++++++++++++++++++ src/ch/zhaw/catan/SiedlerGame.java | 13 ++++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/ch/zhaw/catan/Settlement.java diff --git a/src/ch/zhaw/catan/Road.java b/src/ch/zhaw/catan/Road.java index 24025c5..92ac502 100644 --- a/src/ch/zhaw/catan/Road.java +++ b/src/ch/zhaw/catan/Road.java @@ -3,11 +3,15 @@ package ch.zhaw.catan; import java.util.HashMap; public class Road { - HashMap buildCost; + private HashMap buildCost; public Road() { buildCost = new HashMap<>(); buildCost.put(Config.Resource.BRICK,1); buildCost.put(Config.Resource.LUMBER,1); } + + public HashMap getBuildCost() { + return buildCost; + } } diff --git a/src/ch/zhaw/catan/Settlement.java b/src/ch/zhaw/catan/Settlement.java new file mode 100644 index 0000000..289e9e8 --- /dev/null +++ b/src/ch/zhaw/catan/Settlement.java @@ -0,0 +1,20 @@ +package ch.zhaw.catan; + +import java.util.HashMap; + +public class Settlement { + private HashMap buildCost; + + public Settlement() { + buildCost = new HashMap<>(); + buildCost.put(Config.Resource.LUMBER,1); + buildCost.put(Config.Resource.BRICK,1); + buildCost.put(Config.Resource.GRAIN,1); + buildCost.put(Config.Resource.WOOL,1); + } + + public HashMap getBuildCost() { + return buildCost; + } + +} diff --git a/src/ch/zhaw/catan/SiedlerGame.java b/src/ch/zhaw/catan/SiedlerGame.java index 48405eb..695b23a 100644 --- a/src/ch/zhaw/catan/SiedlerGame.java +++ b/src/ch/zhaw/catan/SiedlerGame.java @@ -212,7 +212,18 @@ public class SiedlerGame { * @return true, if the placement was successful */ public boolean buildRoad(Point roadStart, Point roadEnd) { - // TODO: Implement + //1. Check if Edge + if(!board.hasEdge(roadStart,roadEnd)){ + // TODO: Error message + } + //2. Check if Edge is empty + if(board.getEdge(roadStart,roadEnd) != null) { + // TODO: Error message + } + //3. Can Player build road + // TODO + + return false; }