--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Copyright (c) 2018. Developed by Hedgecode.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hedgecode.chess</groupId>
+ <artifactId>chesshog</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>chesshog-format</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>Hedgecode ChessHog Format</name>
+ <description>
+ Hedgecode ChessHog Format Module.
+ </description>
+
+ <properties>
+ <chessHogVersion>0.1-SNAPSHOT</chessHogVersion>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.hedgecode.chess</groupId>
+ <artifactId>chesshog</artifactId>
+ <version>${chessHogVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hedgecode.chess</groupId>
+ <artifactId>chesshog-core</artifactId>
+ <version>${chessHogVersion}</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
/*
- * Copyright (c) 2018. Developed by Hedgecode.
+ * Copyright (c) 2018-2019. Developed by Hedgecode.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
} else {
boolean isKing = false, isQueen = false;
switch (color) {
- case WHITE:
+ case Color.WHITE:
isKing = (castles.indexOf(WHITE_KING) >= 0);
isQueen = (castles.indexOf(WHITE_QUEEN) >= 0);
break;
- case BLACK:
+ case Color.BLACK:
isKing = (castles.indexOf(BLACK_KING) >= 0);
isQueen = (castles.indexOf(BLACK_QUEEN) >= 0);
break;
public static String getCastle(Castle whiteCastle, Castle blackCastle) {
StringBuilder sb = new StringBuilder();
switch (whiteCastle) {
- case KING:
+ case Castle.KING:
sb.append(WHITE_KING);
break;
- case QUEEN:
+ case Castle.QUEEN:
sb.append(WHITE_QUEEN);
break;
- case BOTH:
+ case Castle.BOTH:
sb.append(WHITE_KING).append(WHITE_QUEEN);
break;
}
switch (blackCastle) {
- case KING:
+ case Castle.KING:
sb.append(BLACK_KING);
break;
- case QUEEN:
+ case Castle.QUEEN:
sb.append(BLACK_QUEEN);
break;
- case BOTH:
+ case Castle.BOTH:
sb.append(BLACK_KING).append(BLACK_QUEEN);
break;
}
private ImageConstants() {
throw new AssertionError(
- "No org.hedgecode.chess.img.ImageConstants instances!"
+ "No ImageConstants instances!"
);
}
/*
- * Copyright (c) 2018. Developed by Hedgecode.
+ * Copyright (c) 2018-2019. Developed by Hedgecode.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
byte[] pieces = new byte[2 * (squarePieces.size() + 1)];
int i = 0;
switch (piece) {
- case PAWN:
+ case Piece.PAWN:
pieces[i++] = TCD.PAWN;
break;
- case KNIGHT:
+ case Piece.KNIGHT:
pieces[i++] = TCD.KNIGHT;
break;
- case BISHOP:
+ case Piece.BISHOP:
pieces[i++] = TCD.BISHOP;
break;
- case ROOK:
+ case Piece.ROOK:
pieces[i++] = TCD.ROOK;
break;
- case QUEEN:
+ case Piece.QUEEN:
pieces[i++] = TCD.QUEEN;
break;
- case KING:
+ case Piece.KING:
pieces[i++] = TCD.KING;
break;
}
if (castle != null) {
byte castleByte;
switch (castle) {
- case KING:
+ case Castle.KING:
castleByte = TCD.CASTLE_KING;
break;
- case QUEEN:
+ case Castle.QUEEN:
castleByte = TCD.CASTLE_QUEEN;
break;
- case BOTH:
+ case Castle.BOTH:
castleByte = TCD.CASTLE_BOTH;
break;
default:
/*
- * Copyright (c) 2018. Developed by Hedgecode.
+ * Copyright (c) 2018-2019. Developed by Hedgecode.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.configuration.XMLConfiguration;
+import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Test
public void testBuild() throws Exception {
Builder asciiBuilder = ASCIIBuilder.getInstance();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
setPositionName(
String.format(
- MSG_ASCII_POSITION, testConfig.getString(NAME)
+ MSG_ASCII_POSITION, testConfig.getString(AbstractPositionTest.NAME)
)
);
String ascii = testConfig.getString(ASCII_TAG);
Position position = assignPosition(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
);
if (testConfig.containsKey(ASCII_TYPE)) {
ASCII.setType(
@Override
protected void assertStringEquals(String expected, String actual) {
- assertNotNull(expected);
- assertNotNull(actual);
+ Assert.assertNotNull(expected);
+ Assert.assertNotNull(actual);
String[] expectedLines = expected.split(LINE_REGEX);
String[] actualLines = actual.split(LINE_REGEX);
- assertEquals(
+ Assert.assertEquals(
expectedLines.length,
actualLines.length
);
@Override
public List<XMLConfiguration> getXMLPositions() throws Exception {
List<XMLConfiguration> xmlPositions = new LinkedList<>();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
xmlPositions.add(
new XMLConfiguration(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
)
);
}
/*
- * Copyright (c) 2018. Developed by Hedgecode.
+ * Copyright (c) 2018-2019. Developed by Hedgecode.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@Test
public void testParse() throws Exception {
Parser asciiParser = ASCIIParser.getInstance();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
setPositionName(
String.format(
- MSG_ASCII_POSITION, testConfig.getString(NAME)
+ MSG_ASCII_POSITION, testConfig.getString(AbstractPositionTest.NAME)
)
);
String ascii = testConfig.getString(ASCII_TAG);
Position position = assignPosition(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
);
assertDiagramEquals(
position,
@Override
public List<XMLConfiguration> getXMLPositions() throws Exception {
List<XMLConfiguration> xmlPositions = new LinkedList<>();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
xmlPositions.add(
new XMLConfiguration(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
)
);
}
/*
- * Copyright (c) 2018. Developed by Hedgecode.
+ * Copyright (c) 2018-2019. Developed by Hedgecode.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@Test
public void testBuild() throws Exception {
Builder fenBuilder = FENBuilder.getInstance();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
setPositionName(
String.format(
- MSG_FEN_POSITION, testConfig.getString(NAME)
+ MSG_FEN_POSITION, testConfig.getString(AbstractPositionTest.NAME)
)
);
String fen = testConfig.getString(FEN_TAG);
Position position = assignPosition(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
);
assertStringEquals(
fen,
@Override
public List<XMLConfiguration> getXMLPositions() throws Exception {
List<XMLConfiguration> xmlPositions = new LinkedList<>();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
xmlPositions.add(
new XMLConfiguration(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
)
);
}
/*
- * Copyright (c) 2018. Developed by Hedgecode.
+ * Copyright (c) 2018-2019. Developed by Hedgecode.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@Test
public void testParse() throws Exception {
Parser fenParser = FENParser.getInstance();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
setPositionName(
String.format(
- MSG_FEN_POSITION, testConfig.getString(NAME)
+ MSG_FEN_POSITION, testConfig.getString(AbstractPositionTest.NAME)
)
);
String fen = testConfig.getString(FEN_TAG);
Position position = assignPosition(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
);
assertPositionEquals(
position,
@Override
public List<XMLConfiguration> getXMLPositions() throws Exception {
List<XMLConfiguration> xmlPositions = new LinkedList<>();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
xmlPositions.add(
new XMLConfiguration(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
)
);
}
/*
- * Copyright (c) 2018. Developed by Hedgecode.
+ * Copyright (c) 2018-2019. Developed by Hedgecode.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@Test
public void testBuild() throws Exception {
Builder tcdBuilder = TCDBuilder.getInstance();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
setPositionName(
String.format(
- MSG_TCD_POSITION, testConfig.getString(NAME)
+ MSG_TCD_POSITION, testConfig.getString(AbstractPositionTest.NAME)
)
);
String tcd = testConfig.getString(TCD_TAG);
Position position = assignPosition(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
);
assertStringEquals(
tcd,
@Override
public List<XMLConfiguration> getXMLPositions() throws Exception {
List<XMLConfiguration> xmlPositions = new LinkedList<>();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
xmlPositions.add(
new XMLConfiguration(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
)
);
}
/*
- * Copyright (c) 2018. Developed by Hedgecode.
+ * Copyright (c) 2018-2019. Developed by Hedgecode.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@Test
public void testParse() throws Exception {
Parser tcdParser = TCDParser.getInstance();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
setPositionName(
String.format(
- MSG_TCD_POSITION, testConfig.getString(NAME)
+ MSG_TCD_POSITION, testConfig.getString(AbstractPositionTest.NAME)
)
);
String tcd = testConfig.getString(TCD_TAG);
Position position = assignPosition(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
);
assertPositionEquals(
position,
@Override
public List<XMLConfiguration> getXMLPositions() throws Exception {
List<XMLConfiguration> xmlPositions = new LinkedList<>();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
xmlPositions.add(
new XMLConfiguration(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
)
);
}
/*
- * Copyright (c) 2018. Developed by Hedgecode.
+ * Copyright (c) 2018-2019. Developed by Hedgecode.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.configuration.XMLConfiguration;
+import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@Test
public void testBuild() throws Exception {
Builder wikiBuilder = WikiBuilder.getInstance();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
setPositionName(
String.format(
- MSG_WIKI_POSITION, testConfig.getString(NAME)
+ MSG_WIKI_POSITION, testConfig.getString(AbstractPositionTest.NAME)
)
);
String wiki = testConfig.getString(WIKI_TAG);
Position position = assignPosition(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
);
boolean withTemplate = false;
if (testConfig.containsKey(WIKI_TEMPLATE)) {
@Override
protected void assertStringEquals(String expected, String actual) {
- assertNotNull(expected);
- assertNotNull(actual);
+ Assert.assertNotNull(expected);
+ Assert.assertNotNull(actual);
String[] expectedLines = expected.split(LINE_REGEX);
String[] actualLines = actual.split(LINE_REGEX);
- assertEquals(
+ Assert.assertEquals(
expectedLines.length,
actualLines.length
);
@Override
public List<XMLConfiguration> getXMLPositions() throws Exception {
List<XMLConfiguration> xmlPositions = new LinkedList<>();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
xmlPositions.add(
new XMLConfiguration(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
)
);
}
/*
- * Copyright (c) 2018. Developed by Hedgecode.
+ * Copyright (c) 2018-2019. Developed by Hedgecode.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@Test
public void testParse() throws Exception {
Parser wikiParser = WikiParser.getInstance();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
setPositionName(
String.format(
- MSG_WIKI_POSITION, testConfig.getString(NAME)
+ MSG_WIKI_POSITION, testConfig.getString(AbstractPositionTest.NAME)
)
);
String wiki = testConfig.getString(WIKI_TAG);
Position position = assignPosition(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
);
boolean withTemplate = false;
if (testConfig.containsKey(WIKI_TEMPLATE)) {
@Override
public List<XMLConfiguration> getXMLPositions() throws Exception {
List<XMLConfiguration> xmlPositions = new LinkedList<>();
- for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(TESTS)) {
+ for (HierarchicalConfiguration testConfig : getXMLConfig().configurationsAt(AbstractXMLConfigTest.TESTS)) {
xmlPositions.add(
new XMLConfiguration(
- testConfig.configurationAt(POSITION)
+ testConfig.configurationAt(AbstractPositionTest.POSITION)
)
);
}