Browse Source

Fixed chooseField returns null

fleetstorm
Lorenz Hohmann 2 years ago
parent
commit
dd2ddc5811
  1. 8
      src/main/java/de/tims/fleetstorm/ai/Logic.java

8
src/main/java/de/tims/fleetstorm/ai/Logic.java

@ -35,7 +35,7 @@ public class Logic {
if (!clearedAbove) { if (!clearedAbove) {
target = matchfield.getAbove(target); target = matchfield.getAbove(target);
out = target; out = target;
if (target.getState() == Coordinate.EMPTY || target == null) {
if (target == null || target.getState() == Coordinate.EMPTY) {
clearedAbove = true; clearedAbove = true;
target = lastShot; target = lastShot;
} }
@ -45,7 +45,7 @@ public class Logic {
if (!clearedBelow) { if (!clearedBelow) {
target = matchfield.getBelow(target); target = matchfield.getBelow(target);
out = target; out = target;
if (target.getState() == Coordinate.EMPTY || target == null) {
if (target == null || target.getState() == Coordinate.EMPTY) {
clearedBelow = true; clearedBelow = true;
target = lastShot; target = lastShot;
} }
@ -57,7 +57,7 @@ public class Logic {
if (!clearedRight) { if (!clearedRight) {
target = matchfield.getRight(target); target = matchfield.getRight(target);
out = target; out = target;
if (target.getState() == Coordinate.EMPTY || target == null) {
if (target == null || target.getState() == Coordinate.EMPTY) {
clearedRight = true; clearedRight = true;
target = lastShot; target = lastShot;
} }
@ -67,7 +67,7 @@ public class Logic {
if (!clearedLeft) { if (!clearedLeft) {
target = matchfield.getLeft(target); target = matchfield.getLeft(target);
out = target; out = target;
if (target.getState() == Coordinate.EMPTY || target == null) {
if (target == null || target.getState() == Coordinate.EMPTY) {
clearedLeft = true; clearedLeft = true;
target = lastShot; target = lastShot;
} }

Loading…
Cancel
Save