New Class Road

Start to edit SiedlerGame.buildRoad
This commit is contained in:
Andrin Fassbind 2021-11-25 17:26:18 +01:00
parent 8b61927eae
commit 79cc4f3f3c
5 changed files with 32 additions and 2 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/out/

2
.idea/.gitignore vendored
View File

@ -5,4 +5,4 @@
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
/httpRequests/

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -0,0 +1,22 @@
package ch.zhaw.catan;
import java.util.HashMap;
/**
* This Class represents a Road Object. It informs about the ressources needed to build a road
*/
public class Road {
final private HashMap<Config.Resource, Integer> buildCost;
public Road() {
buildCost = new HashMap<>();
buildCost.put(Config.Resource.LUMBER, 1);
buildCost.put(Config.Resource.BRICK, 1);
}
public HashMap<Config.Resource, Integer> getBuildCost() {
return buildCost;
}
}

View File

@ -213,6 +213,13 @@ public class SiedlerGame {
*/
public boolean buildRoad(Point roadStart, Point roadEnd) {
// TODO: Implement
// 0.Is Edge 1. Check if Edge is empty 2. Check if One neighbors Corner is own settlement 3. Set road
boolean validTask = true;
while (validTask) {
validTask = board.hasEdge(roadStart,roadEnd);
validTask = board.getEdge(roadStart,roadEnd) == null;
}
return false;
}