ÆÆÆÆ Eg er lei av å skrive
Del A er implementert sånn omtrentlig ok. Tester har blitt fikset slik at de fungerer med Intellij. Noen kommentarer har blitt fikset. En del dårlig kode har blitt fikset.
This commit is contained in:
@@ -148,6 +148,13 @@ public class Game implements IGame {
|
||||
beginTurn();
|
||||
}
|
||||
|
||||
if (random.nextInt(100) < 20) {
|
||||
ILocation loc = map.getLocation((int)(Math.random() * map.getWidth()), (int)(Math.random() * map.getHeight()));
|
||||
if (!map.hasActors(loc) && !map.hasItems(loc) && !map.hasWall(loc)) {
|
||||
map.add(loc, new Carrot());
|
||||
}
|
||||
}
|
||||
|
||||
// process actors one by one; for the IPlayer, we return and wait for keypresses
|
||||
// Possible TODO: for INonPlayer, we could also return early (returning
|
||||
// *false*), and then insert a little timer delay between each non-player move
|
||||
@@ -231,6 +238,8 @@ public class Game implements IGame {
|
||||
}
|
||||
} else if (item instanceof IActor) {
|
||||
actors.add((IActor) item); // add other actors to the end of the list
|
||||
} else if (item instanceof Carrot) {
|
||||
((Carrot) item).doTurn();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -356,8 +365,13 @@ public class Game implements IGame {
|
||||
|
||||
@Override
|
||||
public List<GridDirection> getPossibleMoves() {
|
||||
// TODO
|
||||
throw new UnsupportedOperationException();
|
||||
List<GridDirection> moves = new ArrayList<>();
|
||||
for (GridDirection dir : GridDirection.FOUR_DIRECTIONS) {
|
||||
if (canGo(dir)) {
|
||||
moves.add(dir);
|
||||
}
|
||||
}
|
||||
return moves;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -187,7 +187,7 @@ public interface IGame {
|
||||
double[] getFreeGraphicsAreaBounds();
|
||||
|
||||
/**
|
||||
* Get the bounds of the free texxt area.
|
||||
* Get the bounds of the free text area.
|
||||
* <p>
|
||||
* You can fill this with whatever you want, using {@link #getPrinter()} and
|
||||
* {@link #clearFreeTextArea()}.
|
||||
|
Reference in New Issue
Block a user