diff --git a/.gitignore b/.gitignore index dd4743e..6242efd 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ nbbuild/ dist/ nbdist/ .nb-gradle/ -store \ No newline at end of file +store +target/ diff --git a/Schack.iml b/Schack.iml deleted file mode 100644 index fb8e866..0000000 --- a/Schack.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/build.xml b/build.xml deleted file mode 100644 index a054126..0000000 --- a/build.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project Schack. - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cli_run.bat b/cli_run.bat new file mode 100755 index 0000000..9c3c76a --- /dev/null +++ b/cli_run.bat @@ -0,0 +1,3 @@ +mvn clean package +java -jar target/Schack-1-jar-with-dependencies.jar +pause \ No newline at end of file diff --git a/cli_run.sh b/cli_run.sh new file mode 100755 index 0000000..59072cd --- /dev/null +++ b/cli_run.sh @@ -0,0 +1,2 @@ +mvn clean package +java -jar target/Schack-1-jar-with-dependencies.jar diff --git a/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar b/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar deleted file mode 100644 index 60e8e2b..0000000 Binary files a/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar and /dev/null differ diff --git a/lib/nblibraries.properties b/lib/nblibraries.properties deleted file mode 100644 index b5bd56c..0000000 --- a/lib/nblibraries.properties +++ /dev/null @@ -1,4 +0,0 @@ -libs.CopyLibs.classpath=\ - ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar -libs.CopyLibs.displayName=CopyLibs Task -libs.CopyLibs.prop-version=3.0 diff --git a/manifest.mf b/manifest.mf deleted file mode 100644 index 1574df4..0000000 --- a/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml deleted file mode 100644 index 5a6ba7f..0000000 --- a/nbproject/build-impl.xml +++ /dev/null @@ -1,1796 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties deleted file mode 100644 index 189ef42..0000000 --- a/nbproject/genfiles.properties +++ /dev/null @@ -1,5 +0,0 @@ -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=8c4b7f48 -nbproject/build-impl.xml.script.CRC32=e431c94e -nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/nbproject/project.properties b/nbproject/project.properties deleted file mode 100644 index 9a87474..0000000 --- a/nbproject/project.properties +++ /dev/null @@ -1,115 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=Schack -application.vendor=love & Simon -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.enable-indent=true -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.modulepath=\ - ${run.modulepath} -debug.test.classpath=\ - ${run.test.classpath} -debug.test.modulepath=\ - ${run.test.modulepath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/Schack.jar -dist.javadoc.dir=${dist.dir}/javadoc -includes=** -jar.archive.disabled=${jnlp.enabled} -jar.compress=false -jar.index=${jnlp.enabled} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.external.vm=true -javac.modulepath= -javac.processormodulepath= -javac.processorpath=\ - ${javac.classpath} -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -javac.test.modulepath=\ - ${javac.modulepath} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.html5=false -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -jlink.launcher=false -jlink.launcher.name=Schack -jnlp.codebase.type=no.codebase -jnlp.descriptor=application -jnlp.enabled=false -jnlp.mixed.code=default -jnlp.offline-allowed=false -jnlp.signed=false -jnlp.signing= -jnlp.signing.alias= -jnlp.signing.keystore= -main.class=schack.Schack -# Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found. -manifest.custom.application.library.allowable.codebase= -# Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts. -manifest.custom.caller.allowable.codebase= -# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed -manifest.custom.codebase= -# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) -manifest.custom.permissions= -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs= -run.modulepath=\ - ${javac.modulepath} -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -run.test.modulepath=\ - ${javac.test.modulepath} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml deleted file mode 100644 index 810ba06..0000000 --- a/nbproject/project.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - Schack - - - - - - - - - .\lib\nblibraries.properties - - - diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..9fce285 --- /dev/null +++ b/pom.xml @@ -0,0 +1,119 @@ + + + + 4.0.0 + + com.billenius + Schack + 1 + + Schack + + + + UTF-8 + 1.8 + 1.8 + + + + + Love Billenius + + + Simon Hansson + + + + + + + + + + src/main/java/ + + com/billenius/img/ + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + package + + single + + + + + com.billenius.schack.Schack + + + + jar-with-dependencies + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + com.billenius.schack.Schack + + + + + + + diff --git a/src/img/BlackBishop.png b/src/main/java/com/billenius/img/BlackBishop.png similarity index 100% rename from src/img/BlackBishop.png rename to src/main/java/com/billenius/img/BlackBishop.png diff --git a/src/img/BlackHorse.png b/src/main/java/com/billenius/img/BlackHorse.png similarity index 100% rename from src/img/BlackHorse.png rename to src/main/java/com/billenius/img/BlackHorse.png diff --git a/src/img/BlackKing.png b/src/main/java/com/billenius/img/BlackKing.png similarity index 100% rename from src/img/BlackKing.png rename to src/main/java/com/billenius/img/BlackKing.png diff --git a/src/img/BlackPawn.png b/src/main/java/com/billenius/img/BlackPawn.png similarity index 100% rename from src/img/BlackPawn.png rename to src/main/java/com/billenius/img/BlackPawn.png diff --git a/src/img/BlackQueen.png b/src/main/java/com/billenius/img/BlackQueen.png similarity index 100% rename from src/img/BlackQueen.png rename to src/main/java/com/billenius/img/BlackQueen.png diff --git a/src/img/BlackRook.png b/src/main/java/com/billenius/img/BlackRook.png similarity index 100% rename from src/img/BlackRook.png rename to src/main/java/com/billenius/img/BlackRook.png diff --git a/src/img/WhiteBishop.png b/src/main/java/com/billenius/img/WhiteBishop.png similarity index 100% rename from src/img/WhiteBishop.png rename to src/main/java/com/billenius/img/WhiteBishop.png diff --git a/src/img/WhiteHorse.png b/src/main/java/com/billenius/img/WhiteHorse.png similarity index 100% rename from src/img/WhiteHorse.png rename to src/main/java/com/billenius/img/WhiteHorse.png diff --git a/src/img/WhiteKing.png b/src/main/java/com/billenius/img/WhiteKing.png similarity index 100% rename from src/img/WhiteKing.png rename to src/main/java/com/billenius/img/WhiteKing.png diff --git a/src/img/WhitePawn.png b/src/main/java/com/billenius/img/WhitePawn.png similarity index 100% rename from src/img/WhitePawn.png rename to src/main/java/com/billenius/img/WhitePawn.png diff --git a/src/img/WhiteQueen.png b/src/main/java/com/billenius/img/WhiteQueen.png similarity index 100% rename from src/img/WhiteQueen.png rename to src/main/java/com/billenius/img/WhiteQueen.png diff --git a/src/img/WhiteRook.png b/src/main/java/com/billenius/img/WhiteRook.png similarity index 100% rename from src/img/WhiteRook.png rename to src/main/java/com/billenius/img/WhiteRook.png diff --git a/src/schack/Bishop.java b/src/main/java/com/billenius/schack/Bishop.java similarity index 73% rename from src/schack/Bishop.java rename to src/main/java/com/billenius/schack/Bishop.java index e7357aa..23cebcb 100644 --- a/src/schack/Bishop.java +++ b/src/main/java/com/billenius/schack/Bishop.java @@ -1,4 +1,4 @@ -package schack; +package com.billenius.schack; import java.awt.Point; import java.io.IOException; @@ -13,10 +13,9 @@ public class Bishop extends LongWalkers { @Override public List validMoves(Piece[][] pieces, boolean allowedToRecurse) { return getMoves( - new int[][]{{-1, -1}, {1, 1}, {-1, 1}, {1, -1}}, + new int[][] { { -1, -1 }, { 1, 1 }, { -1, 1 }, { 1, -1 } }, pieces, - allowedToRecurse - ); + allowedToRecurse); } } diff --git a/src/schack/Board.java b/src/main/java/com/billenius/schack/Board.java similarity index 85% rename from src/schack/Board.java rename to src/main/java/com/billenius/schack/Board.java index d4ef234..51a6b3e 100644 --- a/src/schack/Board.java +++ b/src/main/java/com/billenius/schack/Board.java @@ -1,4 +1,4 @@ -package schack; +package com.billenius.schack; import java.awt.Color; import java.awt.Dimension; @@ -41,14 +41,22 @@ public class Board extends JPanel implements MouseListener { private Piece[][] getPieces() throws IOException { Piece[][] piecesRet = { - {new Rook(false, new Point(0, 0)), null, null, null, null, null, null, new Rook(true, new Point(0, 7))}, - {new Horse(false, new Point(1, 0)), null, null, null, null, null, null, new Horse(true, new Point(1, 7))}, - {new Bishop(false, new Point(2, 0)), null, null, null, null, null, null, new Bishop(true, new Point(2, 7))}, - {new Queen(false, new Point(3, 0)), null, null, null, null, null, null, new Queen(true, new Point(3, 7))}, - {new King(false, new Point(4, 0)), null, null, null, null, null, null, new King(true, new Point(4, 7))}, - {new Bishop(false, new Point(5, 0)), null, null, null, null, null, null, new Bishop(true, new Point(5, 7))}, - {new Horse(false, new Point(6, 0)), null, null, null, null, null, null, new Horse(true, new Point(6, 7))}, - {new Rook(false, new Point(7, 0)), null, null, null, null, null, null, new Rook(true, new Point(7, 7))} + { new Rook(false, new Point(0, 0)), null, null, null, null, null, null, + new Rook(true, new Point(0, 7)) }, + { new Horse(false, new Point(1, 0)), null, null, null, null, null, null, + new Horse(true, new Point(1, 7)) }, + { new Bishop(false, new Point(2, 0)), null, null, null, null, null, null, + new Bishop(true, new Point(2, 7)) }, + { new Queen(false, new Point(3, 0)), null, null, null, null, null, null, + new Queen(true, new Point(3, 7)) }, + { new King(false, new Point(4, 0)), null, null, null, null, null, null, + new King(true, new Point(4, 7)) }, + { new Bishop(false, new Point(5, 0)), null, null, null, null, null, null, + new Bishop(true, new Point(5, 7)) }, + { new Horse(false, new Point(6, 0)), null, null, null, null, null, null, + new Horse(true, new Point(6, 7)) }, + { new Rook(false, new Point(7, 0)), null, null, null, null, null, null, + new Rook(true, new Point(7, 7)) } }; // Sätt ut bönder diff --git a/src/schack/Horse.java b/src/main/java/com/billenius/schack/Horse.java similarity index 84% rename from src/schack/Horse.java rename to src/main/java/com/billenius/schack/Horse.java index ba53c6e..87660bf 100644 --- a/src/schack/Horse.java +++ b/src/main/java/com/billenius/schack/Horse.java @@ -1,4 +1,4 @@ -package schack; +package com.billenius.schack; import java.awt.Point; import java.io.IOException; @@ -15,8 +15,8 @@ public class Horse extends Piece { public List validMoves(Piece[][] pieces, boolean allowedToRecurse) { List movable = new ArrayList<>(); - for (int dx : new int[]{-2, -1, 1, 2}) { - for (int direction : new int[]{-1, 1}) { + for (int dx : new int[] { -2, -1, 1, 2 }) { + for (int direction : new int[] { -1, 1 }) { int stepLength = (3 - Math.abs(dx)), dy = direction * stepLength; Point potentialMove = new Point(this.position.x + dx, this.position.y + dy); diff --git a/src/schack/King.java b/src/main/java/com/billenius/schack/King.java similarity index 92% rename from src/schack/King.java rename to src/main/java/com/billenius/schack/King.java index 988fd1d..599adff 100644 --- a/src/schack/King.java +++ b/src/main/java/com/billenius/schack/King.java @@ -1,4 +1,4 @@ -package schack; +package com.billenius.schack; import java.awt.Point; import java.io.IOException; @@ -26,7 +26,7 @@ public final class King extends Piece { boolean[] somethingBetweenOrSchackOnTheWay = new boolean[2]; // Vänster, höger int leftModifier = -1, rightModifier = 1; - for (int modifier : new int[]{leftModifier, rightModifier}) { + for (int modifier : new int[] { leftModifier, rightModifier }) { for (int loopX = this.position.x + modifier; loopX > 0 && loopX < 7; loopX += modifier) { if (pieces[loopX][this.position.y] != null || isInSchack(pieces, new Point(loopX, this.position.y))) { somethingBetweenOrSchackOnTheWay[(modifier == leftModifier) ? 0 : 1] = true; @@ -36,7 +36,7 @@ public final class King extends Piece { } leftModifier = 0; rightModifier = 1; - for (int direction : new int[]{leftModifier, rightModifier}) { + for (int direction : new int[] { leftModifier, rightModifier }) { if (!somethingBetweenOrSchackOnTheWay[direction]) { Piece possibleRook = pieces[direction == leftModifier ? 0 : 7][this.position.y]; if (possibleRook != null && !possibleRook.isMoved()) { @@ -87,7 +87,8 @@ public final class King extends Piece { if (loopY == 0 && loopX == 0) { continue; } - addMovesIfCan(new Point(this.position.x + loopX, this.position.y + loopY), movable, pieces, allowedToRecurse); + addMovesIfCan(new Point(this.position.x + loopX, this.position.y + loopY), movable, pieces, + allowedToRecurse); } } diff --git a/src/schack/LongWalkers.java b/src/main/java/com/billenius/schack/LongWalkers.java similarity index 78% rename from src/schack/LongWalkers.java rename to src/main/java/com/billenius/schack/LongWalkers.java index d025af4..c6cef8b 100644 --- a/src/schack/LongWalkers.java +++ b/src/main/java/com/billenius/schack/LongWalkers.java @@ -1,4 +1,4 @@ -package schack; +package com.billenius.schack; import java.awt.Point; import java.io.IOException; @@ -14,9 +14,15 @@ public abstract class LongWalkers extends Piece { /** * Generell metod för att generera möjliga drag för LongWalkers * - * @param directions vilka håll. Exempel:
-     * {@code new int[][]{{1, 0}, {-1, 0}, {0, 1}, {0, -1}}}
för att gå - * som ett torn + * @param directions vilka håll. Exempel: + * + *
+     * {@code
+     * new int[][] { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } }
+     * }
+ * + * för att gå + * som ett torn * * @param pieces * @param allowedToRecurse diff --git a/src/schack/Pawn.java b/src/main/java/com/billenius/schack/Pawn.java similarity index 93% rename from src/schack/Pawn.java rename to src/main/java/com/billenius/schack/Pawn.java index 4eece1d..7d9286d 100644 --- a/src/schack/Pawn.java +++ b/src/main/java/com/billenius/schack/Pawn.java @@ -1,4 +1,4 @@ -package schack; +package com.billenius.schack; import java.awt.HeadlessException; import java.awt.Point; @@ -18,7 +18,8 @@ public class Pawn extends Piece { * * @param pieces * @param shouldNotCareIfAttackSpaceIsEmptyOrNot Ifall man ska kolla ifall - * det är något i möjliga attackrutor ifall + * det är något i möjliga + * attackrutor ifall * @return Alla lämpliga attackMoves */ @Override @@ -26,7 +27,7 @@ public class Pawn extends Piece { List movable = new ArrayList<>(); // Kolla ifall vi kan ta någon - for (int pawnX : new int[]{-1, 1}) { + for (int pawnX : new int[] { -1, 1 }) { // Position vi kollar just nu, snett upp åt höger & vänster Point pos = new Point(this.position.x + pawnX, this.position.y + (this.isWhite() ? -1 : 1)); if (pos.x < 0 || pos.x > 7 || pos.y < 0 || pos.y > 7) { @@ -59,7 +60,7 @@ public class Pawn extends Piece { } // Kolla ifall vi kan ta någon - for (int pawnX : new int[]{-1, 1}) { + for (int pawnX : new int[] { -1, 1 }) { // Position vi kollar just nu, snett upp åt höger & vänster final Point pos = new Point(this.position.x + pawnX, this.position.y + (this.isWhite() ? -1 : 1)); movable.addAll(addAttackMovesIfCan(pos, pieces)); @@ -121,7 +122,7 @@ public class Pawn extends Piece { } private void transform(Piece[][] pieces) throws HeadlessException { - String[] transformations = {"Queen", "Rook", "Bishop", "Horse"}; + String[] transformations = { "Queen", "Rook", "Bishop", "Horse" }; int choosenTransformations = JOptionPane.showOptionDialog(null, "What do you want to the pawn to transform into?", "Pawn about to transform", @@ -129,8 +130,7 @@ public class Pawn extends Piece { JOptionPane.INFORMATION_MESSAGE, null, transformations, - transformations[0] - ); + transformations[0]); try { switch (choosenTransformations) { case 0: diff --git a/src/schack/Piece.java b/src/main/java/com/billenius/schack/Piece.java similarity index 90% rename from src/schack/Piece.java rename to src/main/java/com/billenius/schack/Piece.java index 15e853a..a7fe100 100644 --- a/src/schack/Piece.java +++ b/src/main/java/com/billenius/schack/Piece.java @@ -1,4 +1,4 @@ -package schack; +package com.billenius.schack; import java.awt.Graphics2D; import java.awt.Point; @@ -54,7 +54,7 @@ public abstract class Piece { String className = this.getClass().getSimpleName(); String colorName = this.isWhite() ? "White" : "Black"; String fileName = colorName + className + ".png"; - InputStream is = getClass().getResourceAsStream("/img/" + fileName); + InputStream is = getClass().getResourceAsStream("/com/billenius/img/" + fileName); icon = ImageIO.read(is); } @@ -72,7 +72,8 @@ public abstract class Piece { * * @param pieces * @param shouldNotCareIfAttackSpaceIsEmptyOrNot För bönder ifall den ska - * kolla ifall det är något i möjliga attackrutor ifall + * kolla ifall det är något i + * möjliga attackrutor ifall * @return Alla lämpliga attackMoves */ public List validAttacks(Piece[][] pieces, boolean shouldNotCareIfAttackSpaceIsEmptyOrNot) { @@ -89,8 +90,7 @@ public abstract class Piece { icon, position.x * Board.SIZE_OF_TILE, position.y * Board.SIZE_OF_TILE, - null - ); + null); } /** @@ -114,11 +114,12 @@ public abstract class Piece { /** * Lägg till move ifall det går, alltså inte är schack där * - * @param pos Drag att lägga till ifall det går - * @param movable Lägger till drag i denna ArrayList - * @param pieces Piece[][] över brädet + * @param pos Drag att lägga till ifall det går + * @param movable Lägger till drag i denna ArrayList + * @param pieces Piece[][] över brädet * @param allowedToRecurse Behövs för att inte gå in i en evig loop där - *
{@code addMovesIfCan -> isInSchack -> validMoves -> getCastlingIfPossible(King) -> isInSchack}
+ * + *
{@code addMovesIfCan -> isInSchack -> validMoves -> getCastlingIfPossible(King) -> isInSchack}
* * @return true ifall man inte kan gå längre i denna riktning */ @@ -155,7 +156,7 @@ public abstract class Piece { * Kolla ifall det är schack vid den här positionen * * @param pieces Piece[][] över hela brädet - * @param pos Kollar ifall det är schack om denna Piece flyttar hit + * @param pos Kollar ifall det är schack om denna Piece flyttar hit * @return true ifall det är schack */ protected boolean isInSchack(Piece[][] pieces, Point pos) { diff --git a/src/schack/Queen.java b/src/main/java/com/billenius/schack/Queen.java similarity index 67% rename from src/schack/Queen.java rename to src/main/java/com/billenius/schack/Queen.java index d4138b7..1260206 100644 --- a/src/schack/Queen.java +++ b/src/main/java/com/billenius/schack/Queen.java @@ -1,4 +1,4 @@ -package schack; +package com.billenius.schack; import java.awt.Point; import java.io.IOException; @@ -13,9 +13,8 @@ public class Queen extends LongWalkers { @Override public List validMoves(Piece[][] pieces, boolean allowedToRecurse) { return getMoves( - new int[][]{{1, 0}, {-1, 0}, {0, 1}, {-1, -1}, {0, -1}, {1, 1}, {-1, 1}, {1, -1}}, + new int[][] { { 1, 0 }, { -1, 0 }, { 0, 1 }, { -1, -1 }, { 0, -1 }, { 1, 1 }, { -1, 1 }, { 1, -1 } }, pieces, - allowedToRecurse - ); + allowedToRecurse); } } diff --git a/src/schack/Rook.java b/src/main/java/com/billenius/schack/Rook.java similarity index 74% rename from src/schack/Rook.java rename to src/main/java/com/billenius/schack/Rook.java index f08503b..26bb479 100644 --- a/src/schack/Rook.java +++ b/src/main/java/com/billenius/schack/Rook.java @@ -1,4 +1,4 @@ -package schack; +package com.billenius.schack; import java.awt.Point; import java.io.IOException; @@ -13,10 +13,9 @@ public class Rook extends LongWalkers { @Override public List validMoves(Piece[][] pieces, boolean allowedToRecurse) { return getMoves( - new int[][]{{1, 0}, {-1, 0}, {0, 1}, {0, -1}}, + new int[][] { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } }, pieces, - allowedToRecurse - ); + allowedToRecurse); } } diff --git a/src/schack/Schack.java b/src/main/java/com/billenius/schack/Schack.java similarity index 91% rename from src/schack/Schack.java rename to src/main/java/com/billenius/schack/Schack.java index 0ef6fb0..dc6bee2 100644 --- a/src/schack/Schack.java +++ b/src/main/java/com/billenius/schack/Schack.java @@ -1,4 +1,4 @@ -package schack; +package com.billenius.schack; import java.awt.HeadlessException; import java.awt.event.ActionEvent; @@ -33,12 +33,12 @@ public class Schack { frame.setAlwaysOnTop(false); frame.setResizable(false); - // Might throw an IOException if the icon of the Pieces isn't embedded correctly + // Might throw an IOException if the icon of the Pieces isn't embedded correctly final Board board = new Board(); frame.setContentPane(board); frame.getContentPane().addMouseListener(board); - // Create menu + // Create menu final JMenuBar menuBar = new JMenuBar(); final JMenu gameMenu = new JMenu("Game"); final JMenu connectMenu = new JMenu("Connect"); @@ -81,9 +81,8 @@ public class Schack { }); connectToOpponent.addActionListener((ActionEvent ae) -> { String opponentIP = JOptionPane.showInputDialog(null, "What's your opponents IP?"); - System.out.println("opponents ip: "+opponentIP); - - + System.out.println("opponents ip: " + opponentIP); + }); // Add the menu stuff diff --git a/src/schack/SchackState.java b/src/main/java/com/billenius/schack/SchackState.java similarity index 76% rename from src/schack/SchackState.java rename to src/main/java/com/billenius/schack/SchackState.java index f6d0266..686ab20 100644 --- a/src/schack/SchackState.java +++ b/src/main/java/com/billenius/schack/SchackState.java @@ -1,4 +1,4 @@ -package schack; +package com.billenius.schack; /** *