|
From: <nu...@us...> - 2006-04-11 22:37:45
|
Revision: 758 Author: nuance Date: 2006-04-11 15:37:30 -0700 (Tue, 11 Apr 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=758&view=rev Log Message: ----------- Consolidate a lot of stuff to do with modchoices. Make the Ability method take it's parameters in the same order as the PObjectUtilties method. Consolidate most of the Ability variants so they call other Ability methods which redirect to the PObjectUtilities method instead of calling it directly. Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/core/Ability.java Trunk/pcgen/code/src/java/pcgen/core/PObjectUtilities.java Trunk/pcgen/code/src/java/pcgen/core/chooser/FeatAddChoiceManager.java Trunk/pcgen/code/src/java/pcgen/core/chooser/FeatSelectChoiceManager.java Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbilityAbility.java Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbilityFeat.java Trunk/pcgen/code/src/java/plugin/pretokens/test/PreFeatTester.java Modified: Trunk/pcgen/code/src/java/pcgen/core/Ability.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Ability.java 2006-04-11 21:58:55 UTC (rev 757) +++ Trunk/pcgen/code/src/java/pcgen/core/Ability.java 2006-04-11 22:37:30 UTC (rev 758) @@ -742,27 +742,22 @@ } /** - * Opens a Chooser to allow sub-choices for this ability. The actual items - * allowed to choose from are based on choiceString, as applied to current - * character. Choices already made (getAssociatedList) are indicated in the - * selectedList + * Deal with CHOOSE tags. The actual items the choice will be made from are + * based on this.choiceString, as applied to current character. Choices already + * made (getAssociatedList) are indicated in the selectedList. This method + * always processes the choices. * * @param aPC The Player Character that we're opening the chooser for. - * @param addIt gets passed on to the PObjectUtilities, has something to - * do with whether or not we're adding an ability. + * @param addIt Whether to add or remove a choice from this Ability. * - * @return opens a Chooser to allow sub-choices for this ability. The - * actual items allowed to choose from are based on choiceString, - * as applied to current character. Choices already made - * (getAssociatedList) are indicated in the selectedList + * @return true if the Ability was modified, false otherwise */ public boolean modChoices(final PlayerCharacter aPC, final boolean addIt) { final List availableList = new ArrayList(); // available list of choices final List selectedList = new ArrayList(); // selected list of choices - return PObjectUtilities.modChoices( - this, + return modChoices( availableList, selectedList, true, @@ -771,20 +766,27 @@ } /** + * Deal with CHOOSE tags. The actual items the choice will be made from are + * based on this.choiceString, as applied to current character. Choices already + * made (getAssociatedList) are indicated in the selectedList. This method + * may also be used to build a list of choices available and choices + * already made by passing false in the process parameter * - * @param aPC - * @param addIt * @param availableList * @param selectedList * @param process - * @return modified choices + * @param aPC + * @param addIt + * + * @return true if we processed the list of choices, false if we used the routine to + * build the list of choices without processing them. */ public boolean modChoices( - final PlayerCharacter aPC, - final boolean addIt, final List availableList, final List selectedList, - final boolean process) + final boolean process, + final PlayerCharacter aPC, + final boolean addIt) { return PObjectUtilities.modChoices( this, @@ -999,13 +1001,13 @@ return false; } - PObjectUtilities.modChoices( - anAbility, - abilityList, - selectedList, - false, - aPC, - true); + // build a list of available choices and choices already made. + anAbility.modChoices( + abilityList, + selectedList, + false, + aPC, + true); final int currentSelections = selectedList.size(); Modified: Trunk/pcgen/code/src/java/pcgen/core/PObjectUtilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObjectUtilities.java 2006-04-11 21:58:55 UTC (rev 757) +++ Trunk/pcgen/code/src/java/pcgen/core/PObjectUtilities.java 2006-04-11 22:37:30 UTC (rev 758) @@ -111,6 +111,17 @@ return aList.indexOf(selectedValue); } + /** + * Deal with CHOOSE tag processing + * + * @param obj + * @param availableList + * @param selectedList + * @param process + * @param aPC + * @param addIt + * @return + */ public static final boolean modChoices( final PObject obj, List availableList, @@ -1105,7 +1116,7 @@ final List aavailableList = new ArrayList(); // available list of choices final List sselectedList = new ArrayList(); // selected list of choices - anAbility.modChoices(aPC, true, availableList, selectedList, false); + anAbility.modChoices(aavailableList, sselectedList, false, aPC, true); // // Remove any that don't match @@ -1339,7 +1350,7 @@ final List xavailableList = new ArrayList(); // available list of choices final List xselectedList = new ArrayList(); // selected list of choices - theAbility.modChoices(aPC, true, xavailableList, xselectedList, false); + theAbility.modChoices(xavailableList, xselectedList, false, aPC, true); // // Remove any that don't match Modified: Trunk/pcgen/code/src/java/pcgen/core/chooser/FeatAddChoiceManager.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/chooser/FeatAddChoiceManager.java 2006-04-11 21:58:55 UTC (rev 757) +++ Trunk/pcgen/code/src/java/pcgen/core/chooser/FeatAddChoiceManager.java 2006-04-11 22:37:30 UTC (rev 758) @@ -25,7 +25,6 @@ import pcgen.core.Ability; import pcgen.core.AbilityUtilities; -import pcgen.core.Domain; import pcgen.core.Globals; import pcgen.core.PObject; import pcgen.core.PlayerCharacter; @@ -164,7 +163,7 @@ final List aavailableList = new ArrayList(); // available list of choices final List sselectedList = new ArrayList(); // selected list of choices - anAbility.modChoices(aPc, true, aavailableList, sselectedList, false); + anAbility.modChoices(aavailableList, sselectedList, false, aPc, true); // // Remove any that don't match Modified: Trunk/pcgen/code/src/java/pcgen/core/chooser/FeatSelectChoiceManager.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/chooser/FeatSelectChoiceManager.java 2006-04-11 21:58:55 UTC (rev 757) +++ Trunk/pcgen/code/src/java/pcgen/core/chooser/FeatSelectChoiceManager.java 2006-04-11 22:37:30 UTC (rev 758) @@ -150,7 +150,7 @@ final List xavailableList = new ArrayList(); // available list of choices final List xselectedList = new ArrayList(); // selected list of choices - theAbility.modChoices(aPc, true, xavailableList, xselectedList, false); + theAbility.modChoices(xavailableList, xselectedList, false, aPc, true); // // Remove any that don't match Modified: Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbilityAbility.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbilityAbility.java 2006-04-11 21:58:55 UTC (rev 757) +++ Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbilityAbility.java 2006-04-11 22:37:30 UTC (rev 758) @@ -356,11 +356,11 @@ (choiceString.indexOf("COUNT=") < 0)) { anAbility.modChoices( - aPC, - true, availableList, selectedList, - false); + false, + aPC, + true); } else { Modified: Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbilityFeat.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbilityFeat.java 2006-04-11 21:58:55 UTC (rev 757) +++ Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbilityFeat.java 2006-04-11 22:37:30 UTC (rev 758) @@ -590,11 +590,11 @@ (choiceString.indexOf("COUNT=") < 0)) { anAbility.modChoices( - aPC, - true, availableList, selectedList, - false); + false, + aPC, + true); } else { Modified: Trunk/pcgen/code/src/java/plugin/pretokens/test/PreFeatTester.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/pretokens/test/PreFeatTester.java 2006-04-11 21:58:55 UTC (rev 757) +++ Trunk/pcgen/code/src/java/plugin/pretokens/test/PreFeatTester.java 2006-04-11 22:37:30 UTC (rev 758) @@ -90,7 +90,8 @@ final List availableList = new ArrayList(); final List selectedList = new ArrayList(); final String aChoiceString = aFeat.getChoiceString(); - PObjectUtilities.modChoices(aFeat, availableList, selectedList, false, character, true); + + aFeat.modChoices(availableList, selectedList, false, character, true); availableList.clear(); if (subKeyIsType) // TYPE syntax This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |