@@ -807,10 +807,16 @@ private void calcPathsFromPlayer(Player player) {
807
807
Cell friendKingCell = getPlayerKing (getFriendIdOfPlayer (player .getPlayerId ())).getCenter ();
808
808
809
809
List <Path > paths = new ArrayList <>();
810
- for (Path path : initMessage .getMap ().getPaths ())
811
- if (path .getCells ().indexOf (playerKingCell ) == 0 || path .getCells ().lastIndexOf (playerKingCell ) == path .getCells ().size () - 1 )
812
- if (!path .getCells ().contains (friendKingCell ))
813
- paths .add (path );
810
+ for (Path path : initMessage .getMap ().getPaths ()) {
811
+ if (path .getCells ().indexOf (playerKingCell ) == 0 || path .getCells ().indexOf (playerKingCell ) == path .getCells ().size () - 1 ) {
812
+ if (!path .getCells ().contains (friendKingCell )){
813
+ Path newPath = path .copy ();
814
+ if (newPath .getCells ().indexOf (playerKingCell ) != 0 )
815
+ Collections .reverse (newPath .getCells ());
816
+ paths .add (newPath );
817
+ }
818
+ }
819
+ }
814
820
player .setPathsFromPlayer (paths );
815
821
}
816
822
@@ -826,8 +832,12 @@ private void calcPathToFriend(Player player) {
826
832
for (Path path : initMessage .getMap ().getPaths ()) {
827
833
List <Cell > pathCells = path .getCells ();
828
834
if (pathCells .indexOf (playerKingCell ) == 0 || pathCells .lastIndexOf (playerKingCell ) == pathCells .size () - 1 )
829
- if (pathCells .indexOf (friendKingCell ) == 0 || pathCells .lastIndexOf (friendKingCell ) == pathCells .size () - 1 )
830
- player .setPathToFriend (path );
835
+ if (pathCells .indexOf (friendKingCell ) == 0 || pathCells .lastIndexOf (friendKingCell ) == pathCells .size () - 1 ) {
836
+ Path newPath = path .copy ();
837
+ if (newPath .getCells ().indexOf (playerKingCell ) != 0 )
838
+ Collections .reverse (newPath .getCells ());
839
+ player .setPathToFriend (newPath );
840
+ }
831
841
}
832
842
}
833
843
0 commit comments