Lets the player set a name

Better comments
This commit is contained in:
2018-03-13 10:50:50 +01:00
parent 7d0f0dc4f8
commit 3c1eca4d39
11 changed files with 162 additions and 52 deletions

View File

@@ -62,12 +62,14 @@ public class Game implements IGame {
private final ITurtle painter;
private final Printer printer;
private int numPlayers = 0;
private Main main;
public Game(Screen screen, ITurtle painter, Printer printer) {
public Game(Main main, Screen screen, ITurtle painter, Printer printer) {
this.painter = painter;
this.printer = printer;
addFactory();
this.main = main;
// NOTE: in a more realistic situation, we will have multiple levels (one map
// per level), and (at least for a Roguelike game) the levels should be
@@ -307,7 +309,6 @@ public class Game implements IGame {
printer.clearLine(Main.LINE_MSG1);
printer.clearLine(Main.LINE_MSG2);
printer.clearLine(Main.LINE_MSG3);
System.out.println(lastMessages.size());
if (lastMessages.size() > 0) {
printer.printAt(1, Main.LINE_MSG1, lastMessages.get(0));
}
@@ -427,9 +428,12 @@ public class Game implements IGame {
// only an IPlayer/human can handle keypresses, and only if it's the human's
// turn
if (currentActor instanceof IPlayer) {
((IPlayer) currentActor).keyPressed(this, code); // do your thing
/*((IPlayer) currentActor).keyPressed(this, code); // do your thing
if (movePoints <= 0)
doTurn(); // proceed with turn if we're out of moves
doTurn(); // proceed with turn if we're out of moves*/
if (((IPlayer) currentActor).keyPressed(this, code)) {
main.doTurn();
}
}
}