From: <nu...@us...> - 2006-03-24 01:18:18
|
Revision: 401 Author: nuance Date: 2006-03-23 17:17:52 -0800 (Thu, 23 Mar 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=401&view=rev Log Message: ----------- Add the ability for Templates to parse Abilitys Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/template/AbilityToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-03-24 01:11:05 UTC (rev 400) +++ Trunk/pcgen/code/pluginbuild.xml 2006-03-24 01:17:52 UTC (rev 401) @@ -3792,6 +3792,13 @@ <target name="jar-lst-template-plugins" depends="makeplugindirs" description="Build (Link) Weapon Prof Lst Token plugin jar files"> <!-- Template tokens--> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-ABILITY.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/AbilityToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${lstplugins.dir}/TemplateLstToken-ADDLEVEL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2006-03-24 01:11:05 UTC (rev 400) +++ Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2006-03-24 01:17:52 UTC (rev 401) @@ -74,17 +74,18 @@ /** Visibility is GUI Only */ public static final int VISIBILITY_DISPLAY_ONLY = 3; - private ArrayList featStrings = null; - private ArrayList hitDiceStrings = null; - private ArrayList levelStrings = null; - private ArrayList templates = new ArrayList(); + private AbilityStore abilityCatStore = null; + private ArrayList featStrings = null; + private ArrayList hitDiceStrings = null; + private ArrayList levelStrings = null; + private ArrayList templates = new ArrayList(); - private ArrayList weaponProfBonus = null; - private HashMap chosenFeatStrings = null; - private List templatesAdded = null; - private String ageString = Constants.s_NONE; - private String chooseLanguageAutos = ""; - private String cost = "1"; + private ArrayList weaponProfBonus = null; + private HashMap chosenFeatStrings = null; + private List templatesAdded = null; + private String ageString = Constants.s_NONE; + private String chooseLanguageAutos = ""; + private String cost = "1"; private String favoredClass = ""; @@ -733,6 +734,12 @@ txt.append("\tFAVOREDCLASS:").append(favoredClass); } + if (abilityCatStore != null) + { + txt.append("\tABILITY:"); + txt.append(abilityCatStore.getParsableStringRepresentation()); + } + if (getListSize(featStrings) > 0) { final StringBuffer buffer = new StringBuffer(); @@ -1669,11 +1676,17 @@ aTemp.weaponProfBonus = (ArrayList) weaponProfBonus.clone(); } + if (abilityCatStore != null) { + aTemp.abilityCatStore = new AbilityStore(); + aTemp.abilityCatStore.addAbilityInfo( + abilityCatStore.getParsableStringRepresentation(), "", "|", false, false); + } + if (getListSize(featStrings) != 0) { aTemp.featStrings = (ArrayList) featStrings.clone(); } - + if (chosenFeatStrings != null) { aTemp.chosenFeatStrings = (HashMap) chosenFeatStrings.clone(); @@ -2097,12 +2110,13 @@ /** - * TODO DOCUMENT ME! + * This is the function that implements a chooser for Feats granted by level + * and/or HD by Templates. * - * @param levelString DOCUMENT ME! - * @param lvl DOCUMENT ME! - * @param featKey DOCUMENT ME! - * @param aPC DOCUMENT ME! + * @param levelString The string to be parsed for the choices to offer + * @param lvl The level this is being added at + * @param featKey either L<lvl> or H<lvl> + * @param aPC The PC that this Template is appled to */ private void getLevelFeat( final String levelString, @@ -2183,37 +2197,45 @@ /** - * Add a | separated list of available feat that this Template may grant. + * Add a | separated list of available abilities that this Template may + * grant. This is the function called by the Lst parser to make the + * Abilities available to this Template. + * + * See AbilityStore.addAbilityInfo for details of the string + * + * @param abilityString + */ + public void addAbilityString (final String abilityString) { + + if (".CLEAR".equals(abilityString)) + { + abilityCatStore = null; + return; + } + + if (abilityCatStore == null) { + abilityCatStore = new AbilityStore(); + } + + abilityCatStore.addAbilityInfo(abilityString, "", "|", false, false); + } + + /** + * Add a | separated list of available feats that this Template may grant. * This is the function called by the Lst parser to make the feats * available to this Template * - * @param featString The | separated list of feats + * @param abilityString The | separated list of feats */ - public void addFeatString(final String featString) + public void addFeatString(final String abilityString) { - if (".CLEAR".equals(featString)) + if (".CLEAR".equals(abilityString)) { - if (featStrings != null) - { - featStrings.clear(); - } - + abilityCatStore = null; return; } - - final StringTokenizer aTok = new StringTokenizer(featString, "|", false); - - while (aTok.hasMoreTokens()) - { - final String fs = aTok.nextToken(); - - if (featStrings == null) - { - featStrings = new ArrayList(); - } - - featStrings.add(fs); - } + + addAbilityString("CATEGORY=FEAT|" + abilityString); } @@ -2244,6 +2266,19 @@ feats = new ArrayList(); } + /* This is very, very temporary. + * + * This needs to be changed very soon so that this entire routine uses + * AbilityInfo objects instead of the names of abilities. + */ + if (abilityCatStore != null) { + Iterator it = abilityCatStore.getKeyIterator("ALL"); + + while (it.hasNext()) { + feats.add(((AbilityInfo) it.next()).getKeyName()); + } + } + // arknight modified this back in 1.27 with the comment: Added support for // Spycraft Game Mode we no longer support Spycraft (at this time), and this // breaks other modes, so I've reverting back to the old method. I am also fixing Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/AbilityToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/AbilityToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/AbilityToken.java 2006-03-24 01:17:52 UTC (rev 401) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with ABILITY Token + */ +public class AbilityToken implements PCTemplateLstToken { + + public String getTokenName() { + return "ABILITY"; + } + + public boolean parse(PCTemplate template, String value) { + template.addAbilityString(value); + return true; + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/template/AbilityToken.java ___________________________________________________________________ Name: svn:executable + * Name: keywords + "Date Revision Author Id" Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sou...@us...> - 2006-03-26 01:43:55
|
Revision: 454 Author: soulcatcher Date: 2006-03-25 17:43:42 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=454&view=rev Log Message: ----------- Added "qualities" to equipment Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/Equipment.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoGear.java Trunk/pcgen/code/src/java/pcgen/io/exporttoken/EqToken.java Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/QualityToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-03-26 01:08:28 UTC (rev 453) +++ Trunk/pcgen/code/pluginbuild.xml 2006-03-26 01:43:42 UTC (rev 454) @@ -3136,6 +3136,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/EquipmentLstToken-QUALITY.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/equipment/QualityToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${lstplugins.dir}/EquipmentLstToken-RANGE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/core/Equipment.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Equipment.java 2006-03-26 01:08:28 UTC (rev 453) +++ Trunk/pcgen/code/src/java/pcgen/core/Equipment.java 2006-03-26 01:43:42 UTC (rev 454) @@ -142,6 +142,7 @@ private Map d_childTypes = null; private Map treasureList = null; private Purse baseCoinCost; + private Map qualityMap = new HashMap(); // support tracking of cost as coins. private Purse coinCost; @@ -7049,4 +7050,43 @@ return thisName + " (" + newSize + ")"; } + + public void setQuality(String key, String value) { + qualityMap.put(key, value); + } + + public String getQuality(String key) { + return (String)qualityMap.get(key); + } + + public String getQuality(int num) { + for(Iterator i = qualityMap.keySet().iterator(); i.hasNext(); ) { + String key = i.next().toString(); + num --; + if(num == 0) { + return key + ": " + (String)qualityMap.get(key); + } + } + return ""; + } + + public Map getQualityMap() { + return qualityMap; + } + + public String getQualityString() { + StringBuffer sb = new StringBuffer(); + boolean firstTime = true; + for(Iterator i = qualityMap.keySet().iterator(); i.hasNext(); ) { + if(!firstTime) { + sb.append(", "); + } + String key = i.next().toString(); + sb.append(key) + .append(": ") + .append((String)qualityMap.get(key)); + firstTime = false; + } + return sb.toString(); + } } Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoGear.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoGear.java 2006-03-26 01:08:28 UTC (rev 453) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoGear.java 2006-03-26 01:43:42 UTC (rev 454) @@ -153,9 +153,10 @@ private static Integer saveSelectedViewMode = null; private static final int COL_NAME = 0; private static final int COL_COST = 1; - private static final int COL_QTY = 2; - private static final int COL_INDEX = 3; - private static final int COL_SRC = 4; + private static final int COL_WEIGHT = 2; + private static final int COL_QTY = 3; + private static final int COL_INDEX = 4; + private static final int COL_SRC = 5; /** * typeSubtypeRoot is the base structure used by both the available @@ -747,9 +748,14 @@ { b.append(" <b>Charges</b>:").append(charges); } + + bString = aEq.getQualityString(); + if (bString.length() > 0) + { + b.append(" <b>QUALITIES</b>:").append(bString); + } bString = aEq.getSource(); - if (bString.length() > 0) { b.append(" <b>SOURCE</b>:").append(bString); @@ -3290,8 +3296,8 @@ private static final int MODEL_TYPE_SELECTED = 1; // Names of the columns. - private String[] names = { "Item", "Cost", "Qty", "Order", "Source" }; - private int[] widths = { 100, 100, 100, 100, 100 }; + private String[] names = { "Item", "Cost", "Weight", "Qty", "Order", "Source" }; + private int[] widths = { 100, 20, 20, 20, 20, 100 }; // Types of the columns. private int modelType = MODEL_TYPE_AVAIL; // availableModel @@ -3313,16 +3319,19 @@ int i = 1; displayList = new ArrayList(); displayList.add(new Boolean(true)); - displayList.add(new Boolean(getColumnViewOption(modelType + "." + names[i++], false))); - displayList.add(new Boolean(getColumnViewOption(modelType + "." + names[i++], false))); + displayList.add(new Boolean(getColumnViewOption(modelType + "." + names[i++], true))); if(available) { displayList.add(new Boolean(getColumnViewOption(modelType + "." + names[i++], false))); + displayList.add(new Boolean(getColumnViewOption(modelType + "." + names[i++], false))); + displayList.add(new Boolean(getColumnViewOption(modelType + "." + names[i++], false))); displayList.add(new Boolean(getColumnViewOption(modelType + "." + names[i++], true))); } else { + displayList.add(new Boolean(getColumnViewOption(modelType + "." + names[i++], false))); displayList.add(new Boolean(getColumnViewOption(modelType + "." + names[i++], true))); + displayList.add(new Boolean(getColumnViewOption(modelType + "." + names[i++], true))); displayList.add(new Boolean(getColumnViewOption(modelType + "." + names[i++], false))); } } @@ -3346,6 +3355,9 @@ case COL_COST: return BigDecimal.class; + case COL_WEIGHT: + return Float.class; + case COL_QTY: return Float.class; @@ -3420,7 +3432,14 @@ retVal = eq.getCost(pc); } break; - + + case COL_WEIGHT: + if (eq != null) + { + retVal = eq.getWeight(pc); + } + break; + case COL_QTY: if (eq != null) { Modified: Trunk/pcgen/code/src/java/pcgen/io/exporttoken/EqToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/EqToken.java 2006-03-26 01:08:28 UTC (rev 453) +++ Trunk/pcgen/code/src/java/pcgen/io/exporttoken/EqToken.java 2006-03-26 01:43:42 UTC (rev 454) @@ -1096,6 +1096,25 @@ } return getTypeToken(eq); } + else if ("QUALITY".equals(token)) + { + if(tokenizer.hasMoreTokens()) + { + String next = tokenizer.nextToken(); + try + { + int num = Integer.parseInt(next); + return eq.getQuality(num); + } + catch(NumberFormatException e) + { + return eq.getQuality(next); + } + } + else { + return eq.getQualityString(); + } + } else if ("SPELLFAILURE".equals(token)) { retString = getSpellFailureToken(pc, eq); Added: Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/QualityToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/QualityToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/QualityToken.java 2006-03-26 01:43:42 UTC (rev 454) @@ -0,0 +1,30 @@ +package plugin.lsttokens.equipment; + +import java.util.StringTokenizer; + +import pcgen.core.Equipment; +import pcgen.persistence.lst.EquipmentLstToken; + +/** + * Deals with ACCHECK token + */ +public class QualityToken implements EquipmentLstToken { + + public String getTokenName() { + return "QUALITY"; + } + + public boolean parse(Equipment eq, String value) { + StringTokenizer tok = new StringTokenizer(value, "|"); + String key = ""; + String val = ""; + if(tok.hasMoreTokens()) { + key = tok.nextToken(); + } + if(tok.hasMoreTokens()) { + val = tok.nextToken(); + } + eq.setQuality(key, val); + return true; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kar...@us...> - 2006-03-30 12:07:08
|
Revision: 521 Author: karianna Date: 2006-03-30 04:06:42 -0800 (Thu, 30 Mar 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=521&view=rev Log Message: ----------- Removed HEIGHT processing in PCTemplate, no longer used. Double checked that PCGs still load/save HEIGHT correctly :-) Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java Trunk/pcgen/code/src/java/pcgen/io/IOConstants.java Trunk/pcgen/code/src/java/plugin/lsttokens/DefineLst.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/template/HeightToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-03-30 09:54:07 UTC (rev 520) +++ Trunk/pcgen/code/pluginbuild.xml 2006-03-30 12:06:42 UTC (rev 521) @@ -3904,13 +3904,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/TemplateLstToken-HEIGHT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/template/HeightToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/TemplateLstToken-HITDIE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2006-03-30 09:54:07 UTC (rev 520) +++ Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2006-03-30 12:06:42 UTC (rev 521) @@ -46,6 +46,7 @@ import pcgen.persistence.lst.prereq.PreParserFactory; import pcgen.persistence.PersistenceLayerException; import pcgen.core.prereq.Prerequisite; + /** * <code>PCTemplate</code>. * @@ -58,19 +59,15 @@ // Static properties /////////////////////////////////////////////////////////////////////// - /** Visibility is Hidden */ public static final int VISIBILITY_HIDDEN = 0; - /** Visibility is Default */ public static final int VISIBILITY_DEFAULT = 1; - /** Visibility is Output Sheets Only */ public static final int VISIBILITY_OUTPUT_ONLY = 2; - /** Visibility is GUI Only */ public static final int VISIBILITY_DISPLAY_ONLY = 3; @@ -92,8 +89,7 @@ // If set these two will override any other choices. private String gender = Constants.s_NONE; private String handed = Constants.s_NONE; - /** @deprecated to remove heightString in 5.10 Beta */ - private String heightString = Constants.s_NONE; + private String levelAdjustment = "0"; // now a string so that we can handle // formulae private String region = Constants.s_NONE; @@ -440,23 +436,7 @@ handed = handedString; } - /** - * Set a lock on the height string. - * - * XXX appears to be totally unused. a private attribute with a setter but - * no accessor. This was removed, but then had to be readded as saving - * HEIGHT to pcg file was failing - * - * @param argHeightString the height to lock the character at - */ - public void setHeightString(final String argHeightString) - { - heightString = argHeightString; - } - - - /** * Set a lock on the hitdie size of a character that this template is * applied to. Possible formats for the lock include * @@ -775,13 +755,6 @@ } } - /* - if (!Constants.s_NONE.equals(heightString)) - { - txt.append("\tHEIGHT:").append(heightString); - } - */ - if (!hitDieLock.equals("")) { txt.append("\tHITDIE:").append(hitDieLock); Modified: Trunk/pcgen/code/src/java/pcgen/io/IOConstants.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/IOConstants.java 2006-03-30 09:54:07 UTC (rev 520) +++ Trunk/pcgen/code/src/java/pcgen/io/IOConstants.java 2006-03-30 12:06:42 UTC (rev 521) @@ -237,7 +237,7 @@ String TAG_HAIRSTYLE = "HAIRSTYLE"; /** HANDED */ String TAG_HANDED = "HANDED"; - /** HEIGHT */ + /** HEIGHT - Used by PCGVer2Creator & Parser */ String TAG_HEIGHT = "HEIGHT"; /** HITDICE */ String TAG_HITDICE = "HITDICE"; Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/DefineLst.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/DefineLst.java 2006-03-30 09:54:07 UTC (rev 520) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/DefineLst.java 2006-03-30 12:06:42 UTC (rev 521) @@ -7,7 +7,6 @@ import java.util.StringTokenizer; import pcgen.core.PObject; -import pcgen.persistence.PersistenceLayerException; import pcgen.persistence.lst.GlobalLstToken; /** @@ -20,7 +19,7 @@ return "DEFINE"; } - public boolean parse(PObject obj, String value, int anInt) throws PersistenceLayerException { + public boolean parse(PObject obj, String value, int anInt) { final StringTokenizer tok = new StringTokenizer(value, "|"); try { String varName = tok.nextToken(); Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/template/HeightToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/HeightToken.java 2006-03-30 09:54:07 UTC (rev 520) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/HeightToken.java 2006-03-30 12:06:42 UTC (rev 521) @@ -1,20 +0,0 @@ -package plugin.lsttokens.template; - -import pcgen.core.PCTemplate; -import pcgen.persistence.lst.PCTemplateLstToken; - - -/** - * Class deals with HEIGHT Token - */ -public class HeightToken implements PCTemplateLstToken { - - public String getTokenName() { - return "HEIGHT"; - } - - public boolean parse(PCTemplate template, String value) { - template.setHeightString(value); - return true; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kar...@us...> - 2006-03-30 12:19:23
|
Revision: 522 Author: karianna Date: 2006-03-30 04:19:11 -0800 (Thu, 30 Mar 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=522&view=rev Log Message: ----------- Removed AGE and WEIGHT processing in PCTemplate, no longer used. Double checked that PCGs still load/save AGE and WEIGHT correctly :-) Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java Trunk/pcgen/code/src/java/pcgen/io/IOConstants.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/template/AgeToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/WeightToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-03-30 12:06:42 UTC (rev 521) +++ Trunk/pcgen/code/pluginbuild.xml 2006-03-30 12:19:11 UTC (rev 522) @@ -3820,13 +3820,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/TemplateLstToken-AGE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/template/AgeToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/TemplateLstToken-BONUSFEATS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -4044,13 +4037,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/TemplateLstToken-WEIGHT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/template/WeightToken.class" /> - </patternset> - </fileset> - </jar> </target> <target name="jar-lst-weaponprof-plugins" depends="makeplugindirs" description="Build (Link) Weapon Prof Lst Token plugin jar files"> Modified: Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2006-03-30 12:06:42 UTC (rev 521) +++ Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2006-03-30 12:19:11 UTC (rev 522) @@ -80,7 +80,6 @@ private ArrayList weaponProfBonus = null; private HashMap chosenFeatStrings = null; private List templatesAdded = null; - private String ageString = Constants.s_NONE; private String chooseLanguageAutos = ""; private String cost = "1"; @@ -96,7 +95,6 @@ private String subRace = Constants.s_NONE; private String subregion = Constants.s_NONE; private String templateSize = ""; - private String weightString = Constants.s_NONE; private TreeSet languageBonus = new TreeSet(); private boolean removable = true; private int ChallengeRating = 0; @@ -127,20 +125,7 @@ // Empty Constructor } - /** - * Set the Age String property. - * XXX: this property appears to be unused Andrew Wilson 20060307 - * - * @param argAgeString a string representing the Age of a PC - */ - public void setAgeString(final String argAgeString) - { - ageString = argAgeString; - } - - - /** * Set the number of Bonus feats that this template grants the character it * is applied to at level 0 (i.e. before classes are added). * @@ -679,11 +664,6 @@ final StringBuffer txt = new StringBuffer(200); txt.append(getName()); - if (!Constants.s_NONE.equals(ageString)) - { - txt.append("\tAGE:").append(ageString); - } - if (bonusInitialFeats != 0) { txt.append("\tBONUSFEATS:").append(bonusInitialFeats); @@ -805,11 +785,6 @@ txt.append("\tSIZE:").append(templateSize); } - if (!Constants.s_NONE.equals(weightString)) - { - txt.append("\tWEIGHT:").append(weightString); - } - if (!"alwaysValid".equals(getQualifyString())) { txt.append("\tQUALIFY:").append(getQualifyString()); @@ -1322,21 +1297,7 @@ return getListSize(weaponProfBonus); } - /** - * Set the override that this template applies to weight - * - * XXX another apparently useless piece of state with no accessor. - * - * @param argWeightString the weight - */ - public void setWeightString(final String argWeightString) - { - weightString = argWeightString; - } - - - /** * Grants the character an ability at the Hit die or hit die range specified. * The text may contain the following tags: CR - Challenge Rating, DR - Damage * Reduction, FEAT - Feat, SA - Special Ability, SR - Spell Resistance Modified: Trunk/pcgen/code/src/java/pcgen/io/IOConstants.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/IOConstants.java 2006-03-30 12:06:42 UTC (rev 521) +++ Trunk/pcgen/code/src/java/pcgen/io/IOConstants.java 2006-03-30 12:19:11 UTC (rev 522) @@ -406,6 +406,7 @@ // Character weapon proficiencies String TAG_WEAPONPROF = "WEAPONPROF"; + /** WEIGHT - Used by PCGVer2 Parser and Creator */ String TAG_WEIGHT = "WEIGHT"; String TAG_WT = "WT"; } Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/template/AgeToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/AgeToken.java 2006-03-30 12:06:42 UTC (rev 521) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/AgeToken.java 2006-03-30 12:19:11 UTC (rev 522) @@ -1,21 +0,0 @@ -package plugin.lsttokens.template; - -import pcgen.core.PCTemplate; -import pcgen.persistence.lst.PCTemplateLstToken; - - -/** - * Class deals with AGE Token - */ -public class AgeToken implements PCTemplateLstToken { - - public String getTokenName() { - return "AGE"; - } - - // replaces racial age - public boolean parse(PCTemplate template, String value) { - template.setAgeString(value); - return true; - } -} Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/template/WeightToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/WeightToken.java 2006-03-30 12:06:42 UTC (rev 521) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/WeightToken.java 2006-03-30 12:19:11 UTC (rev 522) @@ -1,21 +0,0 @@ -package plugin.lsttokens.template; - -import pcgen.core.PCTemplate; -import pcgen.persistence.lst.PCTemplateLstToken; - - -/** - * Class deals with WEIGHT Token - */ -public class WeightToken implements PCTemplateLstToken { - - public String getTokenName() { - return "WEIGHT"; - } - - // replace racial weight - public boolean parse(PCTemplate template, String value) { - template.setWeightString(value); - return true; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kar...@us...> - 2006-03-30 13:52:05
|
Revision: 523 Author: karianna Date: 2006-03-30 05:51:20 -0800 (Thu, 30 Mar 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=523&view=rev Log Message: ----------- Removed much deprecated code. Have left in several items (waiting for responses), especially the Purse/Coin/Currency code from Brad Stiles (bsmiester) Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/gmgen/GMGenSystem.java Trunk/pcgen/code/src/java/gmgen/GMGenSystemView.java Trunk/pcgen/code/src/java/gmgen/gui/ImageFileChooser.java Trunk/pcgen/code/src/java/gmgen/util/LogUtilities.java Trunk/pcgen/code/src/java/gmgen/util/MiscUtilities.java Trunk/pcgen/code/src/java/gmgen/util/OSXAdapter.java Trunk/pcgen/code/src/java/gmgen/util/OperatingSystem.java Trunk/pcgen/code/src/java/pcgen/core/Equipment.java Trunk/pcgen/code/src/java/pcgen/core/PCClass.java Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java Trunk/pcgen/code/src/java/pcgen/io/IOConstants.java Trunk/pcgen/code/src/java/pcgen/io/PCGParseException.java Trunk/pcgen/code/src/java/pcgen/io/exporttoken/SpellListToken.java Trunk/pcgen/code/src/java/pcgen/io/exporttoken/WeaponToken.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstObjectFileLoader.java Trunk/pcgen/code/src/java/pcgen/util/PJEP.java Trunk/pcgen/code/src/java/plugin/overland/gui/OverPanel.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/template/HandedlockToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/pluginbuild.xml 2006-03-30 13:51:20 UTC (rev 523) @@ -3876,13 +3876,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/TemplateLstToken-HANDEDLOCK.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/template/HandedlockToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/TemplateLstToken-HANDS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/gmgen/GMGenSystem.java =================================================================== --- Trunk/pcgen/code/src/java/gmgen/GMGenSystem.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/gmgen/GMGenSystem.java 2006-03-30 13:51:20 UTC (rev 523) @@ -67,20 +67,6 @@ public static GMGenSystem inst; /** - * Default width for the GUI. - * - * @deprecated Unused - */ - public static final int DEFAULT_WIDTH = 700; - - /** - * Default height for the GUI. - * - * @deprecated Unused - */ - public static final int DEFAULT_HEIGHT = 500; - - /** * Boolean true if this is a Macintosh system. */ public static boolean MAC_OS_X = (System.getProperty("os.name").equals("Mac OS X")); Modified: Trunk/pcgen/code/src/java/gmgen/GMGenSystemView.java =================================================================== --- Trunk/pcgen/code/src/java/gmgen/GMGenSystemView.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/gmgen/GMGenSystemView.java 2006-03-30 13:51:20 UTC (rev 523) @@ -41,9 +41,8 @@ public class GMGenSystemView extends JPanel implements ChangeListener { /** - * A value that signifies the current pane that is showing. - * - * @deprecated Unused + * A value that signifies the current pane that is showing. Is not + * directly used in this class, but is needed to support interface */ public static int currentPane; @@ -77,21 +76,6 @@ } /** - * Adds a pane to the panel. The system will call it sending it a <code> - * JPanel</code> and that will be placed in the view. - * - *@param paneName the name to be on the tab. - *@param pane the pane to be displayed. - *@since GMGen 3.3 - * - * @deprecated Unused - */ - public void addPane(String paneName, JPanel pane) - { - tabbedPane.addTab(paneName, pane); - } - - /** * Inserts a pane into the panel in an arbitrary index. The system will call * it sending it a <code>JPanel</code> and that will be placed in the view. * Modified: Trunk/pcgen/code/src/java/gmgen/gui/ImageFileChooser.java =================================================================== --- Trunk/pcgen/code/src/java/gmgen/gui/ImageFileChooser.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/gmgen/gui/ImageFileChooser.java 2006-03-30 13:51:20 UTC (rev 523) @@ -40,10 +40,4 @@ { this(new File(strCurrentPath)); } - - /** @deprecated Unused */ - public ImageFileChooser() - { - this((File) null); - } } \ No newline at end of file Modified: Trunk/pcgen/code/src/java/gmgen/util/LogUtilities.java =================================================================== --- Trunk/pcgen/code/src/java/gmgen/util/LogUtilities.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/gmgen/util/LogUtilities.java 2006-03-30 13:51:20 UTC (rev 523) @@ -97,11 +97,11 @@ // end removeReceiver /** - * Log a message associated with a specific owner - from LogReceiver + * Log a message associated with a specific owner - from LogReceiver * - *@param owner The owning component of the message - *@param message The message to send - *@since GMGen 3.3 + * @param owner The owning component of the message + * @param message The message to send + * @since GMGen 3.3 */ public void logMessage(String owner, String message) { @@ -125,12 +125,10 @@ // end logMessage - 2 params /** - * Log a message without an owner - from LogReceiver + * Log a message without an owner - from LogReceiver * - *@param message The message to send - *@since GMGen 3.3 - * - * @deprecated Unused + * @param message The message to send + * @since GMGen 3.3 */ public void logMessage(String message) { @@ -152,20 +150,6 @@ } // end addReceiver - - /** - * Remove a receiver from the list to be called with new messages. - * - *@param rcvr the receiver to be removed. - *@since GMGen 3.3 - * - * @deprecated Unused - */ - public void removeReceiver(LogReceiver rcvr) - { - receivers.remove(rcvr); - } - // end logMessage - 1 param } Modified: Trunk/pcgen/code/src/java/gmgen/util/MiscUtilities.java =================================================================== --- Trunk/pcgen/code/src/java/gmgen/util/MiscUtilities.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/gmgen/util/MiscUtilities.java 2006-03-30 13:51:20 UTC (rev 523) @@ -105,43 +105,6 @@ } /** - * Returns the file name component of the specified path. - * - *@param path The path - *@return The file name - *@since GMGen 3.3 - * - * @deprecated Unused - */ - public static String getFileName(String path) - { - if (path.equals("/")) - { - return path; - } - - if (path.endsWith("/") || path.endsWith(File.separator)) - { - path = path.substring(0, path.length() - 1); - } - - int index = Math.max(path.lastIndexOf('/'), path.lastIndexOf(File.separatorChar)); - - if (index == -1) - { - index = path.indexOf(':'); - } - - // don't want getFileName("roots:") to return "" - if ((index == -1) || (index == (path.length() - 1))) - { - return path; - } - - return path.substring(index + 1); - } - - /** * Returns the localization property with the specified name, formatting it * with the <code>java.text.MessageFormat.format()</code> method. * @@ -197,17 +160,6 @@ // end setCursor /** - * Sets the any property values that need to be set on close - *@since GMGen 3.3 - * - * @deprecated Unused - */ - public static void setOptionsProperties() - { - //Set any properties that need to be set based on the last run. - } - - /** * Returns the parent of the specified path. * *@param path The path name @@ -561,23 +513,6 @@ } /** - * Constructs an absolute path name from three path components. This method is - * VFS-aware. - * - *@param parent The parent directory - *@param path1 The first path - *@param path2 The second path - *@return the absolute path name - *@since GMGen 3.3 - * - * @deprecated Unused - */ - public static String constructPath(String parent, String path1, String path2) - { - return constructPath(constructPath(parent, path1), path2); - } - - /** * Copy a file * @param from_file * @param to_file @@ -730,25 +665,6 @@ return new String(clsName, 0, clsName.length - 6); } - /** - * Reads the localization properties file. - *@since GMGen 3.3 - * - * @deprecated Unused - */ - public static void readLocalizationProperties() - { - try - { - FileInputStream in = new FileInputStream("/pcgen/gui/prop/LanguageBundle.properties"); - localization.load(in); - } - catch (IOException e) - { - Logging.errorPrint("No localization file found."); - } - } - /** Converts a Color to an 7 byte hex string starting with '#'. * @param c * @return String*/ Modified: Trunk/pcgen/code/src/java/gmgen/util/OSXAdapter.java =================================================================== --- Trunk/pcgen/code/src/java/gmgen/util/OSXAdapter.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/gmgen/util/OSXAdapter.java 2006-03-30 13:51:20 UTC (rev 523) @@ -34,23 +34,6 @@ mainApp = inApp; } - /** - * Another static entry point for EAWT functionality. Enables the - * "Preferences..." menu item in the application menu. - * - * @param enabled - * @deprecated Unused - */ - public static void enablePrefs(boolean enabled) - { - if (theApplication == null) - { - theApplication = new com.apple.eawt.Application(); - } - - theApplication.setEnabledPreferencesMenu(enabled); - } - public void handlePreferences(ApplicationEvent ae) { if (mainApp != null) Modified: Trunk/pcgen/code/src/java/gmgen/util/OperatingSystem.java =================================================================== --- Trunk/pcgen/code/src/java/gmgen/util/OperatingSystem.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/gmgen/util/OperatingSystem.java 2006-03-30 13:51:20 UTC (rev 523) @@ -20,9 +20,6 @@ */ package gmgen.util; -import javax.swing.UIManager; -import java.awt.Rectangle; -import java.awt.Toolkit; import java.io.File; /** @@ -47,7 +44,6 @@ private static final int VMS = 0xDEAD2; private static final int UNKNOWN = 0xBAD; private static int os; - private static int hasScreenMenuBar = -1; static { @@ -114,19 +110,6 @@ } /** - * Returns if we're running MacOS X and using the native look and feel. - * - *@return if we're running MacOS X and using the native look and feel. - *@since GMGen 3.3 - * - * @deprecated Unused - */ - public static final boolean isMacOSLF() - { - return (isMacOS() && UIManager.getLookAndFeel().isNativeLookAndFeel()); - } - - /** * Returns if we're running OS/2. * *@return if we're running OS/2. @@ -138,50 +121,6 @@ } /** - * Returns the bounds of the default screen. - * - *@return the bounds of the default screen. - *@since GMGen 3.3 - * - * @deprecated Unused - */ - public static final Rectangle getScreenBounds() - { - int screenX = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth(); - int screenY = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight(); - int x; - int y; - int w; - int h; - - if (isMacOS()) - { - x = 0; - y = 22; - w = screenX; - h = screenY - y - 4; - - //shadow size - } - else if (isWindows()) - { - x = -4; - y = -4; - w = screenX - (2 * x); - h = screenY - (2 * y); - } - else - { - x = 0; - y = 0; - w = screenX; - h = screenY; - } - - return new Rectangle(x, y, w, h); - } - - /** * Returns if we're running Unix (this includes MacOS X). * *@return if we're running Unix (this includes MacOS X). @@ -193,20 +132,6 @@ } /** - * Returns if we're unning VMS. Yah, right... pull the other one, it's got - * bells on it. - * - *@return if we're running VMS. - *@since GMGen 3.3 - * - * @deprecated Unused - */ - public static final boolean isVMS() - { - return os == VMS; - } - - /** * Returns if we're running Windows 95/98/ME/NT/2000/XP. * *@return if we're running Windows 95/98/ME/NT/2000/XP. @@ -216,72 +141,4 @@ { return (os == WINDOWS_9x) || (os == WINDOWS_NT); } - - /** - * Returns if we're running Windows 95/98/ME. - * - *@return if we're running Windows 95/98/ME. - *@since GMGen 3.3 - * - * @deprecated Unused - */ - public static final boolean isWindows9x() - { - return os == WINDOWS_9x; - } - - /** - * Returns if we're running Windows NT/2000/XP. - * - *@return if we're running Windows NT/2000/XP. - *@since GMGen 3.3 - * - * @deprecated Unused - */ - public static final boolean isWindowsNT() - { - return os == WINDOWS_NT; - } - - /** - * Returns if Java 2 version 1.4 is in use. - * - *@return if Java 2 v 1.4 is being used - *@since GMGen 3.3 - * - * @deprecated Unused - */ - public static final boolean isJava14() - { - return IS_JAVA_14; - } - - /** - * Returns whether the screen menu bar on Mac OS X is in use. - * - *@return whether the screen menu bar on Mac OS X is in use. - *@since GMGen 3.3 - * - * @deprecated Unused - */ - public static final boolean hasScreenMenuBar() - { - if (!isMacOS()) - { - return false; - } - else if (hasScreenMenuBar == -1) - { - String result = System.getProperty("apple.laf.useScreenMenuBar"); - - if (result == null) - { - result = System.getProperty("com.apple.macos.useScreenMenuBar"); - } - - hasScreenMenuBar = (result.equals("true")) ? 1 : 0; - } - - return (hasScreenMenuBar == 1); - } } Modified: Trunk/pcgen/code/src/java/pcgen/core/Equipment.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Equipment.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/pcgen/core/Equipment.java 2006-03-30 13:51:20 UTC (rev 523) @@ -6264,7 +6264,6 @@ * Description of the Method * * @return Description of the Return Value - * @deprecated -- this is dead code; sage_sam 04 Sept 2003 */ private SortedSet eqTypeList() { Modified: Trunk/pcgen/code/src/java/pcgen/core/PCClass.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2006-03-30 13:51:20 UTC (rev 523) @@ -2251,16 +2251,6 @@ return list; } - - - - public boolean isPrestige() - { - Logging.errorPrint("IsPrestige should be deprecated."); - - return isType("PRESTIGE"); - } - public boolean isQualified(final PlayerCharacter aPC) { @@ -3653,20 +3643,6 @@ return numSpellsFromSpecialty; } - boolean isNPC() - { - Logging.errorPrint("IsNPC should be deprecated."); - - return isType("NPC"); - } - - boolean isPC() - { - Logging.errorPrint("IsPC should be deprecated."); - - return ((getMyTypeCount() == 0) || isType("PC")); - } - public boolean isProhibited(final Spell aSpell, final PlayerCharacter aPC) { final StringTokenizer aTok = new StringTokenizer(prohibitedString, ",", false); Modified: Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2006-03-30 13:51:20 UTC (rev 523) @@ -406,22 +406,7 @@ return gender; } - /** - * Set a lock on which hand will be the dominant one in characters this - * Template is applied to - * - * @deprecated appears to be totally unused. a private attribute with a setter but - * no accessor. - * - * @param handedString the favoured hand - */ - public void setHandedLock(final String handedString) - { - handed = handedString; - } - - /** * Set a lock on the hitdie size of a character that this template is * applied to. Possible formats for the lock include * Modified: Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-03-30 13:51:20 UTC (rev 523) @@ -3838,15 +3838,6 @@ */ /** - * @return Returns the canWrite. - * - * @deprecated Unused - */ - public final boolean getCanWrite() - { - return canWrite; - } - /** * @param canWrite The canWrite to set. */ public final void setCanWrite(boolean canWrite) @@ -3877,26 +3868,6 @@ } /** - * @param existsOnly The existsOnly value to set. - * - * @deprecated Unused - */ - public final void setExistsOnly(boolean existsOnly) - { - this.existsOnly = existsOnly; - } - - /** - * @return Returns the noMoreItems. - * - * @deprecated Unused - */ - public final boolean getNoMoreItems() - { - return noMoreItems; - } - - /** * @param noMoreItems The noMoreItems value to set. */ public final void setNoMoreItems(boolean noMoreItems) @@ -3904,8 +3875,6 @@ this.noMoreItems = noMoreItems; } - - /** * Get the token string * @param aPC Modified: Trunk/pcgen/code/src/java/pcgen/io/IOConstants.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/IOConstants.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/pcgen/io/IOConstants.java 2006-03-30 13:51:20 UTC (rev 523) @@ -28,7 +28,7 @@ */ interface IOConstants { - /** AGE tag */ + /** AGE tag - Used by PCGVer2Creator and Parser */ String TAG_AGE = "AGE"; /** AGE SET tag */ @@ -76,15 +76,9 @@ /** CAMPAIGN - System Information */ String TAG_CAMPAIGN = "CAMPAIGN"; - /** @deprecated Unused, to be removed 5.10 Beta 1 */ - String TAG_CAMPAIGNS = "CAMPAIGNS"; - /** CANCASTPERDAY - character spells info */ String TAG_CANCASTPERDAY = "CANCASTPERDAY"; - /** @deprecated Unused, to be removed 5.10 Beta 1 */ - String TAG_CARRIED = "CARRIED"; - /** CATCHPHRASE */ String TAG_CATCHPHRASE = "CATCHPHRASE"; @@ -127,27 +121,12 @@ /** CLASSBOUGHT - Character skills */ String TAG_CLASSBOUGHT = "CLASSBOUGHT"; - /** @deprecated Unused, to be removed in 5.10 Beta 1 */ - String TAG_CLASSLEVEL = "CLASSLEVEL"; - /** CLASSSKILL */ String TAG_CLASSSKILL = "CLASSSKILL"; - /** @deprecated Unused, to be removed in 5.10 Beta 1 */ - String TAG_COMP = "COMP"; - - /** @deprecated Unused, to be removed in 5.10 Beta 1 */ - String TAG_CONTAINS = "CONTAINS"; - /** COST - Currently (20/03/2006) only being used by CMP data sources */ String TAG_COST = "COST"; - /** @deprecated Unused, to be removed in 5.10 Beta 1 */ - String TAG_CROSSCLASS = "CROSSCLASS"; - - /** @deprecated Unused, to be removed in 5.10 Beta 1 */ - String TAG_CT = "CT"; - /** CUSTOMIZATION */ String TAG_CUSTOMIZATION = "CUSTOMIZATION"; /** DATA */ @@ -163,36 +142,19 @@ String TAG_DEITYDOMAINS = "DEITYDOMAINS"; /** DEITYFAVWEAP */ String TAG_DEITYFAVWEAP = "DEITYFAVWEAP"; + /** DESC */ String TAG_DESC = "DESC"; - /** @deprecated Unused - remove in 5.10 Beta 1 */ - String TAG_DESCRIPTOR = "DESCRIPTOR"; /** DOMAIN */ String TAG_DOMAIN = "DOMAIN"; - /** @deprecated Unused remove in 5.10 Beta 1 */ - String TAG_DOMAINFEATS = "DOMAINFEATS"; /** DOMAINGRANTS */ String TAG_DOMAINGRANTS = "DOMAINGRANTS"; - /** @deprecated Unused - remove in 5.10 Beta 1 */ - String TAG_DOMAINSKILLS = "DOMAINSKILLS"; - - /** @deprecated Unused - remove in 5.10 Beta 1 */ - String TAG_DOMAINSPECIALS = "DOMAINSPECIALS"; /** DOMAINSPELLS */ String TAG_DOMAINSPELLS = "DOMAINSPELLS"; - /** @deprecated Unused - remove in 5.10 Beta 1 */ - String TAG_DURATION = "DURATION"; - - /** @deprecated Unused - remove in 5.10 Beta 1 */ - String TAG_EFFECT = "EFFECT"; - - /** @deprecated Unused - remove in 5.10 Beta 1 */ - String TAG_EFFECTTYPE = "EFFECTTYPE"; - /** EquipSet Temporary Bonuses */ String TAG_EQSETBONUS = "EQSETBONUS"; @@ -216,8 +178,6 @@ /** Character feats */ String TAG_FEAT = "FEAT"; - /** @deprecated Unused - remove in 5.10 Beta 1 */ - String TAG_FEAT_CATEGORY = "CATEGORY"; /** FEATLIST */ String TAG_FEATLIST = "FEATLIST"; /** FEATPOOL */ @@ -265,10 +225,6 @@ String TAG_MASTER = "MASTER"; - /** - * @deprecated Unused - */ - String TAG_MISC = "MISC"; String TAG_MONEY = "MONEY"; String TAG_MULTISELECT = "MULTISELECT"; String TAG_NAME = "NAME"; @@ -287,10 +243,6 @@ String TAG_POSTSTAT = "POSTSTAT"; - /** - * @deprecated Unused - */ - String TAG_POWERNAME = "POWERNAME"; String TAG_PRESTAT = "PRESTAT"; String TAG_PROHIBITED = "PROHIBITED"; String TAG_PROMPT = "PROMPT"; @@ -299,10 +251,6 @@ String TAG_RACE = "RACE"; - /** - * @deprecated Unused - */ - String TAG_RANGE = "RANGE"; String TAG_RANKS = "RANKS"; String TAG_REGION = "REGION"; String TAG_RESIDENCE = "RESIDENCE"; @@ -311,11 +259,6 @@ String TAG_SAVE = "SAVE"; String TAG_SAVES = "SAVES"; - - /** - * @deprecated Unused - */ - String TAG_SCHOOL = "SCHOOL"; String TAG_SCORE = "SCORE"; String TAG_SKILL = "SKILL"; String TAG_SKILLPOINTSGAINED = "SKILLSGAINED"; @@ -330,10 +273,6 @@ String TAG_SPEECHPATTERN = "SPEECHPATTERN"; - /** - * @deprecated Unused - */ - String TAG_SPELL = "SPELL"; String TAG_SPELLBASE = "SPELLBASE"; String TAG_SPELL_BOOK = "BOOK"; String TAG_SPELLBOOK = "SPELLBOOK"; @@ -344,26 +283,11 @@ String TAG_SPELLNUMPAGES = "SPELLNUMPAGES"; - /** - * @deprecated Unused - */ - String TAG_SR = "SR"; // Character attributes String TAG_STAT = "STAT"; String TAG_SUBCLASS = "SUBCLASS"; - - /** - * @deprecated Unused - */ - String TAG_SUBSCHOOL = "SUBSCHOOL"; - - - /** - * @deprecated Unused - */ - String TAG_SYMBOL = "SYMBOL"; String TAG_SYNERGY = "SYNERGY"; String TAG_TABLABEL = "TABLABEL"; String TAG_TABNAME = "TABNAME"; @@ -372,11 +296,6 @@ String TAG_TEMPBONUS = "TEMPBONUS"; String TAG_TEMPBONUSBONUS = "TBBONUS"; - - /** - * @deprecated Unused - */ - String TAG_TEMPBONUSSOURCE = "TBSOURCE"; String TAG_TEMPBONUSTARGET = "TBTARGET"; String TAG_TEMPLATE = "TEMPLATE"; @@ -384,18 +303,8 @@ String TAG_TEMPLATESAPPLIED = "TEMPLATESAPPLIED"; String TAG_TIMES = "TIMES"; - - /** - * @deprecated Unused - */ - String TAG_TOTALWT = "TOTALWT"; String TAG_TYPE = "TYPE"; - - /** - * @deprecated Unused - */ - String TAG_UNLIMITEDPOOLCHECKED = "UNLIMITEDPOOLCHECKED"; String TAG_USETEMPMODS = "USETEMPMODS"; String TAG_USEHIGHERKNOWN = "USEHIGHERKNOWN"; String TAG_USEHIGHERPREPPED = "USEHIGHERPREPPED"; Modified: Trunk/pcgen/code/src/java/pcgen/io/PCGParseException.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/PCGParseException.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/pcgen/io/PCGParseException.java 2006-03-30 13:51:20 UTC (rev 523) @@ -37,16 +37,6 @@ /** * Constructor - * - * @deprecated Unused - */ - PCGParseException() - { - this("", "", ""); - } - - /** - * Constructor * @param errorMethod * @param errorLine * @param errorMessage Modified: Trunk/pcgen/code/src/java/pcgen/io/exporttoken/SpellListToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/SpellListToken.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/pcgen/io/exporttoken/SpellListToken.java 2006-03-30 13:51:20 UTC (rev 523) @@ -38,8 +38,6 @@ */ public abstract class SpellListToken extends Token { - /** @deprecated Unused */ - protected static final int SPELLTAG_UNKNOWN = -1; protected static final int SPELLTAG_CAST = 0; protected static final int SPELLTAG_KNOWN = 1; protected static final int SPELLTAG_BOOK = 2; Modified: Trunk/pcgen/code/src/java/pcgen/io/exporttoken/WeaponToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/WeaponToken.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/pcgen/io/exporttoken/WeaponToken.java 2006-03-30 13:51:20 UTC (rev 523) @@ -496,19 +496,6 @@ } /** - * Get the name sub token - * @param eq - * @param pc - * @return name sub token - * - * @deprecated Unused - */ - public static String getNameToken(Equipment eq, PlayerCharacter pc) - { - return getNameToken(eq, pc, false); - } - - /** * Get the is light sub token * @param pc * @param eq @@ -2049,12 +2036,13 @@ int secondariesToadd = 1 + (int) pc.getTotalBonusTo("COMBAT", "ATTACKS-SECONDARY"); - /* The data team wishes to keep the old syntax for secondary attacks. + /* + * The data team wishes to keep the old syntax for secondary attacks. * The docs have been updated to reflect this. The new syntax (with * the hyphen, see above) is not used in the repository. This comment * is here so that the old syntax will not be deprecated or removed in - * the future. */ - + * the future. + */ secondariesToadd += (int) pc.getTotalBonusTo("COMBAT", "SECONDARYATTACKS"); if (pc.getPrimaryWeapons().isEmpty() && (hitMode == HITMODE_TOTALHIT)) Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstObjectFileLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstObjectFileLoader.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstObjectFileLoader.java 2006-03-30 13:51:20 UTC (rev 523) @@ -458,24 +458,6 @@ } /** - * This method, when implemented, will perform a single .FORGET - * operation. - * @deprecated instead implement performForget(PObject) - * @param forgetName containing the name of the object to forget - * - * Commented out, to be removed later - */ - /*private void performForget(String forgetName) - { - PObject objToForget = getObjectNamed(forgetName); - - if (objToForget != null) - { - performForget(objToForget); - } - }*/ - - /** * This method will perform a single .MOD * operation. Loaders can [typically] use the name without checking * for (or stripping off) .MOD due to the implementation of Modified: Trunk/pcgen/code/src/java/pcgen/util/PJEP.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/util/PJEP.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/pcgen/util/PJEP.java 2006-03-30 13:51:20 UTC (rev 523) @@ -158,12 +158,10 @@ /** * @deprecated + * eg. cl("Fighter") + * eg. cl("Fighter", 21) + * eg. cl() */ - // - // eg. cl("Fighter") - // eg. cl("Fighter", 21) - // eg. cl() - // private final class ClassLevel extends PostfixMathCommand { private ClassLevel() Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/template/HandedlockToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/HandedlockToken.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/HandedlockToken.java 2006-03-30 13:51:20 UTC (rev 523) @@ -1,24 +0,0 @@ -package plugin.lsttokens.template; - -import pcgen.core.PCTemplate; -import pcgen.persistence.lst.PCTemplateLstToken; - - -/** - * Class deals with HANDEDLOCK Token - * @deprecated To be removed in 5.10 Beta 1 (don't forget to remove entry in - * build.xml file when you remove this class) - */ -public class HandedlockToken implements PCTemplateLstToken { - - public String getTokenName() { - return "HANDEDLOCK"; - } - - // set and lock character handedness, disabling pulldown menu in description section. - public boolean parse(PCTemplate template, String value) { - // template.setHandedLock(value); - return true; - } -} - Modified: Trunk/pcgen/code/src/java/plugin/overland/gui/OverPanel.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/overland/gui/OverPanel.java 2006-03-30 12:19:11 UTC (rev 522) +++ Trunk/pcgen/code/src/java/plugin/overland/gui/OverPanel.java 2006-03-30 13:51:20 UTC (rev 523) @@ -120,26 +120,6 @@ initData(); } - /** - * Initialization of the bulk of preferences. sets the defaults - * if this is the first time you have used this version - * @deprecated Code here is commented out and therefore not run - * to be removed in 5.9.6 - */ - public void initPrefs() - { -/* boolean prefsSet = namePrefs.getBoolean("arePrefsSet", false); - if (!prefsSet) { - namePrefs.putBoolean("arePrefsSet", true); - } - double version = namePrefs.getDouble("Version", 0); - if (version < 0.5 || !prefsSet) { - namePrefs.putDouble("Version", 0.5); - } - namePrefs.putDouble("SubVersion", 0); - */ - } - private void butToDistActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_butToDistActionPerformed This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <boo...@us...> - 2006-04-05 04:26:17
|
Revision: 629 Author: boomer70 Date: 2006-04-04 21:26:09 -0700 (Tue, 04 Apr 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=629&view=rev Log Message: ----------- Removed unused and undocumented PROF: token from Race. Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/Globals.java Trunk/pcgen/code/src/java/pcgen/core/Race.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/race/ProfToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-04-05 02:28:01 UTC (rev 628) +++ Trunk/pcgen/code/pluginbuild.xml 2006-04-05 04:26:09 UTC (rev 629) @@ -21,8 +21,8 @@ <property name="lstplugins.dir" value="${plugins.dir}/lstplugins" /> <property name="systemlstplugins.dir" value="${plugins.dir}/systemlstplugins" /> <property name="jepplugins.dir" value="${plugins.dir}/jepplugins" /> - + <target name="jar-all-plugins" depends="makeplugindirs,jar-gmgen-plugins,jar-export-plugins,jar-bonus-plugins,jar-pre-plugins,jar-lst-plugins, jar-systemlst-plugins, jar-jep-plugins" description="Build (Link) plugin jar files"> </target> @@ -2831,7 +2831,7 @@ </fileset> </jar> </target> - + <target name="jar-lst-diety-plugins" depends="makeplugindirs" description="Build (Link) Diety Lst Token plugin jar files"> <!-- Deity tokens--> <jar jarfile="${lstplugins.dir}/DeityLstToken-ALIGN.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> @@ -2912,7 +2912,7 @@ </fileset> </jar> </target> - + <target name="jar-lst-domain-plugins" depends="makeplugindirs" description="Build (Link) Do Lst Token plugin jar files"> <!-- Domain tokens--> <jar jarfile="${lstplugins.dir}/DomainLstToken-ABILITY.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> @@ -3466,13 +3466,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/RaceLstToken-PROF.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/race/ProfToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/RaceLstToken-QUALIFY.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -4482,7 +4475,7 @@ </patternset> </fileset> </jar> - + </target> <target name="jar-jep-plugins" depends="makeplugindirs" description="Build (Link) Jep Command plugin jar files"> Modified: Trunk/pcgen/code/src/java/pcgen/core/Globals.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2006-04-05 02:28:01 UTC (rev 628) +++ Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2006-04-05 04:26:09 UTC (rev 629) @@ -115,7 +115,7 @@ private static List templateList = new ArrayList(350); private static DenominationList denomList = DenominationList.getInstance(); // derived from ArrayList private static SortedSet saSet = new TreeSet(); - + private static Map sponsors = new HashMap(); private static List sponsorList = new ArrayList(); @@ -555,7 +555,7 @@ if (tTok.hasMoreTokens()) { final String tabName = tTok.nextToken(); - + if (tabName.equals(cName)) { colSize = Integer.parseInt(tTok.nextToken()); @@ -566,7 +566,7 @@ return colSize; } // END Game Modes Section. - + /** * Get the default path * @return default path @@ -749,7 +749,7 @@ } /** - * Set equipment slot type count + * Set equipment slot type count * @param aString * @param aNum */ @@ -1039,7 +1039,7 @@ } /** - * Get game mode skill cost for class + * Get game mode skill cost for class * @return game modeskill cost for class */ public static int getGameModeSkillCost_Class() @@ -1048,7 +1048,7 @@ } /** - * Get game mode skill cost for cross-class + * Get game mode skill cost for cross-class * @return game modeskill cost for cross-class */ public static int getGameModeSkillCost_CrossClass() @@ -1057,7 +1057,7 @@ } /** - * Get game mode skill cost for exclusive + * Get game mode skill cost for exclusive * @return game modeskill cost for exclusive */ public static int getGameModeSkillCost_Exclusive() @@ -1180,7 +1180,7 @@ /** * Get kit info - * @return kit info + * @return kit info */ public static List getKitInfo() { @@ -1313,7 +1313,7 @@ } /** - * Get PCC class type list + * Get PCC class type list * @return PCC class type list */ public static List getPCClassTypeList() @@ -1834,7 +1834,7 @@ } /** - * Get the template list + * Get the template list * @return list of tempaltes */ public static List getTemplateList() @@ -2250,7 +2250,7 @@ } // Spell info section - + /** * Add to the spell casting times set * @param aString @@ -2261,7 +2261,7 @@ } /** - * Add to the spell components set + * Add to the spell components set * @param aString */ public static void addSpellComponentSet(final String aString) @@ -2796,10 +2796,10 @@ } /** - * Return TRUE if the weapon profs have a variable named x + * Return TRUE if the weapon profs have a variable named x * @param collectionOfNames * @param variableString - * @return TRUE if the weapon profs have a variable named x + * @return TRUE if the weapon profs have a variable named x */ public static boolean hasWeaponProfVariableNamed(final Collection collectionOfNames, final String variableString) { @@ -3485,29 +3485,6 @@ String wpString; WeaponProf tempProf; - for (Iterator e = aPC.getRace().getWeaponProfs().iterator(); e.hasNext();) - { - aString = (String) e.next(); - aTok = new StringTokenizer(aString, "|"); - typeString = aTok.nextToken(); - wpString = aTok.nextToken(); - tempProf = getWeaponProfNamed(wpString); - - if (tempProf == null) - { - continue; - } - - if (typeString.equalsIgnoreCase(type)) - { - aList.add(tempProf); - } - else - { - bList.add(tempProf); - } - } - for (Iterator e = aPC.getChangeProfList().iterator(); e.hasNext();) { aString = (String) e.next(); @@ -4100,7 +4077,7 @@ sponsors.put(sponsor.get("SPONSOR"), sponsor); sponsorList.add(sponsor); } - + /** * Get a list of sponsors of PCGen * @return list of sponsors of PCGen @@ -4108,7 +4085,7 @@ public static List getSponsors() { return sponsorList; } - + /** * Get a sponsor * @param name Modified: Trunk/pcgen/code/src/java/pcgen/core/Race.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Race.java 2006-04-05 02:28:01 UTC (rev 628) +++ Trunk/pcgen/code/src/java/pcgen/core/Race.java 2006-04-05 04:26:09 UTC (rev 629) @@ -45,7 +45,6 @@ private ArrayList monCCSkillList = null; private ArrayList monCSkillList = null; private ArrayList weaponProfBonus = new ArrayList(); - private ArrayList weaponProfs = new ArrayList(); private HashMap hitPointMap = new HashMap(); private Integer initMod = new Integer(0); private Integer naturalAC = new Integer(0); @@ -868,23 +867,6 @@ txt.append("\tLEVELADJUSTMENT:").append(levelAdjustment); } - if ((weaponProfs != null) && (weaponProfs.size() > 0)) - { - final StringBuffer buffer = new StringBuffer(); - - for (Iterator e = weaponProfs.iterator(); e.hasNext();) - { - if (buffer.length() != 0) - { - buffer.append('|'); - } - - buffer.append((String) e.next()); - } - - txt.append("\tPROF:").append(buffer.toString()); - } - if (!"alwaysValid".equals(getQualifyString())) { txt.append("\tQUALIFY:").append(getQualifyString()); @@ -959,18 +941,6 @@ return weaponProfBonus; } - public void setWeaponProfs(final String aString) - { - final StringTokenizer aTok = new StringTokenizer(aString, "|"); - final String typeString = aTok.nextToken(); - final String prefix = typeString + "|"; - - while (aTok.hasMoreTokens()) - { - weaponProfs.add(prefix + aTok.nextToken()); - } - } - public Object clone() { Race aRace = null; @@ -1006,7 +976,6 @@ aRace.hands = hands; aRace.reach = reach; aRace.face = face; - aRace.weaponProfs = (ArrayList) weaponProfs.clone(); } catch (CloneNotSupportedException exc) { @@ -1131,11 +1100,6 @@ return getMonsterClass(aPC, true); } - ArrayList getWeaponProfs() - { - return weaponProfs; - } - int bonusForSkill(final String skillName) { if (getBonusSkillList().length() == 0) Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/race/ProfToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/race/ProfToken.java 2006-04-05 02:28:01 UTC (rev 628) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/race/ProfToken.java 2006-04-05 04:26:09 UTC (rev 629) @@ -1,19 +0,0 @@ -package plugin.lsttokens.race; - -import pcgen.core.Race; -import pcgen.persistence.lst.RaceLstToken; - -/** - * Class deals with PROF Token - */ -public class ProfToken implements RaceLstToken { - - public String getTokenName() { - return "PROF"; - } - - public boolean parse(Race race, String value) { - race.setWeaponProfs(value); - return true; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kar...@us...> - 2006-05-19 15:29:52
|
Revision: 992 Author: karianna Date: 2006-05-19 08:29:39 -0700 (Fri, 19 May 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=992&view=rev Log Message: ----------- Tokenised Armor Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/exporttokens/ArmorToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-05-19 15:07:50 UTC (rev 991) +++ Trunk/pcgen/code/pluginbuild.xml 2006-05-19 15:29:39 UTC (rev 992) @@ -135,6 +135,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${outputplugins.dir}/ExportToken-ARMOR.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/ArmorToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${outputplugins.dir}/ExportToken-BASEMOVEMENT.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-05-19 15:07:50 UTC (rev 991) +++ Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-05-19 15:29:39 UTC (rev 992) @@ -420,359 +420,6 @@ } /** - * select suits - shields - * @param armor - * @param property - * @param equipped - * @param len - * @param output - * @param merge - * @param aPC - * @return int - */ - private int _replaceTokenArmor(int armor, String property, int equipped, int len, BufferedWriter output, int merge, PlayerCharacter aPC) - { - final List aArrayList = aPC.getEquipmentOfTypeInOutputOrder("Armor", equipped, merge); - final List bArrayList = aPC.getEquipmentOfTypeInOutputOrder("Shield", equipped, merge); - - for (Iterator e = bArrayList.iterator(); e.hasNext();) - { - aArrayList.remove(e.next()); - } - - if ((armor >= (aArrayList.size() - 1)) && existsOnly) - { - len = 0; - noMoreItems = true; - } - - if (armor < aArrayList.size()) - { - final Equipment eq = (Equipment) aArrayList.get(armor); - _writeArmorProperty(eq, property, output, aPC); - } - - return len; - } - - /** - * select items, which improve AC but are not type ARMOR - * @param item - * @param subtype - * @param property - * @param equipped - * @param len - * @param output - * @param merge - * @param aPC - * @return int - */ - private int _replaceTokenArmorItem(int item, String subtype, String property, int equipped, int len, - BufferedWriter output, int merge, PlayerCharacter aPC) - { - // select all pieces of equipment of status==equipped - // filter all AC relevant stuff - final List aArrayList = new ArrayList(); - - for (Iterator e = aPC.getEquipmentListInOutputOrder(merge).iterator(); e.hasNext();) - { - Equipment eq = (Equipment) e.next(); - - if (("".equals(subtype) || eq.isType(subtype)) - && ((equipped == 3) || ((equipped == 2) && !eq.isEquipped()) || ((equipped == 1) && eq.isEquipped()))) - { - if (eq.getBonusListString("AC") && !eq.isArmor() && !eq.isShield()) - { - aArrayList.add(eq); - } - } - } - - if (item >= aArrayList.size()) - { - len = 0; - noMoreItems = true; - } - - if (item < aArrayList.size()) - { - final Equipment eq = (Equipment) aArrayList.get(item); - _writeArmorProperty(eq, property, output, aPC); - } - - return len; - } - - /** - * select shields - * @param shield - * @param subtype - * @param property - * @param equipped - * @param len - * @param output - * @param merge - * @param aPC - * @return int - */ - private int _replaceTokenArmorShield(int shield, String subtype, String property, int equipped, int len, - BufferedWriter output, int merge, PlayerCharacter aPC) - { - final List aArrayList = aPC.getEquipmentOfTypeInOutputOrder("Shield", subtype, equipped, merge); - - if ((shield >= (aArrayList.size() - 1)) && existsOnly) - { - len = 0; - noMoreItems = true; - } - - if (shield < aArrayList.size()) - { - final Equipment eq = (Equipment) aArrayList.get(shield); - _writeArmorProperty(eq, property, output, aPC); - } - - return len; - } - - /** - * select shirts - * @param shirt - * @param subtype - * @param property - * @param equipped - * @param len - * @param output - * @param merge - * @param aPC - * @return int - */ - private int _replaceTokenArmorShirt(int shirt, String subtype, String property, int equipped, int len, - BufferedWriter output, int merge, PlayerCharacter aPC) - { - final List aArrayList = aPC.getEquipmentOfTypeInOutputOrder("Shirt", subtype, equipped, merge); - - if ((shirt >= (aArrayList.size() - 1)) && existsOnly) - { - len = 0; - noMoreItems = true; - } - - if (shirt < aArrayList.size()) - { - final Equipment eq = (Equipment) aArrayList.get(shirt); - _writeArmorProperty(eq, property, output, aPC); - } - - return len; - } - - /** - * select suits - * @param suit - * @param subtype - * @param property - * @param equipped - * @param len - * @param output - * @param merge - * @param aPC - * @return int - */ - private int _replaceTokenArmorSuit(int suit, String subtype, String property, int equipped, int len, - BufferedWriter output, int merge, PlayerCharacter aPC) - { - final List aArrayList = aPC.getEquipmentOfTypeInOutputOrder("Suit", subtype, equipped, merge); - - // - // Temporary hack until someone gets around to fixing it properly - // - //aArrayList.addAll(aPC.getEquipmentOfTypeInOutputOrder("Shirt", subtype, equipped)); - if ((suit >= (aArrayList.size() - 1)) && existsOnly) - { - len = 0; - noMoreItems = true; - } - - if (suit < aArrayList.size()) - { - final Equipment eq = (Equipment) aArrayList.get(suit); - _writeArmorProperty(eq, property, output, aPC); - } - - return len; - } - - /** - * select various stuff, that improves AC - * @param index - * @param type - * @param subtype - * @param property - * @param equipped - * @param len - * @param output - * @param merge - * @param aPC - * @return int - */ - private int _replaceTokenArmorVarious(int index, String type, String subtype, String property, int equipped, - int len, BufferedWriter output, int merge, PlayerCharacter aPC) - { - Equipment eq; - final List aArrayList = new ArrayList(); - - for (Iterator mapIter = aPC.getEquipmentOfTypeInOutputOrder(type, subtype, equipped, merge).iterator(); - mapIter.hasNext();) - { - eq = (Equipment) mapIter.next(); - - if (eq.getACMod(aPC).intValue() > 0) - { - aArrayList.add(eq); - } - else if (eq.getBonusListString("AC")) - { - aArrayList.add(eq); - } - } - - if ((index >= (aArrayList.size() - 1)) && existsOnly) - { - len = 0; - noMoreItems = true; - } - - if (index < aArrayList.size()) - { - eq = (Equipment) aArrayList.get(index); - _writeArmorProperty(eq, property, output, aPC); - } - - return len; - } - - private void _writeArmorProperty(Equipment eq, String property, BufferedWriter output, PlayerCharacter aPC) - { - if (property.startsWith("NAME")) - { - if (eq.isEquipped()) - { - FileAccess.write(output, "*"); - } - - //FileAccess.encodeWrite(output, eq.getName()); - FileAccess.encodeWrite(output, eq.parseOutputName(eq.getOutputName(), aPC)); - FileAccess.encodeWrite(output, eq.getAppliedName()); - } - else if (property.startsWith("OUTPUTNAME")) - { - if (eq.isEquipped()) - { - FileAccess.write(output, "*"); - } - - FileAccess.encodeWrite(output, eq.parseOutputName(eq.getOutputName(), aPC)); - FileAccess.encodeWrite(output, eq.getAppliedName()); - } - else if (property.startsWith("TOTALAC")) - { - // adjustments for new equipment modifier - // EQMARMOR|AC|x|TYPE=ENHANCEMENT changed to COMBAT|AC|x|TYPE=Armor.ENHANCEMENT - //FileAccess.write(output, Delta.toString(eq.getACMod())); - FileAccess.write(output, Delta.toString((int) eq.bonusTo(aPC, "COMBAT", "AC", true))); - } - else if (property.startsWith("BASEAC")) - { - // adjustments for new equipment modifier - // EQMARMOR|AC|x|TYPE=ENHANCEMENT changed to COMBAT|AC|x|TYPE=Armor.ENHANCEMENT - //FileAccess.write(output, Delta.toString(eq.getACMod())); - FileAccess.write(output, Delta.toString((int) eq.bonusTo("COMBAT", "AC", aPC, aPC))); - } - else if (property.startsWith("ACBONUS")) - { - FileAccess.write(output, Delta.toString((int) eq.bonusTo(aPC, "COMBAT", "AC", true))); - } - else if (property.startsWith("MAXDEX")) - { - final int iMax = eq.getMaxDex(aPC).intValue(); - - if (iMax != Constants.MAX_MAXDEX) - { - FileAccess.write(output, Delta.toString(iMax)); - } - } - else if (property.startsWith("ACCHECK")) - { - FileAccess.write(output, Delta.toString(eq.acCheck(aPC))); - } - else if (property.startsWith("EDR")) - { - FileAccess.write(output, Delta.toString(eq.eDR(aPC))); - } - else if (property.startsWith("ISTYPE")) - { - FileAccess.write(output, (eq.isType(property.substring(property.indexOf(".") + 1))) ? "TRUE" : "FALSE"); - } - else if (property.startsWith("SPELLFAIL")) - { - FileAccess.write(output, eq.spellFailure(aPC).toString()); - } - else if (property.startsWith("MOVE")) - { - final StringTokenizer aTok = new StringTokenizer(eq.moveString(), ",", false); - String tempString = ""; - - if (("M".equals(aPC.getSize()) || "S".equals(aPC.getSize())) && (aTok.countTokens() > 0)) - { - tempString = aTok.nextToken(); - - if ("S".equals(aPC.getSize()) && (aTok.countTokens() > 1)) - { - tempString = aTok.nextToken(); - } - } - - FileAccess.write(output, tempString); - } - else if (property.startsWith("SPROP")) - { - FileAccess.encodeWrite(output, eq.getSpecialProperties(aPC)); - } - else if (property.startsWith("TYPE")) - { - String typeString = ""; - - if (eq.isLight()) - { - typeString = "Light"; - } - else if (eq.isMedium()) - { - typeString = "Medium"; - } - else if (eq.isHeavy()) - { - typeString = "Heavy"; - } - else if (eq.isShield()) - { - typeString = "Shield"; - } - else if (eq.isExtra()) - { - typeString = "Extra"; - } - - FileAccess.write(output, typeString); - } - else if (property.startsWith("WT")) - { - FileAccess.write(output, BigDecimalHelper.trimZeros(eq.getWeight(aPC).toString())); - } - } - - /** * Add to the token map, called mainly by the plugin loader * @param newToken */ @@ -2638,14 +2285,6 @@ replaceTokenFollowers(aString, output, aPC); } - //TODO:DJ: Create pcgen.io.exportTokens.ArmorToken - // - // Not an ARMOR token unless ARMOR. or ARMOR#. ARMORQUI is most likely a variable name - // - else if (aString.startsWith("ARMOR") && ((aString.charAt(5) == '.') || Character.isDigit(aString.charAt(5)))) - { - len = replaceTokenArmor(aString, len, output, aPC); - } else { len = aString.trim().length(); @@ -2769,167 +2408,6 @@ return aString; } - /** - * See the PCGen Docs on Token Syntax - * - * @param aString - * @param len - * @param output - * @param aPC - * @return int - */ - private int replaceTokenArmor(String aString, int len, BufferedWriter output, PlayerCharacter aPC) - { - final StringTokenizer aTok = new StringTokenizer(aString, "."); - final String[] tokens = new String[aTok.countTokens()]; - - for (int i = 0; aTok.hasMoreTokens(); ++i) - { - tokens[i] = aTok.nextToken(); - } - - String property = ""; - - // When removing old syntax, this if should be removed - if (tokens.length > 0) - { - property = tokens[tokens.length - 1]; - } - - int equipped = 3; - int index = 0; - String type = ""; - String subtype = ""; - int merge = Constants.MERGE_ALL; - - for (int i = 0; i < tokens.length; ++i) - { - if ("ARMOR".equals(tokens[i])) - { - continue; - } - - // When removing old syntax, delete this if - else if (tokens[i].startsWith("ARMOR")) - { - try - { - index = Integer.parseInt(tokens[i].substring(5)); - } - catch (NumberFormatException nfe) - { - index = 0; - } - - Logging.errorPrint("Old syntax ARMORx will be replaced for ARMOR.x"); - } - else if ("ALL".equals(tokens[i])) - { - equipped = 3; - } - - // When removing old syntax, delete this if - else if (tokens[i].startsWith("ALL")) - { - Logging.errorPrint("Old syntax ALLx will be replaced for ALL.x"); - - index = Integer.parseInt(tokens[i].substring(3)); - equipped = 3; - } - else if ("EQUIPPED".equals(tokens[i])) - { - equipped = 1; - } - - // When removing old syntax, delete this if - else if (tokens[i].startsWith("EQUIPPED")) - { - Logging.errorPrint("Old syntax EQUIPPEDx will be replaced for EQUIPPED.x"); - - index = Integer.parseInt(tokens[i].substring(8)); - equipped = 1; - } - else if ("NOT_EQUIPPED".equals(tokens[i])) - { - equipped = 2; - } - - // When removing old syntax, delete this if - else if (tokens[i].startsWith("NOT_EQUIPPED")) - { - Logging.errorPrint("Old syntax NOT_EQUIPPEDx will be replaced for NOT_EQUIPPED.x"); - - index = Integer.parseInt(tokens[i].substring(12)); - equipped = 2; - } - else if (tokens[i].equals("MERGENONE")) - { - merge = Constants.MERGE_NONE; - } - else if (tokens[i].equals("MERGELOC")) - { - merge = Constants.MERGE_LOCATION; - } - else if (tokens[i].equals("MERGEALL")) - { - merge = Constants.MERGE_ALL; - } - else if (tokens[i].equals("ISTYPE")) - { - property = tokens[i] + "." + tokens[i + 1]; - - break; - } - else if (i < (tokens.length - 1)) - { - try - { - index = Integer.parseInt(tokens[i]); - } - catch (NumberFormatException exc) - { - if ("".equals(type)) - { - type = tokens[i]; - } - else - { - subtype = tokens[i]; - } - } - } - else - { - property = tokens[i]; - } - } - - if ("".equals(type)) - { - return _replaceTokenArmor(index, property, equipped, len, output, merge, aPC); - } - else if ("SUIT".equals(type)) - { - return _replaceTokenArmorSuit(index, subtype, property, equipped, len, output, merge, aPC); - } - else if ("SHIRT".equals(type)) - { - return _replaceTokenArmorShirt(index, subtype, property, equipped, len, output, merge, aPC); - } - else if ("SHIELD".equals(type)) - { - return _replaceTokenArmorShield(index, subtype, property, equipped, len, output, merge, aPC); - } - else if ("ITEM".equals(type) || "ACITEM".equals(type)) - { - return _replaceTokenArmorItem(index, subtype, property, equipped, len, output, merge, aPC); - } - else - { - return _replaceTokenArmorVarious(index, type, subtype, property, equipped, len, output, merge, aPC); - } - } - private void replaceTokenFollowers(String aString, BufferedWriter output, PlayerCharacter aPC) { /* syndaryl 24/07/2002 12:51PM: kitbashed an output format for followers, much like the FEATLIST tag */ Added: Trunk/pcgen/code/src/java/plugin/exporttokens/ArmorToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/ArmorToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/ArmorToken.java 2006-05-19 15:29:39 UTC (rev 992) @@ -0,0 +1,525 @@ +package plugin.exporttokens; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; + +import pcgen.core.Constants; +import pcgen.core.Equipment; +import pcgen.core.PlayerCharacter; +import pcgen.io.ExportHandler; +import pcgen.io.exporttoken.Token; +import pcgen.util.BigDecimalHelper; +import pcgen.util.Delta; +import pcgen.util.Logging; + +/** + * Class deals with ARMOR Token + */ +public class ArmorToken extends Token +{ + + /** Name of the Token */ + public static final String TOKENNAME = "ARMOR"; + + /** + * Get the token name + * @return token name + */ + public String getTokenName() + { + return TOKENNAME; + } + + /** + * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) + */ + public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) + { + if (tokenSource.startsWith("ARMOR") && ((tokenSource.charAt(5) == '.') || Character.isDigit(tokenSource.charAt(5)))) { + return getArmorToken(tokenSource, pc); + } + return null; + } + + /** + * @param tokenSource + * @param pc + * @return token + * + */ + public static String getArmorToken(String tokenSource, PlayerCharacter pc) + { + return replaceTokenArmor(tokenSource, pc); + } + + /** + * See the PCGen Docs on Token Syntax + * + * @param aString + * @param aPC + * @return int + */ + private static String replaceTokenArmor(String aString, PlayerCharacter aPC) + { + final StringTokenizer aTok = new StringTokenizer(aString, "."); + final String[] tokens = new String[aTok.countTokens()]; + + for (int i = 0; aTok.hasMoreTokens(); ++i) + { + tokens[i] = aTok.nextToken(); + } + + String property = ""; + + // When removing old syntax, this if should be removed + if (tokens.length > 0) + { + property = tokens[tokens.length - 1]; + } + + int equipped = 3; + int index = 0; + String type = ""; + String subtype = ""; + int merge = Constants.MERGE_ALL; + + for (int i = 0; i < tokens.length; ++i) + { + if ("ARMOR".equals(tokens[i])) + { + continue; + } + + // When removing old syntax, delete this if + else if (tokens[i].startsWith("ARMOR")) + { + try + { + index = Integer.parseInt(tokens[i].substring(5)); + } + catch (NumberFormatException nfe) + { + index = 0; + } + + Logging.errorPrint("Old syntax ARMORx will be replaced for ARMOR.x"); + } + else if ("ALL".equals(tokens[i])) + { + equipped = 3; + } + + // When removing old syntax, delete this if + else if (tokens[i].startsWith("ALL")) + { + Logging.errorPrint("Old syntax ALLx will be replaced for ALL.x"); + + index = Integer.parseInt(tokens[i].substring(3)); + equipped = 3; + } + else if ("EQUIPPED".equals(tokens[i])) + { + equipped = 1; + } + + // When removing old syntax, delete this if + else if (tokens[i].startsWith("EQUIPPED")) + { + Logging.errorPrint("Old syntax EQUIPPEDx will be replaced for EQUIPPED.x"); + + index = Integer.parseInt(tokens[i].substring(8)); + equipped = 1; + } + else if ("NOT_EQUIPPED".equals(tokens[i])) + { + equipped = 2; + } + + // When removing old syntax, delete this if + else if (tokens[i].startsWith("NOT_EQUIPPED")) + { + Logging.errorPrint("Old syntax NOT_EQUIPPEDx will be replaced for NOT_EQUIPPED.x"); + + index = Integer.parseInt(tokens[i].substring(12)); + equipped = 2; + } + else if (tokens[i].equals("MERGENONE")) + { + merge = Constants.MERGE_NONE; + } + else if (tokens[i].equals("MERGELOC")) + { + merge = Constants.MERGE_LOCATION; + } + else if (tokens[i].equals("MERGEALL")) + { + merge = Constants.MERGE_ALL; + } + else if (tokens[i].equals("ISTYPE")) + { + property = tokens[i] + "." + tokens[i + 1]; + + break; + } + else if (i < (tokens.length - 1)) + { + try + { + index = Integer.parseInt(tokens[i]); + } + catch (NumberFormatException exc) + { + if ("".equals(type)) + { + type = tokens[i]; + } + else + { + subtype = tokens[i]; + } + } + } + else + { + property = tokens[i]; + } + } + + if ("".equals(type)) + { + return _replaceTokenArmor(index, property, equipped, merge, aPC); + } + else if ("SUIT".equals(type)) + { + return _replaceTokenArmorSuit(index, subtype, property, equipped, merge, aPC); + } + else if ("SHIRT".equals(type)) + { + return _replaceTokenArmorShirt(index, subtype, property, equipped, merge, aPC); + } + else if ("SHIELD".equals(type)) + { + return _replaceTokenArmorShield(index, subtype, property, equipped, merge, aPC); + } + else if ("ITEM".equals(type) || "ACITEM".equals(type)) + { + return _replaceTokenArmorItem(index, subtype, property, equipped, merge, aPC); + } + else + { + return _replaceTokenArmorVarious(index, type, subtype, property, equipped, merge, aPC); + } + } + + /** + * select suits - shields + * @param armor + * @param property + * @param equipped + * @param merge + * @param aPC + * @return int + */ + private static String _replaceTokenArmor(int armor, String property, int equipped, int merge, PlayerCharacter aPC) + { + final List aArrayList = aPC.getEquipmentOfTypeInOutputOrder("Armor", equipped, merge); + final List bArrayList = aPC.getEquipmentOfTypeInOutputOrder("Shield", equipped, merge); + + for (Iterator e = bArrayList.iterator(); e.hasNext();) + { + aArrayList.remove(e.next()); + } + + if (armor < aArrayList.size()) + { + final Equipment eq = (Equipment) aArrayList.get(armor); + return _writeArmorProperty(eq, property, aPC); + } + + return null; + } + + /** + * select items, which improve AC but are not type ARMOR + * @param item + * @param subtype + * @param property + * @param equipped + * @param merge + * @param aPC + * @return int + */ + private static String _replaceTokenArmorItem(int item, String subtype, String property, int equipped, int merge, PlayerCharacter aPC) + { + // select all pieces of equipment of status==equipped + // filter all AC relevant stuff + final List aArrayList = new ArrayList(); + + for (Iterator e = aPC.getEquipmentListInOutputOrder(merge).iterator(); e.hasNext();) + { + Equipment eq = (Equipment) e.next(); + + if (("".equals(subtype) || eq.isType(subtype)) + && ((equipped == 3) || ((equipped == 2) && !eq.isEquipped()) || ((equipped == 1) && eq.isEquipped()))) + { + if (eq.getBonusListString("AC") && !eq.isArmor() && !eq.isShield()) + { + aArrayList.add(eq); + } + } + } + + if (item < aArrayList.size()) + { + final Equipment eq = (Equipment) aArrayList.get(item); + return _writeArmorProperty(eq, property, aPC); + } + + return null; + } + + /** + * select shields + * @param shield + * @param subtype + * @param property + * @param equipped + * @param merge + * @param aPC + * @return int + */ + private static String _replaceTokenArmorShield(int shield, String subtype, String property, int equipped, int merge, PlayerCharacter aPC) + { + final List aArrayList = aPC.getEquipmentOfTypeInOutputOrder("Shield", subtype, equipped, merge); + + if (shield < aArrayList.size()) + { + final Equipment eq = (Equipment) aArrayList.get(shield); + return _writeArmorProperty(eq, property, aPC); + } + + return null; + } + + /** + * select shirts + * @param shirt + * @param subtype + * @param property + * @param equipped + * @param merge + * @param aPC + * @return int + */ + private static String _replaceTokenArmorShirt(int shirt, String subtype, String property, int equipped, int merge, PlayerCharacter aPC) + { + final List aArrayList = aPC.getEquipmentOfTypeInOutputOrder("Shirt", subtype, equipped, merge); + + if (shirt < aArrayList.size()) + { + final Equipment eq = (Equipment) aArrayList.get(shirt); + return _writeArmorProperty(eq, property, aPC); + } + + return null; + } + + /** + * select suits + * @param suit + * @param subtype + * @param property + * @param equipped + * @param merge + * @param aPC + * @return int + */ + private static String _replaceTokenArmorSuit(int suit, String subtype, String property, int equipped, int merge, PlayerCharacter aPC) + { + final List aArrayList = aPC.getEquipmentOfTypeInOutputOrder("Suit", subtype, equipped, merge); + + // + // Temporary hack until someone gets around to fixing it properly + // + //aArrayList.addAll(aPC.getEquipmentOfTypeInOutputOrder("Shirt", subtype, equipped)); + + if (suit < aArrayList.size()) + { + final Equipment eq = (Equipment) aArrayList.get(suit); + return _writeArmorProperty(eq, property, aPC); + } + + return null; + } + + /** + * select various stuff, that improves AC + * @param index + * @param type + * @param subtype + * @param property + * @param equipped + * @param merge + * @param aPC + * @return int + */ + private static String _replaceTokenArmorVarious(int index, String type, String subtype, String property, int equipped, + int merge, PlayerCharacter aPC) + { + Equipment eq; + final List aArrayList = new ArrayList(); + + for (Iterator mapIter = aPC.getEquipmentOfTypeInOutputOrder(type, subtype, equipped, merge).iterator(); + mapIter.hasNext();) + { + eq = (Equipment) mapIter.next(); + + if (eq.getACMod(aPC).intValue() > 0) + { + aArrayList.add(eq); + } + else if (eq.getBonusListString("AC")) + { + aArrayList.add(eq); + } + } + + if (index < aArrayList.size()) + { + eq = (Equipment) aArrayList.get(index); + return _writeArmorProperty(eq, property, aPC); + } + + return null; + } + + private static String _writeArmorProperty(Equipment eq, String property, PlayerCharacter aPC) + { + String retString = ""; + + if (property.startsWith("NAME")) + { + if (eq.isEquipped()) + { + retString = retString + "*"; + } + + //retString = retString + eq.getName(); + retString = retString + eq.parseOutputName(eq.getOutputName(), aPC); + retString = retString + eq.getAppliedName(); + } + else if (property.startsWith("OUTPUTNAME")) + { + if (eq.isEquipped()) + { + retString = retString + "*"; + } + + retString = retString + eq.parseOutputName(eq.getOutputName(), aPC); + retString = retString + eq.getAppliedName(); + } + else if (property.startsWith("TOTALAC")) + { + // adjustments for new equipment modifier + // EQMARMOR|AC|x|TYPE=ENHANCEMENT changed to COMBAT|AC|x|TYPE=Armor.ENHANCEMENT + //FileAccess.write(output, Delta.toString(eq.getACMod())); + retString = retString + Delta.toString((int) eq.bonusTo(aPC, "COMBAT", "AC", true)); + } + else if (property.startsWith("BASEAC")) + { + // adjustments for new equipment modifier + // EQMARMOR|AC|x|TYPE=ENHANCEMENT changed to COMBAT|AC|x|TYPE=Armor.ENHANCEMENT + //FileAccess.write(output, Delta.toString(eq.getACMod())); + retString = retString + Delta.toString((int) eq.bonusTo("COMBAT", "AC", aPC, aPC)); + } + else if (property.startsWith("ACBONUS")) + { + retString = retString + Delta.toString((int) eq.bonusTo(aPC, "COMBAT", "AC", true)); + } + else if (property.startsWith("MAXDEX")) + { + final int iMax = eq.getMaxDex(aPC).intValue(); + + if (iMax != Constants.MAX_MAXDEX) + { + retString = retString + Delta.toString(iMax); + } + } + else if (property.startsWith("ACCHECK")) + { + retString = retString + Delta.toString(eq.acCheck(aPC)); + } + else if (property.startsWith("EDR")) + { + retString = retString + Delta.toString(eq.eDR(aPC)); + } + else if (property.startsWith("ISTYPE")) + { + if (eq.isType(property.substring(property.indexOf(".") + 1))) { + retString = retString + "TRUE"; + } else { + retString = retString + "FALSE"; + } + } + else if (property.startsWith("SPELLFAIL")) + { + retString = retString + eq.spellFailure(aPC).toString(); + } + else if (property.startsWith("MOVE")) + { + final StringTokenizer aTok = new StringTokenizer(eq.moveString(), ",", false); + String tempString = ""; + + if (("M".equals(aPC.getSize()) || "S".equals(aPC.getSize())) && (aTok.countTokens() > 0)) + { + tempString = aTok.nextToken(); + + if ("S".equals(aPC.getSize()) && (aTok.countTokens() > 1)) + { + tempString = aTok.nextToken(); + } + } + + retString = retString + tempString; + } + else if (property.startsWith("SPROP")) + { + retString = retString + eq.getSpecialProperties(aPC); + } + else if (property.startsWith("TYPE")) + { + String typeString = ""; + + if (eq.isLight()) + { + typeString = "Light"; + } + else if (eq.isMedium()) + { + typeString = "Medium"; + } + else if (eq.isHeavy()) + { + typeString = "Heavy"; + } + else if (eq.isShield()) + { + typeString = "Shield"; + } + else if (eq.isExtra()) + { + typeString = "Extra"; + } + + retString = retString + typeString; + } + else if (property.startsWith("WT")) + { + retString = retString + BigDecimalHelper.trimZeros(eq.getWeight(aPC).toString()); + } + return retString; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2006-06-17 11:59:00
|
Revision: 1075 Author: jdempsey Date: 2006-06-17 04:58:44 -0700 (Sat, 17 Jun 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=1075&view=rev Log Message: ----------- Fix for bug #1283149 - create FollowerToken - Copy revision 1074 from 5.10.x branch to trunk ViewCVS Links: ------------- http://svn.sourceforge.net/pcgen/?rev=1074&view=rev Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerListToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerTypeToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-06-17 11:44:04 UTC (rev 1074) +++ Trunk/pcgen/code/pluginbuild.xml 2006-06-17 11:58:44 UTC (rev 1075) @@ -373,6 +373,20 @@ </patternset> </fileset> </jar> + <jar jarfile="${outputplugins.dir}/ExportToken-FOLLOWERLIST.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/FollowerListToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${outputplugins.dir}/ExportToken-FOLLOWER.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/FollowerToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${outputplugins.dir}/ExportToken-FOLLOWEROF.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -380,6 +394,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${outputplugins.dir}/ExportToken-FOLLOWERTYPE.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/FollowerTypeToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${outputplugins.dir}/ExportToken-GENDER.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-06-17 11:44:04 UTC (rev 1074) +++ Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-06-17 11:58:44 UTC (rev 1075) @@ -2281,12 +2281,6 @@ } } - //TODO:DJ: Create pcgen.io.exportTokens.FollowerToken - else if (aString.startsWith("FOLLOWER")) - { - replaceTokenFollowers(aString, output, aPC); - } - else { len = aString.trim().length(); @@ -2403,6 +2397,19 @@ converted.append(aString.substring(5)); } } + else if (aString.startsWith("FOLLOWER") + && !aString.startsWith("FOLLOWERLIST") + && !aString.startsWith("FOLLOWEROF") + && !aString.startsWith("FOLLOWERTYPE")) + { + if ((aString.length() > 8) && (aString.charAt(8) != '.') + && (aString.charAt(8) != '(')) + { + converted.append(aString.substring(0, 8)); + converted.append('.'); + converted.append(aString.substring(8)); + } + } if (converted.length() > 0) @@ -2414,207 +2421,6 @@ return aString; } - private void replaceTokenFollowers(String aString, BufferedWriter output, PlayerCharacter aPC) - { - /* syndaryl 24/07/2002 12:51PM: kitbashed an output format for followers, much like the FEATLIST tag */ - /* Will also need to cover COUNT[FOLLOWERS], not done yet. */ - final List followers = aPC.getFollowerList(); - - if (!followers.isEmpty()) - { /* if it's empty, do nothing */ - - if ("FOLLOWERLIST".equals(aString)) - { - int i; - boolean lastflag = false; - - for (i = 0; i < followers.size(); ++i) - { - if (followers.get(i) instanceof Follower) - { - Follower aF = (Follower) followers.get(i); - - for (Iterator p = Globals.getPCList().iterator(); p.hasNext();) - { - PlayerCharacter nPC = (PlayerCharacter) p.next(); - - if (aF.getFileName().equals(nPC.getFileName())) - { - if (lastflag) - { - FileAccess.write(output, ", "); - } - - FileAccess.encodeWrite(output, nPC.getName()); - lastflag = true; - } - } - } - } - } - else if (aString.startsWith("FOLLOWERTYPE.")) - { - // Handle FOLLOWERTYPE.<type>x.subtag stuff - // New token syntax FOLLOWERTYPE.<type>.x instead of FOLLOWERTYPE.<type>x - StringTokenizer aTok = new StringTokenizer(aString, "."); - aTok.nextToken(); // FOLLOWERTYPE - - String typeString = aTok.nextToken(); - String restString = ""; - int followerIndex = -1; - - if (aTok.hasMoreTokens()) - { - restString = aTok.nextToken(); - - // When removing old token syntax, remove the catch code - try - { - followerIndex = Integer.parseInt(restString); - restString = ""; - } - catch (NumberFormatException exc) - { - // Error, not debug. We want users to report - // use of the deprecated syntax so we can fix - // them as they are found. - Logging.errorPrint("Old syntax FOLLOWERTYPEx will be replaced for FOLLOWERTYPE.x"); - - int numCharToRemove = 0; - - for (int i = typeString.length() - 1; i > 0; i--) - { - if ((typeString.charAt(i) >= '0') && (typeString.charAt(i) <= '9')) - { - followerIndex = Integer.parseInt(typeString.substring(i)); - numCharToRemove++; - } - else - { - i = 0; - } - } - - if (numCharToRemove > 0) - { - typeString = typeString.substring(0, typeString.length() - numCharToRemove); - } - } - - while (aTok.hasMoreTokens()) - { - restString = restString + "." + aTok.nextToken(); - } - - if (restString.indexOf(".") == 0) - { - restString = restString.substring(1); - } - } - - List aList = new ArrayList(); - - for (int i = followers.size() - 1; i >= 0; --i) - { - final Follower fol = (Follower) followers.get(i); - - if (fol.getType().equalsIgnoreCase(typeString)) - { - aList.add(fol); - } - } - - if (followerIndex < aList.size()) - { - if (aList.get(followerIndex) instanceof Follower) - { - final Follower aF = (Follower) aList.get(followerIndex); - PlayerCharacter newPC; - - for (Iterator p = Globals.getPCList().iterator(); p.hasNext();) - { - PlayerCharacter nPC = (PlayerCharacter) p.next(); - - if (aF.getFileName().equals(nPC.getFileName())) - { - newPC = nPC; - - if (restString.equals("")) - { - restString = "NAME"; - } - - nPC = aPC; - aPC = newPC; - Globals.setCurrentPC(aPC); - replaceToken(restString, output, aPC); - aPC = nPC; - Globals.setCurrentPC(aPC); - } - } - } - } - } - else - { - /* FOLLOWER%.subtag stuff handled in here*/ - - // New token syntax FOLLOWER.x instead of FOLLOWERx - StringTokenizer aTok = new StringTokenizer(aString, "."); - String fString = aTok.nextToken(); // FOLLOWER - final int i; - - if ("FOLLOWER".equals(fString)) - { - i = Integer.parseInt(aTok.nextToken()); - } - else - { - Logging.errorPrint("Old syntax FOLLOWERx will be replaced for FOLLOWER.x"); - - i = Integer.parseInt(aString.substring(8, aString.indexOf('.'))); - } - - if (i < followers.size()) - { - if (followers.get(i) instanceof Follower) - { - final Follower aF = (Follower) followers.get(i); - PlayerCharacter newPC; - - for (Iterator p = Globals.getPCList().iterator(); p.hasNext();) - { - PlayerCharacter nPC = (PlayerCharacter) p.next(); - - if (aF.getFileName().equals(nPC.getFileName())) - { - newPC = nPC; - - String aLabel; - - if (aTok.hasMoreTokens()) - { - aLabel = aTok.nextToken(); - } - else - { - aLabel = "NAME"; - } - - nPC = aPC; - aPC = newPC; - Globals.setCurrentPC(aPC); - replaceToken(aLabel, output, aPC); - aPC = nPC; - Globals.setCurrentPC(aPC); - } - } - } - } - } - } - } - private void replaceTokenForDfor(String aString, BufferedWriter output, PlayerCharacter aPC) { int x = 0; Added: Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerListToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerListToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerListToken.java 2006-06-17 11:58:44 UTC (rev 1075) @@ -0,0 +1,107 @@ +/* + * FollowerOfToken.java + * Copyright 2006 (C) James Dempsey <jde...@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 + * + * Created on Jun 17, 2006 + * + * $Id: InfoKnownSpells.java 1030 2006-05-26 08:25:10Z jdempsey $ + * + */ +package plugin.exporttokens; + +import java.util.Iterator; +import java.util.List; + +import pcgen.core.Globals; +import pcgen.core.PlayerCharacter; +import pcgen.core.character.Follower; +import pcgen.io.ExportHandler; +import pcgen.io.FileAccess; +import pcgen.io.exporttoken.Token; + +/** + * Deal with FOLLOWERLIST Token + * + * + * Last Editor: $Author: jdempsey $ + * Last Edited: $Date: 2006-05-26 18:25:10 +1000 (Fri, 26 May 2006) $ + * + * @author James Dempsey <jde...@us...> + * @version $Revision: 1030 $ + */ +public class FollowerListToken extends Token +{ + /** Token Name */ + public static final String TOKENNAME = "FOLLOWERLIST"; + + /** + * @see pcgen.io.exporttoken.Token#getTokenName() + */ + public String getTokenName() + { + return TOKENNAME; + } + + /** + * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) + */ + public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) + { + return getFollowerListToken(pc) + ""; + } + + /** + * Get FOLLOWERLIST Token + * + * @param pc The character to be queried + * @return The list of followers. + */ + public static String getFollowerListToken(PlayerCharacter pc) + { + StringBuffer buf = new StringBuffer(); + + int i; + boolean lastflag = false; + + final List followers = pc.getFollowerList(); + for (i = 0; i < followers.size(); ++i) + { + if (followers.get(i) instanceof Follower) + { + Follower aF = (Follower) followers.get(i); + + for (Iterator p = Globals.getPCList().iterator(); p.hasNext();) + { + PlayerCharacter nPC = (PlayerCharacter) p.next(); + + if (aF.getFileName().equals(nPC.getFileName())) + { + if (lastflag) + { + buf.append(", "); + } + + buf.append(FileAccess.filterString(nPC.getName())); + lastflag = true; + } + } + } + } + + return buf.toString(); + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerListToken.java ___________________________________________________________________ Name: keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerToken.java 2006-06-17 11:58:44 UTC (rev 1075) @@ -0,0 +1,156 @@ +/* + * FollowerToken.java + * Copyright 2006 (C) James Dempsey <jde...@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 + * + * Created on Jun 17, 2006 + * + * $Id: InfoKnownSpells.java 1030 2006-05-26 08:25:10Z jdempsey $ + * + */ +package plugin.exporttokens; + +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.StringWriter; +import java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; + +import pcgen.core.Globals; +import pcgen.core.PlayerCharacter; +import pcgen.core.character.Follower; +import pcgen.io.ExportHandler; +import pcgen.io.exporttoken.Token; +import pcgen.util.Logging; + +/** + * Deal with FOLLOWER Token + * + * + * Last Editor: $Author: jdempsey $ + * Last Edited: $Date: 2006-05-26 18:25:10 +1000 (Fri, 26 May 2006) $ + * + * @author James Dempsey <jde...@us...> + * @version $Revision: 1030 $ + */ +public class FollowerToken extends Token +{ + /** Token Name */ + public static final String TOKENNAME = "FOLLOWER"; + + /** + * @see pcgen.io.exporttoken.Token#getTokenName() + */ + public String getTokenName() + { + return TOKENNAME; + } + + /** + * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) + */ + public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) + { + /* FOLLOWER%.subtag stuff handled in here*/ + + // New token syntax FOLLOWER.x instead of FOLLOWERx + StringTokenizer aTok = new StringTokenizer(tokenSource, "."); + String fString = aTok.nextToken(); // FOLLOWER + final int i; + + if ("FOLLOWER".equals(fString)) + { + i = Integer.parseInt(aTok.nextToken()); + } + else + { + Logging.errorPrint("Old syntax FOLLOWERx will be replaced for FOLLOWER.x"); + + i = Integer.parseInt(tokenSource.substring(8, tokenSource.indexOf('.'))); + } + + String restString = ""; + while (aTok.hasMoreTokens()) + { + restString = restString + "." + aTok.nextToken(); + } + if (restString.indexOf(".") == 0) + { + restString = restString.substring(1); + } + + String result = ""; + final List followers = pc.getFollowerList(); + if (i < followers.size()) + { + if (followers.get(i) instanceof Follower) + { + final Follower aF = (Follower) followers.get(i); + result = FollowerToken.getFollowerOutput(pc, eh, restString, aF); + } + } + + return result; + } + + /** + * Process a token for a follower (must already be loaded) and return the output. + * + * @param pc The character being processed. + * @param eh The ExportHandler being used for output. + * @param followerToken The token to be processed. + * @param follower The follower to be reported upon. + * @return The follower's token output + */ + public static String getFollowerOutput(PlayerCharacter pc, ExportHandler eh, String followerToken, final Follower follower) + { + StringWriter writer = new StringWriter(); + BufferedWriter bw = new BufferedWriter(writer); + PlayerCharacter newPC; + for (Iterator p = Globals.getPCList().iterator(); p.hasNext();) + { + PlayerCharacter nPC = (PlayerCharacter) p.next(); + + if (follower.getFileName().equals(nPC.getFileName())) + { + newPC = nPC; + + if (followerToken.equals("")) + { + followerToken = "NAME"; + } + + nPC = pc; + pc = newPC; + Globals.setCurrentPC(pc); + eh.replaceToken(followerToken, bw, pc); + pc = nPC; + Globals.setCurrentPC(pc); + } + } + try + { + bw.flush(); + } + catch (IOException e) + { + Logging.errorPrint("Ignoring error while processing FOLLOWER or FOLLOWERTYPE token", e); + } + return writer.toString(); + } + +} Property changes on: Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerToken.java ___________________________________________________________________ Name: keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerTypeToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerTypeToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerTypeToken.java 2006-06-17 11:58:44 UTC (rev 1075) @@ -0,0 +1,158 @@ +/* + * FollowerTypeToken.java + * Copyright 2006 (C) James Dempsey <jde...@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 + * + * Created on Jun 17, 2006 + * + * $Id: InfoKnownSpells.java 1030 2006-05-26 08:25:10Z jdempsey $ + * + */ +package plugin.exporttokens; + +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import pcgen.core.PlayerCharacter; +import pcgen.core.character.Follower; +import pcgen.io.ExportHandler; +import pcgen.io.exporttoken.Token; +import pcgen.util.Logging; + +/** + * Deal with FOLLOWERTYPE Token + * + * + * Last Editor: $Author: jdempsey $ + * Last Edited: $Date: 2006-05-26 18:25:10 +1000 (Fri, 26 May 2006) $ + * + * @author James Dempsey <jde...@us...> + * @version $Revision: 1030 $ + */ +public class FollowerTypeToken extends Token +{ + /** Token Name */ + public static final String TOKENNAME = "FOLLOWERTYPE"; + + /** + * @see pcgen.io.exporttoken.Token#getTokenName() + */ + public String getTokenName() + { + return TOKENNAME; + } + + /** + * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) + */ + public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) + { + // Handle FOLLOWERTYPE.<type>x.subtag stuff + // New token syntax FOLLOWERTYPE.<type>.x instead of FOLLOWERTYPE.<type>x + StringTokenizer aTok = new StringTokenizer(tokenSource, "."); + aTok.nextToken(); // FOLLOWERTYPE + + String typeString = aTok.nextToken(); + String restString = ""; + int followerIndex = -1; + + if (aTok.hasMoreTokens()) + { + restString = aTok.nextToken(); + + // When removing old token syntax, remove the catch code + try + { + followerIndex = Integer.parseInt(restString); + restString = ""; + } + catch (NumberFormatException exc) + { + // Error, not debug. We want users to report + // use of the deprecated syntax so we can fix + // them as they are found. + Logging.errorPrint("Old syntax FOLLOWERTYPEx will be replaced for FOLLOWERTYPE.x"); + + int numCharToRemove = 0; + + for (int i = typeString.length() - 1; i > 0; i--) + { + if ((typeString.charAt(i) >= '0') && (typeString.charAt(i) <= '9')) + { + followerIndex = Integer.parseInt(typeString.substring(i)); + numCharToRemove++; + } + else + { + i = 0; + } + } + + if (numCharToRemove > 0) + { + typeString = typeString.substring(0, typeString.length() - numCharToRemove); + } + } + + while (aTok.hasMoreTokens()) + { + restString = restString + "." + aTok.nextToken(); + } + + if (restString.indexOf(".") == 0) + { + restString = restString.substring(1); + } + } + + String result = ""; + List aList = getFollowersOfType(pc, typeString); + if (followerIndex < aList.size()) + { + if (aList.get(followerIndex) instanceof Follower) + { + final Follower aF = (Follower) aList.get(followerIndex); + result = FollowerToken.getFollowerOutput(pc, eh, restString, aF); + } + } + + return result; + } + + /** + * Retrieve a list of followers of the desired type. + * + * @param pc The targte character + * @param typeString The follower type being looked for + * @return The list of qualifying followers. + */ + private List getFollowersOfType(PlayerCharacter pc, String typeString) + { + List aList = new ArrayList(); + final List followers = pc.getFollowerList(); + for (int i = followers.size() - 1; i >= 0; --i) + { + final Follower fol = (Follower) followers.get(i); + + if (fol.getType().equalsIgnoreCase(typeString)) + { + aList.add(fol); + } + } + return aList; + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/exporttokens/FollowerTypeToken.java ___________________________________________________________________ Name: keywords + "Author Revision Date Id" Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <boo...@us...> - 2006-07-14 01:29:12
|
Revision: 1198 Author: boomer70 Date: 2006-07-13 18:28:55 -0700 (Thu, 13 Jul 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=1198&view=rev Log Message: ----------- Part 3 of FREQ [ 1484380 ] [SPEC] Companion Mod Enhancements implemented. 1. Global FOLLOWERS tag implemented 2. BONUS:FOLLOWERS tag implemented 3. GUI changed to display and use the max companions of each type. Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/Globals.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/gui/editor/EditorMainForm.java Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoResources.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/resources/SelectedFollowerModel.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-07-13 22:54:39 UTC (rev 1197) +++ Trunk/pcgen/code/pluginbuild.xml 2006-07-14 01:28:55 UTC (rev 1198) @@ -981,6 +981,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${bonusplugins.dir}/BonusToken-FOLLOWERS.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/bonustokens/Followers.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${bonusplugins.dir}/BonusToken-HD.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -1876,6 +1883,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/LstToken-FOLLOWERS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/FollowersLst.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${lstplugins.dir}/LstToken-HITDIE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/core/Globals.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2006-07-13 22:54:39 UTC (rev 1197) +++ Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2006-07-14 01:28:55 UTC (rev 1198) @@ -109,29 +109,30 @@ private static CategorisableStore abilityStore = new CategorisableStore(); /** we need maps for efficient lookups */ - private static Map<String, Campaign> campaignMap = new HashMap<String, Campaign>(); - private static Map<String, Domain> domainMap = new TreeMap<String, Domain>(); - private static SortedMap<String, Race> raceMap = new TreeMap<String, Race>(); - private static Map<String, Object> spellMap = new TreeMap<String, Object>(); - private static Map<String, String> eqSlotMap = new HashMap<String, String>(); - private static Map<String, String> visionMap = new HashMap<String, String>(); + private static Map<String, Campaign> campaignMap = new HashMap<String, Campaign>(); + private static Map<String, Domain> domainMap = new TreeMap<String, Domain>(); + private static SortedMap<String, Race> raceMap = new TreeMap<String, Race>(); + private static Map<String, Object> spellMap = new TreeMap<String, Object>(); + private static Map<String, String> eqSlotMap = new HashMap<String, String>(); + private static Map<String, String> visionMap = new HashMap<String, String>(); + private static Map<String, List<CompanionMod>> companionModMap = new TreeMap<String, List<CompanionMod>>(); /** We use lists for efficient iteration */ - private static List<String> armorProfList = new ArrayList<String>(); - private static List<Campaign> campaignList = new ArrayList<Campaign>(85); - private static List<PCClass> classList = new ArrayList<PCClass>(380); - private static List<CompanionMod> companionModList = new ArrayList<CompanionMod>(); - private static List<Deity> deityList = new ArrayList<Deity>(275); - private static List<Domain> domainList = new ArrayList<Domain>(100); - private static List<Kit> kitList = new ArrayList<Kit>(); - private static List<Language> languageList = new ArrayList<Language>(200); + private static List<String> armorProfList = new ArrayList<String>(); + private static List<Campaign> campaignList = new ArrayList<Campaign>(85); + private static List<PCClass> classList = new ArrayList<PCClass>(380); +// private static List<CompanionMod> companionModList = new ArrayList<CompanionMod>(); + private static List<Deity> deityList = new ArrayList<Deity>(275); + private static List<Domain> domainList = new ArrayList<Domain>(100); + private static List<Kit> kitList = new ArrayList<Kit>(); + private static List<Language> languageList = new ArrayList<Language>(200); //any TYPE added to pcClassTypeList is assumed be pre-tokenized - private static List<String> pcClassTypeList = new ArrayList<String>(); - private static List<Skill> skillList = new ArrayList<Skill>(400); - private static List<PCTemplate> templateList = new ArrayList<PCTemplate>(350); - private static DenominationList denomList = DenominationList.getInstance(); // derived from ArrayList - private static SortedSet<SpecialAbility> saSet = new TreeSet<SpecialAbility>(); + private static List<String> pcClassTypeList = new ArrayList<String>(); + private static List<Skill> skillList = new ArrayList<Skill>(400); + private static List<PCTemplate> templateList = new ArrayList<PCTemplate>(350); + private static DenominationList denomList = DenominationList.getInstance(); // derived from ArrayList + private static SortedSet<SpecialAbility> saSet = new TreeSet<SpecialAbility>(); private static Map<String, Map<String, String>> sponsors = new HashMap<String, Map<String, String>>(); private static List<Map<String, String>> sponsorList = new ArrayList<Map<String, String>>(); @@ -471,6 +472,49 @@ return getPObjectsOfType(getClassList(), aType); } + public static void addCompanionMod( final CompanionMod aMod ) + { + List<CompanionMod> mods = companionModMap.get( aMod.getType() ); + if ( mods == null ) + { + mods = new ArrayList<CompanionMod>(); + companionModMap.put( aMod.getType(), mods ); + } + mods.add( aMod ); + } + + public static void removeCompanionMod( final CompanionMod aMod ) + { + final Collection<List<CompanionMod>> allMods = companionModMap.values(); + for ( Iterator<List<CompanionMod>> i = allMods.iterator(); i.hasNext(); ) + { + final List<CompanionMod> mods = i.next(); + final boolean removed = mods.remove( aMod ); + if ( removed ) + { + if ( mods.size() == 0 ) + { + i.remove(); + return; + } + } + } + } + + public static Collection<String> getFollowerTypes() + { + return Collections.unmodifiableSet( companionModMap.keySet() ); + } + + public static Collection<CompanionMod> getCompanionMods( final String aType ) + { + final List<CompanionMod> cMods = companionModMap.get( aType ); + if ( cMods == null ) + { + return Collections.emptyList(); + } + return Collections.unmodifiableList( companionModMap.get( aType ) ); + } /** * Get companion modifier * @param aString @@ -486,7 +530,7 @@ StringTokenizer aTok = new StringTokenizer(aString.substring(9), "=", false); final String classes = aTok.nextToken(); final int level = Integer.parseInt(aTok.nextToken()); - for ( CompanionMod cMod : getCompanionModList() ) + for ( CompanionMod cMod : getAllCompanionMods() ) { aTok = new StringTokenizer(classes, ",", false); @@ -508,9 +552,15 @@ * Get companion mod list * @return companion mod list */ - public static List<CompanionMod> getCompanionModList() + public static Collection<CompanionMod> getAllCompanionMods() { - return companionModList; + final List<CompanionMod> ret = new ArrayList<CompanionMod>(); + final Collection<List<CompanionMod>> values = companionModMap.values(); + for ( List<CompanionMod> cMods : values ) + { + ret.addAll( cMods ); + } + return Collections.unmodifiableCollection( ret ); } /** @@ -2224,7 +2274,7 @@ abilityStore = new CategorisableStore(); armorProfList = new ArrayList<String>(); classList = new ArrayList<PCClass>(); - companionModList = new ArrayList<CompanionMod>(); + companionModMap = new TreeMap<String, List<CompanionMod>>(); deityList = new ArrayList<Deity>(); domainList = new ArrayList<Domain>(); EquipmentList.clearEquipmentMap(); Modified: Trunk/pcgen/code/src/java/pcgen/core/PObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2006-07-13 22:54:39 UTC (rev 1197) +++ Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2006-07-14 01:28:55 UTC (rev 1198) @@ -73,8 +73,6 @@ // TODO Contains strings or FeatMultipleObjects protected ArrayList<AssociatedChoice<String>> associatedList = null; - /** List of Bonuses for the object */ - private ArrayList<BonusObj> bonusList = new ArrayList<BonusObj>(); /** List of Level Abilities for the object */ private ArrayList<LevelAbility> levelAbilityList = null; @@ -98,6 +96,9 @@ /** Map of the bonuses for the object */ private HashMap<String, String> bonusMap = null; + /** List of Bonuses for the object */ + private ArrayList<BonusObj> bonusList = new ArrayList<BonusObj>(); + private HashMap<String, String> changeProfMap = new HashMap<String, String>(); private Movement movement; @@ -121,6 +122,9 @@ private String chooseLanguageAutos = ""; + /** Number of followers of each type allowed */ + private Map<String, List<String>> followerNumbers = new HashMap<String, List<String>>(); + /* ************ * Methods * ************/ @@ -1593,6 +1597,7 @@ retVal.levelAbilityList.add(ab); } } + retVal.followerNumbers = new HashMap<String,List<String>>(followerNumbers); return retVal; } @@ -1607,6 +1612,27 @@ return 1; } + public boolean equals( final Object obj ) + { + if ( obj == null ) + { + return false; + } + final String thisKey; + final String otherKey; + if ( obj instanceof PObject ) + { + thisKey = getKeyName(); + otherKey = ((PObject)obj).getKeyName(); + } + else + { + thisKey = toString(); + otherKey = obj.toString(); + } + return thisKey.equalsIgnoreCase( otherKey ); + } + /** * Set's all the BonusObj's to this creator */ @@ -4594,6 +4620,34 @@ * End methods for the KeyedListContainer Interface * ************************************************/ + /** + * Adds a formula to use to calculate the maximum number of followers of a + * given type for the character. + * @param aType Name of the follower type e.g. Familiar + * @param aFormula Formula, variable or number represent the max number + */ + public void setNumFollowers( final String aType, final String aFormula) + { + List<String> numFollowers = followerNumbers.get( aType ); + if ( numFollowers == null ) + { + numFollowers = new ArrayList<String>(); + followerNumbers.put( aType.toUpperCase(), numFollowers ); + } + + numFollowers.add( aFormula ); + } + + public List<String> getNumFollowers( final String aType ) + { + final List<String> formulas = followerNumbers.get( aType.toUpperCase() ); + if ( formulas == null ) + { + return null; + } + return Collections.unmodifiableList( formulas ); + } + // public void addSpellLikeAbilities( final int aLevel, final List<SpellLikeAbility> aList ) // { // Prerequisite minLevel = null; Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2006-07-13 22:54:39 UTC (rev 1197) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2006-07-14 01:28:55 UTC (rev 1198) @@ -846,18 +846,17 @@ final String rType = aF.getType().toUpperCase(); final String rName = aF.getRace().toUpperCase(); - for (Iterator<CompanionMod> cm = Globals.getCompanionModList().iterator(); cm.hasNext();) + for ( CompanionMod cm : Globals.getCompanionMods( rType ) ) { - final CompanionMod aComp = cm.next(); - final String aType = aComp.getType().toUpperCase(); - final int iRace = aComp.getLevel(rName); + final String aType = cm.getType().toUpperCase(); + final int iRace = cm.getLevel(rName); if (aType.equals(rType) && (iRace == 1)) { // Found race and type of follower // so add bonus to the master - companionModList.add(aComp); - aComp.activateBonuses(aPC); + companionModList.add(cm); + cm.activateBonuses(aPC); } } } @@ -1973,18 +1972,10 @@ final PCClass mClass = c.next(); boolean found = false; - for (Iterator<CompanionMod> cm = Globals.getCompanionModList().iterator(); cm.hasNext();) + for ( CompanionMod cMod : Globals.getCompanionMods( aM.getType() ) ) { - final CompanionMod aComp = cm.next(); - final String aType = aComp.getType().toUpperCase(); - - if (!(aType.equalsIgnoreCase(aM.getType()))) + if ((cMod.getLevel(mClass.getKeyName()) > 0) && !found) { - continue; - } - - if ((aComp.getLevel(mClass.getKeyName()) > 0) && !found) - { mTotalLevel += mClass.getLevel(); found = true; } @@ -1994,23 +1985,14 @@ // Clear the companionModList so we can add everything to it companionModList.clear(); - // New way of doing this. Through VARs on the Master - for (Iterator<CompanionMod> cm = Globals.getCompanionModList().iterator(); cm.hasNext();) + for ( CompanionMod cMod : Globals.getCompanionMods( aM.getType() ) ) { - final CompanionMod aComp = cm.next(); - final String aType = aComp.getType().toUpperCase(); - - if (!(aType.equalsIgnoreCase(aM.getType()))) - { - continue; - } - // Check all the masters classes for (Iterator<PCClass> c = mPC.getClassList().iterator(); c.hasNext();) { final PCClass mClass = c.next(); final int mLev = mClass.getLevel(); - final int compLev = aComp.getLevel(mClass.getKeyName()); + final int compLev = cMod.getLevel(mClass.getKeyName()); if (compLev < 0) { @@ -2021,25 +2003,25 @@ // and for the correct level or lower if ((compLev <= mLev) || (compLev <= mTotalLevel)) { - if ( PrereqHandler.passesAll( aComp.getPreReqList(), this, aComp ) ) + if ( PrereqHandler.passesAll( cMod.getPreReqList(), this, cMod ) ) // if (!companionModList.contains(aComp)) { - companionModList.add(aComp); - addHD += aComp.getHitDie(); + companionModList.add(cMod); + addHD += cMod.getHitDie(); } } } - for (Iterator<String> iType = aComp.getVarMap().keySet().iterator(); iType.hasNext();) + for (Iterator<String> iType = cMod.getVarMap().keySet().iterator(); iType.hasNext();) { final String varName = iType.next(); - if (mPC.getVariableValue(varName, "").intValue() >= aComp.getLevel(varName)) + if (mPC.getVariableValue(varName, "").intValue() >= cMod.getLevel(varName)) { - if ( PrereqHandler.passesAll( aComp.getPreReqList(), this, aComp ) ) + if ( PrereqHandler.passesAll( cMod.getPreReqList(), this, cMod ) ) // if (!companionModList.contains(aComp)) { - companionModList.add(aComp); - addHD += aComp.getHitDie(); + companionModList.add(cMod); + addHD += cMod.getHitDie(); } } } @@ -2138,6 +2120,65 @@ setDirty(true); } + public int getMaxFollowers( final String aType ) + { + int ret = -1; + + List<? extends PObject> pobjList = getPObjectList(); + for ( PObject pobj : pobjList ) + { + if ( pobj == null ) + { + continue; + } + + final List<String> formulas = pobj.getNumFollowers( aType ); + if ( formulas == null ) + { + continue; + } + for ( String formula : formulas ) + { + final int val = this.getVariableValue( formula, "", this ).intValue(); + ret = Math.max( ret, val ); + } + } + + if ( ret != -1 ) + { + ret += this.getTotalBonusTo("FOLLOWERS", aType.toUpperCase()); + } + else + { + // Old way of handling this + // If the character qualifies for any companion mod of this type + // they can take unlimited number of them. + for ( CompanionMod cMod : Globals.getCompanionMods( aType ) ) + { + for ( String varName : cMod.getVarMap().keySet() ) + { + if ( this.getVariableValue(varName, "").intValue() > 0 ) + { + return -1; + } + } + for ( String key : cMod.getClassMap().keySet() ) + { + for ( PCClass pcClass : getClassList() ) + { + if ( pcClass.getKeyName().equals( key ) ) + { + return -1; + } + } + } + } + + return 0; + } + return ret; + } + /** * Get the Follower object that is the "master" for this object * @return follower master Modified: Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2006-07-13 22:54:39 UTC (rev 1197) +++ Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2006-07-14 01:28:55 UTC (rev 1198) @@ -2104,7 +2104,7 @@ addVariables(availableList, Globals.getSkillList()); addVariables(availableList, EquipmentList.getModifierList()); addVariables(availableList, Globals.getTemplateList()); - addVariables(availableList, Globals.getCompanionModList()); + addVariables(availableList, Globals.getAllCompanionMods()); Collections.sort(availableList); pnlFollowers.setVariableModel(new DefaultComboBoxModel(availableList.toArray())); Modified: Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2006-07-13 22:54:39 UTC (rev 1197) +++ Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2006-07-14 01:28:55 UTC (rev 1198) @@ -15,6 +15,8 @@ in_hdLabel=HD in_typeName=Type/Name +in_typeRace=Type/Race +in_fileName=File Name in_alignmentName=Alignment/Name @@ -2867,6 +2869,7 @@ InfoSpells.can.not.metamagic=Unable to metamagic this spell +in_confirmOverwriteCaption=Confirm OverWrite InfoSpells.confirm.overwrite=The file {0} already exists, are you sure you want to overwrite it? InfoSpells.unable.to.metamagic=Unable to metamagic spells for @@ -2955,4 +2958,57 @@ EquipLocation.Contained=Contained EquipLocation.NotCarried=Not Carried -EquipLocation.Unknown=Location "{0)" unknown. +EquipLocation.Unknown=Location "{0}" unknown. + +InfoResources.AutoLoadCompanions=Auto load companions +InfoResources.ModeLabel=Select Type of Resource: +InfoResources.SortLabel=Sort +InfoResources.FilterLabel=Filter: +InfoResources.LoadMasterNotice=NOTICE: Load Master from File to display info +InfoResources.MasterInformation=Master Information +InfoResources.PCNameLabel=PC Name: +InfoResources.FileLabel=File: +InfoResources.SaveFirst=You must save the current character first +InfoResources.DestinationFirst=First select destination +InfoResources.EnterName=Please enter a name for new {0}: +InfoResources.SaveCaption=Save new {0} named: {1} +InfoResources.SaveAndSwitch=Saving {0} and switching tabs +InfoResources.UpdateFromMaster=Update from Master +InfoResources.FollowerInformation=Follower Information +InfoResources.RightClickToAdd=Right click to add +InfoResources.RightClickToRemove=Right click to remove +InfoResources.ClickToAdd=Click to add +InfoResources.ClickToRemove=Click to remove from List +InfoResources.LoadDlgPrompt=Load... +InfoResources.Information=Information +InfoResources.AddModifier=Add Modifier +InfoResources.DelModifier=Delete Modifier +InfoResources.NameLabel=Name: +InfoResources.TypeLabel=Type: +InfoResources.TotalLabel=Total +InfoResources.FlatfootedLabel=Flatfooted +InfoResources.LoadFromFile=NOTICE: Load from File to display info +InfoResources.SelectToRemove=Select the object to remove +InfoResources.ConfirmDelete=Are you sure you want to delete? +InfoResources.ConfirmRemove=Confirm Remove +InfoResources.FindFile=Find file +InfoResources.AddFollowersEtc=Add followers/cohorts, animal companions, special mounts or familiars +InfoResources.ChooseViewMode=Choose View Mode +InfoResources.SelectObjectLoad=Select the object to load +InfoResources.AlreadyLoaded={0} is already loaded +InfoResources.MovedChanged={0} has moved/changed. Please select the new .pcg filename +InfoResources.LoadAndSwitch=Loading {0} from {1} and switching tabs +InfoResources.DoneUpdating=Done updating {0} +InfoResources.AddNewToList=Add New to List +InfoResources.AddToList=Add New to List +InfoResources.FindItem=Find item +InfoResources.RemoveFromList=Remove from List +InfoResources.AddFromFile=Add from existing File +InfoResources.AddExistingFile=Add from existing File +InfoResources.NoMoreFollowers=You cannot add any more followers of the selected type. + +Errors.Save=Could not save {0} +Errors.Load=Unable to load {0} + +in_plusSign=+ +in_caretSymbol=^ Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoResources.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoResources.java 2006-07-13 22:54:39 UTC (rev 1197) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoResources.java 2006-07-14 01:28:55 UTC (rev 1198) @@ -135,10 +135,10 @@ private JButton delModButton = new JButton(); private JButton loadButton = new JButton(); private JButton updateButton = new JButton(); - private JCheckBox shouldLoadCompanion = new JCheckBox("Auto load companions"); - private final JLabel modeLabel = new JLabel("Select Type of Resource:"); + private JCheckBox shouldLoadCompanion = new JCheckBox(PropertyFactory.getString("InfoResources.AutoLoadCompanions")); //$NON-NLS-1$ + private final JLabel modeLabel = new JLabel(PropertyFactory.getString("InfoResources.ModeLabel")); //$NON-NLS-1$ private JComboBoxEx viewModeBox = new JComboBoxEx(); - private final JLabel sortLabel = new JLabel("Sort"); + private final JLabel sortLabel = new JLabel(PropertyFactory.getString("InfoResources.SortLabel")); //$NON-NLS-1$ private JComboBoxEx viewSortBox = new JComboBoxEx(); private JLabelPane followerInfo = new JLabelPane(); private JLabelPane infoLabel = new JLabelPane(); @@ -156,22 +156,42 @@ private int viewMode = 0; private int viewSortMode = 0; - private final JLabel lblQFilter = new JLabel("Filter:"); + private final JLabel lblQFilter = new JLabel(PropertyFactory.getString("InfoResources.FilterLabel")); //$NON-NLS-1$ private JTextField textQFilter = new JTextField(); - private JButton clearQFilterButton = new JButton("Clear"); + private JButton clearQFilterButton = new JButton(PropertyFactory.getString("in_mnuToolsFiltersClear")); //$NON-NLS-1$ private static Integer saveViewMode = null; PlayerCharacter pc; private int serial = 0; private boolean readyForRefresh = false; + private static final String TAB_ORDER_KEY = ".Panel.Resources.Order"; //$NON-NLS-1$ + + + private static final String HTML = "<html>"; //$NON-NLS-1$ + private static final String END_HTML = "</html>"; //$NON-NLS-1$ + private static final String FONT_PLUS_1 = "<font size=+1>"; //$NON-NLS-1$ + private static final String END_FONT = "</font>"; //$NON-NLS-1$ + private static final String PARA = "<p>"; //$NON-NLS-1$ + private static final String BOLD = "<b>"; //$NON-NLS-1$ + private static final String END_BOLD = "</b>"; //$NON-NLS-1$ + private static final String BR = "<br>"; //$NON-NLS-1$ + private static final String ITALIC = "<i>"; //$NON-NLS-1$ + private static final String END_ITALIC = "</i>"; //$NON-NLS-1$ + private static final String UL = "<ul>"; //$NON-NLS-1$ + private static final String END_UL = "</ul>"; //$NON-NLS-1$ + private static final String LI = "<li>"; //$NON-NLS-1$ + private static final String END_LI = "</li>"; //$NON-NLS-1$ + + + /** - * Constructor for the InfoEquips object - * @param pc + * Constructor for the InfoResources object + * @param aPC **/ - public InfoResources(PlayerCharacter pc) + public InfoResources(PlayerCharacter aPC) { - this.pc = pc; + this.pc = aPC; // do not remove this as we will use the component's name // to save component specific settings setName(Constants.tabNames[Constants.TAB_RESOURCES]); @@ -183,42 +203,68 @@ //FilterFactory.restoreFilterSettings(this); } - public void setPc(PlayerCharacter pc) + /** + * Sets the PlayerCharacter to display info for + * @param aPC The PlayerCharacter to display + * @see pcgen.gui.CharacterInfoTab#setPc(pcgen.core.PlayerCharacter) + */ + public void setPc(PlayerCharacter aPC) { - if(this.pc != pc || pc.getSerial() > serial) + if(this.pc != aPC || aPC.getSerial() > serial) { - this.pc = pc; - serial = pc.getSerial(); - availableModel.setCharacter(pc); - selectedModel.setCharacter(pc); + this.pc = aPC; + serial = aPC.getSerial(); + availableModel.setCharacter(aPC); + selectedModel.setCharacter(aPC); forceRefresh(); } } + /** + * Gets the currently displayed PlayerCharacter + * @return The PlayerCharacter being displayed + */ public PlayerCharacter getPc() { return pc; } + /** + * Gets an integer placement within the list of tabs to + * display this tab in. + * @return The order to display this tab in + */ public int getTabOrder() { - return SettingsHandler.getPCGenOption(".Panel.Resources.Order", Constants.TAB_RESOURCES); + return SettingsHandler.getPCGenOption(TAB_ORDER_KEY, Constants.TAB_RESOURCES); } + /** + * @param order The order to put this tab in in the list + * of tabs to display + */ public void setTabOrder(int order) { - SettingsHandler.setPCGenOption(".Panel.Resources.Order", order); + SettingsHandler.setPCGenOption(TAB_ORDER_KEY, order); } + /** + * Returns the name of this tab + * @return The tab name + */ public String getTabName() { - GameMode game = SettingsHandler.getGame(); + final GameMode game = SettingsHandler.getGame(); return game.getTabName(Constants.TAB_RESOURCES); } + /** + * This this tab visible within the GUI + * @return true if the tab will be shown + */ public boolean isShown() { - GameMode game = SettingsHandler.getGame(); + final GameMode game = SettingsHandler.getGame(); return game.getTabShown(Constants.TAB_RESOURCES); } @@ -232,6 +278,10 @@ return toDoList; } + /** + * Refresh this tab if a change to the displayed + * PlayerCharacter is detected. + */ public void refresh() { if(pc.getSerial() > serial) @@ -241,6 +291,9 @@ } } + /** + * Force this tabs data to be considered invalid. + */ public void forceRefresh() { if(readyForRefresh) @@ -254,6 +307,10 @@ } } + /** + * Returns the Component used to view this tab. + * @return The component that draws the view for this tab + */ public JComponent getView() { return this; @@ -263,6 +320,7 @@ * specifies whether the "match any" option should be available * @return true **/ + @Override public final boolean isMatchAnyEnabled() { return true; @@ -272,7 +330,7 @@ * Sets the update flag for this tab * It's a lazy update and will only occur * on other status change - * @param flag + * @param flag true to flag the tab as needing a refresh **/ public static void setNeedsUpdate(boolean flag) { @@ -283,31 +341,38 @@ * specifies whether the "negate/reverse" option should be available * @return true **/ + @Override public final boolean isNegateEnabled() { return true; } /** - * specifies the filter selection mode + * Specifies the filter selection mode * @return FilterConstants.DISABLED_MODE = -2 **/ + @Override public final int getSelectionMode() { return FilterConstants.DISABLED_MODE; } /** - * implementation of Filterable interface - **/ + * Initializes the Filters used by this tab. + * @see pcgen.gui.filter.FilterAdapterPanel#initializeFilters() + */ + @Override public final void initializeFilters() { FilterFactory.registerAllSourceFilters(this); } /** - * implementation of Filterable interface - **/ + * Called when the filtering has changed. Components should + * redraw themselves using the new filter parameters. + * @see pcgen.gui.filter.FilterAdapterPanel#refreshFiltering() + */ + @Override public final void refreshFiltering() { updateAvailableModel(); @@ -380,13 +445,13 @@ if (mPC == null) { - followerInfo.setText("NOTICE: Load Master from File to display info"); + followerInfo.setText(PropertyFactory.getString("InfoResources.LoadMasterNotice")); //$NON-NLS-1$ return; } StringBuffer b = new StringBuffer(); - b.append("<html>"); + b.append(HTML); b.append(followerStatBlock(aF, pc)); // @@ -394,22 +459,41 @@ // but first switch the "current PC" to master // so stats show up correctly // - b.append("<p>"); - b.append("<font size=+1><b>Master Information</b></font><br>"); - b.append("<b>PC Name:</b> ").append(mPC.getName()); - b.append("<br>"); - b.append("<b>File:</b> ").append(mPC.getFileName()); - b.append("<br>"); - b.append("<b>Race:</b> ").append(mPC.getRace()); - b.append("<br>"); - b.append("<b>").append(Globals.getGameModeHPAbbrev()).append("</b>: ").append(mPC.hitPoints()); - b.append("<br>"); + b.append(PARA); + b.append(FONT_PLUS_1); + b.append(BOLD); + b.append(PropertyFactory.getString("InfoResources.MasterInformation")); //$NON-NLS-1$ + b.append(END_BOLD).append(END_FONT).append(BR); + b.append(BOLD); + b.append(PropertyFactory.getString("InfoResources.PCNameLabel")); //$NON-NLS-1$ + b.append(END_BOLD).append(" "); //$NON-NLS-1$ + b.append(mPC.getName()); + b.append(BR).append(BOLD); + b.append(PropertyFactory.getString("InfoResources.FileLabel")); //$NON-NLS-1$ + b.append(END_BOLD).append(" "); //$NON-NLS-1$ + b.append(mPC.getFileName()); + b.append(BR).append(BOLD); + b.append(PropertyFactory.getString("in_sumRace")); //$NON-NLS-1$ + b.append(END_BOLD).append(" "); //$NON-NLS-1$ + b.append(mPC.getRace()); + b.append(BR).append(BOLD); + b.append(Globals.getGameModeHPAbbrev()); + b.append(END_BOLD).append(": ").append(mPC.hitPoints()); //$NON-NLS-1$ + b.append(BR); int bonus = mPC.baseAttackBonus(); - b.append("<b>BAB</b>: ").append((bonus >= 0) ? "+" : "").append(bonus); - b.append("<br>"); + b.append(BOLD); + String babAbbrev = SettingsHandler.getGame().getBabAbbrev(); + if ( babAbbrev == null ) + { + babAbbrev = "BAB"; //$NON-NLS-1$ + } + b.append(babAbbrev); + b.append(END_BOLD).append(": "); //$NON-NLS-1$ + b.append((bonus >= 0) ? PropertyFactory.getString("in_plusSign") : "").append(bonus); //$NON-NLS-1$ //$NON-NLS-2$ + b.append(BR); - b.append("</html>"); + b.append(END_HTML); followerInfo.setText(b.toString()); followerInfo.setVisible(true); @@ -419,24 +503,29 @@ private void addButton() { - if ("".equals(pc.getFileName())) + if ("".equals(pc.getFileName())) //$NON-NLS-1$ { - ShowMessageDelegate.showMessageDialog("You must save the current character first", Constants.s_APPNAME, MessageType.ERROR); + ShowMessageDelegate.showMessageDialog(PropertyFactory.getString("InfoResources.SaveFirst"), Constants.s_APPNAME, MessageType.ERROR); //$NON-NLS-1$ return; } TreePath avaCPath = availableTable.getTree().getSelectionPath(); TreePath selCPath = selectedTable.getTree().getSelectionPath(); - String target; +// String target; if (selCPath == null) { - ShowMessageDelegate.showMessageDialog("First select destination", Constants.s_APPNAME, MessageType.ERROR); + ShowMessageDelegate.showMessageDialog(PropertyFactory.getString("InfoResources.DestinationFirst"), Constants.s_APPNAME, MessageType.ERROR); //$NON-NLS-1$ return; } - target = selCPath.getPathComponent(1).toString(); + SelectedFollowerModel.FollowerType target = (SelectedFollowerModel.FollowerType)((PObjectNode)selCPath.getPathComponent(1)).getItem(); + if ( target.getNumRemaining() < 1 ) + { + ShowMessageDelegate.showMessageDialog(PropertyFactory.getString("InfoResources.NoMoreFollowers"), Constants.s_APPNAME, MessageType.ERROR); //$NON-NLS-1$ + return; + } Object endComp = avaCPath.getLastPathComponent(); PObjectNode fNode = (PObjectNode) endComp; @@ -455,10 +544,10 @@ String nName; String aType; - Logging.debugPrint("addButton:race: " + aRace.getDisplayName() + " -> " + target); + Logging.debugPrint("addButton:race: " + aRace.getDisplayName() + " -> " + target); //$NON-NLS-1$ //$NON-NLS-2$ // first ask for the name of the new object - Object nValue = JOptionPane.showInputDialog(null, "Please enter a name for new " + target + ":", + Object nValue = JOptionPane.showInputDialog(null, PropertyFactory.getFormattedString("InfoResources.EnterName", target), //$NON-NLS-1$ Constants.s_APPNAME, JOptionPane.QUESTION_MESSAGE); if (nValue != null) @@ -471,7 +560,7 @@ } JFileChooser fc = new JFileChooser(); - fc.setDialogTitle("Save new " + target + " named: " + nName); + fc.setDialogTitle(PropertyFactory.getFormattedString("InfoResources.SaveCaption", target, nName)); //$NON-NLS-1$ fc.setSelectedFile(new File(SettingsHandler.getPcgPath(), nName + Constants.s_PCGEN_CHARACTER_EXTENSION)); fc.setCurrentDirectory(SettingsHandler.getPcgPath()); @@ -489,9 +578,9 @@ if (file.exists()) { - int iConfirm = JOptionPane.showConfirmDialog(null, - "The file " + file.getName() + " already exists. Are you sure you want to overwrite it?", - "Confirm OverWrite", JOptionPane.YES_NO_OPTION); + int iConfirm = JOptionPane.showConfirmDialog(null, + PropertyFactory.getFormattedString("InfoSpells.confirm.overwrite", file.getName()), //$NON-NLS-1$ + PropertyFactory.getString("in_confirmOverwriteCaption"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$ if (iConfirm != JOptionPane.YES_OPTION) { @@ -519,7 +608,7 @@ newPC.setDirty(true); - aType = target; + aType = target.getType(); Follower newMaster = new Follower(pc.getFileName(), pc.getName(), aType); newPC.setMaster(newMaster); @@ -532,7 +621,8 @@ pc.setAggregateFeatsStable(false); pc.setVirtualFeatsStable(false); - ShowMessageDelegate.showMessageDialog("Saving " + nName + " and switching tabs", Constants.s_APPNAME, MessageType.INFORMATION); + ShowMessageDelegate.showMessageDialog(PropertyFactory.getFormattedString("InfoResources.SaveAndSwitch", nName), //$NON-NLS-1$ + Constants.s_APPNAME, MessageType.INFORMATION); // save the new Follower to a file @@ -542,8 +632,9 @@ } catch (Exception ex) { - ShowMessageDelegate.showMessageDialog("Could not save " + newPC.getDisplayName(), Constants.s_APPNAME, MessageType.ERROR); - Logging.errorPrint("Could not save " + newPC.getDisplayName(), ex); + ShowMessageDelegate.showMessageDialog(PropertyFactory.getFormattedString("Errors.Save", newPC.getDisplayName()), //$NON-NLS-1$ + Constants.s_APPNAME, MessageType.ERROR); + Logging.errorPrint(PropertyFactory.getFormattedString("Errors.Save", newPC.getDisplayName()), ex); //$NON-NLS-1$ return; } @@ -568,7 +659,7 @@ return; } - Logging.errorPrint("addButton:item: " + eqI.getName() + " -> " + target); + Logging.errorPrint("addButton:item: " + eqI.getName() + " -> " + target); //$NON-NLS-1$//$NON-NLS-2$ // reset EquipSet model to get the new equipment // added into the selectedTable tree @@ -579,9 +670,9 @@ private void addFileButton() { - if ("".equals(pc.getFileName())) + if ("".equals(pc.getFileName())) //$NON-NLS-1$ { - ShowMessageDelegate.showMessageDialog("You must save the current character first", Constants.s_APPNAME, MessageType.ERROR); + ShowMessageDelegate.showMessageDialog(PropertyFactory.getString("InfoResources.SaveFirst"), Constants.s_APPNAME, MessageType.ERROR); //$NON-NLS-1$ return; } @@ -591,7 +682,7 @@ if (selCPath == null) { - ShowMessageDelegate.showMessageDialog("First select destination", Constants.s_APPNAME, MessageType.ERROR); + ShowMessageDelegate.showMessageDialog(PropertyFactory.getString("InfoResources.DestinationFirst"), Constants.s_APPNAME, MessageType.ERROR); //$NON-NLS-1$ return; } @@ -616,7 +707,7 @@ { if (iPC.getFileName().equals(file.toString())) { - Logging.errorPrint("already open"); + Logging.errorPrint("already open"); //$NON-NLS-1$ PCGen_Frame1.getBaseTabbedPane().setSelectedIndex(newIndex); newPC = iPC; @@ -631,7 +722,7 @@ newPC = PCGen_Frame1.getInst().loadPCFromFile(file); if (newPC == null) { - Logging.errorPrint("Unable to load " + file.toString()); + Logging.errorPrint(PropertyFactory.getFormattedString("Errors.Load", file.toString())); //$NON-NLS-1$ Globals.setCurrentPC(oldPC); return; @@ -695,13 +786,13 @@ JPanel aPanel = new JPanel(); aPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 2)); - updateButton.setText("Update from Master"); + updateButton.setText(PropertyFactory.getString("InfoResources.UpdateFromMaster")); //$NON-NLS-1$ updateButton.setEnabled(true); aPanel.add(updateButton); followerPane.add(aPanel, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(followerInfo); - TitledBorder sTitle = BorderFactory.createTitledBorder("Follower Information"); + TitledBorder sTitle = BorderFactory.createTitledBorder(PropertyFactory.getString("InfoResources.FollowerInformation")); //$NON-NLS-1$ sTitle.setTitleJustification(TitledBorder.CENTER); scrollPane.setBorder(sTitle); followerInfo.setBackground(topPane.getBackground()); @@ -744,10 +835,10 @@ // the available table panel JScrollPane scrollPane = new JScrollPane(availableTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - Utility.setDescription(scrollPane, "Right click to add"); + Utility.setDescription(scrollPane, PropertyFactory.getString("InfoResources.RightClickToAdd")); //$NON-NLS-1$ JButton columnButton = new JButton(); scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, columnButton); - columnButton.setText("^"); + columnButton.setText(PropertyFactory.getString("in_caretSymbol")); //$NON-NLS-1$ new TableColumnManager(availableTable, columnButton, availableModel); leftPane.add(scrollPane, BorderLayout.CENTER); @@ -759,8 +850,8 @@ JPanel bottomLeftPane = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 1)); shouldLoadCompanion.setSelected(pc.getLoadCompanion()); bottomLeftPane.add(shouldLoadCompanion, BorderLayout.WEST); - addButton.setIcon(IconUtilitities.getImageIcon("Forward16.gif")); - Utility.setDescription(addButton, "Click to add"); + addButton.setIcon(IconUtilitities.getImageIcon("Forward16.gif")); //$NON-NLS-1$ + Utility.setDescription(addButton, PropertyFactory.getString("InfoResources.ClickToAdd")); //$NON-NLS-1$ addButton.setEnabled(false); bottomLeftPane.add(addButton); leftPane.add(bottomLeftPane, BorderLayout.SOUTH); @@ -768,20 +859,20 @@ // now build the right pane // for the selected table JScrollPane scrollPane2 = new JScrollPane(selectedTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - Utility.setDescription(scrollPane2, "Right click to remove"); + Utility.setDescription(scrollPane2, PropertyFactory.getString("InfoResources.RightClickToRemove")); //$NON-NLS-1$ JButton columnButton2 = new JButton(); scrollPane2.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, columnButton2); - columnButton2.setText("^"); + columnButton2.setText(PropertyFactory.getString("in_caretSymbol")); //$NON-NLS-1$ new TableColumnManager(selectedTable, columnButton2, selectedModel); rightPane.add(scrollPane2, BorderLayout.CENTER); JPanel bottomRightPane = new JPanel(); bottomRightPane.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 1)); - delButton.setIcon(IconUtilitities.getImageIcon("Back16.gif")); - Utility.setDescription(delButton, "Click to remove from List"); + delButton.setIcon(IconUtilitities.getImageIcon("Back16.gif")); //$NON-NLS-1$ + Utility.setDescription(delButton, PropertyFactory.getString("ClickToRemove")); //$NON-NLS-1$ delButton.setEnabled(false); bottomRightPane.add(delButton); - loadButton.setText("Load..."); + loadButton.setText(PropertyFactory.getString("InfoResources.LoadDlgPrompt")); //$NON-NLS-1$ loadButton.setEnabled(false); bottomRightPane.add(loadButton); rightPane.add(bottomRightPane, BorderLayout.SOUTH); @@ -807,7 +898,7 @@ botPane.add(botSplit, BorderLayout.CENTER); // Bottom left panel - TitledBorder sTitle = BorderFactory.createTitledBorder("Information"); + TitledBorder sTitle = BorderFactory.createTitledBorder(PropertyFactory.getString("InfoResources.Information")); //$NON-NLS-1$ sTitle.setTitleJustification(TitledBorder.CENTER); bLeftPane.setBorder(sTitle); infoLabel.setBackground(topPane.getBackground()); @@ -818,10 +909,10 @@ JPanel iPanel = new JPanel(); iPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); - addModButton.setText("Add Modifier"); + addModButton.setText(PropertyFactory.getString("InfoResources.AddModifier")); //$NON-NLS-1$ addModButton.setEnabled(false); iPanel.add(addModButton); - delModButton.setText("Delete Modifier"); + delModButton.setText(PropertyFactory.getString("InfoResources.DelModifier")); //$NON-NLS-1$ delModButton.setEnabled(false); iPanel.add(delModButton); bRightPane.add(iPanel); @@ -857,81 +948,99 @@ private static String followerStatBlock(Follower aF, PlayerCharacter newPC) { StringBuffer b = new StringBuffer(); - b.append("<font size=+1><b>Name:</b> "); - b.append(newPC.getName()).append("</font>"); - b.append("<br>"); - b.append("<b>Type:</b> ").append(aF.getType()); - b.append("<br>"); - b.append("<b>Race:</b> ").append(newPC.getRace()); - b.append("<br>"); + b.append(FONT_PLUS_1).append(BOLD); + b.append(PropertyFactory.getString("InfoResources.NameLabel")); //$NON-NLS-1$ + b.append(END_BOLD).append(" "); //$NON-NLS-1$ + b.append(newPC.getName()).append(END_FONT); + b.append(BR).append(BOLD); + b.append(PropertyFactory.getString("InfoResources.TypeLabel")); //$NON-NLS-1$ + b.append(END_BOLD).append(" ").append(aF.getType()); //$NON-NLS-1$ + b.append(BR).append(BOLD); + b.append(PropertyFactory.getString("in_sumRace")); //$NON-NLS-1$ + b.append(END_BOLD).append(" ").append(newPC.getRace()); //$NON-NLS-1$ + b.append(BR); for (int i = 0; i < SettingsHandler.getGame().s_ATTRIBSHORT.length; i++) { - b.append("<b>").append(SettingsHandler.getGame().s_ATTRIBSHORT[i]).append("</b>: ") - .append(newPC.getStatList().getTotalStatFor(SettingsHandler.getGame().s_ATTRIBSHORT[i])).append(" "); + b.append(BOLD).append(SettingsHandler.getGame().s_ATTRIBSHORT[i]).append(END_BOLD).append(": ") //$NON-NLS-1$ + .append(newPC.getStatList().getTotalStatFor(SettingsHandler.getGame().s_ATTRIBSHORT[i])).append(" "); //$NON-NLS-1$ } - b.append("<br>"); + b.append(BR); if (Globals.getGameModeACText().length() != 0) { - b.append("<b>").append(Globals.getGameModeACText()).append("</b> "); - b.append("<i>Total</i>: ").append(newPC.getACTotal()); - b.append(" <i>Flatfooted</i>: ").append(newPC.flatfootedAC()); - b.append(" <i>Touch</i>: ").append(newPC.touchAC()); - b.append("<br>"); + b.append(BOLD).append(Globals.getGameModeACText()).append(END_BOLD).append(" "); //$NON-NLS-1$ + b.append(ITALIC).append(PropertyFactory.getString("in_sumTotal")); //$NON-NLS-1$ + b.append(END_ITALIC).append(": ").append(newPC.getACTotal()); //$NON-NLS-1$ + b.append(" ").append(ITALIC); //$NON-NLS-1$ + b.append(PropertyFactory.getString("in_sumFlatfooted")); //$NON-NLS-1$ + b.append(END_ITALIC).append(": ").append(newPC.flatfootedAC()); //$NON-NLS-1$ + b.append(" ").append(ITALIC); //$NON-NLS-1$ + b.append(PropertyFactory.getString("in_sumTouch")); //$NON-NLS-1$ + b.append(END_ITALIC).append(": ").append(newPC.touchAC()); //$NON-NLS-1$ + b.append(BR); } else { - b.append("<b>AC</b> "); - b.append("<i>Total</i>: ").append((int) newPC.getTotalBonusTo("COMBAT", "AC")); - b.append("<br>"); + b.append(BOLD).append(PropertyFactory.getString("in_sumAC")).append(END_BOLD).append(" "); //$NON-NLS-1$//$NON-NLS-2$ + b.append(ITALIC).append(PropertyFactory.getString("in_sumTotal")).append(END_ITALIC).append(": "); //$NON-NLS-1$//$NON-NLS-2$ + b.append((int) newPC.getTotalBonusTo("COMBAT", "AC")); //$NON-NLS-1$ //$NON-NLS-2$ + b.append(BR); } final int initMod = newPC.initiativeMod(); - b.append("<b>Init</b>: ").append((initMod >= 0) ? "+" : "").append(initMod); - b.append("<br>"); + b.append(BOLD).append(PropertyFactory.getString("in_sumInit")).append(END_BOLD).append(": "); //$NON-NLS-1$//$NON-NLS-2$ + b.append((initMod >= 0) ? PropertyFactory.getString("in_plusSign") : "").append(initMod); //$NON-NLS-1$ //$NON-NLS-2$ + b.append(BR); int bonus = newPC.baseAttackBonus(); - b.append(" <b>BAB</b>: ").append((bonus >= 0) ? "+" : "").append(bonus); - b.append("<br>"); - b.append(" <b>").append(Globals.getGameModeHPAbbrev()).append("</b>: ").append(newPC.hitPoints()); + String babAbbrev = SettingsHandler.getGame().getBabAbbrev(); + if ( babAbbrev == null ) + { + babAbbrev = "BAB"; //$NON-NLS-1$ + } + b.append(BOLD).append(babAbbrev).append(END_BOLD).append(": "); //$NON-NLS-1$ //$NON-NLS-2$ + b.append((bonus >= 0) ? PropertyFactory.getString("in_plusSign") : "").append(bonus); //$NON-NLS-1$ //$NON-NLS-2$ + b.append(BR); + b.append(" ").append(BOLD).append(Globals.getGameModeHPAbbrev()).append(END_BOLD).append(": ").append(newPC.hitPoints()); //$NON-NLS-1$//$NON-NLS-2$ if (Globals.getGameModeAltHPText().length() != 0) { - b.append(" <b>").append(Globals.getGameModeAltHPAbbrev()).append("</b>: ").append(newPC.altHP()); + b.append(" ").append(BOLD).append(Globals.getGameModeAltHPAbbrev()).append(END_BOLD).append(": ").append(newPC.altHP()); //$NON-NLS-1$//$NON-NLS-2$ } - b.append("<br>"); + b.append(BR); - b.append("<b>Saves</b>: "); + b.append(BOLD).append(PropertyFactory.getString("in_sumSaves")).append(END_BOLD).append(": "); //$NON-NLS-1$ //$NON-NLS-2$ for (int z = 0; z < SettingsHandler.getGame().getUnmodifiableCheckList().size(); z++) { bonus = (int) newPC.getBonus(z + 1, true); - b.append(" <i>").append(SettingsHandler.getGame().getUnmodifiableCheckList().get(z).toString()).append("</i>: ") - .append((bonus >= 0) ? "+" : "").append(bonus); + b.append(" ").append(ITALIC).append(SettingsHandler.getGame().getUnmodifiableCheckList().get(z).toString()).append(END_ITALIC).append(": ") //$NON-NLS-1$ //$NON-NLS-2$ + .append((bonus >= 0) ? PropertyFactory.getString("in_plusSign") : "").append(bonus); //$NON-NLS-1$//$NON-NLS-2$ } - b.append("<br>"); + b.append(BR); bonus = newPC.getSR(); if (bonus > 0) { - b.append("<b>Spell Resistance</b>: ").append(newPC.getSR()); + b.append(BOLD).append(PropertyFactory.getString("in_demSpellResistance")).append(END_BOLD).append(": "); //$NON-NLS-1$ //$NON-NLS-2$ + b.append(newPC.getSR()); } - b.append("<br>"); - b.append("<b>Special Abilities:</b>"); - b.append("<ul>"); + b.append(BR); + b.append(BOLD).append(PropertyFactory.getString("in_specialAb")).append(":").append(END_BOLD); //$NON-NLS-1$//$NON-NLS-2$ + b.append(UL); for (String sa : newPC.getSpecialAbilityListStrings()) { - b.append("<li>").append(sa).append("</li>"); + b.append(LI).append(sa).append(END_LI); } - b.append("</ul>"); - b.append("<br>"); + b.append(END_UL); + b.append(BR); return b.toString(); } @@ -951,15 +1060,18 @@ { Race aRace = (Race) obj; - if (aRace.getKeyName().startsWith("<none")) + if (aRace.getKeyName().startsWith(Constants.s_NONESELECTED)) { return; } - StringBuffer b = new StringBuffer(); - String bString = ""; - b.append("<html><font size=+1><b>").append(aRace.getDisplayName()).append("</b></font>"); - b.append(" <b>Type:</b>").append(aRace.getType()); + final StringBuffer b = new StringBuffer(); + String bString = ""; //$NON-NLS-1$ + b.append(HTML).append(FONT_PLUS_1).append(BOLD); + b.append(aRace.getDisplayName()); + b.append(END_BOLD).append(END_FONT); + b.append(" ").append(BOLD).append(PropertyFactory.getString("InfoResources.TypeLabel")).append(END_BOLD); //$NON-NLS-1$ //$NON-NLS-2$ + b.append(aRace.getType()); if (aRace.getMovement() != null) { bString = aRace.getMovement().toString(); @@ -967,24 +1079,27 @@ if (bString.length() > 0) { - b.append(" <b>Move</b>:").append(bString); + b.append(" ").append(BOLD).append(PropertyFactory.getString("in_move")).append(END_BOLD).append(":"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + b.append(bString); } bString = aRace.getSize(); if (bString.length() > 0) { - b.append(" <b>Size</b>:").append(bString); + b.append(" ").append(BOLD).append(PropertyFactory.getString("in_sumSize")).append(END_BOLD).append(": "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + b.append(bString); } bString = aRace.getSource(); if (bString.length() > 0) { - b.append(" <b>SOURCE:</b> ").append(bString); + b.append(" ").append(BOLD).append(PropertyFactory.getString("in_sumSource1")).append(END_BOLD).append(": "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + b.append(bString); } - b.append("</html>"); + b.append(END_HTML); infoLabel.setText(b.toString()); } else if (obj instanceof Follower) @@ -1002,15 +1117,16 @@ if (newPC == null) { - infoLabel.setText("NOTICE: Load from File to display info"); + + infoLabel.setText(PropertyFactory.getString("InfoResources.LoadFromFile")); //$NON-NLS-1$ return; } StringBuffer b = new StringBuffer(); - b.append("<html>"); + b.append(HTML); b.append(followerStatBlock(aF, newPC)); - b.append("</html>"); + b.append(END_HTML); infoLabel.setText(b.toString()); } } @@ -1055,14 +1171,30 @@ private class AvailableClickHandler implements ClickHandler { + /** + * Handles a single click event for the available panel. Does nothing. + * @see pcgen.gui.utils.ClickHandler#singleClickEvent() + */ public void singleClickEvent() { // Do Nothing } + /** + * Handles double click event for the available panel. Adds the clicked + * resource to the selected type. + * @see pcgen.gui.utils.ClickHandler#doubleClickEvent() + */ + @SuppressWarnings("synthetic-access") public void doubleClickEvent() { addButton(); } + + /** + * Check if this Object is allowed to be selected. + * @return true if the clicked object can be selected. + * @see pcgen.gui.utils.ClickHandler#isSelectable(java.lang.Object) + */ public boolean isSelectable(Object obj) { return !(obj instanceof String); @@ -1071,14 +1203,30 @@ private class SelectedClickHandler implements ClickHandler { + /** + * Handles a single click event for the selected panel. Does nothing. + * @see pcgen.gui.utils.ClickHandler#singleClickEvent() + */ public void singleClickEvent() { // Do Nothing } + /** + * Handles double click event for the selected panel. Adds the clicked + * resource to the selected type. + * @see pcgen.gui.utils.ClickHandler#doubleClickEvent() + */ + @SuppressWarnings("synthetic-access") public void doubleClickEvent() { addFileButton(); } + + /** + * Check if this Object is allowed to be selected. + * @return true if the clicked object can be selected. + * @see pcgen.gui.utils.ClickHandler#isSelectable(java.lang.Object) + */ public boolean isSelectable(Object obj) { return !(obj instanceof String); @@ -1167,7 +1315,7 @@ return; } - infoLabel.setText("None"); + infoLabel.setText(PropertyFactory.getString("in_none")); //$NON-NLS-1$ loadButton.setEnabled(false); return; } @@ -1191,7 +1339,7 @@ if (selCPath == null) { - ShowMessageDelegate.showMessageDialog("Select the object to remove", Constants.s_APPNAME, MessageType.ERROR); + ShowMessageDelegate.showMessageDialog(PropertyFactory.getString("InfoResources.SelectToRemove"), Constants.s_APPNAME, MessageType.ERROR); //$NON-NLS-1$ return; } @@ -1199,7 +1347,7 @@ Object endComp = selCPath.getLastPathComponent(); PObjectNode fNode = (PObjectNode) endComp; - int iConfirm = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete?", "Confirm Remove", + int iConfirm = JOptionPane.showConfirmDialog(null, PropertyFactory.getString("InfoResources.ConfirmDelete"), PropertyFactory.getString("InfoResources.ConfirmRemove"), //$NON-NLS-1$ //$NON-NLS-2$ JOptionPane.YES_NO_OPTION); if (iConfirm != JOptionPane.YES_OPTION) @@ -1232,7 +1380,7 @@ private File findPCGFile(File file) { JFileChooser fc = new JFileChooser(); - fc.setDialogTitle("Find file"); + fc.setDialogTitle(PropertyFactory.getString("InfoResources.FindFile")); //$NON-NLS-1$ fc.setCurrentDirectory(SettingsHandler.getPcgPath()); if (fc.showOpenDialog(InfoResources.this) != JFileChooser.APPROVE_OPTION) @@ -1256,8 +1404,7 @@ refresh(); requestFocus(); - // TODO: I18N - PCGen_Frame1.setMessageAreaTextWithoutSaving("Add followers/cohorts, animal companions, special mounts or familiars"); + PCGen_Frame1.setMessageAreaTextWithoutSaving(PropertyFactory.getString("InfoResources.AddFollowersEtc")); //$NON-NLS-1$ int top = topSplit.getDividerLocation(); int bot = botSplit.getDividerLocation(); @@ -1269,55 +1416,55 @@ hasBeenSized = true; Component c = getParent(); - top = SettingsHandler.getPCGenOption("InfoResources.topSplit", ((c.getWidth() * 7) / 10)); - bot = SettingsHandler.getPCGenOption("InfoResources.botSplit", (c.getWidth() - 300)); - cent = SettingsHandler.getPCGenOption("InfoResources.centerSplit", (c.getHeight() - 100)); + top = SettingsHandler.getPCGenOption("InfoResources.topSplit", ((c.getWidth() * 7) / 10)); //$NON-NLS-1$ + bot = SettingsHandler.getPCGenOption("InfoResources.botSplit", (c.getWidth() - 300)); //$NON-NLS-1$ + cent = SettingsHandler.getPCGenOption("InfoResources.centerSplit", (c.getHeight() - 100)); //$NON-NLS-1$ // set the prefered width on selectedTable for (int i = 0; i < selectedTable.getColumnCount(); i++) { TableColumn sCol = selectedTable.getColumnModel().getColumn(i); - width = Globals.getCustColumnWidth("ResSel", i); + width = Globals.getCustColumnWidth("ResSel", i); //$NON-NLS-1$ if (width != 0) { sCol.setPreferredWidth(width); } - sCol.addPropertyChangeListener(new ResizeColumnListener(selectedTable, "ResSel", i)); + sCol.addPropertyChangeListener(new ResizeColumnListener(selectedTable, "ResSel", i)); //$NON-NLS-1$ } // set the prefered width on availableTable for (int i = 0; i < availableTable.getColumnCount(); i++) { TableColumn sCol = availableTable.getColumnModel().getColumn(i); - width = Globals.getCustColumnWidth("ResAva", i); + width = Globals.getCustColumnWidth("ResAva", i); //$NON-NLS-1$ if (width != 0) { sCol.setPreferredWidth(width); } - sCol.addPropertyChangeListener(new ResizeColumnListener(availableTable, "ResAva", i)); + sCol.addPropertyChangeListener(new ResizeColumnListener(availableTable, "ResAva", i)); //$NON-NLS-1$ } } if (top > 0) { topSplit.setDividerLocation(top); - SettingsHandler.setPCGenOption("InfoResources.topSplit", top); + SettingsHandler.setPCGenOption("InfoResources.topSplit", top); //$NON-NLS-1$ } if (bot > 0) { botSplit.setDividerLocation(bot); - SettingsHandler.setPCGenOption("InfoResources.botSplit", bot); + SettingsHandler.setPCGenOption("InfoResources.botSplit", bot); //$NON-NLS-1$ } if (cent > 0) { centerSplit.setDividerLocation(cent); - SettingsHandler.setPCGenOption("InfoResources.centerSplit", cent); + SettingsHandler.setPCGenOption("InfoResources.centerSplit", cent); //$NON-NLS-1$ } } @@ -1330,61 +1477,69 @@ { addComponentListener(new ComponentAdapter() { - public void componentShown(ComponentEvent evt) + @Override + public void componentShown(@SuppressWarnings("unused") + ComponentEvent evt) { formComponentShown(); } }); addComponentListener(new ComponentAdapter() { - public void componentResized(ComponentEvent e) + @Override + public void componentResized(@SuppressWarnings("unused") + ComponentEvent e) { int i = topSplit.getDividerLocation(); if (i > 0) { - SettingsHandler.setPCGenOption("InfoResources.topSplit", i); + SettingsHandler.setPCGenOption("InfoResources.topSplit", i); //$NON-NLS-1$ } i = botSplit.getDividerLocation(); if (i > 0) { - SettingsHandler.setPCGenOption("InfoResources.botSplit", i); + SettingsHandler.setPCGenOption("InfoResources.botSplit", i); //$NON-NLS-1$ } i = centerSplit.getDividerLocation(); if (i > 0) { - SettingsHandler.setPCGenOption("InfoResources.centerSplit", i); + SettingsHandler.setPCGenOption("InfoResources.centerSplit", i); //$NON-NLS-1$ } } }); addButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) + public void actionPerformed(@SuppressWarnings("unused") + ActionEvent evt) { addButton(); } }); delButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) + public void actionPerformed(@SuppressWarnings("unused") + ActionEvent evt) { delButton(); } }); loadButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) + public void actionPerformed(@SuppressWarnings("unused") + ActionEvent evt) { loadButton(); } }); updateButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) + public void actionPerformed(@SuppressWarnings("unused") + ActionEvent evt) { updateButton(); } @@ -1408,43 +1563,50 @@ */ viewModeBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) + public void actionPerformed(@SuppressWarnings("unused") + ActionEvent evt) { viewModeBoxActionPerformed(); } }); viewSortBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) + public void actionPerformed(@SuppressWarnings("unused") + ActionEvent evt) { viewSortBoxActionPerformed(); } }); shouldLoadCompanion.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) + public void actionPerformed(@SuppressWarnings("unused") + ActionEvent evt) { pc.setLoadCompanion(shouldLoadCompanion.isSelected()); } }); textQFilter.getDocument().addDocumentListener(new DocumentListener() { - public void changedUpdate(DocumentEvent evt) + public void changedUpdate(@SuppressWarnings("unused") + DocumentEvent evt) { setQFilter(); } - public void insertUpdate(DocumentEvent evt) + public void insertUpdate(@SuppressWarnings("unused") + DocumentEvent evt) { setQFilter(); } - public void removeUpdate(DocumentEvent evt) + public void removeUpdate(@SuppressWarnings("unused") + DocumentEvent evt) { setQFilter(); } }); clearQFilterButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) + public void actionPerformed(@SuppressWarnings("unused") + ActionEvent evt) {... [truncated message content] |
From: <za...@us...> - 2006-07-15 12:44:17
|
Revision: 1200 Author: zaister Date: 2006-07-15 05:43:47 -0700 (Sat, 15 Jul 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=1200&view=rev Log Message: ----------- Remove the deprecated BonusStacksLoader and CurrencyLoader classes, as well as the classes dependent on these. Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/Campaign.java Trunk/pcgen/code/src/java/pcgen/core/Globals.java Trunk/pcgen/code/src/java/pcgen/core/utils/ListKey.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/CampaignLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstConstants.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java Removed Paths: ------------- Trunk/pcgen/code/src/java/pcgen/core/money/ Trunk/pcgen/code/src/java/pcgen/persistence/lst/BonusStackLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/CurrencyLoader.java Trunk/pcgen/code/src/java/plugin/lsttokens/campaign/CoinsToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-07-15 01:19:23 UTC (rev 1199) +++ Trunk/pcgen/code/pluginbuild.xml 2006-07-15 12:43:47 UTC (rev 1200) @@ -2227,13 +2227,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/CampaignLstToken-COINS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/campaign/CoinsToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/CampaignLstToken-COMPANIONMOD.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/core/Campaign.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Campaign.java 2006-07-15 01:19:23 UTC (rev 1199) +++ Trunk/pcgen/code/src/java/pcgen/core/Campaign.java 2006-07-15 12:43:47 UTC (rev 1200) @@ -58,7 +58,6 @@ listChar.initializeListFor(ListKey.FILE_CLASS); listChar.initializeListFor(ListKey.FILE_CLASS_SKILL); listChar.initializeListFor(ListKey.FILE_CLASS_SPELL); - listChar.initializeListFor(ListKey.FILE_COIN); listChar.initializeListFor(ListKey.FILE_COMPANION_MOD); listChar.initializeListFor(ListKey.FILE_COVER); listChar.initializeListFor(ListKey.FILE_DEITY); @@ -128,15 +127,6 @@ * * @param files */ - public void addAllCoinFiles(final List<CampaignSourceEntry> files) - { - listChar.addAllToListFor(ListKey.FILE_COIN, files); - } - - /** - * - * @param files - */ public void addAllCompanionModFiles(final List<CampaignSourceEntry> files) { listChar.addAllToListFor(ListKey.FILE_COMPANION_MOD, files); @@ -335,15 +325,6 @@ * * @param file */ - public void addCoinFile(final CampaignSourceEntry file) - { - listChar.addToListFor(ListKey.FILE_COIN, file); - } - - /** - * - * @param file - */ public void addCompanionModFile(final CampaignSourceEntry file) { listChar.addToListFor(ListKey.FILE_COMPANION_MOD, file); @@ -613,18 +594,7 @@ { return getListFor(ListKey.FILE_CLASS_SPELL); } - /** - * Returns the coverFileList. - * @return List - */ - public List<CampaignSourceEntry> getCoinFiles() - { - return getListFor(ListKey.FILE_COIN); - } - - - /** * Returns the companionmodFileList. * @return List */ Modified: Trunk/pcgen/code/src/java/pcgen/core/Globals.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2006-07-15 01:19:23 UTC (rev 1199) +++ Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2006-07-15 12:43:47 UTC (rev 1200) @@ -49,7 +49,6 @@ import pcgen.core.character.CompanionMod; import pcgen.core.character.EquipSlot; -import pcgen.core.money.DenominationList; import pcgen.core.spell.Spell; import pcgen.core.utils.CoreUtility; import pcgen.core.utils.MessageType; @@ -131,7 +130,6 @@ private static List<String> pcClassTypeList = new ArrayList<String>(); private static List<Skill> skillList = new ArrayList<Skill>(400); private static List<PCTemplate> templateList = new ArrayList<PCTemplate>(350); - private static DenominationList denomList = DenominationList.getInstance(); // derived from ArrayList private static SortedSet<SpecialAbility> saSet = new TreeSet<SpecialAbility>(); private static Map<String, Map<String, String>> sponsors = new HashMap<String, Map<String, String>>(); @@ -753,15 +751,6 @@ } /** - * Get denomination list - * @return denomination list - */ - public static DenominationList getDenominationList() - { - return denomList; - } - - /** * Get descriptor set * @return descriptor set */ @@ -2255,7 +2244,6 @@ // They only get loaded once. // //birthplaceList.clear(); - //bonusStackList.clear(); //cityList.clear(); //hairStyleList.clear(); //helpContextFileList.clear(); Modified: Trunk/pcgen/code/src/java/pcgen/core/utils/ListKey.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/utils/ListKey.java 2006-07-15 01:19:23 UTC (rev 1199) +++ Trunk/pcgen/code/src/java/pcgen/core/utils/ListKey.java 2006-07-15 12:43:47 UTC (rev 1200) @@ -56,8 +56,6 @@ public static final ListKey<CampaignSourceEntry> FILE_CLASS_SKILL = new ListKey<CampaignSourceEntry>(); /** FILE_CLASS_SPELL - a ListKey */ public static final ListKey<CampaignSourceEntry> FILE_CLASS_SPELL = new ListKey<CampaignSourceEntry>(); - /** FILE_COIN - a ListKey */ - public static final ListKey<CampaignSourceEntry> FILE_COIN = new ListKey<CampaignSourceEntry>(); /** FILE_COMPANION_MOD - a ListKey */ public static final ListKey<CampaignSourceEntry> FILE_COMPANION_MOD = new ListKey<CampaignSourceEntry>(); /** FILE_COVER - a ListKey */ Deleted: Trunk/pcgen/code/src/java/pcgen/persistence/lst/BonusStackLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/BonusStackLoader.java 2006-07-15 01:19:23 UTC (rev 1199) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/BonusStackLoader.java 2006-07-15 12:43:47 UTC (rev 1200) @@ -1,76 +0,0 @@ -/* - * BonusStackLoader.java - * Copyright 2003 (C) David Hibbs <sag...@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 - * - * Created on September 22, 2003, 11:29 AM - * - * Current Ver: $Revision$ <br> - * Last Editor: $Author$ <br> - * Last Edited: $Date$ - */ -package pcgen.persistence.lst; - -import java.net.URL; - -import pcgen.core.SystemCollections; -import pcgen.persistence.PersistenceLayerException; -import pcgen.util.Logging; - -/** - * This class is an LstFileLoader that handles loading of bonus-stacking - * data. - * - * <p> - * Current Ver: $Revision$ <br> - * Last Editor: $Author$ <br> - * Last Edited: $Date$ - * - * @deprecated Now processed in miscinfo.lst - * To be removed in 5.11.1 - * @author ad9c15 - */ -public class BonusStackLoader extends LstLineFileLoader -{ - /** - * Constructor for BonusStackLoader. - */ - public BonusStackLoader() - { - super(); - } - - /** - * Load the LST file - * @param fileName - * @param gameModeIn - * @throws PersistenceLayerException - */ - public void loadLstFile(String fileName, String gameModeIn) throws PersistenceLayerException - { - //SystemCollections.getGameModeNamed(gameModeIn).clearBonusStacksList(); - super.loadLstFile(fileName, gameModeIn); - Logging.errorPrint("Warning: bonusstacks.lst deprecated. use BONUSSTACKS in miscinfo.lst instead (GameMode: " + gameModeIn + ")"); - } - - /** - * @see pcgen.persistence.lst.LstLineFileLoader#parseLine(java.lang.String, java.net.URL) - */ - public void parseLine(String lstLine, URL sourceURL) - { - SystemCollections.getGameModeNamed(getGameMode()).addToBonusStackList(lstLine.toUpperCase()); - } -} Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/CampaignLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/CampaignLoader.java 2006-07-15 01:19:23 UTC (rev 1199) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/CampaignLoader.java 2006-07-15 12:43:47 UTC (rev 1200) @@ -286,7 +286,6 @@ baseCampaign.addAllReqSkillFiles(subCampaign.getReqSkillFiles()); baseCampaign.addAllTemplateFiles(subCampaign.getTemplateFiles()); baseCampaign.addAllEquipModFiles(subCampaign.getEquipModFiles()); - baseCampaign.addAllCoinFiles(subCampaign.getCoinFiles()); baseCampaign.addAllKitFiles(subCampaign.getKitFiles()); baseCampaign.addAllBioSetFiles(subCampaign.getBioSetFiles()); } Deleted: Trunk/pcgen/code/src/java/pcgen/persistence/lst/CurrencyLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/CurrencyLoader.java 2006-07-15 01:19:23 UTC (rev 1199) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/CurrencyLoader.java 2006-07-15 12:43:47 UTC (rev 1200) @@ -1,140 +0,0 @@ -/* - * CurrencyParser.java - * Copyright 2003 (C) David Hibbs <sag...@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 - * - * Created on Oct 10, 2003, 12:30 PM - * - * Current Ver: $Revision$ <br> - * Last Editor: $Author$ <br> - * Last Edited: $Date$ - */ -package pcgen.persistence.lst; - -import pcgen.core.money.DenominationList; -import pcgen.core.money.Denominations; -import pcgen.persistence.PersistenceLayerException; -import pcgen.persistence.SystemLoader; - -import java.math.BigDecimal; -import java.net.URL; -import java.util.StringTokenizer; - -/** - * This class is a LstFileLoader for parsing currencies. - * - * <p> - * Current Ver: $Revision$ <br> - * Last Editor: $Author$ <br> - * Last Edited: $Date$ - * @deprecated - * @author AD9C15 - */ -public class CurrencyLoader extends LstLineFileLoader -{ - /** - * CurrencyParser Constructor. - * - */ - public CurrencyLoader() - { - super(); - } - - /** - * @see pcgen.persistence.lst.LstLineFileLoader#parseLine(java.lang.String, java.net.URL) - */ - public void parseLine(String lstLine, URL sourceURL) - throws PersistenceLayerException - { - LstUtils.deprecationWarning("COIN file type deprecated. Currency is declared in equipment files"); - DenominationList denominationList = DenominationList.getInstance(); - - final StringTokenizer colToken = new StringTokenizer(lstLine, SystemLoader.TAB_DELIM); - String colString; - - String region = "Global"; - String name = ""; - String abbr = ""; - int factor = 0; - float weight = 0f; - BigDecimal bdWeight; - boolean isDefault = false; - - while (colToken.hasMoreTokens()) - { - colString = colToken.nextToken(); - - if (colString.startsWith("COIN")) - { - colString = colString.replace('(', ' '); - colString = colString.replace(')', ' '); - colString = colString.substring(4); - colString = colString.trim(); - } - else if (colString.startsWith("COST:")) - { - String costString = colString.substring(5); - - try - { - factor = Integer.parseInt(costString); - } - catch (NumberFormatException e) - { - throw new PersistenceLayerException("Invalid Coin Cost '" + costString + "' in " - + sourceURL.toString()); - } - } - else if (colString.startsWith("ABBR:")) - { - abbr = colString.substring(5); - } - else if (colString.startsWith("WT:")) - { - bdWeight = new BigDecimal(colString.substring(3)); - weight = bdWeight.floatValue(); - } - else if ("DEFAULT".equalsIgnoreCase(colString)) - { - isDefault = true; - } - } - - if (!(("".equals(name) && "".equals(abbr)) || (factor == 0))) - { - if ("".equals(name)) - { - name = abbr; - } - else if ("".equals(abbr)) - { - abbr = name; - } - - Denominations d = denominationList.getRegionalDenominations(region); - - if (d == null) - { - d = new Denominations(); - d.setRegion(region); - denominationList.add(d); - } - - d.addDenomination(name, abbr, factor, weight, isDefault); - } - } -} Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstConstants.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstConstants.java 2006-07-15 01:19:23 UTC (rev 1199) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstConstants.java 2006-07-15 12:43:47 UTC (rev 1200) @@ -46,8 +46,6 @@ int CLASSSPELL_TYPE = 15; /** CLASS_TYPE = 1 */ int CLASS_TYPE = 1; - /** COINS_TYPE = 23 */ - int COINS_TYPE = 23; /** COMPANIONMOD_TYPE = 25 */ int COMPANIONMOD_TYPE = 25; /** DEITY_TYPE = 5 */ Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java 2006-07-15 01:19:23 UTC (rev 1199) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java 2006-07-15 12:43:47 UTC (rev 1200) @@ -146,7 +146,6 @@ private BioSetLoader bioLoader = new BioSetLoader(); private CampaignLoader campaignLoader = new CampaignLoader(); private CampaignSourceEntry globalCampaign = new CampaignSourceEntry(new Campaign(), "System Configuration Document"); - private CurrencyLoader currencyParser = new CurrencyLoader(); private DeityLoader deityLoader = new DeityLoader(); private DomainLoader domainLoader = new DomainLoader(); private AbilityLoader abilityLoader = new AbilityLoader(); @@ -193,7 +192,6 @@ private final List<CampaignSourceEntry> classFileList = new ArrayList<CampaignSourceEntry>(); private final List<CampaignSourceEntry> classSkillFileList = new ArrayList<CampaignSourceEntry>(); private final List<CampaignSourceEntry> classSpellFileList = new ArrayList<CampaignSourceEntry>(); - private final List<CampaignSourceEntry> coinFileList = new ArrayList<CampaignSourceEntry>(); private final List<CampaignSourceEntry> companionmodFileList = new ArrayList<CampaignSourceEntry>(); private final List<CampaignSourceEntry> deityFileList = new ArrayList<CampaignSourceEntry>(); private final List<CampaignSourceEntry> domainFileList = new ArrayList<CampaignSourceEntry>(); @@ -231,7 +229,6 @@ private RaceLoader raceLoader = new RaceLoader(); private final Set<String> sourcesSet = new TreeSet<String>(); private BioSet bioSet = new BioSet(); - private BonusStackLoader bonusLoader = new BonusStackLoader(); private SizeAdjustmentLoader sizeLoader = new SizeAdjustmentLoader(); private SkillLoader skillLoader = new SkillLoader(); private SpellLoader spellLoader = new SpellLoader(); @@ -260,7 +257,6 @@ { //featLoader.addObserver(this); bioLoader.addObserver(this); - bonusLoader.addObserver(this); campaignLoader.addObserver(this); deityLoader.addObserver(this); domainLoader.addObserver(this); @@ -443,7 +439,6 @@ spellLoader.loadLstFiles(spellFileList); // loaded before equipment to cover costs - currencyParser.loadLstFiles(coinFileList); // TODO: Convert remaining items to new persistence framework! // Process file content by load order [file type] @@ -516,7 +511,6 @@ count += classFileList.size(); count += classSkillFileList.size(); count += classSpellFileList.size(); - count += coinFileList.size(); count += companionmodFileList.size(); count += deityFileList.size(); count += domainFileList.size(); @@ -1632,7 +1626,6 @@ reqSkillFileList.addAll(aCamp.getReqSkillFiles()); templateFileList.addAll(aCamp.getTemplateFiles()); equipmodFileList.addAll(aCamp.getEquipModFiles()); - coinFileList.addAll(aCamp.getCoinFiles()); kitFileList.addAll(aCamp.getKitFiles()); bioSetFileList.addAll(aCamp.getBioSetFiles()); } @@ -2124,10 +2117,6 @@ // Load sizeAdjustment.lst loadGameModeLstFile(sizeLoader, gameFiles[i], "sizeAdjustment.lst"); - // Load bonusstacks.lst - //TODO: Remove after 5.10 - loadGameModeLstFile(bonusLoader, gameFiles[i], "bonusstacks.lst", false); - // Load statsandchecks.lst loadGameModeLstFile(statCheckLoader, gameFiles[i], "statsandchecks.lst"); } @@ -2411,7 +2400,6 @@ reqSkillFileList.removeAll(lstExcludeFiles); templateFileList.removeAll(lstExcludeFiles); equipmodFileList.removeAll(lstExcludeFiles); - coinFileList.removeAll(lstExcludeFiles); kitFileList.removeAll(lstExcludeFiles); bioSetFileList.removeAll(lstExcludeFiles); } @@ -2441,7 +2429,6 @@ reqSkillFileList.clear(); languageFileList.clear(); equipmodFileList.clear(); - coinFileList.clear(); kitFileList.clear(); bioSetFileList.clear(); } Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/campaign/CoinsToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/campaign/CoinsToken.java 2006-07-15 01:19:23 UTC (rev 1199) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/campaign/CoinsToken.java 2006-07-15 12:43:47 UTC (rev 1200) @@ -1,24 +0,0 @@ -package plugin.lsttokens.campaign; - -import pcgen.core.Campaign; -import pcgen.persistence.lst.CampaignLoader; -import pcgen.persistence.lst.CampaignLstToken; -import pcgen.persistence.lst.CampaignSourceEntry; - -import java.net.URL; - -/** - * Class deals with COINS Token - */ -public class CoinsToken implements CampaignLstToken { - - public String getTokenName() { - return "COINS"; - } - - public boolean parse(Campaign campaign, String value, URL sourceUrl) { - campaign.addLine("COINS:" + value); - campaign.addCoinFile(new CampaignSourceEntry(campaign, CampaignLoader.convertFilePath(sourceUrl, value))); - return true; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2006-08-19 11:48:41
|
Revision: 1323 Author: jdempsey Date: 2006-08-19 04:48:20 -0700 (Sat, 19 Aug 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=1323&view=rev Log Message: ----------- FReq #1461250 - Move MW/Magic Type Definitions Used by Eq Customiser to Data Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/Equipment.java Trunk/pcgen/code/src/java/pcgen/core/EquipmentModifier.java Trunk/pcgen/code/src/java/pcgen/core/utils/IntegerKey.java Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/equipmentmodifier/FormatcatToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-08-19 11:28:16 UTC (rev 1322) +++ Trunk/pcgen/code/pluginbuild.xml 2006-08-19 11:48:20 UTC (rev 1323) @@ -3322,6 +3322,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/EquipmentModifierLstToken-FORMATCAT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/equipmentmodifier/FormatcatToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${lstplugins.dir}/EquipmentModifierLstToken-FUMBLERANGE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/core/Equipment.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Equipment.java 2006-08-19 11:28:16 UTC (rev 1322) +++ Trunk/pcgen/code/src/java/pcgen/core/Equipment.java 2006-08-19 11:48:20 UTC (rev 1323) @@ -32,6 +32,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.SortedSet; @@ -1212,6 +1213,9 @@ final List<EquipmentModifier> modList = new ArrayList<EquipmentModifier>(eqModifierList); final List<EquipmentModifier> altModList = new ArrayList<EquipmentModifier>(altEqModifierList); final List<EquipmentModifier> commonList = new ArrayList<EquipmentModifier>(); + final List<EquipmentModifier> modListByFC[] = initSplitModList(); + final List<EquipmentModifier> altModListByFC[] = initSplitModList(); + final List<EquipmentModifier> commonListByFC[] = initSplitModList(); // // Remove any modifiers on the base item so they don't confuse the naming @@ -1261,85 +1265,51 @@ extractListFromCommon(commonList, modList); removeCommonFromList(altModList, commonList, "eqMod expected but not found: "); + + // Remove masterwork from the list if magic is present + suppressMasterwork(commonList, modList, altModList); - // - // Look for a modifier named "masterwork" (assumption: this is marked as "assigntoall") - // - String eqMaster = ""; + //Split the eqmod lists by format category + splitModListByFormatCat(commonList, commonListByFC); + splitModListByFormatCat(modList, modListByFC); + splitModListByFormatCat(altModList, altModListByFC); - for ( EquipmentModifier eqMod : commonList ) + + final StringBuffer itemName = new StringBuffer(); + + // Add in front eq mods + String eqmodDesc = buildEqModDesc( + commonListByFC[EquipmentModifier.FORMATCAT_FRONT], + modListByFC[EquipmentModifier.FORMATCAT_FRONT], + altModListByFC[EquipmentModifier.FORMATCAT_FRONT]); + itemName.append(eqmodDesc); + if (itemName.length() > 0) { - if ("MASTERWORK".equalsIgnoreCase(eqMod.getDisplayName()) - || eqMod.isIType("Masterwork")) - { - eqMaster = eqMod.getDisplayName(); - - break; - } + itemName.append(' '); } - - final EquipmentModifier magicMod1 = getMagicBonus(eqModifierList); - final String magic1 = (magicMod1 == null ? "" : magicMod1.getDisplayName()); - final String desc1 = getNameFromModifiers(modList, magic1, ""); - EquipmentModifier magicMod2 = null; - String magic2 = ""; - String desc2 = ""; - - if (isDouble()) - { - magicMod2 = getMagicBonus(altEqModifierList); - magic2 = (magicMod2 == null ? "" : magicMod2.getDisplayName()); - desc2 = getNameFromModifiers(altModList, magic2, ""); - } - - final StringBuffer common = new StringBuffer(getNameFromModifiers(commonList, magic1 + magic2, eqMaster)); - - final StringBuffer itemName; - final String baseName = getBaseItemName().trim(); - + // - // Start with the base name, less any modifiers + // Add in the base name, less any modifiers // + final String baseName = getBaseItemName().trim(); int idx = baseName.indexOf('('); - if (idx >= 0) { - itemName = new StringBuffer(baseName.substring(0, idx - 1).trim()); + itemName.append(baseName.substring(0, idx - 1).trim()); } else { - itemName = new StringBuffer(baseName); + itemName.append(baseName); } - // - // Add magic bonus(es) to description - // - if ((magic1.length() != 0) || (magic2.length() != 0)) + // Add in middle mods + eqmodDesc = buildEqModDesc( + commonListByFC[EquipmentModifier.FORMATCAT_MIDDLE], + modListByFC[EquipmentModifier.FORMATCAT_MIDDLE], + altModListByFC[EquipmentModifier.FORMATCAT_MIDDLE]); + if (eqmodDesc.length() > 0) { - itemName.append(' '); - - if (magic1.length() != 0) - { - itemName.append(magicMod1.getEquipNamePortion()); - } - else - { - itemName.append('-'); - } - - if (isDouble()) - { - itemName.append('/'); - - if (magic2.length() != 0) - { - itemName.append(magicMod2.getEquipNamePortion()); - } - else - { - itemName.append('-'); - } - } + itemName.append(' ').append(eqmodDesc); } // @@ -1370,78 +1340,143 @@ // Put size in name if not the same as the base item // final int iSize = Globals.sizeInt(getSize(), 4); - if (Globals.sizeInt(getBaseSize(), 4) != iSize) { - if (common.length() != 0) - { - common.append('/'); - } + itemName.append((SettingsHandler.getGame().getSizeAdjustmentAtIndex(iSize)).getDisplayName()); + itemName.append('/'); + } - common.append((SettingsHandler.getGame().getSizeAdjustmentAtIndex(iSize)).getDisplayName()); + // Put in parens mods + eqmodDesc = buildEqModDesc( + commonListByFC[EquipmentModifier.FORMATCAT_PARENS], + modListByFC[EquipmentModifier.FORMATCAT_PARENS], + altModListByFC[EquipmentModifier.FORMATCAT_PARENS]); + itemName.append(eqmodDesc); + + // + // If there were no modifiers, then drop the trailing '/' + // + if (itemName.toString().endsWith("/") || itemName.toString().endsWith(";")) + { + itemName.setLength(itemName.length() - 1); } + itemName.append(')'); + // - // add the modifier description(s) + // If there were no modifiers, then strip the empty parenthesis // - if ((desc1.length() == 0) && (desc2.length() == 0)) + idx = itemName.toString().indexOf(" ()"); + + if (idx >= 0) { - itemName.append(String.valueOf(common)); + itemName.setLength(idx); } + + return itemName.toString(); + } + + /** + * Where a magic eqmod is present, remove the masterwork eqmod from + * the list. + * + * @param commonList The list of eqmods on both heads (or only head) + * @param modList The list of eqmods on the primary head + * @param altModList The list of eqmods on the secondary head + */ + private void suppressMasterwork(List<EquipmentModifier> commonList, + List<EquipmentModifier> modList, List<EquipmentModifier> altModList) + + { + // + // Look for a modifier named "masterwork" (assumption: this is marked as "assigntoall") + // + EquipmentModifier eqMaster = null; + for ( EquipmentModifier eqMod : commonList ) + { + if ("MASTERWORK".equalsIgnoreCase(eqMod.getDisplayName()) + || eqMod.isIType("Masterwork")) + { + eqMaster = eqMod; + + break; + } + } + + if (eqMaster == null) + { + return; + } + + final EquipmentModifier magicMod1 = getMagicBonus(eqModifierList); + EquipmentModifier magicMod2 = null; + if (isDouble()) + { + magicMod2 = getMagicBonus(altEqModifierList); + } + + if (magicMod1 != null || magicMod2 != null) + { + commonList.remove(eqMaster); + } + } + + + /** + * Build up the description of the listed equipmods for this equipment item. + * Takes into account if the item is a double weapon or not. + * + * @param commonList The list of common equipment modifiers. + * @param modList The list of eqmods on the primary head. + * @param altModList The list of eqmods on the secondary head. + * @return The description of these equipment modifiers. + */ + private String buildEqModDesc(List<EquipmentModifier> commonList, List<EquipmentModifier> modList, List<EquipmentModifier> altModList) + { + StringBuffer desc = new StringBuffer(); + + String commonDesc = getNameFromModifiers(commonList); + String modDesc = getNameFromModifiers(modList); + String altModDesc = getNameFromModifiers(altModList); + + if ((modList.isEmpty()) && (altModList.isEmpty())) + { + desc.append(commonDesc); + } else if (!isDouble()) { - itemName.append(desc1).append('/').append(String.valueOf(common)); + desc.append(modDesc).append('/').append(commonDesc); } else { - if (common.length() != 0) + if (commonDesc.length() != 0) { - itemName.append(String.valueOf(common)).append(';'); + desc.append(commonDesc).append(';'); } - if (desc1.length() != 0) + if (modDesc.length() != 0) { - itemName.append(desc1); + desc.append(modDesc); } else { - itemName.append('-'); + desc.append('-'); } - itemName.append(';'); + desc.append(';'); - if (desc2.length() != 0) + if (altModDesc.length() != 0) { - itemName.append(desc2); + desc.append(altModDesc); } else { - itemName.append('-'); + desc.append('-'); } } - - // - // If there were no modifiers, then drop the trailing '/' - // - if (itemName.toString().endsWith("/") || itemName.toString().endsWith(";")) - { - itemName.setLength(itemName.length() - 1); - } - - itemName.append(')'); - - // - // If there were no modifiers, then strip the empty parenthesis - // - idx = itemName.toString().indexOf(" ()"); - - if (idx >= 0) - { - itemName.setLength(idx); - } - - return itemName.toString(); + return desc.toString(); } + /** * OwnedItem @@ -4641,15 +4676,14 @@ return null; } + /** * Gets the nameFromModifiers attribute of the Equipment object * * @param eqModList The list of modifiers - * @param eqMagic ??? - * @param eqMaster ??? * @return The nameFromModifiers value */ - private static String getNameFromModifiers(final List<EquipmentModifier> eqModList, final String eqMagic, final String eqMaster) + private static String getNameFromModifiers(final List<EquipmentModifier> eqModList) { // // Get a sorted list so that the description will always come @@ -4660,23 +4694,14 @@ final StringBuffer sMod = new StringBuffer(70); - if ((eqMagic.length() == 0) && (eqMaster.length() != 0)) - { - sMod.append(eqMaster); - } - for ( EquipmentModifier eqMod : eqList ) { - if (!eqMod.getDisplayName().equals(eqMagic) - && !eqMod.getDisplayName().equals(eqMaster)) + if (sMod.length() != 0) { - if (sMod.length() != 0) - { - sMod.append('/'); - } + sMod.append('/'); + } - sMod.append(eqMod.getEquipNamePortion()); - } + sMod.append(eqMod.getEquipNamePortion()); } return sMod.toString(); @@ -5311,6 +5336,37 @@ } /** + * Initialise an array of equipment modifier lists with an entry for + * each format category. + * + * @return An array of equipmod lists. + */ + private List<EquipmentModifier>[] initSplitModList() + { + List<EquipmentModifier>[] modListArray = new List[EquipmentModifier.FORMATCAT_PARENS+1]; + for (int i = 0; i < modListArray.length; i++) + { + modListArray[i] = new ArrayList<EquipmentModifier>(); + } + return modListArray; + } + + /** + * Split the equipmod list into seperate lists by format category. + * @param modList The list to be split. + * @param splitModList The array of receiving lists, one for each format cat. + */ + private void splitModListByFormatCat(final List<EquipmentModifier> modList, final List<EquipmentModifier>[] splitModList) + { + for (Iterator iter = modList.iterator(); iter.hasNext();) + { + EquipmentModifier eqMod = (EquipmentModifier) iter.next(); + splitModList[eqMod.getFormatCat()].add(eqMod); + + } + } + + /** * remover * @param i */ Modified: Trunk/pcgen/code/src/java/pcgen/core/EquipmentModifier.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/EquipmentModifier.java 2006-08-19 11:28:16 UTC (rev 1322) +++ Trunk/pcgen/code/src/java/pcgen/core/EquipmentModifier.java 2006-08-19 11:48:20 UTC (rev 1323) @@ -31,6 +31,7 @@ import pcgen.core.prereq.Prerequisite; import pcgen.core.spell.Spell; import pcgen.core.utils.CoreUtility; +import pcgen.core.utils.IntegerKey; import pcgen.core.utils.MessageType; import pcgen.core.utils.ShowMessageDelegate; import pcgen.util.Delta; @@ -63,6 +64,10 @@ private static final int NAMINGOPTION_SPELL = 4; private static final int NAMINGOPTION_TEXT = 5; + public static final int FORMATCAT_FRONT = 0; + public static final int FORMATCAT_MIDDLE = 1; + public static final int FORMATCAT_PARENS = 2; + private static final String s_CHARGES = "CHARGES"; private List<String> ignores = new ArrayList<String>(); private List<String> itemType = new ArrayList<String>(); @@ -1641,6 +1646,25 @@ } /** + * Set the eqmod's format category. + * @param cat + */ + public void setFormatCat(int cat) + { + integerChar.put(IntegerKey.FORMAT_CAT, cat); + } + + /** + * Retrieve the eqmod's format category. Defaults to parens. + * @return The format category for this eqmod. + */ + public int getFormatCat() + { + final Integer characteristic = integerChar.get(IntegerKey.FORMAT_CAT); + return characteristic == null ? FORMATCAT_PARENS : characteristic.intValue(); + } + + /** * lets this object compare to others. * * @param o The object to compare to Modified: Trunk/pcgen/code/src/java/pcgen/core/utils/IntegerKey.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/utils/IntegerKey.java 2006-08-19 11:28:16 UTC (rev 1322) +++ Trunk/pcgen/code/src/java/pcgen/core/utils/IntegerKey.java 2006-08-19 11:48:20 UTC (rev 1323) @@ -35,6 +35,8 @@ public static final IntegerKey ADD_SPELL_LEVEL = new IntegerKey(); /** Key to a characteristic defining the type of ability. */ public static final IntegerKey ABILITY_TYPE = new IntegerKey(); + /** Key to a characteristic defining the format category of the object. */ + public static final IntegerKey FORMAT_CAT = new IntegerKey(); /** Key to a characteristic defining the number of hit dice the object has. */ public static final IntegerKey HIT_DIE = new IntegerKey(); /** Key to a characteristic defining the level of the object. */ Added: Trunk/pcgen/code/src/java/plugin/lsttokens/equipmentmodifier/FormatcatToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/equipmentmodifier/FormatcatToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/equipmentmodifier/FormatcatToken.java 2006-08-19 11:48:20 UTC (rev 1323) @@ -0,0 +1,74 @@ +/* + * Formatcat.java + * Copyright 2006 (C) James Dempsey <jde...@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 + * + * Created on 19/08/2006 + * + * $Id: $ + * + */ +package plugin.lsttokens.equipmentmodifier; + +import pcgen.core.EquipmentModifier; +import pcgen.persistence.lst.EquipmentModifierLstToken; +import pcgen.util.Logging; + +/** + * Deals with FORMATCAT token, which indicates where the name of the + * equipment modifier should be added in the name of any equipment item + * the eqmod is added to. + */ +public class FormatcatToken implements EquipmentModifierLstToken +{ + + /** + * @see pcgen.persistence.lst.LstToken#getTokenName() + * @Override + */ + public String getTokenName() + { + return "FORMATCAT"; + } + + /** + * @see pcgen.persistence.lst.EquipmentModifierLstToken#parse(pcgen.core.EquipmentModifier, java.lang.String) + * @Override + */ + public boolean parse(EquipmentModifier mod, String value) + { + String testVal = value == null ? "" : value.toUpperCase(); + if ("FRONT".equals(testVal)) + { + mod.setFormatCat(EquipmentModifier.FORMATCAT_FRONT); + } + else if ("MIDDLE".equals(testVal)) + { + mod.setFormatCat(EquipmentModifier.FORMATCAT_MIDDLE); + } + else if ("PARENS".equals(testVal)) + { + mod.setFormatCat(EquipmentModifier.FORMATCAT_PARENS); + } + else + { + Logging.errorPrint("Ignoring unrecognized format category " + value + + " for EqMod " + mod.getKeyName()); + return false; + } + return true; + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/equipmentmodifier/FormatcatToken.java ___________________________________________________________________ Name: keywords + "Author Revision Date Id" Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <boo...@us...> - 2006-10-04 01:56:58
|
Revision: 1447 http://svn.sourceforge.net/pcgen/?rev=1447&view=rev Author: boomer70 Date: 2006-10-03 18:56:03 -0700 (Tue, 03 Oct 2006) Log Message: ----------- More Ability object changes and stabilizations. Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/AbilityUtilities.java Trunk/pcgen/code/src/java/pcgen/core/AssociatedChoice.java 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/PObjectUtilities.java Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java Trunk/pcgen/code/src/java/pcgen/core/chooser/ProficiencyChoiceManager.java Trunk/pcgen/code/src/java/pcgen/core/chooser/SimpleWeaponProfChoiceManager.java Trunk/pcgen/code/src/java/pcgen/core/chooser/WeaponProfChoiceManager.java Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbilityWeaponBonus.java Trunk/pcgen/code/src/java/pcgen/core/utils/ListKey.java Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoAbility.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoGear.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityInfoPanel.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityPoolPanel.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilitySelectionPanel.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java Trunk/pcgen/code/src/java/plugin/charactersheet/gui/Page2Panel.java Trunk/pcgen/code/src/java/plugin/exporttokens/WeaponProfsToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/NaturalattacksLst.java Trunk/pcgen/code/src/java/plugin/pretokens/test/PreWeaponProfTester.java Trunk/pcgen/code/src/test/pcgen/core/AbilityStoreTest.java Trunk/pcgen/code/src/test/pcgen/core/AbilityTest.java Trunk/pcgen/code/src/test/pcgen/core/AllJUnitTests.java Trunk/pcgen/code/src/test/pcgen/core/BioSetTest.java Trunk/pcgen/code/src/test/pcgen/core/DamageReductionTest.java Trunk/pcgen/code/src/test/pcgen/core/DomainTest.java Trunk/pcgen/code/src/test/pcgen/core/EquipmentListTest.java Trunk/pcgen/code/src/test/pcgen/core/EquipmentTest.java Trunk/pcgen/code/src/test/pcgen/core/EquipmentUtilitiesTest.java Trunk/pcgen/code/src/test/pcgen/core/GlobalsTest.java Trunk/pcgen/code/src/test/pcgen/core/NamesTest.java Trunk/pcgen/code/src/test/pcgen/core/PCClassTest.java Trunk/pcgen/code/src/test/pcgen/core/PObjectTest.java Trunk/pcgen/code/src/test/pcgen/core/PObjectUtilitiesTest.java Trunk/pcgen/code/src/test/pcgen/core/PlayerCharacterTest.java Trunk/pcgen/code/src/test/pcgen/core/PrereqHandlerTest.java Trunk/pcgen/code/src/test/pcgen/core/UtilityTest.java Trunk/pcgen/code/src/test/pcgen/core/chooser/AbilityFromTemplateChoiceManagerTest.java Trunk/pcgen/code/src/test/pcgen/core/chooser/AbstractComplexChoiceManagerTest.java Trunk/pcgen/code/src/test/pcgen/core/levelability/LevelAbilityClassSkillsTest.java Trunk/pcgen/code/src/test/pcgen/core/levelability/LevelAbilityTest.java Trunk/pcgen/code/src/test/pcgen/gui/pcGenGUIBarJackTest.java Trunk/pcgen/code/src/test/pcgen/gui/pcGenGUIBrdJoeTest.java Trunk/pcgen/code/src/test/pcgen/gui/pcGenGUICleElfTest.java Trunk/pcgen/code/src/test/pcgen/gui/pcGenGUICloudGiantTest.java Trunk/pcgen/code/src/test/pcgen/gui/pcGenGUIDrakelingSorcTest.java Trunk/pcgen/code/src/test/pcgen/gui/pcGenGUIElwoodTest.java Trunk/pcgen/code/src/test/pcgen/gui/pcGenGUIFigFaeTest.java Trunk/pcgen/code/src/test/pcgen/gui/pcGenGUIJimDopTest.java Trunk/pcgen/code/src/test/pcgen/gui/pcGenGUIMonKeeTest.java Trunk/pcgen/code/src/test/pcgen/gui/pcGenGUISWizSamTest.java Trunk/pcgen/code/src/test/pcgen/gui/pcGenGUITestCase.java Trunk/pcgen/code/src/test/pcgen/gui/pcGenGUIWizSharTest.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/WeaponautoLst.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-10-03 21:51:30 UTC (rev 1446) +++ Trunk/pcgen/code/pluginbuild.xml 2006-10-04 01:56:03 UTC (rev 1447) @@ -23,7 +23,7 @@ <property name="jepplugins.dir" value="${plugins.dir}/jepplugins" /> - <target name="jar-all-plugins" depends="makeplugindirs,jar-gmgen-plugins,jar-export-plugins,jar-bonus-plugins,jar-pre-plugins,jar-lst-plugins, jar-systemlst-plugins, jar-jep-plugins" description="Build (Link) plugin jar files"> + <target name="jar-all-plugins" depends="makeplugindirs,jar-gmgen-plugins,jar-export-plugins,jar-bonus-plugins,jar-pre-plugins,jar-lst-plugins, jar-systemlst-plugins, jar-jep-plugins, jar-deprecated-plugin" description="Build (Link) plugin jar files"> </target> <target name="jar-gmgen-plugins" depends="makeplugindirs" description="Build (Link) GMGen plugin jar files"> @@ -5843,6 +5843,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/LstToken-DEPRECATED-WEAPONAUTO.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/deprecated/WeaponautoLst.class" /> + </patternset> + </fileset> + </jar> </target> <target name="manifest" description="Write the Java manifest"> Modified: Trunk/pcgen/code/src/java/pcgen/core/AbilityUtilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/AbilityUtilities.java 2006-10-03 21:51:30 UTC (rev 1446) +++ Trunk/pcgen/code/src/java/pcgen/core/AbilityUtilities.java 2006-10-04 01:56:03 UTC (rev 1447) @@ -81,7 +81,7 @@ * @param addList * @return the Ability added, or null if Ability was not added to the list. */ - private static Ability addCloneOfAbilityToListwithChoices( + public static Ability addCloneOfAbilityToListwithChoices( final Ability anAbility, final List<String> choices, final List<Ability> addList) @@ -115,7 +115,7 @@ * * @return The Ability processed */ - private static Ability addCloneOfGlobalAbilityToListWithChoices( + public static Ability addCloneOfGlobalAbilityToListWithChoices( final List<Ability> theAbilityList, final String category, final String abilityName) @@ -891,179 +891,187 @@ * @return a List of the Abilities this Character has */ - static public List<Ability> rebuildAutoAbilityList(PlayerCharacter aPc) - { - final List<Ability> autoFeatList; - autoFeatList = new ArrayList<Ability>(); +// static public List<Ability> rebuildAutoAbilityList(PlayerCharacter aPc) +// { +// final List<Ability> autoFeatList; +// autoFeatList = new ArrayList<Ability>(); +// +// // +// // add racial feats +// // +// if ((aPc.getRace() != null) && !PlayerCharacterUtilities.canReassignRacialFeats()) +// { +// final StringTokenizer aTok = new StringTokenizer(aPc.getRace().getFeatList(aPc), Constants.PIPE); +// +// while (aTok.hasMoreTokens()) +// { +// Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, Constants.FEAT_CATEGORY, aTok.nextToken()); +// if ( added != null ) +// { +// added.setFeatType(Ability.Nature.AUTOMATIC); +// } +// } +// } +// +// for (PCClass aClass : aPc.getClassList()) +// { +// for (Iterator<String> e1 = aClass.getFeatAutos().iterator(); e1.hasNext();) +// { +// // +// // PCClass object have auto feats stored in format: +// // lvl|feat_name +// // +// final String aString = e1.next(); +// +// if (aString.indexOf('|') < 1) +// { +// continue; +// } +// +// final StringTokenizer aTok = new StringTokenizer(aString, "|"); +// int i; +// +// try +// { +// i = Integer.parseInt(aTok.nextToken()); +// } +// catch (NumberFormatException exc) +// { +// continue; +// } +// +// if (i > aClass.getLevel()) +// { +// continue; +// } +// +// String autoFeat = aTok.nextToken(); +// final int idx = autoFeat.indexOf('['); +// +// if (idx >= 0) +// { +// final StringTokenizer bTok = new StringTokenizer(autoFeat.substring(idx + 1), "[]"); +// final List<Prerequisite> preReqList = new ArrayList<Prerequisite>(); +// +// while (bTok.hasMoreTokens()) +// { +// final String prereqString = bTok.nextToken(); +// Logging.debugPrint("Why is the prerequisite '"+prereqString+ +// "' parsed in PlayerCharacter.featAutoList() rather than the persistence layer"); +// try { +// final PreParserFactory factory = PreParserFactory.getInstance(); +// final Prerequisite prereq = factory.parse(prereqString); +// preReqList.add(prereq); +// } +// catch (PersistenceLayerException ple){ +// Logging.errorPrint(ple.getMessage(), ple); +// } +// } +// +// autoFeat = autoFeat.substring(0, idx); +// +// if (preReqList.size() != 0) +// { +// // +// // To avoid possible infinite loop +// // +// if (!aPc.isAutomaticFeatsStable()) +// { +// aPc.setStableAutomaticFeatList(autoFeatList); +// } +// +// if (! PrereqHandler.passesAll(preReqList, aPc, null )) +// { +// continue; +// } +// } +// } +// +// Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, "FEAT", autoFeat); +// if ( added != null ) +// { +// added.setFeatType(Ability.Nature.AUTOMATIC); +// } +// } +// } +// +// if (!PlayerCharacterUtilities.canReassignTemplateFeats() && !aPc.getTemplateList().isEmpty()) +// { +// for (PCTemplate aTemplate : aPc.getTemplateList()) +// { +// aPc.setStableAutomaticFeatList(autoFeatList); +// final List<String> templateFeats = aTemplate.feats(aPc.getTotalLevels(), aPc.totalHitDice(), aPc, false); +// +// if (!templateFeats.isEmpty()) +// { +// for (Iterator<String> e2 = templateFeats.iterator(); e2.hasNext();) +// { +// final String aString = e2.next(); +// final StringTokenizer aTok = new StringTokenizer(aString, ","); +// +// while (aTok.hasMoreTokens()) +// { +// Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, "FEAT", aTok.nextToken()); +// if ( added != null ) +// { +// added.setFeatType(Ability.Nature.AUTOMATIC); +// } +// } +// } +// } +// } +// } +// +// if (!aPc.getCharacterDomainList().isEmpty()) +// { +// for (CharacterDomain aCD : aPc.getCharacterDomainList()) +// { +// final Domain aDomain = aCD.getDomain(); +// +// if (aDomain != null) +// { +// for (int e2 = 0; e2 < aDomain.getAssociatedCount(); ++e2) +// { +// final String aString = aDomain.getAssociated(e2); +// +// if (aString.startsWith("FEAT")) +// { +// final int idx = aString.indexOf('?'); +// +// if (idx > -1) +// { +// Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, "FEAT", aString.substring(idx + 1)); +// if ( added != null ) +// { +// added.setFeatType(Ability.Nature.AUTOMATIC); +// } +// } +// else +// { +// Logging.errorPrint("no '?' in Domain assocatedList entry: " + aString); +// } +// } +// } +// +// final Iterator<Categorisable> anIt = aDomain.getFeatIterator(); +// +// for (; anIt.hasNext();) +// { +// final Ability abI = (Ability)anIt.next(); +// Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, "FEAT", abI.getKeyName()); +// if ( added != null ) +// { +// added.setFeatType(Ability.Nature.AUTOMATIC); +// } +// } +// } +// } +// } +// +//// aPc.setStableAutomaticFeatList(autoFeatList); +// return autoFeatList; +// } - // - // add racial feats - // - if ((aPc.getRace() != null) && !PlayerCharacterUtilities.canReassignRacialFeats()) - { - final StringTokenizer aTok = new StringTokenizer(aPc.getRace().getFeatList(aPc), Constants.PIPE); - - while (aTok.hasMoreTokens()) - { - Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, Constants.FEAT_CATEGORY, aTok.nextToken()); - if ( added != null ) - { - added.setFeatType(Ability.Nature.AUTOMATIC); - } - } - } - - for (PCClass aClass : aPc.getClassList()) - { - for (Iterator<String> e1 = aClass.getFeatAutos().iterator(); e1.hasNext();) - { - // - // PCClass object have auto feats stored in format: - // lvl|feat_name - // - final String aString = e1.next(); - - if (aString.indexOf('|') < 1) - { - continue; - } - - final StringTokenizer aTok = new StringTokenizer(aString, "|"); - int i; - - try - { - i = Integer.parseInt(aTok.nextToken()); - } - catch (NumberFormatException exc) - { - continue; - } - - if (i > aClass.getLevel()) - { - continue; - } - - String autoFeat = aTok.nextToken(); - final int idx = autoFeat.indexOf('['); - - if (idx >= 0) - { - final StringTokenizer bTok = new StringTokenizer(autoFeat.substring(idx + 1), "[]"); - final List<Prerequisite> preReqList = new ArrayList<Prerequisite>(); - - while (bTok.hasMoreTokens()) - { - final String prereqString = bTok.nextToken(); - Logging.debugPrint("Why is the prerequisite '"+prereqString+ - "' parsed in PlayerCharacter.featAutoList() rather than the persistence layer"); - try { - final PreParserFactory factory = PreParserFactory.getInstance(); - final Prerequisite prereq = factory.parse(prereqString); - preReqList.add(prereq); - } - catch (PersistenceLayerException ple){ - Logging.errorPrint(ple.getMessage(), ple); - } - } - - autoFeat = autoFeat.substring(0, idx); - - if (preReqList.size() != 0) - { - // - // To avoid possible infinite loop - // - if (!aPc.isAutomaticFeatsStable()) - { - aPc.setStableAutomaticFeatList(autoFeatList); - } - - if (! PrereqHandler.passesAll(preReqList, aPc, null )) - { - continue; - } - } - } - - Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, "FEAT", autoFeat); - added.setFeatType(Ability.Nature.AUTOMATIC); - } - } - - if (!PlayerCharacterUtilities.canReassignTemplateFeats() && !aPc.getTemplateList().isEmpty()) - { - for (PCTemplate aTemplate : aPc.getTemplateList()) - { - aPc.setStableAutomaticFeatList(autoFeatList); - final List<String> templateFeats = aTemplate.feats(aPc.getTotalLevels(), aPc.totalHitDice(), aPc, false); - - if (!templateFeats.isEmpty()) - { - for (Iterator<String> e2 = templateFeats.iterator(); e2.hasNext();) - { - final String aString = e2.next(); - final StringTokenizer aTok = new StringTokenizer(aString, ","); - - while (aTok.hasMoreTokens()) - { - Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, "FEAT", aTok.nextToken()); - added.setFeatType(Ability.Nature.AUTOMATIC); - } - } - } - } - } - - if (!aPc.getCharacterDomainList().isEmpty()) - { - for (CharacterDomain aCD : aPc.getCharacterDomainList()) - { - final Domain aDomain = aCD.getDomain(); - - if (aDomain != null) - { - for (int e2 = 0; e2 < aDomain.getAssociatedCount(); ++e2) - { - final String aString = aDomain.getAssociated(e2); - - if (aString.startsWith("FEAT")) - { - final int idx = aString.indexOf('?'); - - if (idx > -1) - { - Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, "FEAT", aString.substring(idx + 1)); - added.setFeatType(Ability.Nature.AUTOMATIC); - } - else - { - Logging.errorPrint("no '?' in Domain assocatedList entry: " + aString); - } - } - } - - final Iterator<Categorisable> anIt = aDomain.getFeatIterator(); - - for (; anIt.hasNext();) - { - final Ability abI = (Ability)anIt.next(); - Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, "FEAT", abI.getKeyName()); - added.setFeatType(Ability.Nature.AUTOMATIC); - } - } - } - } - - // Need to save current as stable as getAutoWeaponProfs() needs it - - aPc.setStableAutomaticFeatList(autoFeatList); - aPc.getAutoWeaponProfs(autoFeatList); - aPc.setStableAutomaticFeatList(autoFeatList); - return autoFeatList; - } - /** * This method attempts to get an Ability Object from the Global Store keyed * by token. If this fails, it checks if token has info in parenthesis Modified: Trunk/pcgen/code/src/java/pcgen/core/AssociatedChoice.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/AssociatedChoice.java 2006-10-03 21:51:30 UTC (rev 1446) +++ Trunk/pcgen/code/src/java/pcgen/core/AssociatedChoice.java 2006-10-04 01:56:03 UTC (rev 1447) @@ -42,7 +42,7 @@ /** The "default" key to allow functionality to pretend it is a single * string value. */ - public static final String DEFAULT_KEY = "CHOICE"; + public static final String DEFAULT_KEY = "CHOICE"; //$NON-NLS-1$ /** * Empty constructor. No choices are associated yet. @@ -171,6 +171,13 @@ return choices.size(); } + /** + * Compares two choices. + * + * @param o The choice to compare with. + * @return See compareTo + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ public int compareTo(Object o) { AssociatedChoice<T> other = (AssociatedChoice<T>)o; Modified: Trunk/pcgen/code/src/java/pcgen/core/PCClass.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2006-10-03 21:51:30 UTC (rev 1446) +++ Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2006-10-04 01:56:03 UTC (rev 1447) @@ -2404,37 +2404,37 @@ if (lp.getLevel() <= level) { final Equipment weapon = (Equipment) lp.getObject(); tempArray.add(weapon); - addWeaponProfAutos(weapon.getName()); +// addWeaponProfAutos(weapon.getName()); } } return tempArray; } - /* - * (non-Javadoc) - * - * @see pcgen.core.PObject#getWeaponProfAutos() - */ - public List<String> getWeaponProfAutos() { - // first build up the list of the standard auto weapon profs - final List<String> list = super.getWeaponProfAutos(); +// /* +// * (non-Javadoc) +// * +// * @see pcgen.core.PObject#getWeaponProfAutos() +// */ +// public List<String> getWeaponProfAutos() { +// // first build up the list of the standard auto weapon profs +// final List<String> list = super.getWeaponProfAutos(); +// +// // then add in the proficiencies for each natural weapon +// // we have active. +// if (naturalWeapons != null) { +// for (Iterator<LevelProperty> li = naturalWeapons.iterator(); li +// .hasNext();) { +// final LevelProperty lp = li.next(); +// if (lp.getLevel() <= level) { +// final Equipment weapon = (Equipment) lp.getObject(); +// list.add(weapon.getSimpleName()); +// } +// } +// } +// return list; +// } - // then add in the proficiencies for each natural weapon - // we have active. - if (naturalWeapons != null) { - for (Iterator<LevelProperty> li = naturalWeapons.iterator(); li - .hasNext();) { - final LevelProperty lp = li.next(); - if (lp.getLevel() <= level) { - final Equipment weapon = (Equipment) lp.getObject(); - list.add(weapon.getSimpleName()); - } - } - } - return list; - } - public boolean isQualified(final PlayerCharacter aPC) { if (aPC == null) { @@ -4657,7 +4657,8 @@ aPC.getSkillList().clear(); aPC.clearRealAbilities(null); // aPC.clearRealFeats(); - aPC.getWeaponProfList().clear(); +// aPC.getWeaponProfList().clear(); + aPC.setDirty(true); } else { aPC.setSkillPoints(aPC.getSkillPoints() - spMod); skillPool = skillPool() - spMod; @@ -5689,7 +5690,7 @@ final int l = aPC.getCharacterDomainIndex(subKey); if (l > -1) { - aPC.getCharacterDomainList().remove(l); + aPC.removeCharacterDomain(subKey); } } else if (adding && addNow && (subKey.length() > 0)) { if (aPC.getCharacterDomainIndex(subKey) == -1) { Modified: Trunk/pcgen/code/src/java/pcgen/core/PObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2006-10-03 21:51:30 UTC (rev 1446) +++ Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2006-10-04 01:56:03 UTC (rev 1447) @@ -391,7 +391,7 @@ public final String getDescription() { String characteristic = stringChar.get(StringKey.DESCRIPTION); - return characteristic == null ? "" : characteristic; + return characteristic == null ? Constants.EMPTY_STRING : characteristic; } /** @@ -649,7 +649,7 @@ public final String getTempDescription() { String characteristic = stringChar.get(StringKey.TEMP_DESCRIPTION); - return characteristic == null ? "" : characteristic; + return characteristic == null ? Constants.EMPTY_STRING : characteristic; } /** @@ -749,60 +749,60 @@ return Collections.emptyList(); } - /** - * Add automatic weapon proficienies for this object - * @param aString - */ - public final void addWeaponProfAutos(final String aString) - { - final StringTokenizer aTok = new StringTokenizer(aString, "|"); +// /** +// * Add automatic weapon proficienies for this object +// * @param aString +// */ +// public final void addWeaponProfAutos(final String aString) +// { +// final StringTokenizer aTok = new StringTokenizer(aString, "|"); +// +// ListKey<String> weaponProfListKey = ListKey.WEAPON_PROF; +// +// while (aTok.hasMoreTokens()) +// { +// final String bString = aTok.nextToken(); +// +// if (".CLEAR".equals(bString)) +// { +// listChar.removeListFor(weaponProfListKey); +// } +// else if (bString.startsWith("TYPE=") || bString.startsWith("TYPE.")) +// { +// final Collection<WeaponProf> weaponProfsOfType = Globals.getAllWeaponProfsOfType(bString.substring(5)); +// if (weaponProfsOfType != null) +// { +// for (Iterator<WeaponProf> e = weaponProfsOfType.iterator(); e.hasNext();) +// { +// final String cString = e.next().getKeyName(); +// +// if (!containsInList(weaponProfListKey, cString)) +// { +// listChar.addToListFor(weaponProfListKey, cString); +// } +// } +// } +// } +// else +// { +// if (!containsInList(weaponProfListKey, bString)) +// { +// listChar.addToListFor(weaponProfListKey, bString); +// } +// } +// } +// } - ListKey<String> weaponProfListKey = ListKey.WEAPON_PROF; +// /** +// * Get the automatic weapon proficiencies for this object +// * @return the automatic weapon proficiencies for this object +// */ +// public List<String> getWeaponProfAutos() +// { +// return getSafeListFor(ListKey.WEAPON_PROF); +// } - while (aTok.hasMoreTokens()) - { - final String bString = aTok.nextToken(); - - if (".CLEAR".equals(bString)) - { - listChar.removeListFor(weaponProfListKey); - } - else if (bString.startsWith("TYPE=") || bString.startsWith("TYPE.")) - { - final Collection<WeaponProf> weaponProfsOfType = Globals.getAllWeaponProfsOfType(bString.substring(5)); - if (weaponProfsOfType != null) - { - for (Iterator<WeaponProf> e = weaponProfsOfType.iterator(); e.hasNext();) - { - final String cString = e.next().getKeyName(); - - if (!containsInList(weaponProfListKey, cString)) - { - listChar.addToListFor(weaponProfListKey, cString); - } - } - } - } - else - { - if (!containsInList(weaponProfListKey, bString)) - { - listChar.addToListFor(weaponProfListKey, bString); - } - } - } - } - /** - * Get the automatic weapon proficiencies for this object - * @return the automatic weapon proficiencies for this object - */ - public List<String> getWeaponProfAutos() - { - return getSafeListFor(ListKey.WEAPON_PROF); - } - - /** * Add the collection passed in to the associated list for this object * @param collection */ @@ -1256,8 +1256,7 @@ } /** - * Add a natural weapon to the character list, also adds the - * appropriate weapon proficiency. + * Add a natural weapon to the character list. * * @param weapon * @param level @@ -1265,7 +1264,6 @@ public void addNaturalWeapon(final Equipment weapon, final int level) { listChar.addToListFor(ListKey.NATURAL_WEAPONS, weapon); - addWeaponProfAutos( weapon.getSimpleName() ); } /** @@ -1308,6 +1306,7 @@ * @return cloned object * @throws CloneNotSupportedException */ + @Override public Object clone() throws CloneNotSupportedException { final PObject retVal = (PObject) super.clone(); @@ -1409,6 +1408,11 @@ return retVal; } + /** + * Compares the keys of the object. + * + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ public int compareTo(final Object obj) { if (obj != null) @@ -1419,6 +1423,9 @@ return 1; } + /** + * @see java.lang.Object#equals(java.lang.Object) + */ @Override public boolean equals( final Object obj ) { @@ -1457,7 +1464,7 @@ public final String getChoiceString() { String characteristic = stringChar.get(StringKey.CHOICE_STRING); - return characteristic == null ? "" : characteristic; + return characteristic == null ? Constants.EMPTY_STRING : characteristic; } /** @@ -1532,7 +1539,7 @@ */ public String getQualifiedKey() { - return ""; + return Constants.EMPTY_STRING; } /** @@ -1647,7 +1654,7 @@ public final String getQualifyString() { String characteristic = stringChar.get(StringKey.QUALIFY); - return characteristic == null ? "" : characteristic; + return characteristic == null ? Constants.EMPTY_STRING : characteristic; } /** @@ -3171,7 +3178,7 @@ * @param aPC * @param expandWeaponTypes */ - public final void addAutoTagsToList(final String tag, final AbstractCollection aList, final PlayerCharacter aPC, boolean expandWeaponTypes) + public final void addAutoTagsToList(final String tag, final Collection aList, final PlayerCharacter aPC, boolean expandWeaponTypes) { for (Iterator<String> i = getSafeListFor(ListKey.AUTO_ARRAY).iterator(); i.hasNext();) { @@ -3968,8 +3975,7 @@ { if ( weaponProfBonus == null ) { - final List<String> ret = Collections.emptyList(); - return Collections.unmodifiableList(ret); + return Collections.emptyList(); } return Collections.unmodifiableList(weaponProfBonus); } Modified: Trunk/pcgen/code/src/java/pcgen/core/PObjectUtilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObjectUtilities.java 2006-10-03 21:51:30 UTC (rev 1446) +++ Trunk/pcgen/code/src/java/pcgen/core/PObjectUtilities.java 2006-10-04 01:56:03 UTC (rev 1447) @@ -59,2518 +59,2518 @@ public class PObjectUtilities { - /** - * @param anAbility - * @return true or false - */ - private static int chooseAbility(final Ability anAbility) - { - int i; - final List aList = new ArrayList(); - aList.add("New"); +// /** +// * @param anAbility +// * @return true or false +// */ +// private static int chooseAbility(final Ability anAbility) +// { +// int i; +// final List aList = new ArrayList(); +// aList.add("New"); +// +// FeatMultipleChoice fmc; +// final StringBuffer sb = new StringBuffer(100); +// for (int j = 0; j < anAbility.getAssociatedCount(); ++j) +// { +// fmc = (FeatMultipleChoice) anAbility.getAssociatedList().get(j); +// sb.append(anAbility.getKeyName()).append(" ("); +// sb.append(fmc.getChoiceCount()); +// sb.append(" of ").append(fmc.getMaxChoices()).append(") "); +// +// for (i = 0; i < fmc.getChoiceCount(); ++i) +// { +// if (i != 0) +// { +// sb.append(','); +// } +// +// sb.append(fmc.getChoice(i)); +// } +// +// aList.add(sb.toString()); +// sb.setLength(0); +// } +// +// final Object selectedValue; +// +// if (aList.size() > 1) +// { +// final InputInterface ii = InputFactory.getInputInstance(); +// selectedValue = ii.showInputDialog(null, +// "Please select the instance of the feat you wish to" + Constants.s_LINE_SEP +// + "modify, or New, from the list below.", Constants.s_APPNAME, +// MessageType.INFORMATION, aList.toArray(), aList.get(0)); +// } +// else +// { +// selectedValue = aList.get(0); +// } +// +// if (selectedValue == null) +// { +// return -1; +// } +// +// return aList.indexOf(selectedValue); +// } - FeatMultipleChoice fmc; - final StringBuffer sb = new StringBuffer(100); - for (int j = 0; j < anAbility.getAssociatedCount(); ++j) - { - fmc = (FeatMultipleChoice) anAbility.getAssociatedList().get(j); - sb.append(anAbility.getKeyName()).append(" ("); - sb.append(fmc.getChoiceCount()); - sb.append(" of ").append(fmc.getMaxChoices()).append(") "); - - for (i = 0; i < fmc.getChoiceCount(); ++i) - { - if (i != 0) - { - sb.append(','); - } - - sb.append(fmc.getChoice(i)); - } - - aList.add(sb.toString()); - sb.setLength(0); - } - - final Object selectedValue; - - if (aList.size() > 1) - { - final InputInterface ii = InputFactory.getInputInstance(); - selectedValue = ii.showInputDialog(null, - "Please select the instance of the feat you wish to" + Constants.s_LINE_SEP - + "modify, or New, from the list below.", Constants.s_APPNAME, - MessageType.INFORMATION, aList.toArray(), aList.get(0)); - } - else - { - selectedValue = aList.get(0); - } - - if (selectedValue == null) - { - return -1; - } - - return aList.indexOf(selectedValue); - } - - /** - * Deal with CHOOSE tag processing - * - * @param obj - * @param availableList - * @param selectedList - * @param process - * @param aPC - * @param addIt - * @return boolean - */ - public static final boolean modChoices( - final PObject obj, - List availableList, - final List selectedList, - final boolean process, - final PlayerCharacter aPC, - final boolean addIt) - { - availableList.clear(); - selectedList.clear(); - - final String aChoiceString = obj.getChoiceString(); - if (aChoiceString.startsWith("WEAPONPROF|") || - aChoiceString.startsWith("ARMORPROF|") || - aChoiceString.startsWith("SHIELDPROF|")) - { - obj.getChoices(aChoiceString, availableList, selectedList, aPC); - - return false; - } - - StringTokenizer aTok = new StringTokenizer(aChoiceString, "|"); - - if ((aTok.countTokens() < 1) || (aPC == null) || aPC.isImporting()) - { - return false; - } - - int numChoices = -1; - - double cost = 1.0; - Ability ability = null; - boolean stacks = false; - boolean multiples = false; - - if (obj instanceof Ability) - { - ability = (Ability) obj; - cost = ability.getCost(); - stacks = ability.isStacks(); - multiples = ability.isMultiples(); - } - - int i; - int maxSelections = (int) ((aPC.getFeats() + obj.getAssociatedCount()) / cost); - - if (cost <= 0) - { - maxSelections = (int) (aPC.getFeats() + obj.getAssociatedCount()); - } - - final List uniqueList = new ArrayList(); - final List aBonusList = new ArrayList(); - final List rootArrayList = new ArrayList(); - String choiceType = aTok.nextToken(); - - Iterator iter; - String title = "Choices"; - - int idxSelected = -1; - - int maxNewSelections = (int) (aPC.getFeats() / cost); - - if (cost <= 0) - { - maxNewSelections = (int) (aPC.getRawFeats(false)); - } - - int requestedSelections = -1; -//////////////////////////////// -// This was moved into its own subroutine, but Java is NOT call-by-reference, so it broke both -// COUNT=, and NUMCHOICES= so I am re-instating it. -// Here is a semi-decent article on Java and parameters http://javadude.com/articles/passbyvalue.htm -// - Byngl Oct 4, 2005 +// /** +// * Deal with CHOOSE tag processing +// * +// * @param obj +// * @param availableList +// * @param selectedList +// * @param process +// * @param aPC +// * @param addIt +// * @return boolean +// */ +// public static final boolean modChoices( +// final PObject obj, +// List availableList, +// final List selectedList, +// final boolean process, +// final PlayerCharacter aPC, +// final boolean addIt) +// { +// availableList.clear(); +// selectedList.clear(); // - for (; ;) - { - if (choiceType.startsWith("COUNT=")) - { - requestedSelections = aPC.getVariableValue(choiceType.substring(6), "").intValue(); - } - else if (choiceType.startsWith("NUMCHOICES=")) - { - // - // If removing, then don't allow an extra 'freebie' (and force the user to enter it) - // - if (addIt) - { - numChoices = aPC.getVariableValue(choiceType.substring(11), "").intValue(); - } - } - else - { - break; - } - if (!aTok.hasMoreTokens()) - { - Logging.errorPrint("not enough tokens: " + aChoiceString); - - return false; - } - - choiceType = aTok.nextToken(); - } -//////////////////////////////// - if (Globals.weaponTypesContains(choiceType)) - { - title = choiceType + " Weapon Choice"; - setWeaponProfTypeSelections(obj, availableList, selectedList, aPC, choiceType); - } - - else if ("ARMORTYPE".equals(choiceType)) - { - title = "Armor Type Choice"; - setArmorTypeSelections(obj, availableList, selectedList, aPC); - } - else if ("CSKILLS".equals(choiceType)) - { - title = "Skill Choice"; - setCSkillsSelections(obj, availableList, selectedList, aPC); - } - else if ("DOMAIN".equals(choiceType)) - { - title = "Domain Choice"; - setDomainSelections(obj, availableList, selectedList, aPC, aTok); - } - else if ("EQUIPTYPE".equals(choiceType)) - { - title = "Equipment Choice"; - setEquipTypeSelections(obj, availableList, selectedList, aTok); - } - else if ("FEATADD".equals(choiceType)) - { - title = "Add a Feat"; - ability = setFeatAddSelections(availableList, selectedList, aPC, aTok); - } - else if ("FEATLIST".equals(choiceType)) - { - setFeatListSelections(obj, availableList, selectedList, aPC, aTok, stacks); - } - else if (choiceType.startsWith("FEAT=") || choiceType.startsWith("FEAT.")) - { - setFeatSelections(obj, availableList, selectedList, aPC, choiceType); - } - else if ("FEATSELECT".equals(choiceType)) - { - setFeatSelectSelections(obj, availableList, selectedList, aPC, aTok, stacks); - } - else if ("HP".equals(choiceType)) - { - setHPSelections(obj, availableList, selectedList, aTok); - } - else if ("PROFICIENCY".equals(choiceType)) - { - title = "Choose Proficiency"; - setProficiencySelections(obj, availableList, selectedList, aTok, aPC); - } - else if ("RACE".equals(choiceType)) - { - title = "Choose Race"; - setRaceSelections(obj, availableList, selectedList, aTok); - } - else if ("SALIST".equals(choiceType)) - { - // SALIST:Smite|VAR|%|1 - title = "Special Ability Choice"; - setSAListSelections(obj, availableList, selectedList, aPC, aChoiceString, aBonusList); - } - else if ("SCHOOLS".equals(choiceType)) - { - title = "School Choice"; - setSchoolsSelections(obj, availableList, selectedList); - } - else if ( - "SKILLLIST".equals(choiceType) || - "CCSKILLLIST".equals(choiceType) || - "NONCLASSSKILLLIST".equals(choiceType)) - { - title = "Skill Choice"; - setSkillListSelections( - obj, availableList, selectedList, - aPC, aTok, rootArrayList, choiceType); - } - else if ( - "SKILLSNAMED".equals(choiceType) || - "SKILLSNAMEDTOCSKILL".equals(choiceType) || - "SKILLSNAMEDTOCCSKILL".equals(choiceType)) - { - // SKILLSNAMEDTOCSKILL --- Make one of the named skills a class skill. - title = "Skill Choice"; - setSkillsNamedSelections(obj, availableList, selectedList, aPC, aTok); - } - else if ("SKILLS".equals(choiceType)) - { - title = "Skill Choice"; - setSkillsSelections(obj, availableList, selectedList, aPC); - } - else if ("SPELLCLASSES".equals(choiceType)) - { - title = "Spellcaster Classes"; - setSpellClassesSelections(obj, availableList, selectedList, aPC); - } - else if ("SPELLLEVEL".equals(choiceType)) - { - setSpellLevelSelections( - obj, availableList, selectedList, - process, aPC, aChoiceString, uniqueList, aBonusList); - } - else if ("SPELLLIST".equals(choiceType)) - { - title = "Spell Choice"; - if (process && (ability != null)) - { - idxSelected = chooseAbility(ability); - if (idxSelected < 0) - { - return false; - } - --idxSelected; - } - - maxNewSelections = - setSpellListSelections(obj, availableList, selectedList, aPC, aTok, idxSelected); - // Set up remaining choices for pre-existing selection - - if (idxSelected >= 0) - { - final FeatMultipleChoice fmc = (FeatMultipleChoice) obj.getAssociatedObject(idxSelected); - maxNewSelections = fmc.getMaxChoices(); - requestedSelections = maxNewSelections; - } - } - else if ("SPELLS".equals(choiceType)) - { - setSpellsSelection(obj, availableList, selectedList, aTok); - } - else if ("STAT".equals(choiceType)) - { - // CHOOSE:COUNT=1|STAT|Con - title = "Stat Choice"; - setStatSelections(obj, availableList, selectedList, aTok); - } - else if ("WEAPONFOCUS".equals(choiceType)) - { - title = "Weapon Focus Choice"; - setWeaponFocusSelections(obj, availableList, selectedList, aPC, aTok); - } - else if ("WEAPONPROFS".equals(choiceType)) - { - title = "Weapon Prof Choice"; - setWeaponProfSelections(obj, availableList, selectedList, aPC, aTok); - } - else - { - title = "Selections"; - setMiscSelections(obj, availableList, selectedList, aTok, stacks, choiceType); - } - - if (!process) - { - return false; - } - - /* XXX Start of do the chooser bit */ - - if (requestedSelections < 0) - { - requestedSelections = maxNewSelections; - } - else - { - requestedSelections -= selectedList.size(); - requestedSelections = Math.min(requestedSelections, maxNewSelections); - } - - final int preSelectedSize = selectedList.size(); - - if (numChoices > 0) - { - // Make sure that we don't try to make the user choose more selections - // than are available or we'll be in an infinite loop... - - numChoices = Math.min(numChoices, availableList.size() - preSelectedSize); - requestedSelections = numChoices; - } - - boolean bNoChoice = false; - if (availableList.size() == 1) - { - if ("NOCHOICE".equals(availableList.get(0).toString())) - { - if (!addIt) - { - try - { - selectedList.remove(0); - } - catch (IndexOutOfBoundsException ioobe) - { - // ignore - } - } - else - { - selectedList.add(""); - } - bNoChoice = true; - numChoices = 0; // Make sure we are processing only 1 selection - } - } - - final ChooserInterface chooser = ChooserFactory.getChooserInstance(); - chooser.setPoolFlag(false); // user is not required to make any changes - chooser.setAllowsDups(stacks); // only stackable feats can be duped - chooser.setVisible(false); - chooser.setPool(requestedSelections); - - title = title + " (" + obj.getDisplayName() + ')'; - chooser.setTitle(title); - Globals.sortChooserLists(availableList, selectedList); - - while (true) - { - chooser.setAvailableList(availableList); - chooser.setSelectedList(selectedList); - if (!bNoChoice) - { - chooser.setVisible(true); - } - - final int selectedSize = chooser.getSelectedList().size() - preSelectedSize; - - if (numChoices > 0) - { - if (selectedSize != numChoices) - { - ShowMessageDelegate.showMessageDialog("You must make " + - (numChoices - selectedSize) + " more selection(s).", - Constants.s_APPNAME, MessageType.INFORMATION); - continue; - } - } - - break; - } - - /* XXX end of choosy bit, now deal with the choices XXX */ - - if ("SPELLLIST".equals(choiceType)) - { - if (idxSelected >= 0) - { - obj.removeAssociated(idxSelected); - - if (chooser.getSelectedList().size() == 0) - { - aPC.adjustFeats(1); - } - } - else if (chooser.getSelectedList().size() != 0) - { - aPC.adjustFeats(-1); - } - } - else if ("SALIST".equals(choiceType)) - { - // remove previous selections from special abilities - // aBonusList contains all possible selections in form: <displayed info>|<special ability> - for (int e = 0; e < obj.getAssociatedCount(); ++e) - { - final String aString = obj.getAssociated(e); - final String prefix = aString + "|"; - - for (int x = 0; x < aBonusList.size(); ++x) - { - final String bString = (String) aBonusList.get(x); - - if (bString.startsWith(prefix)) - { - obj.removeBonus(bString.substring(bString.indexOf('|') + 1), "", aPC); - - break; - } - } - } - } - else if ("SPELLLEVEL".equals(choiceType)) - { - // remove previous selections from bonuses - // aBonusList contains the bonuses - for (int e = 0; e < obj.getAssociatedCount(); ++e) - { - final String aString = obj.getAssociated(e); - - for (Iterator bonusIter = aBonusList.iterator(); bonusIter - .hasNext();) - { - String bonus = (String) bonusIter.next(); - obj.removeBonus(bonus, aString, aPC); - } - } - obj.clearAssociated(); - - } - - if ("SKILLSNAMEDTOCSKILL".equals(choiceType)) - { - for (iter = ability.getCSkillList().iterator(); iter.hasNext();) - { - final String tempString = (String) iter.next(); - - if (!"LIST".equals(tempString)) - { - String tempKey = obj.getKeyName(); - final Ability tempAbility = Globals.getAbilityKeyed("FEAT", tempKey); - - if (tempAbility != null) - { - if (tempAbility.getCSkillList() != null) - { - if (tempAbility.getCSkillList().contains(tempString)) - { - iter.remove(); - } - } - } - } - } - - ability.clearCcSkills(); - } - - if (!"SPELLLIST".equals(choiceType) && !"SPELLLEVEL".equals(choiceType)) - { - obj.clearAssociated(); - } - - String objPrefix = ""; - - if (obj instanceof Domain) - { - objPrefix = choiceType + '?'; - } - - FeatMultipleChoice fmc = null; - if (obj instanceof Ability) { - ((Ability)obj).clearSelectedWeaponProfBonus(); //Cleans up the feat - } - - for (i = 0; i < chooser.getSelectedList().size(); ++i) - { - final String chosenItem = (String) chooser.getSelectedList().get(i); - - if ("HP".equals(choiceType)) - { - //obj.addAssociated(objPrefix + "CURRENTMAX"); - obj.addAssociated(objPrefix + chosenItem); - } - else if ("SPELLLEVEL".equals(choiceType)) - { - for (Iterator e = aBonusList.iterator(); e.hasNext();) - { - final String bString = (String) e.next(); - obj.addAssociated(objPrefix + chosenItem); - obj.applyBonus(bString, chosenItem, aPC); - } - } - else if ("SPELLLIST".equals(choiceType)) - { - if (fmc == null) - { - fmc = new FeatMultipleChoice(); - fmc.setMaxChoices(maxNewSelections); - obj.addAssociated(fmc); - } - - fmc.addChoice(chosenItem); - } - else if ("ARMORTYPE".equals(choiceType)) - { - for (Iterator e = aBonusList.iterator(); e.hasNext();) - { - final String bString = (String) e.next(); - obj.addAssociated(objPrefix + chosenItem); - obj.applyBonus("ARMORPROF=" + bString, chosenItem, aPC); - } - } - else if (multiples && !stacks) - { - if (!obj.containsAssociated(objPrefix + chosenItem)) - { - obj.addAssociated(objPrefix + chosenItem); - } - } - else - { - final String prefix = chosenItem + "|"; - obj.addAssociated(objPrefix + chosenItem); - - // SALIST: aBonusList contains all possible selections in form: <displayed info>|<special ability> - for (int x = 0; x < aBonusList.size(); ++x) - { - final String bString = (String) aBonusList.get(x); - - if (bString.startsWith(prefix)) - { - obj.addBonusList(bString.substring(bString.indexOf('|') + 1)); - - break; - } - } - } - - if (ability != null) - { - if ("SKILLLIST".equals(choiceType) || "SKILLSNAMEDTOCSKILL".equals(choiceType) - || "NONCLASSSKILLLIST".equals(choiceType)) - { - if (rootArrayList.contains(chosenItem)) - { - for (Iterator e2 = Globals.getSkillList().iterator(); e2.hasNext();) - { - final Skill skill = (Skill) e2.next(); - - if (skill.getRootName().equalsIgnoreCase(chosenItem)) - { - ability.addCSkill(skill.getKeyName()); - } - } - } - else - { - ability.addCSkill(chosenItem); - } - } - else if ("CCSKILLLIST".equals(choiceType) || "SKILLSNAMEDTOCCSKILL".equals(choiceType)) - { - if (rootArrayList.contains(chosenItem)) - { - for (Iterator e2 = Globals.getSkillList().iterator(); e2.hasNext();) - { - final Skill skill = (Skill) e2.next(); - - if (skill.getRootName().equalsIgnoreCase(chosenItem)) - { - ability.addCcSkill(skill.getKeyName()); - } - } - } - else - { - ability.addCcSkill(chosenItem); - } - } - else if ("FEATADD".equals(choiceType)) - { - if (!aPC.hasRealFeatNamed(chosenItem)) - { - aPC.adjustFeats(1); - } - - AbilityUtilities.modFeat(aPC, null, chosenItem, true, false); - } - } - if (Globals.weaponTypesContains(choiceType)) - { - // TODO This should go away if we ever depricate the - // CHOOSE:<weapon_type> syntax - boomer70 - obj.addAutoArray("WEAPONPROF|" + chosenItem); - } - } - - if (!"SPELLLIST".equals(choiceType)) - { - double featCount = aPC.getFeats(); - if (numChoices > 0) - { - if (cost > 0) - { - featCount -= cost; - } - } - else - { - if (cost > 0) - { - featCount = ((maxSelections - selectedList.size()) * cost); - } - } - - aPC.adjustFeats(featCount - aPC.getFeats()); - } - - // This will get assigned by autofeat (if a feat) - - if (objPrefix.length() != 0) - { - aPC.setAutomaticAbilitiesStable(null, false); -// aPC.setAutomaticFeatsStable(false); - } - - return true; - } - - /** - * @param obj - * @param availableList - * @param selectedList - * @param aPC - */ - private static void setArmorTypeSelections( - final PObject obj, - final List availableList, - final List selectedList, - final PlayerCharacter aPC) - { - String temptype; - - for (Iterator it = Globals.getAbilityKeyIterator("FEAT"); it.hasNext(); ) { - final Ability tempAbility = (Ability) it.next(); - - if (tempAbility.getKeyName().startsWith("Armor Proficiency (")) - { - final int idxbegin = tempAbility.getKeyName().indexOf("("); - final int idxend = tempAbility.getKeyName().indexOf(")"); - temptype = tempAbility.getKeyName().substring((idxbegin + 1), idxend); - - if (aPC.getFeatKeyed(tempAbility.getKeyName()) != null) - { - availableList.add(temptype); - } - } - } - - obj.addAssociatedTo(selectedList); - } - - /** - * @param obj - * @param availableList - * @param selectedList - * @param aPC - */ - private static void setCSkillsSelections( - final PObject obj, - final List availableList, - final List selectedList, - final PlayerCharacter aPC) - { - Iterator iter; - Skill aSkill; - - for (iter = Globals.getSkillList().iterator(); iter.hasNext();) - { - aSkill = (Skill) iter.next(); - - if (aSkill.costForPCClassList(aPC.getClassList(), aPC) == Globals.getGameModeSkillCost_Class()) - { - availableList.add(aSkill.getKeyName()); - } - } - - obj.addAssociatedTo(selectedList); - } - - private static void setRaceSelections( - final PObject obj, - final List availableList, - final List selectedList, - StringTokenizer aTok) - { - // CHOOSE:RACE|RACETYPE=x,RACESUBTYPE=y,<racename>,TYPE=z - // or CHOOSE:RACE|[RACETYPE=x,RACESUBTYPE=y] - Collection races = Globals.getAllRaces(); - - while (aTok.hasMoreTokens()) - { - String choice = aTok.nextToken(); - // All top-level comma-separated items are added to the list. - if (choice.indexOf("[") != -1) - { - ArrayList raceTypes = new ArrayList(); - ArrayList raceSubTypes = new ArrayList(); - ArrayList types = new ArrayList(); - - choice = choice.substring(1,choice.length()-1); - StringTokenizer options = new StringTokenizer(choice, ","); - while (options.hasMoreTokens()) - { - String option = options.nextToken(); - if (option.startsWith("RACETYPE=") || option.startsWith("RACETYPE.")) - { - raceTypes.add(option.substring(9)); - } - else if (option.startsWith("RACESUBTYPE=") || option.startsWith("RACESUBTYPE.")) - { - raceSubTypes.add(option.substring(12)); - } - else if (option.startsWith("TYPE=") || option.startsWith("TYPE.")) - { - types.add(option.substring(5)); - } - } - for (Iterator i = races.iterator(); i.hasNext(); ) - { - Race race = (Race) i.next(); - if (checkRace(race, raceTypes, raceSubTypes, types)) - { - availableList.add(race.getKeyName()); - } - } - } - if (choice.startsWith("RACETYPE=") || choice.startsWith("RACETYPE.")) - { - // Add all races matching this racetype - for (Iterator i = races.iterator(); i.hasNext(); ) - { - Race race = (Race) i.next(); - if (race.getRaceType().equals(choice.substring(9))) - { - availableList.add(race.getKeyName()); - } - } - } - else if (choice.startsWith("RACESUBTYPE=") || choice.startsWith("RACESUBTYPE.")) - { - // Add all races matching this racetype - for (Iterator i = races.iterator(); i.hasNext(); ) - { - Race race = (Race) i.next(); - if (race.getRacialSubTypes().contains(choice.substring(9))) - { - availableList.add(race.getKeyName()); - } - } - } - else if (choice.startsWith("TYPE=") || choice.startsWith("TYPE.")) - { - // Add all races matching this racetype - for (Iterator i = races.iterator(); i.hasNext(); ) - { - Race race = (Race) i.next(); - if (race.getType().equals(choice.substring(5))) - { - availableList.add(race.getKeyName()); - } - } - } - else - { - Race race = Globals.getRaceKeyed(choice); - if (race != null) - { - availableList.add(race.getKeyName()); - } - } - } - } - - private static boolean checkRace(Race race, List raceTypes, List raceSubTypes, List types) - { - for (Iterator i = raceTypes.iterator(); i.hasNext(); ) - { - String raceType = (String)i.next(); - if (!race.getRaceType().equals(raceType)) - { - return false; - } - } - for (Iterator i = raceSubTypes.iterator(); i.hasNext(); ) - { - String raceSubType = (String)i.next(); - if (!race.getRacialSubTypes().contains(raceSubType)) - { - return false; - } - } - for (Iterator i = types.iterator(); i.hasNext(); ) - { - String rType = (String)i.next(); - if (!race.getType().equals(rType)) - { - return false; - } - } - return true; - } - - private static void setDomainSelections( - final PObject obj, - final List availableList, - final List selectedList, - final PlayerCharacter aPC, - StringTokenizer aTok) - { - while (aTok.hasMoreTokens()) - { - String option = aTok.nextToken(); - if ("ANY".equals(option)) - { - // returns a list of all loaded Domains. - List domains = Globals.getDomainList(); - for (Iterator i = domains.iterator(); i.hasNext(); ) - { - Domain domain = (Domain)i.next(); - availableList.add(domain.getKeyName()); - } - break; - } - else if ("QUALIFY".equals(option)) - { - // returns a list of loaded Domains the PC qualifies for - // but does not have. - List allDomains = Globals.getDomainList(); - for (Iterator i = allDomains.iterator(); i.hasNext(); ) - { - Domain domain = (Domain)i.next(); - if (domain.qualifiesForDomain(aPC)) - { - boolean found = false; - List pcDomainList = aPC.getCharacterDomainList(); - for (Iterator j = pcDomainList.iterator(); j.hasNext();) - { - CharacterDomain cd = (CharacterDomain)j.next(); - if (domain.equals(cd.getDomain())) - { - found = true; - break; - } - } - if (found == false) - { - availableList.add(domain.getKeyName()); - } - } - } - break; - } - else if ("PC".equals(option)) - { - // returns a list of all domains a character actually has. - List pcDomainList = aPC.getCharacterDomainList(); - for (Iterator i = pcDomainList.iterator(); i.hasNext();) - { - CharacterDomain cd = (CharacterDomain)i.next(); - availableList.add(cd.getDomain().getKeyName()); - } - break; - } - else if (option.startsWith("DEITY")) - { - // returns a list of Domains granted by specified Diety. - String deityKey = option.substring(6); - Deity deity = Globals.getDeityKeyed(deityKey); - if (deity != null) - { - List domainList = deity.getDomainList(); - for (Iterator i = domainList.iterator(); i.hasNext();) - { - Domain domain = (Domain)i.next(); - availableList.add(domain.getKeyName()); - } - } - break; - } - else - { - // returns a list of the specified domains. - Domain domain = Globals.getDomainKeyed(option); - if (domain != null) - { - availableList.add(option); - } - } - } - obj.addAssociatedTo(selectedList); - } - - /** - * @param obj - * @param availableList - * @param selectedList - * @param aTok - */ - private static void setEquipTypeSelections( - final PObject obj, - final List availableList, - final List selectedList, - StringTokenizer aTok) - { - String choiceSec = (aTok.hasMoreTokens()) - ? aTok.nextToken() - : obj.getKeyName(); - - availableList.addAll(EquipmentList.getEquipmentOfType(choiceSec, "")); - obj.addAssociatedTo(selectedList); - } - - /** - * @param availableList - * @param selectedList - * @param aPC - * @param aTok - * @return anAbility - */ - private static Ability setFeatAddSelections( - final List availableList, - final List selectedList, - final PlayerCharacter aPC, - final StringTokenizer aTok) - { - Ability anAbility = null; - while (aTok.hasMoreTokens()) - { - final String aString = aTok.nextToken(); - - if (aString.startsWith("TYPE=") || aString.startsWith("TYPE.")) - { - final String featType = aString.substring(5); - - for (Iterator it = Globals.getAbilityKeyIterator("FEAT"); it.hasNext(); ) - { - final Ability ability = (Ability) it.next(); - - if ( - ability.isType(featType) && - aPC.canSelectAbility(ability) && - !availableList.contains(ability.getKeyName()) - ) { - - availableList.add(ability.getKeyName()); - } - } - } - - else - { - final StringTokenizer bTok = new StringTokenizer(aString, ","); - String featKey = bTok.nextToken().trim(); - String subName = ""; - anAbility = Globals.getAbilityKeyed("FEAT", featKey); - - if (anAbility == null) - { - Logging.errorPrint("Feat not found: " + featKey); - - //return false; - } - - if (!featKey.equalsIgnoreCase(anAbility.getKeyName())) - { - subName = featKey.substring(anAbility.getKeyName().length()); - featKey = anAbility.getKeyName(); - - final int si = subName.indexOf('('); - - if (si > -1) - { - subName = subName.substring(si + 1); - } - } - - if (PrereqHandler.passesAll(anAbility.getPreReqList(), aPC, anAbility)) - { - if (anAbility.isMultiples()) - { - // - // If already have taken the feat, use it so we can remove - // any choices already selected - // - final Ability pcFeat = aPC.getFeatKeyed(featKey); - - if (pcFeat != null) - { - anAbility = pcFeat; - } - - final int percIdx = subName.indexOf('%'); - - if (percIdx > -1) - { - subName = subName.substring(0, percIdx); - } - else if (subName.length() != 0) - { - final int idx = subName.lastIndexOf(')'); - - if (idx > -1) - { - subName = subName.substring(0, idx); - } - } - - final List aavailableList = new ArrayList(); // available list of choices - final List sselectedList = new ArrayList(); // selected list of choices - anAbility.modChoices(aavailableList, sselectedList, false, aPC, true); - - // - // Remove any that don't match - // - if (subName.length() != 0) - { - for (int n = aavailableList.size() - 1; n >= 0; --n) - { - final String bString = (String) aavailableList.get(n); - - if (!bString.startsWith(subName)) - { - aavailableList.remove(n); - } - } - - // - // Example: ADD:FEAT(Skill Focus(Craft (Basketweaving))) - // If you have no ranks in Craft (Basketweaving), the available list will be empty - // - // Make sure that the specified feat is available, even though it does not meet the prerequisite - // - if ((percIdx == -1) && (aavailableList.size() == 0)) - { - aavailableList.add(subName); - } - } - - // - // Remove any already selected - // - if (!anAbility.isStacks()) - { - for (Iterator e = sselectedList.iterator(); e.hasNext();) - { - final int idx = aavailableList.indexOf(e.next().toString()); - - if (idx > -1) - { - aavailableList.remove(idx); - } - } - } - - for (Iterator e = aavailableList.iterator(); e.hasNext();) - { - availableList.add(featKey + "(" + (String) e.next() + ")"); - } - - //return false; - } - else if (!aPC.hasRealFeat(Globals.getAbilityKeyed("FEAT", featKey)) && !aPC.hasFeatAutomatic(featKey)) - { - availableList.add(aString); - } - } - } - } - return anAbility; - } - - /** - * @param obj - * @param availableList - * @param selectedList - * @param aPC - * @param aTok - * @param stacks - */ - private static void setFeatListSelections( - final PObject obj, - final List availableList, - final List selectedList, - final PlayerCharacter aPC, - StringTokenizer aTok, - final boolean stacks) - { - String aString; - - while (aTok.hasMoreTokens()) - { - aString = aTok.nextToken(); - - if (aString.startsWith("TYPE=") || aString.startsWith("TYPE.")) - { - aString = aString.substring(5); - - if (!stacks && availableList.contains(aString)) - { - continue; - } - - for (Iterator e1 = aPC.aggregateFeatList().iterator(); e1.hasNext();) - { - final Ability theFeat = (Ability) e1.next(); - - if (theFeat.isType(aString) - && (stacks || (!stacks && !availableList.contains(theFeat.getKeyName())))) - { - availableList.add(theFeat.getKeyName()); - } - } - } - else if (aPC.getFeatNamed(aString) != null) - { - if (stacks || (!stacks && !availableList.contains(aString))) - { - availableList.add(aString); - } - } - } - obj.addAssociatedTo(selectedList); - } - - /** - * @param obj - * @param availableList - * @param selectedList - * @param aPC - * @param choiceType - */ - private static void setFeatSelections( - final PObject obj, - final List availableList, - final List selectedList, - final PlayerCharacter aPC, - String choiceType) - { - final Ability theFeat = aPC.getFeatNamed(choiceType.substring(5)); - - if (theFeat != null) - { - theFeat.addAssociatedTo(availableList); - } - - obj.addAssociatedTo(selectedList); - } - - /** - * @param obj - * @param availableList - * @param selectedList - * @param aPC - * @param aTok - * @param stacks - */ - private static void setFeatSelectSelections( - final PObject obj, - final List availableList, - final List selectedList, - final PlayerCharacter aPC, - StringTokenizer aTok, - final boolean stacks) - { - obj.addAssociatedTo(selectedList); - - while (aTok.hasMoreTokens()) - { - Stri... [truncated message content] |
From: <jde...@us...> - 2006-10-14 11:42:38
|
Revision: 1471 http://svn.sourceforge.net/pcgen/?rev=1471&view=rev Author: jdempsey Date: 2006-10-14 04:42:27 -0700 (Sat, 14 Oct 2006) Log Message: ----------- Correct natural weapon proficiency processing where the natural weapon is not equipped. Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java Trunk/pcgen/code/testsuite/csheets/CloudGiantHalfDragon.xml Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2006-10-14 06:52:13 UTC (rev 1470) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2006-10-14 11:42:27 UTC (rev 1471) @@ -11877,7 +11877,8 @@ // Equipment for (Equipment eq : getEquipmentList()) { - if (eq.isEquipped()) + // Include natural weapons by default as they have an effect even if not equipped. + if (eq.isEquipped() || eq.isNatural()) { results.add(eq); @@ -11974,6 +11975,10 @@ return aList; } + /** + * @todo Need to confirm that getSkillList is sorted, or switch to brute force search + * @param level + */ private void addNewSkills(final int level) { final List<Skill> addItems = new ArrayList<Skill>(); Modified: Trunk/pcgen/code/testsuite/csheets/CloudGiantHalfDragon.xml =================================================================== --- Trunk/pcgen/code/testsuite/csheets/CloudGiantHalfDragon.xml 2006-10-14 06:52:13 UTC (rev 1470) +++ Trunk/pcgen/code/testsuite/csheets/CloudGiantHalfDragon.xml 2006-10-14 11:42:27 UTC (rev 1471) @@ -1433,7 +1433,7 @@ <!-- Domains --> - <weapon_proficiencies>Axe (Throwing), Battleaxe, Bite, Claw, Club, Crossbow (Heavy), Crossbow (Light), Dagger, Dagger (Punching), Dart, Falchion, Flail, Flail (Heavy), Gauntlet, Gauntlet (Spiked), Glaive, Greataxe, Greatclub, Greatsword, Guisarme, Halberd, Hammer (Light), Handaxe, Javelin, Kukri, Lance, Longbow, Longspear, Longsword, Mace (Heavy), Mace (Light), Morningstar, Pick (Heavy), Pick (Light), Quarterstaff, Ranseur, Rapier, Sap, Scimitar, Scythe, Shieldbash (Heavy), Shieldbash (Light), Shortbow, Shortspear, Sickle, Slam, Sling, Spear, Spells(Ray), Spiked Armor, Sword (Bastard), Sword (Short), Thrown Rock, Trident, Unarmed Strike, Waraxe (Dwarven), Warhammer</weapon_proficiencies> + <weapon_proficiencies>Axe (Throwing), Battleaxe, Bite, Claw, Club, Crossbow (Heavy), Crossbow (Light), Dagger, Dagger (Punching), Dart, Falchion, Flail, Flail (Heavy), Gauntlet, Gauntlet (Spiked), Glaive, Greataxe, Greatclub, Greatsword, Guisarme, Halberd, Hammer (Light), Handaxe, Javelin, Kukri, Lance, Longbow, Longspear, Longsword, Mace (Heavy), Mace (Light), Morningstar, Pick (Heavy), Pick (Light), Quarterstaff, Ranseur, Rapier, Sap, Scimitar, Scythe, Shieldbash (Heavy), Shieldbash (Light), Shortbow, Shortspear, Sickle, Slam, Sling, Spear, Spells(Ray), Spiked Armor, Sword (Bastard), Sword (Short), Trident, Unarmed Strike, Waraxe (Dwarven), Warhammer</weapon_proficiencies> <languages>Giant</languages> <templates> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2006-11-22 07:22:46
|
Revision: 1686 http://svn.sourceforge.net/pcgen/?rev=1686&view=rev Author: jdempsey Date: 2006-11-21 23:22:44 -0800 (Tue, 21 Nov 2006) Log Message: ----------- FReq#1262322 - Ability Object: Output - Add ABILITY export token and its children to output individual abilities Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAllToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAutoToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/VAbilityToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-11-22 03:56:37 UTC (rev 1685) +++ Trunk/pcgen/code/pluginbuild.xml 2006-11-22 07:22:44 UTC (rev 1686) @@ -114,6 +114,20 @@ <target name="jar-export-plugins" depends="makeplugindirs" description="Build (Link) Export Token plugin jar files"> <!-- Export tokens--> + <jar jarfile="${outputplugins.dir}/ExportToken-ABILITYALL.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/AbilityAllToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${outputplugins.dir}/ExportToken-ABILITYAUTO.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/AbilityAutoToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${outputplugins.dir}/ExportToken-AC.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -856,6 +870,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${outputplugins.dir}/ExportToken-VABILITY.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/VAbilityToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${outputplugins.dir}/ExportToken-VFEAT.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-11-22 03:56:37 UTC (rev 1685) +++ Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-11-22 07:22:44 UTC (rev 1686) @@ -1403,6 +1403,7 @@ private static void populateTokenMap() { if(!tokenMapPopulated) { + addToTokenMap(new AbilityToken()); addToTokenMap(new ACCheckToken()); addToTokenMap(new AlignmentToken()); addToTokenMap(new AttackToken()); Added: Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityToken.java 2006-11-22 07:22:44 UTC (rev 1686) @@ -0,0 +1,367 @@ +/* + * AbilityToken.java + * Copyright 2006 (C) James Dempsey + * + * 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 + * + * Created on 20/11/2006 + * + * $Id: $ + */ + +package pcgen.io.exporttoken; + +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.Globals; +import pcgen.core.PlayerCharacter; +import pcgen.core.SettingsHandler; +import pcgen.io.ExportHandler; +import pcgen.util.enumeration.Visibility; + +/** + * <code>AbilityToken</code> handles the output of ability information. + * The format is ABILITY.w.x.y.z where + * w is the category (FEAT, FIGHTER etc, or ALL) + * x is the ability's position in the list of abilities - 0-based index. + * y is the required ability type - default is ALL). + * z is what is to be output DESC, TYPE, SOURCE, default is name, or TYPE=<type> - type filter + * + * @author James Dempsey <jde...@us...> + * @version $Revision: $ + */ +public class AbilityToken extends Token +{ + + /** Token Name */ + public static final String TOKENNAME = "ABILITY"; + + /** Default Ability = 0**/ + public final int ABILITY_DEFAULT = 0; + /** Visible Ability = 1 */ + public final int ABILITY_VISIBLE = 1; + /** Hidden Ability = 2 */ + public final int ABILITY_HIDDEN = 2; + /** All Abilitys = 3 */ + public final int ABILITY_ALL = 3; + + //private int visibility = ABILITY_DEFAULT; + private List<Ability> abilityList = new ArrayList<Ability>(); + private PlayerCharacter cachedPC = null; + private int cachedPcSerial = 0; + private String lastToken = null; + private AbilityCategory lastCategory = null; + private int visibility = ABILITY_DEFAULT; + + /** + * Get the TOKENNAME + * @return TOKENNAME + */ + @Override + public String getTokenName() + { + return TOKENNAME; + } + + /** + * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, + * pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) + */ + @Override + public String getToken(String tokenSource, PlayerCharacter pc, + ExportHandler eh) + { + final StringTokenizer aTok = new StringTokenizer(tokenSource, "."); + // Skip the ABILITY token itself + final String tokenString = aTok.nextToken(); + final String catString = aTok.nextToken(); + final AbilityCategory aCategory = SettingsHandler.getGame() + .getAbilityCategory(catString); + + if (cachedPC != pc || !aCategory.equals(lastCategory) + || cachedPcSerial != pc.getSerial() || !tokenString.equals(lastToken)) + { + // Overridden by subclasses to return the right list. + abilityList = getAbilityList(pc, aCategory); + cachedPC = pc; + lastCategory = aCategory; + cachedPcSerial = pc.getSerial(); + lastToken = tokenString; + } + + // Default values + List<String> types = new ArrayList<String>(); + List<String> negate = new ArrayList<String>(); + String abilityType = null; + + // abilityIndex holds the number of the ability we want, is + // decremented as we iterate through the list. It is only + // decremented if the current ability matches the desired ability + int abilityIndex = -1; + + while (aTok.hasMoreTokens()) + { + final String bString = aTok.nextToken(); + + try + { + abilityIndex = Integer.parseInt(bString); + + break; + } + catch (NumberFormatException exc) + { + if (bString.equals("VISIBLE")) + { + visibility = ABILITY_VISIBLE; + continue; + } + else if (bString.equals("HIDDEN")) + { + visibility = ABILITY_HIDDEN; + continue; + } + else if (bString.equals("ALL")) + { + visibility = ABILITY_ALL; + continue; + } + else + { + abilityType = bString; + } + } + + } + + while (aTok.hasMoreTokens()) + { + final String typeStr = aTok.nextToken(); + + int typeInd = typeStr.indexOf("TYPE"); + if (typeInd != -1 && typeStr.length() > 4) + { + if (typeInd > 0) + { + negate.add(typeStr.substring(typeInd + 5)); + } + else + { + types.add(typeStr.substring(typeInd + 5)); + } + } + } + + List<Ability> aList = buildAbilityList(types, negate, abilityType, + visibility); + + String retString = getRetString(tokenSource, pc, eh, abilityIndex, + aList); + + return retString; + } + + /** + * Build up the list of abilities of interest based on the type selection. + * + * @param types The list of types which it must match at least one of. + * @param negate The list of types it must not match any of. + * @param abilityType The type definition it must match. + * @return + */ + private List<Ability> buildAbilityList(List<String> types, List<String> negate, String abilityType, int visibility) + { + List<Ability> aList = new ArrayList<Ability>(); + + Globals.sortPObjectListByName(abilityList); + + for (Ability aAbility : abilityList) + { + boolean matchTypeDef = false; + boolean matchVisibilityDef = false; + + if (abilityType != null) + { + if (aAbility.isType(abilityType)) + { + matchTypeDef = true; + } + } + else + { + matchTypeDef = true; + } + + boolean istype = false; + boolean isnttype = true; + + // is at leas one of the types we've asked for + if (types.size() > 0) + { + for (String typeStr : types) + { + istype |= aAbility.isType(typeStr); + } + } + else + { + istype = true; + } + + // isn't all the types we've said it's not + for (String typeStr : negate) + { + isnttype &= !aAbility.isType(typeStr); + } + + matchTypeDef = matchTypeDef && istype && isnttype; + + switch (visibility) + { + case ABILITY_ALL: + matchVisibilityDef = true; + break; + case ABILITY_HIDDEN: + if (aAbility.getVisibility() == Visibility.HIDDEN + || aAbility.getVisibility() == Visibility.DISPLAY_ONLY) + { + matchVisibilityDef = true; + } + break; + case ABILITY_VISIBLE: // Fall thru intentional + default: + if (aAbility.getVisibility() == Visibility.DEFAULT + || aAbility.getVisibility() == Visibility.OUTPUT_ONLY) + { + matchVisibilityDef = true; + } + break; + } + + if (matchTypeDef && matchVisibilityDef) + { + aList.add(aAbility); + } + } + return aList; + } + + /** + * Calculate the token value for the ability token. + * + * @param tokenSource The text of the export token. + * @param pc The character ebign exported. + * @param eh The export handler. + * @param abilityIndex The location f the ability in the list. + * @param aList The list of abilities. + * @return The token value. + */ + private String getRetString(String tokenSource, PlayerCharacter pc, ExportHandler eh, int abilityIndex, List<Ability> aList) + { + String retString = ""; + Ability aAbility; + if (abilityIndex < aList.size()) + { + aAbility = aList.get(abilityIndex); + + if (abilityIndex == aList.size() - 1 && eh != null && eh.getExistsOnly()) + { + eh.setNoMoreItems(true); + } + else if (eh != null && eh.getExistsOnly()) + { + eh.setNoMoreItems(true); + } + + if (tokenSource.endsWith(".DESC")) + { + retString += aAbility.getDescription(pc); + } + else if (tokenSource.endsWith(".TYPE")) + { + retString += aAbility.getType(); + } + else if (tokenSource.endsWith(".ASSOCIATED")) + { + StringBuffer buf = new StringBuffer(); + + for (int j = 0; j < aAbility.getAssociatedCount(); j++) + { + if (j != 0) + { + buf.append(","); + } + buf.append(aAbility.getAssociated(j)); + } + + retString += buf.toString(); + } + else if (tokenSource.endsWith(".ASSOCIATEDCOUNT")) + { + retString += Integer.toString(aAbility.getAssociatedCount()); + } + else if (tokenSource.endsWith(".SOURCE")) + { + retString += aAbility.getDefaultSourceString(); + } + else + { + retString += aAbility.qualifiedName(); + } + } + return retString; + } + + /** + * Returns the correct list of abilities for the character. + * This method is overridden in subclasses if they need to change the list + * of abilities looked at. + * + * @param pc the character who's abilities we are retrieving. + * @param aCategory The category of ability being reported. + * @return List of abilities. + */ + protected List<Ability> getAbilityList(PlayerCharacter pc, + final AbilityCategory aCategory) + { + List<Ability> abilityList = new ArrayList<Ability>(); + for (Ability aAbility : pc.getRealAbilityList(aCategory)) + { + abilityList.add(aAbility); + } + return abilityList; + } + + /** + * @return the visibility + */ + protected int getVisibility() + { + return visibility; + } + + /** + * @param visibility the visibility to set + */ + protected void setVisibility(int visibility) + { + this.visibility = visibility; + } + +} Property changes on: Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityToken.java ___________________________________________________________________ Name: keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAllToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAllToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAllToken.java 2006-11-22 07:22:44 UTC (rev 1686) @@ -0,0 +1,78 @@ +/* + * AbilityAllToken.java + * Copyright 2006 (C) James Dempsey + * + * 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 + * + * Created on 21 Nov 2006 + * + * $$Id: $$ + */ + +package plugin.exporttokens; + +import java.util.ArrayList; +import java.util.List; + +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.PlayerCharacter; +import pcgen.io.ExportHandler; +import pcgen.io.exporttoken.AbilityToken; + +/** + * <code>AbilityAllToken</code> deals with the ABILITYALL output + * token. + * + * Last Editor: $Author: $ + * Last Edited: $Date: $ + * + * @author James Dempsey <jde...@us...> + * @version $Revision: $ + */ +public class AbilityAllToken extends AbilityToken +{ + + /** + * @see pcgen.io.exporttoken.Token#getTokenName() + */ + public String getTokenName() + { + return "ABILITYALL"; + } + + /** + * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) + */ + public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) + { + setVisibility(ABILITY_ALL); + return super.getToken(tokenSource, pc, eh); + } + + /** + * @see pcgen.io.exporttoken.AbilityToken#getAbilityList(pcgen.core.PlayerCharacter, pcgen.core.AbilityCategory) + */ + @Override + protected List<Ability> getAbilityList(PlayerCharacter pc, + final AbilityCategory aCategory) + { + List<Ability> ret = new ArrayList<Ability>(); + ret.addAll(pc.getRealAbilityList(aCategory)); + ret.addAll(pc.getAutomaticAbilityList(aCategory)); + ret.addAll(pc.getVirtualAbilityList(aCategory)); + return ret; + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAllToken.java ___________________________________________________________________ Name: keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAutoToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAutoToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAutoToken.java 2006-11-22 07:22:44 UTC (rev 1686) @@ -0,0 +1,65 @@ +/* + * AbilityAutoToken.java + * Copyright 2006 (C) James Dempsey + * + * 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 + * + * Created on 21 Nov 2006 + * + * $$Id: $$ + */ + +package plugin.exporttokens; + +import java.util.List; + +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.PlayerCharacter; +import pcgen.io.exporttoken.AbilityToken; + +/** + * @author karianna + * Class deals with FEATAUTO Token + */ +/** + * <code>AbilityAutoToken</code> deals with the ABILITYAUTO output + * token. + * + * @author James Dempsey <jde...@us...> + * @version $Revision: $ + */ +public class AbilityAutoToken extends AbilityToken +{ + + /** + * @see pcgen.io.exporttoken.Token#getTokenName() + */ + @Override + public String getTokenName() + { + return "ABILITYAUTO"; + } + + /** + * @see pcgen.io.exporttoken.AbilityToken#getAbilityList(pcgen.core.PlayerCharacter, pcgen.core.AbilityCategory) + */ + @Override + protected List<Ability> getAbilityList(PlayerCharacter pc, + final AbilityCategory aCategory) + { + return pc.getAutomaticAbilityList(aCategory); + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAutoToken.java ___________________________________________________________________ Name: keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/exporttokens/VAbilityToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/VAbilityToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/VAbilityToken.java 2006-11-22 07:22:44 UTC (rev 1686) @@ -0,0 +1,63 @@ +/* + * VAbilityToken.java + * Copyright 2006 (C) James Dempsey + * + * 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 + * + * Created on 21 Nov 2006 + * + * $$Id: $$ + */ + +package plugin.exporttokens; + +import java.util.List; + +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.PlayerCharacter; +import pcgen.io.exporttoken.AbilityToken; + +/** + * <code>VAbilityToken</code> deals with the VABILITY output + * token. + * + * Last Editor: $Author: $ + * Last Edited: $Date: $ + * + * @author James Dempsey <jde...@us...> + * @version $Revision: $ + */ +public class VAbilityToken extends AbilityToken +{ + /** + * @see pcgen.io.exporttoken.Token#getTokenName() + */ + @Override + public String getTokenName() + { + return "VABILITY"; + } + + /** + * @see pcgen.io.exporttoken.AbilityToken#getAbilityList(pcgen.core.PlayerCharacter, pcgen.core.AbilityCategory) + */ + @Override + protected List<Ability> getAbilityList(PlayerCharacter pc, + final AbilityCategory aCategory) + { + return pc.getVirtualFeatList(); + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/exporttokens/VAbilityToken.java ___________________________________________________________________ Name: keywords + "Author Revision Date Id" Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2006-11-22 11:28:30
|
Revision: 1687 http://svn.sourceforge.net/pcgen/?rev=1687&view=rev Author: jdempsey Date: 2006-11-22 03:28:29 -0800 (Wed, 22 Nov 2006) Log Message: ----------- FReq#1262322 - Ability Object: Output - Add ABILITYLIST export token and its children to output lists of abilities Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityToken.java Trunk/pcgen/code/testsuite/base.xml Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityListToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAllListToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAutoListToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/VAbilityListToken.java Trunk/pcgen/code/src/test/pcgen/io/exporttoken/AbilityListTokenTest.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-11-22 07:22:44 UTC (rev 1686) +++ Trunk/pcgen/code/pluginbuild.xml 2006-11-22 11:28:29 UTC (rev 1687) @@ -121,6 +121,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${outputplugins.dir}/ExportToken-ABILITYALLLIST.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/AbilityAllListToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${outputplugins.dir}/ExportToken-ABILITYAUTO.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -128,6 +135,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${outputplugins.dir}/ExportToken-ABILITYAUTOLIST.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/AbilityAutoListToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${outputplugins.dir}/ExportToken-AC.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -877,6 +891,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${outputplugins.dir}/ExportToken-VABILITYLIST.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/VAbilityListToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${outputplugins.dir}/ExportToken-VFEAT.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-11-22 07:22:44 UTC (rev 1686) +++ Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-11-22 11:28:29 UTC (rev 1687) @@ -1404,6 +1404,7 @@ { if(!tokenMapPopulated) { addToTokenMap(new AbilityToken()); + addToTokenMap(new AbilityListToken()); addToTokenMap(new ACCheckToken()); addToTokenMap(new AlignmentToken()); addToTokenMap(new AttackToken()); Added: Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityListToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityListToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityListToken.java 2006-11-22 11:28:29 UTC (rev 1687) @@ -0,0 +1,159 @@ +/* + * AbilityListToken.java + * Copyright 2006 (C) James Dempsey + * + * 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 + * + * Created on 21/11/2006 + * + * $Id: $ + */ + +package pcgen.io.exporttoken; + +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.PlayerCharacter; +import pcgen.core.SettingsHandler; +import pcgen.io.ExportHandler; + +/** + * <code>AbilityListToken</code> handles the output of a comma separated + * list of ability information. + * + * The format is ABILITYLIST.y.z where + * y is the category (FEAT, FIGHTER etc, or ALL) + * z is an option list of TYPE=<type> - type filter - may be negated + * + * Last Editor: $Author: $ + * Last Edited: $Date: $ + * + * @author James Dempsey <jde...@us...> + * @version $Revision: $ + */ +public class AbilityListToken extends Token +{ + private static final String DELIM = ", "; + + private List<Ability> abilityList = null; + private PlayerCharacter lastPC = null; + private int lastPCSerial; + private String lastType = ""; + private AbilityCategory lastCategory = null; + + /** Token Name */ + public static final String TOKENNAME = "ABILITYLIST"; + + /** + * Get the TOKENNAME + * @return TOKENNAME + */ + @Override + public String getTokenName() + { + return TOKENNAME; + } + + /** + * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) + */ + @Override + public String getToken(String tokenSource, PlayerCharacter pc, + ExportHandler eh) + { + StringBuffer retString = new StringBuffer(); + + final StringTokenizer aTok = new StringTokenizer(tokenSource, "."); + // Skip the ABILITYLIST token itself + final String tokenString = aTok.nextToken(); + final String catString = aTok.nextToken(); + final AbilityCategory aCategory = SettingsHandler.getGame() + .getAbilityCategory(catString); + + if (lastPC != pc || !aCategory.equals(lastCategory) + || lastPCSerial != pc.getSerial() || !tokenString.equals(lastType)) + { + abilityList = getAbilityList(pc, aCategory); + lastPC = pc; + lastCategory = aCategory; + lastPCSerial = pc.getSerial(); + lastType = tokenString; + } + + // Default values + List<String> types = new ArrayList<String>(); + List<String> negate = new ArrayList<String>(); + + while (aTok.hasMoreTokens()) + { + final String typeStr = aTok.nextToken(); + + int typeInd = typeStr.indexOf("TYPE="); + if (typeInd != -1 && typeStr.length() > 5) + { + if (typeInd > 0) + { + negate.add(typeStr.substring(typeInd + 5)); + } + else + { + types.add(typeStr.substring(typeInd + 5)); + } + } + } + + List<Ability> aList = AbilityToken.buildAbilityList(types, negate, + null, AbilityToken.ABILITY_VISIBLE, abilityList); + + boolean needComma = false; + for (Ability ability : aList) + { + if (needComma) + { + retString.append(DELIM); + } + needComma = true; + + retString.append(ability.qualifiedName()); + } + + return retString.toString(); + } + + /** + * Returns the correct list of abilities of a particular category for the character. + * This method is overridden in subclasses if they need to change the list + * of abilities looked at. + * + * @param pc the character who's feats we are retrieving. + * @param aCategory The category of ability required. + * @return List of feats. + */ + protected List<Ability> getAbilityList(PlayerCharacter pc, + AbilityCategory aCategory) + { + List<Ability> listOfAbilities = new ArrayList<Ability>(); + for (Ability ability : pc.getRealAbilityList(aCategory)) + { + listOfAbilities.add(ability); + } + return listOfAbilities; + } + +} Property changes on: Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityListToken.java ___________________________________________________________________ Name: keywords + Author Revision Date Id Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityToken.java 2006-11-22 07:22:44 UTC (rev 1686) +++ Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityToken.java 2006-11-22 11:28:29 UTC (rev 1687) @@ -53,13 +53,13 @@ public static final String TOKENNAME = "ABILITY"; /** Default Ability = 0**/ - public final int ABILITY_DEFAULT = 0; + public static final int ABILITY_DEFAULT = 0; /** Visible Ability = 1 */ - public final int ABILITY_VISIBLE = 1; + public static final int ABILITY_VISIBLE = 1; /** Hidden Ability = 2 */ - public final int ABILITY_HIDDEN = 2; + public static final int ABILITY_HIDDEN = 2; /** All Abilitys = 3 */ - public final int ABILITY_ALL = 3; + public static final int ABILITY_ALL = 3; //private int visibility = ABILITY_DEFAULT; private List<Ability> abilityList = new ArrayList<Ability>(); @@ -168,8 +168,8 @@ } } - List<Ability> aList = buildAbilityList(types, negate, abilityType, - visibility); + List<Ability> aList = AbilityToken.buildAbilityList(types, negate, + abilityType, visibility, abilityList); String retString = getRetString(tokenSource, pc, eh, abilityIndex, aList); @@ -185,7 +185,7 @@ * @param abilityType The type definition it must match. * @return */ - private List<Ability> buildAbilityList(List<String> types, List<String> negate, String abilityType, int visibility) + static List<Ability> buildAbilityList(List<String> types, List<String> negate, String abilityType, int visibility, List<Ability> abilityList) { List<Ability> aList = new ArrayList<Ability>(); Added: Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAllListToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAllListToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAllListToken.java 2006-11-22 11:28:29 UTC (rev 1687) @@ -0,0 +1,67 @@ +/* + * AbilityAllListToken.java + * Copyright 2006 (C) James Dempsey + * + * 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 + * + * Created on 22/11/2006 + * + * $Id: $ + */ +package plugin.exporttokens; + +import java.util.List; + +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.PlayerCharacter; +import pcgen.io.exporttoken.AbilityListToken; + +/** + * <code>AbilityAllListToken</code> handles the output of a comma separated + * list of all ability information. + * + * The format is ABILITYALLLIST.y.z where + * y is the category (FEAT, FIGHTER etc, or ALL) + * z is an option list of TYPE=<type> - type filter - may be negated + * + * Last Editor: $Author: $ + * Last Edited: $Date: $ + * + * @author James Dempsey <jde...@us...> + * @version $Revision: $ + */ +public class AbilityAllListToken extends AbilityListToken +{ + + /** + * @see pcgen.io.exporttoken.Token#getTokenName() + */ + @Override + public String getTokenName() + { + return "ABILITYALLLIST"; + } + + /** + * @see pcgen.io.exporttoken.AbilityListToken#getAbilityList(pcgen.core.PlayerCharacter, pcgen.core.AbilityCategory) + */ + @Override + protected List<Ability> getAbilityList(PlayerCharacter pc, + AbilityCategory aCategory) + { + return pc.getAggregateVisibleAbilityList(aCategory); + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAllListToken.java ___________________________________________________________________ Name: keywords + Author Revision Date Id Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAutoListToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAutoListToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAutoListToken.java 2006-11-22 11:28:29 UTC (rev 1687) @@ -0,0 +1,67 @@ +/* + * AbilityAutoListToken.java + * Copyright 2006 (C) James Dempsey + * + * 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 + * + * Created on 22/11/2006 + * + * $Id: $ + */ +package plugin.exporttokens; + +import java.util.List; + +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.PlayerCharacter; +import pcgen.io.exporttoken.AbilityListToken; + +/** + * <code>AbilityAutoListToken</code> handles the output of a comma separated + * list of automatic ability information. + * + * The format is ABILITYAUTOLIST.y.z where + * y is the category (FEAT, FIGHTER etc, or ALL) + * z is an option list of TYPE=<type> - type filter - may be negated + * + * Last Editor: $Author: $ + * Last Edited: $Date: $ + * + * @author James Dempsey <jde...@us...> + * @version $Revision: $ + */ +public class AbilityAutoListToken extends AbilityListToken +{ + + /** + * @see pcgen.io.exporttoken.Token#getTokenName() + */ + @Override + public String getTokenName() + { + return "ABILITYAUTOLIST"; + } + + /** + * @see pcgen.io.exporttoken.AbilityListToken#getAbilityList(pcgen.core.PlayerCharacter, pcgen.core.AbilityCategory) + */ + @Override + protected List<Ability> getAbilityList(PlayerCharacter pc, + AbilityCategory aCategory) + { + return pc.getAutomaticAbilityList(aCategory); + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/exporttokens/AbilityAutoListToken.java ___________________________________________________________________ Name: keywords + Author Revision Date Id Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/exporttokens/VAbilityListToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/VAbilityListToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/VAbilityListToken.java 2006-11-22 11:28:29 UTC (rev 1687) @@ -0,0 +1,67 @@ +/* + * VAbilityListToken.java + * Copyright 2006 (C) James Dempsey + * + * 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 + * + * Created on 22/11/2006 + * + * $Id: $ + */ +package plugin.exporttokens; + +import java.util.List; + +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.PlayerCharacter; +import pcgen.io.exporttoken.AbilityListToken; + +/** + * <code>VAbilityListToken</code> handles the output of a comma separated + * list of virtual ability information. + * + * The format is ABILITYALLLIST.y.z where + * y is the category (FEAT, FIGHTER etc, or ALL) + * z is an option list of TYPE=<type> - type filter - may be negated + * + * Last Editor: $Author: $ + * Last Edited: $Date: $ + * + * @author James Dempsey <jde...@us...> + * @version $Revision: $ + */ +public class VAbilityListToken extends AbilityListToken +{ + + /** + * @see pcgen.io.exporttoken.Token#getTokenName() + */ + public String getTokenName() + { + return "VABILITYLIST"; + } + + /** + * @see pcgen.io.exporttoken.AbilityListToken#getAbilityList(pcgen.core.PlayerCharacter, pcgen.core.AbilityCategory) + */ + @Override + protected List<Ability> getAbilityList(PlayerCharacter pc, + AbilityCategory aCategory) + { + return pc.getVirtualAbilityList(aCategory); + } + +} Property changes on: Trunk/pcgen/code/src/java/plugin/exporttokens/VAbilityListToken.java ___________________________________________________________________ Name: keywords + Author Revision Date Id Name: svn:eol-style + native Added: Trunk/pcgen/code/src/test/pcgen/io/exporttoken/AbilityListTokenTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/io/exporttoken/AbilityListTokenTest.java (rev 0) +++ Trunk/pcgen/code/src/test/pcgen/io/exporttoken/AbilityListTokenTest.java 2006-11-22 11:28:29 UTC (rev 1687) @@ -0,0 +1,149 @@ +/* + * AbilityListTokenTest.java + * Copyright 2006 (C) James Dempsey <jde...@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 + * + * Created on Oct 17, 2006 + * + * $Id: $ + * + */ +package pcgen.io.exporttoken; + +import junit.framework.Test; +import junit.framework.TestSuite; +import pcgen.AbstractCharacterTestCase; +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.PlayerCharacter; +import pcgen.core.SettingsHandler; +import pcgen.io.ExportHandler; +import pcgen.util.TestHelper; +import plugin.exporttokens.TextToken; + +/** + * <code>AbilityListTokenTest</code> tests the functioning of the ABILITYLIST + * token processing code. + * + * Last Editor: $Author: $ + * Last Edited: $Date: $ + * + * @author James Dempsey <jde...@us...> + * @version $Revision: $ + */ +public class AbilityListTokenTest extends AbstractCharacterTestCase +{ + + /** + * Quick test suite creation - adds all methods beginning with "test" + * @return The Test suite + */ + public static Test suite() + { + return new TestSuite(AbilityListTokenTest.class); + } + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + PlayerCharacter character = getCharacter(); + + Ability ab1 = TestHelper.makeAbility("Perform (Dance)", "FEAT", + "General.Fighter"); + ab1.setMultiples("NO"); + AbilityCategory aCategory = SettingsHandler.getGame() + .getAbilityCategory(ab1.getCategory()); + if (aCategory == null) + { + aCategory = new AbilityCategory(ab1.getCategory()); + SettingsHandler.getGame().addAbilityCategory(aCategory); + } + character.addAbility(aCategory, ab1, null); + + Ability ab2 = TestHelper.makeAbility("Perform (Dance)", "BARDIC", + "General.Bardic"); + ab2.setMultiples("NO"); + aCategory = SettingsHandler.getGame().getAbilityCategory( + ab2.getCategory()); + if (aCategory == null) + { + aCategory = new AbilityCategory(ab2.getCategory()); + SettingsHandler.getGame().addAbilityCategory(aCategory); + } + character.addAbility(aCategory, ab2, null); + + Ability ab3 = TestHelper.makeAbility("Perform (Oratory)", "FEAT", + "General.Fighter"); + ab3.setMultiples("NO"); + aCategory = SettingsHandler.getGame().getAbilityCategory( + ab3.getCategory()); + if (aCategory == null) + { + aCategory = new AbilityCategory(ab3.getCategory()); + SettingsHandler.getGame().addAbilityCategory(aCategory); + } + character.addAbility(aCategory, ab3, null); + + Ability ab4 = TestHelper.makeAbility("Silent Step", "FEAT", "General"); + ab4.setMultiples("NO"); + aCategory = SettingsHandler.getGame().getAbilityCategory( + ab4.getCategory()); + if (aCategory == null) + { + aCategory = new AbilityCategory(ab4.getCategory()); + SettingsHandler.getGame().addAbilityCategory(aCategory); + } + character.addAbility(aCategory, ab4, null); + } + + /** + * Test the output for positive numbers with fractions. + */ + public void testTypes() + { + AbilityListToken tok = new AbilityListToken(); + ExportHandler eh = new ExportHandler(null); + PlayerCharacter character = getCharacter(); + + assertEquals("ABILITYLIST.FEAT", + "Perform (Dance), Perform (Oratory), Silent Step", tok + .getToken("ABILITYLIST.FEAT", character, eh)); + assertEquals("ABILITYLIST.FEAT.TYPE=Fighter", + "Perform (Dance), Perform (Oratory)", tok + .getToken("ABILITYLIST.FEAT.TYPE=Fighter", character, eh)); + assertEquals("ABILITYLIST.FEAT.!TYPE=Fighter", + "Silent Step", tok + .getToken("ABILITYLIST.FEAT.!TYPE=Fighter", character, eh)); + } + + /** + * Test the output for negative numbers with fractions. + */ + public void testCategory() + { + AbilityListToken tok = new AbilityListToken(); + ExportHandler eh = new ExportHandler(null); + PlayerCharacter character = getCharacter(); + + assertEquals("ABILITYLIST.BARDIC", + "Perform (Dance)", tok + .getToken("ABILITYLIST.BARDIC", character, eh)); + } + +} \ No newline at end of file Property changes on: Trunk/pcgen/code/src/test/pcgen/io/exporttoken/AbilityListTokenTest.java ___________________________________________________________________ Name: keywords + Author Revision Date Id Name: svn:eol-style + native Modified: Trunk/pcgen/code/testsuite/base.xml =================================================================== --- Trunk/pcgen/code/testsuite/base.xml 2006-11-22 07:22:44 UTC (rev 1686) +++ Trunk/pcgen/code/testsuite/base.xml 2006-11-22 11:28:29 UTC (rev 1687) @@ -925,11 +925,11 @@ <!-- Visible standard feats (not including the auto feats) --> |FOR,%feat,0,COUNT[FEATS.VISIBLE]-1,1,0| <feat> - <name>|FEAT.VISIBLE.%feat|</name> - <description>|FEAT.VISIBLE.%feat.DESC|</description> - <type>|FEAT.VISIBLE.%feat.TYPE|</type> - <associated>|FEAT.VISIBLE.%feat.ASSOCIATED|</associated> - <count>|FEAT.VISIBLE.%feat.ASSOCIATEDCOUNT|</count> + <name>|ABILITY.FEAT.VISIBLE.%feat|</name> + <description>|ABILITY.FEAT.VISIBLE.%feat.DESC|</description> + <type>|ABILITY.FEAT.VISIBLE.%feat.TYPE|</type> + <associated>|ABILITY.FEAT.VISIBLE.%feat.ASSOCIATED|</associated> + <count>|ABILITY.FEAT.VISIBLE.%feat.ASSOCIATEDCOUNT|</count> <auto>F</auto> <hidden>F</hidden> <virtual>F</virtual> @@ -939,11 +939,11 @@ <!-- Auto feats --> |FOR,%feat,0,COUNT[FEATSAUTO.VISIBLE]-1,1,0| <feat> - <name>|FEATAUTO.VISIBLE.%feat|</name> - <description>|FEATAUTO.VISIBLE.%feat.DESC|</description> - <type>|FEATAUTO.VISIBLE.%feat.TYPE|</type> - <associated>|FEATAUTO.VISIBLE.%feat.ASSOCIATED|</associated> - <count>|FEATAUTO.VISIBLE.%feat.ASSOCIATEDCOUNT|</count> + <name>|ABILITYAUTO.FEAT.VISIBLE.%feat|</name> + <description>|ABILITYAUTO.FEAT.VISIBLE.%feat.DESC|</description> + <type>|ABILITYAUTO.FEAT.VISIBLE.%feat.TYPE|</type> + <associated>|ABILITYAUTO.FEAT.VISIBLE.%feat.ASSOCIATED|</associated> + <count>|ABILITYAUTO.FEAT.VISIBLE.%feat.ASSOCIATEDCOUNT|</count> <auto>T</auto> <hidden>F</hidden> <virtual>F</virtual> @@ -980,11 +980,11 @@ <!-- Hidden VFEATS --> |FOR,%feat,0,COUNT[VFEATS.HIDDEN]-1,1,0| <feat> - <name>|VFEAT.HIDDEN.%feat|</name> - <description>|VFEAT.HIDDEN.%feat.DESC|</description> - <type>|VFEAT.HIDDEN.%feat.TYPE|</type> - <associated>|VFEAT.HIDDEN.%feat.ASSOCIATED|</associated> - <count>|VFEAT.HIDDEN.%feat.ASSOCIATEDCOUNT|</count> + <name>|VABILITY.FEAT.HIDDEN.%feat|</name> + <description>|VABILITY.FEAT.HIDDEN.%feat.DESC|</description> + <type>|VABILITY.FEAT.HIDDEN.%feat.TYPE|</type> + <associated>|VABILITY.FEAT.HIDDEN.%feat.ASSOCIATED|</associated> + <count>|VABILITY.FEAT.HIDDEN.%feat.ASSOCIATEDCOUNT|</count> <auto>F</auto> <hidden>T</hidden> <virtual>T</virtual> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2006-11-24 11:43:23
|
Revision: 1693 http://svn.sourceforge.net/pcgen/?rev=1693&view=rev Author: jdempsey Date: 2006-11-24 03:43:22 -0800 (Fri, 24 Nov 2006) Log Message: ----------- FReq#1262322 - Ability Object: Output - Add JEP count command - implement ABILITIES counting - Allow multi-param JEP commands in FOR loop definitions Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java Trunk/pcgen/code/src/java/pcgen/util/enumeration/Visibility.java Trunk/pcgen/code/src/test/pcgen/io/exporttoken/AbilityListTokenTest.java Trunk/pcgen/code/testsuite/base.xml Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/util/enumeration/View.java Trunk/pcgen/code/src/java/plugin/jepcommands/CountCommand.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-11-23 09:05:43 UTC (rev 1692) +++ Trunk/pcgen/code/pluginbuild.xml 2006-11-24 11:43:22 UTC (rev 1693) @@ -4618,6 +4618,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${jepplugins.dir}/JepCommand-COUNT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/jepcommands/CountCommand.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${jepplugins.dir}/JepCommand-FLOOR.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-11-23 09:05:43 UTC (rev 1692) +++ Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-11-24 11:43:22 UTC (rev 1693) @@ -1271,14 +1271,12 @@ private FORNode parseFORs(String forLine, StringTokenizer tokens) { - final StringTokenizer forVars = new StringTokenizer(forLine, ","); - forVars.nextToken(); - - final String var = forVars.nextToken(); - final String min = forVars.nextToken(); - final String max = forVars.nextToken(); - final String step = forVars.nextToken(); - final String eTest = forVars.nextToken(); + final List<String> forVars = ExportHandler.getParameters(forLine); + final String var = forVars.get(1); + final String min = forVars.get(2); + final String max = forVars.get(3); + final String step = forVars.get(4); + final String eTest = forVars.get(5); boolean exists = false; if (((eTest.length() > 0) && (eTest.charAt(0) == '1')) || ((eTest.length() > 0) && (eTest.charAt(0) == '2'))) @@ -1325,6 +1323,49 @@ return node; } + + /** + * Retrieve the parameters of a comma seperated command such as a + * FOR token. Commas inside brackets are ignored, thus allowing JEP + * functions with multiple parameters to be included in FOR loops. + * + * @param forToken The token to be broken up. + * @return The token parameters. + */ + public static List<String> getParameters(String forToken) + { + String splitStr[] = forToken.split(","); + List<String> result = new ArrayList<String>(); + StringBuffer buf = new StringBuffer(); + boolean inFormula = false; + for (String string : splitStr) + { + if (string.indexOf("(") >= 0) + { + inFormula = true; + buf.append(string); + } + else if (inFormula && string.indexOf(")") >= 0) + { + inFormula = false; + buf.append(","); + buf.append(string); + result.add(buf.toString()); + buf = new StringBuffer(); + } + else if (inFormula) + { + buf.append(","); + buf.append(string); + } + else + { + result.add(string); + } + } + return result; + } + private IIFNode parseIIFs(String expr, StringTokenizer tokens) { final IIFNode node = new IIFNode(expr); Added: Trunk/pcgen/code/src/java/pcgen/util/enumeration/View.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/util/enumeration/View.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/util/enumeration/View.java 2006-11-24 11:43:22 UTC (rev 1693) @@ -0,0 +1,54 @@ +package pcgen.util.enumeration; + +/** + * <code>View</code> is an enumeration of possible view types. It is + * closely related to the Visibility enumeration. + * + * Last Editor: $Author: $ + * Last Edited: $Date: $ + * + * @author James Dempsey <jde...@us...> + * @version $Revision: $ + */ +public enum View +{ + ALL("ALL"), // Show all visibility types + HIDDEN("HIDDEN"), // Show only those not visible + VISIBLE("VISIBLE"); // Shows types visible to the GUI/Export as appropriate + + private final String text; + + /** + * Create a new view based on a name. + * @param s + */ + View(String s) + { + text = s; + } + + @Override + public String toString() + { + return text; + } + + /** + * Retrieve a View matching the supplied name. + * @param name The name of the view + * @return The view, or null if not a view name. + */ + public static View getViewFromName(String name) + { + final String viewName = name.toUpperCase(); + for (View view : View.values()) + { + if (view.text.equals(viewName)) + { + return view; + } + } + + return null; + } +} Property changes on: Trunk/pcgen/code/src/java/pcgen/util/enumeration/View.java ___________________________________________________________________ Name: keywords + Author Revision Date Id Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/java/pcgen/util/enumeration/Visibility.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/util/enumeration/Visibility.java 2006-11-23 09:05:43 UTC (rev 1692) +++ Trunk/pcgen/code/src/java/pcgen/util/enumeration/Visibility.java 2006-11-24 11:43:22 UTC (rev 1693) @@ -19,4 +19,34 @@ { return text; } + + /** + * Determine if this visibility can be seen in the supplied view level. + * + * @param view The view level. + * @param isExporting Is the visibility being detemerined for an export function + * @return true if the visibility can be viewed, false if not. + */ + public boolean isVisibileTo(View view, boolean isExporting) + { + if (view == View.ALL) + { + return true; + } + if (view == View.HIDDEN) + { + if (this == Visibility.HIDDEN || this == Visibility.DISPLAY_ONLY) + { + return true; + } + } + else + { + if (this == Visibility.DEFAULT || this == Visibility.OUTPUT_ONLY) + { + return true; + } + } + return false; + } } Added: Trunk/pcgen/code/src/java/plugin/jepcommands/CountCommand.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/jepcommands/CountCommand.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/jepcommands/CountCommand.java 2006-11-24 11:43:22 UTC (rev 1693) @@ -0,0 +1,221 @@ +/* + * CountCommand.java + * Copyright 2006 (C) James Dempsey + * + * 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 + * + * Created on 23/11/2006 + * + * $Id: $ + */ + +package plugin.jepcommands; + +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +import org.nfunk.jep.ParseException; + +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.PlayerCharacter; +import pcgen.core.SettingsHandler; +import pcgen.core.VariableProcessor; +import pcgen.util.Logging; +import pcgen.util.PCGenCommand; +import pcgen.util.enumeration.View; + +/** + * <code>CountCommand</code> deals with the count() JEP command. + * The first parameter will be the type of objetc being counted + * and further parameters will specify the criteria. + * + * Last Editor: $Author: $ + * Last Edited: $Date: $ + * + * @author James Dempsey <jde...@us...> + * @version $Revision: $ + */ +public class CountCommand extends PCGenCommand +{ + + /** + * Constructor + */ + public CountCommand() + { + numberOfParameters = -1; + } + + /** + * @see pcgen.util.PCGenCommand#getFunctionName() + */ + @Override + public String getFunctionName() + { + return "COUNT"; + } + + /** + * Runs count on the inStack. The parameter is popped + * off the <code>inStack</code>, and the variable's value is + * pushed back to the top of <code>inStack</code>. + * @param inStack + * @throws ParseException + */ + @Override + public void run(Stack inStack) throws ParseException + { + Logging.errorPrint("Got a call!"); + // check the stack + checkStack(inStack); + + // get the parameters from the stack + // + // have to do this in reverse order...this is a stack afterall + // + Object params[] = new Object[curNumberOfParameters]; + for (int i = curNumberOfParameters-1; i >= 0 ; i--) + { + params[i] = inStack.pop(); + } + + if ((params[0] instanceof String)) + { + // Grab the character under scrutiny + PlayerCharacter pc = null; + if (parent instanceof VariableProcessor) + { + pc = ((VariableProcessor) parent).getPc(); + } + else if (parent instanceof PlayerCharacter) + { + pc = (PlayerCharacter) parent; + } + if (pc == null) + { + throw new ParseException("Invalid parent (no PC): " + + parent.getClass().getName()); + } + + // Count the requested object type. + Object result = null; + final String countType = (String) params[0]; + if ("ABILITIES".equals(countType)) + { + result = countAbilities(pc, params); + } + + inStack.push(result); + } + else + { + throw new ParseException("Invalid parameter type"); + } + } + + /** + * Count a character's abiltiies. + * + * @param pc The character being counted. + * @param params The parameters determining which abilities get counted. + * @return A Double with the number of matching abilities. + * @throws ParseException If any invalid parameters are encountered. + */ + private Object countAbilities(PlayerCharacter pc, Object[] params) throws ParseException + { + if (params.length < 2) + { + throw new ParseException("Count of abilities had too few parameters."); + } + + String visibility = "VISIBLE"; + String category = null; + String nature = "NORMAL"; + + // Parse the parameters passed in + for (int i = 1; i < params.length; i++) + { + if (!(params[i] instanceof String)) + { + throw new ParseException( + "Invalid parameter type for parameter #" + (i + 1) + " - " + + String.valueOf(params[i])); + } + + String[] keyValue=((String)params[i]).split("="); + if ("CATEGORY".equalsIgnoreCase(keyValue[0])) + { + category = keyValue[1]; + } + else if ("VISIBILITY".equalsIgnoreCase(keyValue[0])) + { + visibility = keyValue[1]; + } + else if ("NATURE".equalsIgnoreCase(keyValue[0])) + { + nature = keyValue[1]; + } + else + { + throw new ParseException( + "Invalid parameter key for parameter #" + (i + 1) + " - " + + String.valueOf(params[i])); + } + } + + // Fetch the requested list of abilities + final AbilityCategory aCategory = SettingsHandler.getGame() + .getAbilityCategory(category); + if (aCategory == null) + { + throw new ParseException( + "Invalid category specified " + String.valueOf(category)); + } + final List<Ability> abilities = new ArrayList<Ability>(); + if ("ALL".equals(nature)) + { + abilities.addAll(pc.getRealAbilityList(aCategory)); + abilities.addAll(pc.getAutomaticAbilityList(aCategory)); + abilities.addAll(pc.getVirtualAbilityList(aCategory)); + } + else if ("VIRTUAL".equals(nature)) + { + abilities.addAll(pc.getVirtualAbilityList(aCategory)); + } + else if ("AUTO".equals(nature)) + { + abilities.addAll(pc.getAutomaticAbilityList(aCategory)); + } + else + { + abilities.addAll(pc.getRealAbilityList(aCategory)); + } + + // Count those abilities that match the visibility level + View view = View.getViewFromName(visibility); + int count = 0; + for (Ability ability : abilities) + { + if (ability.getVisibility().isVisibileTo(view, true)) + { + count++; + } + } + + return new Double(count); + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/jepcommands/CountCommand.java ___________________________________________________________________ Name: keywords + Author Revision Date Id Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/test/pcgen/io/exporttoken/AbilityListTokenTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/io/exporttoken/AbilityListTokenTest.java 2006-11-23 09:05:43 UTC (rev 1692) +++ Trunk/pcgen/code/src/test/pcgen/io/exporttoken/AbilityListTokenTest.java 2006-11-24 11:43:22 UTC (rev 1693) @@ -23,6 +23,8 @@ */ package pcgen.io.exporttoken; +import java.util.List; + import junit.framework.Test; import junit.framework.TestSuite; import pcgen.AbstractCharacterTestCase; @@ -32,7 +34,7 @@ import pcgen.core.SettingsHandler; import pcgen.io.ExportHandler; import pcgen.util.TestHelper; -import plugin.exporttokens.TextToken; +import pcgen.util.enumeration.Visibility; /** * <code>AbilityListTokenTest</code> tests the functioning of the ABILITYLIST @@ -67,6 +69,7 @@ Ability ab1 = TestHelper.makeAbility("Perform (Dance)", "FEAT", "General.Fighter"); ab1.setMultiples("NO"); + ab1.setVisibility(Visibility.DEFAULT); AbilityCategory aCategory = SettingsHandler.getGame() .getAbilityCategory(ab1.getCategory()); if (aCategory == null) @@ -146,4 +149,38 @@ .getToken("ABILITYLIST.BARDIC", character, eh)); } + /** + * Test the JEP count function on abilities. + */ + public void testCount() + { + PlayerCharacter character = getCharacter(); + + assertEquals( + "count(\"ABILITIES\",\"CATEGORY=FEAT\",\"VISIBILITY=VISIBLE\")", 3.0, + character.getVariableValue( + "count(\"ABILITIES\",\"CATEGORY=FEAT\",\"VISIBILITY=VISIBLE\")", + ""), 0.01); + } + + /** + * Test the mechanism of splitting FOR node parameters to + * ensure it copes with JEP functions with multiple comma + * separated parameters. + */ + public void testForNodeSplit() + { + String testStr = "|FOR,%feat,0,count(\"ABILITIES\",\"CATEGORY=FEAT\",\"VISIBILITY=VISIBLE\")-1,1,0|"; + + List<String> result = ExportHandler.getParameters(testStr); + assertEquals("Complex split len", 6, result.size()); + assertEquals("Complex split combined token 0", "|FOR", result.get(0)); + assertEquals("Complex split combined token 1", "%feat", result.get(1)); + assertEquals("Complex split combined token 2", "0", result.get(2)); + assertEquals("Complex split combined token 3", + "count(\"ABILITIES\",\"CATEGORY=FEAT\",\"VISIBILITY=VISIBLE\")-1", + result.get(3)); + assertEquals("Complex split combined token 4", "1", result.get(4)); + assertEquals("Complex split combined token 5", "0|", result.get(5)); + } } \ No newline at end of file Modified: Trunk/pcgen/code/testsuite/base.xml =================================================================== --- Trunk/pcgen/code/testsuite/base.xml 2006-11-23 09:05:43 UTC (rev 1692) +++ Trunk/pcgen/code/testsuite/base.xml 2006-11-24 11:43:22 UTC (rev 1693) @@ -923,7 +923,7 @@ ====================================--> <feats> <!-- Visible standard feats (not including the auto feats) --> -|FOR,%feat,0,COUNT[FEATS.VISIBLE]-1,1,0| +|FOR,%feat,0,count("ABILITIES","CATEGORY=FEAT","VISIBILITY=VISIBLE")-1,1,0| <feat> <name>|ABILITY.FEAT.VISIBLE.%feat|</name> <description>|ABILITY.FEAT.VISIBLE.%feat.DESC|</description> @@ -937,7 +937,7 @@ |ENDFOR| <!-- Auto feats --> -|FOR,%feat,0,COUNT[FEATSAUTO.VISIBLE]-1,1,0| +|FOR,%feat,0,count("ABILITIES","CATEGORY=FEAT","VISIBILITY=VISIBLE","NATURE=AUTO")-1,1,0| <feat> <name>|ABILITYAUTO.FEAT.VISIBLE.%feat|</name> <description>|ABILITYAUTO.FEAT.VISIBLE.%feat.DESC|</description> @@ -978,7 +978,7 @@ </feat> |ENDFOR| <!-- Hidden VFEATS --> -|FOR,%feat,0,COUNT[VFEATS.HIDDEN]-1,1,0| +|FOR,%feat,0,count("ABILITIES","CATEGORY=FEAT","VISIBILITY=HIDDEN","NATURE=VIRTUAL")-1,1,0| <feat> <name>|VABILITY.FEAT.HIDDEN.%feat|</name> <description>|VABILITY.FEAT.HIDDEN.%feat.DESC|</description> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2006-11-26 17:33:35
|
Revision: 1703 http://svn.sourceforge.net/pcgen/?rev=1703&view=rev Author: thpr Date: 2006-11-26 09:33:35 -0800 (Sun, 26 Nov 2006) Log Message: ----------- [ 1599063 ] Deprecate AL Tag in Race Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/AlToken.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/race/AlToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-11-26 17:30:35 UTC (rev 1702) +++ Trunk/pcgen/code/pluginbuild.xml 2006-11-26 17:33:35 UTC (rev 1703) @@ -3431,13 +3431,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/RaceLstToken-AL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/race/AlToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/RaceLstToken-CR.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -5913,6 +5906,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/RaceLstToken-DEPRECATED-AL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/deprecated/AlToken.class" /> + </patternset> + </fileset> + </jar> </target> <target name="manifest" description="Write the Java manifest"> Copied: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/AlToken.java (from rev 1700, Trunk/pcgen/code/src/java/plugin/lsttokens/race/AlToken.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/AlToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/AlToken.java 2006-11-26 17:33:35 UTC (rev 1703) @@ -0,0 +1,34 @@ +package plugin.lsttokens.deprecated; + +import pcgen.core.PObject; +import pcgen.core.Race; +import pcgen.core.prereq.Prerequisite; +import pcgen.persistence.lst.DeprecatedToken; +import pcgen.persistence.lst.RaceLstToken; + +/** + * Class deals with AL Token + */ +public class AlToken implements RaceLstToken, DeprecatedToken { + + public String getTokenName() { + return "AL"; + } + + public boolean parse(Race race, String value) { + // Pass into PREALIGN instead + Prerequisite prereq = new Prerequisite(); + for (int i = 0; i < value.length() ; i++) { + Prerequisite subreq = new Prerequisite(); + subreq.setKind("align"); + subreq.setKey(value.substring(i, i + 1)); + prereq.addPrerequisite(subreq); + } + race.addPreReq(prereq); + return true; + } + + public String getMessage(PObject obj, String value) { + return "AL Tag has been deprecated. Use PREALIGN instead"; + } +} Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/race/AlToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/race/AlToken.java 2006-11-26 17:30:35 UTC (rev 1702) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/race/AlToken.java 2006-11-26 17:33:35 UTC (rev 1703) @@ -1,28 +0,0 @@ -package plugin.lsttokens.race; - -import pcgen.core.Race; -import pcgen.core.prereq.Prerequisite; -import pcgen.persistence.lst.RaceLstToken; - -/** - * Class deals with AL Token - */ -public class AlToken implements RaceLstToken { - - public String getTokenName() { - return "AL"; - } - - public boolean parse(Race race, String value) { - // Pass into PREALIGN instead - Prerequisite prereq = new Prerequisite(); - for (int i = 0; i < value.length() ; i++) { - Prerequisite subreq = new Prerequisite(); - subreq.setKind("align"); - subreq.setKey(value.substring(i, i + 1)); - prereq.addPrerequisite(subreq); - } - race.addPreReq(prereq); - return true; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2006-11-30 09:46:02
|
Revision: 1719 http://svn.sourceforge.net/pcgen/?rev=1719&view=rev Author: jdempsey Date: 2006-11-30 01:45:58 -0800 (Thu, 30 Nov 2006) Log Message: ----------- Freq #1262324 - Ability Object: Output of feats Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityListToken.java Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/DFeatAllToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/FeatAllListToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/FeatAutoListToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/FeatAutoToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/VFeatListToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/VFeatToken.java Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/exporttokens/FeatListToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/FeatToken.java Removed Paths: ------------- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatListToken.java Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-11-29 11:28:03 UTC (rev 1718) +++ Trunk/pcgen/code/pluginbuild.xml 2006-11-30 09:45:58 UTC (rev 1719) @@ -373,6 +373,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${outputplugins.dir}/ExportToken-FEAT.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/FeatToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${outputplugins.dir}/ExportToken-FEATALLLIST.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -394,6 +401,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${outputplugins.dir}/ExportToken-FEATLIST.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/FeatListToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${outputplugins.dir}/ExportToken-FEATPOINTS.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-11-29 11:28:03 UTC (rev 1718) +++ Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-11-30 09:45:58 UTC (rev 1719) @@ -1455,8 +1455,6 @@ addToTokenMap(new DRToken()); addToTokenMap(new EqToken()); addToTokenMap(new EqTypeToken()); - addToTokenMap(new FeatToken()); - addToTokenMap(new FeatListToken()); addToTokenMap(new GameModeToken()); addToTokenMap(new HeightToken()); addToTokenMap(new HPToken()); Modified: Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityListToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityListToken.java 2006-11-29 11:28:03 UTC (rev 1718) +++ Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityListToken.java 2006-11-30 09:45:58 UTC (rev 1719) @@ -51,6 +51,7 @@ { private static final String DELIM = ", "; + //TODO: Should these be static to enable the caching? private List<Ability> abilityList = null; private PlayerCharacter lastPC = null; private int lastPCSerial; @@ -77,8 +78,6 @@ public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) { - StringBuffer retString = new StringBuffer(); - final StringTokenizer aTok = new StringTokenizer(tokenSource, "."); // Skip the ABILITYLIST token itself final String tokenString = aTok.nextToken(); @@ -86,6 +85,22 @@ final AbilityCategory aCategory = SettingsHandler.getGame() .getAbilityCategory(catString); + return getTokenForCategory(pc, aTok, tokenString, aCategory); + } + + /** + * Produce the ABILITY token output for a specific ability + * category. + * + * @param pc The character being processed. + * @param aTok The tokenised request, already past the category. + * @param tokenString The output token requested + * @param aCategory The ability category being output. + * @return The token value. + */ + protected String getTokenForCategory(PlayerCharacter pc, final StringTokenizer aTok, final String tokenString, final AbilityCategory aCategory) + { + StringBuffer retString = new StringBuffer(); if (lastPC != pc || !aCategory.equals(lastCategory) || lastPCSerial != pc.getSerial() || !tokenString.equals(lastType)) { Modified: Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityToken.java 2006-11-29 11:28:03 UTC (rev 1718) +++ Trunk/pcgen/code/src/java/pcgen/io/exporttoken/AbilityToken.java 2006-11-30 09:45:58 UTC (rev 1719) @@ -63,6 +63,7 @@ //private int visibility = ABILITY_DEFAULT; private List<Ability> abilityList = new ArrayList<Ability>(); + //TODO: Should these be static? They probably never get used if not. private PlayerCharacter cachedPC = null; private int cachedPcSerial = 0; private String lastToken = null; @@ -94,6 +95,23 @@ final AbilityCategory aCategory = SettingsHandler.getGame() .getAbilityCategory(catString); + return getTokenForCategory(tokenSource, pc, eh, aTok, tokenString, aCategory); + } + + /** + * Produce the ABILITY token output for a specific ability + * category. + * + * @param tokenSource The token being processed. + * @param pc The character being processed. + * @param eh The export handler in use for the export. + * @param aTok The tokenised request, already past the category. + * @param tokenString The output token requested + * @param aCategory The ability category being output. + * @return The token value. + */ + protected String getTokenForCategory(String tokenSource, PlayerCharacter pc, ExportHandler eh, final StringTokenizer aTok, final String tokenString, final AbilityCategory aCategory) + { if (cachedPC != pc || !aCategory.equals(lastCategory) || cachedPcSerial != pc.getSerial() || !tokenString.equals(lastToken)) { Deleted: Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatListToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatListToken.java 2006-11-29 11:28:03 UTC (rev 1718) +++ Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatListToken.java 2006-11-30 09:45:58 UTC (rev 1719) @@ -1,172 +0,0 @@ -package pcgen.io.exporttoken; - -import pcgen.core.Ability; -import pcgen.core.Globals; -import pcgen.core.PlayerCharacter; -import pcgen.io.ExportHandler; -import pcgen.util.enumeration.Visibility; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -/** - * @author karianna - * Class deals with FEATLIST Token - */ -public class FeatListToken extends Token -{ - String delim = ""; - List<Ability> featList = null; - PlayerCharacter lastPC = null; - String lastType = ""; - - /** Token Name */ - public static final String TOKENNAME = "FEATLIST"; - - /** - * Get the TOKENNAME - * @return TOKENNAME - */ - @Override - public String getTokenName() - { - return TOKENNAME; - } - - /** - * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) - */ - @Override - public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) - { - StringBuffer retString = new StringBuffer(); - - delim = getDelimiter(tokenSource); - - if (lastType != getTokenName() || pc != lastPC) - { - featList = getFeatList(pc); - } - - if ((delim == null) || "".equals(delim)) - { - delim = ", "; - } - - String aString = ""; - - if (delim.lastIndexOf('.') >= 0) - { - try - { - aString = delim.substring(delim.lastIndexOf('.')); - } - catch (StringIndexOutOfBoundsException e) - { - return ""; - } - } - - delim = ", "; - boolean needComma = false; - - int dotpos = aString.indexOf('.'); - String typeStr = ""; - - if (aString.indexOf("TYPE") > 0) - { - typeStr = aString.substring(dotpos); - } - - Globals.sortPObjectListByName(featList); - - for (Ability aFeat : featList) - { - String test; //will hold token we are testing against - StringTokenizer st = null; - int clusive = 0; //clusive 0 = no type, 1 = inclusive(.TYPE), 2 = exclusive(.!TYPE=) - int match = 0; //match 0 = does not match type, 1 = feat matches type - - //Test for inclusive/exclusive - if (aString.indexOf(".TYPE=") >= 0) - { - clusive = 1; - st = new StringTokenizer(typeStr.substring(5), "="); - } - else if (aString.indexOf(".!TYPE=") >= 0) - { - clusive = 2; - st = new StringTokenizer(typeStr.substring(6), "="); - } - - if ((clusive == 1) || (clusive == 2)) - { - while (st.hasMoreTokens()) - { - test = st.nextToken(); - - if (aFeat.isType(test)) - { - match = 1; - } - } - } - - int doIprint = 1; - - if (((clusive == 1) && (match == 0)) || ((clusive == 2) && (match == 1))) - { - doIprint = 0; - } - - if (doIprint == 1) - { - if ((aFeat.getVisibility() == Visibility.DEFAULT) - || (aFeat.getVisibility() == Visibility.OUTPUT_ONLY)) - { - if (needComma) - { - retString.append(delim); - } - needComma = true; - - retString.append(aFeat.qualifiedName()); - } - } - } - - return retString.toString(); - } - - protected String getDelimiter(final String tokenSource) - { - return tokenSource.substring(8); - } - - /** - * Returns the correct list of feats for the character. - * This method is overridden in subclasses if they need to change the list - * of feats looked at. - * - * @param pc the character who's feats we are retrieving. - * @return List of feats. - */ - protected List<Ability> getFeatList(PlayerCharacter pc) - { - List<Ability> listOfFeats = new ArrayList<Ability>(); - for (Ability aFeat : pc.getRealFeatList()) { - listOfFeats.add(aFeat); - } - return listOfFeats; - } - - /** - * Set the deliminator - * @param aDelim - */ - protected void setDelim(String aDelim) { - delim = aDelim; - } - -} Deleted: Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatToken.java 2006-11-29 11:28:03 UTC (rev 1718) +++ Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatToken.java 2006-11-30 09:45:58 UTC (rev 1719) @@ -1,253 +0,0 @@ -package pcgen.io.exporttoken; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import pcgen.core.Ability; -import pcgen.core.Globals; -import pcgen.core.PlayerCharacter; -import pcgen.io.ExportHandler; -import pcgen.util.enumeration.Visibility; - -/** - * @author karianna - * - * Class deals with FEAT Token - */ -public class FeatToken extends Token { - - /** Token Name */ - public static final String TOKENNAME = "FEAT"; - - /** Default Feat = 0**/ - public final int FEAT_DEFAULT = 0; - /** Visible Feat = 1 */ - public final int FEAT_VISIBLE = 1; - /** Hidden Feat = 2 */ - public final int FEAT_HIDDEN = 2; - /** All Feats = 3 */ - public final int FEAT_ALL = 3; - - private int visibility = FEAT_DEFAULT; - private List<Ability> feat = new ArrayList<Ability>(); - private PlayerCharacter cachedPC = null; - private int cachedPcSerial = 0; - private String lastMode = ""; - - /** - * Get the TOKENNAME - * @return TOKENNAME - */ - @Override - public String getTokenName() { - return TOKENNAME; - } - - /** - * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, - * pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) - */ - @Override - public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) { - - String retString = ""; - - final StringTokenizer aTok = new StringTokenizer(tokenSource, "."); - final String fString = aTok.nextToken(); - - if (cachedPC != pc || !fString.equals(lastMode) || cachedPcSerial != pc.getSerial()) - { - // Overridden by subclasses to return the right list. - feat = getFeatList(pc); - } - cachedPC = pc; - lastMode = fString; - cachedPcSerial = pc.getSerial(); - - List<String> types = new ArrayList<String>(); - List<String> negate = new ArrayList<String>(); - String featType = null; - - // i holds the number of the feat we want, is decremented - // as we iterate through the list. It is only decremented - // if the current feat matches the desired feat - int i = -1; - - if ("FEAT".equals(fString) || "VFEAT".equals(fString) || "FEATALL".equals(fString) || "FEATAUTO".equals(fString)) { - while (aTok.hasMoreTokens()) { - final String bString = aTok.nextToken(); - - try { - i = Integer.parseInt(bString); - - break; - } catch (NumberFormatException exc) { - if (bString.equals("VISIBLE")) { - visibility = FEAT_VISIBLE; - continue; - } else if (bString.equals("HIDDEN")) { - visibility = FEAT_HIDDEN; - continue; - } else if (bString.equals("ALL")) { - visibility = FEAT_ALL; - continue; - } else { - featType = bString; - } - } - - } - - while (aTok.hasMoreTokens()) - { - final String typeStr = aTok.nextToken(); - - int typeInd = typeStr.indexOf("TYPE"); - if (typeInd != -1 && typeStr.length() > 4) - { - if (typeInd > 0) - { - negate.add(typeStr.substring(typeInd + 5)); - } - else - { - types.add(typeStr.substring(typeInd + 5)); - } - } - } - } - - List<Ability> aList = new ArrayList<Ability>(); - - Globals.sortPObjectListByName(feat); - - for (Ability aFeat : feat) { - - boolean matchTypeDef = false; - boolean matchVisibilityDef = false; - - if (featType != null) { - if (aFeat.isType(featType)) { - matchTypeDef = true; - } - } else { - matchTypeDef = true; - } - - boolean istype = false; - boolean isnttype = true; - - // is at leas one of the types we've asked for - if (types.size() > 0) - { - for (String typeStr : types) - { - istype |= aFeat.isType(typeStr); - } - } - else - { - istype = true; - } - - // isn't all the types we've said it's not - for (String typeStr : negate) - { - isnttype &= !aFeat.isType(typeStr); - } - - matchTypeDef = matchTypeDef && istype && isnttype; - - switch ( visibility ) - { - case FEAT_ALL: - matchVisibilityDef = true; - break; - case FEAT_HIDDEN: - if ( aFeat.getVisibility() == Visibility.HIDDEN - || aFeat.getVisibility() == Visibility.DISPLAY_ONLY ) - { - matchVisibilityDef = true; - } - break; - case FEAT_VISIBLE: // Fall thru intentional - default: - if ( aFeat.getVisibility() == Visibility.DEFAULT - || aFeat.getVisibility() == Visibility.OUTPUT_ONLY ) - { - matchVisibilityDef = true; - } - break; - } - - if (matchTypeDef && matchVisibilityDef) { - aList.add(aFeat); - } - } - - Ability aFeat; - if (i < aList.size()) { - aFeat = aList.get(i); - - if (i == aList.size() - 1 && eh != null && eh.getExistsOnly()) - { - eh.setNoMoreItems(true); - } - else if (eh != null && eh.getExistsOnly()) - { - eh.setNoMoreItems(true); - } - - if (tokenSource.endsWith(".DESC")) { - retString += aFeat.getDescription(pc); - } else if (tokenSource.endsWith(".TYPE")) { - retString += aFeat.getType(); - } else if (tokenSource.endsWith(".ASSOCIATED")) { - StringBuffer buf = new StringBuffer(); - - for (int j = 0; j < aFeat.getAssociatedCount(); j++) { - if (j != 0) { - buf.append(","); - } - buf.append(aFeat.getAssociated(j)); - } - - retString += buf.toString(); - } else if (tokenSource.endsWith(".ASSOCIATEDCOUNT")) { - retString += Integer.toString(aFeat.getAssociatedCount()); - } else if (tokenSource.endsWith(".SOURCE")) { - retString += aFeat.getDefaultSourceString(); - } else { - retString += aFeat.qualifiedName(); - } - } - - return retString; - } - - /** - * Returns the correct list of feats for the character. - * This method is overridden in subclasses if they need to change the list - * of feats looked at. - * - * @param pc the character who's feats we are retrieving. - * @return List of feats. - */ - protected List<Ability> getFeatList(PlayerCharacter pc) - { - List<Ability> featList = new ArrayList<Ability>(); - for (Ability aFeat : pc.getRealFeatList()) { - featList.add(aFeat); - } - return featList; - } - - /** - * Set the visibility - * @param aVisibility - */ - protected void setVisibility(int aVisibility) { - visibility = aVisibility; - } -} Modified: Trunk/pcgen/code/src/java/plugin/exporttokens/DFeatAllToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/DFeatAllToken.java 2006-11-29 11:28:03 UTC (rev 1718) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/DFeatAllToken.java 2006-11-30 09:45:58 UTC (rev 1719) @@ -1,19 +1,17 @@ package plugin.exporttokens; -import java.util.List; +import java.util.StringTokenizer; import pcgen.core.AbilityCategory; import pcgen.core.PlayerCharacter; +import pcgen.core.SettingsHandler; import pcgen.io.ExportHandler; -import pcgen.io.exporttoken.FeatToken; -import java.util.ArrayList; -import pcgen.core.Ability; /** * @author karianna * Class deals with FEATALL Token */ -public class DFeatAllToken extends FeatToken +public class DFeatAllToken extends AbilityAllToken { /** @@ -29,19 +27,13 @@ */ public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) { - setVisibility(FEAT_ALL); - return super.getToken(tokenSource, pc, eh); - } + setVisibility(ABILITY_ALL); + final StringTokenizer aTok = new StringTokenizer(tokenSource, "."); + final String fString = aTok.nextToken(); + final AbilityCategory aCategory = SettingsHandler.getGame() + .getAbilityCategory("FEAT"); - /** - * @see pcgen.io.exporttoken.FeatToken#getFeatList(pcgen.core.PlayerCharacter) - */ - protected List<Ability> getFeatList(PlayerCharacter pc) - { - List<Ability> ret = new ArrayList<Ability>(); - ret.addAll(pc.getRealAbilityList(AbilityCategory.FEAT)); - ret.addAll(pc.featAutoList()); - ret.addAll(pc.getVirtualFeatList()); - return ret; + return getTokenForCategory(tokenSource, pc, eh, aTok, fString, + aCategory); } } Modified: Trunk/pcgen/code/src/java/plugin/exporttokens/FeatAllListToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/FeatAllListToken.java 2006-11-29 11:28:03 UTC (rev 1718) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/FeatAllListToken.java 2006-11-30 09:45:58 UTC (rev 1719) @@ -1,39 +1,41 @@ package plugin.exporttokens; -import java.util.List; +import java.util.StringTokenizer; -import pcgen.core.Ability; +import pcgen.core.AbilityCategory; import pcgen.core.PlayerCharacter; -import pcgen.io.exporttoken.FeatListToken; +import pcgen.core.SettingsHandler; +import pcgen.io.ExportHandler; /** * @author karianna * Class deals with FEATALLLIST Token */ -public class FeatAllListToken extends FeatListToken +public class FeatAllListToken extends AbilityAllListToken { /** * @see pcgen.io.exporttoken.Token#getTokenName() */ + @Override public String getTokenName() { return "FEATALLLIST"; } /** - * @see pcgen.io.exporttoken.FeatListToken#getDelimiter(String tokenSource) + * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) */ - protected String getDelimiter(final String tokenSource) + @Override + public String getToken(String tokenSource, PlayerCharacter pc, + ExportHandler eh) { - return tokenSource.substring(11); - } + final StringTokenizer aTok = new StringTokenizer(tokenSource, "."); + // Skip the token itself + final String tokenString = aTok.nextToken(); + final AbilityCategory aCategory = SettingsHandler.getGame() + .getAbilityCategory("FEAT"); - /** - * @see pcgen.io.exporttoken.FeatListToken#getFeatList(PlayerCharacter) - */ - protected List<Ability> getFeatList(PlayerCharacter pc) - { - return pc.aggregateVisibleFeatList(); + return getTokenForCategory(pc, aTok, tokenString, aCategory); } } Modified: Trunk/pcgen/code/src/java/plugin/exporttokens/FeatAutoListToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/FeatAutoListToken.java 2006-11-29 11:28:03 UTC (rev 1718) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/FeatAutoListToken.java 2006-11-30 09:45:58 UTC (rev 1719) @@ -1,39 +1,41 @@ package plugin.exporttokens; -import java.util.List; +import java.util.StringTokenizer; -import pcgen.core.Ability; +import pcgen.core.AbilityCategory; import pcgen.core.PlayerCharacter; -import pcgen.io.exporttoken.FeatListToken; +import pcgen.core.SettingsHandler; +import pcgen.io.ExportHandler; /** * @author karianna * Class deals with FEATAUTOLIST Token */ -public class FeatAutoListToken extends FeatListToken +public class FeatAutoListToken extends AbilityAutoListToken { /** * @see pcgen.io.exporttoken.Token#getTokenName() */ + @Override public String getTokenName() { return "FEATAUTOLIST"; } /** - * @see pcgen.io.exporttoken.FeatListToken#getDelimiter(String) + * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) */ - protected String getDelimiter(final String tokenSource) + @Override + public String getToken(String tokenSource, PlayerCharacter pc, + ExportHandler eh) { - return tokenSource.substring(12); - } + final StringTokenizer aTok = new StringTokenizer(tokenSource, "."); + // Skip the token itself + final String tokenString = aTok.nextToken(); + final AbilityCategory aCategory = SettingsHandler.getGame() + .getAbilityCategory("FEAT"); - /** - * @see pcgen.io.exporttoken.FeatListToken#getFeatList(PlayerCharacter) - */ - protected List<Ability> getFeatList(PlayerCharacter pc) - { - return pc.featAutoList(); + return getTokenForCategory(pc, aTok, tokenString, aCategory); } } Modified: Trunk/pcgen/code/src/java/plugin/exporttokens/FeatAutoToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/FeatAutoToken.java 2006-11-29 11:28:03 UTC (rev 1718) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/FeatAutoToken.java 2006-11-30 09:45:58 UTC (rev 1719) @@ -1,16 +1,17 @@ package plugin.exporttokens; -import java.util.List; +import java.util.StringTokenizer; +import pcgen.core.AbilityCategory; import pcgen.core.PlayerCharacter; -import pcgen.io.exporttoken.FeatToken; -import pcgen.core.Ability; +import pcgen.core.SettingsHandler; +import pcgen.io.ExportHandler; /** * @author karianna * Class deals with FEATAUTO Token */ -public class FeatAutoToken extends FeatToken +public class FeatAutoToken extends AbilityAutoToken { /** @@ -22,10 +23,16 @@ } /** - * @see pcgen.io.exporttoken.FeatToken#getFeatList(pcgen.core.PlayerCharacter) + * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) */ - protected List<Ability> getFeatList(PlayerCharacter pc) + public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) { - return pc.featAutoList(); + final StringTokenizer aTok = new StringTokenizer(tokenSource, "."); + final String fString = aTok.nextToken(); + final AbilityCategory aCategory = SettingsHandler.getGame() + .getAbilityCategory("FEAT"); + + return getTokenForCategory(tokenSource, pc, eh, aTok, fString, + aCategory); } } Copied: Trunk/pcgen/code/src/java/plugin/exporttokens/FeatListToken.java (from rev 1715, Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatListToken.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/FeatListToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/FeatListToken.java 2006-11-30 09:45:58 UTC (rev 1719) @@ -0,0 +1,52 @@ +package plugin.exporttokens; + +import java.util.StringTokenizer; + +import pcgen.core.AbilityCategory; +import pcgen.core.PlayerCharacter; +import pcgen.core.SettingsHandler; +import pcgen.io.ExportHandler; +import pcgen.io.exporttoken.AbilityListToken; + +/** + * <code>FeatListToken</code> deals with FEATLIST Token + * + * Last Editor: $Author$ + * Last Edited: $Date$ + * + * @author karianna + * @version $Revision$ + */ +public class FeatListToken extends AbilityListToken +{ + + /** Token Name */ + public static final String TOKENNAME = "FEATLIST"; + + /** + * Get the TOKENNAME + * @return TOKENNAME + */ + @Override + public String getTokenName() + { + return TOKENNAME; + } + + /** + * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) + */ + @Override + public String getToken(String tokenSource, PlayerCharacter pc, + ExportHandler eh) + { + final StringTokenizer aTok = new StringTokenizer(tokenSource, "."); + // Skip the ABILITYLIST token itself + final String tokenString = aTok.nextToken(); + final AbilityCategory aCategory = SettingsHandler.getGame() + .getAbilityCategory("FEAT"); + + return getTokenForCategory(pc, aTok, tokenString, aCategory); + } + +} Copied: Trunk/pcgen/code/src/java/plugin/exporttokens/FeatToken.java (from rev 1715, Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatToken.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/FeatToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/FeatToken.java 2006-11-30 09:45:58 UTC (rev 1719) @@ -0,0 +1,49 @@ +package plugin.exporttokens; + +import java.util.StringTokenizer; + +import pcgen.core.AbilityCategory; +import pcgen.core.PlayerCharacter; +import pcgen.core.SettingsHandler; +import pcgen.io.ExportHandler; +import pcgen.io.exporttoken.AbilityToken; + +/** + * @author karianna + * + * Class deals with FEAT Token + */ +public class FeatToken extends AbilityToken +{ + + /** Token Name */ + public static final String TOKENNAME = "FEAT"; + + /** + * Get the TOKENNAME + * @return TOKENNAME + */ + @Override + public String getTokenName() + { + return TOKENNAME; + } + + /** + * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, + * pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) + */ + @Override + public String getToken(String tokenSource, PlayerCharacter pc, + ExportHandler eh) + { + + final StringTokenizer aTok = new StringTokenizer(tokenSource, "."); + final String fString = aTok.nextToken(); + final AbilityCategory aCategory = SettingsHandler.getGame() + .getAbilityCategory("FEAT"); + + return getTokenForCategory(tokenSource, pc, eh, aTok, fString, + aCategory); + } +} Modified: Trunk/pcgen/code/src/java/plugin/exporttokens/VFeatListToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/VFeatListToken.java 2006-11-29 11:28:03 UTC (rev 1718) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/VFeatListToken.java 2006-11-30 09:45:58 UTC (rev 1719) @@ -1,10 +1,11 @@ package plugin.exporttokens; -import java.util.List; +import java.util.StringTokenizer; -import pcgen.core.Ability; +import pcgen.core.AbilityCategory; import pcgen.core.PlayerCharacter; -import pcgen.io.exporttoken.FeatListToken; +import pcgen.core.SettingsHandler; +import pcgen.io.ExportHandler; /** * <code>VFeatListToken</code> deals with VFEATLIST output token. @@ -15,31 +16,31 @@ * @author karianna * @version $Revision$ */ -public class VFeatListToken extends FeatListToken +public class VFeatListToken extends VAbilityListToken { /** * @see pcgen.io.exporttoken.Token#getTokenName() */ + @Override public String getTokenName() { return "VFEATLIST"; } /** - * @see pcgen.io.exporttoken.FeatListToken#getFeatList(PlayerCharacter) + * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) */ - protected List<Ability> getFeatList(PlayerCharacter pc) + @Override + public String getToken(String tokenSource, PlayerCharacter pc, + ExportHandler eh) { - return pc.getVirtualFeatList(); - } + final StringTokenizer aTok = new StringTokenizer(tokenSource, "."); + // Skip the token itself + final String tokenString = aTok.nextToken(); + final AbilityCategory aCategory = SettingsHandler.getGame() + .getAbilityCategory("FEAT"); - /** - * @see pcgen.io.exporttoken.FeatListToken#getDelimiter(String) - */ - protected String getDelimiter(final String tokenSource) - { - return tokenSource.substring(9); + return getTokenForCategory(pc, aTok, tokenString, aCategory); } - } Modified: Trunk/pcgen/code/src/java/plugin/exporttokens/VFeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/VFeatToken.java 2006-11-29 11:28:03 UTC (rev 1718) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/VFeatToken.java 2006-11-30 09:45:58 UTC (rev 1719) @@ -1,10 +1,11 @@ package plugin.exporttokens; -import java.util.List; +import java.util.StringTokenizer; +import pcgen.core.AbilityCategory; import pcgen.core.PlayerCharacter; -import pcgen.io.exporttoken.FeatToken; -import pcgen.core.Ability; +import pcgen.core.SettingsHandler; +import pcgen.io.ExportHandler; /** * <code>VFeatToken</code> deals with VFEAT output token. @@ -15,7 +16,7 @@ * @author karianna * @version $Revision$ */ -public class VFeatToken extends FeatToken +public class VFeatToken extends VAbilityToken { /** * @see pcgen.io.exporttoken.Token#getTokenName() @@ -26,10 +27,17 @@ } /** - * @see pcgen.io.exporttoken.FeatToken#getFeatList(PlayerCharacter) + * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter, pcgen.io.ExportHandler) */ - protected List<Ability> getFeatList(PlayerCharacter pc) + public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) { - return pc.getVirtualFeatList(); + setVisibility(ABILITY_ALL); + final StringTokenizer aTok = new StringTokenizer(tokenSource, "."); + final String fString = aTok.nextToken(); + final AbilityCategory aCategory = SettingsHandler.getGame() + .getAbilityCategory("FEAT"); + + return getTokenForCategory(tokenSource, pc, eh, aTok, fString, + aCategory); } -} +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2007-01-03 07:53:54
|
Revision: 1870 http://svn.sourceforge.net/pcgen/?rev=1870&view=rev Author: jdempsey Date: 2007-01-02 23:53:55 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Freq #1262317 - Ability Object: Add ability tags - Remove obsolete Template-specific Ability tag. - Add support of global ABILITY tag in LEVEL and HD Freq #1025273 - LEVEL & HD tags need to be able to call all global tags - Add support of all global tags that support PREREQs to LEVEL and HD Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/PCTemplateLoader.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/HdToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2007-01-03 07:49:14 UTC (rev 1869) +++ Trunk/pcgen/code/pluginbuild.xml 2007-01-03 07:53:55 UTC (rev 1870) @@ -3884,13 +3884,6 @@ <target name="jar-lst-template-plugins" depends="makeplugindirs" description="Build (Link) Weapon Prof Lst Token plugin jar files"> <!-- Template tokens--> - <jar jarfile="${lstplugins.dir}/TemplateLstToken-ABILITY.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/template/AbilityToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/TemplateLstToken-ADDLEVEL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2007-01-03 07:49:14 UTC (rev 1869) +++ Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2007-01-03 07:53:55 UTC (rev 1870) @@ -32,7 +32,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.StringTokenizer; import pcgen.core.levelability.LevelAbility; @@ -62,8 +61,6 @@ private AbilityStore abilityCatStore = null; private List<String> featStrings = null; - /** A Map storing a List of Ability keys Keyed on AbilityCategory */ - private Map<AbilityCategory, List<String>> theAutoAbilityKeys = null; private List<String> hitDiceStrings = null; private List<String> templates = new ArrayList<String>(); @@ -575,32 +572,7 @@ txt.append("\tFEAT:").append(buffer.toString()); } - // TODO - Need a tag for this - if (theAutoAbilityKeys != null) - { - final Set<AbilityCategory> categories = theAutoAbilityKeys.keySet(); - for (final AbilityCategory category : categories) - { - if (category == AbilityCategory.FEAT) - { - continue; - } - final StringBuffer buffer = new StringBuffer(); - for (final String key : theAutoAbilityKeys.get(category)) - { - if (buffer.length() != 0) - { - buffer.append(Constants.PIPE); - } - buffer.append(key); - } - txt.append("\tABILITY:AUTO|CATEGORY=").append( - category.getKeyName()).append("|") - .append(buffer.toString()); - } - } - if (!Constants.s_NONE.equals(gender)) { txt.append("\tGENDERLOCK:").append(gender); @@ -1139,15 +1111,6 @@ */ public void addHitDiceString(final String hitDiceString) { - if (".CLEAR".equals(hitDiceString)) - { - if (hitDiceStrings != null) - { - hitDiceStrings.clear(); - } - - return; - } StringTokenizer tok = new StringTokenizer(hitDiceString, ":"); String hdStr = tok.nextToken(); String typeStr = tok.nextToken(); @@ -1185,6 +1148,17 @@ } /** + * Clear the list of HD strings for this template. + */ + public void clearHitDiceStrings() + { + if (hitDiceStrings != null) + { + hitDiceStrings.clear(); + } + } + + /** * Get a list of strings which may grant the following abilities at a given * hit die: * @@ -1423,12 +1397,6 @@ aTemp.featStrings = new ArrayList<String>(featStrings); } - if (theAutoAbilityKeys != null) - { - aTemp.theAutoAbilityKeys = new HashMap<AbilityCategory, List<String>>( - theAutoAbilityKeys); - } - if (chosenFeatStrings != null) { aTemp.chosenFeatStrings = new HashMap<String, String>( @@ -1827,7 +1795,6 @@ * @param aPC * The PC that this Template is appled to */ - // TODO - This should be refactored to use the LevelAbility code. private void getLevelFeat(final String featString, final int lvl, final String aKey, final PlayerCharacter aPC) { @@ -1887,64 +1854,6 @@ addChosenFeat(aKey, featKe); } - private void getLevelAbility(final String anAbilityString, - final int aLevel, final PlayerCharacter aPC) - { - String abilityKey = null; - while (true) - { - List<String> abilityList = new ArrayList<String>(); - final LevelAbility la = LevelAbility.createAbility(this, aLevel, - "FEAT(" + anAbilityString + ")"); - - la.process(abilityList, aPC, null); - - switch (abilityList.size()) - { - case 1: - abilityKey = abilityList.get(0); - - break; - - default: - - if ((aPC != null) && !aPC.isImporting()) - { - Collections.sort(abilityList); - - final ChooserInterface c = ChooserFactory - .getChooserInstance(); - c.setPool(1); - c.setTitle("Ability Choice"); - c.setAvailableList(abilityList); - c.setVisible(true); - abilityList = c.getSelectedList(); - - if ((abilityList != null) && (abilityList.size() != 0)) - { - abilityKey = abilityList.get(0); - - continue; - } - } - - // fall-through intentional - case 0: - return; - } - - break; - } - final LevelAbility la = LevelAbility.createAbility(this, aLevel, - "FEAT(" + abilityKey + ")"); - - aPC.setAllowFeatPoolAdjustment(false); - la.process(null, aPC, null); - aPC.setAllowFeatPoolAdjustment(true); - - addChosenFeat("L" + aLevel, abilityKey); - } - /** * Add a chosen feat to the Template * @@ -2034,30 +1943,10 @@ addAbilityString("CATEGORY=FEAT|" + abilityString); } - public void addAbilityString(final AbilityCategory aCategory, - final String anAbilityKey) - { - if (aCategory == AbilityCategory.FEAT) - { - addFeatString(anAbilityKey); - return; - } - - if (theAutoAbilityKeys == null) - { - theAutoAbilityKeys = new HashMap<AbilityCategory, List<String>>(); - } - // TODO - Move this to token processing. - if (".CLEAR".equals(anAbilityKey)) - { - theAutoAbilityKeys.put(aCategory, null); - return; - } - - } - /** - * TODO DOCUMENT ME! + * Retrieve the list of the keynames of any feats + * that the PC qualifies for at the supplied level and + * hit dice. * * @param level * TODO DOCUMENT ME! @@ -2169,70 +2058,6 @@ return feats; } - public List<String> getAutoAbilityKeys(final AbilityCategory aCategory, - final PlayerCharacter aPC, final boolean addNew) - { - if (aCategory == AbilityCategory.FEAT) - { - return this.feats(aPC.getTotalLevels(), aPC.totalHitDice(), aPC, - addNew); - } - - List<String> ret = null; - - if (theAutoAbilityKeys != null) - { - ret = theAutoAbilityKeys.get(aCategory); - } - if (ret == null) - { - ret = new ArrayList<String>(); - } - - // Add all the abilities we have already chosen - if (theChosenAbilityKeys != null) - { - final Map<String, String> choices = theChosenAbilityKeys - .get(aCategory); - ret.addAll(choices.values()); - } - - if (theLevelAbilities != null) - { - for (int lvl = 0; lvl < aPC.getTotalLevels(); lvl++) - { - // TODO - Need to deal with this - final String abilityString = theLevelAbilities.get(lvl, - "ABILITY"); - if (abilityString != null) - { - this.getLevelAbility(abilityString, lvl, aPC); - } - } - } - - for (int x = 0; x < getListSize(hitDiceStrings); ++x) - { - final String featKey = "H" + Integer.toString(x); - String featName = null; - - if (chosenFeatStrings != null) - { - featName = chosenFeatStrings.get(featKey); - } - - if ((featName == null) && addNew) - { - if (doesHitDiceQualify(aPC.totalHitDice(), x)) - { - getLevelFeat(hitDiceStrings.get(x), -1, featKey, aPC); - } - } - } - - return ret; - } - /** * Set face * Modified: Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2007-01-03 07:49:14 UTC (rev 1869) +++ Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2007-01-03 07:53:55 UTC (rev 1870) @@ -973,7 +973,7 @@ // // Save level and hit dice abilities // - thisPCTemplate.addHitDiceString(".CLEAR"); + thisPCTemplate.clearHitDiceStrings(); thisPCTemplate.clearLevelAbilities(); sel = pnlLevelAbilities.getSelectedList(); Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/PCTemplateLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/PCTemplateLoader.java 2007-01-03 07:49:14 UTC (rev 1869) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/PCTemplateLoader.java 2007-01-03 07:53:55 UTC (rev 1870) @@ -40,7 +40,7 @@ * @author David Rice <dav...@jc...> * @version $Revision$ */ -final class PCTemplateLoader +public final class PCTemplateLoader { /** Creates a new instance of PCTemplateLoader */ private PCTemplateLoader() Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/template/HdToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/HdToken.java 2007-01-03 07:49:14 UTC (rev 1869) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/HdToken.java 2007-01-03 07:53:55 UTC (rev 1870) @@ -1,7 +1,15 @@ package plugin.lsttokens.template; +import java.util.Map; +import java.util.StringTokenizer; + import pcgen.core.PCTemplate; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.lst.LstToken; import pcgen.persistence.lst.PCTemplateLstToken; +import pcgen.persistence.lst.PObjectLoader; +import pcgen.persistence.lst.TokenStore; +import pcgen.util.Logging; /** * Class deals with HD Token @@ -9,14 +17,50 @@ public class HdToken implements PCTemplateLstToken { + /* (non-Javadoc) + * @see pcgen.persistence.lst.LstToken#getTokenName() + */ public String getTokenName() { return "HD"; } + /* (non-Javadoc) + * @see pcgen.persistence.lst.PCTemplateLstToken#parse(pcgen.core.PCTemplate, java.lang.String) + */ public boolean parse(PCTemplate template, String value) { - template.addHitDiceString(value); + if (".CLEAR".equals(value)) + { + template.clearHitDiceStrings(); + return true; + } + + StringTokenizer tok = new StringTokenizer(value, ":"); + String hdStr = tok.nextToken(); + String typeStr = tok.nextToken(); + Map<String, LstToken> tokenMap = + TokenStore.inst().getTokenMap(PCTemplateLstToken.class); + PCTemplateLstToken token = (PCTemplateLstToken) tokenMap.get(typeStr); + + if (token != null) + { + template.addHitDiceString(value); + } + else + { + String tagValue = + value.substring(hdStr.length() + 1) + "|PREHD:" + hdStr; + try + { + return PObjectLoader.parseTag(template, tagValue); + } + catch (PersistenceLayerException e) + { + Logging.errorPrint("Failed to parse " + value + ".", e); + return false; + } + } return true; } } Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelToken.java 2007-01-03 07:49:14 UTC (rev 1869) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelToken.java 2007-01-03 07:53:55 UTC (rev 1870) @@ -1,21 +1,37 @@ package plugin.lsttokens.template; +import java.util.Map; import java.util.StringTokenizer; import pcgen.core.PCTemplate; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.lst.LstToken; import pcgen.persistence.lst.PCTemplateLstToken; +import pcgen.persistence.lst.PObjectLoader; +import pcgen.persistence.lst.TokenStore; +import pcgen.util.Logging; /** * Class deals with LEVEL Token + * + * Last Editor: $Author$ + * Last Edited: $Date$ + * + * @version $Revision$ */ public class LevelToken implements PCTemplateLstToken { - + /* (non-Javadoc) + * @see pcgen.persistence.lst.LstToken#getTokenName() + */ public String getTokenName() { return "LEVEL"; } + /* (non-Javadoc) + * @see pcgen.persistence.lst.PCTemplateLstToken#parse(pcgen.core.PCTemplate, java.lang.String) + */ public boolean parse(PCTemplate template, String value) { if (".CLEAR".equals(value)) @@ -38,7 +54,27 @@ } final String typeStr = tok.nextToken(); - template.addLevelAbility(level, typeStr, tok.nextToken()); + Map<String, LstToken> tokenMap = + TokenStore.inst().getTokenMap(PCTemplateLstToken.class); + PCTemplateLstToken token = (PCTemplateLstToken) tokenMap.get(typeStr); + + if (token != null) + { + template.addLevelAbility(level, typeStr, tok.nextToken()); + } + else + { + String tagValue = value.substring(levelStr.length() + 1); + try + { + return PObjectLoader.parseTagLevel(template, tagValue, level); + } + catch (PersistenceLayerException e) + { + Logging.errorPrint("Failed to parse " + value + ".", e); + return false; + } + } return true; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <za...@us...> - 2007-01-04 12:59:07
|
Revision: 1872 http://svn.sourceforge.net/pcgen/?rev=1872&view=rev Author: zaister Date: 2007-01-04 04:59:01 -0800 (Thu, 04 Jan 2007) Log Message: ----------- [ 1627789 ] Implement PREREACH Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/pretokens/parser/PreReachParser.java Trunk/pcgen/code/src/java/plugin/pretokens/test/PreReachTester.java Trunk/pcgen/code/src/java/plugin/pretokens/writer/PreReachWriter.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2007-01-03 17:40:10 UTC (rev 1871) +++ Trunk/pcgen/code/pluginbuild.xml 2007-01-04 12:59:01 UTC (rev 1872) @@ -1657,6 +1657,15 @@ </patternset> </fileset> </jar> + <jar jarfile="${preplugins.dir}/PreToken-PREREACH.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/pretokens/parser/PreReachParser.class" /> + <include name="plugin/pretokens/test/PreReachTester.class" /> + <include name="plugin/pretokens/writer/PreReachWriter.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${preplugins.dir}/PreToken-PREREGION.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Added: Trunk/pcgen/code/src/java/plugin/pretokens/parser/PreReachParser.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/pretokens/parser/PreReachParser.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/pretokens/parser/PreReachParser.java 2007-01-04 12:59:01 UTC (rev 1872) @@ -0,0 +1,89 @@ +/* + * PreReachParser.java + * + * Copyright 2003 (C) Chris Ward <fr...@pu...> + * + * 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 + * + * Created on 18-Dec-2003 + * + * Current Ver: $Revision: 1777 $ + * + * Last Editor: $Author: jdempsey $ + * + * Last Edited: $Date: 2006-12-17 05:36:01 +0100 (So, 17 Dez 2006) $ + * + */ +package plugin.pretokens.parser; + +import pcgen.core.prereq.Prerequisite; +import pcgen.core.prereq.PrerequisiteException; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.lst.prereq.AbstractPrerequisiteParser; +import pcgen.persistence.lst.prereq.PrerequisiteParserInterface; + +/** + * @author zaister + * + */ +public class PreReachParser extends AbstractPrerequisiteParser implements + PrerequisiteParserInterface +{ + /* (non-Javadoc) + * @see pcgen.persistence.lst.prereq.PrerequisiteParserInterface#kindsHandled() + */ + public String[] kindsHandled() + { + return new String[]{"REACH", "REACHEQ", "REACHGT", "REACHGTEQ", + "REACHLT", "REACHLTEQ", "REACHNEQ"}; + } + + /* (non-Javadoc) + * @see pcgen.persistence.lst.prereq.PrerequisiteParserInterface#parse(java.lang.String, java.lang.String, boolean) + */ + @Override + public Prerequisite parse(String kind, String formula, + boolean invertResult, boolean overrideQualify) + throws PersistenceLayerException + { + Prerequisite prereq = + super.parse(kind, formula, invertResult, overrideQualify); + try + { + prereq.setKind("reach"); + + // Get the comparator type SIZEGTEQ, BSIZE, SIZENEQ etc. + String compType = kind.substring(5).toLowerCase(); + if (compType.length() == 0) + { + compType = "gteq"; + } + prereq.setOperator(compType); + + prereq.setOperand(formula); + if (invertResult) + { + prereq.setOperator(prereq.getOperator().invert()); + } + } + catch (PrerequisiteException pe) + { + throw new PersistenceLayerException( + "Unable to parse the prerequisite :'" + kind + ":" + formula + + "'. " + pe.getLocalizedMessage()); + } + return prereq; + } +} Added: Trunk/pcgen/code/src/java/plugin/pretokens/test/PreReachTester.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/pretokens/test/PreReachTester.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/pretokens/test/PreReachTester.java 2007-01-04 12:59:01 UTC (rev 1872) @@ -0,0 +1,75 @@ +/* + * PreReach.java + * Copyright 2001 (C) Bryan McRoberts <mer...@ya...> + * Copyright 2003 (C) Chris Ward <fr...@pu...> + * + * 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 + * + * Created on November 28, 2003 + * + * Current Ver: $Revision: 1777 $ + * Last Editor: $Author: jdempsey $ + * Last Edited: $Date: 2006-12-17 05:36:01 +0100 (So, 17 Dez 2006) $ + * + */ +package plugin.pretokens.test; + +import pcgen.core.PlayerCharacter; +import pcgen.core.prereq.AbstractPrerequisiteTest; +import pcgen.core.prereq.Prerequisite; +import pcgen.core.prereq.PrerequisiteException; +import pcgen.core.prereq.PrerequisiteTest; +import pcgen.util.PropertyFactory; + +/** + * @author wardc + * + */ +public class PreReachTester extends AbstractPrerequisiteTest implements + PrerequisiteTest +{ + + /* (non-Javadoc) + * @see pcgen.core.prereq.PrerequisiteTest#passes(pcgen.core.PlayerCharacter) + */ + @Override + public int passes(final Prerequisite prereq, final PlayerCharacter character) + throws PrerequisiteException + { + int runningTotal; + try + { + final int targetReach = Integer.parseInt(prereq.getOperand()); + + runningTotal = + prereq.getOperator().compare(character.getReach(), + targetReach); + } + catch (NumberFormatException nfe) + { + throw new PrerequisiteException(PropertyFactory.getFormattedString( + "PreReach.error.badly_formed", prereq.getOperand())); //$NON-NLS-1$ + } + return countedTotal(prereq, runningTotal); + } + + /* (non-Javadoc) + * @see pcgen.core.prereq.PrerequisiteTest#kindsHandled() + */ + public String kindHandled() + { + return "REACH"; //$NON-NLS-1$ + } +} Added: Trunk/pcgen/code/src/java/plugin/pretokens/writer/PreReachWriter.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/pretokens/writer/PreReachWriter.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/pretokens/writer/PreReachWriter.java 2007-01-04 12:59:01 UTC (rev 1872) @@ -0,0 +1,79 @@ +/* + * PreReachWriter.java + * + * Copyright 2004 (C) Frugal <fr...@pu...> + * + * 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 + * + * Created on 18-Dec-2003 + * + * Current Ver: $Revision: 1821 $ + * + * Last Editor: $Author: jdempsey $ + * + * Last Edited: $Date: 2006-12-28 07:12:38 +0100 (Do, 28 Dez 2006) $ + * + */ +package plugin.pretokens.writer; + +import pcgen.core.prereq.Prerequisite; +import pcgen.core.prereq.PrerequisiteOperator; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.lst.output.prereq.AbstractPrerequisiteWriter; +import pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface; + +import java.io.IOException; +import java.io.Writer; + +public class PreReachWriter extends AbstractPrerequisiteWriter implements + PrerequisiteWriterInterface +{ + + /* (non-Javadoc) + * @see pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface#kindHandled() + */ + public String kindHandled() + { + return "reach"; + } + + /* (non-Javadoc) + * @see pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface#operatorsHandled() + */ + public PrerequisiteOperator[] operatorsHandled() + { + return null; + } + + /* (non-Javadoc) + * @see pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface#write(java.io.Writer, pcgen.core.prereq.Prerequisite) + */ + public void write(Writer writer, Prerequisite prereq) + throws PersistenceLayerException + { + try + { + writer.write("PREREACH" + (prereq.isOverrideQualify() ? "Q:":"")); + writer.write(prereq.getOperator().toString().toUpperCase()); + writer.write(':'); + writer.write(prereq.getOperand()); + } + catch (IOException e) + { + throw new PersistenceLayerException(e.getMessage()); + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2007-01-07 05:13:08
|
Revision: 1906 http://svn.sourceforge.net/pcgen/?rev=1906&view=rev Author: thpr Date: 2007-01-06 21:13:07 -0800 (Sat, 06 Jan 2007) Log Message: ----------- [ 1620950 ] Deprecate UATT and PREUATT tags [ 1613697 ] Deprecate ALTCRITICAL tag [ 1611839 ] Deprecate +d in KNOWN Tag Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/KnownToken.java Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/AltcriticalToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/UattToken.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/AltcriticalToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/UattToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2007-01-07 04:52:29 UTC (rev 1905) +++ Trunk/pcgen/code/pluginbuild.xml 2007-01-07 05:13:07 UTC (rev 1906) @@ -2844,13 +2844,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/ClassLstToken-UATT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/pcclass/UattToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/ClassLstToken-VFEAT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -3063,13 +3056,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/EquipmentLstToken-ALTCRITICAL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/equipment/AltcriticalToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/EquipmentLstToken-ALTCRITMULT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -5938,6 +5924,20 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/EquipmentLstToken-DEPRECATED-ALTCRITICAL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/deprecated/AltcriticalToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/ClassLstToken-DEPRECATED-UATT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/deprecated/UattToken.class" /> + </patternset> + </fileset> + </jar> </target> <target name="manifest" description="Write the Java manifest"> Copied: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/AltcriticalToken.java (from rev 1902, Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/AltcriticalToken.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/AltcriticalToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/AltcriticalToken.java 2007-01-07 05:13:07 UTC (rev 1906) @@ -0,0 +1,52 @@ +package plugin.lsttokens.deprecated; + +import pcgen.core.Equipment; +import pcgen.core.PObject; +import pcgen.persistence.lst.DeprecatedToken; +import pcgen.persistence.lst.EquipmentLstToken; +import pcgen.util.PropertyFactory; + +/** + * Deals with ALTCRITICAL token + */ +public class AltcriticalToken implements EquipmentLstToken, DeprecatedToken +{ + + public String getTokenName() + { + return "ALTCRITICAL"; + } + + public boolean parse(Equipment eq, String value) + { + if ((value.length() > 0) && (value.charAt(0) == 'x')) + { + try + { + eq.setAltCritMult(Integer.parseInt(value.substring(1))); + } + catch (NumberFormatException nfe) + { + return false; + } + return true; + } + else if (value.equals("-")) + { + eq.setAltCritMult(-1); + return true; + } + return false; + } + + /** + * @see pcgen.persistence.lst.DeprecatedToken#getMessage(pcgen.core.PObject, java.lang.String) + */ + public String getMessage(@SuppressWarnings("unused") + PObject anObj, @SuppressWarnings("unused") + String anValue) + { + return PropertyFactory.getString("Use ALTCRITMULT instead of ALTCRITICAL"); //$NON-NLS-1$ + } + +} Copied: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/UattToken.java (from rev 1902, Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/UattToken.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/UattToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/UattToken.java 2007-01-07 05:13:07 UTC (rev 1906) @@ -0,0 +1,35 @@ +package plugin.lsttokens.deprecated; + +import pcgen.core.PCClass; +import pcgen.core.PObject; +import pcgen.persistence.lst.DeprecatedToken; +import pcgen.persistence.lst.PCClassLstToken; +import pcgen.util.PropertyFactory; + +/** + * Class deals with UATT Token + */ +public class UattToken implements PCClassLstToken, DeprecatedToken +{ + + public String getTokenName() + { + return "UATT"; + } + + public boolean parse(PCClass pcclass, String value, int level) + { + pcclass.addUatt(value); + return true; + } + + /** + * @see pcgen.persistence.lst.DeprecatedToken#getMessage(pcgen.core.PObject, java.lang.String) + */ + public String getMessage(@SuppressWarnings("unused") + PObject anObj, @SuppressWarnings("unused") + String anValue) + { + return PropertyFactory.getString("Use ATTACKCYCLE:UAB and BONUS:COMBAT|BAB instead of UATT"); //$NON-NLS-1$ + } +} Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/AltcriticalToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/AltcriticalToken.java 2007-01-07 04:52:29 UTC (rev 1905) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/AltcriticalToken.java 2007-01-07 05:13:07 UTC (rev 1906) @@ -1,39 +0,0 @@ -package plugin.lsttokens.equipment; - -import pcgen.core.Equipment; -import pcgen.persistence.lst.EquipmentLstToken; - -/** - * Deals with ALTCRITICAL token - */ -public class AltcriticalToken implements EquipmentLstToken -{ - - public String getTokenName() - { - return "ALTCRITICAL"; - } - - public boolean parse(Equipment eq, String value) - { - if ((value.length() > 0) && (value.charAt(0) == 'x')) - { - try - { - eq.setAltCritMult(Integer.parseInt(value.substring(1))); - } - catch (NumberFormatException nfe) - { - return false; - } - return true; - } - else if (value.equals("-")) - { - eq.setAltCritMult(-1); - return true; - } - return false; - } - -} Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/KnownToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/KnownToken.java 2007-01-07 04:52:29 UTC (rev 1905) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/KnownToken.java 2007-01-07 05:13:07 UTC (rev 1906) @@ -28,13 +28,18 @@ List<String> knownList = new ArrayList<String>(st.countTokens()); while (st.hasMoreTokens()) { - knownList.add(st.nextToken()); + String nextToken = st.nextToken(); + if (nextToken.endsWith("+d")) { + Logging.errorPrint("+d use in KNOWN has been deprecated. " + + "Use SPECIALTYKNOWN instead"); + } + knownList.add(nextToken); } pcclass.setKnown(level, knownList); return true; } - Logging.errorPrint("CAST tag without level not allowed!"); + Logging.errorPrint("KNOWN tag without level not allowed!"); return false; } } Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/UattToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/UattToken.java 2007-01-07 04:52:29 UTC (rev 1905) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/UattToken.java 2007-01-07 05:13:07 UTC (rev 1906) @@ -1,22 +0,0 @@ -package plugin.lsttokens.pcclass; - -import pcgen.core.PCClass; -import pcgen.persistence.lst.PCClassLstToken; - -/** - * Class deals with UATT Token - */ -public class UattToken implements PCClassLstToken -{ - - public String getTokenName() - { - return "UATT"; - } - - public boolean parse(PCClass pcclass, String value, int level) - { - pcclass.addUatt(value); - return true; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2007-01-27 14:18:15
|
Revision: 2072 http://svn.sourceforge.net/pcgen/?rev=2072&view=rev Author: thpr Date: 2007-01-27 06:18:14 -0800 (Sat, 27 Jan 2007) Log Message: ----------- [ 1641072 ] Prepared spells with metamagic feat [ 1641069 ] Improved Spell Capacity [ 1580961 ] XTRAFEATS is parsed, not used Deprecate BONUSTYPE: since it's undocumented and doesn't do anything Move HITDIE out of Globals (where it gates to only handling PCClass) and into a PCClassLstToken Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java Trunk/pcgen/code/src/java/pcgen/core/chooser/SpellLevelChoiceManager.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoPreparedSpells.java Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/BonustypeToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/HitdieLst.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/HitdieLst.java Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/BonustypeToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2007-01-27 11:19:03 UTC (rev 2071) +++ Trunk/pcgen/code/pluginbuild.xml 2007-01-27 14:18:14 UTC (rev 2072) @@ -2001,13 +2001,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/LstToken-HITDIE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/HitdieLst.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/LstToken-KEY.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -2685,6 +2678,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/ClassLstToken-HITDIE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/pcclass/HitdieLst.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${lstplugins.dir}/ClassLstToken-ISMONSTER.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -3093,13 +3093,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/EquipmentLstToken-BONUSTYPE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/equipment/BonustypeToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/EquipmentLstToken-CHOOSE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -5884,6 +5877,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/EquipmentLstToken-DEPRECATED-BONUSTYPE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/deprecated/BonustypeToken.class" /> + </patternset> + </fileset> + </jar> </target> <target name="manifest" description="Write the Java manifest"> Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2007-01-27 11:19:03 UTC (rev 2071) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2007-01-27 14:18:14 UTC (rev 2072) @@ -13789,6 +13789,12 @@ return; } + // If not importing, add extra feats + if (!isImporting() && classList.isEmpty()) + { + adjustFeats(pcClassClone.getInitialFeats()); + } + // Add the class to the character classes as level 0 classList.add(pcClassClone); Modified: Trunk/pcgen/code/src/java/pcgen/core/chooser/SpellLevelChoiceManager.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/chooser/SpellLevelChoiceManager.java 2007-01-27 11:19:03 UTC (rev 2071) +++ Trunk/pcgen/code/src/java/pcgen/core/chooser/SpellLevelChoiceManager.java 2007-01-27 14:18:14 UTC (rev 2072) @@ -118,9 +118,7 @@ aBonusList.add(cTok.nextToken()); } - //final StringTokenizer choicesTok = new StringTokenizer(choicesSt, "|"); - //CONSIDER TODO - This split | needs to be reviewed?? - should be \\|?? - String choicesArr[] = choicesSt.split("|"); + String choicesArr[] = choicesSt.split("\\|"); List<String> choicesList = Arrays.asList(choicesArr); // get appropriate choices for chooser Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoPreparedSpells.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoPreparedSpells.java 2007-01-27 11:19:03 UTC (rev 2071) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoPreparedSpells.java 2007-01-27 14:18:14 UTC (rev 2072) @@ -1158,14 +1158,14 @@ c.setPool(99); c.setVisible(true); - final List<Ability> fList = c.getSelectedList(); + final List<String> fList = c.getSelectedList(); List<Ability> selFeatList = new ArrayList<Ability>(); int spLevel = si.getActualLevel(); int realLevel = spLevel; for (int i = 0; i < fList.size(); ++i) { - Ability aFeat = pc.getFeatNamed(fList.get(i).toString()); + Ability aFeat = pc.getFeatNamed(fList.get(i)); realLevel += aFeat.getAddSpellLevel(); selFeatList.add(aFeat); } Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/HitdieLst.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/HitdieLst.java 2007-01-27 11:19:03 UTC (rev 2071) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/HitdieLst.java 2007-01-27 14:18:14 UTC (rev 2072) @@ -1,32 +0,0 @@ -/* - * Created on Sep 2, 2005 - * - */ -package plugin.lsttokens; - -import pcgen.core.PCClass; -import pcgen.core.PObject; -import pcgen.persistence.lst.GlobalLstToken; - -/** - * @author djones4 - * - */ -public class HitdieLst implements GlobalLstToken -{ - - public String getTokenName() - { - return "HITDIE"; - } - - public boolean parse(PObject obj, String value, int anInt) - { - if (obj instanceof PCClass) - { - ((PCClass) obj).putHitDieLock(value, anInt); - return true; - } - return false; - } -} Copied: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/BonustypeToken.java (from rev 2053, Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/BonustypeToken.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/BonustypeToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/BonustypeToken.java 2007-01-27 14:18:14 UTC (rev 2072) @@ -0,0 +1,28 @@ +package plugin.lsttokens.deprecated; + +import pcgen.core.Equipment; +import pcgen.core.PObject; +import pcgen.persistence.lst.DeprecatedToken; +import pcgen.persistence.lst.EquipmentLstToken; + +/** + * Deals with BONUSTYPE token + */ +public class BonustypeToken implements EquipmentLstToken, DeprecatedToken +{ + + public String getTokenName() + { + return "BONUSTYPE"; + } + + public boolean parse(Equipment eq, String value) + { + // eq.setBonusType(value); + return true; + } + + public String getMessage(PObject obj, String value) { + return "BONUSTYPE is ignored by PCGen - please remove this tag"; + } +} Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/BonustypeToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/BonustypeToken.java 2007-01-27 11:19:03 UTC (rev 2071) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/equipment/BonustypeToken.java 2007-01-27 14:18:14 UTC (rev 2072) @@ -1,22 +0,0 @@ -package plugin.lsttokens.equipment; - -import pcgen.core.Equipment; -import pcgen.persistence.lst.EquipmentLstToken; - -/** - * Deals with BONUSTYPE token - */ -public class BonustypeToken implements EquipmentLstToken -{ - - public String getTokenName() - { - return "BONUSTYPE"; - } - - public boolean parse(Equipment eq, String value) - { - // eq.setBonusType(value); - return true; - } -} Copied: Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/HitdieLst.java (from rev 2053, Trunk/pcgen/code/src/java/plugin/lsttokens/HitdieLst.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/HitdieLst.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/HitdieLst.java 2007-01-27 14:18:14 UTC (rev 2072) @@ -0,0 +1,27 @@ +/* + * Created on Sep 2, 2005 + * + */ +package plugin.lsttokens.pcclass; + +import pcgen.core.PCClass; +import pcgen.persistence.lst.PCClassLstToken; + +/** + * @author djones4 + * + */ +public class HitdieLst implements PCClassLstToken +{ + + public String getTokenName() + { + return "HITDIE"; + } + + public boolean parse(PCClass pcclass, String value, int level) + { + pcclass.putHitDieLock(value, level); + return true; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2007-02-07 11:40:26
|
Revision: 2125 http://svn.sourceforge.net/pcgen/?rev=2125&view=rev Author: jdempsey Date: 2007-02-07 03:40:26 -0800 (Wed, 07 Feb 2007) Log Message: ----------- Fix bug#1549384 - gameMode should be independent of the gameMode folder name - Add new GAMEMODEKEY tag to allow folder name and game mode name to be different. Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/GameMode.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/GamemodekeyToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2007-02-07 05:08:56 UTC (rev 2124) +++ Trunk/pcgen/code/pluginbuild.xml 2007-02-07 11:40:26 UTC (rev 2125) @@ -4825,6 +4825,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${systemlstplugins.dir}/GameModeLstToken-GAMEMODEKEY.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/gamemode/GamemodekeyToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${systemlstplugins.dir}/GameModeLstToken-HIDDENEQUIPTYPES.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/core/GameMode.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/GameMode.java 2007-02-07 05:08:56 UTC (rev 2124) +++ Trunk/pcgen/code/src/java/pcgen/core/GameMode.java 2007-02-07 11:40:26 UTC (rev 2125) @@ -94,6 +94,7 @@ private String displayVariable3Text = ""; private String displayVariableName = ""; private String displayVariableText = ""; + private String folderName = "";; private String hpAbbrev = ""; private String hpName = ""; private String levelUpMessage = ""; @@ -180,6 +181,7 @@ public GameMode(final String modeName) { name = modeName; + folderName = modeName; for (Tab aTab : Tab.values()) { @@ -541,6 +543,14 @@ } /** + * @return the folderName + */ + public String getFolderName() + { + return folderName; + } + + /** * Set the hidden equipment types * @param pipeList */ @@ -710,6 +720,16 @@ } /** + * Set the game mode name (aka key). Should not + * be used after game mode is loaded. + * @param name the name to set + */ + public void setName(String name) + { + this.name = name; + } + + /** * Get Plus calculation * @param type * @return plus calculation Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java 2007-02-07 05:08:56 UTC (rev 2124) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java 2007-02-07 11:40:26 UTC (rev 2125) @@ -423,7 +423,7 @@ if (SettingsHandler.getGame() != null) { File gameModeDir = new File(SettingsHandler.getPcgenSystemDir(), "gameModes"); - File specificGameModeDir = new File(gameModeDir, SettingsHandler.getGame().getName()); + File specificGameModeDir = new File(gameModeDir, SettingsHandler.getGame().getFolderName()); File statsAndChecks = new File(specificGameModeDir, "statsandchecks.lst"); statCheckLoader.loadLstFile(statsAndChecks.toURI()); } @@ -1585,12 +1585,13 @@ * reading the file from the default game mode directory. * @param lstFileLoader the Loader object for the type of file. * @param gameModeName the game mode + * @param gameModeFolderName the name of the folder that the game mode is located in * @param lstFileName the lst file to load */ private void loadGameModeLstFile(LstLineFileLoader lstFileLoader, - String gameModeName, String lstFileName) + String gameModeName, String gameModeFolderName, String lstFileName) { - loadGameModeLstFile(lstFileLoader, gameModeName, lstFileName, true); + loadGameModeLstFile(lstFileLoader, gameModeName, gameModeFolderName, lstFileName, true); } /** @@ -1599,17 +1600,18 @@ * reading the file from the default game mode directory. * @param lstFileLoader the Loader object for the type of file. * @param gameModeName the game mode + * @param gameModeFolderName the name of the folder that the game mode is located in * @param lstFileName the lst file to load * @param showMissing show the missing file as a warning. Some files are optional and shouldn't generate a warning */ private void loadGameModeLstFile(LstLineFileLoader lstFileLoader, - String gameModeName, String lstFileName, final boolean showMissing) + String gameModeName, String gameModeFolderName, String lstFileName, final boolean showMissing) { File gameModeDir = new File(SettingsHandler.getPcgenSystemDir(), "gameModes"); try { - File specGameModeDir = new File(gameModeDir, gameModeName); + File specGameModeDir = new File(gameModeDir, gameModeFolderName); File gameModeFile = new File(specGameModeDir, lstFileName); if (gameModeFile.exists()) { @@ -1661,7 +1663,8 @@ File miscInfoFile = new File(specGameModeDir, "miscinfo.lst"); final GameMode gm = loadGameModeMiscInfo(gameFile, miscInfoFile.toURI()); - SettingsHandler.setGame(gameFile); + String gmName = gm.getName(); + SettingsHandler.setGame(gmName); if (gm != null) { loadGameModeInfoFile(gm, new File(specGameModeDir, "level.lst") @@ -1670,37 +1673,37 @@ .toURI(), "rules"); // Load equipmentslot.lst - loadGameModeLstFile(eqSlotLoader, gameFile, + loadGameModeLstFile(eqSlotLoader, gmName, gameFile, "equipmentslots.lst"); // Load paperInfo.lst - loadGameModeLstFile(paperLoader, gameFile, "paperInfo.lst"); + loadGameModeLstFile(paperLoader, gmName, gameFile, "paperInfo.lst"); // Load bio files - loadGameModeLstFile(traitLoader, gameFile, "bio" + loadGameModeLstFile(traitLoader, gmName, gameFile, "bio" + File.separator + "traits.lst"); - loadGameModeLstFile(locationLoader, gameFile, "bio" + loadGameModeLstFile(locationLoader, gmName, gameFile, "bio" + File.separator + "locations.lst"); - loadGameModeLstFile(bioLoader, gameFile, "bio" + loadGameModeLstFile(bioLoader, gmName, gameFile, "bio" + File.separator + "biosettings.lst"); // Load load.lst and check for completeness - loadGameModeLstFile(loadInfoLoader, gameFile, "load.lst"); + loadGameModeLstFile(loadInfoLoader, gmName, gameFile, "load.lst"); // Load unitset.lst - loadGameModeLstFile(unitSetLoader, gameFile, "unitset.lst", + loadGameModeLstFile(unitSetLoader, gmName, gameFile, "unitset.lst", false); // Load pointbuymethods.lst - loadGameModeLstFile(pointBuyLoader, gameFile, + loadGameModeLstFile(pointBuyLoader, gmName, gameFile, "pointbuymethods.lst", false); // Load sizeAdjustment.lst - loadGameModeLstFile(sizeLoader, gameFile, + loadGameModeLstFile(sizeLoader, gmName, gameFile, "sizeAdjustment.lst"); // Load statsandchecks.lst - loadGameModeLstFile(statCheckLoader, gameFile, + loadGameModeLstFile(statCheckLoader, gmName, gameFile, "statsandchecks.lst"); } } Added: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/GamemodekeyToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/GamemodekeyToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/GamemodekeyToken.java 2007-02-07 11:40:26 UTC (rev 2125) @@ -0,0 +1,60 @@ +/* + * GamemodekeyToken.java + * Copyright 2007 (C) James Dempsey <jde...@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 + * + * Created on February 7, 2007 + * + * Current Ver: $Revision$ + * Last Editor: $Author$ + * Last Edited: $Date$ + * + */package plugin.lsttokens.gamemode; + +import java.net.URI; + +import pcgen.core.GameMode; +import pcgen.persistence.lst.GameModeLstToken; + +/** + * <code>GamemodekeyToken</code> parses the GAMEMODEKEY token. + * + * Last Editor: $Author$ + * Last Edited: $Date$ + * + * @author James Dempsey <jde...@us...> + * @version $Revision$ + */ +public class GamemodekeyToken implements GameModeLstToken +{ + + /* (non-Javadoc) + * @see pcgen.persistence.lst.LstToken#getTokenName() + */ + public String getTokenName() + { + return "GAMEMODEKEY"; + } + + /* (non-Javadoc) + * @see pcgen.persistence.lst.GameModeLstToken#parse(pcgen.core.GameMode, java.lang.String, java.net.URI) + */ + public boolean parse(GameMode gameMode, String value, URI source) + { + gameMode.setName(value.replace('|', ' ')); + return true; + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/GamemodekeyToken.java ___________________________________________________________________ Name: svn:keywords + Author Revision Date Id Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2007-02-21 02:43:53
|
Revision: 2173 http://svn.sourceforge.net/pcgen/?rev=2173&view=rev Author: thpr Date: 2007-02-20 18:43:53 -0800 (Tue, 20 Feb 2007) Log Message: ----------- Convert AUTO to have individual SubTokens (Note this is not a complete token conversion, as some parsing is still done in PObject) Part of [ 1653673 ] Token Cleanup (ADD, AUTO, CHOOSE) Issue#: 1653673 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/chooser/WeaponProfTypeChoiceManager.java Trunk/pcgen/code/src/java/pcgen/core/utils/ListKey.java Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java Trunk/pcgen/code/src/java/pcgen/util/DoubleKeyMap.java Trunk/pcgen/code/src/java/plugin/lsttokens/AutoLst.java Trunk/pcgen/code/src/java/plugin/lsttokens/NaturalattacksLst.java Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/WeaponautoLst.java Trunk/pcgen/code/src/test/pcgen/core/PlayerCharacterTest.java Trunk/pcgen/code/src/test/pcgen/core/chooser/ArmorTypeChoiceManagerTest.java Trunk/pcgen/code/src/test/pcgen/core/prereq/PreArmorTypeTest.java Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/core/utils/MapKey.java Trunk/pcgen/code/src/java/pcgen/core/utils/MapKeyMapToObject.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/AutoLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/AutoLstToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/auto/ Trunk/pcgen/code/src/java/plugin/lsttokens/auto/ArmorProfToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/auto/EquipToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/auto/ShieldProfToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/auto/WeaponProfToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/pluginbuild.xml 2007-02-21 02:43:53 UTC (rev 2173) @@ -1898,7 +1898,7 @@ </jar> </target> - <target name="jar-lst-plugins" depends="jar-lst-global-plugins, jar-lst-ability-plugins, jar-lst-campaign-plugins, jar-lst-class-plugins, jar-lst-companionmod-plugins, jar-lst-diety-plugins, jar-lst-domain-plugins, jar-lst-equipment-plugins, jar-lst-equipmentmodifier-plugins, jar-lst-race-plugins, jar-lst-skill-plugins, jar-lst-spell-plugins, jar-lst-subclass-plugins, jar-lst-substitutionlevel-plugins, jar-lst-template-plugins, jar-lst-weaponprof-plugins, jar-lst-kit-plugins" description="Build (Link) Lst Token plugin jar files"> + <target name="jar-lst-plugins" depends="jar-lst-global-plugins, jar-lst-ability-plugins, jar-lst-auto-plugins, jar-lst-campaign-plugins, jar-lst-class-plugins, jar-lst-companionmod-plugins, jar-lst-diety-plugins, jar-lst-domain-plugins, jar-lst-equipment-plugins, jar-lst-equipmentmodifier-plugins, jar-lst-race-plugins, jar-lst-skill-plugins, jar-lst-spell-plugins, jar-lst-subclass-plugins, jar-lst-substitutionlevel-plugins, jar-lst-template-plugins, jar-lst-weaponprof-plugins, jar-lst-kit-plugins" description="Build (Link) Lst Token plugin jar files"> </target> <target name="jar-lst-global-plugins" depends="makeplugindirs" description="Build (Link) Global Lst Token plugin jar files"> @@ -2266,6 +2266,38 @@ </jar> </target> + <target name="jar-lst-auto-plugins" depends="makeplugindirs" description="Build (Link) Auto Lst Token plugin jar files"> + <!-- Auto tokens--> + <jar jarfile="${lstplugins.dir}/AutoLstToken-ARMORPROF.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/auto/ArmorProfToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/AutoLstToken-EQUIP.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/auto/EquipToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/AutoLstToken-SHIELDPROF.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/auto/ShieldProfToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/AutoLstToken-WEAPONPROF.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/auto/WeaponProfToken.class" /> + </patternset> + </fileset> + </jar> + </target> + <target name="jar-lst-campaign-plugins" depends="makeplugindirs" description="Build (Link) Campaign Lst Token plugin jar files"> <!-- Campaign tokens--> <jar jarfile="${lstplugins.dir}/CampaignLstToken-ABILITY.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> Modified: Trunk/pcgen/code/src/java/pcgen/core/PCClass.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -29,6 +29,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.StringTokenizer; import pcgen.core.bonus.Bonus; @@ -6347,7 +6348,14 @@ classSpellChoices = otherClass.classSpellChoices; - addAutoArray(otherClass.getSafeListFor(ListKey.AUTO_ARRAY)); + Set<String> s = otherClass.getAutoMapKeys(); + if (s != null) + { + for (String key : s) + { + addAutoArray(key, otherClass.getAuto(key)); + } + } if (!otherClass.getBonusList().isEmpty()) { getBonusList().addAll(otherClass.getBonusList()); Modified: Trunk/pcgen/code/src/java/pcgen/core/PObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -32,7 +32,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; @@ -57,6 +56,8 @@ import pcgen.core.utils.KeyedListContainer; import pcgen.core.utils.ListKey; import pcgen.core.utils.ListKeyMapToList; +import pcgen.core.utils.MapKey; +import pcgen.core.utils.MapKeyMapToObject; import pcgen.core.utils.MessageType; import pcgen.core.utils.ShowMessageDelegate; import pcgen.core.utils.StringKey; @@ -94,6 +95,8 @@ protected Map<IntegerKey, Integer> integerChar = new HashMap<IntegerKey, Integer>(); /** A map of Lists for the object */ protected ListKeyMapToList listChar = new ListKeyMapToList(); + + private final MapKeyMapToObject mapChar = new MapKeyMapToObject(); /** List of associated items for the object */ // TODO Contains strings or FeatMultipleObjects @@ -2280,20 +2283,11 @@ /** * Add auto array - * @param aList - */ - public final void addAutoArray(final List<String> aList) - { - listChar.addAllToListFor(ListKey.AUTO_ARRAY, aList); - } - - /** - * Add auto array * @param arg */ - public final void addAutoArray(final String arg) + public final void addAutoArray(String arrayName, String item) { - listChar.addToListFor(ListKey.AUTO_ARRAY, arg); + mapChar.put(MapKey.AUTO_ARRAY, arrayName, item); } /** @@ -2330,9 +2324,9 @@ /** * Clear the auto list */ - public final void clearAutoList() + public final void clearAutoMap() { - listChar.removeListFor(ListKey.AUTO_ARRAY); + mapChar.removeAll(MapKey.AUTO_ARRAY); } /** @@ -2340,22 +2334,21 @@ * carrying the supplied tag * @param tag The type to be removed e.g. WEAPONPROF */ - public final void clearAutoListForTag(String tag) + public final void clearAutoTag(String tag) { - List<String> autoList = getListFor(ListKey.AUTO_ARRAY); - if (autoList == null) - { - return; - } - for (String element : autoList) - { - if (element.startsWith(tag)) - { - autoList.remove(element); - } - } + mapChar.remove(MapKey.AUTO_ARRAY, tag); } + public final Set<String> getAutoMapKeys() + { + return mapChar.getKeySet(MapKey.AUTO_ARRAY); + } + + public final String getAuto(String tag) + { + return mapChar.get(MapKey.AUTO_ARRAY, tag); + } + /** * Set the campaign source * @param arg @@ -2708,9 +2701,14 @@ txt.append("\tKEY:").append(getKeyName()); // } - for (String s : getSafeListFor(ListKey.AUTO_ARRAY)) + Set<String> aaKeys = mapChar.getKeySet(MapKey.AUTO_ARRAY); + if (aaKeys != null) { - txt.append("\tAUTO:").append(s); + for (String s : aaKeys) + { + txt.append("\tAUTO:").append(s).append(Constants.PIPE).append( + mapChar.get(MapKey.AUTO_ARRAY, s)); + } } if (!(this instanceof PCClass) && (getBonusList().size() != 0)) @@ -3152,120 +3150,120 @@ */ public final void addAutoTagsToList(final String tag, final Collection aList, final PlayerCharacter aPC, boolean expandWeaponTypes) { - for (Iterator<String> i = getSafeListFor(ListKey.AUTO_ARRAY).iterator(); i.hasNext();) + String aString = mapChar.get(MapKey.AUTO_ARRAY, tag); + + if (aString == null) { - String aString = i.next(); + return; + } + + String preReqTag; + final List<Prerequisite> aPreReqList = new ArrayList<Prerequisite>(); + final int j1 = aString.lastIndexOf('['); + int j2 = aString.lastIndexOf(']'); - if (!aString.startsWith(tag)) + if (j2 < j1) + { + j2 = tag.length(); + } + + if (j1 >= 0) + { + preReqTag = aString.substring(j1 + 1, j2); + Prerequisite prereq = null; + try { - continue; + final PreParserFactory factory = PreParserFactory.getInstance(); + prereq = factory.parse(preReqTag); } - - String preReqTag; - final List<Prerequisite> aPreReqList = new ArrayList<Prerequisite>(); - final int j1 = aString.lastIndexOf('['); - int j2 = aString.lastIndexOf(']'); - - if (j2 < j1) + catch (PersistenceLayerException ple) { - j2 = tag.length(); + Logging.errorPrint(ple.getMessage(), ple); } - if (j1 >= 0) + if (prereq != null) { - preReqTag = aString.substring(j1 + 1, j2); - Prerequisite prereq = null; - try - { - final PreParserFactory factory = PreParserFactory.getInstance(); - prereq = factory.parse( preReqTag ); - } - catch (PersistenceLayerException ple) - { - Logging.errorPrint(ple.getMessage(), ple); - } + aPreReqList.add(prereq); + } + if (!PrereqHandler.passesAll(aPreReqList, aPC, null)) + { + return; + } - if ( prereq != null ) - { - aPreReqList.add(prereq); - } - if (!PrereqHandler.passesAll(aPreReqList, aPC, null)) - { - return; - } + aString = aString.substring(0, j1); + } - aString = aString.substring(0, j1); - } + final StringTokenizer aTok = new StringTokenizer(aString, "|"); - final StringTokenizer aTok = new StringTokenizer(aString, "|"); - aTok.nextToken(); // removes tag token + while (aTok.hasMoreTokens()) + { + String tok = aTok.nextToken(); - String tok; + if ((tok.startsWith("TYPE=") || tok.startsWith("TYPE.")) + && tag.startsWith("WEAPON") && expandWeaponTypes) + { + List<String> xList = processWeaponAutoTags(aPC, tok); - while (aTok.hasMoreTokens()) + aList.addAll(xList); + } + else if ((tok.startsWith("TYPE=") || tok.startsWith("TYPE.")) + && tag.startsWith("ARMOR")) { - tok = aTok.nextToken(); + aList.add(tok); + } + else if (tag.startsWith("EQUIP")) + { + final Equipment aEq = + EquipmentList.getEquipmentFromName(tok, aPC); - if ((tok.startsWith("TYPE=") || tok.startsWith("TYPE.")) - && tag.startsWith("WEAPON") && expandWeaponTypes) + if (aEq != null) { - List<String> xList = processWeaponAutoTags(aPC, tok); - - aList.addAll(xList); + final Equipment newEq = aEq.clone(); + newEq.setQty(1); + newEq.setAutomatic(true); + newEq.setOutputIndex(aList.size()); + aList.add(newEq); } - else if ((tok.startsWith("TYPE=") || tok.startsWith("TYPE.")) && tag.startsWith("ARMOR")) + } + else if ("%LIST".equals(tok)) + { + for (Iterator<AssociatedChoice<String>> e = + getAssociatedList().iterator(); e.hasNext();) { - aList.add(tok); + aList.add(e.next().getDefaultChoice()); } - else if (tag.startsWith("EQUIP")) + } + else if ("DEITYWEAPONS".equals(tok)) + { + if (aPC.getDeity() != null) { - final Equipment aEq = EquipmentList.getEquipmentFromName(tok, aPC); + String weaponList = aPC.getDeity().getFavoredWeapon(); - if (aEq != null) + if (!("ALL".equalsIgnoreCase(weaponList) || "ANY" + .equalsIgnoreCase(weaponList))) { - final Equipment newEq = aEq.clone(); - newEq.setQty(1); - newEq.setAutomatic(true); - newEq.setOutputIndex(aList.size()); - aList.add(newEq); - } - } - else if ("%LIST".equals(tok)) - { - for (Iterator<AssociatedChoice<String>> e = getAssociatedList().iterator(); e.hasNext();) - { - aList.add(e.next().getDefaultChoice()); - } - } - else if ("DEITYWEAPONS".equals(tok)) - { - if (aPC.getDeity() != null) - { - String weaponList = aPC.getDeity().getFavoredWeapon(); + final StringTokenizer bTok = + new StringTokenizer(weaponList, "|"); - if (!("ALL".equalsIgnoreCase(weaponList) || "ANY".equalsIgnoreCase(weaponList))) + while (bTok.hasMoreTokens()) { - final StringTokenizer bTok = new StringTokenizer(weaponList, "|"); - - while (bTok.hasMoreTokens()) + final String bString = bTok.nextToken(); + final WeaponProf wp = + Globals.getWeaponProfKeyed(bString); + if (!wp.isType("Natural")) { - final String bString = bTok.nextToken(); - final WeaponProf wp = Globals.getWeaponProfKeyed(bString); - if (!wp.isType("Natural")) - { - aList.add(bString); - } + aList.add(bString); } } - } + } - else - { - // add tok to list - aList.add(tok); - } } + else + { + // add tok to list + aList.add(tok); + } } } Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -11115,7 +11115,6 @@ pObj.addAutoTagsToList("ARMORPROF", aList, this, true); } } - return aList; } Modified: Trunk/pcgen/code/src/java/pcgen/core/chooser/WeaponProfTypeChoiceManager.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/chooser/WeaponProfTypeChoiceManager.java 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/src/java/pcgen/core/chooser/WeaponProfTypeChoiceManager.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -108,7 +108,7 @@ if (Globals.weaponTypesContains(weaponType)) { - pobject.addAutoArray("WEAPONPROF|" + item); + pobject.addAutoArray("WEAPONPROF", item); } } Modified: Trunk/pcgen/code/src/java/pcgen/core/utils/ListKey.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/utils/ListKey.java 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/src/java/pcgen/core/utils/ListKey.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -40,8 +40,6 @@ */ public final class ListKey<T> { - /** AUTO_ARRAY - a ListKey */ - public static final ListKey<String> AUTO_ARRAY = new ListKey<String>(); /** AUTO_LANGUAGES - a ListKey */ public static final ListKey<Language> AUTO_LANGUAGES = new ListKey<Language>(); /** CLASS_SKILLS - a ListKey */ Added: Trunk/pcgen/code/src/java/pcgen/core/utils/MapKey.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/utils/MapKey.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/core/utils/MapKey.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -0,0 +1,41 @@ +/* + * Copyright 2005 (C) Tom Parker <th...@so...> + * + * 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 + * + * Created on June 18, 2005. + * + * Current Ver: $Revision: 2135 $ + * Last Editor: $Author: thpr $ + * Last Edited: $Date: 2007-02-10 11:55:15 -0500 (Sat, 10 Feb 2007) $ + */ +package pcgen.core.utils; + +/** + * @author Tom Parker <th...@so...> + * + * This is a Typesafe enumeration of legal List Characteristics of an object. + */ +public final class MapKey<K, V> +{ + + public static final MapKey<String, String> AUTO_ARRAY = new MapKey<String, String>(); + + /** Private constructor to prevent instantiation of this class */ + private MapKey() + { + //Only allow instantation here + } +} Added: Trunk/pcgen/code/src/java/pcgen/core/utils/MapKeyMapToObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/utils/MapKeyMapToObject.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/core/utils/MapKeyMapToObject.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -0,0 +1,51 @@ +package pcgen.core.utils; + +import java.util.Map; +import java.util.Set; + +import pcgen.util.DoubleKeyMap; + +public class MapKeyMapToObject +{ + + private final DoubleKeyMap<MapKey<?, ?>, Object, Object> dkm = + new DoubleKeyMap<MapKey<?, ?>, Object, Object>(); + + public <SK> boolean containsKey(MapKey<SK, ?> key1, SK key2) + { + return dkm.containsKey(key1, key2); + } + + public boolean containsKey(MapKey<?, ?> key1) + { + return dkm.containsKey(key1); + } + + public <SK, SV> SV get(MapKey<SK, SV> key1, SK key2) + { + return (SV) dkm.get(key1, key2); + } + + public <SK, SV> SV put(MapKey<SK, SV> key1, SK key2, SV value) + { + return (SV) dkm.put(key1, key2, value); + } + + /* + * TODO Need to fix the generics here... + */ + public <SK, SV> Map<Object, Object> removeAll(MapKey<SK, SV> key1) + { + return dkm.removeAll(key1); + } + + public <SK, SV> SV remove(MapKey<SK, SV> key1, SK key2) + { + return (SV) dkm.remove(key1, key2); + } + + public <SK> Set<SK> getKeySet(MapKey<SK, ?> key1) + { + return (Set<SK>) dkm.getSecondaryKeySet(key1); + } +} Modified: Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -617,7 +617,7 @@ thisPObject.clearSpecialAbilityList(); thisPObject.clearSRList(); thisPObject.getSpellSupport().clearSpellList(); - thisPObject.clearAutoList(); + thisPObject.clearAutoMap(); SpellSupport spellSupport = thisPObject.getSpellSupport(); switch (editType) @@ -1043,11 +1043,11 @@ // if (pnlWeapons != null) { - thisPObject.clearAutoListForTag("WEAPONPROF"); + thisPObject.clearAutoTag("WEAPONPROF"); sel = pnlWeapons.getSelectedList(); for (int i = 0; i < sel.length; i++) { - thisPObject.addAutoArray("WEAPONPROF|" + sel[i]); + thisPObject.addAutoArray("WEAPONPROF", (String) sel[i]); } sel = pnlWeapons.getSelectedList2(); @@ -3003,18 +3003,18 @@ break; } - final List<String> autoList = thisPObject.getSafeListFor(ListKey.AUTO_ARRAY); + final Set<String> keySet = thisPObject.getAutoMapKeys(); - if (autoList != null) + if (keySet != null) { - for (Iterator<String> e = autoList.iterator(); e.hasNext();) + for (String key : keySet) { - String tagContent = e.next(); - // We need to exclude WEAPONPROFs as they appear on the weapon tab - if (tagContent != null && !tagContent.startsWith("WEAPONPROF")) + if (key.equalsIgnoreCase("WEAPONPROF")) { - selectedList.add("AUTO:" + tagContent); + // We need to exclude WEAPONPROFs as they appear on the weapon tab + continue; } + selectedList.add("AUTO:" + key + "|" + thisPObject.getAuto(key)); } } Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/AutoLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/AutoLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/AutoLoader.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -0,0 +1,66 @@ +/* + * SubClassLoader.java + * 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 + * + * Created on February 17, 2007 + * + * $Id: SubClassLoader.java 2077 2007-01-27 16:45:58Z thpr $ + */ +package pcgen.persistence.lst; + +import java.util.Map; + +import pcgen.core.PObject; +import pcgen.persistence.PersistenceLayerException; +import pcgen.util.Logging; + +public final class AutoLoader +{ + private AutoLoader() + { + //Utility Class, no construction needed + } + + /** + * This method is static so it can be used by the AUTO Token. + * @param target + * @param lstLine + * @param source + * @throws PersistenceLayerException + */ + public static boolean parseLine(PObject target, String key, String value) + { + Map<String, LstToken> tokenMap = + TokenStore.inst().getTokenMap(AutoLstToken.class); + AutoLstToken token = (AutoLstToken) tokenMap.get(key); + if (token != null) + { + LstUtils.deprecationCheck(token, target, value); + if (!token.parse(target, value)) + { + Logging.errorPrint("Error parsing AUTO: " + key + ":" + value); + return false; + } + return true; + } + else + { + Logging.errorPrint("Error parsing AUTO, invalid SubToken: " + key); + return false; + } + } +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/AutoLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/AutoLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/AutoLstToken.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -0,0 +1,38 @@ +/* + * AbilityLstToken + * 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 + * + * Created on February 17, 2007 + * + * Current Ver: $Revision: 197 $ + * Last Editor: $Author: nuance $ + * Last Edited: $Date: 2006-03-14 17:59:43 -0500 (Tue, 14 Mar 2006) $ + * + */ +package pcgen.persistence.lst; + +import pcgen.core.PObject; + +/** + * <code>AutoLstToken</code> + * + * @author Thomas Parker <th...@us...> + */ +public interface AutoLstToken extends LstToken +{ + public abstract boolean parse(PObject target, String value); +} Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -115,6 +115,9 @@ //sponsors.lst tokenTypeList.add(SponsorLstToken.class); + + //subtokens + tokenTypeList.add(AutoLstToken.class); } /** Modified: Trunk/pcgen/code/src/java/pcgen/util/DoubleKeyMap.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/util/DoubleKeyMap.java 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/src/java/pcgen/util/DoubleKeyMap.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -145,6 +145,21 @@ /** * Returns true if an object is stored in this DoubleKeyMap for the given + * primary key. + * + * @param key1 + * The primary key to be tested for containing a value in this + * DoubleKeyMap. + * @return true if this DoubleKeyMap has an Object stored in this + * DoubleKeyMap for the given primary key; false otherwise + */ + public boolean containsKey(K1 key1) + { + return map.containsKey(key1); + } + + /** + * Returns true if an object is stored in this DoubleKeyMap for the given * keys. * * @param key1 @@ -167,6 +182,20 @@ } /** + * Removes all objects with the given primary key from the DoubleKeyMap. + * + * @param key1 + * The primary key used to remove the value in this DoubleKeyMap. + * @return the Map of objects stored in this DoubleKeyMap for the given + * primary keys. null if this DoubleKeyMap does not have an object + * stored with the given primary key. + */ + public Map<K2, V> removeAll(K1 key1) + { + return map.remove(key1); + } + + /** * Removes an object from the DoubleKeyMap. * * @param key1 Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/AutoLst.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/AutoLst.java 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/AutoLst.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -4,8 +4,11 @@ */ package plugin.lsttokens; +import pcgen.core.Constants; import pcgen.core.PObject; +import pcgen.persistence.lst.AutoLoader; import pcgen.persistence.lst.GlobalLstToken; +import pcgen.util.Logging; /** * @author djones4 @@ -21,7 +24,13 @@ public boolean parse(PObject obj, String value, int anInt) { - obj.addAutoArray(value); - return true; + int barLoc = value.indexOf(Constants.PIPE); + if (barLoc == -1) + { + Logging.errorPrint(getTokenName() + " must contain a PIPE (|)"); + return false; + } + String subKey = value.substring(0, barLoc); + return AutoLoader.parseLine(obj, subKey, value); } } Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/NaturalattacksLst.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/NaturalattacksLst.java 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/NaturalattacksLst.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -235,7 +235,7 @@ Globals.addWeaponProf(prof); } - anEquip.addAutoArray("WEAPONPROF|" + attackName); //$NON-NLS-1$ + anEquip.addAutoArray("WEAPONPROF", attackName); //$NON-NLS-1$ return anEquip; } } Added: Trunk/pcgen/code/src/java/plugin/lsttokens/auto/ArmorProfToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/auto/ArmorProfToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/auto/ArmorProfToken.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -0,0 +1,20 @@ +package plugin.lsttokens.auto; + +import pcgen.core.PObject; +import pcgen.persistence.lst.AutoLstToken; + +public class ArmorProfToken implements AutoLstToken +{ + + public String getTokenName() + { + return "ARMORPROF"; + } + + public boolean parse(PObject target, String value) + { + target.addAutoArray(getTokenName(), value); + return true; + } + +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/auto/EquipToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/auto/EquipToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/auto/EquipToken.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -0,0 +1,20 @@ +package plugin.lsttokens.auto; + +import pcgen.core.PObject; +import pcgen.persistence.lst.AutoLstToken; + +public class EquipToken implements AutoLstToken +{ + + public String getTokenName() + { + return "EQUIP"; + } + + public boolean parse(PObject target, String value) + { + target.addAutoArray(getTokenName(), value); + return true; + } + +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/auto/ShieldProfToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/auto/ShieldProfToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/auto/ShieldProfToken.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -0,0 +1,20 @@ +package plugin.lsttokens.auto; + +import pcgen.core.PObject; +import pcgen.persistence.lst.AutoLstToken; + +public class ShieldProfToken implements AutoLstToken +{ + + public String getTokenName() + { + return "SHIELDPROF"; + } + + public boolean parse(PObject target, String value) + { + target.addAutoArray(getTokenName(), value); + return true; + } + +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/auto/WeaponProfToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/auto/WeaponProfToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/auto/WeaponProfToken.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -0,0 +1,20 @@ +package plugin.lsttokens.auto; + +import pcgen.core.PObject; +import pcgen.persistence.lst.AutoLstToken; + +public class WeaponProfToken implements AutoLstToken +{ + + public String getTokenName() + { + return "WEAPONPROF"; + } + + public boolean parse(PObject target, String value) + { + target.addAutoArray(getTokenName(), value); + return true; + } + +} Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/WeaponautoLst.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/WeaponautoLst.java 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/WeaponautoLst.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -29,7 +29,7 @@ */ public boolean parse(PObject obj, String value, int anInt) { - obj.addAutoArray("WEAPONPROF|" + value); //$NON-NLS-1$ + obj.addAutoArray("WEAPONPROF", value); //$NON-NLS-1$ // obj.addWeaponProfAutos(value); return true; } Modified: Trunk/pcgen/code/src/test/pcgen/core/PlayerCharacterTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/PlayerCharacterTest.java 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/src/test/pcgen/core/PlayerCharacterTest.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -508,7 +508,7 @@ "General.Fighter"); exoticWpnProf.setMultiples("YES"); exoticWpnProf.setChoiceString("PROFICIENCY|WEAPON|UNIQUE|TYPE.Exotic"); - exoticWpnProf.addAutoArray("WEAPONPROF|%LIST"); + exoticWpnProf.addAutoArray("WEAPONPROF", "%LIST"); WeaponProf wpnProfTestA = new WeaponProf(); wpnProfTestA.setName("Weapon A"); Modified: Trunk/pcgen/code/src/test/pcgen/core/chooser/ArmorTypeChoiceManagerTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/chooser/ArmorTypeChoiceManagerTest.java 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/src/test/pcgen/core/chooser/ArmorTypeChoiceManagerTest.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -75,19 +75,19 @@ Ability a = Globals.getAbilityKeyed("FEAT", "KEY_Armor Proficiency (Light)"); - a.addAutoArray("ARMORPROF|TYPE.Light"); + a.addAutoArray("ARMORPROF", "TYPE.Light"); TestHelper.makeAbility("Armor Proficiency (Medium)", "FEAT", "General.Fighter"); a = Globals.getAbilityKeyed("FEAT", "KEY_Armor Proficiency (Medium)"); - a.addAutoArray("ARMORPROF|TYPE.Medium"); + a.addAutoArray("ARMORPROF", "TYPE.Medium"); TestHelper.makeAbility("Armor Proficiency (Heavy)", "FEAT", "General.Fighter"); a = Globals.getAbilityKeyed("FEAT", "KEY_Armor Proficiency (Heavy)"); - a.addAutoArray("ARMORPROF|TYPE.Heavy"); + a.addAutoArray("ARMORPROF", "TYPE.Heavy"); TestHelper.makeAbility("Armor Proficiency (Heavy)", "FOO", "General.Fighter"); } Modified: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreArmorTypeTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/prereq/PreArmorTypeTest.java 2007-02-19 07:35:13 UTC (rev 2172) +++ Trunk/pcgen/code/src/test/pcgen/core/prereq/PreArmorTypeTest.java 2007-02-21 02:43:53 UTC (rev 2173) @@ -139,7 +139,7 @@ final Ability mediumProf = TestHelper.makeAbility("Armor Proficiency (Medium)", "FEAT", "General"); - mediumProf.addAutoArray("ARMORPROF|TYPE.Medium"); + mediumProf.addAutoArray("ARMORPROF", "TYPE.Medium"); AbilityUtilities.modFeat(character, null, "KEY_Armor Proficiency (Medium)", true, false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <za...@us...> - 2007-02-28 11:18:50
|
Revision: 2239 http://svn.sourceforge.net/pcgen/?rev=2239&view=rev Author: zaister Date: 2007-02-28 03:18:51 -0800 (Wed, 28 Feb 2007) Log Message: ----------- [ 1660695 ] new PCC tag: ISMATURE Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/Campaign.java Trunk/pcgen/code/src/java/pcgen/core/SettingsHandler.java Trunk/pcgen/code/src/java/pcgen/gui/PreferencesDialog.java Trunk/pcgen/code/src/java/pcgen/gui/pcGenGUI.java Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/campaign/IsmatureToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2007-02-27 22:29:53 UTC (rev 2238) +++ Trunk/pcgen/code/pluginbuild.xml 2007-02-28 11:18:51 UTC (rev 2239) @@ -2454,6 +2454,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/CampaignLstToken-ISMATURE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/campaign/IsmatureToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${lstplugins.dir}/CampaignLstToken-ISOGL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/core/Campaign.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Campaign.java 2007-02-27 22:29:53 UTC (rev 2238) +++ Trunk/pcgen/code/src/java/pcgen/core/Campaign.java 2007-02-28 11:18:51 UTC (rev 2239) @@ -44,6 +44,7 @@ private boolean isLicensed; private boolean isLoaded; private boolean isOGL; + private boolean isMature; private boolean showInMenu; /** @@ -1122,6 +1123,15 @@ } /** + * Set the isMature flag + * @param isMature + */ + public void setIsMature(final boolean isMature) + { + this.isMature = isMature; + } + + /** * Returns whether this campaign is licensed * @return true if this campaign is licensed */ @@ -1147,6 +1157,14 @@ } /** + * @return whether or not the Mature dataset warning will pop up when this campaign is loaded + */ + public boolean isMature() + { + return isMature; + } + + /** * Set the campaign options * @param options */ Modified: Trunk/pcgen/code/src/java/pcgen/core/SettingsHandler.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/SettingsHandler.java 2007-02-27 22:29:53 UTC (rev 2238) +++ Trunk/pcgen/code/src/java/pcgen/core/SettingsHandler.java 2007-02-28 11:18:51 UTC (rev 2239) @@ -102,6 +102,7 @@ private static boolean showD20InfoAtStart = true; private static boolean loadURLs = false; private static boolean showOGLOnLoad = true; + private static boolean showMatureOnLoad = true; private static boolean showSponsorsOnLoad = true; private static boolean hpMaxAtFirstLevel = true; private static int hpRollMethod = Constants.HP_STANDARD; @@ -1132,6 +1133,7 @@ loadURLs = getPCGenOption("loadURLs", false); //$NON-NLS-1$ allowOverride = getPCGenOption("allowOverride", false); //$NON-NLS-1$ showOGLOnLoad = getPCGenOption("showOGLOnLoad", true); //$NON-NLS-1$ + showMatureOnLoad = getPCGenOption("showMatureOnLoad", true); //$NON-NLS-1$ showSponsorsOnLoad = getPCGenOption("showSponsorsOnLoad", true); //$NON-NLS-1$ Globals.setSourceDisplay(SourceEntry.SourceFormat.valueOf(getPCGenOption("sourceDisplay", SourceEntry.SourceFormat.LONG.ordinal()))); //$NON-NLS-1$ @@ -1573,6 +1575,7 @@ setPCGenOption("showImagePreview", isShowImagePreview()); //$NON-NLS-1$ setPCGenOption("showNatWeaponTab", showNatWeaponTab); //$NON-NLS-1$ setPCGenOption("showOGLOnLoad", showOGLOnLoad); //$NON-NLS-1$ + setPCGenOption("showMatureOnLoad", showMatureOnLoad); //$NON-NLS-1$ setPCGenOption("showSponsorsOnLoad", showSponsorsOnLoad); //$NON-NLS-1$ setPCGenOption("showStatDialogAtLevelUp", getShowStatDialogAtLevelUp()); //$NON-NLS-1$ setPCGenOption("showTipOfTheDay", getShowTipOfTheDay()); //$NON-NLS-1$ @@ -2167,6 +2170,11 @@ showOGLOnLoad = arg; } + public static void setShowMature(final boolean arg) + { + showMatureOnLoad = arg; + } + public static void setShowSponsors(final boolean arg) { showSponsorsOnLoad = arg; @@ -2516,6 +2524,11 @@ return showOGLOnLoad; } + public static boolean showMature() + { + return showMatureOnLoad; + } + public static boolean showSponsors() { return showSponsorsOnLoad; } Modified: Trunk/pcgen/code/src/java/pcgen/gui/PreferencesDialog.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/PreferencesDialog.java 2007-02-27 22:29:53 UTC (rev 2238) +++ Trunk/pcgen/code/src/java/pcgen/gui/PreferencesDialog.java 2007-02-28 11:18:51 UTC (rev 2239) @@ -93,121 +93,228 @@ // Used to create the entries for the max spell level combos private static final int SPELLLVLMIN = 0; private static final int SPELLLVLMAX = 9; - private static String[] potionSpellLevel = new String[SPELLLVLMAX - SPELLLVLMIN + 1]; - private static String[] wandSpellLevel = new String[SPELLLVLMAX - SPELLLVLMIN + 1]; + private static String[] potionSpellLevel = + new String[SPELLLVLMAX - SPELLLVLMIN + 1]; + private static String[] wandSpellLevel = + new String[SPELLLVLMAX - SPELLLVLMIN + 1]; // Resource strings - private static String in_abilities = PropertyFactory.getString("in_Prefs_abilities"); + private static String in_abilities = + PropertyFactory.getString("in_Prefs_abilities"); //PropertyFactory.getString("in_Prefs_abilitiesUserRolled"); //PropertyFactory.getString("in_Prefs_abilitiesAllSame"); //PropertyFactory.getString("in_Prefs_abilitiesPurchased"); - private static String in_allowMetamagic = PropertyFactory.getString("in_Prefs_allowMetamagic"); - private static String in_allowOverride = PropertyFactory.getString("in_Prefs_allowOverride"); - private static String in_alwaysOverwrite = PropertyFactory.getString("in_Prefs_alwaysOverwrite"); - private static String in_appearance = PropertyFactory.getString("in_Prefs_appearance"); - private static String in_autoLoadAtStart = PropertyFactory.getString("in_Prefs_autoLoadAtStart"); - private static String in_autoLoadWithPC = PropertyFactory.getString("in_Prefs_autoLoadWithPC"); - private static String in_anyAutoEquip = PropertyFactory.getString("in_Prefs_anyAutoEquip"); - private static String in_autoEquip = PropertyFactory.getString("in_Prefs_autoEquip"); - private static String in_autoEquipRace = PropertyFactory.getString("in_Prefs_autoEquipRace"); - private static String in_autoEquipMasterwork = PropertyFactory.getString("in_Prefs_autoEquipMasterwork"); - private static String in_autoEquipMagic = PropertyFactory.getString("in_Prefs_autoEquipMagic"); - private static String in_autoEquipExotic = PropertyFactory.getString("in_Prefs_autoEquipExotic"); - private static String in_browserPath = PropertyFactory.getString("in_Prefs_browserPath"); - private static String in_clearBrowserPath = PropertyFactory.getString("in_Prefs_clearBrowserPath"); - private static String in_color = PropertyFactory.getString("in_Prefs_color"); - private static String in_colorPrereqQualify = PropertyFactory.getString("in_Prefs_colorPrereqQualify"); - private static String in_colorPrereqFail = PropertyFactory.getString("in_Prefs_colorPrereqFail"); - private static String in_colorAutoFeat = PropertyFactory.getString("in_Prefs_colorAutoFeat"); - private static String in_colorVirtFeat = PropertyFactory.getString("in_Prefs_colorVirtFeat"); - private static String in_charTabPlacement = PropertyFactory.getString("in_Prefs_charTabPlacement"); - private static String in_charTabLabel = PropertyFactory.getString("in_Prefs_charTabLabel"); - private static String in_character = PropertyFactory.getString("in_Prefs_character"); + private static String in_allowMetamagic = + PropertyFactory.getString("in_Prefs_allowMetamagic"); + private static String in_allowOverride = + PropertyFactory.getString("in_Prefs_allowOverride"); + private static String in_alwaysOverwrite = + PropertyFactory.getString("in_Prefs_alwaysOverwrite"); + private static String in_appearance = + PropertyFactory.getString("in_Prefs_appearance"); + private static String in_autoLoadAtStart = + PropertyFactory.getString("in_Prefs_autoLoadAtStart"); + private static String in_autoLoadWithPC = + PropertyFactory.getString("in_Prefs_autoLoadWithPC"); + private static String in_anyAutoEquip = + PropertyFactory.getString("in_Prefs_anyAutoEquip"); + private static String in_autoEquip = + PropertyFactory.getString("in_Prefs_autoEquip"); + private static String in_autoEquipRace = + PropertyFactory.getString("in_Prefs_autoEquipRace"); + private static String in_autoEquipMasterwork = + PropertyFactory.getString("in_Prefs_autoEquipMasterwork"); + private static String in_autoEquipMagic = + PropertyFactory.getString("in_Prefs_autoEquipMagic"); + private static String in_autoEquipExotic = + PropertyFactory.getString("in_Prefs_autoEquipExotic"); + private static String in_browserPath = + PropertyFactory.getString("in_Prefs_browserPath"); + private static String in_clearBrowserPath = + PropertyFactory.getString("in_Prefs_clearBrowserPath"); + private static String in_color = + PropertyFactory.getString("in_Prefs_color"); + private static String in_colorPrereqQualify = + PropertyFactory.getString("in_Prefs_colorPrereqQualify"); + private static String in_colorPrereqFail = + PropertyFactory.getString("in_Prefs_colorPrereqFail"); + private static String in_colorAutoFeat = + PropertyFactory.getString("in_Prefs_colorAutoFeat"); + private static String in_colorVirtFeat = + PropertyFactory.getString("in_Prefs_colorVirtFeat"); + private static String in_charTabPlacement = + PropertyFactory.getString("in_Prefs_charTabPlacement"); + private static String in_charTabLabel = + PropertyFactory.getString("in_Prefs_charTabLabel"); + private static String in_character = + PropertyFactory.getString("in_Prefs_character"); //PropertyFactory.getString("in_Prefs_chooseSkin"); - private static String in_cmNone = PropertyFactory.getString("in_Prefs_cmNone"); - private static String in_cmSelect = PropertyFactory.getString("in_Prefs_cmSelect"); - private static String in_cmSelectExit = PropertyFactory.getString("in_Prefs_cmSelectExit"); - private static String in_displayOGL = PropertyFactory.getString("in_Prefs_displayOGL"); - private static String in_displayd20 = PropertyFactory.getString("in_Prefs_displayd20"); - private static String in_displaySponsors = PropertyFactory.getString("in_Prefs_displaySponsors"); - private static String in_dialogTitle = PropertyFactory.getString("in_Prefs_title"); - private static String in_displayOpts = PropertyFactory.getString("in_Prefs_displayOpts"); - private static String in_expertGUI = PropertyFactory.getString("in_Prefs_expertGUI"); - private static String in_enforceSpending = PropertyFactory.getString("in_Prefs_enforceSpending"); - private static String in_equipment = PropertyFactory.getString("in_Prefs_equipment"); -// private static String in_featWindow = PropertyFactory.getString("in_Prefs_featWindow"); + private static String in_cmNone = + PropertyFactory.getString("in_Prefs_cmNone"); + private static String in_cmSelect = + PropertyFactory.getString("in_Prefs_cmSelect"); + private static String in_cmSelectExit = + PropertyFactory.getString("in_Prefs_cmSelectExit"); + private static String in_displayOGL = + PropertyFactory.getString("in_Prefs_displayOGL"); + private static String in_displayMature = + PropertyFactory.getString("in_Prefs_displayMature"); + private static String in_displayd20 = + PropertyFactory.getString("in_Prefs_displayd20"); + private static String in_displaySponsors = + PropertyFactory.getString("in_Prefs_displaySponsors"); + private static String in_dialogTitle = + PropertyFactory.getString("in_Prefs_title"); + private static String in_displayOpts = + PropertyFactory.getString("in_Prefs_displayOpts"); + private static String in_expertGUI = + PropertyFactory.getString("in_Prefs_expertGUI"); + private static String in_enforceSpending = + PropertyFactory.getString("in_Prefs_enforceSpending"); + private static String in_equipment = + PropertyFactory.getString("in_Prefs_equipment"); + // private static String in_featWindow = PropertyFactory.getString("in_Prefs_featWindow"); private static String in_hp = PropertyFactory.getString("in_Prefs_hp"); - private static String in_houseRules = PropertyFactory.getString("in_Prefs_houseRules"); - private static String in_hpWindow = PropertyFactory.getString("in_Prefs_hpWindow"); - private static String in_invalidToHitText = PropertyFactory.getString("in_Prefs_invalidToHitText"); - private static String in_invalidDmgText = PropertyFactory.getString("in_Prefs_invalidDmgText"); - private static String in_loadURLs = PropertyFactory.getString("in_Prefs_loadURLs"); - private static String in_language = PropertyFactory.getString("in_Prefs_language"); - private static String in_langEnglish = PropertyFactory.getString("in_Prefs_langEnglish"); - private static String in_langFrench = PropertyFactory.getString("in_Prefs_langFrench"); - private static String in_langGerman = PropertyFactory.getString("in_Prefs_langGerman"); - private static String in_langItalian = PropertyFactory.getString("in_Prefs_langItalian"); - private static String in_langSpanish = PropertyFactory.getString("in_Prefs_langSpanish"); - private static String in_langPortuguese = PropertyFactory.getString("in_Prefs_langPortuguese"); - private static String in_langSystem = PropertyFactory.getString("in_Prefs_langSystem"); - private static String in_location = PropertyFactory.getString("in_Prefs_location"); - private static String in_lookAndFeel = PropertyFactory.getString("in_Prefs_lookAndFeel"); - private static String in_aaText = PropertyFactory.getString("in_Prefs_aaText"); - private static String in_levelUp = PropertyFactory.getString("in_Prefs_levelUp"); - private static String in_monsters = PropertyFactory.getString("in_Prefs_monsters"); - private static String in_mainTabPlacement = PropertyFactory.getString("in_Prefs_mainTabPlacement"); - private static String in_noAutoEquip = PropertyFactory.getString("in_Prefs_noAutoEquip"); - private static String in_output = PropertyFactory.getString("in_Prefs_output"); - private static String in_outputSheetEqSet = PropertyFactory.getString("in_Prefs_templateEqSet"); - private static String in_pcgen = PropertyFactory.getString("in_Prefs_pcgen"); + private static String in_houseRules = + PropertyFactory.getString("in_Prefs_houseRules"); + private static String in_hpWindow = + PropertyFactory.getString("in_Prefs_hpWindow"); + private static String in_invalidToHitText = + PropertyFactory.getString("in_Prefs_invalidToHitText"); + private static String in_invalidDmgText = + PropertyFactory.getString("in_Prefs_invalidDmgText"); + private static String in_loadURLs = + PropertyFactory.getString("in_Prefs_loadURLs"); + private static String in_language = + PropertyFactory.getString("in_Prefs_language"); + private static String in_langEnglish = + PropertyFactory.getString("in_Prefs_langEnglish"); + private static String in_langFrench = + PropertyFactory.getString("in_Prefs_langFrench"); + private static String in_langGerman = + PropertyFactory.getString("in_Prefs_langGerman"); + private static String in_langItalian = + PropertyFactory.getString("in_Prefs_langItalian"); + private static String in_langSpanish = + PropertyFactory.getString("in_Prefs_langSpanish"); + private static String in_langPortuguese = + PropertyFactory.getString("in_Prefs_langPortuguese"); + private static String in_langSystem = + PropertyFactory.getString("in_Prefs_langSystem"); + private static String in_location = + PropertyFactory.getString("in_Prefs_location"); + private static String in_lookAndFeel = + PropertyFactory.getString("in_Prefs_lookAndFeel"); + private static String in_aaText = + PropertyFactory.getString("in_Prefs_aaText"); + private static String in_levelUp = + PropertyFactory.getString("in_Prefs_levelUp"); + private static String in_monsters = + PropertyFactory.getString("in_Prefs_monsters"); + private static String in_mainTabPlacement = + PropertyFactory.getString("in_Prefs_mainTabPlacement"); + private static String in_noAutoEquip = + PropertyFactory.getString("in_Prefs_noAutoEquip"); + private static String in_output = + PropertyFactory.getString("in_Prefs_output"); + private static String in_outputSheetEqSet = + PropertyFactory.getString("in_Prefs_templateEqSet"); + private static String in_pcgen = + PropertyFactory.getString("in_Prefs_pcgen"); //PropertyFactory.getString("in_Prefs_purchaseModeConfig"); - private static String in_potionMax = PropertyFactory.getString("in_Prefs_potionMax"); - private static String in_paperType = PropertyFactory.getString("in_Prefs_paperType"); - private static String in_postExportCommandStandard = PropertyFactory.getString("in_Prefs_postExportCommandStandard"); - private static String in_postExportCommandPDF = PropertyFactory.getString("in_Prefs_postExportCommandPDF"); - private static String in_removeTemp = PropertyFactory.getString("in_Prefs_removeTemp"); - private static String in_statWindow = PropertyFactory.getString("in_Prefs_statWindow"); - private static String in_showToolTips = PropertyFactory.getString("in_Prefs_showToolTips"); - private static String in_showToolBar = PropertyFactory.getString("in_Prefs_showToolBar"); - private static String in_showFeatDescription = PropertyFactory.getString("in_Prefs_showFeatDesciption"); - private static String in_singleChoiceOption = PropertyFactory.getString("in_Prefs_singleChoiceOption"); - private static String in_skinnedLAF = PropertyFactory.getString("in_Prefs_skinnedLAF"); - private static String in_sources = PropertyFactory.getString("in_Prefs_sources"); - private static String in_saveCustom = PropertyFactory.getString("in_Prefs_saveCustom"); - private static String in_saveOutputSheetWithPC = PropertyFactory.getString("in_Prefs_saveOutputSheetWithPC"); - private static String in_sdLong = PropertyFactory.getString("in_Prefs_sdLong"); - private static String in_sdPage = PropertyFactory.getString("in_Prefs_sdPage"); - private static String in_sdShort = PropertyFactory.getString("in_Prefs_sdShort"); - private static String in_sdMedium = PropertyFactory.getString("in_Prefs_sdMedium"); - private static String in_sdWeb = PropertyFactory.getString("in_Prefs_sdWeb"); - private static String in_showMemory = PropertyFactory.getString("in_Prefs_showMemory"); - private static String in_showImagePreview = PropertyFactory.getString("in_Prefs_showImagePreview"); - private static String in_showSkillModifierBreakdown = PropertyFactory.getString("in_Prefs_showSkillModifierBreakdown"); - private static String in_sourceDisplay = PropertyFactory.getString("in_Prefs_sourceDisplay"); + private static String in_potionMax = + PropertyFactory.getString("in_Prefs_potionMax"); + private static String in_paperType = + PropertyFactory.getString("in_Prefs_paperType"); + private static String in_postExportCommandStandard = + PropertyFactory.getString("in_Prefs_postExportCommandStandard"); + private static String in_postExportCommandPDF = + PropertyFactory.getString("in_Prefs_postExportCommandPDF"); + private static String in_removeTemp = + PropertyFactory.getString("in_Prefs_removeTemp"); + private static String in_statWindow = + PropertyFactory.getString("in_Prefs_statWindow"); + private static String in_showToolTips = + PropertyFactory.getString("in_Prefs_showToolTips"); + private static String in_showToolBar = + PropertyFactory.getString("in_Prefs_showToolBar"); + private static String in_showFeatDescription = + PropertyFactory.getString("in_Prefs_showFeatDesciption"); + private static String in_singleChoiceOption = + PropertyFactory.getString("in_Prefs_singleChoiceOption"); + private static String in_skinnedLAF = + PropertyFactory.getString("in_Prefs_skinnedLAF"); + private static String in_sources = + PropertyFactory.getString("in_Prefs_sources"); + private static String in_saveCustom = + PropertyFactory.getString("in_Prefs_saveCustom"); + private static String in_saveOutputSheetWithPC = + PropertyFactory.getString("in_Prefs_saveOutputSheetWithPC"); + private static String in_sdLong = + PropertyFactory.getString("in_Prefs_sdLong"); + private static String in_sdPage = + PropertyFactory.getString("in_Prefs_sdPage"); + private static String in_sdShort = + PropertyFactory.getString("in_Prefs_sdShort"); + private static String in_sdMedium = + PropertyFactory.getString("in_Prefs_sdMedium"); + private static String in_sdWeb = + PropertyFactory.getString("in_Prefs_sdWeb"); + private static String in_showMemory = + PropertyFactory.getString("in_Prefs_showMemory"); + private static String in_showImagePreview = + PropertyFactory.getString("in_Prefs_showImagePreview"); + private static String in_showSkillModifierBreakdown = + PropertyFactory.getString("in_Prefs_showSkillModifierBreakdown"); + private static String in_sourceDisplay = + PropertyFactory.getString("in_Prefs_sourceDisplay"); private static String in_tabs = PropertyFactory.getString("in_Prefs_tabs"); - private static String in_tabLabelPlain = PropertyFactory.getString("in_Prefs_tabLabelPlain"); - private static String in_tabLabelEpic = PropertyFactory.getString("in_Prefs_tabLabelEpic"); - private static String in_tabLabelRace = PropertyFactory.getString("in_Prefs_tabLabelRace"); - private static String in_tabLabelNetHack = PropertyFactory.getString("in_Prefs_tabLabelNetHack"); - private static String in_tabLabelFull = PropertyFactory.getString("in_Prefs_tabLabelFull"); - private static String in_tabPosTop = PropertyFactory.getString("in_Prefs_tabPosTop"); - private static String in_tabPosBottom = PropertyFactory.getString("in_Prefs_tabPosBottom"); - private static String in_tabPosLeft = PropertyFactory.getString("in_Prefs_tabPosLeft"); - private static String in_tabPosRight = PropertyFactory.getString("in_Prefs_tabPosRight"); - private static String in_tabAbilities = PropertyFactory.getString("in_Prefs_tabAbilities"); - private static String in_unitSetType = PropertyFactory.getString("in_Prefs_unitSetType"); - private static String in_useAutoWaitCursor = PropertyFactory.getString("in_Prefs_useAutoWaitCursor"); - private static String in_useOutputNamesEquipment = PropertyFactory.getString("in_Prefs_useOutputNamesEquipment"); - private static String in_useOutputNamesSpells = PropertyFactory.getString("in_Prefs_useOutputNamesSpells"); - private static String in_wandMax = PropertyFactory.getString("in_Prefs_wandMax"); - private static String in_warnFirstLevelUp = PropertyFactory.getString("in_Prefs_warnFirstLevelUp"); - private static String in_weaponProfPrintout = PropertyFactory.getString("in_Prefs_weaponProfPrintout"); - private static String in_skillChoice = PropertyFactory.getString("in_Prefs_skillChoiceLabel"); - private static String in_skillChoiceNone = PropertyFactory.getString("in_Prefs_skillChoiceNone"); - private static String in_skillChoiceUntrained = PropertyFactory.getString("in_Prefs_skillChoiceUntrained"); - private static String in_skillChoiceAll = PropertyFactory.getString("in_Prefs_skillChoiceAll"); - private static String in_skillChoiceAsUI = PropertyFactory.getString("in_Prefs_skillChoiceAsUI"); - private static String[] singleChoiceMethods = { in_cmNone, in_cmSelect, in_cmSelectExit }; + private static String in_tabLabelPlain = + PropertyFactory.getString("in_Prefs_tabLabelPlain"); + private static String in_tabLabelEpic = + PropertyFactory.getString("in_Prefs_tabLabelEpic"); + private static String in_tabLabelRace = + PropertyFactory.getString("in_Prefs_tabLabelRace"); + private static String in_tabLabelNetHack = + PropertyFactory.getString("in_Prefs_tabLabelNetHack"); + private static String in_tabLabelFull = + PropertyFactory.getString("in_Prefs_tabLabelFull"); + private static String in_tabPosTop = + PropertyFactory.getString("in_Prefs_tabPosTop"); + private static String in_tabPosBottom = + PropertyFactory.getString("in_Prefs_tabPosBottom"); + private static String in_tabPosLeft = + PropertyFactory.getString("in_Prefs_tabPosLeft"); + private static String in_tabPosRight = + PropertyFactory.getString("in_Prefs_tabPosRight"); + private static String in_tabAbilities = + PropertyFactory.getString("in_Prefs_tabAbilities"); + private static String in_unitSetType = + PropertyFactory.getString("in_Prefs_unitSetType"); + private static String in_useAutoWaitCursor = + PropertyFactory.getString("in_Prefs_useAutoWaitCursor"); + private static String in_useOutputNamesEquipment = + PropertyFactory.getString("in_Prefs_useOutputNamesEquipment"); + private static String in_useOutputNamesSpells = + PropertyFactory.getString("in_Prefs_useOutputNamesSpells"); + private static String in_wandMax = + PropertyFactory.getString("in_Prefs_wandMax"); + private static String in_warnFirstLevelUp = + PropertyFactory.getString("in_Prefs_warnFirstLevelUp"); + private static String in_weaponProfPrintout = + PropertyFactory.getString("in_Prefs_weaponProfPrintout"); + private static String in_skillChoice = + PropertyFactory.getString("in_Prefs_skillChoiceLabel"); + private static String in_skillChoiceNone = + PropertyFactory.getString("in_Prefs_skillChoiceNone"); + private static String in_skillChoiceUntrained = + PropertyFactory.getString("in_Prefs_skillChoiceUntrained"); + private static String in_skillChoiceAll = + PropertyFactory.getString("in_Prefs_skillChoiceAll"); + private static String in_skillChoiceAsUI = + PropertyFactory.getString("in_Prefs_skillChoiceAsUI"); + private static String[] singleChoiceMethods = + {in_cmNone, in_cmSelect, in_cmSelectExit}; private static String in_choose = "..."; private ButtonGroup groupFilesDir; private DefaultTreeModel settingsModel; @@ -251,7 +358,7 @@ private JCheckBox displayAbilitiesAsTab = new JCheckBox(); private JCheckBox expertGUICheckBox = new JCheckBox(); private JCheckBox featDescriptionShown = new JCheckBox(); -// private JCheckBox featDialogShownAtLevelUp = new JCheckBox(); + // private JCheckBox featDialogShownAtLevelUp = new JCheckBox(); private JCheckBox hideMonsterClasses = new JCheckBox(); // Level Up @@ -264,6 +371,7 @@ private JCheckBox saveCustom = new JCheckBox(); private JCheckBox saveOutputSheetWithPC = new JCheckBox(); private JCheckBox showOGL = new JCheckBox(); + private JCheckBox showMature = new JCheckBox(); private JCheckBox showToolbar = new JCheckBox(); private JCheckBox showWarningAtFirstLevelUp = new JCheckBox(); private JCheckBox showd20 = new JCheckBox(); @@ -289,7 +397,7 @@ private JComboBoxEx abilityRolledModeCombo = null; private JComboBoxEx charTabPlacementCombo; private JComboBoxEx cmbChoiceMethods = new JComboBoxEx(singleChoiceMethods); -// private JComboBoxEx crossClassSkillCostCombo = new JComboBoxEx(new String[]{ "0 ", "1 ", "2 " }); + // private JComboBoxEx crossClassSkillCostCombo = new JComboBoxEx(new String[]{ "0 ", "1 ", "2 " }); // Tab Options private JComboBoxEx mainTabPlacementCombo; @@ -311,11 +419,16 @@ private JRadioButton autoEquipCreate; // "HP Roll Methods" - private JRadioButton hpAutomax = new JRadioButton(PropertyFactory.getString("in_Prefs_hpAutoMax")); - private JRadioButton hpAverage = new JRadioButton(PropertyFactory.getString("in_Prefs_hpAverage")); - private JRadioButton hpPercentage = new JRadioButton(PropertyFactory.getString("in_Prefs_hpPercentage")); - private JRadioButton hpStandard = new JRadioButton(PropertyFactory.getString("in_Prefs_hpStandard")); - private JRadioButton hpUserRolled = new JRadioButton(PropertyFactory.getString("in_Prefs_hpUserRolled")); + private JRadioButton hpAutomax = + new JRadioButton(PropertyFactory.getString("in_Prefs_hpAutoMax")); + private JRadioButton hpAverage = + new JRadioButton(PropertyFactory.getString("in_Prefs_hpAverage")); + private JRadioButton hpPercentage = + new JRadioButton(PropertyFactory.getString("in_Prefs_hpPercentage")); + private JRadioButton hpStandard = + new JRadioButton(PropertyFactory.getString("in_Prefs_hpStandard")); + private JRadioButton hpUserRolled = + new JRadioButton(PropertyFactory.getString("in_Prefs_hpUserRolled")); // Language private JRadioButton langEng; @@ -364,9 +477,10 @@ // Listeners private PrefsButtonListener prefsButtonHandler = new PrefsButtonListener(); private PurchaseModeFrame pmsFrame = null; - private final TextFocusLostListener textFieldListener = new TextFocusLostListener(); + private final TextFocusLostListener textFieldListener = + new TextFocusLostListener(); private WholeNumberField hpPct = new WholeNumberField(0, 6); -// private String[] allSameValue = new String[STATMAX - STATMIN + 1]; + // private String[] allSameValue = new String[STATMAX - STATMIN + 1]; // "House Rules" private JCheckBox[] hrBoxes = null; @@ -414,28 +528,32 @@ public static PreferencesComponent getPreferencesComponent() { - if(compInst == null) + if (compInst == null) { compInst = new PreferencesComponent(); } return compInst; } - private void addPluginPanes(DefaultMutableTreeNode rootNode, DefaultMutableTreeNode pluginNode) + private void addPluginPanes(DefaultMutableTreeNode rootNode, + DefaultMutableTreeNode pluginNode) { List<String> nameList = compInst.getNameList(); List<PreferencesPanel> panelList = compInst.getPanelList(); - HashMap<String, JTabbedPane> nodeMap = new HashMap<String, JTabbedPane>(); + HashMap<String, JTabbedPane> nodeMap = + new HashMap<String, JTabbedPane>(); - for(int i = 0; i < nameList.size(); i++) + for (int i = 0; i < nameList.size(); i++) { String name = nameList.get(i); PreferencesPanel panel = panelList.get(i); JTabbedPane tpane; - if(nodeMap.get(name) == null) { + if (nodeMap.get(name) == null) + { tpane = new JTabbedPane(); } - else { + else + { tpane = nodeMap.get(name); } @@ -444,7 +562,7 @@ } Set<String> keySet = nodeMap.keySet(); - for(String name : keySet) + for (String name : keySet) { JTabbedPane tpane = nodeMap.get(name); @@ -452,7 +570,8 @@ settingsPanel.add(tpane, name); } - if(pluginsPanel == null) { + if (pluginsPanel == null) + { pluginsPanel = new PreferencesPluginsPanel(); } JTabbedPane tpane = new JTabbedPane(); @@ -463,7 +582,7 @@ public void applyPluginPreferences() { - List<PreferencesPanel> panelList = compInst.getPanelList(); + List<PreferencesPanel> panelList = compInst.getPanelList(); for (int i = 0; i < panelList.size(); i++) { @@ -478,7 +597,8 @@ final GameMode gameMode = SettingsHandler.getGame(); // Abilities - gameMode.setAllStatsValue(abilityScoreCombo.getSelectedIndex() + gameMode.getStatMin()); + gameMode.setAllStatsValue(abilityScoreCombo.getSelectedIndex() + + gameMode.getStatMin()); if (abilitiesUserRolledButton.isSelected()) { @@ -490,20 +610,25 @@ } else if (abilitiesPurchasedButton.isSelected()) { - if (abilityPurchaseModeCombo.isVisible() && (abilityPurchaseModeCombo.getSelectedIndex() >= 0)) + if (abilityPurchaseModeCombo.isVisible() + && (abilityPurchaseModeCombo.getSelectedIndex() >= 0)) { - gameMode.setPurchaseMethodName(pModeMethodName[abilityPurchaseModeCombo.getSelectedIndex()]); + gameMode + .setPurchaseMethodName(pModeMethodName[abilityPurchaseModeCombo + .getSelectedIndex()]); } else { gameMode.setRollMethod(Constants.CHARACTERSTATMETHOD_USER); } } - else if ((abilitiesRolledButton != null) && (abilitiesRolledButton.isSelected())) + else if ((abilitiesRolledButton != null) + && (abilitiesRolledButton.isSelected())) { if (abilityRolledModeCombo.getSelectedIndex() >= 0) { - gameMode.setRollMethodExpressionByName(abilityRolledModeCombo.getSelectedItem().toString()); + gameMode.setRollMethodExpressionByName(abilityRolledModeCombo + .getSelectedItem().toString()); } else { @@ -522,7 +647,6 @@ characterPane.refresh(); } - // Hit points if (hpStandard.isSelected()) { @@ -580,7 +704,7 @@ } } -// SettingsHandler.setIntCrossClassSkillCost(crossClassSkillCostCombo.getSelectedIndex()); + // SettingsHandler.setIntCrossClassSkillCost(crossClassSkillCostCombo.getSelectedIndex()); // Monsters SettingsHandler.setMonsterDefault(useMonsterDefault.isSelected()); @@ -611,8 +735,10 @@ break; default: - Logging.errorPrint("In PreferencesDialog.setOptionsBasedOnControls (mainTabPlacementCombo) the index " - + mainTabPlacementCombo.getSelectedIndex() + " is unsupported."); + Logging + .errorPrint("In PreferencesDialog.setOptionsBasedOnControls (mainTabPlacementCombo) the index " + + mainTabPlacementCombo.getSelectedIndex() + + " is unsupported."); break; } @@ -640,8 +766,10 @@ break; default: - Logging.errorPrint("In PreferencesDialog.setOptionsBasedOnControls (charTabPlacementCombo) the index " - + charTabPlacementCombo.getSelectedIndex() + " is unsupported."); + Logging + .errorPrint("In PreferencesDialog.setOptionsBasedOnControls (charTabPlacementCombo) the index " + + charTabPlacementCombo.getSelectedIndex() + + " is unsupported."); break; } @@ -649,38 +777,46 @@ switch (tabLabelsCombo.getSelectedIndex()) { case 0: - SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME); + SettingsHandler + .setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME); break; case 1: - SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_CLASS); + SettingsHandler + .setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_CLASS); break; case 2: - SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_RACE); + SettingsHandler + .setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_RACE); break; case 3: - SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_RACE_CLASS); + SettingsHandler + .setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_RACE_CLASS); break; case 4: - SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_FULL); + SettingsHandler + .setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_FULL); break; default: - Logging.errorPrint("In PreferencesDialog.setOptionsBasedOnControls (tabLabelsCombo) the index " - + tabLabelsCombo.getSelectedIndex() + " is unsupported."); + Logging + .errorPrint("In PreferencesDialog.setOptionsBasedOnControls (tabLabelsCombo) the index " + + tabLabelsCombo.getSelectedIndex() + + " is unsupported."); break; } - SettingsHandler.setAbilitiesShownAsATab(displayAbilitiesAsTab.isSelected()); + SettingsHandler.setAbilitiesShownAsATab(displayAbilitiesAsTab + .isSelected()); SettingsHandler.setExpertGUI(expertGUICheckBox.isSelected()); SettingsHandler.setIncludeSkills(skillChoice.getSelectedIndex()); @@ -690,9 +826,12 @@ SettingsHandler.setShowImagePreview(showImagePreview.isSelected()); SettingsHandler.setToolBarShown(showToolbar.isSelected()); SettingsHandler.setUseWaitCursor(waitCursor.isSelected()); - SettingsHandler.setGUIUsesOutputNameEquipment(useOutputNamesEquipment.isSelected()); - SettingsHandler.setGUIUsesOutputNameSpells(useOutputNamesSpells.isSelected()); - SettingsHandler.setSingleChoicePreference(cmbChoiceMethods.getSelectedIndex()); + SettingsHandler.setGUIUsesOutputNameEquipment(useOutputNamesEquipment + .isSelected()); + SettingsHandler.setGUIUsesOutputNameSpells(useOutputNamesSpells + .isSelected()); + SettingsHandler.setSingleChoicePreference(cmbChoiceMethods + .getSelectedIndex()); SettingsHandler.setUseFeatBenefits(!featDescriptionShown.isSelected()); SettingsHandler.setShowSkillModifier(showSkillModifier.isSelected()); @@ -726,7 +865,9 @@ { if (SettingsHandler.getSkinLFThemePack().length() == 0) { - ShowMessageDelegate.showMessageDialog(PropertyFactory.getString("in_Prefs_noSkinError"), in_pcgen, MessageType.WARNING); + ShowMessageDelegate.showMessageDialog(PropertyFactory + .getString("in_Prefs_noSkinError"), in_pcgen, + MessageType.WARNING); } else { @@ -740,39 +881,57 @@ { SettingsHandler.setLookAndFeel(0); UIFactory.setLookAndFeel(0); - ShowMessageDelegate.showMessageDialog(PropertyFactory.getString("in_Prefs_skinSetError") + e.toString(), - in_pcgen, MessageType.ERROR); + ShowMessageDelegate.showMessageDialog(PropertyFactory + .getString("in_Prefs_skinSetError") + + e.toString(), in_pcgen, MessageType.ERROR); } } } else { - Logging.errorPrint(SkinLFResourceChecker.getMissingResourceMessage()); + Logging.errorPrint(SkinLFResourceChecker + .getMissingResourceMessage()); //final String missingLibMsg = PropertyFactory.getString("MissingLibMessage").replace('|', '\n'); //GuiFacade.showMessageDialog(null, SkinLFResourceChecker.getMissingResourceMessage() + missingLibMsg, Constants.s_APPNAME, GuiFacade.WARNING_MESSAGE); - new LinkableHtmlMessage(this, SkinLFResourceChecker.getMissingResourceMessage(), Constants.s_APPNAME) - .setVisible(true); + new LinkableHtmlMessage(this, SkinLFResourceChecker + .getMissingResourceMessage(), Constants.s_APPNAME) + .setVisible(true); } } // Level up - SettingsHandler.setShowHPDialogAtLevelUp(hpDialogShownAtLevelUp.isSelected()); + SettingsHandler.setShowHPDialogAtLevelUp(hpDialogShownAtLevelUp + .isSelected()); //SettingsHandler.setShowFeatDialogAtLevelUp(featDialogShownAtLevelUp.isSelected()); - SettingsHandler.setShowStatDialogAtLevelUp(statDialogShownAtLevelUp.isSelected()); - SettingsHandler.setShowWarningAtFirstLevelUp(showWarningAtFirstLevelUp.isSelected()); - SettingsHandler.setEnforceSpendingBeforeLevelUp(enforceSpendingBeforeLevelUp.isSelected()); + SettingsHandler.setShowStatDialogAtLevelUp(statDialogShownAtLevelUp + .isSelected()); + SettingsHandler.setShowWarningAtFirstLevelUp(showWarningAtFirstLevelUp + .isSelected()); + SettingsHandler + .setEnforceSpendingBeforeLevelUp(enforceSpendingBeforeLevelUp + .isSelected()); // Equipment - SettingsHandler.setMetamagicAllowedInEqBuilder(allowMetamagicInEqBuilder.isSelected()); - SettingsHandler.setMaxPotionSpellLevel(potionMaxLevel.getSelectedIndex() + SPELLLVLMIN); - SettingsHandler.setMaxWandSpellLevel(wandMaxLevel.getSelectedIndex() + SPELLLVLMIN); + SettingsHandler + .setMetamagicAllowedInEqBuilder(allowMetamagicInEqBuilder + .isSelected()); + SettingsHandler.setMaxPotionSpellLevel(potionMaxLevel + .getSelectedIndex() + + SPELLLVLMIN); + SettingsHandler.setMaxWandSpellLevel(wandMaxLevel.getSelectedIndex() + + SPELLLVLMIN); SettingsHandler.setWantToLoadMasterworkAndMagic(false); // Turn it off temporarily so we can set the values - SettingsHandler.setAutogen(Constants.AUTOGEN_RACIAL, autoMethod1.isSelected()); - SettingsHandler.setAutogen(Constants.AUTOGEN_MASTERWORK, autoMethod2.isSelected()); - SettingsHandler.setAutogen(Constants.AUTOGEN_MAGIC, autoMethod3.isSelected()); - SettingsHandler.setAutogen(Constants.AUTOGEN_EXOTICMATERIAL, autoMethod4.isSelected()); - SettingsHandler.setWantToLoadMasterworkAndMagic(noAutoEquipCreate.isSelected()); // Now set it properly + SettingsHandler.setAutogen(Constants.AUTOGEN_RACIAL, autoMethod1 + .isSelected()); + SettingsHandler.setAutogen(Constants.AUTOGEN_MASTERWORK, autoMethod2 + .isSelected()); + SettingsHandler.setAutogen(Constants.AUTOGEN_MAGIC, autoMethod3 + .isSelected()); + SettingsHandler.setAutogen(Constants.AUTOGEN_EXOTICMATERIAL, + autoMethod4.isSelected()); + SettingsHandler.setWantToLoadMasterworkAndMagic(noAutoEquipCreate + .isSelected()); // Now set it properly // Language if (langEng.isSelected()) @@ -811,14 +970,16 @@ Globals.setCountry(null); } - SettingsHandler.getGame().selectUnitSet((String) unitSetType.getSelectedItem()); + SettingsHandler.getGame().selectUnitSet( + (String) unitSetType.getSelectedItem()); // Location -- added 10 April 2000 by sage_sam SettingsHandler.setBrowserPath(browserPath.getText()); SettingsHandler.setPcgPath(new File(pcgenCharacterDir.getText())); SettingsHandler.setPortraitsPath(new File(pcgenPortraitsDir.getText())); SettingsHandler.setPcgenCustomDir(new File(pcgenCustomDir.getText())); - SettingsHandler.setPcgenVendorDataDir(new File(pcgenVendorDataDir.getText())); + SettingsHandler.setPcgenVendorDataDir(new File(pcgenVendorDataDir + .getText())); SettingsHandler.setPccFilesLocation(new File(pcgenDataDir.getText())); SettingsHandler.setPcgenDocsDir(new File(pcgenDocsDir.getText())); SettingsHandler.setPcgenSystemDir(new File(pcgenSystemDir.getText())); @@ -835,36 +996,48 @@ SettingsHandler.setFilePaths(pcgenFilesDir.getText()); } SettingsHandler.setPcgenFilesDir(new File(pcgenFilesDir.getText())); - SettingsHandler.setPcgenOutputSheetDir(new File(pcgenOutputSheetDir.getText())); - SettingsHandler.setCreatePcgBackup(pcgenCreateBackupCharacter.isSelected()); - SettingsHandler.setBackupPcgPath(new File(pcgenBackupCharacterDir.getText())); + SettingsHandler.setPcgenOutputSheetDir(new File(pcgenOutputSheetDir + .getText())); + SettingsHandler.setCreatePcgBackup(pcgenCreateBackupCharacter + .isSelected()); + SettingsHandler.setBackupPcgPath(new File(pcgenBackupCharacterDir + .getText())); // Output Globals.selectPaper((String) paperType.getSelectedItem()); - if (SettingsHandler.getCleanupTempFiles() || removeTempFiles.isSelected()) + if (SettingsHandler.getCleanupTempFiles() + || removeTempFiles.isSelected()) { SettingsHandler.setCleanupTempFiles(removeTempFiles.isSelected()); } - if (SettingsHandler.getWeaponProfPrintout() != weaponProfPrintout.isSelected()) + if (SettingsHandler.getWeaponProfPrintout() != weaponProfPrintout + .isSelected()) { - SettingsHandler.setWeaponProfPrintout(weaponProfPrintout.isSelected()); + SettingsHandler.setWeaponProfPrintout(weaponProfPrintout + .isSelected()); } - if (SettingsHandler.getAlwaysOverwrite() || alwaysOverwrite.isSelected()) + if (SettingsHandler.getAlwaysOverwrite() + || alwaysOverwrite.isSelected()) { SettingsHandler.setAlwaysOverwrite(alwaysOverwrite.isSelected()); } // added 10 April 2000 by sage_sam - SettingsHandler.setSelectedCharacterHTMLOutputSheet(outputSheetHTMLDefault.getText(), null); - SettingsHandler.setSelectedCharacterPDFOutputSheet(outputSheetPDFDefault.getText(), null); + SettingsHandler.setSelectedCharacterHTMLOutputSheet( + outputSheetHTMLDefault.getText(), null); + SettingsHandler.setSelectedCharacterPDFOutputSheet( + outputSheetPDFDefault.getText(), null); SettingsHandler.setSelectedEqSetTemplate(outputSheetEqSet.getText()); - SettingsHandler.setSaveOutputSheetWithPC(saveOutputSheetWithPC.isSelected()); - SettingsHandler.setSelectedSpellSheet(outputSheetSpellsDefault.getText()); + SettingsHandler.setSaveOutputSheetWithPC(saveOutputSheetWithPC + .isSelected()); + SettingsHandler.setSelectedSpellSheet(outputSheetSpellsDefault + .getText()); SettingsHandler.setPrintSpellsWithPC(printSpellsWithPC.isSelected()); - SettingsHandler.setPostExportCommandStandard(postExportCommandStandard.getText()); + SettingsHandler.setPostExportCommandStandard(postExportCommandStandard + .getText()); SettingsHandler.setPostExportCommandPDF(postExportCommandPDF.getText()); SettingsHandler.setInvalidToHitText(invalidToHitText.getText()); SettingsHandler.setInvalidDmgText(invalidDmgText.getText()); @@ -872,9 +1045,11 @@ // Sources SettingsHandler.setLoadCampaignsAtStart(campLoad.isSelected()); SettingsHandler.setLoadCampaignsWithPC(charCampLoad.isSelected()); - SettingsHandler.setOptionAllowedInSources(allowOptsInSource.isSelected()); + SettingsHandler.setOptionAllowedInSources(allowOptsInSource + .isSelected()); SettingsHandler.setSaveCustomEquipment(saveCustom.isSelected()); SettingsHandler.setShowLicense(showOGL.isSelected()); + SettingsHandler.setShowMature(showMature.isSelected()); SettingsHandler.setShowD20Info(showd20.isSelected()); SettingsHandler.setShowSponsors(showSponsors.isSelected()); SettingsHandler.setLoadURLs(loadURL.isSelected()); @@ -909,8 +1084,9 @@ break; default: - Logging.errorPrint("In PreferencesDialog.setOptionsBasedOnControls (sourceOptions) the index " - + sourceOptions.getSelectedIndex() + " is unsupported."); + Logging + .errorPrint("In PreferencesDialog.setOptionsBasedOnControls (sourceOptions) the index " + + sourceOptions.getSelectedIndex() + " is unsupported."); break; } @@ -944,7 +1120,8 @@ break; case Constants.CHARACTERSTATMETHOD_PURCHASE: - if (!abilitiesPurchasedButton.isVisible() || (pMode.length == 0)) + if (!abilitiesPurchasedButton.isVisible() + || (pMode.length == 0)) { bValid = false; } @@ -963,7 +1140,8 @@ else { abilitiesRolledButton.setSelected(true); - abilityRolledModeCombo.setSelectedItem(gameMode.getRollMethodExpressionName()); + abilityRolledModeCombo.setSelectedItem(gameMode + .getRollMethodExpressionName()); } break; @@ -980,9 +1158,11 @@ gameMode.setRollMethod(Constants.CHARACTERSTATMETHOD_USER); } - final int allStatsValue = Math.min(gameMode.getStatMax(), gameMode.getAllStatsValue()); + final int allStatsValue = + Math.min(gameMode.getStatMax(), gameMode.getAllStatsValue()); gameMode.setAllStatsValue(allStatsValue); - abilityScoreCombo.setSelectedIndex(allStatsValue - gameMode.getStatMin()); + abilityScoreCombo.setSelectedIndex(allStatsValue + - gameMode.getStatMin()); if ((pMode != null) && (pModeMethodName != null)) { @@ -1021,7 +1201,7 @@ break; case Constants.HP_STANDARD: - //No break + //No break default: hpStandard.setSelected(true); @@ -1032,7 +1212,7 @@ maxHpAtFirstLevel.setSelected(SettingsHandler.isHPMaxAtFirstLevel()); // House Rules -// crossClassSkillCostCombo.setSelectedIndex(SettingsHandler.getIntCrossClassSkillCost()); + // crossClassSkillCostCombo.setSelectedIndex(SettingsHandler.getIntCrossClassSkillCost()); // Monsters useMonsterDefault.setSelected(SettingsHandler.isMonsterDefault()); @@ -1040,10 +1220,14 @@ ignoreMonsterHDCap.setSelected(SettingsHandler.isIgnoreMonsterHDCap()); // Colors - prereqQualifyColor.setForeground(new Color(SettingsHandler.getPrereqQualifyColor())); - prereqFailColor.setForeground(new Color(SettingsHandler.getPrereqFailColor())); - featAutoColor.setForeground(new Color(SettingsHandler.getFeatAutoColor())); - featVirtualColor.setForeground(new Color(SettingsHandler.getFeatVirtualColor())); + prereqQualifyColor.setForeground(new Color(SettingsHandler + .getPrereqQualifyColor())); + prereqFailColor.setForeground(new Color(SettingsHandler + .getPrereqFailColor())); + featAutoColor.setForeground(new Color(SettingsHandler + .getFeatAutoColor())); + featVirtualColor.setForeground(new Color(SettingsHandler + .getFeatVirtualColor())); // Tab options switch (SettingsHandler.getTabPlacement()) @@ -1069,8 +1253,10 @@ break; default: - Logging.errorPrint("In PreferencesDialog.applyOptionValuesToControls (tab placement) the tab option " - + SettingsHandler.getTabPlacement() + " is unsupported."); + Logging + .errorPrint("In PreferencesDialog.applyOptionValuesToControls (tab placement) the tab option " + + SettingsHandler.getTabPlacement() + + " is unsupported."); break; } @@ -1098,9 +1284,10 @@ break; default: - Logging.errorPrint( - "In PreferencesDialog.applyOptionValuesToControls (cha tab placement) the tab option " - + SettingsHandler.getChaTabPlacement() + " is unsupported."); + Logging + .errorPrint("In PreferencesDialog.applyOptionValuesToControls (cha tab placement) the tab option " + + SettingsHandler.getChaTabPlacement() + + " is unsupported."); break; } @@ -1133,27 +1320,32 @@ break; default: - Logging.errorPrint( - "In PreferencesDialog.applyOptionValuesToControls (name display style) the tab option " - + SettingsHandler.getNameDisplayStyle() + " is unsupported."); + Logging + .errorPrint("In PreferencesDialog.applyOptionValuesToControls (name display style) the tab option " + + SettingsHandler.getNameDisplayStyle() + + " is unsupported."); break; } - displayAbilitiesAsTab.setSelected(SettingsHandler.isAbilitiesShownAsATab()); + displayAbilitiesAsTab.setSelected(SettingsHandler + .isAbilitiesShownAsATab()); expertGUICheckBox.setSelected(SettingsHandler.isExpertGUI()); skillChoice.setSelectedIndex(SettingsHandler.getIncludeSkills()); // Display options - cmbChoiceMethods.setSelectedIndex(SettingsHandler.getSingleChoicePreference()); + cmbChoiceMethods.setSelectedIndex(SettingsHandler + .getSingleChoicePreference()); featDescriptionShown.setSelected(!SettingsHandler.useFeatBenefits()); showMemory.setSelected(SettingsHandler.isShowMemoryArea()); showImagePreview.setSelected(SettingsHandler.isShowImagePreview()); showSkillModifier.setSelected(SettingsHandler.getShowSkillModifier()); showToolbar.setSelected(SettingsHandler.isToolBarShown()); toolTipTextShown.setSelected(SettingsHandler.isToolTipTextShown()); - useOutputNamesEquipment.setSelected(SettingsHandler.guiUsesOutputNameEquipment()); - useOutputNamesSpells.setSelected(SettingsHandler.guiUsesOutputNameSpells()); + useOutputNamesEquipment.setSelected(SettingsHandler + .guiUsesOutputNameEquipment()); + useOutputNamesSpells.setSelected(SettingsHandler + .guiUsesOutputNameSpells()); waitCursor.setSelected(SettingsHandler.getUseWaitCursor()); // Look and feel @@ -1182,16 +1374,24 @@ } // Level up - hpDialogShownAtLevelUp.setSelected(SettingsHandler.getShowHPDialogAtLevelUp()); + hpDialogShownAtLevelUp.setSelected(SettingsHandler + .getShowHPDialogAtLevelUp()); //featDialogShownAtLevelUp.setSelected(SettingsHandler.getShowFeatDialogAtLevelUp()); - statDialogShownAtLevelUp.setSelected(SettingsHandler.getShowStatDialogAtLevelUp()); - showWarningAtFirstLevelUp.setSelected(SettingsHandler.isShowWarningAtFirstLevelUp()); - enforceSpendingBeforeLevelUp.setSelected(SettingsHandler.getEnforceSpendingBeforeLevelUp()); + statDialogShownAtLevelUp.setSelected(SettingsHandler + .getShowStatDialogAtLevelUp()); + showWarningAtFirstLevelUp.setSelected(SettingsHandler + .isShowWarningAtFirstLevelUp()); + enforceSpendingBeforeLevelUp.setSelected(SettingsHandler + .getEnforceSpendingBeforeLevelUp()); // Equipment - allowMetamagicInEqBuilder.setSelected(SettingsHandler.isMetamagicAllowedInEqBuilder()); - potionMaxLevel.setSelectedIndex(SettingsHandler.getMaxPotionSpellLevel() - SPELLLVLMIN); - wandMaxLevel.setSelectedIndex(SettingsHandler.getMaxWandSpellLevel() - SPELLLVLMIN); + allowMetamagicInEqBuilder.setSelected(SettingsHandler + .isMetamagicAllowedInEqBuilder()); + potionMaxLevel.setSelectedIndex(SettingsHandler + .getMaxPotionSpellLevel() + - SPELLLVLMIN); + wandMaxLevel.setSelectedIndex(SettingsHandler.getMaxWandSpellLevel() + - SPELLLVLMIN); if (SettingsHandler.wantToLoadMasterworkAndMagic()) { @@ -1203,11 +1403,16 @@ } SettingsHandler.setWantToLoadMasterworkAndMagic(false); // Turn off temporarily so we get current setting - autoMethod1.setSelected(SettingsHandler.getAutogen(Constants.AUTOGEN_RACIAL)); - autoMethod2.setSelected(SettingsHandler.getAutogen(Constants.AUTOGEN_MASTERWORK)); - autoMethod3.setSelected(SettingsHandler.getAutogen(Constants.AUTOGEN_MAGIC)); - autoMethod4.setSelected(SettingsHandler.getAutogen(Constants.AUTOGEN_EXOTICMATERIAL)); - SettingsHandler.setWantToLoadMasterworkAndMagic(noAutoEquipCreate.isSelected()); // Reset its state now we are done + autoMethod1.setSelected(SettingsHandler + .getAutogen(Constants.AUTOGEN_RACIAL)); + autoMethod2.setSelected(SettingsHandler + .getAutogen(Constants.AUTOGEN_MASTERWORK)); + autoMethod3.setSelected(SettingsHandler + .getAutogen(Constants.AUTOGEN_MAGIC)); + autoMethod4.setSelected(SettingsHandler + .getAutogen(Constants.AUTOGEN_EXOTICMATERIAL)); + SettingsHandler.setWantToLoadMasterworkAndMagic(noAutoEquipCreate + .isSelected()); // Reset its state now we are done // Language langEng.setSelected(false); @@ -1219,7 +1424,8 @@ langSystem.setSelected(false); String language = Globals.getLanguage(); - if (language==null || language.equals("")) { + if (language == null || language.equals("")) + { langSystem.setSelected(true); } else if (Globals.getLanguage().equals("en")) @@ -1255,27 +1461,32 @@ unitSetType.setSelectedIndex(0); for (int i = 0; i < SystemCollections.getUnitSetList().size(); ++i) { - if (unitSetNames[i].equals(SettingsHandler.getGameModeUnitSet().getName())) + if (unitSetNames[i].equals(SettingsHandler.getGameModeUnitSet() + .getName())) { unitSetType.setSelectedIndex(i); } } // Locations - pcgenCreateBackupCharacter.setSelected(SettingsHandler.getCreatePcgBackup()); + pcgenCreateBackupCharacter.setSelected(SettingsHandler + .getCreatePcgBackup()); // Output paperType.setSelectedIndex(Globals.getSelectedPaper()); weaponProfPrintout.setSelected(SettingsHandler.getWeaponProfPrintout()); - saveOutputSheetWithPC.setSelected(SettingsHandler.getSaveOutputSheetWithPC()); + saveOutputSheetWithPC.setSelected(SettingsHandler + .getSaveOutputSheetWithPC()); printSpellsWithPC.setSelected(SettingsHandler.getPrintSpellsWithPC()); // Sources campLoad.setSelected(SettingsHandler.isLoadCampaignsAtStart()); charCampLoad.setSelected(SettingsHandler.isLoadCampaignsWithPC()); - allowOptsInSource.setSelected(SettingsHandler.isOptionAllowedInSources()); + allowOptsInSource.setSelected(SettingsHandler + .isOptionAllowedInSources()); saveCustom.setSelected(SettingsHandler.getSaveCustomEquipment()); showOGL.setSelected(SettingsHandler.showLicense()); + showMature.setSelected(SettingsHandler.showMature()); showd20.setSelected(SettingsHandler.showD20Info()); showSponsors.setSelected(SettingsHandler.showSponsors()); loadURL.setSelected(SettingsHandler.isLoadURLs()); @@ -1309,8 +1520,9 @@ break; default: - Logging.errorPrint("In PreferencesDialog.applyOptionValuesToControls (source display) the option " - + Globals.getSourceDisplay() + " is unsupported."); + Logging + .errorPrint("In PreferencesDialog.applyOptionValuesToControls (source display) the option " + + Globals.getSourceDisplay() + " is unsupported."); break; } @@ -1323,7 +1535,8 @@ JLabel label; ButtonGroup exclusiveGroup; Border etched = null; - TitledBorder title1 = BorderFactory.createTitledBorder(etched, in_abilities); + TitledBorder title1 = + BorderFactory.createTitledBorder(etched, in_abilities); JPanel abilityScoresPanel = new JPanel(); title1.setTitleJustification(TitledBorder.LEFT); @@ -1339,7 +1552,10 @@ exclusiveGroup = new ButtonGroup(); Utility.buildConstraints(c, 0, row++, 3, 1, 0, 0); - label = new JLabel(PropertyFactory.getString("in_Prefs_abilitiesGenLabel") + ": (" + gameMode.getName() + ")"); + label = + new JLabel(PropertyFactory + .getString("in_Prefs_abilitiesGenLabel") + + ": (" + gameMode.getName() + ")"); gridbag.setConstraints(label, c); abilityScoresPanel.add(label); Utility.buildConstraints(c, 0, row, 1, 1, 0, 0); @@ -1348,13 +1564,18 @@ abilityScoresPanel.add(label); Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0); - abilitiesUserRolledButton = new JRadioButton(PropertyFactory.getString("in_Prefs_abilitiesUserRolled")); + abilitiesUserRolledButton = + new JRadioButton(PropertyFactory + .getString("in_Prefs_abilitiesUserRolled")); gridbag.setConstraints(abilitiesUserRolledButton, c); abilityScoresPanel.add(abilitiesUserRolledButton); exclusiveGroup.add(abilitiesUserRolledButton); Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0); - abilitiesAllSameButton = new JRadioButton(PropertyFactory.getString("in_Prefs_abilitiesAllSame") + ": "); + abilitiesAllSameButton = + new JRadioButton(PropertyFactory + .getString("in_Prefs_abilitiesAllSame") + + ": "); gridbag.setConstraints(abilitiesAllSameButton, c); abilityScoresPanel.add(abilitiesAllSameButton); exclusiveGroup.add(abilitiesAllSameButton); @@ -1386,7 +1607,7 @@ abilityRolledModeCombo = new JComboBoxEx(); int gmi = 0; - while(rm != null) + while (rm != null) { abilityRolledModeCombo.addItem(rm.getMethodName()); rm = gameMode.getRollingMethod(++gmi); @@ -1398,7 +1619,10 @@ final int purchaseMethodCount = gameMode.getPurchaseMethodCount(); Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0); - abilitiesPurchasedButton = new JRadioButton(PropertyFactory.getString("in_Prefs_abilitiesPurchased") + ": "); + abilitiesPurchasedButton = + new JRadioButton(PropertyFactory + .getString("in_Prefs_abilitiesPurchased") + + ": "); gridbag.setConstraints(abilitiesPurchasedButton, c); abilityScoresPanel.add(abilitiesPurchasedButton); exclusiveGroup.add(abilitiesPurchasedButton); @@ -1433,7 +1657,9 @@ gridbag.setConstraints(label, c); abilityScoresPanel.add(label); Utility.buildConstraints(c, 1, row++, 3, 1, 0, 0); - purchaseModeButton = new JButton(PropertyFactory.getString("in_Prefs_purchaseModeConfig")); + purchaseModeButton = + new JButton(PropertyFactory + .getString("in_Prefs_purchaseModeConfig")); gridbag.setConstraints(purchaseModeButton, c); abilityScoresPanel.add(purchaseModeButton); purchaseModeButton.addActionListener(prefsButtonHandler); @@ -1453,7 +1679,8 @@ GridBagConstraints c = new GridBagConstraints(); JLabel label; Border etched = null; - TitledBorder title1 = BorderFactory.createTitledBorder(etched, in_color); + TitledBorder title1 = + BorderFactory.createTitledBorder(etched, in_color); JPanel colorsPanel = new JPanel(); title1.setTitleJustification(TitledBorder.LEFT); @@ -1468,14 +1695,18 @@ int col = 0; // NB - not alphabetized! - col = addColorsOption(col, c, gridbag, colorsPanel, - prereqQualifyColor = new JButton(in_colorPrereqQualify)); - col = addColorsOption(col, c, gridbag, colorsPanel, - prereqFailColor = new JButton(in_colorPrereqFail)); - col = addColorsOption(col, c, gridbag, colorsPanel, - featAutoColor = new JButton(in_colorAutoFeat)); - col = addColorsOption(col, c, gridbag, colorsPanel, - featVirtualColor = new JButton(in_colorVirtFeat)); + col = + addColorsOption(col, c, gridbag, colorsPanel, + prereqQualifyColor = new JButton(in_colorPrereqQualify)); + col = + addColorsOption(col, c, gridbag, colorsPanel, prereqFailColor = + new JButton(in_colorPrereqFail)); + col = + addColorsOption(col, c, gridbag, colorsPanel, featAutoColor = + new JButton(in_colorAutoFeat)); + col = + addColorsOption(col, c, gridbag, colorsPanel, featVirtualColor = + new JButton(in_colorVirtFeat)); Utility.buildConstraints(c, 5, 20, 1, 1, 1, 1); c.fill = GridBagConstraints.BOTH; @@ -1487,8 +1718,8 @@ } private int addColorsOption(int col, final GridBagConstraints c, - final GridBagLayout gridbag, final JPanel colorsPanel, - final JButton button) + final GridBagLayout gridbag, final JPanel colorsPanel, + final JButton button) { Utility.buildConstraints(c, 0, col++, 1, 1, 0, 0); gridbag.setConstraints(button, c); @@ -1504,7 +1735,8 @@ GridBagConstraints c = new GridBagConstraints(); JLabel label; Border etched = null; - TitledBorder title1 = BorderFactory.createTitledBorder(etched, in_displayOpts); + TitledBorder title1 = + BorderFactory.createTitledBorder(etched, in_disp... [truncated message content] |