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<String> arguments) {
return arguments.get(0).equals("Update");
}
public int getMinimumArgCount() {
return 1;
public void run(ZorkGame game, List<String> arguments) {
final String object = arguments.get(1);
final String newStatus = arguments.get(3);
ZorkMap<ZorkObject> collection = game.getListThroughLookup(ZorkObject.class, object);
ZorkObject tempObject = collection.get(object);
tempObject.updateStatus(newStatus);
collection.put(tempObject);