35 lines
927 B
Java
35 lines
927 B
Java
package com.github.dtschust.zork.repl.actions;
|
|
|
|
import com.github.dtschust.zork.ZorkGame;
|
|
import com.github.dtschust.zork.repl.Action;
|
|
import com.github.dtschust.zork.objects.ZorkItem;
|
|
|
|
import java.io.PrintStream;
|
|
import java.util.List;
|
|
|
|
import static com.github.dtschust.zork.objects.ZorkObjectTypes.ITEM;
|
|
|
|
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, PrintStream stream) {
|
|
final String what = arguments.get(1);
|
|
|
|
if (game.inventory.contains(what)) {
|
|
ZorkItem tempItem = (ZorkItem) game.get(ITEM, what);
|
|
stream.println(tempItem.getWriting());
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|