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.ZorkMap; import com.github.dtschust.zork.types.ZorkObject; import java.util.List; /** * The "Update" command figures out what type of item it is, and then change its status */ public class UpdateAction implements Action { @Override public boolean matchesInput(List arguments) { return arguments.get(0).equals("Update"); } @Override public int getMinimumArgCount() { return 1; } @Override public void run(ZorkGame game, List arguments) { final String object = arguments.get(1); final String newStatus = arguments.get(3); ZorkMap collection = game.getListThroughLookup(ZorkObject.class, object); ZorkObject tempObject = collection.get(object); tempObject.updateStatus(newStatus); collection.put(tempObject); } }