Browse Source

restrucered logic-Class

Max Wenzel 3 years ago
parent
commit
59bb3317e0
  1. 106
      src/main/java/de/tims/fleetstorm/ai/Logic.java

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

@ -68,7 +68,8 @@ public class Logic {
}
}
// If ship is sinked
sinkShip();
ArrayList<Coordinate> possibleFields = new ArrayList<Coordinate>();
for (int i = 0; i < coordinates.size(); i++) {
if (coordinates.get(i).getState() != Coordinate.SHOT && coordinates.get(i).getState() != Coordinate.HIT) {
@ -93,137 +94,116 @@ public class Logic {
}
}
}
return out;
}
public void setLastShot(Coordinate coordinate) {
lastShot = this.matchfield.getField(coordinate);
}
public Coordinate getLastShot() {
return lastShot;
}
public void setMatchfield(Matchfield matchfield) {
this.matchfield = matchfield;
}
public Matchfield getMatchfield() {
return matchfield;
}
public void findShip() {
if (lastShot.getState() == Coordinate.HIT) {
foundShip = true;
}
}
public void setFoundShip(boolean b) {
this.foundShip = b;
}
public boolean getFoundShip() {
// TODO Auto-generated method stub
return this.foundShip;
public void sinkShip() {
if (foundShip && clearedAbove && clearedBelow && clearedLeft && clearedRight) {
this.foundShip = false;
this.clearedAbove = false;
this.clearedBelow = false;
this.clearedLeft = false;
this.clearedRight = false;
}
public void checkAround(Coordinate coordinate) {
// TODO Auto-generated method stub
}
public void clearAbove(Coordinate shot) {
target = matchfield.getAbove(shot);
if (target.getState() == Coordinate.EMPTY) {
clearedAbove = true;
}
}
private void shot() {
// TODO Auto-generated method stub
}
public void clearBelow(Coordinate shot) {
target = matchfield.getBelow(shot);
if (target.getState() == Coordinate.EMPTY) {
clearedBelow = true;
}
}
public void clearRight(Coordinate shot) {
target = matchfield.getRight(shot);
if (target.getState() == Coordinate.EMPTY) {
clearedRight = true;
}
}
public void clearLeft(Coordinate shot) {
target = matchfield.getLeft(shot);
if (target.getState() == Coordinate.EMPTY) {
clearedLeft = true;
}
}
public boolean getClearedAbove() {
return this.clearedAbove;
}
// Getter And Setter
public boolean getClearedBelow() {
return this.clearedBelow;
public void setLastShot(Coordinate coordinate) {
lastShot = this.matchfield.getField(coordinate);
}
public boolean getClearedRight() {
return this.clearedRight;
public Coordinate getLastShot() {
return lastShot;
}
public boolean getClearedLeft() {
return this.clearedLeft;
public void setFoundShip(boolean b) {
this.foundShip = b;
}
public void sinkShip() {
if (foundShip && clearedAbove && clearedBelow && clearedLeft && clearedRight) {
this.foundShip = false;
this.clearedAbove = false;
this.clearedBelow = false;
this.clearedLeft = false;
this.clearedRight = false;
}
public boolean getFoundShip() {
return this.foundShip;
}
public void setClearedAbove(boolean b) {
this.clearedAbove = b;
}
public boolean getClearedAbove() {
return this.clearedAbove;
}
public void setClearedBelow(boolean b) {
this.clearedBelow = b;
}
public boolean getClearedBelow() {
return this.clearedBelow;
}
public void setClearedRight(boolean b) {
this.clearedRight = b;
}
public boolean getClearedRight() {
return this.clearedRight;
}
public void setClearedLeft(boolean b) {
this.clearedLeft = b;
}
public Coordinate getTarget() {
return target;
public boolean getClearedLeft() {
return this.clearedLeft;
}
public void setTarget(Coordinate target) {
this.target = target;
}
public Coordinate getTarget() {
return target;
}
public void setMatchfield(Matchfield matchfield) {
this.matchfield = matchfield;
}
public Matchfield getMatchfield() {
return matchfield;
}
}
Loading…
Cancel
Save