CMGenEditor.java

com/planet_ink/coffee_mud/Libraries/CMGenEditor.java · 325.7 KB

From the archive CoffeeMud_5_5_5.zip

Download the archive   « Back to the archive contents

package com.planet_ink.coffee_mud.Libraries;
import com.planet_ink.coffee_mud.core.interfaces.*;
import com.planet_ink.coffee_mud.core.exceptions.*;
import com.planet_ink.coffee_mud.core.*;
import com.planet_ink.coffee_mud.Libraries.interfaces.*;
import com.planet_ink.coffee_mud.Libraries.interfaces.MoneyLibrary.MoneyDenomination;
import com.planet_ink.coffee_mud.Abilities.interfaces.*;
import com.planet_ink.coffee_mud.Areas.interfaces.*;
import com.planet_ink.coffee_mud.Behaviors.interfaces.*;
import com.planet_ink.coffee_mud.CharClasses.interfaces.*;
import com.planet_ink.coffee_mud.Commands.interfaces.*;
import com.planet_ink.coffee_mud.Common.interfaces.*;
import com.planet_ink.coffee_mud.Exits.interfaces.*;
import com.planet_ink.coffee_mud.Items.interfaces.*;
import com.planet_ink.coffee_mud.Locales.interfaces.*;
import com.planet_ink.coffee_mud.MOBS.interfaces.*;
import com.planet_ink.coffee_mud.Races.interfaces.*;


import java.io.IOException;
import java.util.*;
import java.util.regex.*;

/*
   Copyright 2000-2010 Bo Zimmerman

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
@SuppressWarnings("unchecked")
public class CMGenEditor extends StdLibrary implements GenericEditor
{
    public String ID(){return "CMGenEditor";}
    
    private final long maxLength=Long.MAX_VALUE;
    // showNumber should always be a valid number no less than 1
    // showFlag should be a valid number for editing, or -1 for skipping


    public void promptStatInt(MOB mob, CMModifiable E, int showNumber, int showFlag, String FieldDisp, String Field)
    throws IOException
    { promptStatInt(mob,E,null,showNumber,showFlag,FieldDisp,Field);}
    public void promptStatInt(MOB mob, CMModifiable E, String help, int showNumber, int showFlag, String FieldDisp, String Field)
    throws IOException
    { E.setStat(Field,""+prompt(mob,CMath.s_long(E.getStat(Field)),showNumber,showFlag,FieldDisp,help)); }
    public void promptStatBool(MOB mob, CMModifiable E, int showNumber, int showFlag, String FieldDisp, String Field)
    throws IOException
    { promptStatBool(mob,E,null,showNumber,showFlag,FieldDisp,Field);}
    public void promptStatBool(MOB mob, CMModifiable E, String help, int showNumber, int showFlag, String FieldDisp, String Field)
    throws IOException
    { E.setStat(Field,""+prompt(mob,CMath.s_bool(E.getStat(Field)),showNumber,showFlag,FieldDisp,help)); }
    public void promptStatStr(MOB mob, CMModifiable E, int showNumber, int showFlag, String FieldDisp, String Field)
    throws IOException
    { promptStatStr(mob,E,null,showNumber,showFlag,FieldDisp,Field,true);}
    public void promptStatStr(MOB mob, CMModifiable E, String help, int showNumber, int showFlag, String FieldDisp, String Field, boolean emptyOK)
    throws IOException
    { E.setStat(Field,prompt(mob,E.getStat(Field),showNumber,showFlag,FieldDisp,emptyOK,false,help,null,null)); }
    public String prompt(MOB mob, String oldVal, int showNumber, int showFlag, String FieldDisp)
    throws IOException
    { return prompt(mob,oldVal,showNumber,showFlag,FieldDisp,false,false,null,null,null); }
    public String prompt(MOB mob, String oldVal, int showNumber, int showFlag, String FieldDisp, String help)
    throws IOException
    { return prompt(mob,oldVal,showNumber,showFlag,FieldDisp,false,false,help,null,null); }
    public String prompt(MOB mob, String oldVal, int showNumber, int showFlag, String FieldDisp, boolean emptyOK)
    throws IOException
    {return prompt(mob,oldVal,showNumber,showFlag,FieldDisp,emptyOK,false,null,null,null); }
    public String prompt(MOB mob, String oldVal, int showNumber, int showFlag, String FieldDisp, boolean emptyOK, String help)
    throws IOException
    { return prompt(mob,oldVal,showNumber,showFlag,FieldDisp,emptyOK,false,help);}
    public String prompt(MOB mob, String oldVal, int showNumber, int showFlag, String FieldDisp, boolean emptyOK, boolean rawPrint)
    throws IOException
    { return prompt(mob,oldVal,showNumber,showFlag,FieldDisp,emptyOK,false,null,null,null);}
    public String prompt(MOB mob, String oldVal, int showNumber, int showFlag, String FieldDisp, boolean emptyOK, boolean rawPrint, String help)
    throws IOException
    { return prompt(mob,oldVal,showNumber,showFlag,FieldDisp,emptyOK,rawPrint,help,null,null);}
    public boolean prompt(MOB mob, boolean oldVal, int showNumber, int showFlag, String FieldDisp)
    throws IOException
    { return prompt(mob,oldVal,showNumber,showFlag,FieldDisp,null); }
    public double prompt(MOB mob, double oldVal, int showNumber, int showFlag, String FieldDisp)
    throws IOException
    { return prompt(mob,oldVal,showNumber,showFlag,FieldDisp,null); }
    public int prompt(MOB mob, int oldVal, int showNumber, int showFlag, String FieldDisp)
    throws IOException
    { return prompt(mob,oldVal,showNumber,showFlag,FieldDisp,null);}
    public long prompt(MOB mob, long oldVal, int showNumber, int showFlag, String FieldDisp)
    throws IOException
    { return prompt(mob,oldVal,showNumber,showFlag,FieldDisp,null);}



    public boolean promptToggle(MOB mob, int showNumber, int showFlag, String FieldDisp)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return false;
        mob.tell(showNumber+". "+FieldDisp);
        if((showFlag!=showNumber)&&(showFlag>-999)) return false;
        if(showFlag!=showNumber)
            return mob.session().confirm("Toggle (y/N)?","N");
        return true;
    }

    public String prompt(MOB mob,
                         String oldVal,
                         int showNumber,
                         int showFlag,
                         String FieldDisp,
                         boolean emptyOK,
                         boolean rawPrint,
                         String help,
                         CMEval eval,
                         Object[] choices)
    throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return oldVal;
        if(rawPrint)
            mob.session().rawPrintln(showNumber+". "+FieldDisp+": '"+oldVal+"'.");
        else
            mob.tell(showNumber+". "+FieldDisp+": '"+oldVal+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return oldVal;
        String newName="?";
        while(newName.equals("?")&&(mob.session()!=null)&&(!mob.session().killFlag()))
        {
            newName=mob.session().prompt("Enter a new value "+(emptyOK?"(or NULL)":"")+(help!=null?" (?)":"")+"\n\r:","");
            if(newName.equals("?")&&(help!=null))
                mob.tell(help);
            else
            {
                boolean noEntry=(newName.trim().length()==0);
                if(noEntry)
                    newName=oldVal;
                else
                if((newName.equalsIgnoreCase("null"))&&(emptyOK))
                    newName="";

                if(eval!=null)
                try
                {
                    Object value=eval.eval(newName,choices,emptyOK);
                    if(value instanceof String)
                        newName=(String)value;
                }
                catch(CMException e)
                {
                    mob.tell(e.getMessage());
                    newName="?";
                    continue;
                }
                if((noEntry)&&(newName.equals(oldVal)))
                    break;
                return newName;
            }
        }
        mob.tell("(no change)");
        return oldVal;
    }

    public boolean prompt(MOB mob, boolean oldVal, int showNumber, int showFlag, String FieldDisp, String help)
    throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return oldVal;
        mob.tell(showNumber+". "+FieldDisp+": '"+oldVal+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return oldVal;
        String newName="?";
        while(newName.equals("?")&&(mob.session()!=null)&&(!mob.session().killFlag()))
        {
            newName=mob.session().prompt("Enter true or false"+(help!=null?" (?)":"")+":","");
            if(newName.equals("?")&&(help!=null))
                mob.tell(help);
            else
            if(newName.toUpperCase().startsWith("T")||newName.toUpperCase().startsWith("F"))
                return newName.toUpperCase().startsWith("T");
            else
            if(newName.toUpperCase().startsWith("Y")||newName.toUpperCase().startsWith("N"))
                return newName.toUpperCase().startsWith("Y");
            else
                break;
        }
        mob.tell("(no change)");
        return oldVal;
    }

    public double prompt(MOB mob, double oldVal, int showNumber, int showFlag, String FieldDisp, String help)
    throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return oldVal;
        mob.tell(showNumber+". "+FieldDisp+": '"+oldVal+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return oldVal;
        String newName="?";
        while(newName.equals("?")&&(mob.session()!=null)&&(!mob.session().killFlag()))
        {
            newName=mob.session().prompt("Enter a new value"+(help!=null?" (?)":"")+":","");
            if(newName.equals("?")&&(help!=null))
                mob.tell(help);
            else
            if(CMath.isNumber(newName))
                return CMath.s_double(newName);
            else
                break;
        }
        mob.tell("(no change)");
        return oldVal;
    }

    public int prompt(MOB mob, int oldVal, int showNumber, int showFlag, String FieldDisp, String help)
    throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return oldVal;
        mob.tell(showNumber+". "+FieldDisp+": '"+oldVal+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return oldVal;
        String newName="?";
        while(newName.equals("?")&&(mob.session()!=null)&&(!mob.session().killFlag()))
        {
            newName=mob.session().prompt("Enter a new value"+(help!=null?" (?)":"")+":","");
            if(newName.equals("?")&&(help!=null))
                mob.tell(help);
            else
            if(CMath.isInteger(newName))
                return CMath.s_int(newName);
            else
                break;
        }
        mob.tell("(no change)");
        return oldVal;
    }

    public long prompt(MOB mob, long oldVal, int showNumber, int showFlag, String FieldDisp, String help)
    throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return oldVal;
        mob.tell(showNumber+". "+FieldDisp+": '"+oldVal+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return oldVal;
        String newName="?";
        while(newName.equals("?")&&(mob.session()!=null)&&(!mob.session().killFlag()))
        {
            newName=mob.session().prompt("Enter a new value"+(help!=null?" (?)":"")+":","");
            if(newName.equals("?")&&(help!=null))
                mob.tell(help);
            else
            if(CMath.isInteger(newName))
                return CMath.s_long(newName);
            else
                break;
        }
        mob.tell("(no change)");
        return oldVal;
    }
    
    public int promptMulti(MOB mob, int oldVal, int showNumber, int showFlag, String FieldDisp, DVector choices) 
    throws IOException
    {
        return CMath.s_int(promptMultiOrExtra(mob,""+oldVal,showNumber,showFlag,FieldDisp,choices));
    }
    
    public String promptMultiOrExtra(MOB mob, String oldVal, int showNumber, int showFlag, String FieldDisp, DVector choices) 
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return oldVal;
        Vector oldVals = new Vector();
        if(CMath.s_int(oldVal) > 0) {
            for(int c=0;c<choices.size();c++)
                if(CMath.bset(CMath.s_int(oldVal),((Integer)choices.elementAt(c,1)).intValue()))
                    oldVals.addElement((String)choices.elementAt(c,2));
        }
        else
        if(choices.contains(oldVal.toUpperCase().trim()))
            oldVals.addElement(oldVal);
        mob.tell(showNumber+". "+FieldDisp+": '"+CMParms.toStringList(oldVals)+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return oldVal;
        String newVal=oldVal;
        String thisVal="?";
        while(thisVal.equals("?")&&(mob.session()!=null)&&(!mob.session().killFlag()))
        {
            thisVal=mob.session().prompt("Enter a new choice to add/remove (?):","").trim();
            if(thisVal.equals("?"))
                mob.tell(CMParms.toStringList(choices.getDimensionVector(2)));
            else
            if(thisVal.length()==0)
                newVal = oldVal;
            else
            if(thisVal.equalsIgnoreCase("NULL")) {
                if(choices.contains(""))
                    newVal = "";
                else
                    newVal = "0";
                oldVals.clear();
                break;
            }
            else
            {
                String foundChoice = null;
                String foundVal = "";
                for(int c=0;c<choices.size();c++)
                    if(((String)choices.elementAt(c,2)).equalsIgnoreCase(thisVal))
                    {
                        foundChoice = (String)choices.elementAt(c,2);
                        foundVal = choices.elementAt(c,1).toString();
                    }
                if(foundChoice == null)
                {
                    mob.tell("'"+newVal+"' is not an available option.  Use ? for a list.");
                    thisVal = "?";
                }
                else
                if(!CMath.isInteger(foundVal))
                {
                    oldVals.clear();
                    newVal = foundVal;
                    oldVals.addElement(foundVal);
                }
                else
                if(foundVal == "0")
                {
                    newVal = "0";
                    oldVals.clear();
                }
                else
                {
                    if(oldVals.contains(foundChoice))
                    {
                        newVal = Integer.toString(CMath.s_int(newVal) - CMath.s_int(foundVal));
                        oldVals.remove(foundChoice);
                        mob.tell("'"+foundChoice+"' removed.");
                        thisVal = "?";
                    } else {
                        oldVals.add(foundChoice);
                        mob.tell("'"+foundChoice+"' added.");
                        thisVal = "?";
                        newVal = Integer.toString(CMath.s_int(newVal) | CMath.s_int(foundVal));
                    }
                }
            }
        }
        if(oldVal.equals(newVal))
            mob.tell("(no change)");
        return newVal;
    }
    
    public String prompt(MOB mob, String oldVal, int showNumber, int showFlag, String FieldDisp, DVector choices)
    throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return oldVal;
        String oldShowVal = oldVal;
        for(int c=0;c<choices.size();c++)
            if(((String)choices.elementAt(c,1)).equalsIgnoreCase(oldVal))
                oldShowVal = (String)choices.elementAt(c,2);
        mob.tell(showNumber+". "+FieldDisp+": '"+oldShowVal+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return oldVal;
        String newVal="?";
        while(newVal.equals("?")&&(mob.session()!=null)&&(!mob.session().killFlag()))
        {
            newVal=mob.session().prompt("Enter a new choice (? or NULL):","").trim();
            if(newVal.equals("?"))
                mob.tell(CMParms.toStringList(choices.getDimensionVector(2)));
            else
            if(newVal.length()==0)
                newVal = oldVal;
            else
            {
                if(newVal.equalsIgnoreCase("NULL"))
                    newVal = "";
                String foundChoice = null;
                for(int c=0;c<choices.size();c++)
                    if(((String)choices.elementAt(c,2)).equalsIgnoreCase(newVal))
                        foundChoice = (String)choices.elementAt(c,1);
                if(foundChoice == null)
                    mob.tell("'"+newVal+"' is not an available choice.  Use ? for a list.");
                else
                {
                    newVal = foundChoice;
                    break;
                }
            }
        }
        if(oldVal.equals(newVal))
            mob.tell("(no change)");
        return newVal;
    }
    
    public void genName(MOB mob, Environmental E, int showNumber, int showFlag) throws IOException
    {
        String newName=CMLib.genEd().prompt(mob,E.Name(),showNumber,showFlag,"Name",false,false);
        if(newName.equals(E.Name())) return;
        if((mob.session()==null)
        ||((!(E instanceof MOB))&&(!(E instanceof Item)))
        ||(!CMLib.flags().isCataloged(E)))
        {
            E.setName(newName);
            return;
        }
        Environmental cataE=CMLib.catalog().getCatalogObj(E);
        if(cataE==null) {
            E.setName(newName);
            CMLib.catalog().changeCatalogUsage(E,false);
            return;
        } else
        if(mob.session().confirm("This object is cataloged.  Changing its name will detach it from the cataloged version, are you sure (y/N)?","N"))
        {
            CMLib.catalog().changeCatalogUsage(E,false);
            E.setName(newName);
        }
    }

    protected void catalogCheckUpdate(MOB mob, Environmental E)
        throws IOException
    {
        if((!CMLib.flags().isCataloged(E))
        ||((!(E instanceof MOB))&&(!(E instanceof Item)))
        ||(mob.session()==null))
        {
        	if(E instanceof MOB)
                E.setMiscText(E.text());
            return;
        }

        StringBuffer diffs=CMLib.catalog().checkCatalogIntegrity(E);
        if((diffs!=null)&&(diffs.length()>0))
        {
        	Environmental origCataE = CMLib.catalog().getCatalogObj(E);
        	Environmental cataE=(Environmental)origCataE.copyOf();
        	CMLib.catalog().changeCatalogUsage(cataE,true);
        	StringBuffer detailedDiff=new StringBuffer("");
        	Vector V=CMParms.parseCommas(diffs.toString(),true);
        	
        	for(int v=0;v<V.size();v++)
        	{
        		String stat=(String)V.elementAt(v);
        		detailedDiff.append("CATALOG:"+stat+":'"+cataE.getStat(stat)+"'\n\r");
        		detailedDiff.append("YOURS  :"+stat+":'"+E.getStat(stat)+"'\n\r");
        	}
        	cataE.destroy();
        	mob.tell("You have modified the following fields: \n\r"+detailedDiff.toString());
        	String message = "This object is cataloged.  Enter U to update the cataloged version, or D to detach this object from the catalog, or C to Cancel (u/d/C)?";
        	String choice = mob.session().choose(message, "UDC", "C");
        	if(choice.equalsIgnoreCase("C"))
        	{
        		E.setMiscText(origCataE.text());
        		E.recoverEnvStats();
        		if(E instanceof MOB)
        		{
        			((MOB)E).recoverCharStats();
        			((MOB)E).recoverMaxState();
        		}
        		CMLib.catalog().changeCatalogUsage(E, true);
        	}
        	else
        	if(choice.equalsIgnoreCase("U"))
	        {
	        	CMLib.catalog().updateCatalog(E);
	            mob.tell("Catalog update complete.");
	            Log.infoOut("BaseGenerics",mob.Name()+" updated catalog "+((E instanceof MOB)?"MOB":"ITEM")+" "+E.Name());
	            E.setMiscText(E.text());
	        }
	        else
        	if(choice.equalsIgnoreCase("D"))
        	{
	            CMLib.catalog().changeCatalogUsage(E,false);
	            E.setMiscText(E.text());
        	}
        	else
        		mob.tell("That wasn't a choice?!");
        }
    }

    protected void genImage(MOB mob, Environmental E, int showNumber, int showFlag) throws IOException
    {   E.setImage(CMLib.genEd().prompt(mob,E.rawImage(),showNumber,showFlag,"MXP Image filename",true,false,"This is the path/filename of your MXP image file for this object."));}

    protected void genCorpseData(MOB mob, DeadBody E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        mob.tell(showNumber+". Corpse Data: '"+E.mobName()+"/"+E.killerName()+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        mob.tell("Dead MOB name: '"+E.mobName()+"'.");
        String newName=mob.session().prompt("Enter a new name\n\r:","");
        if(newName.length()>0) E.setMobName(newName);
        else mob.tell("(no change)");
        mob.tell("Dead MOB Description: '"+E.mobDescription()+"'.");
        newName=mob.session().prompt("Enter a new description\n\r:","");
        if(newName.length()>0) E.setMobDescription(newName);
        else mob.tell("(no change)");
        mob.tell("Is a Players corpse: "+E.playerCorpse());
        newName=mob.session().prompt("Enter a new true/false\n\r:","");
        if((newName.length()>0)&&(newName.equalsIgnoreCase("true")||newName.equalsIgnoreCase("false")))
            E.setPlayerCorpse(Boolean.valueOf(newName.toLowerCase()).booleanValue());
        else mob.tell("(no change)");
        mob.tell("Dead mobs PK flag: "+E.mobPKFlag());
        newName=mob.session().prompt("Enter a new true/false\n\r:","");
        if((newName.length()>0)&&(newName.equalsIgnoreCase("true")||newName.equalsIgnoreCase("false")))
            E.setMobPKFlag(Boolean.valueOf(newName.toLowerCase()).booleanValue());
        else mob.tell("(no change)");
        genCharStats(mob,E.charStats());
        mob.tell("Killers Name: '"+E.killerName()+"'.");
        newName=mob.session().prompt("Enter a new killer\n\r:","");
        if(newName.length()>0) E.setKillerName(newName);
        else mob.tell("(no change)");
        mob.tell("Killer is a player: "+E.killerPlayer());
        newName=mob.session().prompt("Enter a new true/false\n\r:","");
        if((newName.length()>0)&&(newName.equalsIgnoreCase("true")||newName.equalsIgnoreCase("false")))
            E.setKillerPlayer(Boolean.valueOf(newName.toLowerCase()).booleanValue());
        else mob.tell("(no change)");
        mob.tell("Time of death: "+CMLib.time().date2String(E.timeOfDeath()));
        newName=mob.session().prompt("Enter a new value\n\r:","");
        if(newName.length()>0) E.setTimeOfDeath(CMLib.time().string2Millis(newName));
        else mob.tell("(no change)");
        mob.tell("Last message string: "+E.lastMessage());
        newName=mob.session().prompt("Enter a new value\n\r:","");
        if(newName.length()>0) E.setLastMessage(newName);
        else mob.tell("(no change)");
    }

    protected void genAuthor(MOB mob, Area A, int showNumber, int showFlag) throws IOException
    {   A.setAuthorID(CMLib.genEd().prompt(mob,A.getAuthorID(),showNumber,showFlag,"Author",true,false,"Area Author's Name"));}

    protected void genPanelType(MOB mob, ShipComponent.ShipPanel S, int showNumber, int showFlag)
    throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        String componentType=CMStrings.capitalizeAndLower(ShipComponent.ShipPanel.COMPONENT_PANEL_DESC[S.panelType()].toLowerCase());
        mob.tell(showNumber+". Panel Type: '"+componentType+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        boolean continueThis=true;
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(continueThis))
        {
            continueThis=false;
            String newName=mob.session().prompt("Enter a new one (?)\n\r:","");
            if(newName.length()>0)
            {
                if(newName.equalsIgnoreCase("?"))
                {
                    mob.tell("Component Types: "+CMParms.toStringList(ShipComponent.ShipPanel.COMPONENT_PANEL_DESC));
                    continueThis=true;
                }
                else
                {
                    int newType=-1;
                    for(int i=0;i<ShipComponent.ShipPanel.COMPONENT_PANEL_DESC.length;i++)
                        if(ShipComponent.ShipPanel.COMPONENT_PANEL_DESC[i].equalsIgnoreCase(newName))
                            newType=i;
                    if(newType<0)
                    {
                        mob.tell("'"+newName+"' is not recognized.  Try '?' for a list.");
                        continueThis=true;
                    }
                    else
                        S.setPanelType(newType);
                }
            }
            else
                mob.tell("(no change)");
        }
    }

    protected void genCurrency(MOB mob, Area A, int showNumber, int showFlag)
    throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        String currencyName=A.getCurrency().length()==0?"Default":A.getCurrency();
        mob.tell(showNumber+". Currency: '"+currencyName+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        String newName=mob.session().prompt("Enter a new one or 'DEFAULT'\n\r:","");
        if(newName.length()>0)
        {
            if(newName.equalsIgnoreCase("default"))
                A.setCurrency("");
            else
            if((newName.indexOf("=")<0)&&(!CMLib.beanCounter().getAllCurrencies().contains(newName.trim().toUpperCase())))
            {
                Vector V=CMLib.beanCounter().getAllCurrencies();
                mob.tell("'"+newName.trim().toUpperCase()+"' is not a known currency. Existing currencies include: DEFAULT"+CMParms.toStringList(V));
            }
            else
            if(newName.indexOf("=")>=0)
                A.setCurrency(newName.trim());
            else
                A.setCurrency(newName.toUpperCase().trim());
        }
        else
            mob.tell("(no change)");
    }

    protected void genTimeClock(MOB mob, Area A, int showNumber, int showFlag)
    throws IOException
    {

        if((showFlag>0)&&(showFlag!=showNumber)) return;
        TimeClock TC=A.getTimeObj();
        StringBuffer report=new StringBuffer("");
        if(TC==CMLib.time().globalClock())
            report.append("Default -- Can't be changed.");
        else
        {
            report.append(TC.getHoursInDay()+" hrs-day/");
            report.append(TC.getDaysInMonth()+" days-mn/");
            report.append(TC.getMonthsInYear()+" mnths-yr");
        }
        mob.tell(showNumber+". Calendar: '"+report.toString()+"'.");
        if(TC==CMLib.time().globalClock()) return;
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        String newName="";
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(newName.length()==0))
        {
            report=new StringBuffer("\n\rCalendar/Clock settings:\n\r");
            report.append("1. "+TC.getHoursInDay()+" hours per day\n\r");
            report.append("2. Dawn Hour: "+TC.getDawnToDusk()[TimeClock.TIME_DAWN]+"\n\r");
            report.append("3. Day Hour: "+TC.getDawnToDusk()[TimeClock.TIME_DAY]+"\n\r");
            report.append("4. Dusk Hour: "+TC.getDawnToDusk()[TimeClock.TIME_DUSK]+"\n\r");
            report.append("5. Night Hour: "+TC.getDawnToDusk()[TimeClock.TIME_NIGHT]+"\n\r");
            report.append("6. Weekdays: "+CMParms.toStringList(TC.getWeekNames())+"\n\r");
            report.append("7. Months: "+CMParms.toStringList(TC.getMonthNames())+"\n\r");
            report.append("8. Year Title(s): "+CMParms.toStringList(TC.getYearNames()));
            mob.tell(report.toString());
            newName=mob.session().prompt("Enter one to change:","");
            if(newName.length()==0) break;
            int which=CMath.s_int(newName);

            if((which<0)||(which>8))
                mob.tell("Invalid: "+which+"");
            else
            if(which<=5)
            {
                newName="";
                String newNum=mob.session().prompt("Enter a new number:","");
                int val=CMath.s_int(newNum);
                if(newNum.length()==0)
                    mob.tell("(no change)");
                else
                switch(which)
                {
                case 1:
                    TC.setHoursInDay(val);
                    break;
                case 2:
                    TC.getDawnToDusk()[TimeClock.TIME_DAWN]=val;
                    break;
                case 3:
                    if((val>=0)&&(TC.getDawnToDusk()[TimeClock.TIME_DAWN]>=val))
                        mob.tell("That value is before the dawn!");
                    else
                        TC.getDawnToDusk()[TimeClock.TIME_DAY]=val;
                    break;
                case 4:
                    if((val>=0)&&(TC.getDawnToDusk()[TimeClock.TIME_DAWN]>=val))
                        mob.tell("That value is before the dawn!");
                    else
                    if((val>=0)&&(TC.getDawnToDusk()[TimeClock.TIME_DAY]>=val))
                        mob.tell("That value is before the day!");
                    else
                        TC.getDawnToDusk()[TimeClock.TIME_DUSK]=val;
                    break;
                case 5:
                    if((val>=0)&&(TC.getDawnToDusk()[TimeClock.TIME_DAWN]>=val))
                        mob.tell("That value is before the dawn!");
                    else
                    if((val>=0)&&(TC.getDawnToDusk()[TimeClock.TIME_DAY]>=val))
                        mob.tell("That value is before the day!");
                    else
                    if((val>=0)&&(TC.getDawnToDusk()[TimeClock.TIME_DUSK]>=val))
                        mob.tell("That value is before the dusk!");
                    else
                        TC.getDawnToDusk()[TimeClock.TIME_NIGHT]=val;
                    break;
                }
            }
            else
            {
                newName="";
                String newNum=mob.session().prompt("Enter a new list (comma delimited)\n\r:","");
                if(newNum.length()==0)
                    mob.tell("(no change)");
                else
                switch(which)
                {
                case 6:
                    TC.setDaysInWeek(CMParms.toStringArray(CMParms.parseCommas(newNum,true)));
                    break;
                case 7:
                    TC.setMonthsInYear(CMParms.toStringArray(CMParms.parseCommas(newNum,true)));
                    break;
                case 8:
                    TC.setYearNames(CMParms.toStringArray(CMParms.parseCommas(newNum,true)));
                    break;
                }
            }
        }
        TC.save();
    }

    protected void genClan(MOB mob, MOB E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag<=0)||(showFlag==showNumber))
        {
            mob.tell(showNumber+". Clan (ID): '"+E.getClanID()+"'.");
            if((showFlag==showNumber)||(showFlag<=-999))
            {
                String newName=mob.session().prompt("Enter a new one (null)\n\r:","");
                if(newName.equalsIgnoreCase("null"))
                    E.setClanID("");
                else
                if(newName.length()>0)
                {
                    E.setClanID(newName);
                    E.setClanRole(Clan.POS_MEMBER);
                }
                else
                    mob.tell("(no change)");
            }
        }
        if(((showFlag<=0)||(showFlag==showNumber))
           &&(!E.isMonster())
           &&(E.getClanID().length()>0)
           &&(CMLib.clans().getClan(E.getClanID())!=null))
        {

            Clan C=CMLib.clans().getClan(E.getClanID());
            mob.tell(showNumber+". Clan (Role): '"+CMLib.clans().getRoleName(C.getGovernment(),E.getClanRole(),true,false)+"'.");
            if((showFlag==showNumber)||(showFlag<=-999))
            {
                String newName=mob.session().prompt("Enter a new one\n\r:","");
                if(newName.length()>0)
                {
                    int newRole=-1;
                    for(int i=0;i<Clan.ROL_DESCS[C.getGovernment()].length;i++)
                        if(newName.equalsIgnoreCase(Clan.ROL_DESCS[C.getGovernment()][i]))
                        {
                            newRole=(int)CMath.pow(2,i-1);
                            break;
                        }
                    if(newRole<0)
                        mob.tell("That role is invalid. Try: "+CMParms.toStringList(Clan.ROL_DESCS[C.getGovernment()]));
                    else
                        E.setClanRole(newRole);
                }
                else
                    mob.tell("(no change)");
            }
        }
    }

    protected void genDeity(MOB mob, MOB E, int showNumber, int showFlag)
    throws IOException
    {
        if((showFlag<=0)||(showFlag==showNumber))
        {
            mob.tell(showNumber+". Deity (ID): '"+E.getWorshipCharID()+"'.");
            if((showFlag==showNumber)||(showFlag<=-999))
            {
                String newName=mob.session().prompt("Enter a new one (null)\n\r:","");
                if(newName.equalsIgnoreCase("null"))
                    E.setWorshipCharID("");
                else
                if(newName.length()>0)
                {
                    if(CMLib.map().getDeity(newName)==null)
                        mob.tell("That deity does not exist.");
                    else
                        E.setWorshipCharID(CMLib.map().getDeity(newName).Name());
                }
                else
                    mob.tell("(no change)");
            }
        }
    }

    protected void genArchivePath(MOB mob, Area E, int showNumber, int showFlag) throws IOException
    {   E.setArchivePath(CMLib.genEd().prompt(mob,E.getArchivePath(),showNumber,showFlag,"Archive Path",true,false,"Path/filename for EXPORT AREA command.  Enter NULL for default."));}

    public Room changeRoomType(Room R, Room newRoom)
    {
        if((R==null)||(newRoom==null)) return R;
        synchronized(("SYNC"+R.roomID()).intern())
        {
            R=CMLib.map().getRoom(R);
            Room oldR=R;
            R=newRoom;
            Vector oldBehavsNEffects=new Vector();
            for(int a=oldR.numEffects()-1;a>=0;a--)
            {
                Ability A=oldR.fetchEffect(a);
                if(A!=null)
                {
                    if(!A.canBeUninvoked())
                    {
                        oldBehavsNEffects.addElement(A);
                        oldR.delEffect(A);
                    }
                    else
                        A.unInvoke();
                }
            }
            for(int b=0;b<oldR.numBehaviors();b++)
            {
                Behavior B=oldR.fetchBehavior(b);
                if(B!=null)
                    oldBehavsNEffects.addElement(B);
            }
            CMLib.threads().deleteTick(oldR,-1);
            R.setRoomID(oldR.roomID());
            Area A=oldR.getArea();
            if(A!=null) A.delProperRoom(oldR);
            R.setArea(A);
            for(int d=0;d<R.rawDoors().length;d++)
                R.rawDoors()[d]=oldR.rawDoors()[d];
            for(int d=Directions.NUM_DIRECTIONS()-1;d>=0;d--)
                R.setRawExit(d,oldR);
            R.setDisplayText(oldR.displayText());
            R.setDescription(oldR.description());
            if(R.image().equalsIgnoreCase(CMProps.getDefaultMXPImage(oldR))) R.setImage(null);
            if((R instanceof GridLocale)&&(oldR instanceof GridLocale))
            {
                ((GridLocale)R).setXGridSize(((GridLocale)oldR).xGridSize());
                ((GridLocale)R).setYGridSize(((GridLocale)oldR).yGridSize());
                ((GridLocale)R).clearGrid(null);
            }
            Vector allmobs=new Vector();
            int skip=0;
            while(oldR.numInhabitants()>(skip))
            {
                MOB M=oldR.fetchInhabitant(skip);
                if(M.savable())
                {
                    if(!allmobs.contains(M))
                        allmobs.addElement(M);
                    oldR.delInhabitant(M);
                }
                else
                if(oldR!=R)
                {
                    oldR.delInhabitant(M);
                    R.bringMobHere(M,true);
                }
                else
                    skip++;
            }
            Vector allitems=new Vector();
            while(oldR.numItems()>0)
            {
                Item I=oldR.fetchItem(0);
                if(!allitems.contains(I))
                    allitems.addElement(I);
                oldR.delItem(I);
            }

            for(int i=0;i<allitems.size();i++)
            {
                Item I=(Item)allitems.elementAt(i);
                if(!R.isContent(I))
                {
                    if(I.subjectToWearAndTear())
                        I.setUsesRemaining(100);
                    I.recoverEnvStats();
                    R.addItem(I);
                    R.recoverRoomStats();
                }
            }
            for(int m=0;m<allmobs.size();m++)
            {
                MOB M=(MOB)allmobs.elementAt(m);
                if(!R.isInhabitant(M))
                {
                    MOB M2=(MOB)M.copyOf();
                    M2.setStartRoom(R);
                    M2.setLocation(R);
                    long rejuv=Tickable.TICKS_PER_RLMIN+Tickable.TICKS_PER_RLMIN+(Tickable.TICKS_PER_RLMIN/2);
                    if(rejuv>(Tickable.TICKS_PER_RLMIN*20)) rejuv=(Tickable.TICKS_PER_RLMIN*20);
                    M2.envStats().setRejuv((int)rejuv);
                    M2.recoverCharStats();
                    M2.recoverEnvStats();
                    M2.recoverMaxState();
                    M2.resetToMaxState();
                    M2.bringToLife(R,true);
                    R.recoverRoomStats();
                    M.destroy();
                }
            }

            try
            {
                for(Enumeration r=CMLib.map().rooms();r.hasMoreElements();)
                {
                    Room R2=(Room)r.nextElement();
                    for(int d=0;d<R2.rawDoors().length;d++)
                        if(R2.rawDoors()[d]==oldR)
                        {
                            R2.rawDoors()[d]=R;
                            if(R2 instanceof GridLocale)
                                ((GridLocale)R2).buildGrid();
                        }
                }
            }catch(NoSuchElementException e){}
            try
            {
                for(Enumeration e=CMLib.players().players();e.hasMoreElements();)
                {
                    MOB M=(MOB)e.nextElement();
                    if(M.getStartRoom()==oldR)
                        M.setStartRoom(R);
                    else
                    if(M.location()==oldR)
                        M.setLocation(R);
                }
            }catch(NoSuchElementException e){}
            R.getArea().fillInAreaRoom(R);
            for(int i=0;i<oldBehavsNEffects.size();i++)
            {
                if(oldBehavsNEffects.elementAt(i) instanceof Behavior)
                    R.addBehavior((Behavior)oldBehavsNEffects.elementAt(i));
                else
                    R.addNonUninvokableEffect((Ability)oldBehavsNEffects.elementAt(i));
            }
            CMLib.database().DBUpdateRoom(R);
            CMLib.database().DBUpdateMOBs(R);
            CMLib.database().DBUpdateItems(R);
            oldR.destroy();
            R.getArea().addProperRoom(R); // necessary because of the destroy
            R.setImage(R.rawImage());
            R.startItemRejuv();
        }
        return R;
    }

    protected Room genRoomType(MOB mob, Room R, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return R;
        mob.tell(showNumber+". Type: '"+CMClass.classID(R)+"'");
        if((showFlag!=showNumber)&&(showFlag>-999)) return R;
        String newName="";
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(newName.length()==0))
        {
            newName=mob.session().prompt("Enter a new one (?)\n\r:","");
            if(newName.trim().equals("?"))
            {
                mob.tell(CMLib.lister().reallyList2Cols(CMClass.locales(),-1,null).toString()+"\n\r");
                newName="";
            }
            else
            if(newName.length()>0)
            {
                Room newRoom=CMClass.getLocale(newName);
                if(newRoom==null)
                    mob.tell("'"+newName+"' does not exist. No Change.");
                else
                if(mob.session().confirm("This will change the room type of room "+R.roomID()+". It will automatically save any mobs and items in this room permanently.  Are you absolutely sure (y/N)?","N"))
                    R=changeRoomType(R,newRoom);
                R.recoverRoomStats();
            }
            else
            {
                mob.tell("(no change)");
                break;
            }
        }
        return R;
    }

    public void genDescription(MOB mob, Environmental E, int showNumber, int showFlag) throws IOException
    {   E.setDescription(CMLib.genEd().prompt(mob,E.description(),showNumber,showFlag,"Description",true,true,null));}

    protected void genNotes(MOB mob, MOB E, int showNumber, int showFlag) throws IOException
    {
        if(E.playerStats()!=null)
        E.playerStats().setNotes(CMLib.genEd().prompt(mob,E.playerStats().notes(),showNumber,showFlag,"Private notes",true,false,null));
    }

    protected void genPassword(MOB mob, MOB E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        mob.tell(showNumber+". Password: ********.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        String newName=mob.session().prompt("Enter a new one to reset\n\r:","");
        if((newName.length()>0)&&(E.playerStats()!=null))
        {
            E.playerStats().setPassword(newName);
            CMLib.database().DBUpdatePassword(E);
        }
        else
            mob.tell("(no change)");
    }

    protected void genEmail(MOB mob, MOB E, int showNumber, int showFlag) throws IOException
    {
        if(E.playerStats()!=null)
        E.playerStats().setEmail(CMLib.genEd().prompt(mob,E.playerStats().getEmail(),showNumber,showFlag,"Email",true,false,null));
    }

    public void genDisplayText(MOB mob, Environmental E, int showNumber, int showFlag) throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        if(mob.session()!=null)
        	mob.session().rawPrintln(showNumber+". Display: '"+E.displayText()+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        String newName=null;
        if(E instanceof Item)
            newName=mob.session().prompt("Enter something new (null == blended)\n\r:","");
        else
        if(E instanceof Exit)
            newName=mob.session().prompt("Enter something new (null == see-through)\n\r:","");
        else
            newName=mob.session().prompt("Enter something new (null = empty)\n\r:","");
        if(newName.length()>0)
        {
            if(newName.trim().equalsIgnoreCase("null"))
                newName="";
            E.setDisplayText(newName);
        }
        else
            mob.tell("(no change)");
        if((E instanceof Item)&&(E.displayText().length()==0))
            mob.tell("(blended)");
    }

    protected void genClosedText(MOB mob, Exit E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        if(E instanceof Item)
            mob.tell(showNumber+". Exit Closed Text: '"+E.closedText()+"'.");
        else
            mob.tell(showNumber+". Closed Text: '"+E.closedText()+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        String newName=mob.session().prompt("Enter something new (null=blank)\n\r:","");
        if(newName.equals("null"))
            E.setExitParams(E.doorName(),E.closeWord(),E.openWord(),"");
        else
        if(newName.length()>0)
            E.setExitParams(E.doorName(),E.closeWord(),E.openWord(),newName);
        else
            mob.tell("(no change)");
    }
    protected void genDoorName(MOB mob, Exit E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        if(E instanceof Item)
            mob.tell(showNumber+". Exit Direction: '"+E.doorName()+"'.");
        else
            mob.tell(showNumber+". Door Name: '"+E.doorName()+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        String newName=mob.session().prompt("Enter something new\n\r:","");
        if(newName.length()>0)
            E.setExitParams(newName,E.closeWord(),E.openWord(),E.closedText());
        else
            mob.tell("(no change)");
    }

    protected void genBurnout(MOB mob, Light E, int showNumber, int showFlag)
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        mob.tell(showNumber+". Is destroyed after burnout: '"+E.destroyedWhenBurnedOut()+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        E.setDestroyedWhenBurntOut(!E.destroyedWhenBurnedOut());
    }

    protected void genOpenWord(MOB mob, Exit E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        mob.tell(showNumber+". Open Word: '"+E.openWord()+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        String newName=mob.session().prompt("Enter something new\n\r:","");
        if(newName.length()>0)
            E.setExitParams(E.doorName(),E.closeWord(),newName,E.closedText());
        else
            mob.tell("(no change)");
    }

    protected void genSubOps(MOB mob, Area A, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        String newName="Q";
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(newName.length()>0))
        {
            mob.tell(showNumber+". Area staff names: "+A.getSubOpList());
            if((showFlag!=showNumber)&&(showFlag>-999)) return;
            newName=mob.session().prompt("Enter a name to add or remove\n\r:","");
            if(newName.length()>0)
            {
                if(A.amISubOp(newName))
                {
                    A.delSubOp(newName);
                    mob.tell("Staff removed.");
                }
                else
                if(CMLib.database().DBUserSearch(null,newName))
                {
                    A.addSubOp(newName);
                    mob.tell("Staff added.");
                }
                else
                    mob.tell("'"+newName+"' is not recognized as a valid user name.");
            }
        }
    }

    protected void genParentAreas(MOB mob, Area A, int showNumber, int showFlag)
            throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        String newArea="Q";
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(newArea.length()>0))
        {
            mob.tell(showNumber+". Parent Areas: "+A.getParentsList());
            if((showFlag!=showNumber)&&(showFlag>-999)) return;
            newArea=mob.session().prompt("Enter an area name to add or remove\n\r:","");
            if(newArea.length()>0)
            {
                Area lookedUp=CMLib.map().getArea(newArea);
                if(lookedUp!=null)
                {
                    if (lookedUp.isChild(A))
                    {
                        // this new area is already a parent to A,
                        // they must want it removed
                        A.removeParent(lookedUp);
                        lookedUp.removeChild(A);
                        mob.tell("Enter an area name to add or remove\n\r:");
                    }
                    else
                    {
                        if(A.canParent(lookedUp))
                        {
                            A.addParent(lookedUp);
                            lookedUp.addChild(A);
                            mob.tell("Area '"+lookedUp.Name()+"' added.");
                        }
                        else
                        {
                            mob.tell("Area '"+lookedUp.Name()+"" +"' cannot be added because this would create a circular reference.");
                        }
                    }
                }
                else
                    mob.tell("'"+newArea+"' is not recognized as a valid area name.");
            }
        }
    }

    protected void genChildAreas(MOB mob, Area A, int showNumber, int showFlag)
            throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        String newArea="Q";
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(newArea.length()>0))
        {
            mob.tell(showNumber+". Area Children: "+A.getChildrenList());
            if((showFlag!=showNumber)&&(showFlag>-999)) return;
            newArea=mob.session().prompt("Enter an area name to add or remove\n\r:","");
            if(newArea.length()>0)
            {
                Area lookedUp=CMLib.map().getArea(newArea);
                if(lookedUp!=null)
                {
                    if (lookedUp.isParent(A))
                    {
                        // this area is already a child to A, they must want it removed
                        A.removeChild(lookedUp);
                        lookedUp.removeParent(A);
                        mob.tell("Enter an area name to add or remove\n\r:");
                    }
                    else
                    {
                        if(A.canChild(lookedUp))
                        {
                            A.addChild(lookedUp);
                            lookedUp.addParent(A);
                            mob.tell("Area '"+ lookedUp.Name()+"' added.");
                        }
                        else
                        {
                            mob.tell("Area '"+ lookedUp.Name()+"" +"' cannot be added because this would create a circular reference.");
                        }
                    }
                }
                else
                    mob.tell("'"+newArea+"' is not recognized as a valid area name.");
            }
        }
    }

    protected void genCloseWord(MOB mob, Exit E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        mob.tell(showNumber+". Close Word: '"+E.closeWord()+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        String newName=mob.session().prompt("Enter something new\n\r:","");
        if(newName.length()>0)
            E.setExitParams(E.doorName(),newName,E.openWord(),E.closedText());
        else
            mob.tell("(no change)");
    }

    protected void genExitMisc(MOB mob, Exit E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        if(E.hasALock())
        {
            E.setReadable(false);
            mob.tell(showNumber+". Assigned Key Item: '"+E.keyName()+"'.");
            if((showFlag!=showNumber)&&(showFlag>-999)) return;
            String newName=mob.session().prompt("Enter something new (null=blank)\n\r:","");
            if(newName.equalsIgnoreCase("null"))
                E.setKeyName("");
            else
            if(newName.length()>0)
                E.setKeyName(newName);
            else
                mob.tell("(no change)");
        }
        else
        {
            if((showFlag!=showNumber)&&(showFlag>-999))
            {
                if(!E.isReadable())
                    mob.tell(showNumber+". Door not is readable.");
                else
                    mob.tell(showNumber+". Door is readable: "+E.readableText());
                return;
            }
            else
            if(genGenericPrompt(mob,"Is this door ",E.isReadable()))
            {
                E.setReadable(true);
                mob.tell("\n\rText: '"+E.readableText()+"'.");
                String newName=mob.session().prompt("Enter something new (null=blank)\n\r:","");
                if(newName.equalsIgnoreCase("null"))
                    E.setReadableText("");
                else
                if(newName.length()>0)
                    E.setReadableText(newName);
                else
                    mob.tell("(no change)");
            }
            else
                E.setReadable(false);
        }
    }

    protected void genReadable1(MOB mob, Item E, int showNumber, int showFlag)
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;

        if((E instanceof Wand)
         ||(E instanceof SpellHolder)
         ||(E instanceof Light)
         ||(E instanceof Container)
         ||(E instanceof Ammunition)
         ||((E instanceof ClanItem)
             &&((((ClanItem)E).ciType()==ClanItem.CI_GATHERITEM)
                 ||(((ClanItem)E).ciType()==ClanItem.CI_CRAFTITEM)
                 ||(((ClanItem)E).ciType()==ClanItem.CI_SPECIALAPRON)))
         ||(E instanceof Key))
            CMLib.flags().setReadable(E,false);
        else
        if((CMClass.classID(E).endsWith("Readable"))
        ||(E instanceof Recipe)
        ||(E instanceof com.planet_ink.coffee_mud.Items.interfaces.Map))
            CMLib.flags().setReadable(E,true);
        else
        if((showFlag!=showNumber)&&(showFlag>-999))
            mob.tell(showNumber+". Item is readable: "+CMLib.flags().isReadable(E)+"");
        else
            CMLib.flags().setReadable(E,genGenericPrompt(mob,showNumber+". Is this item readable",CMLib.flags().isReadable(E)));
    }

    protected void genReadable2(MOB mob, Item E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;

        if((CMLib.flags().isReadable(E))
         ||(E instanceof SpellHolder)
         ||(E instanceof Ammunition)
         ||(E instanceof Recipe)
         ||(E instanceof Exit)
         ||(E instanceof Wand)
         ||(E instanceof ClanItem)
         ||(E instanceof Light)
         ||(E instanceof Key))
        {
            boolean ok=false;
            while((mob.session()!=null)&&(!mob.session().killFlag())&&(!ok))
            {
                if(CMClass.classID(E).endsWith("SuperPill"))
                {
                    mob.tell(showNumber+". Assigned Spell or Parameters: '"+E.readableText()+"'.");
                    ok=true;
                }
                else
                if(E instanceof SpellHolder)
                    mob.tell(showNumber+". Assigned Spell(s) ( ';' delimited)\n: '"+E.readableText()+"'.");
                else
                if(E instanceof Ammunition)
                {
                    mob.tell(showNumber+". Ammunition type: '"+E.readableText()+"'.");
                    ok=true;
                }
                else
                if(E instanceof Exit)
                {
                    mob.tell(showNumber+". Assigned Room IDs: '"+E.readableText()+"'.");
                    ok=true;
                }
                else
                if(E instanceof Wand)
                    mob.tell(showNumber+". Assigned Spell Name: '"+E.readableText()+"'.");
                else
                if(E instanceof Key)
                {
                    mob.tell(showNumber+". Assigned Key Code: '"+E.readableText()+"'.");
                    ok=true;
                }
                else
                if(E instanceof com.planet_ink.coffee_mud.Items.interfaces.Map)
                {
                    mob.tell(showNumber+". Assigned Map Area(s): '"+E.readableText()+"'.");
                    ok=true;
                }
                else
                if(E instanceof Light)
                {
                    mob.tell(showNumber+". Light duration (before burn out): '"+CMath.s_int(E.readableText())+"'.");
                    ok=true;
                }
                else
                {
                    mob.tell(showNumber+". Assigned Read Text: '"+E.readableText()+"'.");
                    ok=true;
                }

                if((showFlag!=showNumber)&&(showFlag>-999)) return;
                String newName=null;

                if((E instanceof Wand)
                ||((E instanceof SpellHolder)&&(!(CMClass.classID(E).endsWith("SuperPill")))))
                {
                    newName=mob.session().prompt("Enter something new (?)\n\r:","");
                    if(newName.length()==0)
                        ok=true;
                    else
                    {
                        if(newName.equalsIgnoreCase("?"))
                            mob.tell(CMLib.lister().reallyList(CMClass.abilities(),-1).toString());
                        else
                        if(E instanceof Wand)
                        {
                            if(CMClass.getAbility(newName)!=null)
                                ok=true;
                            else
                                mob.tell("'"+newName+"' is not recognized.  Try '?'.");
                        }
                        else
                        if(E instanceof SpellHolder)
                        {
                            String oldName=newName;
                            if(!newName.endsWith(";")) newName+=";";
                            int x=newName.indexOf(";");
                            while(x>=0)
                            {
                                String spellName=newName.substring(0,x).trim();
                                if(CMClass.getAbility(spellName)!=null)
                                    ok=true;
                                else
                                {
                                    mob.tell("'"+spellName+"' is not recognized.  Try '?'.");
                                    break;
                                }
                                newName=newName.substring(x+1).trim();
                                x=newName.indexOf(";");
                            }
                            newName=oldName;
                        }
                    }
                }
                else
                    newName=mob.session().prompt("Enter something new (null=blank)\n\r:","");

                if(ok)
                {
                    if(newName.equalsIgnoreCase("null"))
                        E.setReadableText("");
                    else
                    if(newName.length()>0)
                        E.setReadableText(newName);
                    else
                        mob.tell("(no change)");
                }
            }
        }
        else
        if(E instanceof Drink)
        {
            mob.session().println(showNumber+". Current liquid type: "+RawMaterial.RESOURCE_DESCS[((Drink)E).liquidType()&RawMaterial.RESOURCE_MASK]);
            if((showFlag!=showNumber)&&(showFlag>-999)) return;
            boolean q=false;
            while((mob.session()!=null)&&(!mob.session().killFlag())&&(!q))
            {
                String newType=mob.session().prompt("Enter a new type (?)\n\r:",RawMaterial.RESOURCE_DESCS[((Drink)E).liquidType()&RawMaterial.RESOURCE_MASK]);
                if(newType.equals("?"))
                {
                    StringBuffer say=new StringBuffer("");
                    for(int i=0;i<RawMaterial.RESOURCE_DESCS.length-1;i++)
                        if((RawMaterial.RESOURCE_DATA[i][0]&RawMaterial.MATERIAL_MASK)==RawMaterial.MATERIAL_LIQUID)
                            say.append(RawMaterial.RESOURCE_DESCS[i]+", ");
                    mob.tell(say.toString().substring(0,say.length()-2));
                    q=false;
                }
                else
                {
                    q=true;
                    int newValue=-1;
                    for(int i=0;i<RawMaterial.RESOURCE_DESCS.length-1;i++)
                        if((RawMaterial.RESOURCE_DATA[i][0]&RawMaterial.MATERIAL_MASK)==RawMaterial.MATERIAL_LIQUID)
                            if(newType.equalsIgnoreCase(RawMaterial.RESOURCE_DESCS[i]))
                                newValue=RawMaterial.RESOURCE_DATA[i][0];
                    if(newValue>=0)
                        ((Drink)E).setLiquidType(newValue);
                    else
                        mob.tell("(no change)");
                }
            }
        }
    }

    protected void genRecipe(MOB mob, Recipe E, int showNumber, int showFlag)
    throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        String prompt="Recipe Data ";
        mob.tell(showNumber+". "+prompt+": "+E.getCommonSkillID()+".");
        mob.tell(CMStrings.padRight(" ",(""+showNumber).length()+2+prompt.length())+": "+CMStrings.replaceAll(E.getRecipeCodeLine(),"\t",",")+".");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        while(!mob.session().killFlag())
        {
            String newName=mob.session().prompt("Enter new skill id (?)\n\r:","");
            if(newName.equalsIgnoreCase("?"))
            {
                StringBuffer str=new StringBuffer("");
                Ability A=null;
                for(Enumeration e=CMClass.abilities();e.hasMoreElements();)
                {
                    A=(Ability)e.nextElement();
                    if(((A.classificationCode()&Ability.ALL_ACODES)==Ability.ACODE_COMMON_SKILL)
                    &&((A.classificationCode()&Ability.ALL_DOMAINS)==Ability.DOMAIN_CRAFTINGSKILL))
                        str.append(A.ID()+"\n\r");
                }
                mob.tell("\n\rCommon Skills:\n\r"+str.toString()+"\n\r");
            }
            else
            if((newName.length()>0)
            &&(CMClass.getAbility(newName)!=null)
            &&((CMClass.getAbility(newName).classificationCode()&Ability.ALL_ACODES)==Ability.ACODE_COMMON_SKILL))
            {
                E.setCommonSkillID(CMClass.getAbility(newName).ID());
                break;
            }
            else
            if(newName.length()>0)
                mob.tell("'"+newName+"' is not a valid common skill.  Try ?.");
            else
            {
                mob.tell("(no change)");
                break;
            }
        }
        String newName=mob.session().prompt("Enter new data line\n\r:","");
        if(newName.length()>0)
            E.setRecipeCodeLine(CMStrings.replaceAll(newName,",","\t"));
        else
            mob.tell("(no change)");
    }

    protected void genGettable(MOB mob, Item E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        if(E instanceof Potion)
            ((Potion)E).setDrunk(false);

        String c="Q";
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(!c.equals("\n")))
        {
            mob.session().println(showNumber+". A) Is Gettable   : "+(!CMath.bset(E.baseEnvStats().sensesMask(),EnvStats.SENSE_ITEMNOTGET)));
            mob.session().println("    B) Is Droppable  : "+(!CMath.bset(E.baseEnvStats().sensesMask(),EnvStats.SENSE_ITEMNODROP)));
            mob.session().println("    C) Is Removable  : "+(!CMath.bset(E.baseEnvStats().sensesMask(),EnvStats.SENSE_ITEMNOREMOVE)));
            mob.session().println("    D) Non-Locatable : "+(((E.baseEnvStats().sensesMask()&EnvStats.SENSE_UNLOCATABLE)>0)?"true":"false"));
            if(E instanceof Weapon)
                mob.session().println("    E) Is Two-Handed : "+E.rawLogicalAnd());
            if((showFlag!=showNumber)&&(showFlag>-999)) return;
            c=mob.session().choose("Enter one to change, or ENTER when done:","ABCDE\n","\n").toUpperCase();
            switch(Character.toUpperCase(c.charAt(0)))
            {
            case 'A': CMLib.flags().setGettable(E,(CMath.bset(E.baseEnvStats().sensesMask(),EnvStats.SENSE_ITEMNOTGET))); break;
            case 'B': CMLib.flags().setDroppable(E,(CMath.bset(E.baseEnvStats().sensesMask(),EnvStats.SENSE_ITEMNODROP))); break;
            case 'C': CMLib.flags().setRemovable(E,(CMath.bset(E.baseEnvStats().sensesMask(),EnvStats.SENSE_ITEMNOREMOVE))); break;
            case 'D': if((E.baseEnvStats().sensesMask()&EnvStats.SENSE_UNLOCATABLE)>0)
                          E.baseEnvStats().setSensesMask(E.baseEnvStats().sensesMask()-EnvStats.SENSE_UNLOCATABLE);
                      else
                          E.baseEnvStats().setSensesMask(E.baseEnvStats().sensesMask()|EnvStats.SENSE_UNLOCATABLE);
                      break;
            case 'E': if(E instanceof Weapon)
                          E.setRawLogicalAnd(!E.rawLogicalAnd());
                      break;
            }
        }
    }

    protected void toggleDispositionMask(EnvStats E, int mask)
    {
        int current=E.disposition();
        if((current&mask)==0)
            E.setDisposition(current|mask);
        else
            E.setDisposition(current&((int)(EnvStats.ALLMASK-mask)));
    }

    protected void genDisposition(MOB mob, EnvStats E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        int[] disps={EnvStats.IS_INVISIBLE,
                     EnvStats.IS_HIDDEN,
                     EnvStats.IS_NOT_SEEN,
                     EnvStats.IS_BONUS,
                     EnvStats.IS_GLOWING,
                     EnvStats.IS_LIGHTSOURCE,
                     EnvStats.IS_FLYING,
                     EnvStats.IS_CLIMBING,
                     EnvStats.IS_SNEAKING,
                     EnvStats.IS_SWIMMING,
                     EnvStats.IS_EVIL,
                     EnvStats.IS_GOOD};
        String[] briefs={"invisible",
                         "hide",
                         "unseen",
                         "magical",
                         "glowing",
                         "lightsrc",
                         "fly",
                         "climb",
                         "sneak",
                         "swimmer",
                         "evil",
                         "good"};
        if((showFlag!=showNumber)&&(showFlag>-999))
        {
            StringBuffer buf=new StringBuffer(showNumber+". Dispositions: ");
            for(int i=0;i<disps.length;i++)
            {
                int mask=disps[i];
                if((E.disposition()&mask)!=0)
                    buf.append(briefs[i]+" ");
            }
            mob.tell(buf.toString());
            return;
        }
        String c="Q";
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(!c.equals("\n")))
        {
            char letter='A';
            String letters="";
            for(int i=0;i<disps.length;i++)
            {
                int mask=disps[i];
                for(int num=0;num<EnvStats.IS_DESCS.length;num++)
                    if(mask==CMath.pow(2,num))
                    {
                        mob.session().println("    "+letter+") "+CMStrings.padRight(EnvStats.IS_DESCS[num],20)+":"+((E.disposition()&mask)!=0));
                        letters+=letter;
                        break;
                    }
                letter++;
            }
            c=mob.session().choose("Enter one to change, or ENTER when done: ",letters+"\n","\n").toUpperCase();
            letter='A';
            for(int i=0;i<disps.length;i++)
            {
                int mask=disps[i];
                if(letter==Character.toUpperCase(c.charAt(0)))
                {
                    toggleDispositionMask(E,mask);
                    break;
                }
                letter++;
            }
        }
    }

    public boolean genGenericPrompt(MOB mob, String prompt, boolean val)
    {
        try
        {
            prompt=CMStrings.padRight(prompt,35);
            if(val)
                prompt+="(Y/n): ";
            else
                prompt+="(y/N): ";

            return mob.session().confirm(prompt,val?"Y":"N");
        }
        catch(IOException e)
        {
            return val;
        }
    }

    protected void toggleSensesMask(EnvStats E, int mask)
    {
        int current=E.sensesMask();
        if((current&mask)==0)
            E.setSensesMask(current|mask);
        else
            E.setSensesMask(current&((int)(EnvStats.ALLMASK-mask)));
    }

    protected void toggleClimateMask(Area A, int mask)
    {
        int current=A.climateType();
        if((current&mask)==0)
            A.setClimateType(current|mask);
        else
            A.setClimateType(current&((int)(EnvStats.ALLMASK-mask)));
    }



    protected void genClimateType(MOB mob, Area A, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        String c="Q";
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(!c.equals("\n")))
        {
            mob.session().println(""+showNumber+". Climate:");
            mob.session().println("    R) Wet and Rainy    : "+((A.climateType()&Area.CLIMASK_WET)>0));
            mob.session().println("    H) Excessively hot  : "+((A.climateType()&Area.CLIMASK_HOT)>0));
            mob.session().println("    C) Excessively cold : "+((A.climateType()&Area.CLIMASK_COLD)>0));
            mob.session().println("    W) Very windy       : "+((A.climateType()&Area.CLIMATE_WINDY)>0));
            mob.session().println("    D) Very dry         : "+((A.climateType()&Area.CLIMASK_DRY)>0));
            if((showFlag!=showNumber)&&(showFlag>-999)) return;
            c=mob.session().choose("Enter one to change, or ENTER when done: ","RHCWD\n","\n").toUpperCase();
            switch(c.charAt(0))
            {
            case 'C': toggleClimateMask(A,Area.CLIMASK_COLD); break;
            case 'H': toggleClimateMask(A,Area.CLIMASK_HOT); break;
            case 'R': toggleClimateMask(A,Area.CLIMASK_WET); break;
            case 'W': toggleClimateMask(A,Area.CLIMATE_WINDY); break;
            case 'D': toggleClimateMask(A,Area.CLIMASK_DRY); break;
            }
        }
    }

    protected void genCharStats(MOB mob, CharStats E)
    throws IOException
    {
        String c="Q";
        String commandStr="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()=+-";
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(!c.equals("\n")))
        {
            for(int i=0;i<CharStats.STAT_DESCS.length;i++)
                if(i!=CharStats.STAT_GENDER)
                    mob.session().println("    "+commandStr.charAt(i)+") "+CMStrings.padRight(CharStats.STAT_DESCS[i],20)+":"+((E.getStat(i))));
            c=mob.session().choose("Enter one to change, or ENTER when done: ",commandStr.substring(0,CharStats.STAT_DESCS.length)+"\n","\n").toUpperCase();
            int num=commandStr.indexOf(c);
            if(num>=0)
            {
                String newVal=mob.session().prompt("Enter a new value:  "+CharStats.STAT_DESCS[num]+" ("+E.getStat(num)+"): ","");
                if(((CMath.s_int(newVal)>0)||(newVal.trim().equals("0")))
                &&(num!=CharStats.STAT_GENDER))
                    E.setStat(num,CMath.s_int(newVal));
                else
                    mob.tell("(no change)");
            }
        }
    }


    protected void genCharStats(MOB mob, MOB E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        if((showFlag!=showNumber)&&(showFlag>-999))
        {
            StringBuffer buf=new StringBuffer(showNumber+". Stats: ");
            for(int i=0;i<CharStats.NUM_BASE_STATS;i++)
                buf.append(CharStats.STAT_ABBR[i]+":"+E.baseCharStats().getStat(i)+" ");
            mob.tell(buf.toString());
            return;
        }
        String c="Q";
        String commandStr="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()=+-";
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(!c.equals("\n")))
        {
            for(int i=0;i<CharStats.STAT_DESCS.length;i++)
                if(i!=CharStats.STAT_GENDER)
                    mob.session().println("    "+commandStr.charAt(i)+") "+CMStrings.padRight(CharStats.STAT_DESCS[i],20)+":"+((E.baseCharStats().getStat(i))));
            c=mob.session().choose("Enter one to change, or ENTER when done: ",commandStr.substring(0,CharStats.STAT_DESCS.length)+"\n","\n").toUpperCase();
            int num=commandStr.indexOf(c);
            if(num>=0)
            {
                String newVal=mob.session().prompt("Enter a new value:  "+CharStats.STAT_DESCS[num]+" ("+E.baseCharStats().getStat(num)+"): ","");
                if(((CMath.s_int(newVal)>0)||(newVal.trim().equals("0")))
                &&(num!=CharStats.STAT_GENDER))
                {
                    E.baseCharStats().setStat(num,CMath.s_int(newVal));
                    if((num==CharStats.STAT_AGE)&&(E.playerStats()!=null)&&(E.playerStats().getBirthday()!=null))
                        E.playerStats().getBirthday()[2]=CMLib.time().globalClock().getYear()-CMath.s_int(newVal);
                }
                else
                    mob.tell("(no change)");
            }
        }
    }

    protected void genSensesMask(MOB mob, EnvStats E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        int[] senses={EnvStats.CAN_SEE_DARK,
                      EnvStats.CAN_SEE_HIDDEN,
                      EnvStats.CAN_SEE_INVISIBLE,
                      EnvStats.CAN_SEE_SNEAKERS,
                      EnvStats.CAN_SEE_INFRARED,
                      EnvStats.CAN_SEE_GOOD,
                      EnvStats.CAN_SEE_EVIL,
                      EnvStats.CAN_SEE_BONUS,
                      EnvStats.CAN_NOT_SPEAK,
                      EnvStats.CAN_NOT_HEAR,
                      EnvStats.CAN_NOT_SEE};
        String[] briefs={"darkvision",
                         "hidden",
                         "invisible",
                         "sneakers",
                         "infrared",
                         "good",
                         "evil",
                         "magic",
                         "MUTE",
                         "DEAF",
                         "BLIND"};
        if((showFlag!=showNumber)&&(showFlag>-999))
        {
            StringBuffer buf=new StringBuffer(showNumber+". Senses: ");
            for(int i=0;i<senses.length;i++)
            {
                int mask=senses[i];
                if((E.sensesMask()&mask)!=0)
                    buf.append(briefs[i]+" ");
            }
            mob.tell(buf.toString());
            return;
        }
        String c="Q";
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(!c.equals("\n")))
        {
            char letter='A';
            String letters="";
            for(int i=0;i<senses.length;i++)
            {
                int mask=senses[i];
                for(int num=0;num<EnvStats.CAN_SEE_DESCS.length;num++)
                    if(mask==CMath.pow(2,num))
                    {
                        letters+=letter;
                        mob.session().println("    "+letter+") "+CMStrings.padRight(EnvStats.CAN_SEE_DESCS[num],20)+":"+((E.sensesMask()&mask)!=0));
                        break;
                    }
                letter++;
            }
            c=mob.session().choose("Enter one to change, or ENTER when done: ",letters+"\n","\n").toUpperCase();
            letter='A';
            for(int i=0;i<senses.length;i++)
            {
                int mask=senses[i];
                if(letter==Character.toUpperCase(c.charAt(0)))
                {
                    toggleSensesMask(E,mask);
                    break;
                }
                letter++;
            }
        }
    }

    protected void genDoorsNLocks(MOB mob, Exit E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        boolean HasDoor=E.hasADoor();
        boolean Open=E.isOpen();
        boolean DefaultsClosed=E.defaultsClosed();
        boolean HasLock=E.hasALock();
        boolean Locked=E.isLocked();
        boolean DefaultsLocked=E.defaultsLocked();
        if((showFlag!=showNumber)&&(showFlag>-999)){
            mob.tell(showNumber+". Has a door: "+E.hasADoor()
                    +"\n\r   Has a lock  : "+E.hasALock()
                    +"\n\r   Open ticks: "+E.openDelayTicks());
            return;
        }

        if(genGenericPrompt(mob,"Has a door",E.hasADoor()))
        {
            HasDoor=true;
            DefaultsClosed=genGenericPrompt(mob,"Defaults closed",E.defaultsClosed());
            Open=!DefaultsClosed;
            if(genGenericPrompt(mob,"Has a lock",E.hasALock()))
            {
                HasLock=true;
                DefaultsLocked=genGenericPrompt(mob,"Defaults locked",E.defaultsLocked());
                Locked=DefaultsLocked;
            }
            else
            {
                HasLock=false;
                Locked=false;
                DefaultsLocked=false;
            }
            mob.tell("\n\rReset Delay (# ticks): '"+E.openDelayTicks()+"'.");
            int newLevel=CMath.s_int(mob.session().prompt("Enter a new delay\n\r:",""));
            if(newLevel>0)
                E.setOpenDelayTicks(newLevel);
            else
                mob.tell("(no change)");
        }
        else
        {
            HasDoor=false;
            Open=true;
            DefaultsClosed=false;
            HasLock=false;
            Locked=false;
            DefaultsLocked=false;
        }
        E.setDoorsNLocks(HasDoor,Open,DefaultsClosed,HasLock,Locked,DefaultsLocked);
    }

    public String makeContainerTypes(Container E)
    {
        String canContain=", "+Container.CONTAIN_DESCS[0];
        if(E.containTypes()>0)
        {
            canContain="";
            for(int i=0;i<20;i++)
                if(CMath.isSet((int)E.containTypes(),i))
                    canContain+=", "+Container.CONTAIN_DESCS[i+1];
        }
        return canContain.substring(2);
    }


    protected void genLidsNLocks(MOB mob, Container E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        if((showFlag!=showNumber)&&(showFlag>-999)){
            mob.tell(showNumber+". Can contain : "+makeContainerTypes(E)
                    +"\n\r   Has a lid   : "+E.hasALid()
                    +"\n\r   Has a lock  : "+E.hasALock()
                    +"\n\r   Key name    : "+E.keyName());
            return;
        }
        String change="NO";
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(change.length()>0))
        {
            mob.tell("\n\rCan only contain: "+makeContainerTypes(E));
            change=mob.session().prompt("Enter a type to add/remove (?)\n\r:","");
            if(change.length()==0) break;
            int found=-1;
            if(change.equalsIgnoreCase("?"))
                for(int i=0;i<Container.CONTAIN_DESCS.length;i++)
                    mob.tell(Container.CONTAIN_DESCS[i]);
            else
            {
                for(int i=0;i<Container.CONTAIN_DESCS.length;i++)
                    if(Container.CONTAIN_DESCS[i].startsWith(change.toUpperCase()))
                        found=i;
                if(found<0)
                    mob.tell("Unknown type.  Try '?'.");
                else
                if(found==0)
                    E.setContainTypes(0);
                else
                if(CMath.isSet((int)E.containTypes(),found-1))
                    E.setContainTypes(E.containTypes()-CMath.pow(2,found-1));
                else
                    E.setContainTypes(E.containTypes()|CMath.pow(2,found-1));
            }
        }

        if(genGenericPrompt(mob,"Has a lid " ,E.hasALid()))
        {
            E.setLidsNLocks(true,false,E.hasALock(),E.isLocked());
            if(genGenericPrompt(mob,"Has a lock",E.hasALock()))
            {
                E.setLidsNLocks(E.hasALid(),E.isOpen(),true,true);
                mob.tell("\n\rKey code: '"+E.keyName()+"'.");
                String newName=mob.session().prompt("Enter something new\n\r:","");
                if(newName.length()>0)
                    E.setKeyName(newName);
                else
                    mob.tell("(no change)");
            }
            else
            {
                E.setKeyName("");
                E.setLidsNLocks(E.hasALid(),E.isOpen(),false,false);
            }
        }
        else
        {
            E.setKeyName("");
            E.setLidsNLocks(false,true,false,false);
        }
    }

    protected void genLevel(MOB mob, Environmental E, int showNumber, int showFlag) throws IOException
    {
        if(E.baseEnvStats().level()<0) E.baseEnvStats().setLevel(1);
        E.baseEnvStats().setLevel(CMLib.genEd().prompt(mob,E.baseEnvStats().level(),showNumber,showFlag,"Level"));
    }

    protected void genRejuv(MOB mob, Environmental E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        if(E instanceof Item)
            mob.tell(showNumber+". Rejuv/Pct: '"+E.baseEnvStats().rejuv()+"' (0=special).");
        else
            mob.tell(showNumber+". Rejuv Ticks: '"+E.baseEnvStats().rejuv()+"' (0=never).");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        String rlevel=mob.session().prompt("Enter new amount\n\r:","");
        int newLevel=CMath.s_int(rlevel);
        if((newLevel>0)||(rlevel.trim().equals("0")))
        {
            E.baseEnvStats().setRejuv(newLevel);
            if((E.baseEnvStats().rejuv()==0)&&(E instanceof MOB))
            {
                E.baseEnvStats().setRejuv(Integer.MAX_VALUE);
                mob.tell(E.Name()+" will now never rejuvinate.");
            }
        }
        else
            mob.tell("(no change)");
    }

    protected void genUses(MOB mob, Item E, int showNumber, int showFlag) throws IOException
    { E.setUsesRemaining(CMLib.genEd().prompt(mob,E.usesRemaining(),showNumber,showFlag,"Uses Remaining")); }

    protected void genMaxUses(MOB mob, Wand E, int showNumber, int showFlag) throws IOException
    { E.setMaxUses(CMLib.genEd().prompt(mob,E.maxUses(),showNumber,showFlag,"Maximum Uses")); }

    protected void genCondition(MOB mob, Item E, int showNumber, int showFlag) throws IOException
    { E.setUsesRemaining(CMLib.genEd().prompt(mob,E.usesRemaining(),showNumber,showFlag,"Condition")); }

    public void genMiscSet(MOB mob, Environmental E)
        throws IOException
    {
        if(CMLib.flags().isCataloged(E))
        {
            if(CMLib.catalog().isCatalogObj(E.Name()))
                mob.tell("*** This object is Cataloged **\n\r");
            else
                mob.tell("*** This object WAS cataloged and is still tied **\n\r");
        }

        if(E instanceof ShopKeeper)
            modifyGenShopkeeper(mob,(ShopKeeper)E);
        else
        if(E instanceof MOB)
        {
            if(((MOB)E).isMonster())
                modifyGenMOB(mob,(MOB)E);
            else
                modifyPlayer(mob,(MOB)E);
        }
        else
        if((E instanceof Exit)&&(!(E instanceof Item)))
            modifyGenExit(mob,(Exit)E);
        else
        if(E instanceof com.planet_ink.coffee_mud.Items.interfaces.Map)
            modifyGenMap(mob,(com.planet_ink.coffee_mud.Items.interfaces.Map)E);
        else
        if(E instanceof Armor)
            modifyGenArmor(mob,(Armor)E);
        else
        if(E instanceof MusicalInstrument)
            modifyGenInstrument(mob,(MusicalInstrument)E);
        else
        if(E instanceof Food)
            modifyGenFood(mob,(Food)E);
        else
        if((E instanceof Drink)&&(E instanceof Item))
            modifyGenDrink(mob,(Drink)E);
        else
        if(E instanceof Weapon)
            modifyGenWeapon(mob,(Weapon)E);
        else
        if(E instanceof Container)
            modifyGenContainer(mob,(Container)E);
        else
        if(E instanceof Item)
        {
            if(E.ID().equals("GenWallpaper"))
                modifyGenWallpaper(mob,(Item)E);
            else
                modifyGenItem(mob,(Item)E);
        }
        catalogCheckUpdate(mob, E);
    }

    public void genMiscText(MOB mob, Environmental E, int showNumber, int showFlag)
        throws IOException
    {
        if(E.isGeneric())
            genMiscSet(mob,E);
        else
        {   E.setMiscText(CMLib.genEd().prompt(mob,E.text(),showNumber,showFlag,"Misc Text",true,false));}
    }

    protected void genTitleRoom(MOB mob, LandTitle E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        mob.tell(showNumber+". Land plot ID: '"+E.landPropertyID()+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        String newText="?!?!";
        while((mob.session()!=null)&&(!mob.session().killFlag())
            &&((newText.length()>0)&&(CMLib.map().getRoom(newText)==null)))
        {
            newText=mob.session().prompt("New Property ID:","");
            if((newText.length()==0)
            &&(CMLib.map().getRoom(newText)==null)
            &&(CMLib.map().getArea(newText)==null))
                mob.tell("That property (room ID) doesn't exist!");
        }
        if(newText.length()>0)
            E.setLandPropertyID(newText);
        else
            mob.tell("(no change)");

    }

    public void genAbility(MOB mob, Environmental E, int showNumber, int showFlag) throws IOException
    { E.baseEnvStats().setAbility(CMLib.genEd().prompt(mob,E.baseEnvStats().ability(),showNumber,showFlag,"Magical Ability")); }

    protected void genCoinStuff(MOB mob, Coins E, int showNumber, int showFlag)
    throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        mob.tell(showNumber+". Money data: '"+E.getNumberOfCoins()+" x "+CMLib.beanCounter().getDenominationName(E.getCurrency(),E.getDenomination())+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        boolean gocontinue=true;
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(gocontinue))
        {
            gocontinue=false;
            String oldCurrency=E.getCurrency();
            if(oldCurrency.length()==0) oldCurrency="Default";
            oldCurrency=mob.session().prompt("Enter currency code (?):",oldCurrency).trim().toUpperCase();
            if(oldCurrency.equalsIgnoreCase("Default"))
            {
                if(E.getCurrency().length()>0)
                    E.setCurrency("");
                else
                    mob.tell("(no change)");
            }
            else
            if((oldCurrency.length()==0)||(oldCurrency.equalsIgnoreCase(E.getCurrency())))
                mob.tell("(no change)");
            else
            if(!CMLib.beanCounter().getAllCurrencies().contains(oldCurrency))
            {
                Vector V=CMLib.beanCounter().getAllCurrencies();
                for(int v=0;v<V.size();v++)
                    if(((String)V.elementAt(v)).length()==0)
                        V.setElementAt("Default",v);
                mob.tell("'"+oldCurrency+"' is not a known currency. Existing currencies include: DEFAULT"+CMParms.toStringList(V));
                gocontinue=true;
            }
            else
                E.setCurrency(oldCurrency.toUpperCase().trim());
        }
        gocontinue=true;
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(gocontinue))
        {
            gocontinue=false;
            String newDenom=mob.session().prompt("Enter denomination (?):",""+E.getDenomination()).trim().toUpperCase();
            MoneyLibrary.MoneyDenomination[] DV=CMLib.beanCounter().getCurrencySet(E.getCurrency());
            if((newDenom.length()>0)
            &&(!CMath.isDouble(newDenom))
            &&(!newDenom.equalsIgnoreCase("?")))
            {
                double denom=CMLib.english().matchAnyDenomination(E.getCurrency(),newDenom);
                if(denom>0.0) newDenom=""+denom;
            }
            if((newDenom.length()==0)
            ||(CMath.isDouble(newDenom)
                &&(!newDenom.equalsIgnoreCase("?"))
                &&(CMath.s_double(newDenom)==E.getDenomination())))
                    mob.tell("(no change)");
            else
            if((newDenom.equalsIgnoreCase("?"))
            ||(!CMath.isDouble(newDenom))
            ||((DV!=null)&&(CMLib.beanCounter().getDenominationIndex(E.getCurrency(), CMath.s_double(newDenom))<0)))
            {
                StringBuffer allDenoms=new StringBuffer("");
                for(int i=0;i<DV.length;i++)
                    allDenoms.append(DV[i].value+"("+DV[i].name+"), ");
                if(allDenoms.toString().endsWith(", "))
                    allDenoms=new StringBuffer(allDenoms.substring(0,allDenoms.length()-2));
                mob.tell("'"+newDenom+"' is not a defined denomination. Try one of these: "+allDenoms.toString()+".");
                gocontinue=true;
            }
            else
                E.setDenomination(CMath.s_double(newDenom));
        }
        if((mob.session()!=null)&&(!mob.session().killFlag()))
            E.setNumberOfCoins(CMath.s_int(mob.session().prompt("Enter stack size\n\r:",""+E.getNumberOfCoins())));
    }

    protected void genHitPoints(MOB mob, MOB E, int showNumber, int showFlag) throws IOException
    {
        if(E.isMonster())
            E.baseEnvStats().setAbility(CMLib.genEd().prompt(mob,E.baseEnvStats().ability(),showNumber,showFlag,"Hit Points Bonus Modifier","Hit points = (level*level) + (random*level*THIS)"));
        else
            E.baseEnvStats().setAbility(CMLib.genEd().prompt(mob,E.baseEnvStats().ability(),showNumber,showFlag,"Ability -- unused"));
    }

    protected void genValue(MOB mob, Item E, int showNumber, int showFlag) throws IOException
    { E.setBaseValue(CMLib.genEd().prompt(mob,E.baseGoldValue(),showNumber,showFlag,"Base Value")); }

    protected void genWeight(MOB mob, Environmental E, int showNumber, int showFlag) throws IOException
    { E.baseEnvStats().setWeight(CMLib.genEd().prompt(mob,E.baseEnvStats().weight(),showNumber,showFlag,"Weight")); }

    protected void genClanItem(MOB mob, ClanItem E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        mob.tell(showNumber+". Clan: '"+E.clanID()+"', Type: "+ClanItem.CI_DESC[E.ciType()]+".");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        String clanID=E.clanID();
        E.setClanID(mob.session().prompt("Enter a new clan\n\r:",clanID));
        if(E.clanID().equals(clanID))
            mob.tell("(no change)");
        String clanType=ClanItem.CI_DESC[E.ciType()];
        String s="?";
        while((mob.session()!=null)&&(!mob.session().killFlag())&&(s.equals("?")))
        {
            s=mob.session().prompt("Enter a new type (?)\n\r:",clanType);
            if(s.equalsIgnoreCase("?"))
                mob.tell("Types: "+CMParms.toStringList(ClanItem.CI_DESC));
            else
            if(s.equalsIgnoreCase(clanType))
            {
                mob.tell("(no change)");
                break;
            }
            else
            {
                boolean found=false;
                for(int i=0;i<ClanItem.CI_DESC.length;i++)
                    if(ClanItem.CI_DESC[i].equalsIgnoreCase(s))
                    { found=true; E.setCIType(i); break;}
                if(!found)
                {
                    mob.tell("'"+s+"' is unknown.  Try '?'");
                    s="?";
                }
            }
        }
    }

    protected void genHeight(MOB mob, Environmental E, int showNumber, int showFlag) throws IOException
    { E.baseEnvStats().setHeight(CMLib.genEd().prompt(mob,E.baseEnvStats().height(),showNumber,showFlag,"Height")); }


    protected void genSize(MOB mob, Armor E, int showNumber, int showFlag) throws IOException
    { E.baseEnvStats().setHeight(CMLib.genEd().prompt(mob,E.baseEnvStats().height(),showNumber,showFlag,"Size")); }

    public void wornLayer(MOB mob, short[] layerAtt, short[] clothingLayer, int showNumber, int showFlag)
    throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber))  return;
        boolean seeThroughBool=CMath.bset(layerAtt[0],Armor.LAYERMASK_SEETHROUGH);
        boolean multiWearBool=CMath.bset(layerAtt[0],Armor.LAYERMASK_MULTIWEAR);
        String seeThroughStr=(!seeThroughBool)?" (opaque)":" (see-through)";
        String multiWearStr=multiWearBool?" (multi)":"";
        mob.tell(showNumber+". Layer: '"+clothingLayer[0]+"'"+seeThroughStr+""+multiWearStr+".");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        if((mob.session()!=null)&&(!mob.session().killFlag()))
            clothingLayer[0] = CMath.s_short(mob.session().prompt("Enter a new layer\n\r:",""+clothingLayer[0]));
        boolean newSeeThrough=seeThroughBool;
        if((mob.session()!=null)&&(!mob.session().killFlag()))
            newSeeThrough=mob.session().confirm("Is see-through (Y/N)? ",""+seeThroughBool);
        boolean multiWear=multiWearBool;
        if((mob.session()!=null)&&(!mob.session().killFlag()))
            multiWear=mob.session().confirm("Is multi-wear (Y/N)? ",""+multiWearBool);
        layerAtt[0] = (short)0;
        layerAtt[0] = (short)(layerAtt[0]|(newSeeThrough?Armor.LAYERMASK_SEETHROUGH:0));
        layerAtt[0] = (short)(layerAtt[0]|(multiWear?Armor.LAYERMASK_MULTIWEAR:0));
    }

    protected void genLayer(MOB mob, Armor E, int showNumber, int showFlag) throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber))  return;
        short[] layerAtt = new short[]{E.getLayerAttributes()};
        short[] clothingLayer = new short[]{E.getClothingLayer()};
        wornLayer(mob,layerAtt,clothingLayer,showNumber,showFlag);
        E.setClothingLayer(clothingLayer[0]);
        E.setLayerAttributes(layerAtt[0]);
    }

    protected void genCapacity(MOB mob, Container E, int showNumber, int showFlag) throws IOException
    { E.setCapacity(CMLib.genEd().prompt(mob,E.capacity(),showNumber,showFlag,"Capacity")); }

    protected void genAttack(MOB mob, Environmental E, int showNumber, int showFlag) throws IOException
    { E.baseEnvStats().setAttackAdjustment(CMLib.genEd().prompt(mob,E.baseEnvStats().attackAdjustment(),showNumber,showFlag,"Attack Adjustment")); }

    protected void genDamage(MOB mob, Environmental E, int showNumber, int showFlag) throws IOException
    { E.baseEnvStats().setDamage(CMLib.genEd().prompt(mob,E.baseEnvStats().damage(),showNumber,showFlag,"Damage")); }

    protected void genBanker1(MOB mob, Banker E, int showNumber, int showFlag) throws IOException
    { E.setCoinInterest(CMLib.genEd().prompt(mob,E.getCoinInterest(),showNumber,showFlag,"Coin Interest [% per real day]")); }

    protected void genBanker2(MOB mob, Banker E, int showNumber, int showFlag) throws IOException
    { E.setItemInterest(CMLib.genEd().prompt(mob,E.getItemInterest(),showNumber,showFlag,"Item Interest [% per real day]")); }

    protected void genBanker3(MOB mob, Banker E, int showNumber, int showFlag) throws IOException
    { E.setBankChain(CMLib.genEd().prompt(mob,E.bankChain(),showNumber,showFlag,"Bank Chain",false,false)); }

    protected void genBanker4(MOB mob, Banker E, int showNumber, int showFlag) throws IOException
    { E.setLoanInterest(CMLib.genEd().prompt(mob,E.getLoanInterest(),showNumber,showFlag,"Loan Interest [% per mud month]")); }

    protected void genSpeed(MOB mob, Environmental E, int showNumber, int showFlag) throws IOException
    { E.baseEnvStats().setSpeed(CMLib.genEd().prompt(mob,E.baseEnvStats().speed(),showNumber,showFlag,"Actions/Attacks per tick")); }

    protected void genArmor(MOB mob, Environmental E, int showNumber, int showFlag) throws IOException
    {
        if(E instanceof MOB)
            E.baseEnvStats().setArmor(CMLib.genEd().prompt(mob,E.baseEnvStats().armor(),showNumber,showFlag,"Armor (lower-better)"));
        else
            E.baseEnvStats().setArmor(CMLib.genEd().prompt(mob,E.baseEnvStats().armor(),showNumber,showFlag,"Armor (higher-better)"));
    }

    protected void genMoney(MOB mob, MOB E, int showNumber, int showFlag) throws IOException
    {
        if(E.getMoney()==0)
        {
            double d=CMLib.beanCounter().getTotalAbsoluteNativeValue(E);
            CMLib.beanCounter().subtractMoney(E,d);
            E.setMoney((int)Math.round(d));
        }
        CMLib.beanCounter().setMoney(E,CMLib.genEd().prompt(mob,E.getMoney(),showNumber,showFlag,"Money"));
    }

    protected void genWeaponAmmo(MOB mob, Weapon E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        String defaultAmmo=(E.requiresAmmunition())?"Y":"N";
        if((showFlag!=showNumber)&&(showFlag>-999))
        {
            mob.tell(showNumber+". Ammo required: "+E.requiresAmmunition()+" ("+E.ammunitionType()+")");
            return;
        }

        if(mob.session().confirm("Does this weapon require ammunition (default="+defaultAmmo+") (Y/N)?",defaultAmmo))
        {
            mob.tell("\n\rAmmo type: '"+E.ammunitionType()+"'.");
            String newName=mob.session().prompt("Enter a new one\n\r:","");
            if(newName.length()>0)
            {
                E.setAmmunitionType(newName);
                mob.tell("(Remember to create a GenAmmunition item with '"+E.ammunitionType()+"' in the secret identity, and the uses remaining above 0!");
            }
            else
                mob.tell("(no change)");
            mob.tell("\n\rAmmo capacity: '"+E.ammunitionCapacity()+"'.)");
            int newValue=CMath.s_int(mob.session().prompt("Enter a new value\n\r:",""));
            if(newValue>0)
                E.setAmmoCapacity(newValue);
            else
                mob.tell("(no change)");
            E.setAmmoRemaining(E.ammunitionCapacity());
        }
        else
        {
            E.setAmmunitionType("");
            E.setAmmoCapacity(0);
        }
    }
    protected void genWeaponRanges(MOB mob, Weapon E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        mob.tell(showNumber+". Minimum/Maximum Ranges: "+E.minRange()+"/"+E.maxRange()+".");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        String newMinStr=mob.session().prompt("Enter a new minimum range\n\r:","");
        String newMaxStr=mob.session().prompt("Enter a new maximum range\n\r:","");
        if((newMinStr.length()==0)&&(newMaxStr.length()==0))
            mob.tell("(no change)");
        else
        {
            E.setRanges(CMath.s_int(newMinStr),CMath.s_int(newMaxStr));
            if((E.minRange()>E.maxRange())||(E.minRange()<0)||(E.maxRange()<0))
            {
                mob.tell("(defective entries.  resetting.)");
                E.setRanges(0,0);
            }
        }
    }

    protected void genWeaponType(MOB mob, Weapon E, int showNumber, int showFlag)
        throws IOException
    {
        if((showFlag>0)&&(showFlag!=showNumber)) return;
        mob.tell(showNumber+". Weapon Attack Type: '"+Weapon.TYPE_DESCS[E.weaponType()]+"'.");
        if((showFlag!=showNumber)&&(showFlag>-999)) return;
        boolean q=false;
        String sel="NSPBFMR";
        while((mob.session()!=null)&&(!mob.sessio

Showing the first 100 KB of 325.7 KB. Download the archive for the full file.

Site Stats

Snippets: 1791
Codebases: 571