|
From: <th...@us...> - 2008-12-31 05:25:11
|
Revision: 8751
http://pcgen.svn.sourceforge.net/pcgen/?rev=8751&view=rev
Author: thpr
Date: 2008-12-31 05:25:07 +0000 (Wed, 31 Dec 2008)
Log Message:
-----------
fix & initial test for SPELLLEVEL
Modified Paths:
--------------
Trunk/pcgen/code/src/java/plugin/lsttokens/SpelllevelLst.java
Added Paths:
-----------
Trunk/pcgen/code/src/utest/plugin/lsttokens/SpellLevelLstTest.java
Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/SpelllevelLst.java
===================================================================
--- Trunk/pcgen/code/src/java/plugin/lsttokens/SpelllevelLst.java 2008-12-31 05:17:44 UTC (rev 8750)
+++ Trunk/pcgen/code/src/java/plugin/lsttokens/SpelllevelLst.java 2008-12-31 05:25:07 UTC (rev 8751)
@@ -225,7 +225,7 @@
Collection<CDOMReference<? extends CDOMList<? extends PrereqObject>>> changedDomainLists = context
.getListContext().getChangedLists(obj, DomainSpellList.class);
- TripleKeyMapToList<String, Integer, CDOMReference<? extends CDOMList<? extends PrereqObject>>, Spell> domainMap = getMap(
+ TripleKeyMapToList<String, Integer, CDOMReference<? extends CDOMList<? extends PrereqObject>>, CDOMReference<Spell>> domainMap = getMap(
context, obj, changedDomainLists);
for (String prereqs : domainMap.getKeySet())
{
@@ -234,7 +234,7 @@
Collection<CDOMReference<? extends CDOMList<? extends PrereqObject>>> changedClassLists = context
.getListContext().getChangedLists(obj, ClassSpellList.class);
- TripleKeyMapToList<String, Integer, CDOMReference<? extends CDOMList<? extends PrereqObject>>, Spell> classMap = getMap(
+ TripleKeyMapToList<String, Integer, CDOMReference<? extends CDOMList<? extends PrereqObject>>, CDOMReference<Spell>> classMap = getMap(
context, obj, changedClassLists);
for (String prereqs : classMap.getKeySet())
{
@@ -250,7 +250,7 @@
private StringBuilder processUnparse(
String type,
- TripleKeyMapToList<String, Integer, CDOMReference<? extends CDOMList<? extends PrereqObject>>, Spell> domainMap,
+ TripleKeyMapToList<String, Integer, CDOMReference<? extends CDOMList<? extends PrereqObject>>, CDOMReference<Spell>> domainMap,
String prereqs)
{
StringBuilder sb = new StringBuilder(type);
@@ -265,9 +265,9 @@
sb.append(Constants.EQUALS);
sb.append(level);
sb.append(Constants.PIPE);
- List<Spell> refs = domainMap.getListFor(prereqs, level, list);
+ List<CDOMReference<Spell>> refs = domainMap.getListFor(prereqs, level, list);
boolean first = true;
- for (Spell lw : refs)
+ for (CDOMReference<Spell> lw : refs)
{
if (!first)
{
@@ -290,12 +290,12 @@
return sb;
}
- private TripleKeyMapToList<String, Integer, CDOMReference<? extends CDOMList<? extends PrereqObject>>, Spell> getMap(
+ private TripleKeyMapToList<String, Integer, CDOMReference<? extends CDOMList<? extends PrereqObject>>, CDOMReference<Spell>> getMap(
LoadContext context,
CDOMObject obj,
Collection<CDOMReference<? extends CDOMList<? extends PrereqObject>>> changedLists)
{
- TripleKeyMapToList<String, Integer, CDOMReference<? extends CDOMList<? extends PrereqObject>>, Spell> map = new TripleKeyMapToList<String, Integer, CDOMReference<? extends CDOMList<? extends PrereqObject>>, Spell>();
+ TripleKeyMapToList<String, Integer, CDOMReference<? extends CDOMList<? extends PrereqObject>>, CDOMReference<Spell>> map = new TripleKeyMapToList<String, Integer, CDOMReference<? extends CDOMList<? extends PrereqObject>>, CDOMReference<Spell>>();
for (CDOMReference listRef : changedLists)
{
@@ -309,7 +309,7 @@
+ " does not support .CLEAR");
return null;
}
- MapToList<Spell, AssociatedPrereqObject> mtl = changes
+ MapToList<CDOMReference<Spell>, AssociatedPrereqObject> mtl = changes
.getAddedAssociations();
if (mtl == null || mtl.isEmpty())
{
@@ -317,7 +317,8 @@
// TODO Error message - unexpected?
return null;
}
- for (Spell added : mtl.getKeySet())
+ System.err.println(mtl.getKeySet());
+ for (CDOMReference<Spell> added : mtl.getKeySet())
{
for (AssociatedPrereqObject assoc : mtl.getListFor(added))
{
Added: Trunk/pcgen/code/src/utest/plugin/lsttokens/SpellLevelLstTest.java
===================================================================
--- Trunk/pcgen/code/src/utest/plugin/lsttokens/SpellLevelLstTest.java (rev 0)
+++ Trunk/pcgen/code/src/utest/plugin/lsttokens/SpellLevelLstTest.java 2008-12-31 05:25:07 UTC (rev 8751)
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2007 Tom Parker <th...@us...>
+ *
+ * This program 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 program 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package plugin.lsttokens;
+
+import java.net.URISyntaxException;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import pcgen.cdom.base.CDOMObject;
+import pcgen.cdom.list.ClassSpellList;
+import pcgen.core.PCTemplate;
+import pcgen.core.spell.Spell;
+import pcgen.persistence.PersistenceLayerException;
+import pcgen.rules.persistence.CDOMLoader;
+import pcgen.rules.persistence.token.CDOMPrimaryToken;
+import plugin.lsttokens.testsupport.AbstractGlobalTokenTestCase;
+import plugin.lsttokens.testsupport.CDOMTokenLoader;
+import plugin.lsttokens.testsupport.TokenRegistration;
+import plugin.pretokens.parser.PreClassParser;
+import plugin.pretokens.parser.PreRaceParser;
+import plugin.pretokens.writer.PreClassWriter;
+import plugin.pretokens.writer.PreRaceWriter;
+
+public class SpellLevelLstTest extends AbstractGlobalTokenTestCase
+{
+ static CDOMPrimaryToken<CDOMObject> token = new SpelllevelLst();
+ static CDOMTokenLoader<PCTemplate> loader = new CDOMTokenLoader<PCTemplate>(
+ PCTemplate.class);
+
+ @Override
+ public CDOMLoader<PCTemplate> getLoader()
+ {
+ return loader;
+ }
+
+ @Override
+ public Class<PCTemplate> getCDOMClass()
+ {
+ return PCTemplate.class;
+ }
+
+ @Override
+ public CDOMPrimaryToken<CDOMObject> getToken()
+ {
+ return token;
+ }
+
+ PreClassParser preclass = new PreClassParser();
+ PreClassWriter preclasswriter = new PreClassWriter();
+ PreRaceParser prerace = new PreRaceParser();
+ PreRaceWriter preracewriter = new PreRaceWriter();
+
+ @Override
+ @Before
+ public void setUp() throws PersistenceLayerException, URISyntaxException
+ {
+ super.setUp();
+ TokenRegistration.register(preclass);
+ TokenRegistration.register(prerace);
+ TokenRegistration.register(preclasswriter);
+ TokenRegistration.register(preracewriter);
+ }
+
+ @Test
+ public void testRoundRobinSingleSpell() throws PersistenceLayerException
+ {
+ primaryContext.ref.constructCDOMObject(Spell.class, "Bless");
+ secondaryContext.ref.constructCDOMObject(Spell.class, "Bless");
+ primaryContext.ref.constructCDOMObject(ClassSpellList.class, "Wizard");
+ secondaryContext.ref.constructCDOMObject(ClassSpellList.class, "Wizard");
+ runRoundRobin("CLASS|Wizard=3|Bless");
+ }
+
+ // @Test
+ // public void testInvalidDoublePipe() throws PersistenceLayerException
+ // {
+ // assertFalse(parse("CLASS||Cleric=1|Fireball"));
+ // assertNoSideEffects();
+ // }
+ //
+ // @Test
+ // public void testInvalidEndingPipe() throws PersistenceLayerException
+ // {
+ // assertFalse(parse("SA Number|"));
+ // assertNoSideEffects();
+ // }
+ //
+ // @Test
+ // public void testInvalidStartingPipe() throws PersistenceLayerException
+ // {
+ // assertFalse(parse("|Var"));
+ // assertNoSideEffects();
+ // }
+ //
+ // @Test
+ // public void testInvalidVarAfterPre() throws PersistenceLayerException
+ // {
+ // assertFalse(parse("SA % plus %|Var|PRECLASS:1,Fighter|Var2"));
+ // assertNoSideEffects();
+ // }
+ //
+ // @Test
+ // public void testInvalidOnlyPre() throws PersistenceLayerException
+ // {
+ // assertFalse(parse("PRECLASS:1,Fighter"));
+ // assertNoSideEffects();
+ // }
+ //
+ // @Test
+ // public void testRoundRobinBase() throws PersistenceLayerException
+ // {
+ // runRoundRobin("SA Number One");
+ // }
+ //
+ // @Test
+ // public void testRoundRobinVariable() throws PersistenceLayerException
+ // {
+ // runRoundRobin("SA Number %|Variab");
+ // }
+ //
+ // @Test
+ // public void testRoundRobinPre() throws PersistenceLayerException
+ // {
+ // runRoundRobin("SA Number One|PRECLASS:1,Fighter=1");
+ // }
+ //
+ // @Test
+ // public void testRoundRobinDoublePre() throws PersistenceLayerException
+ // {
+ // runRoundRobin("SA Number One|PRECLASS:1,Fighter=1|PRERACE:1,Human");
+ // }
+ //
+ // @Test
+ // public void testRoundRobinVarDoublePre() throws PersistenceLayerException
+ // {
+ // runRoundRobin("SA Number % before
+ // %|Var|TwoVar|PRECLASS:1,Fighter=1|PRERACE:1,Human");
+ // }
+ //
+ // @Test
+ // public void testRoundRobinCompound() throws PersistenceLayerException
+ // {
+ // runRoundRobin(
+ // "SA Number % before %|Var|TwoVar|PRECLASS:1,Fighter=1|PRERACE:1,Human",
+ // "SA Number One|PRECLASS:1,Fighter=1");
+ // }
+ //
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|