Skip to content
This repository has been archived by the owner on Nov 27, 2021. It is now read-only.

Commit

Permalink
2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
timmyRS committed Sep 5, 2018
1 parent 57b132a commit 016f7d9
Show file tree
Hide file tree
Showing 10 changed files with 395 additions and 256 deletions.
11 changes: 9 additions & 2 deletions src/Tests.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import sh.hell.compactchess.game.EndReason;
import sh.hell.compactchess.game.Game;
import sh.hell.compactchess.game.GameStatus;
import sh.hell.compactchess.game.Language;
import sh.hell.compactchess.game.Move;
import sh.hell.compactchess.game.Piece;
import sh.hell.compactchess.game.PieceType;
Expand All @@ -32,7 +33,7 @@ public class Tests
{
private static void visualize(Game game)
{
System.out.println(game.toString(true, false, false, true));
System.out.println(game.toString(true, false, null, true));
}

private static void evaluatePossibleMoves(int expectedSquares, Game game, ArrayList<Square> squares)
Expand Down Expand Up @@ -358,7 +359,7 @@ public void pgn() throws ChessException
visualize(game);
game.uciMove("h2h1q").commit();
visualize(game);
final String pgn = game.toPGN(false, false, true);
String pgn = game.toPGN(false, false, true);
System.out.println(pgn);
Game game_ = Game.fromPGN(pgn).get(0);
visualize(game_);
Expand All @@ -370,6 +371,12 @@ public void pgn() throws ChessException
assertEquals(game, Game.fromPGN(game.toPGN(AlgebraicNotationVariation.MAN)).get(0));
assertEquals(game, Game.fromPGN(game.toPGN(AlgebraicNotationVariation.LAN)).get(0));
assertEquals(game, Game.fromPGN(game.toPGN(AlgebraicNotationVariation.RAN)).get(0));
pgn = game.toPGN(false, false, true, Language.GERMAN);
System.out.println(pgn);
game_ = Game.fromPGN(pgn, Language.GERMAN).get(0);
visualize(game_);
assertEquals(game, game_);
assertTrue(pgn.contains("1. O-O-O+ { Annotation! } Ke7 2. Kb1 h1=D *"));
game = new Game().loadFEN("8/2K5/4q3/8/3N1N2/6b1/8/7k w - -").start();
game.move("Nxe6");
game = Game.fromPGN("1.e4").get(0);
Expand Down
6 changes: 0 additions & 6 deletions src/sh/hell/compactchess/game/CGNVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

public enum CGNVersion
{
/**
* https://web.archive.org/web/20180724201036/https://hellsh.com/CompactChess/cgn
*/
V1,
/**
* http://web.archive.org/web/20180901071215/https://hellsh.com/CompactChess/cgn
*/
V2;

public static final CGNVersion latest = CGNVersion.V2;
Expand Down
179 changes: 179 additions & 0 deletions src/sh/hell/compactchess/game/Country.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
package sh.hell.compactchess.game;

@SuppressWarnings({"WeakerAccess", "UnusedReturnValue", "unused"})
public enum Country
{
AFGHANISTAN("AFG", "Afghanistan"),
ABOARD_AIRCRAFT("AIR", "Aboard aircraft"),
ALBANIA("ALB", "Albania"),
ALGERIA("ALG", "Algeria"),
ANDORRA("AND", "Andorra"),
ANGOLA("ANG", "Angola"),
ANTIGUA("ANT", "Antigua"),
ARGENTINA("ARG", "Argentina"),
ARMENIA("ARM", "Armenia"),
ANTARCTICA("ATA", "Antarctica"),
AUSTRALIA("AUS", "Australia"),
AZERBAIJAN("AZB", "Azerbaijan"),
BANGLADESH("BAN", "Bangladesh"),
BAHRAIN("BAR", "Bahrain"),
BAHAMAS("BHM", "Bahamas"),
BELGIUM("BEL", "Belgium"),
BERMUDA("BER", "Bermuda"),
BOSNIA_AND_HERZEGOVINA("BIH", "Bosnia and Herzegovina"),
BELARUS("BLA", "Belarus"),
BULGARIA("BLG", "Bulgaria"),
BELIZE("BLZ", "Belize"),
BOLIVIA("BOL", "Bolivia"),
BARBADOS("BRB", "Barbados"),
BRAZIL("BRS", "Brazil"),
BRUNEI("BRU", "Brunei"),
BOTSWANA("BSW", "Botswana"),
CANADA("CAN", "Canada"),
CHILE("CHI", "Chile"),
COLUMBIA("COL", "Columbia"),
COSTA_RICA("CRA", "Costa Rica"),
CROATIA("CRO", "Croatia"),
CZECHOSLOVAKIA("CSR", "Czechoslovakia"),
CUBA("CUB", "Cuba"),
CYPRUS("CYP", "Cyprus"),
DENMARK("DEN", "Denmark"),
DOMINICAN_REPUBLIC("DOM", "Dominican Republic"),
ECUADOR("ECU", "Ecuador"),
EGYPT("EGY", "Egypt"),
ENGLAND("ENG", "England"),
SPAIN("ESP", "Spain"),
ESTONIA("EST", "Estonia"),
FAROE_ISLANDS("FAI", "Faroe Islands"),
FIJI("FIJ", "Fiji"),
FINLAND("FIN", "Finland"),
FRANCE("FRA", "France"),
GAMBIA("GAM", "Gambia"),
GUERNSEY_JERSEY("GCI", "Guernsey-Jersey"),
GEORGIA("GEO", "Georgia"),
GERMANY("GER", "Germany"),
GHANA("GHA", "Ghana"),
GREECE("GRC", "Greece"),
GUATEMALA("GUA", "Guatemala"),
GUYANA("GUY", "Guyana"),
HAITI("HAI", "Haiti"),
HONG_KONG("HKG", "Hong Kong"),
HONDURAS("HON", "Honduras"),
HUNGARY("HUN", "Hungary"),
INDIA("IND", "India"),
IRELAND("IRL", "Ireland"),
IRAN("IRN", "Iran"),
IRAQ("IRQ", "Iraq"),
ICELAND("ISD", "Iceland"),
ISRAEL("ISR", "Israel"),
ITALY("ITA", "Italy"),
IVORY_COAST("IVO", "Ivory Coast"),
JAMAICA("JAM", "Jamaica"),
JAPAN("JAP", "Japan"),
JORDAN("JRD", "Jordan"),
YUGOSLAVIA_JUG("JUG", "Yugoslavia"),
KAZAKHSTAN("KAZ", "Kazakhstan"),
KENYA("KEN", "Kenya"),
KYRGYZSTAN("KIR", "Kyrgyzstan"),
KUWAIT("KUW", "Kuwait"),
LATVIA("LAT", "Latvia"),
LEBANON("LEB", "Lebanon"),
LIBYA("LIB", "Libya"),
LIECHTENSTEIN("LIC", "Liechtenstein"),
LITHUANIA("LTU", "Lithuania"),
LUXEMBOURG("LUX", "Luxembourg"),
MALAYSIA("MAL", "Malaysia"),
MAURITANIA("MAU", "Mauritania"),
MEXICO("MEX", "Mexico"),
MALI("MLI", "Mali"),
MALTA("MLT", "Malta"),
MONACO("MNC", "Monaco"),
MOLDOVA("MOL", "Moldova"),
MONGOLIA("MON", "Mongolia"),
MOZAMBIQUE("MOZ", "Mozambique"),
MOROCCO("MRC", "Morocco"),
MAURITIUS("MRT", "Mauritius"),
MYANMAR("MYN", "Myanmar"),
NICARAGUA("NCG", "Nicaragua"),
THE_INTERNET("NET", "The Internet"),
NIGERIA("NIG", "Nigeria"),
NETHERLANDS_ANTILLES("NLA", "Netherlands Antilles"),
NETHERLANDS("NLD", "Netherlands"),
NORWAY("NOR", "Norway"),
NEW_ZEALAND("NZD", "New Zealand"),
AUSTRIA("OST", "Austria"),
PAKISTAN("PAK", "Pakistan"),
PALESTINE("PAL", "Palestine"),
PANAMA("PAN", "Panama"),
PARAGUAY("PAR", "Paraguay"),
PERU("PER", "Peru"),
PHILIPPINES("PHI", "Philippines"),
PAPUA_NEW_GUINEA("PNG", "Papua New Guinea"),
POLAND("POL", "Poland"),
PORTUGAL("POR", "Portugal"),
PEOPLES_REPUBLIC_OF_CHINA("PRC", "People's Republic of China"),
PUERTO_RICO("PRO", "Puerto Rico"),
QATAR("QTR", "Qatar"),
INDONESIA("RIN", "Indonesia"),
ROMANIA("ROM", "Romania"),
RUSSIA("RUS", "Russia"),
SOUTH_AFRICA("SAF", "South Africa"),
EL_SALVADOR("SAL", "El Salvador"),
SCOTLAND("SCO", "Scotland"),
AT_SEA("SEA", "At Sea"),
SENEGAL("SEN", "Senegal"),
SEYCHELLES("SEY", "Seychelles"),
SINGAPORE("SIP", "Singapore"),
SLOVENIA("SLV", "Slovenia"),
SAN_MARINO("SMA", "San Marino"),
ABOARD_SPACECRAFT("SPC", "Aboard spacecraft"),
SRI_LANKA("SRI", "Sri Lanka"),
SUDAN("SUD", "Sudan"),
SURINAM("SUR", "Surinam"),
SWEDEN("SVE", "Sweden"),
SWITZERLAND("SWZ", "Switzerland"),
SYRIA("SYR", "Syria"),
THAILAND("TAI", "Thailand"),
TURKMENISTAN("TMT", "Turkmenistan"),
TURKEY("TRK", "Turkey"),
TRINIDAD_AND_TOBAGO("TTO", "Trinidad and Tobago"),
TUNISIA("TUN", "Tunisia"),
UNITED_ARAB_EMIRATES("UAE", "United Arab Emirates"),
UGANDA("UGA", "Uganda"),
UKRAINE("UKR", "Ukraine"),
UNKNOWN("UNK", "Unknown"),
URUGUAY("URU", "Uruguay"),
UNITED_STATES_OF_AMERICA("USA", "United States of America"),
UZBEKISTAN("UZB", "Uzbekistan"),
VENEZUELA("VEN", "Venezuela"),
BRITISH_VIRGIN_ISLANDS("VGB", "British Virgin Islands"),
VIETNAM("VIE", "Vietnam"),
US_VIRGIN_ISLANDS("VUS", "U.S. Virgin Islands"),
WALES("WLS", "Wales"),
YEMEN("YEM", "Yemen"),
YUGOSLAVIA("YUG", "Yugoslavia"),
ZAMBIA("ZAM", "Zambia"),
ZIMBABWE("ZIM", "Zimbabwe"),
ZAIRE("ZRE", "Zaire");

public final String code;
public final String name;

Country(String code, String name)
{
this.code = code;
this.name = name;
}

public static Country fromCode(String code)
{
for(Country country : Country.values())
{
if(country.code.equalsIgnoreCase(code))
{
return country;
}
}
return null;
}
}
Loading

0 comments on commit 016f7d9

Please sign in to comment.