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.types.ZorkItem; import java.util.List; import static com.github.dtschust.zork.Zork.Type.ITEM; /** * Turn on an item */ public class TurnOnAction implements Action { @Override public boolean matchesInput(List arguments) { return arguments.get(0).equals("turn") && arguments.get(1).equals("on"); } @Override public int getMinimumArgCount() { return 3; } @Override public void run(ZorkGame game, List arguments) { final String what = arguments.get(2); if (game.inventory.contains(what)) { ZorkItem tempItem = (ZorkItem) game.get(ITEM, what); System.out.println("You activate the " + what + "."); if (tempItem != null) { tempItem.printAndExecuteActions(game); return; } } System.out.println("Error"); } }