package bvyy.command; // Copyright(C)1998 Brian Yap // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the // Free Software Foundation; either version 2 of the License, or (at your // option) any later version. // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for // more details. // You should have received a copy of the GNU General Public License along with // this program; if not, write to the Free Software Foundation, Inc., 675 Mass // Ave, Cambridge, MA 02139, USA. import bvyy.database.*; import java.util.*; /** * The Assemble command attempts to create a new object out of the component * objects.

* * @see bvyy.command.Disassemble * * @version 0.0.1 27 October 1998 * @author (c)1998 Brian Voon Yee Yap */ public class Assemble extends Operate { /** * Creates a new Assemble command. */ public Assemble() { super(); } /** * Creates a new Assemble command with a description of S. * * @param s the event description. */ public Assemble(String S) { super(S); } /** * Executes this command.

* * This command:

*
    *
  1. Determines if there is such a category object exists. A No-Such- * Category-Exception is thrown if the category does not exist.
  2. *
  3. Determines if the components are sufficient to create the object. If * they are not, it will return a Command-Completely-Failed-Exception. * The object will not have been created.
  4. *
  5. Determines if the capabilities are sufficient to create the object. * If they are not, it will return a Command-Completely-Failed- * Exception. The object will not have been created.
  6. *
  7. Determines if the tools are sufficient to create the object. If * they are not, it will return a Command-Completely-Failed-Exception. * The object will not have been created.
  8. *
  9. Determines if the components are sufficient to create the object. If * they are not, it will return a Command-Completely-Failed-Exception. * The object will not have been created.
  10. *
  11. Assemble the objects out of the supplied components using both * mandatory and optional components. In this processing any surplus * objects will be ignored.
  12. *
* Arguments:

*
    *
  1. Category - The object template of the object to be * assembled.
  2. *
  3. String - The name to be assigned to the object being created. * If this string is null then the default name suplied * in the category will be used.
  4. *
  5. Vector - A set of 0 to N component things that are to be used * to create the new thing. Any components requried * (mandatory or optional) are consumed. Any surplus * components are not consumed.
  6. *
  7. Vector - A set of 0 to N tools that are to be used to * create the new thing. Any tools marked as being consumed * will be destroyed by the construction process. The * lifetime cycle of the tool will be incremented as * required.
  8. *
  9. Vector - A set of 0 to N capabilities that are to be used to * create the new thing. Any temporary or permanent * reductions or increases in the performance of the skills * will be processed.
  10. *
  11. Vector - A set of 0 to N characteristics that are to be used to * create the new thing. Any temporary or permanent * reductions or increases will be processed.
  12. *
  13. Thing - The location where the thing is to be created.
  14. *
*/ public void execute(Hashtable theArguments) throws CommandCompletelyFailedException, CommandPartlyFailedException, NoSuchCategoryException { private Category theCategory; private Thing theThing = null; private GameThing gameThing = new GameThing(); System.out.println("Command: Assemble: Execute"); if (!(theArguments.contains("Category")) then { throw CommandCompletelyFailedException("No category supplied."); } if (!(theArguments.contains("Location")) then { throw CommandCompletelyFailedException("No location supplied."); } //grab a data base lock // Start The creation process theCategory = theArguments.get("Category"); if (gameThing.getCategoryIndex.getFlatCategoryList.contains(theArguments.get("Category").getName())) { try (theThing = theCategory.buildThing(theArguments.get("Components"), theArguments.get("Tools"), theArguments.get("Capabilities"), theArguments.get("Characteristics"), theArguments.get("Location") ) catch (ContructionFailedExcpetion) { throw CommandCompeletelyFailedException = new CommandCompeletelyFailedException(ContructionFailedExcpetion.getMessage()); }; }; } else { throw NoSuchCategoryException = new NoSuchCategoryException("Not a registered category. Category is: " + theArguments.get("Category").getName()) + "."); }; }