BaseGenerics.java
com/planet_ink/coffee_mud/Commands/BaseGenerics.java · 264.0 KB
From the archive CoffeeMud.zip
Download the archive « Back to the archive contents
package com.planet_ink.coffee_mud.Commands;
import com.planet_ink.coffee_mud.core.interfaces.*;
import com.planet_ink.coffee_mud.core.*;
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.util.*;
import java.io.ByteArrayInputStream;
import java.io.IOException;
/*
Copyright 2000-2006 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.
*/
public class BaseGenerics extends StdCommand
{
private static 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
static void genName(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","Name",showNumber+"",E.Name()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=mob.session().prompt(getScr("BaseGenerics","enternewone"),"");
if(newName.length()>0)
E.setName(newName);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
static void genImage(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","mxpfile",showNumber+"",E.rawImage()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=mob.session().prompt(getScr("BaseGenerics","enterfile"),"");
if(newName.length()>0)
E.setImage(newName);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
static void genCorpseData(MOB mob, DeadBody E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","corpsedata",showNumber+"",E.mobName(),E.killerName()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
mob.tell(getScr("BaseGenerics","deadMobname",E.mobName()));
String newName=mob.session().prompt(getScr("BaseGenerics","enternewname"),"");
if(newName.length()>0) E.setMobName(newName);
else mob.tell(getScr("BaseGenerics","nochange"));
mob.tell(getScr("BaseGenerics","deadMobd",E.mobDescription()));
newName=mob.session().prompt(getScr("BaseGenerics","enterd"),"");
if(newName.length()>0) E.setMobDescription(newName);
else mob.tell(getScr("BaseGenerics","nochange"));
mob.tell(getScr("BaseGenerics","deadmobplayercorpse",""+E.playerCorpse()));
newName=mob.session().prompt(getScr("BaseGenerics","truefalse"),"");
if((newName.length()>0)&&(newName.equalsIgnoreCase("true")||newName.equalsIgnoreCase("false")))
E.setPlayerCorpse(Boolean.valueOf(newName.toLowerCase()).booleanValue());
else mob.tell(getScr("BaseGenerics","nochange"));
mob.tell(getScr("BaseGenerics","deadmobpkflag",""+E.mobPKFlag()));
newName=mob.session().prompt(getScr("BaseGenerics","truefalse"),"");
if((newName.length()>0)&&(newName.equalsIgnoreCase("true")||newName.equalsIgnoreCase("false")))
E.setMobPKFlag(Boolean.valueOf(newName.toLowerCase()).booleanValue());
else mob.tell(getScr("BaseGenerics","nochange"));
genCharStats(mob,E.charStats());
mob.tell(getScr("BaseGenerics","killersname",E.killerName()));
newName=mob.session().prompt(getScr("BaseGenerics","enterk"),"");
if(newName.length()>0) E.setKillerName(newName);
else mob.tell(getScr("BaseGenerics","nochange"));
mob.tell(getScr("BaseGenerics","deadmobkillerplayer",""+E.killerPlayer()));
newName=mob.session().prompt(getScr("BaseGenerics","truefalse"),"");
if((newName.length()>0)&&(newName.equalsIgnoreCase("true")||newName.equalsIgnoreCase("false")))
E.setKillerPlayer(Boolean.valueOf(newName.toLowerCase()).booleanValue());
else mob.tell(getScr("BaseGenerics","nochange"));
mob.tell(getScr("BaseGenerics","deadmobtod",CMLib.time().date2String(E.timeOfDeath())));
newName=mob.session().prompt(getScr("BaseGenerics","entvaluenew"),"");
if(newName.length()>0) E.setTimeOfDeath(CMLib.time().string2Millis(newName));
else mob.tell(getScr("BaseGenerics","nochange"));
mob.tell(getScr("BaseGenerics","deadmoblastmsg",E.lastMessage()));
newName=mob.session().prompt(getScr("BaseGenerics","entvaluenew"),"");
if(newName.length()>0) E.setLastMessage(newName);
else mob.tell(getScr("BaseGenerics","nochange"));
}
static void genAuthor(MOB mob, Area A, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","author",showNumber+"",A.getAuthorID()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=mob.session().prompt(getScr("BaseGenerics","enternewone"),"");
if(newName.length()>0)
A.setAuthorID(newName);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
static 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(getScr("BaseGenerics","paneltype",showNumber+"",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(getScr("BaseGenerics","enter2"),"");
if(newName.length()>0)
{
if(newName.equalsIgnoreCase("?"))
{
mob.tell(getScr("BaseGenerics","comptypes",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(getScr("BaseGenerics","newnotrec",newName));
continueThis=true;
}
else
S.setPanelType(newType);
}
}
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
static 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(getScr("BaseGenerics","currencyname",showNumber+"",currencyName));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=mob.session().prompt(getScr("BaseGenerics","entdef"),"");
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(getScr("BaseGenerics","currencyerr",newName.trim().toUpperCase(),CMParms.toStringList(V)));
}
else
if(newName.indexOf("=")>=0)
A.setCurrency(newName.trim());
else
A.setCurrency(newName.toUpperCase().trim());
}
else
mob.tell(getScr("BaseGenerics","nochange"));
}
static 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==CMClass.globalClock())
report.append(getScr("BaseGenerics","defaultant"));
else
{
report.append(getScr("BaseGenerics","hrsday",TC.getHoursInDay()+""));
report.append(getScr("BaseGenerics","daysmn",TC.getDaysInMonth()+""));
report.append(getScr("BaseGenerics","mthyrs",TC.getMonthsInYear()+""));
}
mob.tell(getScr("BaseGenerics","calendar",showNumber+"",report.toString()));
if(TC==CMClass.globalClock()) return;
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName="";
while((mob.session()!=null)&&(!mob.session().killFlag())&&(newName.length()==0))
{
report=new StringBuffer(getScr("BaseGenerics","calset"));
report.append(getScr("BaseGenerics","hoursperday",TC.getHoursInDay()+""));
report.append(getScr("BaseGenerics","dawnhour",TC.getDawnToDusk()[TimeClock.TIME_DAWN]+""));
report.append(getScr("BaseGenerics","dayhour",TC.getDawnToDusk()[TimeClock.TIME_DAY]+""));
report.append(getScr("BaseGenerics","duskhour",TC.getDawnToDusk()[TimeClock.TIME_DUSK]+""));
report.append(getScr("BaseGenerics","nighthour",TC.getDawnToDusk()[TimeClock.TIME_NIGHT]+""));
report.append(getScr("BaseGenerics","weekdays",CMParms.toStringList(TC.getWeekNames())));
report.append(getScr("BaseGenerics","months",CMParms.toStringList(TC.getMonthNames())));
report.append(getScr("BaseGenerics","yeartitle",CMParms.toStringList(TC.getYearNames())));
mob.tell(report.toString());
newName=mob.session().prompt(getScr("BaseGenerics","entchange"),"");
if(newName.length()==0) break;
int which=CMath.s_int(newName);
if((which<0)||(which>8))
mob.tell(getScr("BaseGenerics","invalid",which+""));
else
if(which<=5)
{
newName="";
String newNum=mob.session().prompt(getScr("BaseGenerics","entnumb"),"");
int val=CMath.s_int(newNum);
if(newNum.length()==0)
mob.tell(getScr("BaseGenerics","nochange"));
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(getScr("BaseGenerics","dawnerr"));
else
TC.getDawnToDusk()[TimeClock.TIME_DAY]=val;
break;
case 4:
if((val>=0)&&(TC.getDawnToDusk()[TimeClock.TIME_DAWN]>=val))
mob.tell(getScr("BaseGenerics","dawnerr"));
else
if((val>=0)&&(TC.getDawnToDusk()[TimeClock.TIME_DAY]>=val))
mob.tell(getScr("BaseGenerics","dayerr"));
else
TC.getDawnToDusk()[TimeClock.TIME_DUSK]=val;
break;
case 5:
if((val>=0)&&(TC.getDawnToDusk()[TimeClock.TIME_DAWN]>=val))
mob.tell(getScr("BaseGenerics","dawnerr"));
else
if((val>=0)&&(TC.getDawnToDusk()[TimeClock.TIME_DAY]>=val))
mob.tell(getScr("BaseGenerics","dayerr"));
else
if((val>=0)&&(TC.getDawnToDusk()[TimeClock.TIME_DUSK]>=val))
mob.tell(getScr("BaseGenerics","duskerr"));
else
TC.getDawnToDusk()[TimeClock.TIME_NIGHT]=val;
break;
}
}
else
{
newName="";
String newNum=mob.session().prompt(getScr("BaseGenerics","entlist"),"");
if(newNum.length()==0)
mob.tell(getScr("BaseGenerics","nochange"));
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();
}
static void genClan(MOB mob, MOB E, int showNumber, int showFlag)
throws IOException
{
if((showFlag<=0)||(showFlag==showNumber))
{
mob.tell(getScr("BaseGenerics","clanid",showNumber+"",E.getClanID()));
if((showFlag==showNumber)||(showFlag<=-999))
{
String newName=mob.session().prompt(getScr("BaseGenerics","entnull"),"");
if(newName.equalsIgnoreCase("null"))
E.setClanID("");
else
if(newName.length()>0)
{
E.setClanID(newName);
E.setClanRole(Clan.POS_MEMBER);
}
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
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(getScr("BaseGenerics","clanrole",showNumber+"",CMLib.clans().getRoleName(C.getGovernment(),E.getClanRole(),true,false)));
if((showFlag==showNumber)||(showFlag<=-999))
{
String newName=mob.session().prompt(getScr("BaseGenerics","enternewone"),"");
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(getScr("BaseGenerics","errrole",CMParms.toStringList(Clan.ROL_DESCS[C.getGovernment()])));
else
E.setClanRole(newRole);
}
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
}
static void genArchivePath(MOB mob, Area E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","arcfilename",showNumber+"",E.getArchivePath()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=mob.session().prompt(getScr("BaseGenerics","entnull2"),"");
if(newName.equalsIgnoreCase("null"))
E.setArchivePath("");
else
if(newName.length()>0)
E.setArchivePath(newName);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
public static 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=0;d<R.rawExits().length;d++)
R.rawExits()[d]=oldR.rawExits()[d];
R.setDisplayText(oldR.displayText());
R.setDescription(oldR.description());
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.map().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;
}
static Room genRoomType(MOB mob, Room R, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return R;
mob.tell(getScr("BaseGenerics","type",showNumber+"",CMClass.className(R)));
if((showFlag!=showNumber)&&(showFlag>-999)) return R;
String newName="";
while((mob.session()!=null)&&(!mob.session().killFlag())&&(newName.length()==0))
{
newName=mob.session().prompt(getScr("BaseGenerics","enter2"),"");
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(getScr("BaseGenerics","newdontex",newName));
else
if(mob.session().confirm(getScr("BaseGenerics","roomcng",R.roomID()),"N"))
R=changeRoomType(R,newRoom);
R.recoverRoomStats();
}
else
{
mob.tell(getScr("BaseGenerics","nochange"));
break;
}
}
return R;
}
static void genDescription(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","description",showNumber+"",E.description()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=mob.session().prompt(getScr("BaseGenerics","entnull3"),"");
if(newName.trim().equalsIgnoreCase("null"))
E.setDescription("");
else
if(newName.length()>0)
E.setDescription(newName);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
static void genNotes(MOB mob, MOB E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","notes",showNumber+"",(E.playerStats()!=null)?E.playerStats().notes():""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=mob.session().prompt(getScr("BaseGenerics","some4"),"");
if((newName.length()>0)&&(E.playerStats()!=null))
E.playerStats().setNotes(newName);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
static void genPassword(MOB mob, MOB E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","pwd",showNumber+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=mob.session().prompt(getScr("BaseGenerics","entreset"),"");
if((newName.length()>0)&&(E.playerStats()!=null))
{
E.playerStats().setPassword(newName);
CMLib.database().DBUpdatePassword(E);
}
else
mob.tell(getScr("BaseGenerics","nochange"));
}
static void genEmail(MOB mob, MOB E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
if(E.playerStats()!=null)
mob.tell(getScr("BaseGenerics","email",showNumber+"",E.playerStats().getEmail()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=mob.session().prompt(getScr("BaseGenerics","enternewone"),"");
if((newName.length()>0)&&(E.playerStats()!=null))
E.playerStats().setEmail(newName);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
public static void genDisplayText(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","display",showNumber+"",E.displayText()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=null;
if(E instanceof Item)
newName=mob.session().prompt(getScr("BaseGenerics","some1"),"");
else
if(E instanceof Exit)
newName=mob.session().prompt(getScr("BaseGenerics","some2"),"");
else
newName=mob.session().prompt(getScr("BaseGenerics","some3"),"");
if(newName.length()>0)
{
if(newName.trim().equalsIgnoreCase("null"))
newName="";
E.setDisplayText(newName);
}
else
mob.tell(getScr("BaseGenerics","nochange"));
if((E instanceof Item)&&(E.displayText().length()==0))
mob.tell(getScr("BaseGenerics","blended"));
}
public static void genClosedText(MOB mob, Exit E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
if(E instanceof Item)
mob.tell(getScr("BaseGenerics","exitclosedtxt",showNumber+"",E.closedText()));
else
mob.tell(getScr("BaseGenerics","closedtxt",showNumber+"",E.closedText()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=mob.session().prompt(getScr("BaseGenerics","some5"),"");
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(getScr("BaseGenerics","nochange"));
}
public static void genDoorName(MOB mob, Exit E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
if(E instanceof Item)
mob.tell(getScr("BaseGenerics","exitdir",showNumber+"",E.doorName()));
else
mob.tell(getScr("BaseGenerics","doorn",showNumber+"",E.doorName()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=mob.session().prompt(getScr("BaseGenerics","some4"),"");
if(newName.length()>0)
E.setExitParams(newName,E.closeWord(),E.openWord(),E.closedText());
else
mob.tell(getScr("BaseGenerics","nochange"));
}
public static void genBurnout(MOB mob, Light E, int showNumber, int showFlag)
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","isdestroyed",showNumber+"",E.destroyedWhenBurnedOut()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.setDestroyedWhenBurntOut(!E.destroyedWhenBurnedOut());
}
public static void genOpenWord(MOB mob, Exit E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","openword",showNumber+"",E.openWord()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=mob.session().prompt(getScr("BaseGenerics","some4"),"");
if(newName.length()>0)
E.setExitParams(E.doorName(),E.closeWord(),newName,E.closedText());
else
mob.tell(getScr("BaseGenerics","nochange"));
}
public static 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(getScr("BaseGenerics","aeastaffname",showNumber+"",A.getSubOpList()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
newName=mob.session().prompt(getScr("BaseGenerics","addrem"),"");
if(newName.length()>0)
{
if(A.amISubOp(newName))
{
A.delSubOp(newName);
mob.tell(getScr("BaseGenerics","staffrem"));
}
else
if(CMLib.database().DBUserSearch(null,newName))
{
A.addSubOp(newName);
mob.tell(getScr("BaseGenerics","ataffadd"));
}
else
mob.tell(getScr("BaseGenerics","usererr",newName));
}
}
}
public static 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(getScr("BaseGenerics","parentareas",showNumber+"",A.getParentsList()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
newArea=mob.session().prompt(getScr("BaseGenerics","arearem"),"");
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(getScr("BaseGenerics","arearem", lookedUp.Name()+""));
}
else
{
if(A.canParent(lookedUp))
{
A.addParent(lookedUp);
lookedUp.addChild(A);
mob.tell(getScr("BaseGenerics","areaadd",lookedUp.Name()+""));
}
else
{
mob.tell(getScr("BaseGenerics","areaerr",lookedUp.Name()+"" ));
}
}
}
else
mob.tell(getScr("BaseGenerics","areaerr2",newArea));
}
}
}
public static 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(getScr("BaseGenerics","areachild",showNumber+"",A.getChildrenList()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
newArea=mob.session().prompt(getScr("BaseGenerics","arearem"),"");
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(getScr("BaseGenerics","arearem",lookedUp.Name()+""));
}
else
{
if(A.canChild(lookedUp))
{
A.addChild(lookedUp);
lookedUp.addParent(A);
mob.tell(getScr("BaseGenerics","areaadd", lookedUp.Name()+""));
}
else
{
mob.tell(getScr("BaseGenerics","areaerr", lookedUp.Name()+"" ));
}
}
}
else
mob.tell(getScr("BaseGenerics","areaerr2",newArea));
}
}
}
public static void genCloseWord(MOB mob, Exit E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","closeword",showNumber+"",E.closeWord()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=mob.session().prompt(getScr("BaseGenerics","some4"),"");
if(newName.length()>0)
E.setExitParams(E.doorName(),newName,E.openWord(),E.closedText());
else
mob.tell(getScr("BaseGenerics","nochange"));
}
public static 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(getScr("BaseGenerics","asskeyitem",showNumber+"",E.keyName()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=mob.session().prompt(getScr("BaseGenerics","some5"),"");
if(newName.equalsIgnoreCase("null"))
E.setKeyName("");
else
if(newName.length()>0)
E.setKeyName(newName);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
else
{
if((showFlag!=showNumber)&&(showFlag>-999))
{
if(!E.isReadable())
mob.tell(getScr("BaseGenerics","dorrnread",showNumber+""));
else
mob.tell(getScr("BaseGenerics","dorread",showNumber+"",E.readableText()));
return;
}
else
if(genGenericPrompt(mob,getScr("BaseGenerics","msgreadble"),E.isReadable()))
{
E.setReadable(true);
mob.tell(getScr("BaseGenerics","readabletxt",E.readableText()));
String newName=mob.session().prompt(getScr("BaseGenerics","some5"),"");
if(newName.equalsIgnoreCase("null"))
E.setReadableText("");
else
if(newName.length()>0)
E.setReadableText(newName);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
else
E.setReadable(false);
}
}
public static 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.className(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(getScr("BaseGenerics","itemread",showNumber+"",CMLib.flags().isReadable(E)+""));
else
CMLib.flags().setReadable(E,genGenericPrompt(mob,showNumber+getScr("BaseGenerics","msgitemr"),CMLib.flags().isReadable(E)));
}
public static 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.className(E).endsWith("SuperPill"))
{
mob.tell(getScr("BaseGenerics","assspellorp",showNumber+"",E.readableText()));
ok=true;
}
else
if(E instanceof SpellHolder)
mob.tell(getScr("BaseGenerics","assspell",showNumber+"",E.readableText()));
else
if(E instanceof Ammunition)
{
mob.tell(getScr("BaseGenerics","ammotype",showNumber+"",E.readableText()));
ok=true;
}
else
if(E instanceof Exit)
{
mob.tell(getScr("BaseGenerics","assroomid",showNumber+"",E.readableText()));
ok=true;
}
else
if(E instanceof Wand)
mob.tell(getScr("BaseGenerics","asspellname",showNumber+"",E.readableText()));
else
if(E instanceof Key)
{
mob.tell(getScr("BaseGenerics","asskeycode",showNumber+"",E.readableText()));
ok=true;
}
else
if(E instanceof com.planet_ink.coffee_mud.Items.interfaces.Map)
{
mob.tell(getScr("BaseGenerics","assmaparea",showNumber+"",E.readableText()));
ok=true;
}
else
if(E instanceof Light)
{
mob.tell(getScr("BaseGenerics","lightdur",showNumber+"",CMath.s_int(E.readableText())+""));
ok=true;
}
else
{
mob.tell(getScr("BaseGenerics","assreadtxt",showNumber+"",E.readableText())+"");
ok=true;
}
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newName=null;
if((E instanceof Wand)
||((E instanceof SpellHolder)&&(!(CMClass.className(E).endsWith("SuperPill")))))
{
newName=mob.session().prompt(getScr("BaseGenerics","some6"),"");
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(getScr("BaseGenerics","namenotrec",newName));
}
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(getScr("BaseGenerics","spellnotrec",spellName));
break;
}
newName=newName.substring(x+1).trim();
x=newName.indexOf(";");
}
newName=oldName;
}
}
}
else
newName=mob.session().prompt(getScr("BaseGenerics","some5"),"");
if(ok)
{
if(newName.equalsIgnoreCase("null"))
E.setReadableText("");
else
if(newName.length()>0)
E.setReadableText(newName);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
}
else
if(E instanceof Drink)
{
mob.session().println(showNumber+getScr("BaseGenerics","curliq")+" "+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(getScr("BaseGenerics","newtype"),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(getScr("BaseGenerics","nochange"));
}
}
}
}
public static void genRecipe(MOB mob, Recipe E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
String prompt=getScr("BaseGenerics","recipedata");
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(getScr("BaseGenerics","entskillid"),"");
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)
&&(CMath.bset(A.flags(),Ability.FLAG_CRAFTING)))
str.append(A.ID()+"\n\r");
}
mob.tell(getScr("BaseGenerics","comskill",str.toString()));
}
else
if((newName.length()>0)
&&(CMClass.getAbility(newName)!=null)
&&(CMClass.getAbility(newName).classificationCode()==Ability.ACODE_COMMON_SKILL))
{
E.setCommonSkillID(CMClass.getAbility(newName).ID());
break;
}
else
if(newName.length()>0)
mob.tell(getScr("BaseGenerics","cskillerr",newName));
else
{
mob.tell(getScr("BaseGenerics","nochange"));
break;
}
}
String newName=mob.session().prompt(getScr("BaseGenerics","entdataline"),"");
if(newName.length()>0)
E.setRecipeCodeLine(CMStrings.replaceAll(newName,",","\t"));
else
mob.tell(getScr("BaseGenerics","nochange"));
}
public static 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+getScr("BaseGenerics","gettable")+" "+(!CMath.bset(E.baseEnvStats().sensesMask(),EnvStats.SENSE_ITEMNOTGET)));
mob.session().println(" "+getScr("BaseGenerics","droppable")+" "+(!CMath.bset(E.baseEnvStats().sensesMask(),EnvStats.SENSE_ITEMNODROP)));
mob.session().println(" "+getScr("BaseGenerics","removable")+" "+(!CMath.bset(E.baseEnvStats().sensesMask(),EnvStats.SENSE_ITEMNOREMOVE)));
mob.session().println(" "+getScr("BaseGenerics","nonlocatable")+" "+(((E.baseEnvStats().sensesMask()&EnvStats.SENSE_UNLOCATABLE)>0)?"true":"false"));
if(E instanceof Weapon)
mob.session().println(" "+getScr("BaseGenerics","twohanded")+" "+E.rawLogicalAnd());
if((showFlag!=showNumber)&&(showFlag>-999)) return;
c=mob.session().choose(getScr("BaseGenerics","msgabcde"),"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;
}
}
}
public static 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)));
}
public static 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(getScr("BaseGenerics","disptxt",showNumber+""));
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.dispositionsDesc.length;num++)
if(mask==CMath.pow(2,num))
{
mob.session().println(" "+letter+") "+CMStrings.padRight(EnvStats.dispositionsDesc[num],20)+":"+((E.disposition()&mask)!=0));
letters+=letter;
break;
}
letter++;
}
c=mob.session().choose(getScr("BaseGenerics","msgabcde")+" ",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 static 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;
}
}
public static 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)));
}
public static 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)));
}
public static 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+getScr("BaseGenerics","climate"));
mob.session().println(" "+getScr("BaseGenerics","wetrainy")+" "+((A.climateType()&Area.CLIMASK_WET)>0));
mob.session().println(" "+getScr("BaseGenerics","exhot")+" "+((A.climateType()&Area.CLIMASK_HOT)>0));
mob.session().println(" "+getScr("BaseGenerics","excold")+" "+((A.climateType()&Area.CLIMASK_COLD)>0));
mob.session().println(" "+getScr("BaseGenerics","verywindy")+" "+((A.climateType()&Area.CLIMATE_WINDY)>0));
mob.session().println(" "+getScr("BaseGenerics","verydry")+" "+((A.climateType()&Area.CLIMASK_DRY)>0));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
c=mob.session().choose(getScr("BaseGenerics","msgabcde")+" ","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;
}
}
}
public static 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(getScr("BaseGenerics","msgabcde")+" ",commandStr.substring(0,CharStats.STAT_DESCS.length)+"\n","\n").toUpperCase();
int num=commandStr.indexOf(c);
if(num>=0)
{
String newVal=mob.session().prompt(getScr("BaseGenerics","entnewvalue")+" "+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(getScr("BaseGenerics","nochange"));
}
}
}
public static 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+getScr("BaseGenerics","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(getScr("BaseGenerics","msgabcde")+" ",commandStr.substring(0,CharStats.STAT_DESCS.length)+"\n","\n").toUpperCase();
int num=commandStr.indexOf(c);
if(num>=0)
{
String newVal=mob.session().prompt(getScr("BaseGenerics","entnewvalue")+" "+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]=CMClass.globalClock().getYear()-CMath.s_int(newVal);
}
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
}
public static 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+getScr("BaseGenerics","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.sensesDesc.length;num++)
if(mask==CMath.pow(2,num))
{
letters+=letter;
mob.session().println(" "+letter+") "+CMStrings.padRight(EnvStats.sensesDesc[num],20)+":"+((E.sensesMask()&mask)!=0));
break;
}
letter++;
}
c=mob.session().choose(getScr("BaseGenerics","msgabcde")+" ",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++;
}
}
}
public static 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+getScr("BaseGenerics","hasadoor")+" "+E.hasADoor()
+getScr("BaseGenerics","hasalock")+" "+E.hasALock()
+getScr("BaseGenerics","openticks")+" "+E.openDelayTicks());
return;
}
if(genGenericPrompt(mob,getScr("BaseGenerics","hasadoor2"),E.hasADoor()))
{
HasDoor=true;
DefaultsClosed=genGenericPrompt(mob,getScr("BaseGenerics","defclosed"),E.defaultsClosed());
Open=!DefaultsClosed;
if(genGenericPrompt(mob,getScr("BaseGenerics","hasalock2"),E.hasALock()))
{
HasLock=true;
DefaultsLocked=genGenericPrompt(mob,getScr("BaseGenerics","deflocked"),E.defaultsLocked());
Locked=DefaultsLocked;
}
else
{
HasLock=false;
Locked=false;
DefaultsLocked=false;
}
mob.tell(getScr("BaseGenerics","resetdticks",E.openDelayTicks()+""));
int newLevel=CMath.s_int(mob.session().prompt(getScr("BaseGenerics","entdelay"),""));
if(newLevel>0)
E.setOpenDelayTicks(newLevel);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
else
{
HasDoor=false;
Open=true;
DefaultsClosed=false;
HasLock=false;
Locked=false;
DefaultsLocked=false;
}
E.setDoorsNLocks(HasDoor,Open,DefaultsClosed,HasLock,Locked,DefaultsLocked);
}
public static 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);
}
public static 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+getScr("BaseGenerics","cancontaini")+" "+makeContainerTypes(E)
+getScr("BaseGenerics","hasalid")+" "+E.hasALid()
+getScr("BaseGenerics","hasalock")+" "+E.hasALock()
+getScr("BaseGenerics","keycode")+" "+E.keyName());
return;
}
String change="NO";
while((mob.session()!=null)&&(!mob.session().killFlag())&&(change.length()>0))
{
mob.tell(getScr("BaseGenerics","cancontain",makeContainerTypes(E)));
change=mob.session().prompt(getScr("BaseGenerics","typeaddrem"),"");
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(getScr("BaseGenerics","unktype"));
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,getScr("BaseGenerics","hasalidmsg")+" " ,E.hasALid()))
{
E.setLidsNLocks(true,false,E.hasALock(),E.isLocked());
if(genGenericPrompt(mob,getScr("BaseGenerics","hasalockmsg"),E.hasALock()))
{
E.setLidsNLocks(E.hasALid(),E.isOpen(),true,true);
mob.tell(getScr("BaseGenerics","textkey",E.keyName()));
String newName=mob.session().prompt(getScr("BaseGenerics","some4"),"");
if(newName.length()>0)
E.setKeyName(newName);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
else
{
E.setKeyName("");
E.setLidsNLocks(E.hasALid(),E.isOpen(),false,false);
}
}
else
{
E.setKeyName("");
E.setLidsNLocks(false,true,false,false);
}
}
public static void genLevel(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
if(E.baseEnvStats().level()<0)
E.baseEnvStats().setLevel(1);
mob.tell(getScr("BaseGenerics","leveltxt",showNumber+"",E.baseEnvStats().level()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.baseEnvStats().setLevel(getNumericData(mob,getScr("BaseGenerics","entlev"),E.baseEnvStats().level()));
}
public static void genRejuv(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
if(E instanceof Item)
mob.tell(getScr("BaseGenerics","rejuv",showNumber+"",E.baseEnvStats().rejuv()+""));
else
mob.tell(getScr("BaseGenerics","rejuvticks",showNumber+"",E.baseEnvStats().rejuv()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String rlevel=mob.session().prompt(getScr("BaseGenerics","entamount"),"");
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(getScr("BaseGenerics","neverrej",E.Name()));
}
}
else
mob.tell(getScr("BaseGenerics","nochange"));
}
public static void genUses(MOB mob, Item E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","usesrema",showNumber+"",E.usesRemaining()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.setUsesRemaining(getNumericData(mob,getScr("BaseGenerics","entvaluenew"),E.usesRemaining()));
}
public static void genMaxUses(MOB mob, Wand E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","maxuses",showNumber+"",E.maxUses()+"" ));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.setMaxUses(getNumericData(mob,getScr("BaseGenerics","entvaluenew"),E.maxUses()));
}
public static void genCondition(MOB mob, Item E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","condition",showNumber+"",E.usesRemaining()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.setUsesRemaining(getNumericData(mob,getScr("BaseGenerics","entvaluenew"),E.usesRemaining()));
}
public static void genMiscSet(MOB mob, Environmental E)
throws IOException
{
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);
}
}
public static int getNumericData(MOB mob, String prompt, int oldValue)
throws IOException
{
String value=mob.session().prompt(prompt,"");
int numValue=CMath.s_int(value);
if((numValue==0)&&(!value.trim().equals("0")))
{
mob.tell(getScr("BaseGenerics","nochange"));
return oldValue;
}
return numValue;
}
public static boolean getBooleanData(MOB mob, String prompt, boolean oldValue)
throws IOException
{
boolean bool=mob.session().confirm(prompt,oldValue?"Y":"N");
if(bool==oldValue)
mob.tell(getScr("BaseGenerics","nochange"));
return bool;
}
public static long getLongData(MOB mob, String prompt, long oldValue)
throws IOException
{
String value=mob.session().prompt(prompt,"");
long numValue=CMath.s_long(value);
if((numValue==0)&&(!value.trim().equals("0")))
{
mob.tell(getScr("BaseGenerics","nochange"));
return oldValue;
}
return numValue;
}
public static String getTextData(MOB mob, String prompt, String oldValue)
throws IOException
{
String value=mob.session().prompt(prompt,"").trim();
if(value.length()==0)
{
mob.tell(getScr("BaseGenerics","nochange"));
return oldValue;
}
if(value.equalsIgnoreCase("null"))
value="";
return value;
}
public static double getDoubleData(MOB mob, String prompt, double oldValue)
throws IOException
{
String value=mob.session().prompt(prompt,"");
double numValue=CMath.s_double(value);
if((numValue==0.0)&&(!value.trim().equals("0")))
{
mob.tell(getScr("BaseGenerics","nochange"));
return oldValue;
}
return numValue;
}
public static void genMiscText(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if(E.isGeneric())
genMiscSet(mob,E);
else
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","misctxt",showNumber+"",E.text()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newText=mob.session().prompt(getScr("BaseGenerics","reent"),"");
if(newText.equalsIgnoreCase("NULL"))
E.setMiscText("");
else
if(newText.length()>0)
E.setMiscText(newText);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
public static void genTitleRoom(MOB mob, LandTitle E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","landplotid",showNumber+"",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(getScr("BaseGenerics","newprpid"),"");
if((newText.length()==0)
&&(CMLib.map().getRoom(newText)==null)
&&(CMLib.map().getArea(newText)==null))
mob.tell(getScr("BaseGenerics","roomiderror"));
}
if(newText.length()>0)
E.setLandPropertyID(newText);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
public static void genAbility(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","magicalability",showNumber+"",E.baseEnvStats().ability()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.baseEnvStats().setAbility(getNumericData(mob,getScr("BaseGenerics","zeronomag"),E.baseEnvStats().ability()));
}
public static void genCoinStuff(MOB mob, Coins E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","moneydata",showNumber+"",E.getNumberOfCoins()+"",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(getScr("BaseGenerics","entcurcode"),oldCurrency).trim().toUpperCase();
if(oldCurrency.equalsIgnoreCase("Default"))
{
if(E.getCurrency().length()>0)
E.setCurrency("");
else
mob.tell(getScr("BaseGenerics","nochange"));
}
else
if((oldCurrency.length()==0)||(oldCurrency.equalsIgnoreCase(E.getCurrency())))
mob.tell(getScr("BaseGenerics","nochange"));
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(getScr("BaseGenerics","currencyerr",oldCurrency,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(getScr("BaseGenerics","entde"),""+E.getDenomination()).trim().toUpperCase();
DVector 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(getScr("BaseGenerics","nochange"));
else
if((!CMath.isDouble(newDenom))
||(newDenom.equalsIgnoreCase("?"))
||((DV!=null)&&(!DV.contains(new Double(CMath.s_double(newDenom))))))
{
StringBuffer allDenoms=new StringBuffer("");
for(int i=0;i<DV.size();i++)
allDenoms.append(((Double)DV.elementAt(i,1)).doubleValue()+"("+((String)DV.elementAt(i,2))+"), ");
if(allDenoms.toString().endsWith(", "))
allDenoms=new StringBuffer(allDenoms.substring(0,allDenoms.length()-2));
mob.tell(getScr("BaseGenerics","denomerr",newDenom,allDenoms.toString()));
gocontinue=true;
}
else
E.setDenomination(CMath.s_double(newDenom));
}
E.setNumberOfCoins(getLongData(mob,getScr("BaseGenerics","entstacksize"),E.getNumberOfCoins()));
}
public static void genHitPoints(MOB mob, MOB E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
if(E.isMonster())
mob.tell(getScr("BaseGenerics","hitpointsmod",showNumber+"",E.baseEnvStats().ability()+""));
else
mob.tell(getScr("BaseGenerics","hitpointsmodp",showNumber+"",E.baseEnvStats().ability()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newLevelStr=mob.session().prompt(getScr("BaseGenerics","entvaluenew"),"");
int newLevel=CMath.s_int(newLevelStr);
if((newLevel!=0)||(newLevelStr.equals("0")))
E.baseEnvStats().setAbility(newLevel);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
public static void genValue(MOB mob, Item E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","basevalue",showNumber+"",E.baseGoldValue()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.setBaseValue(getNumericData(mob,getScr("BaseGenerics","entvaluenew"),E.baseGoldValue()));
}
public static void genWeight(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","weight",showNumber+"",E.baseEnvStats().weight()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.baseEnvStats().setWeight(getNumericData(mob,getScr("BaseGenerics","weightmsg"),E.baseEnvStats().weight()));
}
public static void genClanItem(MOB mob, ClanItem E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","clanline",showNumber+"",E.clanID(),ClanItem.CI_DESC[E.ciType()]));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String clanID=E.clanID();
E.setClanID(mob.session().prompt(getScr("BaseGenerics","entclan"),clanID));
if(E.clanID().equals(clanID))
mob.tell(getScr("BaseGenerics","nochange"));
String clanType=ClanItem.CI_DESC[E.ciType()];
String s="?";
while((mob.session()!=null)&&(!mob.session().killFlag())&&(s.equals("?")))
{
s=mob.session().prompt(getScr("BaseGenerics","newtype"),clanType);
if(s.equalsIgnoreCase("?"))
mob.tell(getScr("BaseGenerics","typesclan",CMParms.toStringList(ClanItem.CI_DESC)));
else
if(s.equalsIgnoreCase(clanType))
{
mob.tell(getScr("BaseGenerics","nochange"));
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(getScr("BaseGenerics","unknown",s));
s="?";
}
}
}
}
public static void genHeight(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","height",showNumber+"",E.baseEnvStats().height()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.baseEnvStats().setHeight(getNumericData(mob,getScr("BaseGenerics","heightmsg"),E.baseEnvStats().height()));
}
public static void genSize(MOB mob, Armor E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","size",showNumber+"",E.baseEnvStats().height()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.baseEnvStats().setHeight(getNumericData(mob,getScr("BaseGenerics","entnewsize"),E.baseEnvStats().height()));
}
public static void genLayer(MOB mob, Armor E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
boolean seeThroughBool=CMath.bset(E.getLayerAttributes(),Armor.LAYERMASK_SEETHROUGH);
boolean multiWearBool=CMath.bset(E.getLayerAttributes(),Armor.LAYERMASK_MULTIWEAR);
String seeThroughStr=(!seeThroughBool)?" (opaque)":" (see-through)";
String multiWearStr=multiWearBool?" (multi)":"";
mob.tell(getScr("BaseGenerics","layer",showNumber+"",E.getClothingLayer()+"",seeThroughStr,multiWearStr));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.setClothingLayer((short)getNumericData(mob,getScr("BaseGenerics","newlayer"),E.getClothingLayer()));
boolean newSeeThrough=getBooleanData(mob,getScr("BaseGenerics","newseethrough"),seeThroughBool);
boolean multiWear=getBooleanData(mob,getScr("BaseGenerics","newmultiwear"),multiWearBool);
E.setLayerAttributes((short)0);
E.setLayerAttributes((short)(E.getLayerAttributes()|(newSeeThrough?Armor.LAYERMASK_SEETHROUGH:0)));
E.setLayerAttributes((short)(E.getLayerAttributes()|(multiWear?Armor.LAYERMASK_MULTIWEAR:0)));
}
public static void genCapacity(MOB mob, Container E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","capacity",showNumber+"",E.capacity()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.setCapacity(getNumericData(mob,getScr("BaseGenerics","entnewcap"),E.capacity()));
}
public static void genAttack(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","attackadj",showNumber+"",E.baseEnvStats().attackAdjustment()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.baseEnvStats().setAttackAdjustment(getNumericData(mob,getScr("BaseGenerics","entvaluenew"),E.baseEnvStats().attackAdjustment()));
}
public static void genDamage(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","damagehit",showNumber+"",E.baseEnvStats().damage()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.baseEnvStats().setDamage(getNumericData(mob,getScr("BaseGenerics","entvaluenew"),E.baseEnvStats().damage()));
}
public static void genBanker1(MOB mob, Banker E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","coininter",showNumber+"",E.getCoinInterest()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.setCoinInterest(getDoubleData(mob,getScr("BaseGenerics","entvaluenew"),E.getCoinInterest()));
}
public static void genBanker2(MOB mob, Banker E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","iteminter",showNumber+"",E.getItemInterest()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.setItemInterest(getDoubleData(mob,getScr("BaseGenerics","entvaluenew"),E.getItemInterest()));
}
public static void genBanker3(MOB mob, Banker E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","bankchain",showNumber+"",E.bankChain()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newValue=mob.session().prompt(getScr("BaseGenerics","entnewchain"),"");
if(newValue.length()>0)
E.setBankChain(newValue);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
public static void genBanker4(MOB mob, Banker E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","loaninter",showNumber+"",E.getLoanInterest()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.setLoanInterest(getDoubleData(mob,getScr("BaseGenerics","entvaluenew"),E.getLoanInterest()));
}
public static void genSpeed(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","attacksperound",showNumber+"",((int)Math.round(E.baseEnvStats().speed())+"")));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.baseEnvStats().setSpeed(getNumericData(mob,getScr("BaseGenerics","entvaluenew"),(int)Math.round(E.baseEnvStats().speed())));
}
public static void genArmor(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
if(E instanceof MOB)
mob.tell(getScr("BaseGenerics","armorlb",showNumber+"",E.baseEnvStats().armor()+""));
else
mob.tell(getScr("BaseGenerics","armorhb",showNumber+"",E.baseEnvStats().armor()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
E.baseEnvStats().setArmor(getNumericData(mob,getScr("BaseGenerics","entvaluenew"),E.baseEnvStats().armor()));
}
public static void genMoney(MOB mob, MOB E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","moneycounter",showNumber+"",CMLib.beanCounter().getMoney(E)+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
CMLib.beanCounter().setMoney(E,getNumericData(mob,getScr("BaseGenerics","entvaluenew"),CMLib.beanCounter().getMoney(E)));
}
public static 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(getScr("BaseGenerics","ammorequi",showNumber+"",E.requiresAmmunition()+"",E.ammunitionType()+""));
return;
}
if(mob.session().confirm(getScr("BaseGenerics","confammo",defaultAmmo),defaultAmmo))
{
mob.tell(getScr("BaseGenerics","ammotype2",E.ammunitionType()));
String newName=mob.session().prompt(getScr("BaseGenerics","enternewone"),"");
if(newName.length()>0)
{
E.setAmmunitionType(newName);
mob.tell(getScr("BaseGenerics","remembergenitem",E.ammunitionType()));
}
else
mob.tell(getScr("BaseGenerics","nochange"));
mob.tell(getScr("BaseGenerics","ammocapacity",E.ammunitionCapacity()+""));
int newValue=CMath.s_int(mob.session().prompt(getScr("BaseGenerics","entvaluenew"),""));
if(newValue>0)
E.setAmmoCapacity(newValue);
else
mob.tell(getScr("BaseGenerics","nochange"));
E.setAmmoRemaining(E.ammunitionCapacity());
}
else
{
E.setAmmunitionType("");
E.setAmmoCapacity(0);
}
}
public static void genWeaponRanges(MOB mob, Weapon E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","minmaxranges",showNumber+"",Math.round(E.minRange())+"",Math.round(E.maxRange())+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newMinStr=mob.session().prompt(getScr("BaseGenerics","minrangemsg"),"");
String newMaxStr=mob.session().prompt(getScr("BaseGenerics","maxrangemsg"),"");
if((newMinStr.length()==0)&&(newMaxStr.length()==0))
mob.tell(getScr("BaseGenerics","nochange"));
else
{
E.setRanges(CMath.s_int(newMinStr),CMath.s_int(newMaxStr));
if((E.minRange()>E.maxRange())||(E.minRange()<0)||(E.maxRange()<0))
{
mob.tell(getScr("BaseGenerics","defectiveent"));
E.setRanges(0,0);
}
}
}
public static void genWeaponType(MOB mob, Weapon E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","weapatttype",showNumber+"",Weapon.typeDescription[E.weaponType()]));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
boolean q=false;
String sel="NSPBFMR";
while((mob.session()!=null)&&(!mob.session().killFlag())&&(!q))
{
String newType=mob.session().choose(getScr("BaseGenerics","entvaluenew"),sel+"?","");
if(newType.equals("?"))
{
for(int i=0;i<sel.length();i++)
mob.tell(sel.charAt(i)+") "+Weapon.typeDescription[i]);
q=false;
}
else
{
q=true;
int newValue=-1;
if(newType.length()>0)
newValue=sel.indexOf(newType.toUpperCase());
if(newValue>=0)
E.setWeaponType(newValue);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
}
public static void genTechLevel(MOB mob, Area A, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","themesettings",showNumber+"",Area.THEME_DESCS[A.getTechLevel()]));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
boolean q=false;
while((mob.session()!=null)&&(!mob.session().killFlag())&&(!q))
{
String newType=mob.session().prompt(getScr("BaseGenerics","entnewlev"),Area.THEME_DESCS[A.getTechLevel()]);
if(newType.equals("?"))
{
StringBuffer say=new StringBuffer("");
for(int i=1;i<Area.THEME_DESCS.length;i++)
say.append(i+") "+Area.THEME_DESCS[i]+"\n\r");
mob.tell(say.toString());
q=false;
}
else
{
q=true;
int newValue=-1;
if(CMath.s_int(newType)>0)
newValue=CMath.s_int(newType);
else
for(int i=0;i<Area.THEME_DESCS.length;i++)
if(Area.THEME_DESCS[i].toUpperCase().startsWith(newType.toUpperCase()))
newValue=i;
if(newValue>=0)
A.setTechLevel(newValue);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
}
public static void genMaterialCode(MOB mob, Item E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","materialtype",showNumber+"",RawMaterial.RESOURCE_DESCS[E.material()&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(getScr("BaseGenerics","entnewmaterial"),RawMaterial.RESOURCE_DESCS[E.material()&RawMaterial.RESOURCE_MASK]);
if(newType.equals("?"))
{
StringBuffer say=new StringBuffer("");
for(int i=0;i<RawMaterial.RESOURCE_DESCS.length-1;i++)
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(newType.equalsIgnoreCase(RawMaterial.RESOURCE_DESCS[i]))
newValue=RawMaterial.RESOURCE_DATA[i][0];
if(newValue>=0)
E.setMaterial(newValue);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
}
public static void genInstrumentType(MOB mob, MusicalInstrument E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","instrumentype",showNumber+"",MusicalInstrument.TYPE_DESC[E.instrumentType()]));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
boolean q=false;
while((mob.session()!=null)&&(!mob.session().killFlag())&&(!q))
{
String newType=mob.session().prompt(getScr("BaseGenerics","entnewty"),MusicalInstrument.TYPE_DESC[E.instrumentType()]);
if(newType.equals("?"))
{
StringBuffer say=new StringBuffer("");
for(int i=0;i<MusicalInstrument.TYPE_DESC.length-1;i++)
say.append(MusicalInstrument.TYPE_DESC[i]+", ");
mob.tell(say.toString().substring(0,say.length()-2));
q=false;
}
else
{
q=true;
int newValue=-1;
for(int i=0;i<MusicalInstrument.TYPE_DESC.length-1;i++)
if(newType.equalsIgnoreCase(MusicalInstrument.TYPE_DESC[i]))
newValue=i;
if(newValue>=0)
E.setInstrumentType(newValue);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
}
public static void genSpecialFaction(MOB mob, MOB E, int showNumber, int showFlag, Faction F)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
if(F==null) return;
Faction.FactionRange myFR=CMLib.factions().getRange(F.factionID(),E.fetchFaction(F.factionID()));
mob.tell(showNumber+". "+F.name()+": "+((myFR!=null)?myFR.name():"UNDEFINED")+" ("+E.fetchFaction(F.factionID())+")");
if((showFlag!=showNumber)&&(showFlag>-999)) return;
if(F.ranges()!=null)
for(int v=0;v<F.ranges().size();v++)
{
Faction.FactionRange FR=(Faction.FactionRange)F.ranges().elementAt(v);
mob.tell(CMStrings.padRight(FR.name(),20)+": "+FR.low()+" - "+FR.high()+")");
}
String newOne=mob.session().prompt(getScr("BaseGenerics","entvaluenew"));
if(CMath.isInteger(newOne))
{
E.addFaction(F.factionID(),CMath.s_int(newOne));
return;
}
for(int v=0;v<F.ranges().size();v++)
{
Faction.FactionRange FR=(Faction.FactionRange)F.ranges().elementAt(v);
if(FR.name().toUpperCase().startsWith(newOne.toUpperCase()))
{
if(FR.low()==F.lowest())
E.addFaction(F.factionID(),FR.low());
else
if(FR.high()==F.highest())
E.addFaction(F.factionID(),FR.high());
else
E.addFaction(F.factionID(),FR.low()+((FR.high()-FR.low())/2));
return;
}
}
mob.tell(getScr("BaseGenerics","nochange"));
}
public static void genFaction(MOB mob, MOB E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
String newFact="Q";
while((mob.session()!=null)&&(!mob.session().killFlag())&&(newFact.length()>0))
{
mob.tell(getScr("BaseGenerics","factions",showNumber+"",E.getFactionListing()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
newFact=mob.session().prompt(getScr("BaseGenerics","factionmsg"),"");
if(newFact.length()>0)
{
Faction lookedUp=CMLib.factions().getFactionByName(newFact);
if(lookedUp==null) lookedUp=CMLib.factions().getFaction(newFact);
if(lookedUp!=null)
{
if (E.fetchFaction(lookedUp.factionID())!=Integer.MAX_VALUE)
{
// this mob already has this faction, they must want it removed
E.removeFaction(lookedUp.factionID());
mob.tell(getScr("BaseGenerics","factionrem",lookedUp.name() ));
}
else
{
int value =new Integer(mob.session().prompt(getScr("BaseGenerics","howmuchf",lookedUp.findDefault(E)+""),
new Integer(lookedUp.findDefault(E)).toString())).intValue();
if(value<lookedUp.minimum()) value=lookedUp.minimum();
if(value>lookedUp.maximum()) value=lookedUp.maximum();
E.addFaction(lookedUp.factionID(),value);
mob.tell(getScr("BaseGenerics","factionadd",lookedUp.name() ));
}
}
else
mob.tell(getScr("BaseGenerics","factionerr",newFact));
}
}
}
public static void genGender(MOB mob, MOB E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","gender",showNumber+"",""+Character.toUpperCase((char)E.baseCharStats().getStat(CharStats.STAT_GENDER))));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newType=mob.session().choose(getScr("BaseGenerics","entergemsg"),"MFN","");
int newValue=-1;
if(newType.length()>0)
newValue=("MFN").indexOf(newType.trim().toUpperCase());
if(newValue>=0)
{
switch(newValue)
{
case 0:
E.baseCharStats().setStat(CharStats.STAT_GENDER,'M');
break;
case 1:
E.baseCharStats().setStat(CharStats.STAT_GENDER,'F');
break;
case 2:
E.baseCharStats().setStat(CharStats.STAT_GENDER,'N');
break;
}
}
else
mob.tell(getScr("BaseGenerics","nochange"));
}
public static void genWeaponClassification(MOB mob, Weapon E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","weaponclass",showNumber+"",Weapon.classifictionDescription[E.weaponClassification()]));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
boolean q=false;
String sel=("ABEFHKPRSDTN");
while((mob.session()!=null)&&(!mob.session().killFlag())&&(!q))
{
String newType=mob.session().choose(getScr("BaseGenerics","entnewvalueh"),sel+"?","");
if(newType.equals("?"))
{
for(int i=0;i<sel.length();i++)
mob.tell(sel.charAt(i)+") "+Weapon.classifictionDescription[i]);
q=false;
}
else
{
q=true;
int newValue=-1;
if(newType.length()>0)
newValue=sel.indexOf(newType.toUpperCase());
if(newValue>=0)
E.setWeaponClassification(newValue);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
}
public static void genSecretIdentity(MOB mob, Item E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","secretid",showNumber+"",E.rawSecretIdentity()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
String newValue=mob.session().prompt(getScr("BaseGenerics","entnewid"),"");
if(newValue.equalsIgnoreCase("null"))
E.setSecretIdentity("");
else
if(newValue.length()>0)
E.setSecretIdentity(newValue);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
public static void genNourishment(MOB mob, Food E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
mob.tell(getScr("BaseGenerics","noureat",showNumber+"",E.nourishment()+""));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
int newValue=CMath.s_int(mob.session().prompt(getScr("BaseGenerics","entnewamount"),""));
if(newValue>0)
E.setNourishment(newValue);
else
mob.tell(getScr("BaseGenerics","nochange"));
}
public static void genRace(MOB mob, MOB E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
String raceID="begin!";
while((mob.session()!=null)&&(!mob.session().killFlag())&&(raceID.length()>0))
{
mob.tell(getScr("BaseGenerics","race",showNumber+"",E.baseCharStats().getMyRace().ID()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
raceID=mob.session().prompt(getScr("BaseGenerics","entnewrace"),"").trim();
if(raceID.equalsIgnoreCase("?"))
mob.tell(CMLib.lister().reallyList(CMClass.races(),-1).toString());
else
if(raceID.length()==0)
mob.tell(getScr("BaseGenerics","nochange"));
else
{
Race R=CMClass.getRace(raceID);
if(R!=null)
{
E.baseCharStats().setMyRace(R);
E.baseCharStats().getMyRace().startRacing(E,false);
E.baseCharStats().getMyRace().setHeightWeight(E.baseEnvStats(),(char)E.baseCharStats().getStat(CharStats.STAT_GENDER));
}
else
mob.tell(getScr("BaseGenerics","unknownrace"));
}
}
}
public static void genCharClass(MOB mob, MOB E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
String classID="begin!";
while((mob.session()!=null)&&(!mob.session().killFlag())&&(classID.length()>0))
{
StringBuffer str=new StringBuffer("");
for(int c=0;c<E.baseCharStats().numClasses();c++)
{
CharClass C=E.baseCharStats().getMyClass(c);
str.append(C.ID()+"("+E.baseCharStats().getClassLevel(C)+") ");
}
mob.tell(getScr("BaseGenerics","classline",showNumber+"",str.toString()));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
classID=mob.session().prompt(getScr("BaseGenerics","entclassar"),"").trim();
if(classID.equalsIgnoreCase("?"))
mob.tell(CMLib.lister().reallyList(CMClass.charClasses(),-1).toString());
else
if(classID.length()==0)
mob.tell(getScr("BaseGenerics","nochange"));
else
{
CharClass C=CMClass.getCharClass(classID);
if(C!=null)
{
if(E.baseCharStats().getClassLevel(C)>=0)
{
if(E.baseCharStats().numClasses()<2)
mob.tell(getScr("BaseGenerics","finalclassmsg"));
else
{
StringBuffer charClasses=new StringBuffer("");
StringBuffer classLevels=new StringBuffer("");
for(int c=0;c<E.baseCharStats().numClasses();c++)
{
CharClass C2=E.baseCharStats().getMyClass(c);
int L2=E.baseCharStats().getClassLevel(C2);
if(C2!=C)
{
charClasses.append(";"+C2.ID());
classLevels.append(";"+L2);
}
}
E.baseCharStats().setMyClasses(charClasses.toString());
E.baseCharStats().setMyLevels(classLevels.toString());
}
}
else
{
int highLvl=Integer.MIN_VALUE;
CharClass highestC=null;
for(int c=0;c<E.baseCharStats().numClasses();c++)
{
CharClass C2=E.baseCharStats().getMyClass(c);
if(E.baseCharStats().getClassLevel(C2)>highLvl)
{
highestC=C2;
highLvl=E.baseCharStats().getClassLevel(C2);
}
}
E.baseCharStats().setCurrentClass(C);
int levels=E.baseCharStats().combinedSubLevels();
levels=E.baseEnvStats().level()-levels;
String lvl=null;
if(levels>0)
{
lvl=mob.session().prompt(getScr("BaseGenerics","levelsclass",levels+""),""+levels).trim();
int lvl2=CMath.s_int(lvl);
if(lvl2>levels) lvl2=levels;
E.baseCharStats().setClassLevel(C,lvl2);
}
else
{
lvl=mob.session().prompt(getScr("BaseGenerics","siphon",highestC.ID()),""+0).trim();
int lvl2=CMath.s_int(lvl);
if(lvl2>highLvl) lvl2=highLvl;
E.baseCharStats().setClassLevel(highestC,highLvl-lvl2);
E.baseCharStats().setClassLevel(C,lvl2);
}
}
int levels=E.baseCharStats().combinedSubLevels();
levels=E.baseEnvStats().level()-levels;
C=E.baseCharStats().getCurrentClass();
E.baseCharStats().setClassLevel(C,levels);
}
else
mob.tell(getScr("BaseGenerics","classerr"));
}
}
}
public static void genTattoos(MOB mob, MOB E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
String behave="NO";
while((mob.session()!=null)&&(!mob.session().killFlag())&&(behave.length()>0))
{
String behaviorstr="";
for(int b=0;b<E.numTattoos();b++)
{
String B=E.fetchTattoo(b);
if(B!=null) behaviorstr+=B+", ";
}
if(behaviorstr.length()>0)
behaviorstr=behaviorstr.substring(0,behaviorstr.length()-2);
mob.tell(getScr("BaseGenerics","tattoos",showNumber+"",behaviorstr));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
behave=mob.session().prompt(getScr("BaseGenerics","tattooent"),"");
if(behave.length()>0)
{
String tattoo=behave;
if((tattoo.length()>0)
&&(Character.isDigit(tattoo.charAt(0)))
&&(tattoo.indexOf(" ")>0)
&&(CMath.isNumber(tattoo.substring(0,tattoo.indexOf(" ")))))
tattoo=tattoo.substring(tattoo.indexOf(" ")+1).trim();
if(E.fetchTattoo(tattoo)!=null)
{
mob.tell(getScr("BaseGenerics","tattoorem",tattoo.trim().toUpperCase()));
E.delTattoo(behave);
}
else
{
mob.tell(getScr("BaseGenerics","tattooadd",behave.trim().toUpperCase()));
E.addTattoo(behave);
}
}
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
public static void genTitles(MOB mob, MOB E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
if(E.playerStats()==null) return;
String behave="NO";
while((mob.session()!=null)&&(!mob.session().killFlag())&&(behave.length()>0))
{
String behaviorstr="";
for(int b=0;b<E.playerStats().getTitles().size();b++)
{
String B=(String)E.playerStats().getTitles().elementAt(b);
if(B!=null) behaviorstr+=B+", ";
}
if(behaviorstr.length()>0)
behaviorstr=behaviorstr.substring(0,behaviorstr.length()-2);
mob.tell(getScr("BaseGenerics","titles",showNumber+"",behaviorstr));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
behave=mob.session().prompt(getScr("BaseGenerics","titleent"),"");
if(behave.length()>0)
{
String tattoo=behave;
if((tattoo.length()>0)
&&(CMath.isInteger(tattoo))
&&(CMath.s_int(tattoo)>0)
&&(CMath.s_int(tattoo)<=E.playerStats().getTitles().size()))
tattoo=(String)E.playerStats().getTitles().elementAt(CMath.s_int(tattoo)-1);
else
if((tattoo.length()>0)
&&(Character.isDigit(tattoo.charAt(0)))
&&(tattoo.indexOf(" ")>0)
&&(CMath.isNumber(tattoo.substring(0,tattoo.indexOf(" ")))))
tattoo=tattoo.substring(tattoo.indexOf(" ")+1).trim();
if(E.playerStats().getTitles().contains(tattoo))
{
mob.tell(getScr("BaseGenerics","tattoorem",tattoo.trim().toUpperCase()));
E.playerStats().getTitles().remove(tattoo);
}
else
{
mob.tell(getScr("BaseGenerics","tattooadd",behave.trim().toUpperCase()));
E.playerStats().getTitles().addElement(tattoo);
}
}
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
public static void genExpertises(MOB mob, MOB E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
String behave="NO";
while((mob.session()!=null)&&(!mob.session().killFlag())&&(behave.length()>0))
{
String behaviorstr="";
for(int b=0;b<E.numExpertises();b++)
{
String B=E.fetchExpertise(b);
if(B!=null) behaviorstr+=B+", ";
}
if(behaviorstr.length()>0)
behaviorstr=behaviorstr.substring(0,behaviorstr.length()-2);
mob.tell(getScr("BaseGenerics","expertises",showNumber+"",behaviorstr));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
behave=mob.session().prompt(getScr("BaseGenerics","lessonent"),"");
if(behave.length()>0)
{
if(E.fetchExpertise(behave)!=null)
{
mob.tell(getScr("BaseGenerics","behaverem",behave));
E.delExpertise(behave);
}
else
{
mob.tell(getScr("BaseGenerics","behaveadd",behave));
E.addExpertise(behave);
}
}
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
public static void genSecurity(MOB mob, MOB E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
PlayerStats P=E.playerStats();
if(P==null) return;
String behave="NO";
while((mob.session()!=null)&&(!mob.session().killFlag())&&(behave.length()>0))
{
String behaviorstr="";
for(int b=0;b<P.getSecurityGroups().size();b++)
{
String B=(String)P.getSecurityGroups().elementAt(b);
if(B!=null) behaviorstr+=B+", ";
}
if(behaviorstr.length()>0)
behaviorstr=behaviorstr.substring(0,behaviorstr.length()-2);
mob.tell(getScr("BaseGenerics","secgroups",showNumber+"",behaviorstr));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
behave=mob.session().prompt(getScr("BaseGenerics","groupent"),"");
if(behave.length()>0)
{
if(P.getSecurityGroups().contains(behave.trim().toUpperCase()))
{
P.getSecurityGroups().remove(behave.trim().toUpperCase());
mob.tell(getScr("BaseGenerics","behaverem",behave));
}
else
if((behave.trim().toUpperCase().startsWith("AREA "))
&&(!CMSecurity.isAllowedAnywhere(mob,behave.trim().toUpperCase().substring(5).trim())))
mob.tell(getScr("BaseGenerics","behavebad",behave));
else
if((!behave.trim().toUpperCase().startsWith("AREA "))
&&(!CMSecurity.isAllowedEverywhere(mob,behave.trim().toUpperCase())))
mob.tell(getScr("BaseGenerics","behavebad",behave));
else
{
P.getSecurityGroups().addElement(behave.trim().toUpperCase());
mob.tell(getScr("BaseGenerics","behaveadd",behave));
}
}
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
public static void genBehaviors(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
String behave="NO";
while((mob.session()!=null)&&(!mob.session().killFlag())&&(behave.length()>0))
{
String behaviorstr="";
for(int b=0;b<E.numBehaviors();b++)
{
Behavior B=E.fetchBehavior(b);
if((B!=null)&&(B.isSavable()))
{
behaviorstr+=B.ID();
if(B.getParms().trim().length()>0)
behaviorstr+="("+B.getParms().trim()+"), ";
else
behaviorstr+=", ";
}
}
if(behaviorstr.length()>0)
behaviorstr=behaviorstr.substring(0,behaviorstr.length()-2);
mob.tell(getScr("BaseGenerics","behaviorsline",showNumber+"",behaviorstr));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
behave=mob.session().prompt(getScr("BaseGenerics","behaent"),"");
if(behave.length()>0)
{
if(behave.equalsIgnoreCase("?"))
mob.tell(CMLib.lister().reallyList(CMClass.behaviors(),-1).toString());
else
{
Behavior chosenOne=null;
for(int b=0;b<E.numBehaviors();b++)
{
Behavior B=E.fetchBehavior(b);
if((B!=null)&&(B.ID().equalsIgnoreCase(behave)))
chosenOne=B;
}
if(chosenOne!=null)
{
mob.tell(getScr("BaseGenerics","cidr",chosenOne.ID()));
E.delBehavior(chosenOne);
}
else
{
chosenOne=CMClass.getBehavior(behave);
if(chosenOne!=null)
{
boolean alreadyHasIt=false;
for(int b=0;b<E.numBehaviors();b++)
{
Behavior B=E.fetchBehavior(b);
if((B!=null)&&(B.ID().equals(chosenOne.ID())))
{
alreadyHasIt=true;
chosenOne=B;
}
}
String parms="?";
while(parms.equals("?"))
{
parms=chosenOne.getParms();
parms=mob.session().prompt(getScr("BaseGenerics","behapar",parms));
if(parms.equals("?")){ StringBuffer s2=CMLib.help().getHelpText(chosenOne.ID(),mob,true); if(s2!=null) mob.tell(s2.toString()); else mob.tell("no help!");}
}
chosenOne.setParms(parms.trim());
if(!alreadyHasIt)
{
mob.tell(getScr("BaseGenerics","cida",chosenOne.ID()));
E.addBehavior(chosenOne);
}
else
mob.tell(getScr("BaseGenerics","cidaa",chosenOne.ID()));
}
else
{
mob.tell(getScr("BaseGenerics","behaveerr",behave));
}
}
}
}
else
mob.tell(getScr("BaseGenerics","nochange"));
}
}
public static void genAffects(MOB mob, Environmental E, int showNumber, int showFlag)
throws IOException
{
if((showFlag>0)&&(showFlag!=showNumber)) return;
String behave="NO";
while((mob.session()!=null)&&(!mob.session().killFlag())&&(behave.length()>0))
{
String affectstr="";
for(int b=0;b<E.numEffects();b++)
{
Ability A=E.fetchEffect(b);
if((A!=null)&&(A.savable()))
{
affectstr+=A.ID();
if(A.text().trim().length()>0)
affectstr+="("+A.text().trim()+"), ";
else
affectstr+=", ";
}
}
if(affectstr.length()>0)
affectstr=affectstr.substring(0,affectstr.length()-2);
mob.tell(getScr("BaseGenerics","effects",showNumber+"",affectstr));
if((showFlag!=showNumber)&&(showFlag>-999)) return;
behave=mob.session().prompt(getScr("BaseGenerics","effectent"),"");
if(behave.length()>0)
{
if(behave.equalsIgnoreCase("?"))
mob.tell(CMLib.lister().reallyList(CMClass.abilities(),-1).toString());
else
{
Ability chosenOne=null;
for(int a=0;a<E.numEffects();a++)
{
Ability A=E.fetchEffect(a);
if((A!=null)&&(A.ID().equalsIgnoreCase(behave)))
chosenOne=A;
}
if(chosenOne!=null)
{
mob.tell(getScr("BaseGenerics","cidr",chosenOne.ID()));
E.delEffect(chosenOne);
}
else
{
chosenOne=CMClass.getAbility(behave);
if(chosenOne!=null)
{
String parms="?";
while(parms.equals("?"))
{
parms=chosenOne.text();
parms=mob.session().prompt(getScr("BaseGenerics","effectpar",parms));
if(parms.equals("?")){ StringBuffer s2=CMLib.help().getHelpText(chosenOne.IShowing the first 100 KB of 264.0 KB. Download the archive for the full file.