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/StartGameAction.java
2022-11-22 18:03:09 +01:00

36 lines
940 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;
/**
* Add: figure out what type the destination is, then what type the object is. Then add object to destination if it makes sense
*/
public class StartGameAction implements Action {
@Override
public boolean matchesInput(List<String> arguments) {
return arguments.get(0).equals("Start") && arguments.get(1).equals("at");
}
@Override
public int getMinimumArgCount() {
return 3;
}
@Override
public boolean run(ZorkGame game, List<String> arguments) {
final String room = arguments.get(2);
if(!game.isRunning()){
if(game.changeRoom(room)){
game.stream.println(game.getCurrentRoom().getDescription());
return true;
}
}
return false;
}
}