From: <th...@us...> - 2008-10-22 01:42:42
|
Revision: 8177 http://pcgen.svn.sourceforge.net/pcgen/?rev=8177&view=rev Author: thpr Date: 2008-10-22 01:42:36 +0000 (Wed, 22 Oct 2008) Log Message: ----------- fix ADD:CLASSSKILLS to not present full list Modified Paths: -------------- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java 2008-10-22 01:16:48 UTC (rev 8176) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java 2008-10-22 01:42:36 UTC (rev 8177) @@ -170,7 +170,7 @@ + " had an invalid reference: " + tokText); return false; } - refs.add(allRef); + refs.add(skref); } } Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java 2008-10-22 01:16:48 UTC (rev 8176) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java 2008-10-22 01:42:36 UTC (rev 8177) @@ -169,7 +169,7 @@ + " had an invalid reference: " + tokText); return false; } - refs.add(allRef); + refs.add(skref); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2008-10-30 21:54:28
|
Revision: 8251 http://pcgen.svn.sourceforge.net/pcgen/?rev=8251&view=rev Author: thpr Date: 2008-10-30 21:39:20 +0000 (Thu, 30 Oct 2008) Log Message: ----------- [ 2210198 ] ADD:CLASSSKILLS|1|CROSSCLASSSKILLS broken Issue#: 2210198 Modified Paths: -------------- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java 2008-10-30 21:38:32 UTC (rev 8250) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java 2008-10-30 21:39:20 UTC (rev 8251) @@ -28,7 +28,7 @@ import pcgen.cdom.base.Constants; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.base.TransitionChoice; -import pcgen.cdom.choiceset.ReferenceChoiceSet; +import pcgen.cdom.choiceset.NonClassChoiceSet; import pcgen.cdom.enumeration.ListKey; import pcgen.cdom.enumeration.ObjectKey; import pcgen.cdom.helper.ClassSkillChoiceActor; @@ -174,15 +174,15 @@ } } - ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<Skill>(refs); + NonClassChoiceSet rcs = new NonClassChoiceSet(refs); ChoiceSet<Skill> cs = new ChoiceSet<Skill>(getFullName(), rcs); TransitionChoice<Skill> tc = new TransitionChoice<Skill>(cs, FormulaFactory.getFormulaFor(count)); - context.getObjectContext().addToList(obj, ListKey.ADD, tc); //TODO This is a hack, to get this to work pre-CDOM PCClass parent = (PCClass) obj.get(ObjectKey.PARENT); ClassSkillChoiceActor actor = new ClassSkillChoiceActor(parent, autoRank); tc.setChoiceActor(actor); + context.getObjectContext().addToList(obj, ListKey.ADD, tc); return true; } Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java 2008-10-30 21:38:32 UTC (rev 8250) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java 2008-10-30 21:39:20 UTC (rev 8251) @@ -28,7 +28,7 @@ import pcgen.cdom.base.Constants; import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.base.TransitionChoice; -import pcgen.cdom.choiceset.ReferenceChoiceSet; +import pcgen.cdom.choiceset.NonClassChoiceSet; import pcgen.cdom.enumeration.ListKey; import pcgen.cdom.enumeration.ObjectKey; import pcgen.cdom.helper.ClassSkillChoiceActor; @@ -173,13 +173,13 @@ } } - ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<Skill>(refs); + NonClassChoiceSet rcs = new NonClassChoiceSet(refs); ChoiceSet<Skill> cs = new ChoiceSet<Skill>(getFullName(), rcs); TransitionChoice<Skill> tc = new TransitionChoice<Skill>(cs, FormulaFactory.getFormulaFor(count)); - context.getObjectContext().addToList(obj, ListKey.ADD, tc); ClassSkillChoiceActor actor = new ClassSkillChoiceActor(obj, autoRank); tc.setChoiceActor(actor); + context.getObjectContext().addToList(obj, ListKey.ADD, tc); return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2008-11-09 22:13:56
|
Revision: 8368 http://pcgen.svn.sourceforge.net/pcgen/?rev=8368&view=rev Author: thpr Date: 2008-11-09 22:13:52 +0000 (Sun, 09 Nov 2008) Log Message: ----------- cleanup tokens Modified Paths: -------------- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/SkillToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java 2008-11-09 22:12:35 UTC (rev 8367) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java 2008-11-09 22:13:52 UTC (rev 8368) @@ -74,30 +74,22 @@ return false; } int pipeLoc = value.indexOf(Constants.PIPE); - int count; + Formula count; String items; if (pipeLoc == -1) { - count = 1; + count = Formula.ONE; items = value; } else { String countString = value.substring(0, pipeLoc); - try + count = FormulaFactory.getFormulaFor(countString); + if (count.isStatic() && count.resolve(null, "").doubleValue() <= 0) { - count = Integer.parseInt(countString); - if (count < 1) - { - Logging.errorPrint("Count in " + getFullName() - + " must be > 0"); - return false; - } - } - catch (NumberFormatException nfe) - { - Logging.errorPrint("Invalid Count in " + getFullName() + ": " - + countString); + Logging + .errorPrint("Count in " + getFullName() + + " must be > 0"); return false; } items = value.substring(pipeLoc + 1); @@ -108,6 +100,9 @@ return false; } + boolean foundAny = false; + boolean foundOther = false; + List<CDOMReference<Skill>> refs = new ArrayList<CDOMReference<Skill>>(); StringTokenizer tok = new StringTokenizer(items, Constants.COMMA); CDOMGroupRef<Skill> allRef = context.ref @@ -118,68 +113,84 @@ String tokText = tok.nextToken(); if (Constants.LST_ALL.equals(tokText)) { + foundAny = true; refs.add(allRef); } - else if (Constants.LST_UNTRAINED.equals(tokText)) + else { - ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<Skill, Boolean>( - tokText, SKILL_CLASS, allRef, ObjectKey.USE_UNTRAINED, - Boolean.TRUE); - omr.returnIncludesNulls(true); - refs.add(omr); - } - else if (Constants.LST_TRAINED.equals(tokText)) - { - refs.add(new ObjectMatchingReference<Skill, Boolean>(tokText, - SKILL_CLASS, allRef, ObjectKey.USE_UNTRAINED, - Boolean.FALSE)); - } - else if (Constants.LST_EXCLUSIVE.equals(tokText)) - { - refs - .add(new ObjectMatchingReference<Skill, Boolean>( - tokText, SKILL_CLASS, allRef, - ObjectKey.EXCLUSIVE, Boolean.TRUE)); - } - else if (Constants.LST_NONEXCLUSIVE.equals(tokText) - || Constants.LST_CROSSCLASS.equals(tokText)) - { - ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<Skill, Boolean>( - tokText, SKILL_CLASS, allRef, ObjectKey.EXCLUSIVE, - Boolean.FALSE); - omr.returnIncludesNulls(true); - refs.add(omr); - } - else if (tokText.startsWith("AUTORANK=")) - { - if (autoRank != null) + foundOther = true; + if (Constants.LST_UNTRAINED.equals(tokText)) { - Logging.errorPrint("Cannot have two AUTORANK= items in " - + getFullName() + ": " + value); - return false; + ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<Skill, Boolean>( + tokText, SKILL_CLASS, allRef, + ObjectKey.USE_UNTRAINED, Boolean.TRUE); + omr.returnIncludesNulls(true); + refs.add(omr); } - String rankString = tokText.substring(9); - autoRank = Integer.decode(rankString); - } - else - { - CDOMReference<Skill> skref = TokenUtilities.getTypeOrPrimitive( - context, SKILL_CLASS, tokText); - if (skref == null) + else if (Constants.LST_TRAINED.equals(tokText)) { - Logging.errorPrint(" Error was encountered while parsing " - + getFullName() + ": " + value - + " had an invalid reference: " + tokText); - return false; + refs.add(new ObjectMatchingReference<Skill, Boolean>( + tokText, SKILL_CLASS, allRef, + ObjectKey.USE_UNTRAINED, Boolean.FALSE)); } - refs.add(skref); + else if (Constants.LST_EXCLUSIVE.equals(tokText)) + { + refs.add(new ObjectMatchingReference<Skill, Boolean>( + tokText, SKILL_CLASS, allRef, ObjectKey.EXCLUSIVE, + Boolean.TRUE)); + } + else if (Constants.LST_NONEXCLUSIVE.equals(tokText) + || Constants.LST_CROSSCLASS.equals(tokText)) + { + ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<Skill, Boolean>( + tokText, SKILL_CLASS, allRef, ObjectKey.EXCLUSIVE, + Boolean.FALSE); + omr.returnIncludesNulls(true); + refs.add(omr); + } + else if (tokText.startsWith("AUTORANK=")) + { + if (autoRank != null) + { + Logging + .errorPrint("Cannot have two AUTORANK= items in " + + getFullName() + ": " + value); + return false; + } + String rankString = tokText.substring(9); + autoRank = Integer.decode(rankString); + } + else + { + CDOMReference<Skill> skref = TokenUtilities + .getTypeOrPrimitive(context, SKILL_CLASS, tokText); + if (skref == null) + { + Logging + .errorPrint(" Error was encountered while parsing " + + getFullName() + + ": " + + value + + " had an invalid reference: " + + tokText); + return false; + } + refs.add(skref); + } } } + if (foundAny && foundOther) + { + Logging.errorPrint("Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + value); + return false; + } + ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<Skill>(refs); ChoiceSet<Skill> cs = new ChoiceSet<Skill>(getTokenName(), rcs); PersistentTransitionChoice<Skill> tc = new PersistentTransitionChoice<Skill>( - cs, FormulaFactory.getFormulaFor(count)); + cs, count); // TODO This is a hack, to get this to work pre-CDOM PCClass parent = (PCClass) obj.get(ObjectKey.PARENT); ClassSkillChoiceActor actor = new ClassSkillChoiceActor(parent, @@ -204,7 +215,7 @@ for (TransitionChoice<?> container : addedItems) { ChoiceSet<?> cs = container.getChoices(); - if (getFullName().equals(cs.getName()) + if (getTokenName().equals(cs.getName()) && SKILL_CLASS.equals(cs.getChoiceClass())) { Formula f = container.getCount(); Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java 2008-11-09 22:12:35 UTC (rev 8367) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java 2008-11-09 22:13:52 UTC (rev 8368) @@ -73,30 +73,22 @@ return false; } int pipeLoc = value.indexOf(Constants.PIPE); - int count; + Formula count; String items; if (pipeLoc == -1) { - count = 1; + count = Formula.ONE; items = value; } else { String countString = value.substring(0, pipeLoc); - try + count = FormulaFactory.getFormulaFor(countString); + if (count.isStatic() && count.resolve(null, "").doubleValue() <= 0) { - count = Integer.parseInt(countString); - if (count < 1) - { - Logging.errorPrint("Count in " + getFullName() - + " must be > 0"); - return false; - } - } - catch (NumberFormatException nfe) - { - Logging.errorPrint("Invalid Count in " + getFullName() + ": " - + countString); + Logging + .errorPrint("Count in " + getFullName() + + " must be > 0"); return false; } items = value.substring(pipeLoc + 1); @@ -107,6 +99,9 @@ return false; } + boolean foundAny = false; + boolean foundOther = false; + List<CDOMReference<Skill>> refs = new ArrayList<CDOMReference<Skill>>(); StringTokenizer tok = new StringTokenizer(items, Constants.COMMA); CDOMGroupRef<Skill> allRef = context.ref @@ -117,68 +112,84 @@ String tokText = tok.nextToken(); if (Constants.LST_ALL.equals(tokText)) { + foundAny = true; refs.add(allRef); } - else if (Constants.LST_UNTRAINED.equals(tokText)) + else { - ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<Skill, Boolean>( - tokText, SKILL_CLASS, allRef, ObjectKey.USE_UNTRAINED, - Boolean.TRUE); - omr.returnIncludesNulls(true); - refs.add(omr); - } - else if (Constants.LST_TRAINED.equals(tokText)) - { - refs.add(new ObjectMatchingReference<Skill, Boolean>(tokText, - SKILL_CLASS, allRef, ObjectKey.USE_UNTRAINED, - Boolean.FALSE)); - } - else if (Constants.LST_EXCLUSIVE.equals(tokText)) - { - refs - .add(new ObjectMatchingReference<Skill, Boolean>( - tokText, SKILL_CLASS, allRef, - ObjectKey.EXCLUSIVE, Boolean.TRUE)); - } - else if (Constants.LST_NONEXCLUSIVE.equals(tokText) - || Constants.LST_CROSSCLASS.equals(tokText)) - { - ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<Skill, Boolean>( - tokText, SKILL_CLASS, allRef, ObjectKey.EXCLUSIVE, - Boolean.FALSE); - omr.returnIncludesNulls(true); - refs.add(omr); - } - else if (tokText.startsWith("AUTORANK=")) - { - if (autoRank != null) + foundOther = true; + if (Constants.LST_UNTRAINED.equals(tokText)) { - Logging.errorPrint("Cannot have two AUTORANK= items in " - + getFullName() + ": " + value); - return false; + ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<Skill, Boolean>( + tokText, SKILL_CLASS, allRef, + ObjectKey.USE_UNTRAINED, Boolean.TRUE); + omr.returnIncludesNulls(true); + refs.add(omr); } - String rankString = tokText.substring(9); - autoRank = Integer.decode(rankString); - } - else - { - CDOMReference<Skill> skref = TokenUtilities.getTypeOrPrimitive( - context, SKILL_CLASS, tokText); - if (skref == null) + else if (Constants.LST_TRAINED.equals(tokText)) { - Logging.errorPrint(" Error was encountered while parsing " - + getFullName() + ": " + value - + " had an invalid reference: " + tokText); - return false; + refs.add(new ObjectMatchingReference<Skill, Boolean>( + tokText, SKILL_CLASS, allRef, + ObjectKey.USE_UNTRAINED, Boolean.FALSE)); } - refs.add(skref); + else if (Constants.LST_EXCLUSIVE.equals(tokText)) + { + refs.add(new ObjectMatchingReference<Skill, Boolean>( + tokText, SKILL_CLASS, allRef, ObjectKey.EXCLUSIVE, + Boolean.TRUE)); + } + else if (Constants.LST_NONEXCLUSIVE.equals(tokText) + || Constants.LST_CROSSCLASS.equals(tokText)) + { + ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<Skill, Boolean>( + tokText, SKILL_CLASS, allRef, ObjectKey.EXCLUSIVE, + Boolean.FALSE); + omr.returnIncludesNulls(true); + refs.add(omr); + } + else if (tokText.startsWith("AUTORANK=")) + { + if (autoRank != null) + { + Logging + .errorPrint("Cannot have two AUTORANK= items in " + + getFullName() + ": " + value); + return false; + } + String rankString = tokText.substring(9); + autoRank = Integer.decode(rankString); + } + else + { + CDOMReference<Skill> skref = TokenUtilities + .getTypeOrPrimitive(context, SKILL_CLASS, tokText); + if (skref == null) + { + Logging + .errorPrint(" Error was encountered while parsing " + + getFullName() + + ": " + + value + + " had an invalid reference: " + + tokText); + return false; + } + refs.add(skref); + } } } + if (foundAny && foundOther) + { + Logging.errorPrint("Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + value); + return false; + } + ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<Skill>(refs); ChoiceSet<Skill> cs = new ChoiceSet<Skill>(getTokenName(), rcs); PersistentTransitionChoice<Skill> tc = new PersistentTransitionChoice<Skill>( - cs, FormulaFactory.getFormulaFor(count)); + cs, count); ClassSkillChoiceActor actor = new ClassSkillChoiceActor(obj, autoRank); tc.setChoiceActor(actor); context.getObjectContext().addToList(obj, ListKey.ADD, tc); @@ -200,7 +211,7 @@ for (TransitionChoice<?> container : addedItems) { ChoiceSet<?> cs = container.getChoices(); - if (getFullName().equals(cs.getName()) + if (getTokenName().equals(cs.getName()) && SKILL_CLASS.equals(cs.getChoiceClass())) { Formula f = container.getCount(); Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/SkillToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/SkillToken.java 2008-11-09 22:12:35 UTC (rev 8367) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/SkillToken.java 2008-11-09 22:13:52 UTC (rev 8368) @@ -70,30 +70,22 @@ public boolean parse(LoadContext context, CDOMObject obj, String value) { int pipeLoc = value.indexOf(Constants.PIPE); - int count; + Formula count; String items; if (pipeLoc == -1) { - count = 1; + count = Formula.ONE; items = value; } else { String countString = value.substring(0, pipeLoc); - try + count = FormulaFactory.getFormulaFor(countString); + if (count.isStatic() && count.resolve(null, "").doubleValue() <= 0) { - count = Integer.parseInt(countString); - if (count < 1) - { - Logging.errorPrint("Count in " + getFullName() - + " must be > 0"); - return false; - } - } - catch (NumberFormatException nfe) - { - Logging.errorPrint("Invalid Count in " + getFullName() + ": " - + countString); + Logging + .errorPrint("Count in " + getFullName() + + " must be > 0"); return false; } items = value.substring(pipeLoc + 1); @@ -144,7 +136,7 @@ ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<Skill>(refs); ChoiceSet<Skill> cs = new ChoiceSet<Skill>("SKILL", rcs); PersistentTransitionChoice<Skill> tc = new PersistentTransitionChoice<Skill>( - cs, FormulaFactory.getFormulaFor(count)); + cs, count); context.getObjectContext().addToList(obj, ListKey.ADD, tc); tc.setChoiceActor(this); return true; @@ -165,7 +157,8 @@ for (TransitionChoice<?> container : addedItems) { ChoiceSet<?> cs = container.getChoices(); - if (SKILL_CLASS.equals(cs.getChoiceClass())) + if (getTokenName().equals(cs.getName()) + && SKILL_CLASS.equals(cs.getChoiceClass())) { Formula f = container.getCount(); if (f == null) Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java 2008-11-09 22:12:35 UTC (rev 8367) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java 2008-11-09 22:13:52 UTC (rev 8368) @@ -18,6 +18,7 @@ package plugin.lsttokens.add; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.StringTokenizer; @@ -29,6 +30,7 @@ import pcgen.cdom.base.FormulaFactory; import pcgen.cdom.base.PersistentChoiceActor; import pcgen.cdom.base.PersistentTransitionChoice; +import pcgen.cdom.base.TransitionChoice; import pcgen.cdom.choiceset.AbilityRefChoiceSet; import pcgen.cdom.enumeration.AssociationListKey; import pcgen.cdom.enumeration.ListKey; @@ -42,6 +44,7 @@ import pcgen.core.PlayerCharacter; import pcgen.core.Ability.Nature; import pcgen.persistence.PersistenceLayerException; +import pcgen.rules.context.Changes; import pcgen.rules.context.LoadContext; import pcgen.rules.persistence.TokenUtilities; import pcgen.rules.persistence.token.AbstractToken; @@ -52,6 +55,7 @@ CDOMSecondaryToken<CDOMObject>, PersistentChoiceActor<AbilitySelection> { + private static final Class<AbilitySelection> ABILITY_SELECTION_CLASS = AbilitySelection.class; private static final Class<Ability> ABILITY_CLASS = Ability.class; public boolean parse(PObject target, String value, int level) @@ -139,6 +143,9 @@ boolean allowStack = false; int dupChoices = 0; + boolean foundAny = false; + boolean foundOther = false; + while (tok.hasMoreTokens()) { CDOMReference<Ability> ab; @@ -165,10 +172,12 @@ } else if (Constants.LST_ALL.equals(token)) { + foundAny = true; ab = context.ref.getCDOMAllReference(ABILITY_CLASS, category); } else { + foundOther = true; ab = TokenUtilities.getTypeOrPrimitive(context, ABILITY_CLASS, category, token); } @@ -196,10 +205,17 @@ } } + if (foundAny && foundOther) + { + Logging.errorPrint("Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + value); + return false; + } + AbilityRefChoiceSet rcs = new AbilityRefChoiceSet(refs, nature, allowStack, dupChoices); ChoiceSet<AbilitySelection> cs = new ChoiceSet<AbilitySelection>( - "VFEAT", rcs); + getTokenName(), rcs); PersistentTransitionChoice<AbilitySelection> tc = new PersistentTransitionChoice<AbilitySelection>( cs, count); context.getObjectContext().addToList(obj, ListKey.ADD, tc); @@ -215,8 +231,40 @@ public String[] unparse(LoadContext context, CDOMObject obj) { - // TODO Auto-generated method stub - return null; + Changes<PersistentTransitionChoice<?>> grantChanges = context + .getObjectContext().getListChanges(obj, ListKey.ADD); + Collection<PersistentTransitionChoice<?>> addedItems = grantChanges + .getAdded(); + if (addedItems == null || addedItems.isEmpty()) + { + // Zero indicates no Token + return null; + } + List<String> addStrings = new ArrayList<String>(); + for (TransitionChoice<?> container : addedItems) + { + ChoiceSet<?> cs = container.getChoices(); + if (getTokenName().equals(cs.getName()) + && ABILITY_SELECTION_CLASS.equals(cs.getChoiceClass())) + { + Formula f = container.getCount(); + if (f == null) + { + context.addWriteMessage("Unable to find " + getFullName() + + " Count"); + return null; + } + String fString = f.toString(); + StringBuilder sb = new StringBuilder(); + if (!"1".equals(fString)) + { + sb.append(fString).append(Constants.PIPE); + } + sb.append(cs.getLSTformat()); + addStrings.add(sb.toString()); + } + } + return addStrings.toArray(new String[addStrings.size()]); } public Class<CDOMObject> getTokenClass() @@ -300,9 +348,9 @@ public void restoreChoice(PlayerCharacter pc, CDOMObject owner, AbilitySelection choice) { -// String featName = choice.getAbilityKey(); -// Ability aFeat = pc.getAbilityKeyed(AbilityCategory.FEAT, -// Ability.Nature.VIRTUAL, featName); -// pc.addAssoc(owner, AssociationListKey.ADDED_ABILITY, aFeat); + // String featName = choice.getAbilityKey(); + // Ability aFeat = pc.getAbilityKeyed(AbilityCategory.FEAT, + // Ability.Nature.VIRTUAL, featName); + // pc.addAssoc(owner, AssociationListKey.ADDED_ABILITY, aFeat); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2008-12-05 22:20:27
|
Revision: 8564 http://pcgen.svn.sourceforge.net/pcgen/?rev=8564&view=rev Author: thpr Date: 2008-12-05 21:43:08 +0000 (Fri, 05 Dec 2008) Log Message: ----------- allow ALL or ANY on ADD:CLASSSKILLS Modified Paths: -------------- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java 2008-12-05 21:15:10 UTC (rev 8563) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java 2008-12-05 21:43:08 UTC (rev 8564) @@ -110,7 +110,8 @@ while (tok.hasMoreTokens()) { String tokText = tok.nextToken(); - if (Constants.LST_ALL.equals(tokText)) + if (Constants.LST_ALL.equals(tokText) + || Constants.LST_ANY.equals(tokText)) { foundAny = true; refs.add(allRef); Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java 2008-12-05 21:15:10 UTC (rev 8563) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java 2008-12-05 21:43:08 UTC (rev 8564) @@ -109,7 +109,8 @@ while (tok.hasMoreTokens()) { String tokText = tok.nextToken(); - if (Constants.LST_ALL.equals(tokText)) + if (Constants.LST_ALL.equals(tokText) + || Constants.LST_ANY.equals(tokText)) { foundAny = true; refs.add(allRef); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-08-29 14:29:02
|
Revision: 10324 http://pcgen.svn.sourceforge.net/pcgen/?rev=10324&view=rev Author: thpr Date: 2009-08-29 14:28:53 +0000 (Sat, 29 Aug 2009) Log Message: ----------- unparse/token cleanup (ADD) Modified Paths: -------------- Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/EquipToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/LanguageToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/SkillToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/SpellCasterToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/TemplateToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java 2009-08-29 09:40:36 UTC (rev 10323) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java 2009-08-29 14:28:53 UTC (rev 10324) @@ -337,6 +337,19 @@ + " Count"); return null; } + if (f.isStatic() && f.resolve(null, "").doubleValue() <= 0) + { + context.addWriteMessage("Count in " + getFullName() + + " must be > 0"); + return null; + } + if (!cs.getGroupingState().isValid()) + { + context.addWriteMessage("Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + + cs.getLSTformat()); + return null; + } StringBuilder sb = new StringBuilder(); if (!FormulaFactory.ONE.equals(f)) { Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java 2009-08-29 09:40:36 UTC (rev 10323) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java 2009-08-29 14:28:53 UTC (rev 10324) @@ -240,6 +240,19 @@ + " Count"); return null; } + if (f.isStatic() && f.resolve(null, "").doubleValue() <= 0) + { + context.addWriteMessage("Count in " + getFullName() + + " must be > 0"); + return null; + } + if (!cs.getGroupingState().isValid()) + { + context.addWriteMessage("Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + + cs.getLSTformat()); + return null; + } StringBuilder sb = new StringBuilder(); if (!FormulaFactory.ONE.equals(f)) { Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java 2009-08-29 09:40:36 UTC (rev 10323) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java 2009-08-29 14:28:53 UTC (rev 10324) @@ -236,6 +236,19 @@ + " Count"); return null; } + if (f.isStatic() && f.resolve(null, "").doubleValue() <= 0) + { + context.addWriteMessage("Count in " + getFullName() + + " must be > 0"); + return null; + } + if (!cs.getGroupingState().isValid()) + { + context.addWriteMessage("Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + + cs.getLSTformat()); + return null; + } StringBuilder sb = new StringBuilder(); if (!FormulaFactory.ONE.equals(f)) { Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/EquipToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/EquipToken.java 2009-08-29 09:40:36 UTC (rev 10323) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/EquipToken.java 2009-08-29 14:28:53 UTC (rev 10324) @@ -153,6 +153,12 @@ + " Count"); return null; } + if (f.isStatic() && f.resolve(null, "").doubleValue() <= 0) + { + context.addWriteMessage("Count in " + getFullName() + + " must be > 0"); + return null; + } StringBuilder sb = new StringBuilder(); if (!FormulaFactory.ONE.equals(f)) { Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java 2009-08-29 09:40:36 UTC (rev 10323) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java 2009-08-29 14:28:53 UTC (rev 10324) @@ -250,6 +250,19 @@ + " Count"); return null; } + if (f.isStatic() && f.resolve(null, "").doubleValue() <= 0) + { + context.addWriteMessage("Count in " + getFullName() + + " must be > 0"); + return null; + } + if (!cs.getGroupingState().isValid()) + { + context.addWriteMessage("Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + + cs.getLSTformat()); + return null; + } StringBuilder sb = new StringBuilder(); if (!FormulaFactory.ONE.equals(f)) { Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/LanguageToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/LanguageToken.java 2009-08-29 09:40:36 UTC (rev 10323) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/LanguageToken.java 2009-08-29 14:28:53 UTC (rev 10324) @@ -159,6 +159,19 @@ + " Count"); return null; } + if (f.isStatic() && f.resolve(null, "").doubleValue() <= 0) + { + context.addWriteMessage("Count in " + getFullName() + + " must be > 0"); + return null; + } + if (!cs.getGroupingState().isValid()) + { + context.addWriteMessage("Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + + cs.getLSTformat()); + return null; + } StringBuilder sb = new StringBuilder(); if (!FormulaFactory.ONE.equals(f)) { Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/SkillToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/SkillToken.java 2009-08-29 09:40:36 UTC (rev 10323) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/SkillToken.java 2009-08-29 14:28:53 UTC (rev 10324) @@ -162,6 +162,19 @@ + " Count"); return null; } + if (f.isStatic() && f.resolve(null, "").doubleValue() <= 0) + { + context.addWriteMessage("Count in " + getFullName() + + " must be > 0"); + return null; + } + if (!cs.getGroupingState().isValid()) + { + context.addWriteMessage("Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + + cs.getLSTformat()); + return null; + } StringBuilder sb = new StringBuilder(); if (!FormulaFactory.ONE.equals(f)) { Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/SpellCasterToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/SpellCasterToken.java 2009-08-29 09:40:36 UTC (rev 10323) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/SpellCasterToken.java 2009-08-29 14:28:53 UTC (rev 10324) @@ -191,6 +191,19 @@ + " Count"); return null; } + if (f.isStatic() && f.resolve(null, "").doubleValue() <= 0) + { + context.addWriteMessage("Count in " + getFullName() + + " must be > 0"); + return null; + } + if (!cs.getGroupingState().isValid()) + { + context.addWriteMessage("Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + + cs.getLSTformat()); + return null; + } StringBuilder sb = new StringBuilder(); if (!FormulaFactory.ONE.equals(f)) { Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/TemplateToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/TemplateToken.java 2009-08-29 09:40:36 UTC (rev 10323) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/TemplateToken.java 2009-08-29 14:28:53 UTC (rev 10324) @@ -140,6 +140,12 @@ + " Count"); return null; } + if (f.isStatic() && f.resolve(null, "").doubleValue() <= 0) + { + context.addWriteMessage("Count in " + getFullName() + + " must be > 0"); + return null; + } StringBuilder sb = new StringBuilder(); if (!FormulaFactory.ONE.equals(f)) { Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java 2009-08-29 09:40:36 UTC (rev 10323) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java 2009-08-29 14:28:53 UTC (rev 10324) @@ -252,6 +252,19 @@ + " Count"); return null; } + if (f.isStatic() && f.resolve(null, "").doubleValue() <= 0) + { + context.addWriteMessage("Count in " + getFullName() + + " must be > 0"); + return null; + } + if (!cs.getGroupingState().isValid()) + { + context.addWriteMessage("Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + + cs.getLSTformat()); + return null; + } StringBuilder sb = new StringBuilder(); if (!FormulaFactory.ONE.equals(f)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2014-01-09 21:55:18
|
Revision: 22849 http://sourceforge.net/p/pcgen/code/22849 Author: thpr Date: 2014-01-09 21:55:15 +0000 (Thu, 09 Jan 2014) Log Message: ----------- Fix: ADD:ABILITY, ADD:FEAT, ADD:VFEAT are not symmetric on parent removal Issue#: CODE-2387 Modified Paths: -------------- Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java 2014-01-09 21:52:48 UTC (rev 22848) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java 2014-01-09 21:55:15 UTC (rev 22849) @@ -55,6 +55,8 @@ import pcgen.core.AbilityCategory; import pcgen.core.AbilityUtilities; import pcgen.core.PlayerCharacter; +import pcgen.core.chooser.ChoiceManagerList; +import pcgen.core.chooser.ChooserUtilities; import pcgen.core.utils.ParsingSeparator; import pcgen.rules.context.Changes; import pcgen.rules.context.LoadContext; @@ -454,7 +456,7 @@ } Ability pcAbility = pc.getMatchingAbility(choice.getAbilityCategory(), - choice.getAbility(), Nature.NORMAL); + choice.getAbility(), choice.getNature()); if (pcAbility != null) { @@ -475,13 +477,28 @@ if (!result) { - removed = pc.removeRealAbility(choice.getAbilityCategory(), + if (pcAbility.getSafe(ObjectKey.MULTIPLE_ALLOWED)) + { + ChoiceManagerList cm = ChooserUtilities.getChoiceManager(pcAbility, pc); + remove(cm, pc, pcAbility, choice.getSelection()); + } + if (choice.getNature().equals(Nature.NORMAL)) + { + removed = pc.removeRealAbility(choice.getAbilityCategory(), pcAbility); + } + else + { + pc.removeUserVirtualAbility(choice.getAbilityCategory(), + pcAbility); + removed = true; + } CDOMObjectUtilities.removeAdds(pcAbility, pc); CDOMObjectUtilities.restoreRemovals(pcAbility, pc); } - if (choice.getAbilityCategory() == AbilityCategory.FEAT) + if ((choice.getNature() == Nature.NORMAL) + && (choice.getAbilityCategory() == AbilityCategory.FEAT)) { AbilityUtilities.adjustPool(pcAbility, pc, false, abilityCount, removed); @@ -491,6 +508,13 @@ } } + private static <T> void remove(ChoiceManagerList<T> aMan, PlayerCharacter pc, + CDOMObject obj, String choice) + { + T sel = aMan.decodeChoice(choice); + aMan.removeChoice(pc, obj, sel); + } + @Override public List<CategorizedAbilitySelection> getCurrentlySelected(CDOMObject owner, PlayerCharacter pc) Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java 2014-01-09 21:52:48 UTC (rev 22848) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java 2014-01-09 21:55:15 UTC (rev 22849) @@ -44,6 +44,8 @@ import pcgen.core.AbilityCategory; import pcgen.core.AbilityUtilities; import pcgen.core.PlayerCharacter; +import pcgen.core.chooser.ChoiceManagerList; +import pcgen.core.chooser.ChooserUtilities; import pcgen.core.utils.ParsingSeparator; import pcgen.rules.context.Changes; import pcgen.rules.context.LoadContext; @@ -347,6 +349,11 @@ if (anAbility != null) { + if (anAbility.getSafe(ObjectKey.MULTIPLE_ALLOWED)) + { + ChoiceManagerList cm = ChooserUtilities.getChoiceManager(anAbility, pc); + remove(cm, pc, anAbility, choice.getSelection()); + } pc.removeRealAbility(AbilityCategory.FEAT, anAbility); CDOMObjectUtilities.removeAdds(anAbility, pc); CDOMObjectUtilities.restoreRemovals(anAbility, pc); @@ -354,6 +361,13 @@ } } + private static <T> void remove(ChoiceManagerList<T> aMan, PlayerCharacter pc, + CDOMObject obj, String choice) + { + T sel = aMan.decodeChoice(choice); + aMan.removeChoice(pc, obj, sel); + } + @Override public List<CategorizedAbilitySelection> getCurrentlySelected(CDOMObject owner, PlayerCharacter pc) Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java 2014-01-09 21:52:48 UTC (rev 22848) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java 2014-01-09 21:55:15 UTC (rev 22849) @@ -24,6 +24,7 @@ import pcgen.base.formula.Formula; import pcgen.cdom.base.CDOMObject; +import pcgen.cdom.base.CDOMObjectUtilities; import pcgen.cdom.base.CDOMReference; import pcgen.cdom.base.ChoiceSet; import pcgen.cdom.base.ConcretePersistentTransitionChoice; @@ -45,6 +46,8 @@ import pcgen.core.AbilityCategory; import pcgen.core.AbilityUtilities; import pcgen.core.PlayerCharacter; +import pcgen.core.chooser.ChoiceManagerList; +import pcgen.core.chooser.ChooserUtilities; import pcgen.core.utils.ParsingSeparator; import pcgen.rules.context.Changes; import pcgen.rules.context.LoadContext; @@ -346,6 +349,31 @@ public void removeChoice(PlayerCharacter pc, CDOMObject owner, CategorizedAbilitySelection choice) { + // See if our choice is not auto or virtual + Ability anAbility = pc.getMatchingAbility(AbilityCategory.FEAT, choice + .getAbility(), Nature.VIRTUAL); + + if (anAbility != null) + { + boolean required = false; + if (anAbility.getSafe(ObjectKey.MULTIPLE_ALLOWED)) + { + required = true; + ChoiceManagerList cm = ChooserUtilities.getChoiceManager(anAbility, pc); + if (remove(cm, pc, anAbility, choice.getSelection())) + { + required = false; + } + } + if (!required) + { + CDOMObjectUtilities.removeAdds(anAbility, pc); + CDOMObjectUtilities.restoreRemovals(anAbility, pc); + pc.adjustMoveRates(); + pc.removeUserVirtualAbility(AbilityCategory.FEAT, anAbility); + } + } + //TODO Need to reverse this action: // String featName = choice.getFullAbilityKey(); // final Ability aFeat = AbilityUtilities.addVirtualAbility("FEAT", @@ -353,6 +381,16 @@ // pc, null); } + private static <T> boolean remove(ChoiceManagerList<T> aMan, PlayerCharacter pc, + CDOMObject obj, String choice) + { + T sel = aMan.decodeChoice(choice); + aMan.removeChoice(pc, obj, sel); + List<T> selected = new ArrayList<T>(); + aMan.getChoices(pc, new ArrayList<T>(), selected); + return selected.isEmpty(); + } + @Override public List<CategorizedAbilitySelection> getCurrentlySelected(CDOMObject owner, PlayerCharacter pc) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-01-10 02:45:42
|
Revision: 8955 http://pcgen.svn.sourceforge.net/pcgen/?rev=8955&view=rev Author: thpr Date: 2009-01-10 02:45:38 +0000 (Sat, 10 Jan 2009) Log Message: ----------- [ 2484692 ] ADD:ABILITY - not respecting PRExxx in choices Issue#: 2484692 Modified Paths: -------------- Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java 2009-01-10 02:36:59 UTC (rev 8954) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java 2009-01-10 02:45:38 UTC (rev 8955) @@ -57,6 +57,7 @@ import pcgen.rules.persistence.token.AbstractToken; import pcgen.rules.persistence.token.CDOMSecondaryToken; import pcgen.util.Logging; +import pcgen.util.enumeration.Visibility; /** * <code>AbilityToken</code> parses ADD:ABILITY entries. @@ -382,13 +383,16 @@ public boolean allow(AbilitySelection choice, PlayerCharacter pc, boolean allowStack) { + boolean isVirtual = Ability.Nature.VIRTUAL.equals(choice.getNature()); // Remove any already selected for (Ability a : pc.getAllAbilities()) { if (a.getKeyName().equals(choice.getAbilityKey())) { - Boolean multYes = a.getSafe(ObjectKey.MULTIPLE_ALLOWED); - if (!multYes || !allowStack(a, allowStack) + if (!pc.canSelectAbility(a, isVirtual) + || !a.getSafe(ObjectKey.VISIBILITY).equals( + Visibility.DEFAULT) + || !allowStack(a, allowStack) && hasAssoc(pc.getAssociationList(a), choice)) { return false; Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java 2009-01-10 02:36:59 UTC (rev 8954) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java 2009-01-10 02:45:38 UTC (rev 8955) @@ -48,6 +48,7 @@ import pcgen.rules.persistence.token.AbstractToken; import pcgen.rules.persistence.token.CDOMSecondaryToken; import pcgen.util.Logging; +import pcgen.util.enumeration.Visibility; public class FeatToken extends AbstractToken implements CDOMSecondaryToken<CDOMObject>, PersistentChoiceActor<AbilitySelection> @@ -303,8 +304,10 @@ { if (a.getKeyName().equals(choice.getAbilityKey())) { - Boolean multYes = a.getSafe(ObjectKey.MULTIPLE_ALLOWED); - if (!multYes || !allowStack(a, allowStack) + if (!pc.canSelectAbility(a, false) + || !a.getSafe(ObjectKey.VISIBILITY).equals( + Visibility.DEFAULT) + || !allowStack(a, allowStack) && hasAssoc(pc.getAssociationList(a), choice)) { return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-07-18 01:44:57
|
Revision: 10130 http://pcgen.svn.sourceforge.net/pcgen/?rev=10130&view=rev Author: thpr Date: 2009-07-18 01:44:53 +0000 (Sat, 18 Jul 2009) Log Message: ----------- Leverage GroupingState in ADD Tokens Modified Paths: -------------- Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/LanguageToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/SkillToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java 2009-07-18 01:38:13 UTC (rev 10129) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java 2009-07-18 01:44:53 UTC (rev 10130) @@ -190,9 +190,6 @@ boolean allowStack = false; int dupChoices = 0; - boolean foundAny = false; - boolean foundOther = false; - ReferenceManufacturer<Ability, ?> rm = context.ref.getManufacturer( ABILITY_CLASS, category); @@ -244,13 +241,11 @@ { if (Constants.LST_ALL.equals(token)) { - foundAny = true; ab = context.ref.getCDOMAllReference(ABILITY_CLASS, category); } else { - foundOther = true; ab = TokenUtilities.getTypeOrPrimitive(rm, token); } } @@ -278,12 +273,6 @@ } } - if (foundAny && foundOther) - { - Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() - + ": Contains ANY and a specific reference: " + value); - return false; - } if (refs.isEmpty()) { Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() @@ -293,6 +282,12 @@ AbilityRefChoiceSet rcs = new AbilityRefChoiceSet(category, refs, nature); + if (!rcs.getGroupingState().isValid()) + { + Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + value); + return false; + } AbilityChoiceSet cs = new AbilityChoiceSet(getTokenName(), rcs); StringBuilder title = new StringBuilder(); if (!Ability.Nature.NORMAL.equals(nature)) Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java 2009-07-18 01:38:13 UTC (rev 10129) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsLevelToken.java 2009-07-18 01:44:53 UTC (rev 10130) @@ -99,9 +99,6 @@ return false; } - boolean foundAny = false; - boolean foundOther = false; - List<CDOMReference<Skill>> refs = new ArrayList<CDOMReference<Skill>>(); StringTokenizer tok = new StringTokenizer(items, Constants.COMMA); CDOMGroupRef<Skill> allRef = context.ref @@ -113,12 +110,10 @@ if (Constants.LST_ALL.equals(tokText) || Constants.LST_ANY.equals(tokText)) { - foundAny = true; refs.add(allRef); } else { - foundOther = true; if (Constants.LST_UNTRAINED.equals(tokText)) { ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<Skill, Boolean>( @@ -194,12 +189,6 @@ } } - if (foundAny && foundOther) - { - Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() - + ": Contains ANY and a specific reference: " + value); - return false; - } if (refs.isEmpty()) { Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() @@ -208,6 +197,12 @@ } ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<Skill>(refs); + if (!rcs.getGroupingState().isValid()) + { + Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + value); + return false; + } ChoiceSet<Skill> cs = new ChoiceSet<Skill>(getTokenName(), rcs, true); PersistentTransitionChoice<Skill> tc = new PersistentTransitionChoice<Skill>( cs, count); Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java 2009-07-18 01:38:13 UTC (rev 10129) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/ClassSkillsToken.java 2009-07-18 01:44:53 UTC (rev 10130) @@ -98,9 +98,6 @@ return false; } - boolean foundAny = false; - boolean foundOther = false; - List<CDOMReference<Skill>> refs = new ArrayList<CDOMReference<Skill>>(); StringTokenizer tok = new StringTokenizer(items, Constants.COMMA); CDOMGroupRef<Skill> allRef = context.ref @@ -112,12 +109,10 @@ if (Constants.LST_ALL.equals(tokText) || Constants.LST_ANY.equals(tokText)) { - foundAny = true; refs.add(allRef); } else { - foundOther = true; if (Constants.LST_UNTRAINED.equals(tokText)) { ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<Skill, Boolean>( @@ -193,12 +188,6 @@ } } - if (foundAny && foundOther) - { - Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() - + ": Contains ANY and a specific reference: " + value); - return false; - } if (refs.isEmpty()) { Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() @@ -207,6 +196,12 @@ } ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<Skill>(refs); + if (!rcs.getGroupingState().isValid()) + { + Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + value); + return false; + } ChoiceSet<Skill> cs = new ChoiceSet<Skill>(getTokenName(), rcs, true); PersistentTransitionChoice<Skill> tc = new PersistentTransitionChoice<Skill>( cs, count); Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java 2009-07-18 01:38:13 UTC (rev 10129) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java 2009-07-18 01:44:53 UTC (rev 10130) @@ -117,9 +117,6 @@ boolean allowStack = false; int dupChoices = 0; - boolean foundAny = false; - boolean foundOther = false; - ReferenceManufacturer<Ability, ?> rm = context.ref.getManufacturer( ABILITY_CLASS, AbilityCategory.FEAT); @@ -169,12 +166,10 @@ } else if (Constants.LST_ALL.equals(token)) { - foundAny = true; ab = context.ref.getCDOMAllReference(ABILITY_CLASS, category); } else { - foundOther = true; ab = TokenUtilities.getTypeOrPrimitive(rm, token); } if (ab == null) @@ -201,12 +196,6 @@ } } - if (foundAny && foundOther) - { - Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() - + ": Contains ANY and a specific reference: " + value); - return false; - } if (refs.isEmpty()) { Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() @@ -215,6 +204,12 @@ } AbilityRefChoiceSet rcs = new AbilityRefChoiceSet(category, refs, nature); + if (!rcs.getGroupingState().isValid()) + { + Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + value); + return false; + } ChoiceSet<AbilitySelection> cs = new ChoiceSet<AbilitySelection>( getTokenName(), rcs); cs.setTitle("Feat Choice"); Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/LanguageToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/LanguageToken.java 2009-07-18 01:38:13 UTC (rev 10129) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/LanguageToken.java 2009-07-18 01:44:53 UTC (rev 10130) @@ -101,20 +101,16 @@ List<CDOMReference<Language>> refs = new ArrayList<CDOMReference<Language>>(); StringTokenizer tok = new StringTokenizer(items, Constants.COMMA); - boolean foundAny = false; - boolean foundOther = false; while (tok.hasMoreTokens()) { String tokText = tok.nextToken(); CDOMReference<Language> lang; if (Constants.LST_ALL.equals(tokText)) { - foundAny = true; lang = context.ref.getCDOMAllReference(LANGUAGE_CLASS); } else { - foundOther = true; lang = TokenUtilities.getTypeOrPrimitive(context, LANGUAGE_CLASS, tokText); } @@ -127,15 +123,16 @@ } refs.add(lang); } - if (foundAny && foundOther) + + ReferenceChoiceSet<Language> rcs = new ReferenceChoiceSet<Language>( + refs); + if (!rcs.getGroupingState().isValid()) { Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() + ": Contains ANY and a specific reference: " + value); return false; } - ReferenceChoiceSet<Language> rcs = - new ReferenceChoiceSet<Language>(refs); ChoiceSet<Language> cs = new ChoiceSet<Language>(getTokenName(), rcs); cs.setTitle("Language Choice"); PersistentTransitionChoice<Language> tc = Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/SkillToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/SkillToken.java 2009-07-18 01:38:13 UTC (rev 10129) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/SkillToken.java 2009-07-18 01:44:53 UTC (rev 10130) @@ -97,9 +97,6 @@ } StringTokenizer tok = new StringTokenizer(items, Constants.COMMA); - boolean foundAny = false; - boolean foundOther = false; - List<CDOMReference<Skill>> refs = new ArrayList<CDOMReference<Skill>>(); while (tok.hasMoreTokens()) { @@ -107,12 +104,10 @@ CDOMReference<Skill> ref; if (Constants.LST_ANY.equalsIgnoreCase(token)) { - foundAny = true; ref = context.ref.getCDOMAllReference(SKILL_CLASS); } else { - foundOther = true; ref = TokenUtilities.getTypeOrPrimitive(context, SKILL_CLASS, token); if (ref == null) @@ -126,14 +121,14 @@ refs.add(ref); } - if (foundAny && foundOther) + ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<Skill>(refs); + if (!rcs.getGroupingState().isValid()) { Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() + ": Contains ANY and a specific reference: " + value); return false; } - ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<Skill>(refs); ChoiceSet<Skill> cs = new ChoiceSet<Skill>("SKILL", rcs, true); PersistentTransitionChoice<Skill> tc = new PersistentTransitionChoice<Skill>( cs, count); Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java 2009-07-18 01:38:13 UTC (rev 10129) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/VFeatToken.java 2009-07-18 01:44:53 UTC (rev 10130) @@ -118,9 +118,6 @@ boolean allowStack = false; int dupChoices = 0; - boolean foundAny = false; - boolean foundOther = false; - ReferenceManufacturer<Ability, ?> rm = context.ref.getManufacturer( ABILITY_CLASS, AbilityCategory.FEAT); @@ -170,12 +167,10 @@ } else if (Constants.LST_ALL.equals(token)) { - foundAny = true; ab = context.ref.getCDOMAllReference(ABILITY_CLASS, category); } else { - foundOther = true; ab = TokenUtilities.getTypeOrPrimitive(rm, token); } if (ab == null) @@ -202,12 +197,6 @@ } } - if (foundAny && foundOther) - { - Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() - + ": Contains ANY and a specific reference: " + value); - return false; - } if (refs.isEmpty()) { Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() @@ -217,6 +206,12 @@ AbilityRefChoiceSet rcs = new AbilityRefChoiceSet(category, refs, nature); + if (!rcs.getGroupingState().isValid()) + { + Logging.log(Logging.LST_ERROR, "Non-sensical " + getFullName() + + ": Contains ANY and a specific reference: " + value); + return false; + } ChoiceSet<AbilitySelection> cs = new ChoiceSet<AbilitySelection>( getTokenName(), rcs); cs.setTitle("Virtual Feat Selection"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2012-10-08 00:07:02
|
Revision: 17673 http://pcgen.svn.sourceforge.net/pcgen/?rev=17673&view=rev Author: jdempsey Date: 2012-10-08 00:06:56 +0000 (Mon, 08 Oct 2012) Log Message: ----------- Fix bug: ADD:FEAT not respecting PRExxx tags present in Feat Issue#: CODE-1730 Modified Paths: -------------- Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java 2012-10-07 23:47:01 UTC (rev 17672) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/AbilityToken.java 2012-10-08 00:06:56 UTC (rev 17673) @@ -423,7 +423,7 @@ } } } - return true; + return pc.canSelectAbility(choice.getAbility(), isVirtual); } private boolean hasAssoc(List<String> associationList, Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java 2012-10-07 23:47:01 UTC (rev 17672) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/add/FeatToken.java 2012-10-08 00:06:56 UTC (rev 17673) @@ -315,7 +315,7 @@ } } } - return true; + return pc.canSelectAbility(choice.getAbility(), false); } private boolean hasAssoc(List<String> associationList, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |