27 lines
651 B
Java
27 lines
651 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;
|
|
|
|
public class ReadAction implements Action {
|
|
@Override
|
|
public boolean matchesInput(List<String> arguments) {
|
|
return arguments.get(0).equals("read");
|
|
}
|
|
|
|
@Override
|
|
public int getMinimumArgCount() {
|
|
return 2;
|
|
}
|
|
|
|
@Override
|
|
public boolean run(ZorkGame game, List<String> arguments) {
|
|
return game.getItem(arguments.get(1)).map(i -> {
|
|
game.stream.println(i.getWriting());
|
|
return true;
|
|
}).orElse(false);
|
|
}
|
|
}
|