player: cleaned code for Coord implementation
This commit is contained in:
parent
329a65176b
commit
91d9721855
@ -475,10 +475,10 @@ public class Player {
|
|||||||
if (currentIslandCount < 8 ){
|
if (currentIslandCount < 8 ){
|
||||||
// Check if there is an island adjacent to this move
|
// Check if there is an island adjacent to this move
|
||||||
for (Island island : state.getIslands()) {
|
for (Island island : state.getIslands()) {
|
||||||
if (island.containsCoord(new Coord(coord.getX() + 1, coord.getY()))
|
if (island.containsCoord(new Coord(coord.x() + 1, coord.y()))
|
||||||
|| island.containsCoord(new Coord(coord.getX() - 1, coord.getY()))
|
|| island.containsCoord(new Coord(coord.x() - 1, coord.y()))
|
||||||
|| island.containsCoord(new Coord(coord.getX(), coord.getY() + 1))
|
|| island.containsCoord(new Coord(coord.x(), coord.y() + 1))
|
||||||
|| island.containsCoord(new Coord(coord.getX(), coord.getY() - 1))) {
|
|| island.containsCoord(new Coord(coord.x(), coord.y() - 1))) {
|
||||||
score += 1;
|
score += 1;
|
||||||
if (state.getCurrentPhase() == 'E'){
|
if (state.getCurrentPhase() == 'E'){
|
||||||
score += 4;
|
score += 4;
|
||||||
@ -501,8 +501,8 @@ public class Player {
|
|||||||
private int maxCol(Coord[] coords){
|
private int maxCol(Coord[] coords){
|
||||||
int maxCol = 0;
|
int maxCol = 0;
|
||||||
for (Coord coord : coords) {
|
for (Coord coord : coords) {
|
||||||
if (coord.getX() > maxCol) {
|
if (coord.x() > maxCol) {
|
||||||
maxCol = coord.getX();
|
maxCol = coord.x();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return maxCol;
|
return maxCol;
|
||||||
@ -553,7 +553,7 @@ public class Player {
|
|||||||
|
|
||||||
while (settlersCoords[settlers.length - 1] == null) {
|
while (settlersCoords[settlers.length - 1] == null) {
|
||||||
for (Coord coord : settlers) {
|
for (Coord coord : settlers) {
|
||||||
if (coord.getX() == col && coord.getY() == row) {
|
if (coord.x() == col && coord.y() == row) {
|
||||||
settlersCoords[i] = coord;
|
settlersCoords[i] = coord;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -575,7 +575,7 @@ public class Player {
|
|||||||
|
|
||||||
while (villagesCoords[villages.length-1] == null){
|
while (villagesCoords[villages.length-1] == null){
|
||||||
for (Coord coord : villages) {
|
for (Coord coord : villages) {
|
||||||
if (coord.getX() == col && coord.getY() == row) {
|
if (coord.x() == col && coord.y() == row) {
|
||||||
villagesCoords[i] = coord;
|
villagesCoords[i] = coord;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user