|
|
@ -32,7 +32,7 @@ public class GameService |
|
|
|
{ |
|
|
|
for (int y = 0; y < 8; y++) |
|
|
|
{ |
|
|
|
fields.add(new Field(x, y, getColor(x, y) , null)); |
|
|
|
fields.add(new Field(x, y, getColor(x, y) , getFigure(x, y, whiteUser, blackUser))); |
|
|
|
} |
|
|
|
} |
|
|
|
return fields; |
|
|
@ -42,4 +42,58 @@ public class GameService |
|
|
|
{ |
|
|
|
return (x + y) % 2 != 1 ? Field.Color.WHITE : Field.Color.BLACK; |
|
|
|
} |
|
|
|
|
|
|
|
private Figure getFigure(final int x, final int y, final UserId whitePlayer, final UserId blackPlayer) |
|
|
|
{ |
|
|
|
if (x == 0) |
|
|
|
{ |
|
|
|
return getFigureOfGroundLevel(y, whitePlayer); |
|
|
|
} |
|
|
|
|
|
|
|
if (x == 1) |
|
|
|
{ |
|
|
|
return new Figure(Figure.Type.PAWN, whitePlayer); |
|
|
|
} |
|
|
|
|
|
|
|
if (x == 7) |
|
|
|
{ |
|
|
|
return getFigureOfGroundLevel(y, blackPlayer); |
|
|
|
} |
|
|
|
|
|
|
|
if (x == 6) |
|
|
|
{ |
|
|
|
return new Figure(Figure.Type.PAWN, blackPlayer); |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
private Figure getFigureOfGroundLevel(final int y, final UserId player) |
|
|
|
{ |
|
|
|
if (y == 0 || y == 7) |
|
|
|
{ |
|
|
|
return new Figure(Figure.Type.ROOK, player); |
|
|
|
} |
|
|
|
|
|
|
|
if (y == 1 || y == 6) |
|
|
|
{ |
|
|
|
return new Figure(Figure.Type.KNIGHT, player); |
|
|
|
} |
|
|
|
|
|
|
|
if (y == 2 || y == 5) |
|
|
|
{ |
|
|
|
return new Figure(Figure.Type.BISHOP, player); |
|
|
|
} |
|
|
|
|
|
|
|
if (y == 3) |
|
|
|
{ |
|
|
|
return new Figure(Figure.Type.QUEEN, player); |
|
|
|
} |
|
|
|
|
|
|
|
if (y == 4) |
|
|
|
{ |
|
|
|
return new Figure(Figure.Type.KING, player); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |