26 lines
687 B
Java
26 lines
687 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 InventoryAction implements Action {
|
|
@Override
|
|
public boolean matchesInput(List<String> arguments) {
|
|
return arguments.get(0).equals("i");
|
|
}
|
|
|
|
@Override
|
|
public boolean run(ZorkGame game, List<String> arguments) {
|
|
|
|
if (game.inventory.isEmpty()) {
|
|
game.stream.println("Inventory: empty");
|
|
} else {
|
|
final String output = "Inventory: " + String.join(", ", game.inventory);
|
|
game.stream.println(output);
|
|
}
|
|
return true;
|
|
}
|
|
}
|