From: <th...@us...> - 2008-07-27 19:31:31
|
Revision: 7252 http://pcgen.svn.sourceforge.net/pcgen/?rev=7252&view=rev Author: thpr Date: 2008-07-27 19:31:36 +0000 (Sun, 27 Jul 2008) Log Message: ----------- remove deprecated SA: ADD:SA Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/PCClass.java Trunk/pcgen/code/src/java/pcgen/core/PObject.java Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbility.java Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbilitySpecial.java Trunk/pcgen/code/src/java/pcgen/gui/AddSpecialAbility.java Trunk/pcgen/code/src/java/pcgen/gui/editor/ClassLevelPanel.java Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java Trunk/pcgen/code/src/test/plugin/PluginBuildTest.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SAToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SaLst.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/pluginbuild.xml 2008-07-27 19:31:36 UTC (rev 7252) @@ -6280,7 +6280,7 @@ </target> <target name="jar-deprecated-plugin" depends="manifest" description="Build (Link) plugin jar files"> - <jar jarfile="${lstplugins.dir}/ClassLstToken-HASSPELLFORMULA.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <jar jarfile="${lstplugins.dir}/ClassLstToken-DEPRECATED-HASSPELLFORMULA.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> <include name="plugin/lsttokens/deprecated/HasspellformulaToken.class" /> Modified: Trunk/pcgen/code/src/java/pcgen/core/PCClass.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -2444,20 +2444,6 @@ } } - final List<SpecialAbility> specialAbilityList = - getListFor(ListKey.SPECIAL_ABILITY); - - if ((specialAbilityList != null) && (specialAbilityList.size() != 0)) - { - for (SpecialAbility sa : specialAbilityList) - { - final String src = sa.getSASource(); - final String lev = src.substring(src.lastIndexOf('|') + 1); - pccTxt.append(lineSep).append(lev).append("\tSAB:").append( - sa.toString()); - } - } - List<SpecialAbility> saList = new ArrayList<SpecialAbility>(); addSABToList(saList, null); for (SpecialAbility sa : saList) @@ -3323,77 +3309,6 @@ } /* - * REFACTOR TO DELETEMETHOD I don't understand why the .CLEAR related - * functionality only exists in PCClass and not other PObjects??? Perhaps - * this should be up in PObject and therefore not be necessary here?... No, - * I suspect this is level related based on how SpecialAbilitys store their - * source and then use that to check if the PC qualifies for the Special - * Ability. Hopefully that String processing can be factored out and this - * can only load the appropriate SpecialAbilitys into the PCClassLevels that - * a PlayerCharacter has. - */ - @Override - public List<SpecialAbility> addSpecialAbilitiesToList( - final List<SpecialAbility> aList, final PlayerCharacter aPC) - { - final List<SpecialAbility> specialAbilityList = - getListFor(ListKey.SPECIAL_ABILITY); - - if ((specialAbilityList == null) || specialAbilityList.isEmpty()) - { - return aList; - } - - final List<SpecialAbility> bList = new ArrayList<SpecialAbility>(); - - for (SpecialAbility sa : specialAbilityList) - { - if (sa.pcQualifiesFor(aPC)) - { - final String saKey = sa.getKeyName(); - if (saKey.startsWith(".CLEAR")) - { - if (".CLEARALL".equals(saKey)) - { - bList.clear(); - } - else if (saKey.startsWith(".CLEAR.")) - { - final String saToRemove = saKey.substring(7); - - for (int itIdx = bList.size() - 1; itIdx >= 0; --itIdx) - { - final String subKey = bList.get(itIdx).getKeyName(); - - if (subKey.equals(saToRemove)) - { - bList.remove(itIdx); - } - else if (subKey.indexOf('(') >= 0) - { - if (subKey.substring(0, subKey.indexOf('(')) - .trim().equals(saToRemove)) - { - bList.remove(itIdx); - } - } - } - } - //CONSIDER else what? No error checking here? - - continue; - } - - bList.add(sa); - } - } - - aList.addAll(bList); - - return aList; - } - - /* * FINALPCCLASSLEVELONLY This is only part of the level, as the skill list is * calculated based on other factors, it is not a Tag */ @@ -4217,30 +4132,6 @@ // Go through the specialty list (SA) and adjust the class to the new // name // - final List<SpecialAbility> specialAbilityList = - getListFor(ListKey.SPECIAL_ABILITY); - - if (specialAbilityList != null) - { - for (int idx = specialAbilityList.size() - 1; idx >= 0; --idx) - { - SpecialAbility sa = specialAbilityList.get(idx); - - // TODO - This looks like it should have always been a reference - // to getSASource not getSource. - if (sa.getSASource().length() != 0) - // if (sa.getSource().length() != 0) - { - removeSpecialAbility(sa); - sa = - new SpecialAbility(sa.getKeyName(), sa - .getSASource(), sa.getSADesc()); - sa.setQualificationClass(oldClass, newClass); - addSpecialAbilityToList(sa); - } - } - } - for (int lev : mapChar.getSecondaryKeySet(MapKey.SAB)) { for (SpecialAbility sa : mapChar.getListFor(MapKey.SAB, lev)) @@ -5324,12 +5215,6 @@ setRegionString(otherClass.getRegionString()); } - for (SpecialAbility sa : otherClass - .getSafeListFor(ListKey.SPECIAL_ABILITY)) - { - addSpecialAbilityToList(sa); - } - for (int lev : otherClass.mapChar.getSecondaryKeySet(MapKey.SAB)) { for (SpecialAbility sa : otherClass.mapChar.getListFor(MapKey.SAB, Modified: Trunk/pcgen/code/src/java/pcgen/core/PObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -845,15 +845,6 @@ } /** - * Add the SA to the character list - * @param sa - */ - public final void addSpecialAbilityToList(final SpecialAbility sa) - { - addToListFor(ListKey.SPECIAL_ABILITY, sa); - } - - /** * Add to the list of temporary bonuses * @param aBonus */ @@ -1520,24 +1511,6 @@ } /** - * Get the SA by key - * @param aKey - * @return the SA - */ - public final SpecialAbility getSpecialAbilityKeyed(final String aKey) - { - for ( SpecialAbility sa : getListFor(ListKey.SPECIAL_ABILITY) ) - { - if (sa.getKeyName().equalsIgnoreCase(aKey)) - { - return sa; - } - } - - return null; - } - - /** * Returns a hardcoded "POBJECT|" + name of this object * @return "POBJECT|" + name of this object */ @@ -1582,14 +1555,6 @@ return spellSupport.getSpellList(-1); } - /** - * Clear the special ability list - */ - public final void clearSpecialAbilityList() - { - removeListFor(ListKey.SPECIAL_ABILITY); - } - public void addSAB(SpecialAbility sa, int level) { mapChar.addToListFor(MapKey.SAB, level, sa); @@ -2623,18 +2588,9 @@ txt.append(writer); } - List<SpecialAbility> specialAbilityList = getListFor(ListKey.SPECIAL_ABILITY); - if (!(this instanceof PCClass) && (specialAbilityList != null) && (specialAbilityList.size() != 0)) - { - for (SpecialAbility sa : specialAbilityList) - { - txt.append("\tSAB:").append(sa.toString()); - } - } - if (!(this instanceof PCClass)) { - specialAbilityList = new ArrayList<SpecialAbility>(); + ArrayList<SpecialAbility> specialAbilityList = new ArrayList<SpecialAbility>(); addSABToList(specialAbilityList, null); for (SpecialAbility sa : specialAbilityList) { @@ -3587,14 +3543,6 @@ } /** - * Remove the speical ability from the list - * @param sa - */ - public void removeSpecialAbility(SpecialAbility sa) { - removeFromListFor(ListKey.SPECIAL_ABILITY, sa); - } - - /** * Set a string referenced by a key * @param key * @param s Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -3102,43 +3102,7 @@ continue; } - List<SpecialAbility> al = new ArrayList<SpecialAbility>(); - al = aPObj.addSpecialAbilitiesToList(al, this); - ArrayList<SpecialAbility> masterList = - new ArrayList<SpecialAbility>(al); - for (SpecialAbility sa : masterList) - { - if (sa.getKeyName().startsWith(".CLEAR.") && sa.qualifies(this)) - { - al.remove(sa); - String key = sa.getKeyName().substring(7); - for (Iterator<SpecialAbility> it = al.iterator(); it - .hasNext();) - { - String saKey = it.next().getKeyName(); - if (saKey.startsWith(key)) - { - int baseLength = key.length(); - int thisLength = saKey.length(); - if (thisLength == baseLength) - { - it.remove(); - } - else if (thisLength > baseLength) - { - if (saKey.charAt(baseLength + 1) == '(' - || thisLength + 1 > baseLength - && saKey.charAt(baseLength + 1) == ' ' - && saKey.charAt(baseLength + 2) == '(') - { - it.remove(); - } - } - } - } - } - } - aList.addAll(al); + aPObj.addSpecialAbilitiesToList(aList, this); aPObj.addSABToList(aList, this); } // for (CDOMObject cdo : getCDOMObjectList()) Modified: Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbility.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbility.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbility.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -22,6 +22,7 @@ */ package pcgen.core.levelability; +import pcgen.cdom.enumeration.ListKey; import pcgen.core.*; import pcgen.core.pclevelinfo.PCLevelInfo; import pcgen.core.prereq.PrereqHandler; @@ -320,7 +321,7 @@ final SpecialAbility sa = new SpecialAbility( zString, "PCCLASS|" + owner.getKeyName() + '|' + level); - owner.addSpecialAbilityToList(sa); + owner.addToListFor(ListKey.SPECIAL_ABILITY, sa); owner.addSave(zString); } } Modified: Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbilitySpecial.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbilitySpecial.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbilitySpecial.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -20,6 +20,7 @@ */ package pcgen.core.levelability; +import pcgen.cdom.enumeration.ListKey; import pcgen.core.*; import pcgen.core.pclevelinfo.PCLevelInfo; import pcgen.util.chooser.ChooserInterface; @@ -104,7 +105,7 @@ sa = new SpecialAbility(selection); } - this.owner.addSpecialAbilityToList(sa); + this.owner.addToListFor(ListKey.SPECIAL_ABILITY, sa); this.owner.addSave(selection); } return true; Modified: Trunk/pcgen/code/src/java/pcgen/gui/AddSpecialAbility.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/AddSpecialAbility.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/java/pcgen/gui/AddSpecialAbility.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -25,6 +25,7 @@ **/ package pcgen.gui; +import pcgen.cdom.enumeration.ListKey; import pcgen.core.Globals; import pcgen.core.PCClass; import pcgen.core.PlayerCharacter; @@ -154,7 +155,7 @@ PCClass aClass = aPC.getClassList().get(0); String aString = (selectedValue).trim(); SpecialAbility sa = new SpecialAbility(aString, "PCCLASS|" + aClass.getKeyName() + "|0"); - aClass.addSpecialAbilityToList(sa); + aClass.addToListFor(ListKey.SPECIAL_ABILITY, sa); aClass.addSave(aString); if (owner != null) Modified: Trunk/pcgen/code/src/java/pcgen/gui/editor/ClassLevelPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/editor/ClassLevelPanel.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/java/pcgen/gui/editor/ClassLevelPanel.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -296,22 +296,7 @@ } } - List<SpecialAbility> saList = obj.getListFor(ListKey.SPECIAL_ABILITY); - - if ((saList != null) && (saList.size() != 0)) - { - for (Iterator<SpecialAbility> se = saList.iterator(); se.hasNext();) - { - final SpecialAbility sa = se.next(); - String src = sa.getSASource(); - String lev = src.substring(src.lastIndexOf('|') + 1); - - LevelTag lt = new LevelTag(lev, LevelTag.TAG_SAB, sa.toString()); - levelTagList.add(lt); - } - } - - saList = new ArrayList<SpecialAbility>(); + List<SpecialAbility> saList = new ArrayList<SpecialAbility>(); obj.addSABToList(saList, null); if (!saList.isEmpty()) Modified: Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -633,7 +633,6 @@ // thisPObject.setDR(".CLEAR"); thisPObject.clearDR(); thisPObject.clearPrerequisiteList(); - thisPObject.clearSpecialAbilityList(); thisPObject.clearAllSABLists(); thisPObject.clearSRList(); thisPObject.getSpellSupport().clearSpellList(); @@ -3146,27 +3145,7 @@ } } - List<SpecialAbility> saList = thisPObject.getListFor(ListKey.SPECIAL_ABILITY); - - if ((saList != null) && (saList.size() != 0) && (anEditType != EditorConstants.EDIT_CLASS)) - { - for (Iterator<SpecialAbility> e = saList.iterator(); e.hasNext();) - { - SpecialAbility specialAbility = e.next(); - String saSource = specialAbility.getSASource(); - String saLevel = saSource.substring(saSource.indexOf("|") + 1); - String saTxt = specialAbility.toString(); - - if (saLevel.length() > 0) - { - saLevel += "|"; - } - - selectedList.add("SAB:" + saLevel + saTxt); - } - } - - saList = new ArrayList<SpecialAbility>(); + List<SpecialAbility> saList = new ArrayList<SpecialAbility>(); thisPObject.addSABToList(saList, null); if ((saList.size() != 0) && (anEditType != EditorConstants.EDIT_CLASS)) Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -623,7 +623,7 @@ } aClass.removeSave(sa.getKeyName()); - aClass.removeSpecialAbility(sa); + aClass.removeFromListFor(ListKey.SPECIAL_ABILITY, sa); } // pc = null; // forces everything to re-display it's broken Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -475,7 +475,7 @@ + cTok.nextToken()); } - aClass.addSpecialAbilityToList(sa); + aClass.addToListFor(ListKey.SPECIAL_ABILITY, sa); } } } @@ -495,7 +495,7 @@ } //sa.setSource(src); - aClass.addSpecialAbilityToList(sa); + aClass.addToListFor(ListKey.SPECIAL_ABILITY, sa); } if (!aClass.containsInList(saveKey, token) Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -874,35 +874,39 @@ for (String save : pcClass.getSafeListFor(ListKey.SAVE)) { - final SpecialAbility specialAbility = - pcClass.getSpecialAbilityKeyed(save); - - if (specialAbility != null) + boolean found = false; + for ( SpecialAbility sa : pcClass.getListFor(ListKey.SPECIAL_ABILITY) ) { - int relevantLevel = 1; - final String source = specialAbility.getSASource(); - - try + if (sa.getKeyName().equalsIgnoreCase(save)) { - relevantLevel = - Integer.parseInt(source.substring(source - .lastIndexOf('|') + 1)); + found = true; + int relevantLevel = 1; + final String source = sa.getSASource(); - if (relevantLevel < 0) + try { - relevantLevel = 1; + relevantLevel = + Integer.parseInt(source.substring(source + .lastIndexOf('|') + 1)); + + if (relevantLevel < 0) + { + relevantLevel = 1; + } } + catch (NumberFormatException nfe) + { + Logging.errorPrint("Error parsing SA relevant level: " //$NON-NLS-1$ + + source.substring(source.lastIndexOf('|') + 1)); + } + + specials.put(pcClass.getKeyName() + TAG_SA + + (relevantLevel - 1), sa.getKeyName()); + break; } - catch (NumberFormatException nfe) - { - Logging.errorPrint("Error parsing SA relevant level: " //$NON-NLS-1$ - + source.substring(source.lastIndexOf('|') + 1)); - } + } - specials.put(pcClass.getKeyName() + TAG_SA - + (relevantLevel - 1), specialAbility.getKeyName()); - } - else + if (!found) { specials.put(key, save); } Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -1666,7 +1666,7 @@ if (!thePC.hasSpecialAbility(specialAbilityName)) { - aPCClass.addSpecialAbilityToList(specialAbility); + aPCClass.addToListFor(ListKey.SPECIAL_ABILITY, specialAbility); } if (!aPCClass.containsInList(ListKey.SAVE, Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SAToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SAToken.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SAToken.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -1,62 +0,0 @@ -/* - * Copyright 2007 (C) Thomas Parker <th...@us...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package plugin.lsttokens.deprecated; - -import pcgen.cdom.base.Constants; -import pcgen.core.PObject; -import pcgen.persistence.lst.AddLstToken; -import pcgen.util.Logging; - -public class SAToken implements AddLstToken -{ - - public boolean parse(PObject target, String value, int level) - { - Logging.deprecationPrint("ADD:SA " - + "is deprecated. Please use ADD:SAB"); - int pipeLoc = value.indexOf(Constants.PIPE); - if (pipeLoc == -1) - { - Logging.deprecationPrint("Lack of a SUBTOKEN for ADD:SA " - + "is prohibited in new syntax."); - Logging.deprecationPrint("Please use ADD:SA|name|[count|]X,X"); - return false; - } - String subToken = value.substring(0, pipeLoc); - String countString; - String items; - int lastPipeLoc = value.lastIndexOf(Constants.PIPE); - if (lastPipeLoc == pipeLoc) - { - items = value; - countString = "1"; - } - else - { - items = value.substring(pipeLoc + 1, lastPipeLoc); - countString = value.substring(lastPipeLoc + 1); - } - target.addAddList(level, subToken + "(" + items + ")" + countString); - return true; - } - - public String getTokenName() - { - return "SA"; - } -} Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SaLst.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SaLst.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SaLst.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -1,151 +0,0 @@ -/* - * Created on Sep 2, 2005 - * - */ -package plugin.lsttokens.deprecated; - -import java.util.StringTokenizer; - -import pcgen.core.Globals; -import pcgen.core.PCClass; -import pcgen.core.PObject; -import pcgen.core.Skill; -import pcgen.core.SpecialAbility; -import pcgen.core.prereq.Prerequisite; -import pcgen.persistence.PersistenceLayerException; -import pcgen.persistence.lst.DeprecatedToken; -import pcgen.persistence.lst.GlobalLstToken; -import pcgen.persistence.lst.prereq.PreParserFactory; -import pcgen.util.Logging; - -/** - * @author djones4 - * - */ -public class SaLst implements GlobalLstToken, DeprecatedToken -{ - - public String getTokenName() - { - return "SA"; - } - - public boolean parse(PObject obj, String value, int anInt) - { - if (obj instanceof Skill) - { - Logging.errorPrint("SA not supported in Skills"); - return false; - } - parseSpecialAbility(obj, value, anInt); - return true; - } - - /** - * This method sets the special abilities granted by this [object]. For - * efficiency, avoid calling this method except from I/O routines. - * - * @param obj - * the PObject that is to receive the new SpecialAbility - * @param aString - * String of special abilities delimited by pipes - * @param level - * int level at which the ability is gained - */ - public void parseSpecialAbility(PObject obj, String aString, - int level) - { - StringTokenizer aTok = new StringTokenizer(aString, "|", true); - - if (!aTok.hasMoreTokens()) - { - return; - } - - StringBuffer saName = new StringBuffer(); - saName.append(aTok.nextToken()); - - SpecialAbility sa = new SpecialAbility(); - - boolean isPre = false; - - while (aTok.hasMoreTokens()) - { - String cString = aTok.nextToken(); - - // Check to see if it's a PRExxx: tag - if (PreParserFactory.isPreReqString(cString)) - { - isPre = true; - try - { - PreParserFactory factory = PreParserFactory.getInstance(); - Prerequisite prereq = factory.parse(cString); - if (obj instanceof PCClass - && "var".equals(prereq.getKind())) - { - prereq.setSubKey("CLASS:" + obj.getKeyName()); - } - sa.addPrerequisite(prereq); - } - catch (PersistenceLayerException ple) - { - Logging.errorPrint(ple.getMessage(), ple); - } - } - else - { - if (isPre) - { - if (!"|".equals(cString)) - { - Logging.errorPrint("Invalid " + getTokenName() + ": " - + aString); - Logging - .errorPrint(" PRExxx must be at the END of the Token"); - isPre = false; - } - } - saName.append(cString); - } - - if (".CLEAR".equals(cString)) - { - obj.clearSpecialAbilityList(); - saName.setLength(0); - } - } - - sa.setName(saName.toString()); - - if (level >= 0) - { - try - { - sa.addPrerequisite(PreParserFactory.createLevelPrereq(obj, level)); - } - catch (PersistenceLayerException notUsed) - { - Logging.errorPrint("Failed to assign level prerequisite.", notUsed); - } - } - if (obj instanceof PCClass) - { - sa.setSASource("PCCLASS=" + obj.getKeyName() + "|" + level); - } - - if (!aString.equals(".CLEAR")) - { - Globals.addToSASet(sa); - obj.addSpecialAbilityToList(sa); - } - } - - public String getMessage(PObject obj, String value) - { - return "SA has been deprecated due to cross-level interaction.\n " + - "Please use SAB: for most situations.\n " + - "If you are using .CLEAR in an SA to remove items granted\n " + - " at a lower level, you must now use a PRExxx token attached to the SAB"; - } -} Modified: Trunk/pcgen/code/src/test/plugin/PluginBuildTest.java =================================================================== --- Trunk/pcgen/code/src/test/plugin/PluginBuildTest.java 2008-07-27 13:02:06 UTC (rev 7251) +++ Trunk/pcgen/code/src/test/plugin/PluginBuildTest.java 2008-07-27 19:31:36 UTC (rev 7252) @@ -80,26 +80,26 @@ checkPluginJars(jarPrefix, sourceFolder, jarFolder); } -// /** -// * Check for the presence of all deprecated token plugins. -// */ -// public void testDeprecatedPlugins() -// { -// String jarPrefix = "^[a-zA-Z]*-DEPRECATED-"; -// String sourceSuffix = "Lst"; -// File sourceFolder = new File("code/src/java/plugin/lsttokens/deprecated"); -// File jarFolder[] = new File[]{new File("plugins/lstplugins"), new File("plugins/preplugins")}; -// assertTrue("Source folder " + sourceFolder.getAbsolutePath() + " should be a directory", sourceFolder.isDirectory()); -// String[] sources = sourceFolder.list(); -// List<String> srcList = new ArrayList<String>(); -// srcList.addAll(Arrays.asList(sources)); -// srcList.remove("PreDefaultMonsterTester.java"); -// srcList.remove("PreDefaultMonsterWriter.java"); -// sources = (String[]) srcList.toArray(sources); -// String [][] exceptions = new String[][] { -// }; -// checkPluginJarsByRegex(jarPrefix, jarFolder, sourceSuffix, sources, exceptions); -// } + /** + * Check for the presence of all deprecated token plugins. + */ + public void testDeprecatedPlugins() + { + String jarPrefix = "^[a-zA-Z]*-DEPRECATED-"; + String sourceSuffix = "Lst"; + File sourceFolder = new File("code/src/java/plugin/lsttokens/deprecated"); + File jarFolder[] = new File[]{new File("plugins/lstplugins"), new File("plugins/preplugins")}; + assertTrue("Source folder " + sourceFolder.getAbsolutePath() + " should be a directory", sourceFolder.isDirectory()); + String[] sources = sourceFolder.list(); + List<String> srcList = new ArrayList<String>(); + srcList.addAll(Arrays.asList(sources)); + srcList.remove("PreDefaultMonsterTester.java"); + srcList.remove("PreDefaultMonsterWriter.java"); + sources = (String[]) srcList.toArray(sources); + String [][] exceptions = new String[][] { + }; + checkPluginJarsByRegex(jarPrefix, jarFolder, sourceSuffix, sources, exceptions); + } /** * Check for the presence of all export token plugins. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |