This repository has been archived on 2022-12-21. You can view files and clone it, but cannot push or open issues or pull requests.
sdm03/src/main/java/com/github/dtschust/zork/repl/actions/GameOverAction.java

29 lines
684 B
Java

package com.github.dtschust.zork.repl.actions;
import com.github.dtschust.zork.ZorkGame;
import com.github.dtschust.zork.repl.Action;
import java.util.List;
/**
* The "Game Over" action marks the end of the game.
*/
public class GameOverAction implements Action {
@Override
public boolean matchesInput(List<String> arguments) {
return arguments.get(0).equals("Game") && arguments.get(1).equals("Over");
}
@Override
public int getMinimumArgCount() {
return 2;
}
@Override
public boolean run(ZorkGame game, List<String> arguments) {
game.stream.println("Victory!");
game.setGameOver();
return true;
}
}