<NME> Fighter_PlanarVeteran.java
<BEF> package com.planet_ink.coffee_mud.Abilities.Fighter;
import com.planet_ink.coffee_mud.core.interfaces.*;
import com.planet_ink.coffee_mud.core.*;
import com.planet_ink.coffee_mud.core.collections.*;
import com.planet_ink.coffee_mud.Abilities.interfaces.*;
import com.planet_ink.coffee_mud.Abilities.interfaces.PlanarAbility.PlanarVar;
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.Common.interfaces.Faction.Align;
import com.planet_ink.coffee_mud.Exits.interfaces.*;
import com.planet_ink.coffee_mud.Items.interfaces.*;
import com.planet_ink.coffee_mud.Libraries.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.util.Map.Entry;

/*
   Copyright 2020-2022 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 Fighter_PlanarVeteran extends FighterSkill
{
	@Override
	public String ID()
	{
		return "Fighter_PlanarVeteran";
	}

	private final static String localizedName = CMLib.lang().L("Planar Veteran");

	@Override
	public String name()
	{
		return localizedName;
	}

	@Override
	public String displayText()
	{
		return "";
	}

	@Override
	protected int canAffectCode()
	{
		return CAN_MOBS;
	}

	@Override
	protected int canTargetCode()
	{
		return 0;
	}

	@Override
	public int abstractQuality()
	{
		return Ability.QUALITY_BENEFICIAL_SELF;
	}

	@Override
	public int classificationCode()
	{
		return Ability.ACODE_SKILL|Ability.DOMAIN_NATURELORE;
	}

	@Override
	public boolean isAutoInvoked()
	{
		return true;
	}

	@Override
	public boolean canBeUninvoked()
	{
		return false;
	}

	private static final Integer[] landClasses = { Integer.valueOf(-1) };

	public Integer[] landClasses()
	{
		return landClasses;
	}

	protected volatile long		nextExpire	= Long.MAX_VALUE;
	protected volatile Area		lastArea	= null;
	protected Map<String, Long>	visits		= new STreeMap<String, Long>();
	protected final static CMParms.DelimiterChecker COMMA_DELIMITER=CMParms.createDelimiter(new char[]{','});

	protected final static int STAT_ARMOR=0;
	protected final static int STAT_DAMAGE=1;
	protected final static int STAT_MOVES=2;
	protected final static int STAT_HITPOINTS=3;
	protected final static int STAT_SPEED=4;
	protected final static int STAT_MINDSAVE=5;
	protected final static int STAT_ATTACK=6;
	protected final static int STAT_ALL=7;

	protected final int[] statBonus	= new int[STAT_ALL];

	protected synchronized void rebuildBonuses()
	{
		Arrays.fill(statBonus, 0);
		final PlanarAbility planeA=(PlanarAbility)CMClass.getAbility("StdPlanarAbility");
		for(final Iterator<String> pl = getUpperVisitations().keySet().iterator();pl.hasNext(); )
		{
			final String plane = pl.next();
			final Map<String,String> planeVars = planeA.getPlanarVars(plane);
			if((planeVars != null)
			&&(planeVars.size()>0))
			{
				final String catStr=planeVars.get(PlanarVar.CATEGORY.toString());
				if(catStr != null)
				{
					final List<String> categories=CMParms.parseCommas(catStr.toLowerCase(), true);
					if(categories.contains("inner"))
						statBonus[STAT_ARMOR] += 2;
					if(categories.contains("transitional"))
						statBonus[STAT_SPEED] += 10;
					final Faction aF=CMLib.factions().getFaction(CMLib.factions().getAlignmentID());
					if(categories.contains("outer"))
					{
						final List<com.planet_ink.coffee_mud.Common.interfaces.Faction.Align> aligns = new
								ArrayList<com.planet_ink.coffee_mud.Common.interfaces.Faction.Align>();
						if(aF!=null)
						{
							final int align = CMath.s_int(planeVars.get(PlanarVar.ALIGNMENT.name()));
							final Faction.FRange range = aF.fetchRange(align);
							if((range != null)&&(range.alignEquiv()!=Align.INDIFF))
								aligns.add(range.alignEquiv());
						}
						final String factions = planeVars.get(PlanarVar.FACTIONS.toString());
						if(factions!=null)
						{
							final PairList<String,String> factionList=new PairVector<String,String>(CMParms.parseSpaceParenList(factions));
							for(final Pair<String,String> p : factionList)
							{
								final String factionName = p.first;
								if(p.first.equals("*"))
									continue;
								Faction F=null;
								if(CMLib.factions().isFactionID(factionName))
									F=CMLib.factions().getFaction(factionName);
								if(F==null)
									F=CMLib.factions().getFactionByName(factionName);
								if(F!=null)
								{
									Faction.FRange FR;
									if(CMath.isInteger(p.second))
										FR=F.fetchRange(CMath.s_int(p.second));
									else
										FR = F.fetchRange(p.second);
									if((FR != null)&&(FR.alignEquiv()!=Align.INDIFF))
										aligns.add(FR.alignEquiv());
								}
							}
						}
						for(final Align A : aligns)
						{
							switch(A)
							{
							case GOOD:
								statBonus[STAT_MOVES] += 5;
								break;
							case NEUTRAL:
								statBonus[STAT_HITPOINTS] += 5;
								break;
							case EVIL:
								statBonus[STAT_DAMAGE] += 1;
								break;
							case LAWFUL:
								statBonus[STAT_MINDSAVE] += 3;
								break;
							case MODERATE:
								statBonus[STAT_ARMOR] += 2;
								break;
							case CHAOTIC:
								statBonus[STAT_ATTACK] += 1;
								break;
							default:
								break;
							}
						}
					}
				}
			}
		}
	}

	protected boolean hasVisited(final String plane)
	{
		return getUpperVisitations().containsKey(plane.toUpperCase().trim());
	}

	protected void addVisitation(final String plane)
	{
		final Map<String, Long> visits = getUpperVisitations();
		final String uplane = plane.toUpperCase().trim();
		if(!visits.containsKey(uplane))
		{
			final MOB M=(affected instanceof MOB)?(MOB)affected:invoker();
			final long expires = System.currentTimeMillis()
					+ (60000L * (M.phyStats().level() * (60 + (30 * super.getXTIMELevel(M)) )));
			visits.put(uplane, Long.valueOf(expires));
			if(expires < this.nextExpire)
				this.nextExpire = expires;
			setMiscText(buildVisitsParm(visits));
			rebuildBonuses();
		}
	}

	protected void parseVisits(final String text)
	{
		visits.clear();
		final Map<String,String> temp = CMParms.parseEQParms(text(), COMMA_DELIMITER, true);
		for(final String tKey : temp.keySet())
			visits.put(tKey, Long.valueOf(CMath.s_long(temp.get(tKey))));
	}

	protected String buildVisitsParm(final Map<String,Long> visits)
	{
		return CMParms.toEqListString(visits,',');
	}

	protected Map<String, Long> getUpperVisitations()
	{
		if((visits.size()==0)&&(text().length()>0))
		{
			parseVisits(text());
			rebuildBonuses();
			checkExpiredVisits();
		}
		return visits;
	}

	protected void checkExpiredVisits()
	{
		final Map<String,Long> visits = getUpperVisitations();
		boolean changed = false;
		long nextMs = Long.MAX_VALUE;
		final long now=System.currentTimeMillis();
		for(final Iterator<Entry<String,Long>> e=visits.entrySet().iterator();e.hasNext();)
		{
			final Entry<String,Long> E=e.next();
			final long expires = E.getValue().longValue();
			if(now > expires)
			{
				e.remove();
				changed=true;
			}
			else
			if(expires < nextMs)
				nextMs = expires;
		}
		if(changed)
		{
			setMiscText(buildVisitsParm(visits));
			rebuildBonuses();
		}
		this.nextExpire = nextMs;
	}

	@Override
	public boolean tick(final Tickable ticking, final int tickID)
	{
		if(!super.tick(ticking,tickID))
			return false;
		final Physical P=affected;
		if(P instanceof MOB)
		{
			final MOB mob=(MOB)P;
			final Room R=mob.location();
			final Area A=(R!=null)?R.getArea():null;
			if((A != null)&&(A != lastArea))
			{
				final String curPlane = CMLib.flags().getPlaneOfExistence(A);
				lastArea=A;
				if((curPlane != null)
				&&(curPlane.trim().length()>0)
				&&(!hasVisited(curPlane)))
					addVisitation(curPlane);
			}
			getUpperVisitations(); // to ensure bonuses exist always
			if(System.currentTimeMillis() > nextExpire)
				checkExpiredVisits();
		}
		return true;
	}

	@Override
	public boolean okMessage(final Environmental myHost, final CMMsg msg)
	{
		return super.okMessage(myHost,msg);
	}

	@Override
	public void affectPhyStats(final Physical affected, final PhyStats affectableStats)
	{
		super.affectPhyStats(affected,affectableStats);
		if(statBonus[STAT_ARMOR] != 0)
			affectableStats.setArmor(affectableStats.armor()-statBonus[STAT_ARMOR]);
		if(statBonus[STAT_DAMAGE] != 0)
			affectableStats.setDamage(affectableStats.damage()+statBonus[STAT_DAMAGE]);
		if(statBonus[STAT_SPEED] != 0)
			affectableStats.setSpeed(affectableStats.speed()+(CMProps.getSpeedAdjustment()*CMath.div(statBonus[STAT_SPEED],100.0)));
		if(statBonus[STAT_ATTACK] != 0)
			affectableStats.setAttackAdjustment(affectableStats.attackAdjustment()+statBonus[STAT_ATTACK]);
	}

	@Override
	public void affectCharState(final MOB mob, final CharState affectableState)
	{
		super.affectCharState(mob,affectableState);
		if(statBonus[STAT_MOVES] != 0)
			affectableState.setMovement(affectableState.getMovement() + statBonus[STAT_MOVES]);
		if(statBonus[STAT_HITPOINTS] != 0)
			affectableState.setHitPoints(affectableState.getHitPoints() + statBonus[STAT_HITPOINTS]);
	}

	@Override
	public void affectCharStats(final MOB affectedMOB, final CharStats affectableStats)
	{
		super.affectCharStats(affectedMOB, affectableStats);
		if(statBonus[STAT_MINDSAVE] != 0)
			affectableStats.setStat(CharStats.STAT_SAVE_MIND,
					statBonus[STAT_MINDSAVE]+affectableStats.getStat(CharStats.STAT_SAVE_MIND));
	}
}

<MSG> 

git-svn-id: svn://192.168.1.10/public/CoffeeMud@19723 0d6f1817-ed0e-0410-87c9-987e46238f29

<DFF> @@ -263,7 +263,7 @@ public class Fighter_PlanarVeteran extends FighterSkill
 			final long expires = E.getValue().longValue();
 			if(now > expires)
 			{
-				e.remove();
+				visits.remove(E);
 				changed=true;
 			}
 			else

{'commit': 'diff --git a/com/planet_ink/coffee_mud/Abilities/Fighter/Fighter_PlanarVeteran.java b/com/planet_ink/coffee_mud/Abilities/Fighter/Fighter_PlanarVeteran.java\nindex eebf79c04a..2ce179a49b 100644\n--- a/com/planet_ink/coffee_mud/Abilities/Fighter/Fighter_PlanarVeteran.java\n+++ b/com/planet_ink/coffee_mud/Abilities/Fighter/Fighter_PlanarVeteran.java\n@@ -263,7 +263,7 @@ public class Fighter_PlanarVeteran extends FighterSkill\n \t\t\tfinal long expires = E.getValue().longValue();\r\n \t\t\tif(now > expires)\r\n \t\t\t{\r\n-\t\t\t\te.remove();\r\n+\t\t\t\tvisits.remove(E);\r\n \t\t\t\tchanged=true;\r\n \t\t\t}\r\n \t\t\telse\r\n', 'commit_subject': '', 'repo_name': 'bozimmerman/CoffeeMud', 'committer': {'name': 'bozimmerman', 'email': 'dc45fe023482b3b890b5e574e53c1d051f45b1ef@zimmers.net', 'time_sec': '1601781858', 'tz_offset': '0', 'date': {'seconds': '1601781858'}}, 'commit_tree': '18625f220a17efe3011450c09bda25f8da11407c', 'commit_message': '\n\ngit-svn-id: svn://192.168.1.10/public/CoffeeMud@19723 0d6f1817-ed0e-0410-87c9-987e46238f29\n', 'language_name': 'JavaScript', 'license': 'apache-2.0', 'hunks': '@@ -263,7 +263,7 @@ public class Fighter_PlanarVeteran extends FighterSkill\n \t\t\tfinal long expires = E.getValue().longValue();\r\n \t\t\tif(now > expires)\r\n \t\t\t{\r\n-\t\t\t\te.remove();\r\n+\t\t\t\tvisits.remove(E);\r\n \t\t\t\tchanged=true;\r\n \t\t\t}\r\n \t\t\telse\r\n', 'addition_count': 1, 'deletion_count': 1, 'src_file': 'a/com/planet_ink/coffee_mud/Abilities/Fighter/Fighter_PlanarVeteran.java', 'tgt_file': 'b/com/planet_ink/coffee_mud/Abilities/Fighter/Fighter_PlanarVeteran.java', 'file_extension': '.java', 'before_file': 'package com.planet_ink.coffee_mud.Abilities.Fighter;\nimport com.planet_ink.coffee_mud.core.interfaces.*;\nimport com.planet_ink.coffee_mud.core.*;\nimport com.planet_ink.coffee_mud.core.collections.*;\nimport com.planet_ink.coffee_mud.Abilities.interfaces.*;\nimport com.planet_ink.coffee_mud.Abilities.interfaces.PlanarAbility.PlanarVar;\nimport com.planet_ink.coffee_mud.Areas.interfaces.*;\nimport com.planet_ink.coffee_mud.Behaviors.interfaces.*;\nimport com.planet_ink.coffee_mud.CharClasses.interfaces.*;\nimport com.planet_ink.coffee_mud.Commands.interfaces.*;\nimport com.planet_ink.coffee_mud.Common.interfaces.*;\nimport com.planet_ink.coffee_mud.Common.interfaces.Faction.Align;\nimport com.planet_ink.coffee_mud.Exits.interfaces.*;\nimport com.planet_ink.coffee_mud.Items.interfaces.*;\nimport com.planet_ink.coffee_mud.Libraries.interfaces.*;\nimport com.planet_ink.coffee_mud.Locales.interfaces.*;\nimport com.planet_ink.coffee_mud.MOBS.interfaces.*;\nimport com.planet_ink.coffee_mud.Races.interfaces.*;\n\nimport java.util.*;\nimport java.util.Map.Entry;\n\n/*\n   Copyright 2020-2022 Bo Zimmerman\n\n   Licensed under the Apache License, Version 2.0 (the "License");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an "AS IS" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n*/\npublic class Fighter_PlanarVeteran extends FighterSkill\n{\n\t@Override\n\tpublic String ID()\n\t{\n\t\treturn "Fighter_PlanarVeteran";\n\t}\n\n\tprivate final static String localizedName = CMLib.lang().L("Planar Veteran");\n\n\t@Override\n\tpublic String name()\n\t{\n\t\treturn localizedName;\n\t}\n\n\t@Override\n\tpublic String displayText()\n\t{\n\t\treturn "";\n\t}\n\n\t@Override\n\tprotected int canAffectCode()\n\t{\n\t\treturn CAN_MOBS;\n\t}\n\n\t@Override\n\tprotected int canTargetCode()\n\t{\n\t\treturn 0;\n\t}\n\n\t@Override\n\tpublic int abstractQuality()\n\t{\n\t\treturn Ability.QUALITY_BENEFICIAL_SELF;\n\t}\n\n\t@Override\n\tpublic int classificationCode()\n\t{\n\t\treturn Ability.ACODE_SKILL|Ability.DOMAIN_NATURELORE;\n\t}\n\n\t@Override\n\tpublic boolean isAutoInvoked()\n\t{\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic boolean canBeUninvoked()\n\t{\n\t\treturn false;\n\t}\n\n\tprivate static final Integer[] landClasses = { Integer.valueOf(-1) };\n\n\tpublic Integer[] landClasses()\n\t{\n\t\treturn landClasses;\n\t}\n\n\tprotected volatile long\t\tnextExpire\t= Long.MAX_VALUE;\n\tprotected volatile Area\t\tlastArea\t= null;\n\tprotected Map<String, Long>\tvisits\t\t= new STreeMap<String, Long>();\n\tprotected final static CMParms.DelimiterChecker COMMA_DELIMITER=CMParms.createDelimiter(new char[]{\',\'});\n\n\tprotected final static int STAT_ARMOR=0;\n\tprotected final static int STAT_DAMAGE=1;\n\tprotected final static int STAT_MOVES=2;\n\tprotected final static int STAT_HITPOINTS=3;\n\tprotected final static int STAT_SPEED=4;\n\tprotected final static int STAT_MINDSAVE=5;\n\tprotected final static int STAT_ATTACK=6;\n\tprotected final static int STAT_ALL=7;\n\n\tprotected final int[] statBonus\t= new int[STAT_ALL];\n\n\tprotected synchronized void rebuildBonuses()\n\t{\n\t\tArrays.fill(statBonus, 0);\n\t\tfinal PlanarAbility planeA=(PlanarAbility)CMClass.getAbility("StdPlanarAbility");\n\t\tfor(final Iterator<String> pl = getUpperVisitations().keySet().iterator();pl.hasNext(); )\n\t\t{\n\t\t\tfinal String plane = pl.next();\n\t\t\tfinal Map<String,String> planeVars = planeA.getPlanarVars(plane);\n\t\t\tif((planeVars != null)\n\t\t\t&&(planeVars.size()>0))\n\t\t\t{\n\t\t\t\tfinal String catStr=planeVars.get(PlanarVar.CATEGORY.toString());\n\t\t\t\tif(catStr != null)\n\t\t\t\t{\n\t\t\t\t\tfinal List<String> categories=CMParms.parseCommas(catStr.toLowerCase(), true);\n\t\t\t\t\tif(categories.contains("inner"))\n\t\t\t\t\t\tstatBonus[STAT_ARMOR] += 2;\n\t\t\t\t\tif(categories.contains("transitional"))\n\t\t\t\t\t\tstatBonus[STAT_SPEED] += 10;\n\t\t\t\t\tfinal Faction aF=CMLib.factions().getFaction(CMLib.factions().getAlignmentID());\n\t\t\t\t\tif(categories.contains("outer"))\n\t\t\t\t\t{\n\t\t\t\t\t\tfinal List<com.planet_ink.coffee_mud.Common.interfaces.Faction.Align> aligns = new\n\t\t\t\t\t\t\t\tArrayList<com.planet_ink.coffee_mud.Common.interfaces.Faction.Align>();\n\t\t\t\t\t\tif(aF!=null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfinal int align = CMath.s_int(planeVars.get(PlanarVar.ALIGNMENT.name()));\n\t\t\t\t\t\t\tfinal Faction.FRange range = aF.fetchRange(align);\n\t\t\t\t\t\t\tif((range != null)&&(range.alignEquiv()!=Align.INDIFF))\n\t\t\t\t\t\t\t\taligns.add(range.alignEquiv());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfinal String factions = planeVars.get(PlanarVar.FACTIONS.toString());\n\t\t\t\t\t\tif(factions!=null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfinal PairList<String,String> factionList=new PairVector<String,String>(CMParms.parseSpaceParenList(factions));\n\t\t\t\t\t\t\tfor(final Pair<String,String> p : factionList)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfinal String factionName = p.first;\n\t\t\t\t\t\t\t\tif(p.first.equals("*"))\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\tFaction F=null;\n\t\t\t\t\t\t\t\tif(CMLib.factions().isFactionID(factionName))\n\t\t\t\t\t\t\t\t\tF=CMLib.factions().getFaction(factionName);\n\t\t\t\t\t\t\t\tif(F==null)\n\t\t\t\t\t\t\t\t\tF=CMLib.factions().getFactionByName(factionName);\n\t\t\t\t\t\t\t\tif(F!=null)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tFaction.FRange FR;\n\t\t\t\t\t\t\t\t\tif(CMath.isInteger(p.second))\n\t\t\t\t\t\t\t\t\t\tFR=F.fetchRange(CMath.s_int(p.second));\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tFR = F.fetchRange(p.second);\n\t\t\t\t\t\t\t\t\tif((FR != null)&&(FR.alignEquiv()!=Align.INDIFF))\n\t\t\t\t\t\t\t\t\t\taligns.add(FR.alignEquiv());\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor(final Align A : aligns)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tswitch(A)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase GOOD:\n\t\t\t\t\t\t\t\tstatBonus[STAT_MOVES] += 5;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase NEUTRAL:\n\t\t\t\t\t\t\t\tstatBonus[STAT_HITPOINTS] += 5;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase EVIL:\n\t\t\t\t\t\t\t\tstatBonus[STAT_DAMAGE] += 1;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase LAWFUL:\n\t\t\t\t\t\t\t\tstatBonus[STAT_MINDSAVE] += 3;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase MODERATE:\n\t\t\t\t\t\t\t\tstatBonus[STAT_ARMOR] += 2;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase CHAOTIC:\n\t\t\t\t\t\t\t\tstatBonus[STAT_ATTACK] += 1;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected boolean hasVisited(final String plane)\n\t{\n\t\treturn getUpperVisitations().containsKey(plane.toUpperCase().trim());\n\t}\n\n\tprotected void addVisitation(final String plane)\n\t{\n\t\tfinal Map<String, Long> visits = getUpperVisitations();\n\t\tfinal String uplane = plane.toUpperCase().trim();\n\t\tif(!visits.containsKey(uplane))\n\t\t{\n\t\t\tfinal MOB M=(affected instanceof MOB)?(MOB)affected:invoker();\n\t\t\tfinal long expires = System.currentTimeMillis()\n\t\t\t\t\t+ (60000L * (M.phyStats().level() * (60 + (30 * super.getXTIMELevel(M)) )));\n\t\t\tvisits.put(uplane, Long.valueOf(expires));\n\t\t\tif(expires < this.nextExpire)\n\t\t\t\tthis.nextExpire = expires;\n\t\t\tsetMiscText(buildVisitsParm(visits));\n\t\t\trebuildBonuses();\n\t\t}\n\t}\n\n\tprotected void parseVisits(final String text)\n\t{\n\t\tvisits.clear();\n\t\tfinal Map<String,String> temp = CMParms.parseEQParms(text(), COMMA_DELIMITER, true);\n\t\tfor(final String tKey : temp.keySet())\n\t\t\tvisits.put(tKey, Long.valueOf(CMath.s_long(temp.get(tKey))));\n\t}\n\n\tprotected String buildVisitsParm(final Map<String,Long> visits)\n\t{\n\t\treturn CMParms.toEqListString(visits,\',\');\n\t}\n\n\tprotected Map<String, Long> getUpperVisitations()\n\t{\n\t\tif((visits.size()==0)&&(text().length()>0))\n\t\t{\n\t\t\tparseVisits(text());\n\t\t\trebuildBonuses();\n\t\t\tcheckExpiredVisits();\n\t\t}\n\t\treturn visits;\n\t}\n\n\tprotected void checkExpiredVisits()\n\t{\n\t\tfinal Map<String,Long> visits = getUpperVisitations();\n\t\tboolean changed = false;\n\t\tlong nextMs = Long.MAX_VALUE;\n\t\tfinal long now=System.currentTimeMillis();\n\t\tfor(final Iterator<Entry<String,Long>> e=visits.entrySet().iterator();e.hasNext();)\n\t\t{\n\t\t\tfinal Entry<String,Long> E=e.next();\n\t\t\tfinal long expires = E.getValue().longValue();\r\n\t\t\tif(now > expires)\r\n\t\t\t{\r\n\t\t\t\te.remove();\r\n\t\t\t\tchanged=true;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\tif(expires < nextMs)\n\t\t\t\tnextMs = expires;\n\t\t}\n\t\tif(changed)\n\t\t{\n\t\t\tsetMiscText(buildVisitsParm(visits));\n\t\t\trebuildBonuses();\n\t\t}\n\t\tthis.nextExpire = nextMs;\n\t}\n\n\t@Override\n\tpublic boolean tick(final Tickable ticking, final int tickID)\n\t{\n\t\tif(!super.tick(ticking,tickID))\n\t\t\treturn false;\n\t\tfinal Physical P=affected;\n\t\tif(P instanceof MOB)\n\t\t{\n\t\t\tfinal MOB mob=(MOB)P;\n\t\t\tfinal Room R=mob.location();\n\t\t\tfinal Area A=(R!=null)?R.getArea():null;\n\t\t\tif((A != null)&&(A != lastArea))\n\t\t\t{\n\t\t\t\tfinal String curPlane = CMLib.flags().getPlaneOfExistence(A);\n\t\t\t\tlastArea=A;\n\t\t\t\tif((curPlane != null)\n\t\t\t\t&&(curPlane.trim().length()>0)\n\t\t\t\t&&(!hasVisited(curPlane)))\n\t\t\t\t\taddVisitation(curPlane);\n\t\t\t}\n\t\t\tgetUpperVisitations(); // to ensure bonuses exist always\n\t\t\tif(System.currentTimeMillis() > nextExpire)\n\t\t\t\tcheckExpiredVisits();\n\t\t}\n\t\treturn true;\n\t}\n\n\t@Override\n\tpublic boolean okMessage(final Environmental myHost, final CMMsg msg)\n\t{\n\t\treturn super.okMessage(myHost,msg);\n\t}\n\n\t@Override\n\tpublic void affectPhyStats(final Physical affected, final PhyStats affectableStats)\n\t{\n\t\tsuper.affectPhyStats(affected,affectableStats);\n\t\tif(statBonus[STAT_ARMOR] != 0)\n\t\t\taffectableStats.setArmor(affectableStats.armor()-statBonus[STAT_ARMOR]);\n\t\tif(statBonus[STAT_DAMAGE] != 0)\n\t\t\taffectableStats.setDamage(affectableStats.damage()+statBonus[STAT_DAMAGE]);\n\t\tif(statBonus[STAT_SPEED] != 0)\n\t\t\taffectableStats.setSpeed(affectableStats.speed()+(CMProps.getSpeedAdjustment()*CMath.div(statBonus[STAT_SPEED],100.0)));\n\t\tif(statBonus[STAT_ATTACK] != 0)\n\t\t\taffectableStats.setAttackAdjustment(affectableStats.attackAdjustment()+statBonus[STAT_ATTACK]);\n\t}\n\n\t@Override\n\tpublic void affectCharState(final MOB mob, final CharState affectableState)\n\t{\n\t\tsuper.affectCharState(mob,affectableState);\n\t\tif(statBonus[STAT_MOVES] != 0)\n\t\t\taffectableState.setMovement(affectableState.getMovement() + statBonus[STAT_MOVES]);\n\t\tif(statBonus[STAT_HITPOINTS] != 0)\n\t\t\taffectableState.setHitPoints(affectableState.getHitPoints() + statBonus[STAT_HITPOINTS]);\n\t}\n\n\t@Override\n\tpublic void affectCharStats(final MOB affectedMOB, final CharStats affectableStats)\n\t{\n\t\tsuper.affectCharStats(affectedMOB, affectableStats);\n\t\tif(statBonus[STAT_MINDSAVE] != 0)\n\t\t\taffectableStats.setStat(CharStats.STAT_SAVE_MIND,\n\t\t\t\t\tstatBonus[STAT_MINDSAVE]+affectableStats.getStat(CharStats.STAT_SAVE_MIND));\n\t}\n}\n', 'message': '\n\ngit-svn-id: svn://192.168.1.10/public/CoffeeMud@19723 0d6f1817-ed0e-0410-87c9-987e46238f29\n', 'author_name': 'bozimmerman', 'lang': 'java'}