Skip to content

Commit

Permalink
Fixed foxes
Browse files Browse the repository at this point in the history
  • Loading branch information
morri564 committed Dec 6, 2023
1 parent a202b4d commit 639f483
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions src/main/java/team/rocket/Entities/Fox.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,49 +207,6 @@ public static int getVision() {

public int instancedGetVision() {
return vision;

public void eat(Map map, int row, int column) {
if (map.getGrid()[row][column] != null) {
AbstractOrganism org = map.getGrid()[row][column];
if (org.instancedToIcon() == 'R') {
this.hunger += org.getNutrition();
org.reduceCount();
map.removeOrganism(row, column);
}
}
}

public AbstractOrganism[] findNeighbors(Map map, int y, int x) {
AbstractOrganism[] neighbors = new AbstractOrganism[4];
if (y == 0) {
neighbors[0] = OrganismFactory.getInstance().createOrganism("Fox"); //Acting as walls
neighbors[0].reduceCount(); //Keeping the Fox count accurate
} else {
neighbors[0] = map.getOrganism(y - 1, x);
}

if (y == map.getHeight() - 1) {
neighbors[1] = OrganismFactory.getInstance().createOrganism("Fox");
neighbors[1].reduceCount();
} else {
neighbors[1] = map.getOrganism(y + 1, x);
}

if (x == 0) {
neighbors[2] = OrganismFactory.getInstance().createOrganism("Fox");
neighbors[2].reduceCount();
} else {
neighbors[2] = map.getOrganism(y, x - 1);
}

if (x == map.getWidth() - 1) {
neighbors[3] = OrganismFactory.getInstance().createOrganism("Fox");
neighbors[3].reduceCount();
} else {
neighbors[3] = map.getOrganism(y, x + 1);
}

return neighbors;
}

public void eat(Map map, int row, int column) {
Expand Down

0 comments on commit 639f483

Please sign in to comment.