From 2dfe55584ec7bc2eb1987de30a99f81a0bdddb7d Mon Sep 17 00:00:00 2001 From: Speedy Gonzalez Date: Fri, 3 Dec 2021 11:28:42 +0100 Subject: [PATCH] Added placeInitialRoad and placeInitialSettlement methods. --- src/ch/zhaw/catan/SiedlerGame.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ch/zhaw/catan/SiedlerGame.java b/src/ch/zhaw/catan/SiedlerGame.java index af4d862..d926afb 100644 --- a/src/ch/zhaw/catan/SiedlerGame.java +++ b/src/ch/zhaw/catan/SiedlerGame.java @@ -148,6 +148,14 @@ public class SiedlerGame { */ public boolean placeInitialSettlement(Point position, boolean payout) { // TODO: Implement + if(!validPositionForSettlement(position)){ + return false; + } + board.setCorner(position, new Settlement(allPlayers.get(activePlayer).getFaction())); + List lands = board.getLandsForCorner(position); + for (Config.Land land:lands){ + allPlayers.get(activePlayer).addResource(land.getResource(), 1); + } return true; } @@ -161,6 +169,10 @@ public class SiedlerGame { */ public boolean placeInitialRoad(Point roadStart, Point roadEnd) { // TODO: Implement + if (!validPositionForRoad(roadStart, roadEnd)){ + return false; + } + board.setEdge(roadStart, roadEnd, new Road(allPlayers.get(activePlayer).getFaction())); return true; }