New methods in SiedlerBoard created

This commit is contained in:
Leonardo Brandenberger 2021-11-24 16:18:49 +01:00
parent e4a56b73c9
commit e6b2882591
24 changed files with 125 additions and 0 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

10
.idea/libraries/lib.xml Normal file
View File

@ -0,0 +1,10 @@
<component name="libraryTable">
<library name="lib">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/slf4j-api-2.0.0-alpha1.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/text-io-3.4.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

6
.idea/misc.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="corretto-11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/gruppe06-hufflepuff-projekt3-catan.iml" filepath="$PROJECT_DIR$/gruppe06-hufflepuff-projekt3-catan.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
<orderEntry type="module-library" scope="TEST">
<library name="JUnit5.7.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.7.0/junit-jupiter-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.7.0/junit-jupiter-api-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.7.0/junit-platform-commons-1.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.7.0/junit-jupiter-params-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.7.0/junit-jupiter-engine-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.7.0/junit-platform-engine-1.7.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>

View File

@ -2,13 +2,61 @@ package ch.zhaw.catan;
import ch.zhaw.catan.Config.Land;
import ch.zhaw.hexboard.HexBoard;
import ch.zhaw.hexboard.Label;
import java.awt.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class SiedlerBoard extends HexBoard<Land, String, String, String> {
Map<Point, ch.zhaw.hexboard.Label> lowerFieldLabel = new HashMap<>();
public void createFixGamefield(){
Integer[][] waterCoordinates = {{4,2},{6,2},{8,2},{10,2},{3,5},{11,5},{2,8},{12,8},{1,11},
{13,11},{2,14},{12,14},{3,17},{11,17},{4,20},{6,20},{8,20},{10,20}};
Integer[][] desertCoordinates = {{7,11}};
Integer[][] forestCoordinates = {{5,5,6},{10,8,10},{3,11,5},{8,14,3}};
Integer[][] hillCoordinates = {{5,11,9},{5,17,8},{9,17,11}};
Integer[][] fieldCoordinates = {{4,8,2},{8,8,5},{11,11,9},{4,14,10}};
Integer[][] pastureCoordinates = {{7,5,3},{9,5,8},{10,14,12},{7,17,4}};
Integer[][] mountainCoordinates = {{6,8,4},{9,11,6},{6,14,11}};
placeFieldWithoutLabel(Land.WATER, waterCoordinates);
placeFieldWithoutLabel(Land.DESERT, desertCoordinates);
placeFieldWithLabel(Land.FOREST, forestCoordinates);
placeFieldWithLabel(Land.HILLS, hillCoordinates);
placeFieldWithLabel(Land.FIELDS, fieldCoordinates);
placeFieldWithLabel(Land.PASTURE, pastureCoordinates);
placeFieldWithLabel(Land.MOUNTAIN, mountainCoordinates);
}
private void placeFieldWithoutLabel(Land fieldType, Integer[][] fieldCoordinates) {
for(Integer[] coordinates : fieldCoordinates) {
addField(new Point(coordinates[0], coordinates[1]), fieldType);
}
}
private void placeFieldWithLabel(Land fieldType, Integer[][] fieldInformation) {
for(Integer[] information : fieldInformation) {
addField(new Point(information[0], information[1]), fieldType);
char[] label = information[2].toString().toCharArray();
if (label.length == 1) {
lowerFieldLabel.put(new Point(information[0], information[1]), new ch.zhaw.hexboard.Label('0', label[0]));
} else {
lowerFieldLabel.put(new Point(information[0], information[1]), new Label(label[0], label[1]));
}
}
}
//TODO: Add fields, constructors and methods as you see fit. Do NOT change the signature
// of the methods below.