From: <nu...@us...> - 2006-04-23 17:04:10
|
Revision: 886 Author: nuance Date: 2006-04-23 10:03:45 -0700 (Sun, 23 Apr 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=886&view=rev Log Message: ----------- Convert all the Ability choosers to use the new code structure. Deprecate PObjectUtilities (which should now be unused). Modified Paths: -------------- Trunk/pcgen/.classpath Trunk/pcgen/code/src/java/pcgen/core/Ability.java Trunk/pcgen/code/src/java/pcgen/core/AbilityUtilities.java Trunk/pcgen/code/src/java/pcgen/core/Domain.java Trunk/pcgen/code/src/java/pcgen/core/PObjectUtilities.java Trunk/pcgen/code/src/java/pcgen/core/chooser/AbstractComplexChoiceManager.java Trunk/pcgen/code/src/java/pcgen/core/chooser/AbstractSimpleChoiceManager.java Trunk/pcgen/code/src/java/pcgen/core/chooser/ChoiceManagerList.java Trunk/pcgen/code/src/java/pcgen/core/chooser/ChooserUtilities.java Trunk/pcgen/code/src/java/pcgen/core/chooser/SpellLevelChoiceManager.java Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbility.java Trunk/pcgen/code/src/test/pcgen/core/PlayerCharacterTest.java Modified: Trunk/pcgen/.classpath =================================================================== --- Trunk/pcgen/.classpath 2006-04-23 11:52:39 UTC (rev 885) +++ Trunk/pcgen/.classpath 2006-04-23 17:03:45 UTC (rev 886) @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="code/build/src"/> - <classpathentry kind="src" path="code/src/java"/> - <classpathentry kind="src" path="code/src/test"/> + <classpathentry excluding="**/.svn/*" kind="src" path="code/build/src"/> + <classpathentry excluding="**/.svn/*" kind="src" path="code/src/java"/> + <classpathentry excluding="**/.svn/*" kind="src" path="code/src/test"/> <classpathentry sourcepath="JRE_SRC" kind="var" path="JRE_LIB"/> <classpathentry kind="lib" path="lib/avalon-framework-cvs-20020806.jar"/> <classpathentry kind="lib" path="lib/batik.jar"/> Modified: Trunk/pcgen/code/src/java/pcgen/core/Ability.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Ability.java 2006-04-23 11:52:39 UTC (rev 885) +++ Trunk/pcgen/code/src/java/pcgen/core/Ability.java 2006-04-23 17:03:45 UTC (rev 886) @@ -23,6 +23,7 @@ import java.util.Iterator; import java.util.List; +import pcgen.core.chooser.ChooserUtilities; import pcgen.core.levelability.LevelAbility; import pcgen.core.prereq.PrereqHandler; import pcgen.core.utils.IntegerKey; @@ -788,7 +789,7 @@ final PlayerCharacter aPC, final boolean addIt) { - return PObjectUtilities.modChoices( + return ChooserUtilities.modChoices( this, availableList, selectedList, Modified: Trunk/pcgen/code/src/java/pcgen/core/AbilityUtilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/AbilityUtilities.java 2006-04-23 11:52:39 UTC (rev 885) +++ Trunk/pcgen/code/src/java/pcgen/core/AbilityUtilities.java 2006-04-23 17:03:45 UTC (rev 886) @@ -368,16 +368,16 @@ int retVal) { // how many sub-choices to make - double featCount = (ability.getAssociatedCount() * ability.getCost(aPC)) + aPC.getFeats(); + double featCount = (ability.getAssociatedCount() * ability.getCost(aPC)); - boolean canSetFeats = true; + boolean didntModifyAbility = true; if (singleChoice && (addIt || ability.isMultiples())) { if ("".equals(choice)) { // Allow sub-choices - canSetFeats = !ability.modChoices(aPC, addIt); + didntModifyAbility = !ability.modChoices(aPC, addIt); } else if (addIt) { @@ -423,8 +423,8 @@ } ability.subAddsForLevel(-9, aPC); } - - if (singleChoice && canSetFeats) + + if (singleChoice && didntModifyAbility) { if (!addIt && !ability.isMultiples() && removed) { @@ -450,8 +450,8 @@ featCount -= (listSize * ability.getCost(aPC)); } - - aPC.adjustFeats(featCount - aPC.getFeats()); + + aPC.adjustFeats(featCount); } aPC.setAutomaticFeatsStable(false); @@ -705,7 +705,7 @@ { return result; } - + return finaliseAbility(anAbility, subName, aPC, addIt, singleChoice1, result); } Modified: Trunk/pcgen/code/src/java/pcgen/core/Domain.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Domain.java 2006-04-23 11:52:39 UTC (rev 885) +++ Trunk/pcgen/code/src/java/pcgen/core/Domain.java 2006-04-23 17:03:45 UTC (rev 886) @@ -26,6 +26,7 @@ package pcgen.core; import pcgen.core.character.CharacterSpell; +import pcgen.core.chooser.ChooserUtilities; import pcgen.core.prereq.PrereqHandler; import pcgen.core.spell.Spell; import pcgen.core.utils.MessageType; @@ -181,7 +182,7 @@ !aPC.isImporting() && !choiceString.startsWith("FEAT|")) { - PObjectUtilities.modChoices( + ChooserUtilities.modChoices( this, new ArrayList(), new ArrayList(), Modified: Trunk/pcgen/code/src/java/pcgen/core/PObjectUtilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObjectUtilities.java 2006-04-23 11:52:39 UTC (rev 885) +++ Trunk/pcgen/code/src/java/pcgen/core/PObjectUtilities.java 2006-04-23 17:03:45 UTC (rev 886) @@ -51,6 +51,8 @@ /** * Modify an Ability object for a given PC (or remove an Ability * Object from a given PC) + * @deprecated delete this early in the 5.12 cycle. This is all handled by + * ChooserUtilities.modChoices */ public class PObjectUtilities { Modified: Trunk/pcgen/code/src/java/pcgen/core/chooser/AbstractComplexChoiceManager.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/chooser/AbstractComplexChoiceManager.java 2006-04-23 11:52:39 UTC (rev 885) +++ Trunk/pcgen/code/src/java/pcgen/core/chooser/AbstractComplexChoiceManager.java 2006-04-23 17:03:45 UTC (rev 886) @@ -158,19 +158,17 @@ /** * Remove a choice - * + * @param aPC * @param availableList * @param selectedList - * @param selectedBonusList - * @param aPC */ public void doChooserRemove ( + PlayerCharacter aPC, final List availableList, - final List selectedList, - final List selectedBonusList, - PlayerCharacter aPC) + final List selectedList) { remove = true; + final List newSelections = doChooser ( aPC, availableList, Modified: Trunk/pcgen/code/src/java/pcgen/core/chooser/AbstractSimpleChoiceManager.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/chooser/AbstractSimpleChoiceManager.java 2006-04-23 11:52:39 UTC (rev 885) +++ Trunk/pcgen/code/src/java/pcgen/core/chooser/AbstractSimpleChoiceManager.java 2006-04-23 17:03:45 UTC (rev 886) @@ -166,7 +166,23 @@ * @param selectedBonusList */ + /** + * + * @param aPc + * @param availableList + * @param selectedList + */ + public void doChooserRemove ( + PlayerCharacter aPc, + List availableList, + List selectedList) + { + // Nothing to do here + } + + + /** * * @param aPC * @param selected Modified: Trunk/pcgen/code/src/java/pcgen/core/chooser/ChoiceManagerList.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/chooser/ChoiceManagerList.java 2006-04-23 11:52:39 UTC (rev 885) +++ Trunk/pcgen/code/src/java/pcgen/core/chooser/ChoiceManagerList.java 2006-04-23 17:03:45 UTC (rev 886) @@ -61,6 +61,17 @@ final List availableList, final List selectedList); + /** + * Do chooser for removing a choice + * @param aPc + * @param availableList + * @param selectedList + */ + public abstract void doChooserRemove ( + PlayerCharacter aPc, + final List availableList, + final List selectedList); + /** * Apply the choices to the Pc Modified: Trunk/pcgen/code/src/java/pcgen/core/chooser/ChooserUtilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/chooser/ChooserUtilities.java 2006-04-23 11:52:39 UTC (rev 885) +++ Trunk/pcgen/code/src/java/pcgen/core/chooser/ChooserUtilities.java 2006-04-23 17:03:45 UTC (rev 886) @@ -264,6 +264,53 @@ } /** + * Deal with CHOOSE tag processing + * + * @param aPObject + * @param availableList + * @param selectedList + * @param process + * @param aPC + * @param addIt + * + * @return true if aPObject was modified + */ + public static final boolean modChoices( + final PObject aPObject, + List availableList, + final List selectedList, + final boolean process, + final PlayerCharacter aPC, + final boolean addIt) + { + availableList.clear(); + selectedList.clear(); + + ChoiceManagerList aMan = getChoiceManager(aPObject, "", aPC); + + if (aMan == null) {return false;} + + aMan.getChoices(aPC, availableList, selectedList); + + if (!process) {return false;} + + if (availableList.size() > 0 || selectedList.size() > 0) + { + if (addIt) + { + final List newSelections = aMan.doChooser(aPC, availableList, selectedList); + aMan.applyChoices(aPC, newSelections); + } + else + { + aMan.doChooserRemove(aPC, availableList, selectedList); + } + return true; + } + return false; + } + + /** * Creates a list of choices based on aChoice, or if aChoice is blank, the * choiceString property of aPObject. If process is true, a chooser will be * presented to the user. Otherwise, availableList will be populated. @@ -374,18 +421,22 @@ { constructMap(); } - + final String choiceString; - if(theChoices!= null && theChoices.length() > 0) + if(theChoices != null && theChoices.length() > 0) { choiceString = theChoices; } else { choiceString = aPObject.getChoiceString(); - theChoices = ""; } + if (choiceString == null || choiceString.length() == 0) + { + return null; + } + List mainList = Arrays.asList(choiceString.split("[|]")); /* Find the first element of the array that does not contain an Modified: Trunk/pcgen/code/src/java/pcgen/core/chooser/SpellLevelChoiceManager.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/chooser/SpellLevelChoiceManager.java 2006-04-23 11:52:39 UTC (rev 885) +++ Trunk/pcgen/code/src/java/pcgen/core/chooser/SpellLevelChoiceManager.java 2006-04-23 17:03:45 UTC (rev 886) @@ -26,11 +26,14 @@ import pcgen.core.PObject; import pcgen.core.PlayerCharacter; +import java.awt.Choice; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; +import org.omg.CORBA.portable.Streamable; + /** * This is the chooser that deals with choosing a spell level. */ @@ -56,6 +59,22 @@ title = "Spell Level choice"; chooserHandled = "SPELLLEVEL"; + if (((String) choices.get(0)).equals("SPELLLEVEL") ) + { + try + { + numberOfChoices = new Integer((String) choices.get(1)).intValue(); + } + catch (NumberFormatException e) + { + numberOfChoices = 1; + } + } + else + { + numberOfChoices = 1; + } + /* reconstruct a suitable choiceString to pass to buildSpellTypeChoices. This is * not necessarily the same as the choiceString that was passed in because we may * have removed some | separated elements from the front of it in the constructor Modified: Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbility.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbility.java 2006-04-23 11:52:39 UTC (rev 885) +++ Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbility.java 2006-04-23 17:03:45 UTC (rev 886) @@ -524,8 +524,7 @@ { if (owner instanceof PCClass) { - // is this necessary? - // is initMod even used? + // is this necessary? is initMod even used? ((PCClass) owner).addInitMod( -Integer.parseInt(thisString.substring(5))); } Modified: Trunk/pcgen/code/src/test/pcgen/core/PlayerCharacterTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/PlayerCharacterTest.java 2006-04-23 11:52:39 UTC (rev 885) +++ Trunk/pcgen/code/src/test/pcgen/core/PlayerCharacterTest.java 2006-04-23 17:03:45 UTC (rev 886) @@ -327,7 +327,7 @@ } catch(HeadlessException e) { - Logging.debugPrint("Ignoring Headless excpetion."); + Logging.debugPrint("Ignoring Headless exception."); } } @@ -409,7 +409,7 @@ toughness.setName("Toughness"); toughness.setMultiples("Y"); toughness.setStacks("Y"); - toughness.setChoiceString("foo"); + toughness.setChoiceString("NOCHOICE"); toughness.setCategory("FEAT"); Globals.addAbility(toughness); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |