Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: <soulcatcher@us...> - 2006-02-28 21:36:17
|
Revision: 28 Author: soulcatcher Date: 2006-02-28 13:36:12 -0800 (Tue, 28 Feb 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=28&view=rev Log Message: ----------- removing the dev bat files since they are no longer pertinent Removed Paths: ------------- Trunk/pcgen/code/pcgendev.bat Trunk/pcgen/code/pcgendev.sh Trunk/pcgen/code/pcgendevw.bat Deleted: Trunk/pcgen/code/pcgendev.bat =================================================================== --- Trunk/pcgen/code/pcgendev.bat 2006-02-28 21:02:27 UTC (rev 27) +++ Trunk/pcgen/code/pcgendev.bat 2006-02-28 21:36:12 UTC (rev 28) @@ -1,10 +0,0 @@ -Rem Batch file to run development build of PCGEN. -Rem Make sure you run "ant" first (or "ant clean", then "ant"). -Rem $Id: pcgendev.bat,v 1.10 2005/10/23 13:17:43 binkley Exp $ -copy bin\pcgen.jar . - -Rem If you have arguments, the class to run must be the FIRST -Rem one! Example: -Rem java -jar pcgen.jar pcgen.core.pcGenGUI arg1 another-arg -REM To load all sources, the JVM runs out of memory with default 64m -java -Xmx96m -jar pcgen.jar %1 %2 %3 %4 %5 %6 %7 %8 %9 Deleted: Trunk/pcgen/code/pcgendev.sh =================================================================== --- Trunk/pcgen/code/pcgendev.sh 2006-02-28 21:02:27 UTC (rev 27) +++ Trunk/pcgen/code/pcgendev.sh 2006-02-28 21:36:12 UTC (rev 28) @@ -1,87 +0,0 @@ -#!/bin/sh -cd `dirname $0` - -pcgendir="$HOME/.pcgen" - -if [ ! -d "$pcgendir" ] -then - mkdir "$pcgendir" || exit 2 -fi - -if [ -f bin/pcgen.jar ] -then - if [ ! -f pcgen.jar -o bin/pcgen.jar -nt pcgen.jar ] - then - cp bin/pcgen.jar . - fi -fi - -if [ ! -f pcgen.jar ] -then - echo "$0: File not found: pcgen.jar: try 'ant build'" >&2 - exit 2 -fi - -if [ "x$BROWSER" = x ] -then - echo "$0: warning: please help fix the Unix desktop guess" >&2 - - case "$WINDOWMANAGER" in - *kde ) BROWSER=kde-open - echo "$0: warning: guessing KDE environment" >&2 ;; - *gdm ) BROWSER=gnome-open - echo "$0: warning: guessing GNOME environment" >&2 ;; - * ) BROWSER=netscape - echo "$0: warning: fallback to netscape" >&2 - esac -fi - -# To load all sources, the JVM runs out of memory with default 64m -javaargs="-Xmx96m" -pcgenargs="" -whosearg=java - -while [ "x$1" != x ] -do - case "$1" in - -h ) cat <<EOM -usage: $0 [java-options] [-- pcgen-options] - For java options, try 'java -h' and 'java -X -h'. - Useful java property defines: - -DBROWSER=/path/to/browser - -Dpcgen.filter=/path/to/filter.ini - -Dpcgen.options=/path/to/options.ini - This script recognizes the BROWSER environment variable. -EOM - exit 0 - ;; - -- ) whosearg=pcgen - ;; - * ) if [ "$whosearg" = java ] - then - javaargs="$javaargs $1" - else - pcgenargs="$pcgenargs $1" - fi - ;; - esac - shift -done - -# If you have arguments, the class to run must be the FIRST one! Example: -# $ java -jar pcgen.jar pcgen.core.pcGenGUI arg1 another-arg - -# PCGen related properties: -# -# pcgen.filter - the full path to the file name containing the filter settings -# pcgen.options - the full path to the file name containing the options -# -# Both of these properties are optional. Default behaviour is to get the -# files from the "user.dir" directory. -# -# Additional properties: -# -DBROWSER="$BROWSER" -# -Dpcgen.filter=/path/to/filter.ini -# -Dpcgen.options=/path/to/options.ini - -exec java -DBROWSER="$BROWSER" $javaargs -jar pcgen.jar $pcgenargs Deleted: Trunk/pcgen/code/pcgendevw.bat =================================================================== --- Trunk/pcgen/code/pcgendevw.bat 2006-02-28 21:02:27 UTC (rev 27) +++ Trunk/pcgen/code/pcgendevw.bat 2006-02-28 21:36:12 UTC (rev 28) @@ -1,7 +0,0 @@ -Rem Batch file to run development build of PCGEN. -Rem Make sure you run "ant" first (or "ant clean", then "ant"). -Rem $Id: pcgendevw.bat,v 1.7 2005/10/23 13:17:43 binkley Exp $ - -REM To load all sources, the JVM runs out of memory with default 64m - -start javaw -Xmx96m -jar bin\pcgen.jar %1 %2 %3 %4 %5 %6 %7 %8 %9 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <karianna@us...> - 2006-03-03 15:01:21
|
Revision: 80 Author: karianna Date: 2006-03-03 07:01:09 -0800 (Fri, 03 Mar 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=80&view=rev Log Message: ----------- Shifting up a directory in order to get an autobuild bootstrapping Removed Paths: ------------- Trunk/pcgen/code/maven.xml Trunk/pcgen/code/pom.xml Trunk/pcgen/code/project.properties Trunk/pcgen/code/project.xml Deleted: Trunk/pcgen/code/maven.xml =================================================================== --- Trunk/pcgen/code/maven.xml 2006-03-03 14:40:46 UTC (rev 79) +++ Trunk/pcgen/code/maven.xml 2006-03-03 15:01:09 UTC (rev 80) @@ -1,12 +0,0 @@ -<project xmlns:maven="jelly:maven" xmlns:j="jelly:core" - xmlns:ant="jelly:ant" xmlns:u="jelly:util"> - <preGoal name="java:compile"> - <attainGoal name="javacc:javacc-generate"/> - <!-- Kludge around a typo in the JavaCC --> - <ant:path id="maven.javacc.compile.src.set" - location="${basedir}/target/generated-src"/> - <maven:addPath id="maven.compile.src.set" - refid="maven.javacc.compile.src.set"/> - </preGoal> - -</project> Deleted: Trunk/pcgen/code/pom.xml =================================================================== --- Trunk/pcgen/code/pom.xml 2006-03-03 14:40:46 UTC (rev 79) +++ Trunk/pcgen/code/pom.xml 2006-03-03 15:01:09 UTC (rev 80) @@ -1,127 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>net.sourceforge.pcgen</groupId> - <artifactId>pcgen</artifactId> - <packaging>jar</packaging> - <version>1.0-SNAPSHOT</version> - <name>PCGen</name> - - <repositories> - <repository> - <id>ibiblio.repo</id> - <url>http://www.ibiblio.org/maven</url> - <layout>legacy</layout> - </repository> - <repository> - <id>pcgen.repo</id> - <url>http://pcgen.sourceforge.net/maven</url> - <layout>legacy</layout> - </repository> - <repository> - <id>maven-plugins.repo</id> - <url>http://maven-plugins.sourceforge.net/maven</url> - <layout>legacy</layout> - </repository> - <repository> - <id>emma.repo</id> - <url>http://emma.sourceforge.net/maven</url> - <layout>legacy</layout> - </repository> - </repositories> - - <build> - <sourceDirectory>src/java</sourceDirectory> - <testSourceDirectory>src/test</testSourceDirectory> - - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-site-plugin</artifactId> - <configuration> - <locales>de,en,fr</locales> - </configuration> - </plugin> - </plugins> - </build> - - <dependencies> - <!-- Compiling --> - <dependency> - <groupId>mrj</groupId> - <artifactId>MRJ141Stubs</artifactId> - <version>0</version> - </dependency> - <dependency> - <groupId>skinlf</groupId> - <artifactId>skinlf</artifactId> - <version>1.2.3</version> - </dependency> - <dependency> - <groupId>wraplf</groupId> - <artifactId>wraplf</artifactId> - <version>0.2</version> - </dependency> - <dependency> - <groupId>fop</groupId> - <artifactId>fop</artifactId> - <version>0.20.5</version> - </dependency> - <dependency> - <groupId>jep</groupId> - <artifactId>jep</artifactId> - <version>2.24</version> - </dependency> - <dependency> - <groupId>jep</groupId> - <artifactId>djep</artifactId> - <version>2.24</version> - </dependency> - <dependency> - <groupId>jdom</groupId> - <artifactId>jdom</artifactId> - <version>1.0b8</version> - </dependency> - <dependency> - <groupId>xalan</groupId> - <artifactId>xalan</artifactId> - <version>2.6.0</version> - </dependency> - <dependency> - <groupId>xerces</groupId> - <artifactId>xmlParserAPIs</artifactId> - <version>2.6.2</version> - </dependency> - <dependency> - <groupId>xerces</groupId> - <artifactId>xercesImpl</artifactId> - <version>2.6.2</version> - </dependency> - - <!-- Testing --> - <dependency> - <scope>test</scope> - <groupId>easymock</groupId> - <artifactId>easymock</artifactId> - <version>1.1</version> - </dependency> - <dependency> - <scope>test</scope> - <groupId>easymock</groupId> - <artifactId>easymockclassextension</artifactId> - <version>1.1</version> - </dependency> - <dependency> - <scope>test</scope> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.1</version> - </dependency> - <dependency> - <scope>test</scope> - <groupId>xmlunit</groupId> - <artifactId>xmlunit</artifactId> - <version>1.0</version> - </dependency> - </dependencies> -</project> Deleted: Trunk/pcgen/code/project.properties =================================================================== --- Trunk/pcgen/code/project.properties 2006-03-03 14:40:46 UTC (rev 79) +++ Trunk/pcgen/code/project.properties 2006-03-03 15:01:09 UTC (rev 80) @@ -1,82 +0,0 @@ -##################################### -# The properties for the repositories -##################################### -maven.repo.remote = http://www.ibiblio.org/maven, \ - http://pcgen.sourceforge.net/maven, \ - http://maven-plugins.sourceforge.net/maven, \ - http://emma.sourceforge.net/maven - -######################################## -# The properties for the checkstyle goal -######################################## -# The checkstyle format should follow Sun coding conventions -maven.checkstyle.format = sun -# Sad, necessary duplication of: maven.license.licenseFile -maven.checkstyle.header.file = LICENSE - -########################################## -# The properties for the java:compile goal -########################################## -maven.compile.deprectation = true -maven.compile.source = 1.4 -maven.compile.target = 1.4 - -################################## -# The properties for the docs goal -################################## -maven.docs.outputencoding = UTF-8 - -######################################## -# The properties for the code style goal -######################################## -maven.jalopy.style = standards/jalopy_pcgen.xml - -################################# -# The properties for the jar goal -################################# -maven.jar.index = true -maven.jar.manifest.extensions.add = true -maven.jar.override = true - -#################################### -# The properties for the javacc goal -#################################### -# TODO: There is a property for src/java -- what is it? -maven.javacc.javacc.grammar = ${maven.src.dir}/java/pcgen/util/DiceExpression.jj - -##################################### -# The properties for the javadoc goal -##################################### -maven.javadoc.author = true -maven.javadoc.customtags = todo -todo.name = todo -todo.description = To Do: -todo.enabled = true -todo.scope = all -maven.javadoc.links = http://java.sun.com/j2se/1.4.2/docs/api/ -maven.javadoc.maxmemory = 192m -maven.javadoc.overview = src/java/overview.html -maven.javadoc.private = true -maven.javadoc.source = 1.4 -maven.javadoc.use = true -maven.javadoc.version = true -maven.javadoc.additionalparam = -linksource - -################################## -# The properties for the jnlp goal -################################## -maven.jnlp.homepage = http://pcgen.sourceforge.net/ -maven.jnlp.j2se.version = 1.4.2+ - -################################## -# The properties for the test goal -################################## -# The junit dir may need to be a build.properties item only -maven.junit.dir=../ -maven.junit.fork=on -maven.test.source = 1.4 - -##################################### -# The properties for the license goal -##################################### -maven.license.licenseFile = LICENSE Deleted: Trunk/pcgen/code/project.xml =================================================================== --- Trunk/pcgen/code/project.xml 2006-03-03 14:40:46 UTC (rev 79) +++ Trunk/pcgen/code/project.xml 2006-03-03 15:01:09 UTC (rev 80) @@ -1,236 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project> - <pomVersion>3</pomVersion> - <id>pcgen</id> - <name>PCGen</name> - <currentVersion>5.9.5</currentVersion> - <organization> - <name>PCGen</name> - <url>http://pcgen.sourceforge.net/</url> - </organization> - <inceptionYear>2003</inceptionYear> - <package>pcgen</package> - <logo>http://maven.apache.org/images/maven.jpg</logo> - - <description>PCGen RPG character generator.</description> - <shortDescription>PCGen PRG character generator.</shortDescription> - - <!-- - <repository> - <connection>scm:cvs:ext:cvs.sourceforge.net:/cvsroot/pcgen:.</connection> - <url>http://cvs.sourceforge.net/viewcvs.py/pcgen/</url> - </repository> - --> - - <developers> - <developer> - <name>Bryan McRoberts</name> - <id>merton_monk</id> - <email>merton_monk@...</email> - <organization>PCGen</organization> - <roles> - <role>Benevolent Dictator</role> - </roles> - <url>http://pcgen.sourceforge.net/</url> - <timezone>-7</timezone> - </developer> - <developer> - <name>B. K. Oxley (binkley)</name> - <id>binkley</id> - <email>binkley@...</email> - <organization>PCGen</organization> - <roles> - <role>Itinerant Sourcerer</role> - </roles> - <url>http://binkley.blogspot.com/</url> - <timezone>-6</timezone> - </developer> - <developer> - <name>Greg Bingleman</name> - <id>byngl</id> - <email>byngl@...</email> - <organization>PCGen</organization> - <roles> - <role>X-Terminator (Mark II)</role> - </roles> - <url>http://www.byngl2.homestead.com/</url> - <timezone>-5</timezone> - </developer> - <developer> - <name>Martijn Verburg (karianna)</name> - <id>karianna</id> - <email>karianna@...</email> - <organization>PCGen</organization> - <roles> - <role>TM SB, Soul Reaper and Lemur*</role> - </roles> - <url>http://www.rageon.org</url> - <timezone>0</timezone> - </developer> - <developer> - <name>Stefan Radermacher</name> - <id>Zaister</id> - <email>radermacher@...</email> - <organization>PCGen</organization> - <roles> - <role>Code Tamarin</role> - </roles> - <timezone>+1</timezone> - </developer> - <developer> - <name>James Dempsey</name> - <id>jdempsey</id> - <email>jdempsey@...</email> - <organization>PCGen</organization> - <roles> - <role>Code Gibbon</role> - </roles> - <url>http://perrenland.org</url> - <timezone>+11</timezone> - </developer> - </developers> - - <dependencies> - <!-- Compiling --> - <dependency> - <groupId>mrj</groupId> - <artifactId>MRJ141Stubs</artifactId> - <version>0</version> - </dependency> - <dependency> - <groupId>skinlf</groupId> - <artifactId>skinlf</artifactId> - <version>1.2.3</version> - <url>http://www.l2fprod.com/</url> - </dependency> - <dependency> - <groupId>wraplf</groupId> - <artifactId>wraplf</artifactId> - <version>0.2</version> - <url>https://wraplf.dev.java.net/</url> - </dependency> - <dependency> - <groupId>fop</groupId> - <artifactId>fop</artifactId> - <version>0.20.5</version> - <url>http://xml.apache.org/fop/</url> - </dependency> - <dependency> - <groupId>jep</groupId> - <artifactId>jep</artifactId> - <version>2.24</version> - <url>http://www.singularsys.com/jep/</url> - </dependency> - <dependency> - <groupId>jep</groupId> - <artifactId>djep</artifactId> - <version>2.24</version> - <url>http://www.singsurf.org/djep/</url> - </dependency> - <dependency> - <groupId>jdom</groupId> - <artifactId>jdom</artifactId> - <version>1.0b8</version> - <url>http://www.jdom.org/</url> - </dependency> - <dependency> - <groupId>xalan</groupId> - <artifactId>xalan</artifactId> - <version>2.6.0</version> - <url>http://xml.apache.org/xalan-j/</url> - </dependency> - <dependency> - <groupId>xerces</groupId> - <artifactId>xmlParserAPIs</artifactId> - <version>2.6.2</version> - <url>http://xml.apache.org/xerces-j/</url> - </dependency> - <dependency> - <groupId>xerces</groupId> - <artifactId>xercesImpl</artifactId> - <version>2.6.2</version> - <url>http://xml.apache.org/xerces-j/</url> - </dependency> - - <!-- Testing --> - <dependency> - <groupId>easymock</groupId> - <artifactId>easymock</artifactId> - <version>1.1</version> - <url>http://www.easymock.org/</url> - </dependency> - <dependency> - <groupId>easymock</groupId> - <artifactId>easymockclassextension</artifactId> - <version>1.1</version> - <url>http://www.easymock.org/</url> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.1</version> - <url>http://www.junit.org/</url> - </dependency> - <dependency> - <groupId>xmlunit</groupId> - <artifactId>xmlunit</artifactId> - <version>1.0</version> - <url>http://xmlunit.sourceforge.net/</url> - </dependency> - <dependency> - <groupId>emma</groupId> - <artifactId>maven-emma-plugin</artifactId> - <version>0.6</version> - <type>plugin</type> - <url>http://emma.sourceforge.net/maven-emma-plugin/</url> - </dependency> -<!-- - <dependency> - <groupId>maven-plugins</groupId> - <artifactId>maven-findbugs-plugin</artifactId> - <version>0.8.4</version> - <type>plugin</type> - <url>http://maven-plugins.sourceforge.net/findbugs/</url> - </dependency> ---> - </dependencies> - - <reports> - <!-- <report>maven-changelog-plugin</report> --> - <!-- <report>maven-changes-plugin</report> --> - <!-- Runs slower'n molassas --> - <!-- <report>maven-checkstyle-plugin</report> --> - <!-- <report>maven-developer-activity-plugin</report> --> - <report>maven-emma-plugin</report> - <!-- <report>maven-file-activity-plugin</report> --> - <report>maven-javadoc-plugin</report> - <report>maven-jdepend-plugin</report> - <report>maven-junit-report-plugin</report> - <report>maven-jxr-plugin</report> - <report>maven-license-plugin</report> - <!-- Another slow'un --> - <!-- <report>maven-linkcheck-plugin</report> --> - <report>maven-pmd-plugin</report> - <report>maven-simian-plugin</report> - <report>maven-tasklist-plugin</report> - </reports> - - <build> - <sourceDirectory>src/java</sourceDirectory> - <unitTestSourceDirectory>src/test</unitTestSourceDirectory> - <unitTest> - <includes> - <include>**/*Test.java</include> - </includes> - </unitTest> - <resources> - <resource> - <!-- The resources are in the same place as the sources. --> - <directory>src/java</directory> - <includes> - <include>**/*.properties</include> - </includes> - </resource> - </resources> - </build> -</project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <soulcatcher@us...> - 2006-03-06 21:56:05
|
Revision: 113 Author: soulcatcher Date: 2006-03-06 13:55:34 -0800 (Mon, 06 Mar 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=113&view=rev Log Message: ----------- Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/persistence/lst/BaseKitLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/BaseKitLstToken.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitAbilityLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitAbilityLstToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/ Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/AbilityToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/CountToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/FeatToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/FreeToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/kit/basekit/ Trunk/pcgen/code/src/java/plugin/lsttokens/kit/basekit/LookupToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/kit/basekit/OptionToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-03-06 16:15:19 UTC (rev 112) +++ Trunk/pcgen/code/pluginbuild.xml 2006-03-06 21:55:34 UTC (rev 113) @@ -3869,6 +3869,50 @@ </patternset> </fileset> </jar> + <!-- Base Kit tokens--> + <jar jarfile="${lstplugins.dir}/BaseKitLstToken-LOOKUP.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/kit/basekit/LookupToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/BaseKitLstToken-OPTION.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/kit/basekit/OptionToken.class" /> + </patternset> + </fileset> + </jar> + <!-- Kit Ability tokens--> + <jar jarfile="${lstplugins.dir}/KitAbilityLstToken-ABILITY.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/kit/ability/AbilityToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/KitAbilityLstToken-COUNT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/kit/ability/CountToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/KitAbilityLstToken-FEAT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/kit/ability/FeatToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/KitAbilityLstToken-FREE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/kit/ability/FreeToken.class" /> + </patternset> + </fileset> + </jar> </target> <!-- System tokens--> Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/BaseKitLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/BaseKitLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/BaseKitLoader.java 2006-03-06 21:55:34 UTC (rev 113) @@ -0,0 +1,42 @@ +package pcgen.persistence.lst; + +import java.util.Map; + +import pcgen.core.kit.BaseKit; +import pcgen.util.Logging; + +public class BaseKitLoader { + public static boolean parseCommonTags(BaseKit obj, final String tag) + { + Map tokenMap = TokenStore.inst().getTokenMap(BaseKitLstToken.class); + + // We will find the first ":" for the "controlling" line token + final int idxColon = tag.indexOf(':'); + String key = ""; + try + { + key = tag.substring(0, idxColon); + } + catch(StringIndexOutOfBoundsException e) { + // TODO Handle Exception + } + BaseKitLstToken token = (BaseKitLstToken) tokenMap.get(key); + + if (token != null) + { + final String value = tag.substring(idxColon + 1); + LstUtils.deprecationCheck(token, obj.toString(), obj.toString(), value); + if (!token.parse(obj, value)) + { + Logging.errorPrint("Error parsing Kit tag " + obj.toString() + ':' + tag + "\""); + } + } + else if (key.startsWith("PRE") || key.startsWith("!PRE")) + { + obj.addPreReq(tag); + return true; + } + + return false; + } +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/BaseKitLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/BaseKitLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/BaseKitLstToken.java 2006-03-06 21:55:34 UTC (rev 113) @@ -0,0 +1,8 @@ +package pcgen.persistence.lst; + +import pcgen.core.kit.BaseKit; + +public interface BaseKitLstToken extends LstToken { + public abstract boolean parse(BaseKit baseKit, String value); + +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitAbilityLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitAbilityLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitAbilityLoader.java 2006-03-06 21:55:34 UTC (rev 113) @@ -0,0 +1,57 @@ +package pcgen.persistence.lst; + +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.Kit; +import pcgen.core.kit.KitAbilities; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; + +public class KitAbilityLoader { + + public static void parseLine(Kit kit, String colString) throws PersistenceLayerException + { + final StringTokenizer colToken = new StringTokenizer(colString, SystemLoader.TAB_DELIM); + KitAbilities kitAbility = null; + String ability = colToken.nextToken(); + kitAbility = new KitAbilities(ability, "", false); + + Map tokenMap = TokenStore.inst().getTokenMap(KitAbilityLstToken.class); + while (colToken.hasMoreTokens()) + { + + // We will find the first ":" for the "controlling" line token + final int idxColon = colString.indexOf(':'); + String key = ""; + try + { + key = colString.substring(0, idxColon); + } + catch(StringIndexOutOfBoundsException e) { + // TODO Handle Exception + } + KitAbilityLstToken token = (KitAbilityLstToken) tokenMap.get(key); + + if (token != null) + { + final String value = colString.substring(idxColon + 1); + LstUtils.deprecationCheck(token, kit, value); + if (!token.parse(kitAbility, value)) + { + Logging.errorPrint("Error parsing Kit Ability tag " + kitAbility.getObjectName() + ':' + colString + "\""); + } + } + else if (BaseKitLoader.parseCommonTags(kitAbility, colString)) + { + continue; + } + else + { + Logging.errorPrint("Unknown Kit Ability info: \"" + colString + "\""); + } + } + kit.addObject(kitAbility); + } +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitAbilityLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitAbilityLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitAbilityLstToken.java 2006-03-06 21:55:34 UTC (rev 113) @@ -0,0 +1,8 @@ +package pcgen.persistence.lst; + +import pcgen.core.kit.KitAbilities; + +public interface KitAbilityLstToken extends LstToken { + public abstract boolean parse(KitAbilities kitAbility, String value); + +} Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLoader.java 2006-03-06 16:15:19 UTC (rev 112) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/KitLoader.java 2006-03-06 21:55:34 UTC (rev 113) @@ -23,33 +23,11 @@ package pcgen.persistence.lst; import java.net.URL; -import java.util.ArrayList; -import java.util.StringTokenizer; +import java.util.Map; -import pcgen.core.Constants; -import pcgen.core.Globals; import pcgen.core.Kit; -import pcgen.core.kit.KitAbilities; -import pcgen.core.kit.KitAlignment; -import pcgen.core.kit.KitClass; -import pcgen.core.kit.KitDeity; -import pcgen.core.kit.KitFunds; -import pcgen.core.kit.KitGear; -import pcgen.core.kit.KitKit; -import pcgen.core.kit.KitProf; -import pcgen.core.kit.KitRace; -import pcgen.core.kit.KitSkill; -import pcgen.core.kit.KitSpells; -import pcgen.core.kit.KitStat; -import pcgen.core.kit.KitTemplate; import pcgen.persistence.PersistenceLayerException; -import pcgen.persistence.SystemLoader; import pcgen.util.Logging; -import pcgen.core.kit.KitSelect; -import pcgen.core.kit.BaseKit; -import pcgen.core.kit.KitLevelAbility; -import pcgen.core.kit.KitBio; -import java.util.Map; /** * @@ -106,5 +84,4 @@ + inputLine + "\""); } } - } Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java 2006-03-06 16:15:19 UTC (rev 112) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java 2006-03-06 21:55:34 UTC (rev 113) @@ -44,12 +44,15 @@ tokenTypeList.add(EquipmentLstToken.class); tokenTypeList.add(EquipmentModifierLstToken.class); tokenTypeList.add(LanguageLstToken.class); - tokenTypeList.add(KitLstToken.class); tokenTypeList.add(RaceLstToken.class); tokenTypeList.add(SkillLstToken.class); tokenTypeList.add(SpellLstToken.class); tokenTypeList.add(SubClassLstToken.class); tokenTypeList.add(WeaponProfLstToken.class); + //Kits + tokenTypeList.add(KitLstToken.class); + tokenTypeList.add(BaseKitLstToken.class); + tokenTypeList.add(KitAbilityLstToken.class); //miscinfo.lst tokenTypeList.add(GameModeLstToken.class); Added: Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/AbilityToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/AbilityToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/AbilityToken.java 2006-03-06 21:55:34 UTC (rev 113) @@ -0,0 +1,48 @@ +/* + * AbilityToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 March 3, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ +package plugin.lsttokens.kit.ability; + +import pcgen.core.kit.KitAbilities; +import pcgen.persistence.lst.KitAbilityLstToken; +import pcgen.util.Logging; + +public class AbilityToken implements KitAbilityLstToken +{ + /** + * Gets the name of the tag this class will parse. + * + * @return Name of the tag this class handles + */ + public String getTokenName() + { + return "FEAT"; + } + + public boolean parse(KitAbilities kitAbility, String value) + { + Logging.errorPrint("Ignoring second FEAT or ABILITY tag \"" + value + "\" in Kit."); + return false; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/CountToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/CountToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/CountToken.java 2006-03-06 21:55:34 UTC (rev 113) @@ -0,0 +1,47 @@ +/* + * AbilityToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 March 3, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ +package plugin.lsttokens.kit.ability; + +import pcgen.core.kit.KitAbilities; +import pcgen.persistence.lst.KitAbilityLstToken; + +public class CountToken implements KitAbilityLstToken +{ + /** + * Gets the name of the tag this class will parse. + * + * @return Name of the tag this class handles + */ + public String getTokenName() + { + return "COUNT"; + } + + public boolean parse(KitAbilities kitAbility, String value) + { + kitAbility.setChoiceCount(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/FeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/FeatToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/FeatToken.java 2006-03-06 21:55:34 UTC (rev 113) @@ -0,0 +1,47 @@ +/* + * AbilityToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 March 3, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ +package plugin.lsttokens.kit.ability; + +import pcgen.core.kit.KitAbilities; +import pcgen.persistence.lst.KitAbilityLstToken; + +public class FeatToken implements KitAbilityLstToken +{ + /** + * Gets the name of the tag this class will parse. + * + * @return Name of the tag this class handles + */ + public String getTokenName() + { + return "FREE"; + } + + public boolean parse(KitAbilities kitAbility, String value) + { + kitAbility.setFree(value.toUpperCase().startsWith("Y")); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/FreeToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/FreeToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/kit/ability/FreeToken.java 2006-03-06 21:55:34 UTC (rev 113) @@ -0,0 +1,48 @@ +/* + * AbilityToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 March 3, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ +package plugin.lsttokens.kit.ability; + +import pcgen.core.kit.KitAbilities; +import pcgen.persistence.lst.KitAbilityLstToken; +import pcgen.util.Logging; + +public class FreeToken implements KitAbilityLstToken +{ + /** + * Gets the name of the tag this class will parse. + * + * @return Name of the tag this class handles + */ + public String getTokenName() + { + return "FEAT"; + } + + public boolean parse(KitAbilities kitAbility, String value) + { + Logging.errorPrint("Ignoring second FEAT or ABILITY tag \"" + value + "\" in Kit."); + return false; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/kit/basekit/LookupToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/kit/basekit/LookupToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/kit/basekit/LookupToken.java 2006-03-06 21:55:34 UTC (rev 113) @@ -0,0 +1,48 @@ +/* + * AbilityToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 March 3, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ +package plugin.lsttokens.kit.basekit; + +import pcgen.core.kit.BaseKit; +import pcgen.persistence.lst.BaseKitLstToken; + +public class LookupToken implements BaseKitLstToken +{ + /** + * Gets the name of the tag this class will parse. + * + * @return Name of the tag this class handles + */ + public String getTokenName() + { + return "LOOKUP"; + } + + public boolean parse(BaseKit baseKit, String value) + { + baseKit.addLookup(value); + return true; + } +} + Added: Trunk/pcgen/code/src/java/plugin/lsttokens/kit/basekit/OptionToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/kit/basekit/OptionToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/kit/basekit/OptionToken.java 2006-03-06 21:55:34 UTC (rev 113) @@ -0,0 +1,67 @@ +/* + * AbilityToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 March 3, 2006 + * + * Current Ver: $Revision: $ + * Last Editor: $Author: $ + * Last Edited: $Date: $ + */ +package plugin.lsttokens.kit.basekit; + +import java.util.StringTokenizer; + +import pcgen.core.kit.BaseKit; +import pcgen.persistence.lst.BaseKitLstToken; + +public class OptionToken implements BaseKitLstToken +{ + /** + * Gets the name of the tag this class will parse. + * + * @return Name of the tag this class handles + */ + public String getTokenName() + { + return "OPTION"; + } + + public boolean parse(BaseKit baseKit, String value) + { + StringTokenizer tok = new StringTokenizer(value, "|"); + while (tok.hasMoreTokens()) + { + String val = tok.nextToken(); + int ind = -1; + String lowVal; + String highVal; + if ((ind = val.indexOf(",")) != -1) + { + lowVal = val.substring(0, ind); + highVal = val.substring(ind + 1); + } + else + { + lowVal = highVal = val; + } + baseKit.addOptionRange(lowVal, highVal); + } + return true; + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zaister@us...> - 2006-03-07 11:14:15
|
Revision: 123 Author: zaister Date: 2006-03-07 03:14:05 -0800 (Tue, 07 Mar 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=123&view=rev Log Message: ----------- Re-added lost SOURCEDATE tag after pluginization Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/SourcedateLst.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-03-07 11:02:43 UTC (rev 122) +++ Trunk/pcgen/code/pluginbuild.xml 2006-03-07 11:14:05 UTC (rev 123) @@ -1931,6 +1931,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/LstToken-SOURCEDATE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/SourcedateLst.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${lstplugins.dir}/LstToken-SOURCELONG.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Added: Trunk/pcgen/code/src/java/plugin/lsttokens/SourcedateLst.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/SourcedateLst.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/SourcedateLst.java 2006-03-07 11:14:05 UTC (rev 123) @@ -0,0 +1 @@ +/* * Created on Sep 2, 2005 * */ package plugin.lsttokens; import java.util.Map; import pcgen.core.PObject; import pcgen.persistence.lst.GlobalLstToken; import pcgen.persistence.lst.SourceLoader; import pcgen.persistence.lst.SourceLstToken; /** * @author zaister * */ public class SourcedateLst implements GlobalLstToken, SourceLstToken { public String getTokenName() { return "SOURCEDATE"; } public boolean parse(PObject obj, String value, int anInt) { obj.setSourceMap(SourceLoader.parseSource("SOURCEDATE:" + value)); return true; } public boolean parse(Map sourceMap, String value) { sourceMap.putAll(SourceLoader.parseSource("SOURCEDATE:" + value)); return true; } } \ 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: <soulcatcher@us...> - 2006-03-07 22:58:34
|
Revision: 125 Author: soulcatcher Date: 2006-03-07 14:58:04 -0800 (Tue, 07 Mar 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=125&view=rev Log Message: ----------- Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/persistence/lst/CampaignSourceEntry.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/CurrencyLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstUtils.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/PCTemplateLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/SourceLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java Trunk/pcgen/code/src/java/plugin/lsttokens/kit/AbilityToken.java Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/persistence/lst/PCTemplateLstToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/ Trunk/pcgen/code/src/java/plugin/lsttokens/template/AgeToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/BonusfeatsToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/BonusskillpointsToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/CostToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/CrToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/FavoredclassToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/FeatToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/GenderlockToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/HandedlockToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/HdToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/HeightToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/HitdieToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/LangbonusToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/LeveladjustmentToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelsperfeatToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/NonppToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/QualifyToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/RacesubtypeToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/RacetypeToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/RegionToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/RemovableToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/RepeatlevelToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/SizeToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/SubraceToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/SubregionToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/TemplateToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/VisibleToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/WeaponbonusToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/WeightToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-03-07 22:39:09 UTC (rev 124) +++ Trunk/pcgen/code/pluginbuild.xml 2006-03-07 22:58:04 UTC (rev 125) @@ -1744,7 +1744,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-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-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-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"> @@ -3782,6 +3782,220 @@ </jar> </target> + <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-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> + <include name="plugin/lsttokens/template/BonusfeatsToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-BONUSSKILLPOINTS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/BonusskillpointsToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-COST.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/CostToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-CR.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/CrToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-FAVOREDCLASS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/FavoredclassToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-FEAT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/FeatToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-GENDERLOCK.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/GenderlockToken.class" /> + </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-HD.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/HdToken.class" /> + </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> + <include name="plugin/lsttokens/template/HitdieToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-LANGBONUS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/LangbonusToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-LEVEL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/LevelToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-LEVELADJUSTMENT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/LeveladjustmentToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-LEVELSPERFEAT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/LevelsperfeatToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-NONPP.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/NonppToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-QUALIFY.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/QualifyToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-RACESUBTYPE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/RacesubtypeToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-RACETYPE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/RacetypeToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-REGION.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/RegionToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-REMOVABLE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/RemovableToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-REPEATLEVEL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/RepeatlevelToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-SIZE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/SizeToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-SUBRACE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/SubraceToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-SUBREGION.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/SubregionToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-TEMPLATE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/TemplateToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-VISIBLE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/VisibleToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-WEAPONBONUS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/WeaponbonusToken.class" /> + </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"> <!-- WeaponProf tokens--> <jar jarfile="${lstplugins.dir}/WeaponProfLstToken-HANDS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/CampaignSourceEntry.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/CampaignSourceEntry.java 2006-03-07 22:39:09 UTC (rev 124) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/CampaignSourceEntry.java 2006-03-07 22:58:04 UTC (rev 125) @@ -25,12 +25,12 @@ */ package pcgen.persistence.lst; +import java.util.ArrayList; +import java.util.List; + import pcgen.core.Campaign; import pcgen.core.utils.CoreUtility; -import java.util.ArrayList; -import java.util.List; - /** * This class is used to match a source file to the campaign that * loaded it. Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/CurrencyLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/CurrencyLoader.java 2006-03-07 22:39:09 UTC (rev 124) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/CurrencyLoader.java 2006-03-07 22:58:04 UTC (rev 125) @@ -40,7 +40,7 @@ * Current Ver: $Revision: 1.7 $ <br> * Last Editor: $Author: binkley $ <br> * Last Edited: $Date: 2005/10/18 20:23:53 $ - * + * @deprecated * @author AD9C15 */ public class CurrencyLoader extends LstLineFileLoader @@ -60,6 +60,7 @@ 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); Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstUtils.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstUtils.java 2006-03-07 22:39:09 UTC (rev 124) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstUtils.java 2006-03-07 22:58:04 UTC (rev 125) @@ -26,7 +26,7 @@ sb.append(obj.getSource()); sb.append(". "); sb.append(((Deprecated)token).getMessage(obj, value)); - Logging.errorPrint(sb.toString()); + deprecationWarning(sb.toString()); } } @@ -49,7 +49,11 @@ sb.append(source); sb.append(". "); sb.append(((Deprecated)token).getMessage(null, value)); - Logging.errorPrint(sb.toString()); + deprecationWarning(sb.toString()); } } + + public static void deprecationWarning(String warning) { + Logging.errorPrint(warning); + } } Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/PCTemplateLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/PCTemplateLoader.java 2006-03-07 22:39:09 UTC (rev 124) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/PCTemplateLoader.java 2006-03-07 22:58:04 UTC (rev 125) @@ -32,6 +32,7 @@ import pcgen.util.Logging; import java.net.URL; +import java.util.Map; import java.util.StringTokenizer; /** @@ -54,9 +55,9 @@ { return; } + template.setName("None"); final StringTokenizer colToken = new StringTokenizer(inputLine, SystemLoader.TAB_DELIM); - String templName = "None"; int col = 0; if (!template.isNewItem()) @@ -65,302 +66,49 @@ colToken.nextToken(); } + Map tokenMap = TokenStore.inst().getTokenMap(PCTemplateLstToken.class); while (colToken.hasMoreTokens()) { final String colString = colToken.nextToken().trim(); - if (colString.startsWith("REGION:")) + final int idxColon = colString.indexOf(':'); + String key = ""; + try { - String region = colString.substring(7); - - if ("Yes".equalsIgnoreCase(region)) - { - region = templName; - } - - template.setRegion(region); - - continue; + key = colString.substring(0, idxColon); } - - if (PObjectLoader.parseTag(template, colString)) - { - continue; + catch(StringIndexOutOfBoundsException e) { + // TODO Handle Exception } + PCTemplateLstToken token = (PCTemplateLstToken) tokenMap.get(key); if (col == 0) { template.setName(colString); - templName = template.getName(); } - else if (colString.startsWith("AGE:")) - { - template.setAgeString(colString.substring(4)); - } - // replaces racial age - else if (colString.startsWith("BONUSFEATS:")) - { - template.setBonusInitialFeats(Integer.parseInt(colString.substring(11))); - } - // number of additional feats to spend - else if (colString.startsWith("BONUSSKILLPOINTS:")) - { - template.setBonusSkillsPerLevel(Integer.parseInt(colString.substring(17))); - } - // additional skill points per level else if (colString.startsWith("CHOOSE:LANGAUTO:")) { template.setChooseLanguageAutos(colString.substring(16)); } - else if (colString.startsWith("COST:")) + else if (token != null) { - template.setCost(colString.substring(5)); - } - else if (colString.startsWith("CR:")) - { - template.setCR(Integer.parseInt(colString.substring(3))); - } - else if (colString.startsWith("FAVOREDCLASS:")) - { - template.setFavoredClass(colString.substring(13)); - } - else if (colString.startsWith("FEAT:")) - { - template.addFeatString(colString.substring(5)); - } - else if (colString.startsWith("GENDERLOCK:")) - { - template.setGenderLock(colString.substring(11)); - } - // set and lock character gender, disabling pulldown menu in description section. - else if (colString.startsWith("GOLD:")) - { - Logging.errorPrint("GOLD: tag in " + sourceURL.toString() - + " no longer supported due to OGL compliance"); - } - else if (colString.startsWith("HANDEDLOCK:")) - { - template.setHandedLock(colString.substring(11)); - } - // set and lock character handedness, disabling pulldown menu in description section. - else if (colString.startsWith("HD:")) - { - template.addHitDiceString(colString.substring(3)); - } - else if (colString.startsWith("HEIGHT:")) - { - template.setHeightString(colString.substring(7)); - } - else if (colString.startsWith("HITDIE:")) // HitDieLock - { - template.setHitDieLock(colString.substring(7)); - } - else if (colString.startsWith("LANGBONUS")) - { - template.setLanguageBonus(colString.substring(10)); - } - else if (colString.startsWith("LEVEL:")) - { - template.addLevelString(colString.substring(6)); - } - else if (colString.startsWith("LEVELADJUSTMENT:")) - { - template.setLevelAdjustment(colString.substring(16)); - } - else if (colString.startsWith("LEVELSPERFEAT:")) - { - final int newLevels = Integer.parseInt(colString.substring(14)); - - if (newLevels >= 0) + final String value = colString.substring(idxColon + 1); + LstUtils.deprecationCheck(token, template, value); + if (!token.parse(template, value)) { - template.setLevelsPerFeat(newLevels); + Logging.errorPrint("Error parsing template " + template.getName() + ':' + sourceURL.toString() + ':' + colString + "\""); } } - // how many levels per feat. - else if (colString.startsWith("NONPP:")) + else if (PObjectLoader.parseTag(template, colString)) { - template.setNonProficiencyPenalty(Integer.parseInt(colString.substring(6))); + continue; } - else if (colString.startsWith("POPUPALERT:")) + else { - // NOTE: This shouldn't be in here... - // GuiFacade ties this class to Swing - // GuiFacade.showMessageDialog(null, colString.substring(11), "PCGen", GuiFacade.ERROR_MESSAGE); + Logging.errorPrint("Unknown tag '" + colString + "' in " + sourceURL.toString()); } - // pops the message to the screen. - else if (colString.startsWith("SIZE:")) - { - template.setTemplateSize(colString.substring(5)); - } - else if (colString.startsWith("WEIGHT:")) - { - template.setWeightString(colString.substring(7)); - } - // replace racial weight - else if (colString.startsWith("QUALIFY:")) - { - template.setQualifyString(colString.substring(8)); - } - else if (colString.startsWith("RACETYPE:")) - { - template.setRaceType(colString.substring(9)); - } - else if (colString.startsWith("RACESUBTYPE:")) - { - template.addSubTypeString(colString.substring(12)); - } - else if (colString.startsWith("REMOVABLE:")) - { - if (colString.substring(10).startsWith("No")) - { - template.setRemovable(false); - } - } - else if (colString.startsWith("REPEATLEVEL:")) - { - parseTemplateRepeatLevel(template, colString.substring(12), sourceURL); - } - else if (colString.startsWith("SUBRACE:")) - { - String subRace = colString.substring(8); - if ("Yes".equalsIgnoreCase(subRace)) - { - subRace = templName; - } - - template.setSubRace(subRace); - } - else if (colString.startsWith("SUBREGION:")) - { - String subregion = colString.substring(10); - - if ("Yes".equalsIgnoreCase(subregion)) - { - subregion = templName; - } - - template.setSubRegion(subregion); - } - else if (colString.startsWith("TEMPLATE:")) - { - template.addTemplate(colString.substring(9)); - } - else if (colString.startsWith("VISIBLE:")) - { - final String visType = colString.substring(8).toUpperCase(); - - if (visType.startsWith("DISPLAY")) - { - template.setVisible(PCTemplate.VISIBILITY_DISPLAY_ONLY); - } - else if (visType.startsWith("EXPORT")) - { - template.setVisible(PCTemplate.VISIBILITY_OUTPUT_ONLY); - } - else if (visType.startsWith("NO")) - { - template.setVisible(PCTemplate.VISIBILITY_HIDDEN); - } - else - { - template.setVisible(PCTemplate.VISIBILITY_DEFAULT); - } - } - else if (colString.startsWith("WEAPONBONUS")) - { - template.setWeaponProfBonus(colString.substring(12)); - } - ++col; } } - - /** - * Attempt to parse "toParse" as an int. If it doesn't parse correctly, use - * aMessage and sourceURL to explain what is badly formatted and where. - * - * @param toParse Potential int string - * @param aMessage What the int represents (i.e. what we're trying to - * parse) - * @param sourceURL Where this came from (for the error message) - * - * @return the parsed int (-1 on failure) - */ - - private static int parseInt(final String toParse, final String aMessage, final URL sourceURL) - { - int iValue = -1; - try - { - iValue = Integer.parseInt(toParse); - } - catch (NumberFormatException nfe) - { - Logging.errorPrint("Non-numeric " + aMessage + " '" + toParse + "' in " + sourceURL.toString()); - } - return iValue; - } - - - /** - * Parse a repeat level tag in the format x|y|z:level:<level assigned item>. - * beginning at level, and ending at z, stepping by x, add <level assigned - * item> for y consecutive steps, then miss one. - * - * @param template the template to add to - * @param colString the repeat string - * @param sourceURL the file this came from - */ - - private static void parseTemplateRepeatLevel(PCTemplate template, String colString, URL sourceURL) - { - // - // x|y|z:level:<level assigned item> - // - final int endRepeat = colString.indexOf(':'); - if (endRepeat > 0) - { - final int endLevel = colString.indexOf(':', endRepeat + 1); - if (endLevel > 0) - { - final StringTokenizer repeatToken = new StringTokenizer(colString.substring(0, endRepeat), "|"); - if (repeatToken.countTokens() == 3) - { - final int lvlIncrement = parseInt(repeatToken.nextToken(), "Level Increment", sourceURL); - final int consecutive = parseInt(repeatToken.nextToken(), "Consecutive Level", sourceURL); - final int maxLevel = parseInt(repeatToken.nextToken(), "Max Level", sourceURL); - int iLevel = parseInt(colString.substring(endRepeat + 1, endLevel), "Level", sourceURL); - - if ((iLevel > 0) && (lvlIncrement > 0) && (maxLevel > 0) && (consecutive >= 0)) - { - int count = consecutive; - for(; iLevel <= maxLevel; iLevel += lvlIncrement) - { - if ((consecutive == 0) || (count != 0)) - { - template.addLevelString(Integer.toString(iLevel) + ":" + - colString.substring(endLevel + 1)); - } - if (consecutive != 0) - { - if (count == 0) - { - count = consecutive; - } - else - { - --count; - } - } - } - } - - return; - } - } - } - - Logging.errorPrint("Invalid REPEATLEVEL tag format: " + colString + "' in " + sourceURL.toString()); - } } Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/PCTemplateLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/PCTemplateLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/PCTemplateLstToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,44 @@ +/* + * PCTemplateLstToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:16 AM + * + * Current Ver: $Revision: 1.2 $ + * Last Editor: $Author: karianna $ + * Last Edited: $Date: 2005/09/20 11:37:34 $ + * + */ +package pcgen.persistence.lst; + +import pcgen.core.PCTemplate; + +/** + * <code>PCTemplateLstToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public interface PCTemplateLstToken extends LstToken +{ + /** + * Parses a Template object + * @param template + * @param value + * @return true if parse OK + */ + public abstract boolean parse(PCTemplate template, String value); +} Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/SourceLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/SourceLoader.java 2006-03-07 22:39:09 UTC (rev 124) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/SourceLoader.java 2006-03-07 22:58:04 UTC (rev 125) @@ -63,7 +63,7 @@ { Map sourceMap = new HashMap(); if(value.indexOf("|") != -1) { - Logging.errorPrint("Use of SOURCELONG:<value>|SOURCESHORT:<value>|SOURCEWEB:<value>|SOURCEPAGE:<value> is deprecated. These need to be split up into separate tokens"); + LstUtils.deprecationWarning("Use of SOURCELONG:<value>|SOURCESHORT:<value>|SOURCEWEB:<value>|SOURCEPAGE:<value> is deprecated. These need to be split up into separate tokens"); } StringTokenizer aTok = new StringTokenizer(value, "|"); Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java 2006-03-07 22:39:09 UTC (rev 124) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java 2006-03-07 22:58:04 UTC (rev 125) @@ -45,6 +45,7 @@ tokenTypeList.add(EquipmentModifierLstToken.class); tokenTypeList.add(LanguageLstToken.class); tokenTypeList.add(RaceLstToken.class); + tokenTypeList.add(PCTemplateLstToken.class); tokenTypeList.add(SkillLstToken.class); tokenTypeList.add(SpellLstToken.class); tokenTypeList.add(SourceLstToken.class); Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/kit/AbilityToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/kit/AbilityToken.java 2006-03-07 22:39:09 UTC (rev 124) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/kit/AbilityToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -24,15 +24,10 @@ */ package plugin.lsttokens.kit; -import java.util.StringTokenizer; - import pcgen.core.Kit; -import pcgen.core.kit.KitAbilities; import pcgen.persistence.PersistenceLayerException; -import pcgen.persistence.SystemLoader; import pcgen.persistence.lst.KitAbilityLoader; import pcgen.persistence.lst.KitLstToken; -import pcgen.util.Logging; /** * Handles the ABILITY tag for Kits. Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/AgeToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/AgeToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/AgeToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,21 @@ +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; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/BonusfeatsToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/BonusfeatsToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/BonusfeatsToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,26 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with BONUSFEATS Token + */ +public class BonusfeatsToken implements PCTemplateLstToken { + + public String getTokenName() { + return "BONUSFEATS"; + } + + // number of additional feats to spend + public boolean parse(PCTemplate template, String value) { + try { + template.setBonusInitialFeats(Integer.parseInt(value)); + } + catch(NumberFormatException nfe) { + return false; + } + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/BonusskillpointsToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/BonusskillpointsToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/BonusskillpointsToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,26 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with BONUSSKILLPOINTS Token + */ +public class BonusskillpointsToken implements PCTemplateLstToken { + + public String getTokenName() { + return "BONUSSKILLPOINTS"; + } + + // additional skill points per level + public boolean parse(PCTemplate template, String value) { + try { + template.setBonusSkillsPerLevel(Integer.parseInt(value)); + } + catch(NumberFormatException nfe) { + return false; + } + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/CostToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/CostToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/CostToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with COST Token + */ +public class CostToken implements PCTemplateLstToken { + + public String getTokenName() { + return "COST"; + } + + public boolean parse(PCTemplate template, String value) { + template.setCost(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/CrToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/CrToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/CrToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,25 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with CR Token + */ +public class CrToken implements PCTemplateLstToken { + + public String getTokenName() { + return "CR"; + } + + public boolean parse(PCTemplate template, String value) { + try { + template.setCR(Integer.parseInt(value)); + } + catch(NumberFormatException nfe) { + return false; + } + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/FavoredclassToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/FavoredclassToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/FavoredclassToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with FAVOREDCLASS Token + */ +public class FavoredclassToken implements PCTemplateLstToken { + + public String getTokenName() { + return "FAVOREDCLASS"; + } + + public boolean parse(PCTemplate template, String value) { + template.setFavoredClass(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/FeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/FeatToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/FeatToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with FEAT Token + */ +public class FeatToken implements PCTemplateLstToken { + + public String getTokenName() { + return "FEAT"; + } + + public boolean parse(PCTemplate template, String value) { + template.addFeatString(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/GenderlockToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/GenderlockToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/GenderlockToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,22 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with GENDERLOCK Token + */ +public class GenderlockToken implements PCTemplateLstToken { + + public String getTokenName() { + return "GENDERLOCK"; + } + + //set and lock character gender, disabling pulldown menu in description section. + public boolean parse(PCTemplate template, String value) { + template.setGenderLock(value); + return true; + } +} + Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/HandedlockToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/HandedlockToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/HandedlockToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,22 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with HANDEDLOCK Token + */ +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; + } +} + Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/HdToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/HdToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/HdToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with HD Token + */ +public class HdToken implements PCTemplateLstToken { + + public String getTokenName() { + return "HD"; + } + + public boolean parse(PCTemplate template, String value) { + template.addHitDiceString(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/HeightToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/HeightToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/HeightToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +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; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/HitdieToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/HitdieToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/HitdieToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with HITDIE Token + */ +public class HitdieToken implements PCTemplateLstToken { + + public String getTokenName() { + return "HITDIE"; + } + + public boolean parse(PCTemplate template, String value) { + template.setHitDieLock(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/LangbonusToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/LangbonusToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/LangbonusToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with LANGBONUS Token + */ +public class LangbonusToken implements PCTemplateLstToken { + + public String getTokenName() { + return "LANGBONUS"; + } + + public boolean parse(PCTemplate template, String value) { + template.setLanguageBonus(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with LEVEL Token + */ +public class LevelToken implements PCTemplateLstToken { + + public String getTokenName() { + return "LEVEL"; + } + + public boolean parse(PCTemplate template, String value) { + template.addLevelString(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/LeveladjustmentToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/LeveladjustmentToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/LeveladjustmentToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with LEVELADJUSTMENT Token + */ +public class LeveladjustmentToken implements PCTemplateLstToken { + + public String getTokenName() { + return "LEVELADJUSTMENT"; + } + + public boolean parse(PCTemplate template, String value) { + template.setLevelAdjustment(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelsperfeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelsperfeatToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelsperfeatToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,30 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with LEVELSPERFEAT Token + */ +public class LevelsperfeatToken implements PCTemplateLstToken { + + public String getTokenName() { + return "LEVELSPERFEAT"; + } + + // how many levels per feat. + public boolean parse(PCTemplate template, String value) { + try { + final int newLevels = Integer.parseInt(value); + + if (newLevels >= 0) { + template.setLevelsPerFeat(newLevels); + } + } + catch(NumberFormatException nfe) { + return false; + } + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/NonppToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/NonppToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/NonppToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,25 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with NONPP Token + */ +public class NonppToken implements PCTemplateLstToken { + + public String getTokenName() { + return "NONPP"; + } + + public boolean parse(PCTemplate template, String value) { + try { + template.setNonProficiencyPenalty(Integer.parseInt(value)); + } + catch(NumberFormatException nfe) { + return false; + } + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/QualifyToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/QualifyToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/QualifyToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with QUALIFY Token + */ +public class QualifyToken implements PCTemplateLstToken { + + public String getTokenName() { + return "QUALIFY"; + } + + public boolean parse(PCTemplate template, String value) { + template.setQualifyString(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/RacesubtypeToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/RacesubtypeToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/RacesubtypeToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with RACESUBTYPE Token + */ +public class RacesubtypeToken implements PCTemplateLstToken { + + public String getTokenName() { + return "RACESUBTYPE"; + } + + public boolean parse(PCTemplate template, String value) { + template.addSubTypeString(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/RacetypeToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/RacetypeToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/RacetypeToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with RACETYPE Token + */ +public class RacetypeToken implements PCTemplateLstToken { + + public String getTokenName() { + return "RACETYPE"; + } + + public boolean parse(PCTemplate template, String value) { + template.setRaceType(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/RegionToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/RegionToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/RegionToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,24 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with REGION Token + */ +public class RegionToken implements PCTemplateLstToken { + + public String getTokenName() { + return "REGION"; + } + + public boolean parse(PCTemplate template, String value) { + if (value.toUpperCase().startsWith("Y")) { + value = template.getName(); + } + + template.setRegion(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/RemovableToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/RemovableToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/RemovableToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with REMOVABLE Token + */ +public class RemovableToken implements PCTemplateLstToken { + + public String getTokenName() { + return "REMOVABLE"; + } + + public boolean parse(PCTemplate template, String value) { + template.setRemovable(!value.toUpperCase().startsWith("N")); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/RepeatlevelToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/RepeatlevelToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/RepeatlevelToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,63 @@ +package plugin.lsttokens.template; + +import java.util.StringTokenizer; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with REPEATLEVEL Token + */ +public class RepeatlevelToken implements PCTemplateLstToken { + + public String getTokenName() { + return "REPEATLEVEL"; + } + + public boolean parse(PCTemplate template, String value) { + // + // x|y|z:level:<level assigned item> + // + final int endRepeat = value.indexOf(':'); + if (endRepeat > 0) + { + final int endLevel = value.indexOf(':', endRepeat + 1); + if (endLevel > 0) { + final StringTokenizer repeatToken = new StringTokenizer(value.substring(0, endRepeat), "|"); + if (repeatToken.countTokens() == 3) { + try { + final int lvlIncrement = Integer.parseInt(repeatToken.nextToken()); + final int consecutive = Integer.parseInt(repeatToken.nextToken()); + final int maxLevel = Integer.parseInt(repeatToken.nextToken()); + int iLevel = Integer.parseInt(value.substring(endRepeat + 1, endLevel)); + + if ((iLevel > 0) && (lvlIncrement > 0) && (maxLevel > 0) && (consecutive >= 0)) { + int count = consecutive; + for(; iLevel <= maxLevel; iLevel += lvlIncrement) { + if ((consecutive == 0) || (count != 0)) { + template.addLevelString(Integer.toString(iLevel) + ":" + + value.substring(endLevel + 1)); + } + if (consecutive != 0) { + if (count == 0) { + count = consecutive; + } + else { + --count; + } + } + } + } + + return true; + } + catch(NumberFormatException nfe) { + return false; + } + } + } + } + return false; + } +} \ No newline at end of file Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/SizeToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/SizeToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/SizeToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with SIZE Token + */ +public class SizeToken implements PCTemplateLstToken { + + public String getTokenName() { + return "SIZE"; + } + + public boolean parse(PCTemplate template, String value) { + template.setTemplateSize(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/SubraceToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/SubraceToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/SubraceToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,24 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with REGION Token + */ +public class SubraceToken implements PCTemplateLstToken { + + public String getTokenName() { + return "REGION"; + } + + public boolean parse(PCTemplate template, String value) { + if (value.toUpperCase().startsWith("Y")) { + value = template.getName(); + } + + template.setSubRace(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/SubregionToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/SubregionToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/SubregionToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,24 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with SUBREGION Token + */ +public class SubregionToken implements PCTemplateLstToken { + + public String getTokenName() { + return "SUBREGION"; + } + + public boolean parse(PCTemplate template, String value) { + if (value.toUpperCase().startsWith("Y")) { + value = template.getName(); + } + + template.setSubRegion(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/TemplateToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/TemplateToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/TemplateToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with TEMPLATE Token + */ +public class TemplateToken implements PCTemplateLstToken { + + public String getTokenName() { + return "TEMPLATE"; + } + + public boolean parse(PCTemplate template, String value) { + template.addTemplate(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/VisibleToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/VisibleToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/VisibleToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,31 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with VISIBLE Token + */ +public class VisibleToken implements PCTemplateLstToken { + + public String getTokenName() { + return "VISIBLE"; + } + + public boolean parse(PCTemplate template, String value) { + if (value.startsWith("DISPLAY")) { + template.setVisible(PCTemplate.VISIBILITY_DISPLAY_ONLY); + } + else if (value.startsWith("EXPORT")) { + template.setVisible(PCTemplate.VISIBILITY_OUTPUT_ONLY); + } + else if (value.startsWith("NO")) { + template.setVisible(PCTemplate.VISIBILITY_HIDDEN); + } + else { + template.setVisible(PCTemplate.VISIBILITY_DEFAULT); + } + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/WeaponbonusToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/WeaponbonusToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/WeaponbonusToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,20 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + + +/** + * Class deals with WEAPONBONUS Token + */ +public class WeaponbonusToken implements PCTemplateLstToken { + + public String getTokenName() { + return "WEAPONBONUS"; + } + + public boolean parse(PCTemplate template, String value) { + template.setWeaponProfBonus(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/WeightToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/WeightToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/WeightToken.java 2006-03-07 22:58:04 UTC (rev 125) @@ -0,0 +1,21 @@ +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: <soulcatcher@us...> - 2006-03-09 00:46:47
|
Revision: 134 Author: soulcatcher Date: 2006-03-08 16:45:50 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=134&view=rev Log Message: ----------- tokenized load and paper Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/EquipSlotLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/LoadInfoLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/PaperInfoLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/persistence/lst/LoadInfoLstToken.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/PaperInfoLstToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/load/ Trunk/pcgen/code/src/java/plugin/lsttokens/load/EncumbranceToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/load/LoadToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/load/LoadmultToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/load/ModifierToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/load/SizemultToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/paper/ Trunk/pcgen/code/src/java/plugin/lsttokens/paper/BottommarginToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/paper/HeightToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/paper/LeftmarginToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/paper/NameToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/paper/RightmarginToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/paper/TopmarginToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/paper/WidthToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/FaceToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/HandsToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/LegsToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/ReachToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-03-09 00:46:20 UTC (rev 133) +++ Trunk/pcgen/code/pluginbuild.xml 2006-03-09 00:45:50 UTC (rev 134) @@ -3820,6 +3820,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-FACE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/FaceToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${lstplugins.dir}/TemplateLstToken-FAVOREDCLASS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -3848,6 +3855,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-HANDS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/HandsToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${lstplugins.dir}/TemplateLstToken-HD.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -3869,6 +3883,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-LEGS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/LegsToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${lstplugins.dir}/TemplateLstToken-LANGBONUS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -3925,6 +3946,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/TemplateLstToken-REACH.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/template/ReachToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${lstplugins.dir}/TemplateLstToken-REGION.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -5189,6 +5217,150 @@ </patternset> </fileset> </jar> + <!-- Level tokens--> + <jar jarfile="${systemlstplugins.dir}/Level-CSKILLMAX.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/level/CskillmaxToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Level-CCSKILLMAX.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/level/CcskillmaxToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Level-LEVEL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/level/LevelToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Level-MINXP.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/level/MinxpToken.class" /> + </patternset> + </fileset> + </jar> + <!-- Eqslot tokens--> + <jar jarfile="${systemlstplugins.dir}/Eqslot-CONTAINS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/eqslot/ContainsToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Eqslot-EQSLOT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/eqslot/EqslotToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Eqslot-NUMBER.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/eqslot/NumberToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Eqslot-NUMSLOTS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/eqslot/NumslotsToken.class" /> + </patternset> + </fileset> + </jar> + <!-- Load tokens--> + <jar jarfile="${systemlstplugins.dir}/Load-ENCUMBRANCE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/load/EncumbranceToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Load-LOAD.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/load/LoadToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Load-LOADMULT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/load/LoadmultToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Load-MODIFIER.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/load/ModifierToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Load-SIZEMULT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/load/SizemultToken.class" /> + </patternset> + </fileset> + </jar> + <!-- Paper tokens--> + <jar jarfile="${systemlstplugins.dir}/Paper-NAME.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/paper/NameToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Paper-HEIGHT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/paper/HeightToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Paper-WIDTH.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/paper/WidthToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Paper-TOPMARGIN.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/paper/TopmarginToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Paper-BOTTOMMARGIN.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/paper/BottommarginToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Paper-LEFTMARGIN.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/paper/LeftmarginToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Paper-RIGHTMARGIN.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/paper/RightmarginToken.class" /> + </patternset> + </fileset> + </jar> </target> <target name="jar-deprecated-plugin" depends="manifest" description="Build (Link) plugin jar files"> Modified: Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2006-03-09 00:46:20 UTC (rev 133) +++ Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2006-03-09 00:45:50 UTC (rev 134) @@ -25,6 +25,17 @@ */ package pcgen.core; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.StringTokenizer; +import java.util.TreeSet; + import pcgen.core.levelability.LevelAbility; import pcgen.core.prereq.PrereqHandler; import pcgen.core.utils.CoreUtility; @@ -33,8 +44,6 @@ import pcgen.util.chooser.ChooserFactory; import pcgen.util.chooser.ChooserInterface; -import java.util.*; - /** * <code>PCTemplate</code>. * @@ -91,7 +100,13 @@ private int nonProficiencyPenalty = 1; private int templateVisible = VISIBILITY_DEFAULT; private String raceType = ""; + private Integer hands; + private Integer legs; + private Integer reach; + + private Point2D.Double face = new Point2D.Double(5, 0); + private ArrayList addedSubTypes = new ArrayList(); private ArrayList removedSubTypes = new ArrayList(); @@ -1463,4 +1478,49 @@ return level >= Integer.parseInt(stuff.nextToken()); } + + public void setFace(final double width, final double height) + { + face = new Point2D.Double(width, height); + } + + public Point2D.Double getFace() + { + return face; + } + + public void setHands(final int newHands) + { + hands = new Integer(newHands); + } + + /** + * Made public for use on equipping tab -- bug 586332 + * sage_sam, 22 Nov 2002 + * @return hands + */ + public Integer getHands() + { + return hands; + } + + public void setLegs(final int argLegs) + { + legs = new Integer(argLegs); + } + + public Integer getLegs() + { + return legs; + } + + public void setReach(final int newReach) + { + reach = new Integer(newReach); + } + + public Integer getReach() + { + return reach; + } } Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/EquipSlotLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/EquipSlotLoader.java 2006-03-09 00:46:20 UTC (rev 133) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/EquipSlotLoader.java 2006-03-09 00:45:50 UTC (rev 134) @@ -71,13 +71,24 @@ } EquipSlotLstToken token = (EquipSlotLstToken) tokenMap.get(key); - if (token != null) + //TODO: (DJ) Sick hack, remove in 5.11.x + if(token != null && key.equals("NUMSLOTS")) { final String value = colString.substring(idxColon + 1); LstUtils.deprecationCheck(token, eqSlot.getSlotName(), sourceURL.toString(), value); + if (!token.parse(eqSlot, lstLine)) + { + Logging.errorPrint("Error parsing equip slots " + eqSlot.getSlotName() + ':' + sourceURL + ':' + colString + "\""); + } + break; + } + else if (token != null) + { + final String value = colString.substring(idxColon + 1); + LstUtils.deprecationCheck(token, eqSlot.getSlotName(), sourceURL.toString(), value); if (!token.parse(eqSlot, value)) { - Logging.errorPrint("Error parsing ability " + eqSlot.getSlotName() + ':' + sourceURL + ':' + colString + "\""); + Logging.errorPrint("Error parsing equip slots " + eqSlot.getSlotName() + ':' + sourceURL + ':' + colString + "\""); } } else Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/LoadInfoLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/LoadInfoLoader.java 2006-03-09 00:46:20 UTC (rev 133) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/LoadInfoLoader.java 2006-03-09 00:45:50 UTC (rev 134) @@ -25,13 +25,14 @@ */ package pcgen.persistence.lst; +import java.net.URL; +import java.util.Map; + import pcgen.core.SystemCollections; import pcgen.core.system.LoadInfo; import pcgen.persistence.PersistenceLayerException; import pcgen.util.Logging; -import java.net.URL; - /** * @author Stefan Radermacher <zaister@...> * @version $Revision: 1.9 $ @@ -72,54 +73,31 @@ { LoadInfo loadInfo = SystemCollections.getLoadInfo(getGameMode()); + Map tokenMap = TokenStore.inst().getTokenMap(LoadInfoLstToken.class); - if (lstLine.startsWith("ENCUMBRANCE:") || lstLine.startsWith("ENCUMBERANCE:")) + final int idxColon = lstLine.indexOf(':'); + String key = ""; + try { + key = lstLine.substring(0, idxColon); + } + catch(StringIndexOutOfBoundsException e) { + // TODO Handle Exception + } + LoadInfoLstToken token = (LoadInfoLstToken) tokenMap.get(key); - String[] fields = lstLine.substring(lstLine.indexOf(':') + 1 ).split("\\|"); - if ((fields.length < 2) || (fields.length > 4)) + if (token != null) + { + final String value = lstLine.substring(idxColon + 1); + LstUtils.deprecationCheck(token, loadInfo.toString(), "level.lst", value); + if (!token.parse(loadInfo, value)) { - Logging.errorPrint("LoadInfoLoader got unexpected line '" + lstLine + ". Line ignored."); - return; + Logging.errorPrint("Error parsing ability " + loadInfo + ':' + "level.lst" + ':' + lstLine + "\""); } - - String moveFormula = ""; - if (fields.length >= 3) - { - moveFormula = fields[2]; - } - - Integer checkPenalty = new Integer(0); - if (fields.length == 4) - { - checkPenalty = new Integer(fields[3]); - } - - String type = fields[0]; - String[] number = fields[1].split("/"); - if (number.length == 1) - { - Float a = new Float(fields[1]); - loadInfo.addLoadMultiplier(type.toUpperCase(), new Float(a.doubleValue()), moveFormula, checkPenalty); - } - else if (number.length == 2) - { - Float a = new Float(number[0]); - Float b = new Float(number[1]); - loadInfo.addLoadMultiplier(type.toUpperCase(), new Float(a.doubleValue() / b.doubleValue()), moveFormula, checkPenalty); - } - else - { - Logging.errorPrint("LoadInfoLoader got unexpected line '" + lstLine + ". Line ignored."); - return; - } } - else if (lstLine.startsWith("MODIFIER:")) - { - loadInfo.setLoadModifierFormula(lstLine.substring(9)); - } else { + LstUtils.deprecationWarning("Using deprecated style of load.lst. Please consult the docs for information about the new style load.lst"); String[] sets = lstLine.split(","); if (sets.length > 1) { Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/LoadInfoLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/LoadInfoLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/LoadInfoLstToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,42 @@ +/* + * LoadInfoLstToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:16 AM + * + * Current Ver: $Revision: 1.1 $ + * Last Editor: $Author: soulcatcher $ + * Last Edited: $Date: 2006/02/18 01:17:15 $ + * + */ +package pcgen.persistence.lst; + +import pcgen.core.system.LoadInfo; + +/** + * <code>LoadInfoLstToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public interface LoadInfoLstToken extends LstToken { + /** + * @param loadInfo + * @param value + * @return true if parse OK + */ + public abstract boolean parse(LoadInfo loadInfo, String value); +} Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/PaperInfoLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/PaperInfoLoader.java 2006-03-09 00:46:20 UTC (rev 133) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/PaperInfoLoader.java 2006-03-09 00:45:50 UTC (rev 134) @@ -30,6 +30,7 @@ import pcgen.util.Logging; import java.net.URL; +import java.util.Map; import java.util.StringTokenizer; /** @@ -61,23 +62,47 @@ { final PaperInfo psize = new PaperInfo(); - final StringTokenizer aTok = new StringTokenizer(lstLine, "\t"); + final StringTokenizer colToken = new StringTokenizer(lstLine, "\t"); int iCount = 0; - while (aTok.hasMoreElements()) + Map tokenMap = TokenStore.inst().getTokenMap(PaperInfoLstToken.class); + while (colToken.hasMoreTokens()) { - final String colString = (String) aTok.nextElement(); + final String colString = colToken.nextToken().trim(); + final int idxColon = colString.indexOf(':'); + String key = ""; try { - psize.setPaperInfo(iCount, colString); + key = colString.substring(0, idxColon); } - catch (IndexOutOfBoundsException e) + catch(StringIndexOutOfBoundsException e) { + // TODO Handle Exception + } + PaperInfoLstToken token = (PaperInfoLstToken) tokenMap.get(key); + + if (token != null) { - Logging.errorPrint("Illegal paper size info '" + lstLine + "' in " + sourceURL.toString()); + final String value = colString.substring(idxColon + 1); + LstUtils.deprecationCheck(token, psize.toString(), sourceURL.toString(), value); + if (!token.parse(psize, value)) + { + Logging.errorPrint("Error parsing equip slots " + psize.toString() + ':' + sourceURL + ':' + colString + "\""); + } } - - iCount += 1; + else { + LstUtils.deprecationWarning("Using deprecated style of paperinfo.lst. Please consult the docs for information about the new style paperinfo.lst"); + try + { + psize.setPaperInfo(iCount, colString); + } + catch (IndexOutOfBoundsException e) + { + Logging.errorPrint("Illegal paper size info '" + lstLine + "' in " + sourceURL.toString()); + } + + iCount += 1; + } } SystemCollections.addToPaperInfoList(psize, gameMode); Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/PaperInfoLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/PaperInfoLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/PaperInfoLstToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,42 @@ +/* + * PaperInfoLstToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:16 AM + * + * Current Ver: $Revision: 1.1 $ + * Last Editor: $Author: soulcatcher $ + * Last Edited: $Date: 2006/02/18 01:17:15 $ + * + */ +package pcgen.persistence.lst; + +import pcgen.core.PaperInfo; + +/** + * <code>PaperInfoLstToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public interface PaperInfoLstToken extends LstToken { + /** + * @param paperInfo + * @param value + * @return true if parse OK + */ + public abstract boolean parse(PaperInfo paperInfo, String value); +} Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java 2006-03-09 00:46:20 UTC (rev 133) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java 2006-03-09 00:45:50 UTC (rev 134) @@ -88,6 +88,12 @@ //equipmentslots.lst tokenTypeList.add(EquipSlotLstToken.class); + + //load.lst + tokenTypeList.add(LoadInfoLstToken.class); + + //paperinfo.lst + tokenTypeList.add(PaperInfoLstToken.class); } /** Added: Trunk/pcgen/code/src/java/plugin/lsttokens/load/EncumbranceToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/load/EncumbranceToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/load/EncumbranceToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,80 @@ +/* + * EncumbranceToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:02 AM + * + * Current Ver: $Revision: 1.3 $ + * Last Editor: $Author: soulcatcher $ + * Last Edited: $Date: 2006/02/16 01:03:16 $ + * + */ +package plugin.lsttokens.load; + +import java.util.StringTokenizer; + +import pcgen.core.system.LoadInfo; +import pcgen.persistence.lst.LoadInfoLstToken; + + +/** + * <code>EncumbranceToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public class EncumbranceToken implements LoadInfoLstToken { + + public String getTokenName() { + return "ENCUMBRANCE"; + } + + public boolean parse(LoadInfo loadInfo, String value) { + final StringTokenizer token = new StringTokenizer(value, "|"); + if(token.countTokens() < 2 || token.countTokens() > 4) { + return false; + } + + try { + String moveFormula = ""; + Integer checkPenalty = new Integer(0); + String type = token.nextToken(); + String number = token.nextToken(); + + if (token.hasMoreTokens() && value.indexOf("||") == -1) { + moveFormula = token.nextToken(); + } + + if (token.hasMoreTokens()) { + checkPenalty = new Integer(token.nextToken()); + } + + double mult = 0; + if (number.indexOf("/") == -1) { + mult = Double.parseDouble(number); + } + else { + final StringTokenizer numTok = new StringTokenizer(number, "/"); + mult = Double.parseDouble(numTok.nextToken()) / Double.parseDouble(numTok.nextToken()); + } + loadInfo.addLoadMultiplier(type.toUpperCase(), new Float(mult), moveFormula, checkPenalty); + } + catch(Exception e) { + return false; + } + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/load/LoadToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/load/LoadToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/load/LoadToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,60 @@ +/* + * LoadToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:02 AM + * + * Current Ver: $Revision: 1.3 $ + * Last Editor: $Author: soulcatcher $ + * Last Edited: $Date: 2006/02/16 01:03:16 $ + * + */ +package plugin.lsttokens.load; + +import java.util.StringTokenizer; + +import pcgen.core.system.LoadInfo; +import pcgen.persistence.lst.LoadInfoLstToken; + + +/** + * <code>LoadToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public class LoadToken implements LoadInfoLstToken { + + public String getTokenName() { + return "LOAD"; + } + + public boolean parse(LoadInfo loadInfo, String value) { + final StringTokenizer token = new StringTokenizer(value, "|"); + if(token.countTokens() != 2) { + return false; + } + try { + int str = Integer.parseInt(token.nextToken()); + Float num = new Float(token.nextToken()); + loadInfo.addLoadScoreValue(str, num); + } + catch(Exception e) { + return false; + } + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/load/LoadmultToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/load/LoadmultToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/load/LoadmultToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,52 @@ +/* + * LoadmultToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:02 AM + * + * Current Ver: $Revision: 1.3 $ + * Last Editor: $Author: soulcatcher $ + * Last Edited: $Date: 2006/02/16 01:03:16 $ + * + */ +package plugin.lsttokens.load; + +import pcgen.core.system.LoadInfo; +import pcgen.persistence.lst.LoadInfoLstToken; + + +/** + * <code>LoadmultToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public class LoadmultToken implements LoadInfoLstToken { + + public String getTokenName() { + return "LOADMULT"; + } + + public boolean parse(LoadInfo loadInfo, String value) { + try { + loadInfo.setLoadScoreMultiplier(new Float(value)); + } + catch(Exception e) { + return false; + } + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/load/ModifierToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/load/ModifierToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/load/ModifierToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,47 @@ +/* + * ModifierToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:02 AM + * + * Current Ver: $Revision: 1.3 $ + * Last Editor: $Author: soulcatcher $ + * Last Edited: $Date: 2006/02/16 01:03:16 $ + * + */ +package plugin.lsttokens.load; + +import pcgen.core.system.LoadInfo; +import pcgen.persistence.lst.LoadInfoLstToken; + + +/** + * <code>ModifierToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public class ModifierToken implements LoadInfoLstToken { + + public String getTokenName() { + return "MODIFIER"; + } + + public boolean parse(LoadInfo loadInfo, String value) { + loadInfo.setLoadModifierFormula(value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/load/SizemultToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/load/SizemultToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/load/SizemultToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,60 @@ +/* + * SizemultToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:02 AM + * + * Current Ver: $Revision: 1.3 $ + * Last Editor: $Author: soulcatcher $ + * Last Edited: $Date: 2006/02/16 01:03:16 $ + * + */ +package plugin.lsttokens.load; + +import java.util.StringTokenizer; + +import pcgen.core.system.LoadInfo; +import pcgen.persistence.lst.LoadInfoLstToken; + + +/** + * <code>SizemultToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public class SizemultToken implements LoadInfoLstToken { + + public String getTokenName() { + return "SIZEMULT"; + } + + public boolean parse(LoadInfo loadInfo, String value) { + final StringTokenizer token = new StringTokenizer(value, "|"); + if(token.countTokens() != 2) { + return false; + } + try { + String size = token.nextToken().substring(0,1); + Float num = new Float(token.nextToken()); + loadInfo.addSizeAdjustment(size, num); + } + catch(Exception e) { + return false; + } + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/paper/BottommarginToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/paper/BottommarginToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/paper/BottommarginToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,48 @@ +/* + * BottommarginToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:02 AM + * + * Current Ver: $Revision: 1.3 $ + * Last Editor: $Author: soulcatcher $ + * Last Edited: $Date: 2006/02/16 01:03:16 $ + * + */ +package plugin.lsttokens.paper; + +import pcgen.core.Constants; +import pcgen.core.PaperInfo; +import pcgen.persistence.lst.PaperInfoLstToken; + + +/** + * <code>BottommarginToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public class BottommarginToken implements PaperInfoLstToken { + + public String getTokenName() { + return "BOTTOMMARGIN"; + } + + public boolean parse(PaperInfo paperInfo, String value) { + paperInfo.setPaperInfo(Constants.PAPERINFO_BOTTOMMARGIN, value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/paper/HeightToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/paper/HeightToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/paper/HeightToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,48 @@ +/* + * HeightToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:02 AM + * + * Current Ver: $Revision: 1.3 $ + * Last Editor: $Author: soulcatcher $ + * Last Edited: $Date: 2006/02/16 01:03:16 $ + * + */ +package plugin.lsttokens.paper; + +import pcgen.core.Constants; +import pcgen.core.PaperInfo; +import pcgen.persistence.lst.PaperInfoLstToken; + + +/** + * <code>HeightToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public class HeightToken implements PaperInfoLstToken { + + public String getTokenName() { + return "HEIGHT"; + } + + public boolean parse(PaperInfo paperInfo, String value) { + paperInfo.setPaperInfo(Constants.PAPERINFO_HEIGHT, value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/paper/LeftmarginToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/paper/LeftmarginToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/paper/LeftmarginToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,48 @@ +/* + * LeftmarginToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:02 AM + * + * Current Ver: $Revision: 1.3 $ + * Last Editor: $Author: soulcatcher $ + * Last Edited: $Date: 2006/02/16 01:03:16 $ + * + */ +package plugin.lsttokens.paper; + +import pcgen.core.Constants; +import pcgen.core.PaperInfo; +import pcgen.persistence.lst.PaperInfoLstToken; + + +/** + * <code>LeftmarginToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public class LeftmarginToken implements PaperInfoLstToken { + + public String getTokenName() { + return "LEFTMARGIN"; + } + + public boolean parse(PaperInfo paperInfo, String value) { + paperInfo.setPaperInfo(Constants.PAPERINFO_LEFTMARGIN, value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/paper/NameToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/paper/NameToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/paper/NameToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,48 @@ +/* + * NameToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:02 AM + * + * Current Ver: $Revision: 1.3 $ + * Last Editor: $Author: soulcatcher $ + * Last Edited: $Date: 2006/02/16 01:03:16 $ + * + */ +package plugin.lsttokens.paper; + +import pcgen.core.Constants; +import pcgen.core.PaperInfo; +import pcgen.persistence.lst.PaperInfoLstToken; + + +/** + * <code>NameToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public class NameToken implements PaperInfoLstToken { + + public String getTokenName() { + return "NAME"; + } + + public boolean parse(PaperInfo paperInfo, String value) { + paperInfo.setPaperInfo(Constants.PAPERINFO_NAME, value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/paper/RightmarginToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/paper/RightmarginToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/paper/RightmarginToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,48 @@ +/* + * RightmarginToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:02 AM + * + * Current Ver: $Revision: 1.3 $ + * Last Editor: $Author: soulcatcher $ + * Last Edited: $Date: 2006/02/16 01:03:16 $ + * + */ +package plugin.lsttokens.paper; + +import pcgen.core.Constants; +import pcgen.core.PaperInfo; +import pcgen.persistence.lst.PaperInfoLstToken; + + +/** + * <code>RightmarginToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public class RightmarginToken implements PaperInfoLstToken { + + public String getTokenName() { + return "RIGHTMARGIN"; + } + + public boolean parse(PaperInfo paperInfo, String value) { + paperInfo.setPaperInfo(Constants.PAPERINFO_RIGHTMARGIN, value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/paper/TopmarginToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/paper/TopmarginToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/paper/TopmarginToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,48 @@ +/* + * TopmarginToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:02 AM + * + * Current Ver: $Revision: 1.3 $ + * Last Editor: $Author: soulcatcher $ + * Last Edited: $Date: 2006/02/16 01:03:16 $ + * + */ +package plugin.lsttokens.paper; + +import pcgen.core.Constants; +import pcgen.core.PaperInfo; +import pcgen.persistence.lst.PaperInfoLstToken; + + +/** + * <code>TopmarginToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public class TopmarginToken implements PaperInfoLstToken { + + public String getTokenName() { + return "TOPMARGIN"; + } + + public boolean parse(PaperInfo paperInfo, String value) { + paperInfo.setPaperInfo(Constants.PAPERINFO_TOPMARGIN, value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/paper/WidthToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/paper/WidthToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/paper/WidthToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,48 @@ +/* + * WidthToken.java + * Copyright 2006 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:02 AM + * + * Current Ver: $Revision: 1.3 $ + * Last Editor: $Author: soulcatcher $ + * Last Edited: $Date: 2006/02/16 01:03:16 $ + * + */ +package plugin.lsttokens.paper; + +import pcgen.core.Constants; +import pcgen.core.PaperInfo; +import pcgen.persistence.lst.PaperInfoLstToken; + + +/** + * <code>WidthToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public class WidthToken implements PaperInfoLstToken { + + public String getTokenName() { + return "WIDTH"; + } + + public boolean parse(PaperInfo paperInfo, String value) { + paperInfo.setPaperInfo(Constants.PAPERINFO_WIDTH, value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/FaceToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/FaceToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/FaceToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,48 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + +/** + * Class deals with FACE Token + */ +public class FaceToken implements PCTemplateLstToken { + + public String getTokenName() { + return "FACE"; + } + + public boolean parse(PCTemplate template, String value) { + if(value.indexOf(",") > -1) { + double width; + double height; + try { + width = Double.parseDouble(value.substring(0, value.indexOf(",") - 1).trim()); + } + catch (NumberFormatException nfe) { + width = 5; + } + + try { + height = Double.parseDouble(value.substring(value.indexOf(",") + 1).trim()); + } + catch (NumberFormatException ne) { + height = 5; + } + template.setFace(width, height); + } + else { + double width; + try { + width = Double.parseDouble(value); + } + catch (NumberFormatException nfe) { + width = 5; + } + template.setFace(width, 0); + } + return true; + } +} + + Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/HandsToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/HandsToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/HandsToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,24 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + +/** + * Class deals with HANDS Token + */ +public class HandsToken implements PCTemplateLstToken { + + public String getTokenName() { + return "HANDS"; + } + + public boolean parse(PCTemplate template, String value) { + try { + template.setHands(Integer.parseInt(value)); + return true; + } + catch(NumberFormatException nfe) { + return false; + } + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/LegsToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/LegsToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/LegsToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,24 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + +/** + * Class deals with LEGS Token + */ +public class LegsToken implements PCTemplateLstToken { + + public String getTokenName() { + return "LEGS"; + } + + public boolean parse(PCTemplate template, String value) { + try { + template.setLegs(Integer.parseInt(value)); + return true; + } + catch(NumberFormatException nfe) { + return false; + } + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/template/ReachToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/ReachToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/ReachToken.java 2006-03-09 00:45:50 UTC (rev 134) @@ -0,0 +1,24 @@ +package plugin.lsttokens.template; + +import pcgen.core.PCTemplate; +import pcgen.persistence.lst.PCTemplateLstToken; + +/** + * Class deals with REACH Token + */ +public class ReachToken implements PCTemplateLstToken { + + public String getTokenName() { + return "REACH"; + } + + public boolean parse(PCTemplate template, String value) { + try { + template.setReach(Integer.parseInt(value)); + return true; + } + catch(NumberFormatException nfe) { + return false; + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <soulcatcher@us...> - 2006-03-26 00:06:04
|
Revision: 449 Author: soulcatcher Date: 2006-03-25 16:05:38 -0800 (Sat, 25 Mar 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=449&view=rev Log Message: ----------- adding the rest of teh sponsor code Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/Globals.java Trunk/pcgen/code/src/java/pcgen/core/SettingsHandler.java Trunk/pcgen/code/src/java/pcgen/gui/MainAbout.java Trunk/pcgen/code/src/java/pcgen/gui/MainSource.java Trunk/pcgen/code/src/java/pcgen/gui/PCGen_Frame1.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 Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/persistence/lst/SponsorLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/SponsorLstToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/ Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/ImagebannerToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/ImagelargeToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/ImagesmallToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/NameToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/SponsorToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/TextToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-03-26 00:00:46 UTC (rev 448) +++ Trunk/pcgen/code/pluginbuild.xml 2006-03-26 00:05:38 UTC (rev 449) @@ -5622,6 +5622,49 @@ </patternset> </fileset> </jar> + <!-- Sponsor tokens--> + <jar jarfile="${systemlstplugins.dir}/Sponsor-IMAGEBANNER.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/sponsor/ImagebannerToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Sponsor-IMAGELARGE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/sponsor/ImagelargeToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Sponsor-IMAGESMALL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/sponsor/ImagesmallToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Sponsor-NAME.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/sponsor/NameToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Sponsor-SPONSOR.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/sponsor/SponsorToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/Sponsor-TEXT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/sponsor/TextToken.class" /> + </patternset> + </fileset> + </jar> </target> <target name="jar-deprecated-plugin" depends="manifest" description="Build (Link) plugin jar files"> Modified: Trunk/pcgen/code/src/java/pcgen/core/Globals.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2006-03-26 00:00:46 UTC (rev 448) +++ Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2006-03-26 00:05:38 UTC (rev 449) @@ -115,6 +115,9 @@ 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(); /** Weapon proficiency Data storage */ private static final WeaponProfDataStore weaponProfs = new WeaponProfDataStore(); @@ -4082,4 +4085,17 @@ return path; } + + public static void addSponsor(Map sponsor) { + sponsors.put(sponsor.get("SPONSOR"), sponsor); + sponsorList.add(sponsor); + } + + public static List getSponsors() { + return sponsorList; + } + + public static Map getSponsor(String name) { + return (Map)sponsors.get(name); + } } Modified: Trunk/pcgen/code/src/java/pcgen/core/SettingsHandler.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/SettingsHandler.java 2006-03-26 00:00:46 UTC (rev 448) +++ Trunk/pcgen/code/src/java/pcgen/core/SettingsHandler.java 2006-03-26 00:05:38 UTC (rev 449) @@ -100,6 +100,7 @@ private static boolean showD20InfoAtStart = true; private static boolean loadURLs = false; private static boolean showOGLOnLoad = true; + private static boolean showSponsorsOnLoad = true; private static boolean hpMaxAtFirstLevel = true; private static int hpRollMethod = Constants.HP_STANDARD; private static int hpPct = 100; @@ -140,6 +141,7 @@ private static File pcgenCustomDir = new File(Globals.getDefaultPath() + File.separator + "data" + File.separator //$NON-NLS-1$ + "customsources"); //$NON-NLS-1$ private static File pcgenVendorDataDir = new File(Globals.getDefaultPath() + File.separator + "vendordata"); //$NON-NLS-1$ + private static File pcgenSponsorDir = new File(Globals.getDefaultPath() + File.separator + "system" + File.separator + "sponsors"); //$NON-NLS-1$ private static File pcgenDocsDir = null; /** @@ -1109,6 +1111,7 @@ loadURLs = getPCGenOption("loadURLs", false); //$NON-NLS-1$ allowOverride = getPCGenOption("allowOverride", false); //$NON-NLS-1$ showOGLOnLoad = getPCGenOption("showOGLOnLoad", true); //$NON-NLS-1$ + showSponsorsOnLoad = getPCGenOption("showSponsorsOnLoad", true); //$NON-NLS-1$ Globals.setSourceDisplay(getPCGenOption("sourceDisplay", Constants.SOURCELONG)); //$NON-NLS-1$ Globals.setLanguage(getPCGenOption("language", null)); //$NON-NLS-1$ //$NON-NLS-2$ @@ -1547,6 +1550,7 @@ setPCGenOption("showImagePreview", isShowImagePreview()); //$NON-NLS-1$ setPCGenOption("showNatWeaponTab", showNatWeaponTab); //$NON-NLS-1$ setPCGenOption("showOGLOnLoad", showOGLOnLoad); //$NON-NLS-1$ + setPCGenOption("showSponsorsOnLoad", showSponsorsOnLoad); //$NON-NLS-1$ setPCGenOption("showStatDialogAtLevelUp", getShowStatDialogAtLevelUp()); //$NON-NLS-1$ setPCGenOption("showTipOfTheDay", getShowTipOfTheDay()); //$NON-NLS-1$ setPCGenOption("showToolBar", isShowToolBar()); //$NON-NLS-1$ @@ -1662,6 +1666,16 @@ return pcgenVendorDataDir; } + public static void setPcgenSponsorDir(final File aFile) + { + pcgenSponsorDir = aFile; + } + + public static File getPcgenSponsorDir() + { + return pcgenSponsorDir; + } + public static void setPcgenDocsDir(final File argPcgenDocsDir) { pcgenDocsDir = argPcgenDocsDir; @@ -2121,6 +2135,11 @@ showOGLOnLoad = arg; } + public static void setShowSponsors(final boolean arg) + { + showSponsorsOnLoad = arg; + } + /** * Sets whether the Stat dialog should be shown at level up. * @param argShowStatDialogAtLevelUp Should the Stat dialog should be shown at level up? @@ -2460,6 +2479,10 @@ return showOGLOnLoad; } + public static boolean showSponsors() { + return showSponsorsOnLoad; + } + public static boolean showNaturalWeaponTab() { return showNatWeaponTab; Modified: Trunk/pcgen/code/src/java/pcgen/gui/MainAbout.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/MainAbout.java 2006-03-26 00:00:46 UTC (rev 448) +++ Trunk/pcgen/code/src/java/pcgen/gui/MainAbout.java 2006-03-26 00:05:38 UTC (rev 449) @@ -25,8 +25,11 @@ */ package pcgen.gui; +import pcgen.core.Globals; import pcgen.gui.utils.BrowserLauncher; import pcgen.gui.utils.IconUtilitities; +import pcgen.gui.utils.JLabelPane; +import pcgen.persistence.lst.SponsorLoader; import pcgen.util.Logging; import pcgen.util.PropertyFactory; @@ -34,7 +37,10 @@ import javax.swing.*; import javax.swing.border.BevelBorder; +import javax.swing.border.Border; import javax.swing.border.EmptyBorder; +import javax.swing.border.TitledBorder; + import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -42,6 +48,8 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; +import java.util.List; +import java.util.Map; /** * Create a simple panel to identify the program and those who contributed @@ -89,6 +97,7 @@ mainPane.add(PropertyFactory.getString("in_abt_libraries"), buildIncludesPanel()); //$NON-NLS-1$ mainPane.add(PropertyFactory.getString("in_abt_license"), buildLicensePanel()); //$NON-NLS-1$ mainPane.add(PropertyFactory.getString("in_abt_awards"), buildAwardsPanel()); //$NON-NLS-1$ + mainPane.add(PropertyFactory.getString("in_abt_sponsors"), buildSponsorsPanel()); //$NON-NLS-1$ setLayout(new BorderLayout()); @@ -364,6 +373,37 @@ return panel; } + private JPanel buildSponsorsPanel() + { + Border etched = null; + TitledBorder title = BorderFactory.createTitledBorder(etched, "Sponsor Info"); + title.setTitleJustification(TitledBorder.CENTER); + JLabelPane sponsorLabel = new JLabelPane(); + JScrollPane sp = new JScrollPane(sponsorLabel); + sp.setBorder(title); + JPanel panel = new JPanel(new BorderLayout()); + sponsorLabel.setBackground(panel.getBackground()); + panel.add(BorderLayout.CENTER, sp); + + List sponsors = Globals.getSponsors(); + StringBuffer sb = new StringBuffer(); + sb.append("<html><b>Our Sponsors</b><br>"); + for(int i = 0; i < sponsors.size(); i++) { + Map sponsor = (Map)sponsors.get(i); + if(sponsor.get("SPONSOR").equals("PCGEN")) { + continue; + } + + sb.append("<img src='") + .append(SponsorLoader.getConvertedSponsorPath((String)sponsor.get("IMAGEBANNER"))) + .append("'><br>"); + } + sb.append("</html>"); + sponsorLabel.setText(sb.toString()); + return panel; + } + + /** * Construct the license panel. This panel shows the full * text of the license under which PCGen is distributed. Modified: Trunk/pcgen/code/src/java/pcgen/gui/MainSource.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/MainSource.java 2006-03-26 00:00:46 UTC (rev 448) +++ Trunk/pcgen/code/src/java/pcgen/gui/MainSource.java 2006-03-26 00:05:38 UTC (rev 449) @@ -44,6 +44,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Map; import javax.swing.BorderFactory; import javax.swing.DefaultListSelectionModel; @@ -92,6 +93,7 @@ import pcgen.persistence.PersistenceLayerException; import pcgen.persistence.PersistenceManager; import pcgen.persistence.lst.CampaignSourceEntry; +import pcgen.persistence.lst.SponsorLoader; import pcgen.util.Logging; import pcgen.util.PropertyFactory; import pcgen.util.SwingWorker; @@ -387,12 +389,18 @@ path = pathNode.getItem().toString() + "." + path; } - StringBuffer b = new StringBuffer(); + StringBuffer sb = new StringBuffer(); // enclose the node-path name with the <p> tag so that we can parse for it later - b.append("<html><b>").append(path).append("</b><br>"); - b.append("</html>"); - infoLabel.setText(b.toString()); + sb.append("<html><b>").append(path).append("</b><br>"); + if(Globals.getSponsor(path) != null) { + Map sponsor = Globals.getSponsor(path); + sb.append("<img src='") + .append(SponsorLoader.getConvertedSponsorPath((String)sponsor.get("IMAGELARGE"))) + .append("'><br>"); + } + sb.append("</html>"); + infoLabel.setText(sb.toString()); } } } Modified: Trunk/pcgen/code/src/java/pcgen/gui/PCGen_Frame1.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/PCGen_Frame1.java 2006-03-26 00:00:46 UTC (rev 448) +++ Trunk/pcgen/code/src/java/pcgen/gui/PCGen_Frame1.java 2006-03-26 00:05:38 UTC (rev 449) @@ -2792,6 +2792,16 @@ }, "help.ogl", null, null, true); helpMenu.add(oglItem); + JMenuItem sponsorItem = Utility.createMenuItem("mnuHelpSponsors", + new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + pcGenGUI.showSponsors(); + } + }, "help.sponsors", null, null, true); + helpMenu.add(sponsorItem); + /* JMenuItem d20Item = CoreUtility.createMenuItem("mnuHelpD20", new ActionListener() { public void actionPerformed(ActionEvent e) Modified: Trunk/pcgen/code/src/java/pcgen/gui/PreferencesDialog.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/PreferencesDialog.java 2006-03-26 00:00:46 UTC (rev 448) +++ Trunk/pcgen/code/src/java/pcgen/gui/PreferencesDialog.java 2006-03-26 00:05:38 UTC (rev 449) @@ -129,6 +129,7 @@ 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"); @@ -265,6 +266,7 @@ private JCheckBox showToolbar = new JCheckBox(); private JCheckBox showWarningAtFirstLevelUp = new JCheckBox(); private JCheckBox showd20 = new JCheckBox(); + private JCheckBox showSponsors = new JCheckBox(); private JCheckBox statDialogShownAtLevelUp = new JCheckBox(); private JCheckBox showSkillModifier = new JCheckBox(); private JCheckBox enforceSpendingBeforeLevelUp = new JCheckBox(); @@ -871,6 +873,7 @@ SettingsHandler.setSaveCustomEquipment(saveCustom.isSelected()); SettingsHandler.setShowLicense(showOGL.isSelected()); SettingsHandler.setShowD20Info(showd20.isSelected()); + SettingsHandler.setShowSponsors(showSponsors.isSelected()); SettingsHandler.setLoadURLs(loadURL.isSelected()); SettingsHandler.setAllowOverride(allowOverride.isSelected()); @@ -1268,6 +1271,7 @@ saveCustom.setSelected(SettingsHandler.getSaveCustomEquipment()); showOGL.setSelected(SettingsHandler.showLicense()); showd20.setSelected(SettingsHandler.showD20Info()); + showSponsors.setSelected(SettingsHandler.showSponsors()); loadURL.setSelected(SettingsHandler.isLoadURLs()); allowOverride.setSelected(SettingsHandler.isAllowOverride()); @@ -2982,19 +2986,27 @@ sourcesPanel.add(showd20); Utility.buildConstraints(c, 0, 6, 3, 1, 0, 0); + label = new JLabel(in_displaySponsors + ": "); + gridbag.setConstraints(label, c); + sourcesPanel.add(label); + Utility.buildConstraints(c, 3, 6, 1, 1, 0, 0); + gridbag.setConstraints(showSponsors, c); + sourcesPanel.add(showSponsors); + + Utility.buildConstraints(c, 0, 7, 3, 1, 0, 0); label = new JLabel(in_sourceDisplay + ": "); gridbag.setConstraints(label, c); sourcesPanel.add(label); - Utility.buildConstraints(c, 3, 6, 1, 1, 0, 0); + Utility.buildConstraints(c, 3, 7, 1, 1, 0, 0); sourceOptions = new JComboBoxEx(new String[]{ in_sdLong, in_sdMedium, in_sdShort, in_sdPage, in_sdWeb }); gridbag.setConstraints(sourceOptions, c); sourcesPanel.add(sourceOptions); - Utility.buildConstraints(c, 0, 7, 3, 1, 0, 0); + Utility.buildConstraints(c, 0, 8, 3, 1, 0, 0); label = new JLabel(in_loadURLs + ": "); gridbag.setConstraints(label, c); sourcesPanel.add(label); - Utility.buildConstraints(c, 3, 7, 1, 1, 0, 0); + Utility.buildConstraints(c, 3, 8, 1, 1, 0, 0); gridbag.setConstraints(loadURL, c); sourcesPanel.add(loadURL); loadURL.addActionListener(new ActionListener() @@ -3009,11 +3021,11 @@ } }); - Utility.buildConstraints(c, 0, 8, 3, 1, 0, 0); + Utility.buildConstraints(c, 0, 9, 3, 1, 0, 0); label = new JLabel(in_allowOverride + ": "); gridbag.setConstraints(label, c); sourcesPanel.add(label); - Utility.buildConstraints(c, 3, 8, 1, 1, 0, 0); + Utility.buildConstraints(c, 3, 9, 1, 1, 0, 0); gridbag.setConstraints(allowOverride, c); sourcesPanel.add(allowOverride); Modified: Trunk/pcgen/code/src/java/pcgen/gui/pcGenGUI.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/pcGenGUI.java 2006-03-26 00:00:46 UTC (rev 448) +++ Trunk/pcgen/code/src/java/pcgen/gui/pcGenGUI.java 2006-03-26 00:05:38 UTC (rev 449) @@ -21,6 +21,42 @@ package pcgen.gui; import gmgen.pluginmgr.PluginLoader; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Observer; + +import javax.swing.ButtonGroup; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JEditorPane; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.UIManager; + import pcgen.core.Constants; import pcgen.core.Globals; import pcgen.core.PlayerCharacter; @@ -30,26 +66,20 @@ import pcgen.core.utils.MessageWrapper; import pcgen.core.utils.ShowMessageConsoleObserver; import pcgen.core.utils.ShowMessageDelegate; -import pcgen.gui.utils.*; +import pcgen.gui.utils.DialogInputInterface; +import pcgen.gui.utils.Hyperactive; +import pcgen.gui.utils.IconUtilitities; +import pcgen.gui.utils.ShowMessageGuiObserver; +import pcgen.gui.utils.SwingChooser; +import pcgen.gui.utils.SwingChooserRadio; +import pcgen.gui.utils.Utility; import pcgen.io.ExportHandler; import pcgen.io.PCGFile; +import pcgen.persistence.lst.SponsorLoader; import pcgen.util.InputFactory; import pcgen.util.Logging; import pcgen.util.chooser.ChooserFactory; -import javax.swing.*; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.*; -import java.util.Iterator; -import java.util.List; -import java.util.Observer; - /** * <code>pcGenGUI</code> is the Main-Class for the application. * It creates an unreferenced copy of itself, basically so that @@ -518,6 +548,73 @@ aFrame.setVisible(true); } + public static void showSponsors() + { + String title = "PCGen's sponsors"; + + final JFrame aFrame = new JFrame(title); + final JButton jClose = new JButton("Close"); + final JPanel jPanel = new JPanel(); + final JCheckBox jCheckBox = new JCheckBox("Show on source load"); + jPanel.add(jCheckBox); + jCheckBox.setSelected(SettingsHandler.showSponsors()); + jCheckBox.addItemListener(new ItemListener() + { + public void itemStateChanged(ItemEvent evt) + { + SettingsHandler.setShowSponsors(jCheckBox.isSelected()); + } + }); + jPanel.add(jClose); + jClose.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent evt) + { + aFrame.dispose(); + } + }); + IconUtilitities.maybeSetIcon(aFrame, "PcgenIcon.gif"); + + StringBuffer sb = new StringBuffer(); + sb.append("<html>"); + sb.append("<img src='") + .append(SponsorLoader.getConvertedSponsorPath((String)Globals.getSponsor("PCGEN").get("IMAGEBANNER"))) + .append("'><br>"); + + String s = ""; + if(Globals.getSponsors().size() > 2) { + s = "s"; + } + sb.append("<H2><CENTER>Would like to thank our official sponsor") + .append(s) + .append(":</CENTER></h2>"); + List sponsors = Globals.getSponsors(); + int size = 172; + for(int i = 0; i < sponsors.size(); i++) { + Map sponsor = (Map)sponsors.get(i); + if(sponsor.get("SPONSOR").equals("PCGEN")) { + continue; + } + + size += 70; + sb.append("<img src='") + .append(SponsorLoader.getConvertedSponsorPath((String)sponsor.get("IMAGEBANNER"))) + .append("'><br>"); + } + sb.append("</html>"); + final JEditorPane a = new JEditorPane("text/html", sb.toString()); + a.setEditable(false); + + final JScrollPane aPane = new JScrollPane(); + aPane.setViewportView(a); + aFrame.getContentPane().setLayout(new BorderLayout()); + aFrame.getContentPane().add(aPane, BorderLayout.CENTER); + aFrame.getContentPane().add(jPanel, BorderLayout.SOUTH); + aFrame.setSize(new Dimension(505, size)); + Utility.centerFrame(aFrame, false); + aFrame.setVisible(true); + } + public static void showMandatoryD20Info() { final ImageIcon imgIcon = IconUtilitities.getImageIcon("D20_logo_RGB.jpg"); Modified: Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2006-03-26 00:00:46 UTC (rev 448) +++ Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2006-03-26 00:05:38 UTC (rev 449) @@ -643,6 +643,8 @@ in_abt_awards=Awards +in_abt_sponsors=Sponsors + in_abt_awards_2005_ennie=2005 Gold ENnie winner for 'Best Electronic Product'. in_abt_awards_2003_ennie=2003 ENnie nominee for 'Best Resource Fan Site'. @@ -2430,6 +2432,8 @@ in_Prefs_displayd20=Display d20 Required Information on Source Load +in_Prefs_displaySponsors=Display Sponsors on Source Load + in_Prefs_loadURLs=Allow sources to be loaded from web links in_Prefs_allowOverride=Allow newer sources to override duplicate object from older sources Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java 2006-03-26 00:00:46 UTC (rev 448) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java 2006-03-26 00:05:38 UTC (rev 449) @@ -65,7 +65,6 @@ import pcgen.core.PCTemplate; import pcgen.core.PObject; import pcgen.core.PlayerCharacter; -import pcgen.core.Race; import pcgen.core.SettingsHandler; import pcgen.core.Skill; import pcgen.core.SourceUtilities; @@ -228,6 +227,7 @@ private PCClassLoader classLoader = new PCClassLoader(); private PaperInfoLoader paperLoader = new PaperInfoLoader(); private PointBuyLoader pointBuyLoader = new PointBuyLoader(); + private SponsorLoader sponsorLoader = new SponsorLoader(); private RaceLoader raceLoader = new RaceLoader(); private final Set sourcesSet = new TreeSet(); private BioSet bioSet = new BioSet(); @@ -272,6 +272,7 @@ classLoader.addObserver(this); paperLoader.addObserver(this); pointBuyLoader.addObserver(this); + sponsorLoader.addObserver(this); raceLoader.addObserver(this); sizeLoader.addObserver(this); skillLoader.addObserver(this); @@ -336,7 +337,8 @@ public void initialize() throws PersistenceLayerException { loadGameModes(); - + loadSponsorsLstFile(); + // Load the initial campaigns loadPCCFilesInDirectory(SettingsHandler.getPccFilesLocation().getAbsolutePath()); loadPCCFilesInDirectory(SettingsHandler.getPcgenVendorDataDir().getAbsolutePath()); @@ -348,6 +350,30 @@ } /** + * Load a game mode file. + * First try the game mode directory. If that fails, try + * 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 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 loadSponsorsLstFile() + { + final String systemPrefix = SettingsHandler.getPcgenSystemDir() + File.separator; + final String sponsorDirectory = systemPrefix + "sponsors" + File.separator; + + try + { + sponsorLoader.loadLstFile(sponsorDirectory + "sponsors.lst", null); + } + catch (PersistenceLayerException ple) + { + Logging.errorPrint("Warning: sponsors file is missing"); + } + } + + /** * @see pcgen.persistence.SystemLoader#loadCampaigns(List) */ public void loadCampaigns(final List aSelectedCampaignsList) @@ -475,6 +501,7 @@ PObjectLoader.finishFeatProcessing(); // Show the licenses showLicensesIfNeeded(); + showSponsorsIfNeeded(); } finally { @@ -2055,7 +2082,6 @@ } } } - } private void loadGameModes() @@ -2467,6 +2493,18 @@ showD20 = false; showLicensed = false; } + + private void showSponsorsIfNeeded() + { + // Only worry about it if we're using the GUI + if (Globals.getUseGUI()) + { + if (SettingsHandler.showSponsors()) + { + pcGenGUI.showSponsors(); + } + } + } /** * This method sorts the provided listof Campaign objects by rank. Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/SponsorLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/SponsorLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/SponsorLoader.java 2006-03-26 00:05:38 UTC (rev 449) @@ -0,0 +1,86 @@ +package pcgen.persistence.lst; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.Globals; +import pcgen.core.SettingsHandler; +import pcgen.core.utils.CoreUtility; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; + +/** + * This class loads in and parses the BASEDICE tag + */ +public class SponsorLoader extends LstLineFileLoader { + + /** Constructor */ + public SponsorLoader() { + } + + /** + * Parses a line + * @param gameMode + * @param lstLine + * @throws PersistenceLayerException + */ + public void parseLine(String lstLine, URL sourceURL) throws PersistenceLayerException { + StringTokenizer colToken = new StringTokenizer(lstLine, SystemLoader.TAB_DELIM); + Map sponsor = new HashMap(); + + Map tokenMap = TokenStore.inst().getTokenMap(SponsorLstToken.class); + while (colToken.hasMoreTokens()) { + final String colString = colToken.nextToken().trim(); + final int idxColon = colString.indexOf(':'); + String key = ""; + try { + key = colString.substring(0, idxColon); + } + catch(StringIndexOutOfBoundsException e) { + // TODO Deal with this exception + } + + SponsorLstToken token = (SponsorLstToken) tokenMap.get(key); + + if (token != null) + { + final String value = colString.substring(idxColon + 1).trim(); + LstUtils.deprecationCheck(token, "sponsors.lst", sourceURL.toString(), value); + if (!token.parse(sponsor, value)) { + Logging.errorPrint("Error parsing sponsor: from sponsors.lst "); + } + } + else { + Logging.errorPrint("Invalid sub tag " + token + " on SPONSOR line"); + throw new PersistenceLayerException("Invalid sub tag " + token + " on SPONSOR line"); + } + } + Globals.addSponsor(sponsor); + } + + public static String getConvertedSponsorPath(String file) { + String convertedPath = SettingsHandler.getPcgenSponsorDir().getAbsolutePath() + File.separator + file; + // Not a URL; make sure to fix the path syntax + convertedPath = CoreUtility.fixFilenamePath(convertedPath); + + // Make sure the path starts with a separator + if (!convertedPath.startsWith(File.separator)) + { + convertedPath = File.separator + convertedPath; + } + + // Return the final result + try + { + return new URL("file:" + convertedPath).toString(); + } + catch (MalformedURLException e) {} + return ""; + } + +} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/SponsorLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/SponsorLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/SponsorLstToken.java 2006-03-26 00:05:38 UTC (rev 449) @@ -0,0 +1,42 @@ +/* + * SponsorLstToken.java + * Copyright 2005 (C) Devon Jones <soulcatcher@...> + * + * 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 2, 2002, 8:16 AM + * + * Current Ver: $Revision: 197 $ + * Last Editor: $Author: nuance $ + * Last Edited: $Date: 2006-03-14 15:59:43 -0700 (Tue, 14 Mar 2006) $ + * + */ +package pcgen.persistence.lst; + +import java.util.Map; + +/** + * <code>SponsorLstToken</code> + * + * @author Devon Jones <soulcatcher@...> + */ +public interface SponsorLstToken extends LstToken { + /** + * @param sponsor + * @param value + * @return true if parse OK + */ + public abstract boolean parse(Map sponsor, String value); +} Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java 2006-03-26 00:00:46 UTC (rev 448) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java 2006-03-26 00:05:38 UTC (rev 449) @@ -104,6 +104,9 @@ //paperinfo.lst tokenTypeList.add(PaperInfoLstToken.class); + + //sponsors.lst + tokenTypeList.add(SponsorLstToken.class); } /** Added: Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/ImagebannerToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/ImagebannerToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/ImagebannerToken.java 2006-03-26 00:05:38 UTC (rev 449) @@ -0,0 +1,20 @@ +package plugin.lsttokens.sponsor; + +import java.util.Map; + +import pcgen.persistence.lst.SponsorLstToken; + +/** + * Class deals with IMAGEBANNER Token + */ +public class ImagebannerToken implements SponsorLstToken { + + public String getTokenName() { + return "IMAGEBANNER"; + } + + public boolean parse(Map sponsor, String value) { + sponsor.put("IMAGEBANNER", value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/ImagelargeToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/ImagelargeToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/ImagelargeToken.java 2006-03-26 00:05:38 UTC (rev 449) @@ -0,0 +1,20 @@ +package plugin.lsttokens.sponsor; + +import java.util.Map; + +import pcgen.persistence.lst.SponsorLstToken; + +/** + * Class deals with IMAGELARGE Token + */ +public class ImagelargeToken implements SponsorLstToken { + + public String getTokenName() { + return "IMAGELARGE"; + } + + public boolean parse(Map sponsor, String value) { + sponsor.put("IMAGELARGE", value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/ImagesmallToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/ImagesmallToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/ImagesmallToken.java 2006-03-26 00:05:38 UTC (rev 449) @@ -0,0 +1,20 @@ +package plugin.lsttokens.sponsor; + +import java.util.Map; + +import pcgen.persistence.lst.SponsorLstToken; + +/** + * Class deals with IMAGESMALL Token + */ +public class ImagesmallToken implements SponsorLstToken { + + public String getTokenName() { + return "IMAGESMALL"; + } + + public boolean parse(Map sponsor, String value) { + sponsor.put("IMAGESMALL", value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/NameToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/NameToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/NameToken.java 2006-03-26 00:05:38 UTC (rev 449) @@ -0,0 +1,20 @@ +package plugin.lsttokens.sponsor; + +import java.util.Map; + +import pcgen.persistence.lst.SponsorLstToken; + +/** + * Class deals with NAME Token + */ +public class NameToken implements SponsorLstToken { + + public String getTokenName() { + return "NAME"; + } + + public boolean parse(Map sponsor, String value) { + sponsor.put("NAME", value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/SponsorToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/SponsorToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/SponsorToken.java 2006-03-26 00:05:38 UTC (rev 449) @@ -0,0 +1,20 @@ +package plugin.lsttokens.sponsor; + +import java.util.Map; + +import pcgen.persistence.lst.SponsorLstToken; + +/** + * Class deals with SPONSOR Token + */ +public class SponsorToken implements SponsorLstToken { + + public String getTokenName() { + return "SPONSOR"; + } + + public boolean parse(Map sponsor, String value) { + sponsor.put("SPONSOR", value); + return true; + } +} Added: Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/TextToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/TextToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/sponsor/TextToken.java 2006-03-26 00:05:38 UTC (rev 449) @@ -0,0 +1,20 @@ +package plugin.lsttokens.sponsor; + +import java.util.Map; + +import pcgen.persistence.lst.SponsorLstToken; + +/** + * Class deals with TEXT Token + */ +public class TextToken implements SponsorLstToken { + + public String getTokenName() { + return "TEXT"; + } + + public boolean parse(Map sponsor, String value) { + sponsor.put("TEXT", value); + return true; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jdempsey@us...> - 2006-05-28 01:17:08
|
Revision: 1039 Author: jdempsey Date: 2006-05-27 18:16:37 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=1039&view=rev Log Message: ----------- FReq: 1231443 - Whitespace in OS Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java Trunk/pcgen/code/testsuite/base.xml Trunk/pcgen/code/testsuite/csheets/BarJack.xml Trunk/pcgen/code/testsuite/csheets/BrdJoe.xml Trunk/pcgen/code/testsuite/csheets/CleElf.xml Trunk/pcgen/code/testsuite/csheets/CloudGiantHalfDragon.xml Trunk/pcgen/code/testsuite/csheets/DrakelingSorc.xml Trunk/pcgen/code/testsuite/csheets/FigFae.xml Trunk/pcgen/code/testsuite/csheets/JimDop.xml Trunk/pcgen/code/testsuite/csheets/MonKee.xml Trunk/pcgen/code/testsuite/csheets/SWizSam.xml Trunk/pcgen/code/testsuite/csheets/WizShar.xml Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/exporttokens/EndManualWhitespaceToken.java Trunk/pcgen/code/src/java/plugin/exporttokens/ManualWhitespaceToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-05-26 21:54:47 UTC (rev 1038) +++ Trunk/pcgen/code/pluginbuild.xml 2006-05-28 01:16:37 UTC (rev 1039) @@ -282,6 +282,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${outputplugins.dir}/ExportToken-ENDMANUALWHITESPACE.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/EndManualWhitespaceToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${outputplugins.dir}/ExportToken-EQCONTAINERS.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -457,6 +464,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${outputplugins.dir}/ExportToken-MANUALWHITESPACE.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/ManualWhitespaceToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${outputplugins.dir}/ExportToken-MAXCCSKILLLEVEL.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-26 21:54:47 UTC (rev 1038) +++ Trunk/pcgen/code/src/java/pcgen/io/ExportHandler.java 2006-05-28 01:16:37 UTC (rev 1039) @@ -50,6 +50,7 @@ // Processing state variables private boolean existsOnly = false; private boolean noMoreItems = false; + private boolean manualWhitespace = false; private File templateFile; private final Map loopVariables = new HashMap(); @@ -773,10 +774,10 @@ replaceLine(lineString, output, aPC); // output a newline if output is allowed -// if (canWrite) -// { -// FileAccess.newLine(output); -// } + if (canWrite && !manualWhitespace) + { + FileAccess.newLine(output); + } } } } @@ -849,10 +850,8 @@ noMoreItems = false; replaceLine(lineString, output, aPC); - // Karianna - These three lines were removed because they were creating extra spaces - // But have been put back in as the Text Export had no \n characters which - // meant that the text export was all on one line - Bug 1370444 - if (canWrite) + // Allow the output sheet author to control new lines. + if (canWrite && !manualWhitespace) { FileAccess.newLine(output); } @@ -1183,6 +1182,10 @@ if (aString.length() > 0) { + if (manualWhitespace) + { + aString = aString.replaceAll("[ \\t]", ""); + } FileAccess.write(output, aString); } } @@ -2288,8 +2291,12 @@ { len = aString.trim().length(); - if (aString.length() > 0) + if (manualWhitespace) { + aString = aString.replaceAll("[ \\t]", ""); + } + if (len > 0) + { FileAccess.write(output, aString); } } @@ -3059,8 +3066,16 @@ { if (!inPipe && (aLine.lastIndexOf('|') < 0)) { + if (manualWhitespace) + { + aLine = aLine.replaceAll("[ \\t]", ""); + } FileAccess.write(out, aLine); - FileAccess.newLine(out); + // Allow the output sheet author to control new lines. + if (!manualWhitespace) + { + FileAccess.newLine(out); + } } else if ((inPipe && (aLine.lastIndexOf('|') < 0)) || (!inPipe && (aLine.lastIndexOf('|') == 0))) { @@ -3085,6 +3100,10 @@ if (!inPipe) { + if (manualWhitespace) + { + bString = bString.replaceAll("[ \\t]", ""); + } FileAccess.write(out, bString); } else @@ -3171,6 +3190,7 @@ { if (x++ == 0) { + Logging.errorPrint("Outputing A '" + bString + "'."); FileAccess.write(out, cStartLineString); } @@ -3223,12 +3243,14 @@ } else { + Logging.errorPrint("Outputing B '" + eString + "'."); FileAccess.write(out, eString); } } if ((x == cStep.intValue()) || (_existsOnly == _noMoreItems)) { + Logging.errorPrint("Outputing C '" + cEndLineString + "'."); FileAccess.write(out, cEndLineString); // FileAccess.newLine(out); x = 0; @@ -3361,6 +3383,22 @@ } /** + * @return Returns the manualWhitespace. + */ + public final boolean isManualWhitespace() + { + return manualWhitespace; + } + + /** + * @param manualWhitespace The manualWhitespace to set. + */ + public final void setManualWhitespace(boolean manualWhitespace) + { + this.manualWhitespace = manualWhitespace; + } + + /** * Get the token string * @param aPC * @param aString Added: Trunk/pcgen/code/src/java/plugin/exporttokens/EndManualWhitespaceToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/EndManualWhitespaceToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/EndManualWhitespaceToken.java 2006-05-28 01:16:37 UTC (rev 1039) @@ -0,0 +1,52 @@ +/* + * EndManualWhitespaceToken.java + * Copyright 2006 (C) James Dempsey <jdempsey@...> + * + * 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 6/05/2006 + * + * $Id: $ + * + */ +package plugin.exporttokens; + +import pcgen.core.PlayerCharacter; +import pcgen.io.ExportHandler; +import pcgen.io.exporttoken.Token; + +public class EndManualWhitespaceToken extends Token +{ + /** The tokenname implemented by this class. */ + public static final String TOKENNAME = "ENDMANUALWHITESPACE"; + + /** + * @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) + { + eh.setManualWhitespace(false); + return ""; + } + +} Property changes on: Trunk/pcgen/code/src/java/plugin/exporttokens/EndManualWhitespaceToken.java ___________________________________________________________________ Name: keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/exporttokens/ManualWhitespaceToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/ManualWhitespaceToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/ManualWhitespaceToken.java 2006-05-28 01:16:37 UTC (rev 1039) @@ -0,0 +1,52 @@ +/* + * ManualWhitespaceToken.java + * Copyright 2006 (C) James Dempsey <jdempsey@...> + * + * 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 6/05/2006 + * + * $Id: $ + * + */ +package plugin.exporttokens; + +import pcgen.core.PlayerCharacter; +import pcgen.io.ExportHandler; +import pcgen.io.exporttoken.Token; + +public class ManualWhitespaceToken extends Token +{ + /** The tokenname implemented by this class. */ + public static final String TOKENNAME = "MANUALWHITESPACE"; + + /** + * @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) + { + eh.setManualWhitespace(true); + return ""; + } + +} Property changes on: Trunk/pcgen/code/src/java/plugin/exporttokens/ManualWhitespaceToken.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-05-26 21:54:47 UTC (rev 1038) +++ Trunk/pcgen/code/testsuite/base.xml 2006-05-28 01:16:37 UTC (rev 1039) @@ -1,11 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> <character> +|MANUALWHITESPACE| <!-- + =============== ===================== + ====================================|BR| + BIO|BR| ==================================== - ==================================== - BIO - ==================================== ====================================--> +|ENDMANUALWHITESPACE| <basics> <bonuses>|BONUSLIST.STAT.STR|</bonuses> <bonuses>|BONUSLIST.STAT.STR.TOTAL|</bonuses> Modified: Trunk/pcgen/code/testsuite/csheets/BarJack.xml =================================================================== --- Trunk/pcgen/code/testsuite/csheets/BarJack.xml 2006-05-26 21:54:47 UTC (rev 1038) +++ Trunk/pcgen/code/testsuite/csheets/BarJack.xml 2006-05-28 01:16:37 UTC (rev 1039) @@ -1,11 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <character> - <!-- - ==================================== - ==================================== - BIO - ==================================== - ====================================--> +<!--======================================================================== +BIO +========================================================================--> <basics> <bonuses></bonuses> <bonuses></bonuses> @@ -886,8 +883,76 @@ - <weapon> <common> <name> <short>*Dagger</short> <long>*Dagger</long> </name> <category>Simple-Both (Melee)</category> <critical> <range>19-20</range> <multiplier>2</multiplier> </critical> <to_hit> <hit>+3</hit> <magic_hit>+0</magic_hit> <total_hit>+3</total_hit> </to_hit> <feat></feat> <hand>Two-Weapons</hand> <num_attacks>1</num_attacks> <reach>5</reach> <size>T</size> <special_properties></special_properties> <template></template> <type>P</type> <weight>0</weight> <sequence>0</sequence> </common> <melee> <w1_h1_p> <!-- One weapon, 1 hand, primary hand --> <to_hit>+7</to_hit> <damage>1d4+2</damage> </w1_h1_p> <w1_h1_o> <!-- One weapon, 1 handed, offhand --> <to_hit>+7</to_hit> <damage>1d4+1</damage> </w1_h1_o> <w1_h2> <!-- One weapon, 2 handed --> <to_hit>+7</to_hit> <damage>1d4+2</damage> </w1_h2> <w2_p_oh> <!-- Two weapons, this weapon in primary hand, other hand with heavy weapon --> <to_hit>+1</to_hit> <damage>1d4+2</damage> </w2_p_oh> <w2_p_ol> <!-- Two weapons, this weapon in primary hand, other hand with light weapon --> <to_hit>+3</to_hit> <damage>1d4+2</damage> </w2_p_ol> <w2_o> <!-- Two weapons, this weapon in off-hand --> <to_hit>+3</to_hit> <damage>1d4+1</damage> </w2_o> </melee> - <ranges> <range> + + + + <weapon> + <common> + <name> + <short>*Dagger</short> + <long>*Dagger</long> + </name> + <category>Simple-Both (Melee)</category> + <critical> + <range>19-20</range> + <multiplier>2</multiplier> + </critical> + <to_hit> + <hit>+3</hit> + <magic_hit>+0</magic_hit> + <total_hit>+3</total_hit> + </to_hit> + <feat></feat> + <hand>Two-Weapons</hand> + <num_attacks>1</num_attacks> + <reach>5</reach> + <size>T</size> + <special_properties></special_properties> + <template></template> + <type>P</type> + <weight>0</weight> + <sequence>0</sequence> + </common> + <melee> + <w1_h1_p> + <!-- One weapon, 1 hand, primary hand --> + <to_hit>+7</to_hit> + <damage>1d4+2</damage> + </w1_h1_p> + <w1_h1_o> + <!-- One weapon, 1 handed, offhand --> + <to_hit>+7</to_hit> + <damage>1d4+1</damage> + </w1_h1_o> + <w1_h2> + <!-- One weapon, 2 handed --> + <to_hit>+7</to_hit> + <damage>1d4+2</damage> + </w1_h2> + <w2_p_oh> + <!-- Two weapons, this weapon in primary hand, other hand with heavy weapon --> + <to_hit>+1</to_hit> + <damage>1d4+2</damage> + </w2_p_oh> + <w2_p_ol> + <!-- Two weapons, this weapon in primary hand, other hand with light weapon --> + <to_hit>+3</to_hit> + <damage>1d4+2</damage> + </w2_p_ol> + <w2_o> + <!-- Two weapons, this weapon in off-hand --> + <to_hit>+3</to_hit> + <damage>1d4+1</damage> + </w2_o> + </melee> + + + + + + + <ranges> + <range> <distance>10 ft.</distance> <to_hit>+8</to_hit> <damage>1d4+2</damage> @@ -912,7 +977,11 @@ <to_hit>+0</to_hit> <damage>1d4+2</damage> </range> - </ranges> </weapon> </weapons> + </ranges> + </weapon> + + + </weapons> <!-- ==================================== ==================================== @@ -1294,6 +1363,7 @@ <spells> <!-- ### BEGIN Innate spells ### --> <spells_innate> + <racial_innate> <spell> <name>Speak with Animals</name> @@ -1409,14 +1479,22 @@ </spell> </racial_innate> - <class_innate> </class_innate> </spells_innate><!-- ### END Innate spells ### --> + + <class_innate> + </class_innate> + </spells_innate> +<!-- ### END Innate spells ### --> <!-- ### BEGIN Known spells ### --> <known_spells> </known_spells> <!-- ### END Known spells ### --> <!-- ### BEGIN memorized spells ### --> - <memorized_spells> <!-- ### BEGIN innate memorized spell section --> <!-- ### BEGIN innate memorized spells ### --> + <memorized_spells> + <!-- ### BEGIN innate memorized spell section --> + +<!-- ### BEGIN innate memorized spells ### --> + <racial_innate_memorized> <spell> <name>Speak with Animals</name> @@ -1532,6 +1610,14 @@ </spell> </racial_innate_memorized> -<!-- ### END innate memorized spells ### --> <!-- ### BEGIN class innate memorized spells ### --> <class_innate_memorized> </class_innate_memorized> <!-- ### END class innate memorized spells ### --><!-- ### END innate memorized spell section --> <!-- ### BEGIN class Spellbook memorized spells ### --> </memorized_spells><!-- ### END class Spellbook memorized spells ### --> +<!-- ### END innate memorized spells ### --> + <!-- ### BEGIN class innate memorized spells ### --> + <class_innate_memorized> + </class_innate_memorized> + <!-- ### END class innate memorized spells ### --> +<!-- ### END innate memorized spell section --> + <!-- ### BEGIN class Spellbook memorized spells ### --> + </memorized_spells> +<!-- ### END class Spellbook memorized spells ### --> </spells> </character> Modified: Trunk/pcgen/code/testsuite/csheets/BrdJoe.xml =================================================================== --- Trunk/pcgen/code/testsuite/csheets/BrdJoe.xml 2006-05-26 21:54:47 UTC (rev 1038) +++ Trunk/pcgen/code/testsuite/csheets/BrdJoe.xml 2006-05-28 01:16:37 UTC (rev 1039) @@ -1,11 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <character> - <!-- - ==================================== - ==================================== - BIO - ==================================== - ====================================--> +<!--======================================================================== +BIO +========================================================================--> <basics> <bonuses></bonuses> <bonuses></bonuses> @@ -1185,12 +1182,14 @@ ====================================--> <spells> <!-- ### BEGIN Innate spells ### --> - <spells_innate number="none"/><!-- ### END Innate spells ### --> + <spells_innate number="none"/> +<!-- ### END Innate spells ### --> <!-- ### BEGIN Known spells ### --> <known_spells> <class number="0" spelllistclass="Bard" spellcastertype="Arcane"> - <level number="0" known="4" cast="2"> <spell> + <level number="0" known="4" cast="2"> + <spell> <name>Flare</name> <outputname>Flare</outputname> <times_memorized>1</times_memorized> @@ -1302,11 +1301,22 @@ <description>5-pound telekinesis.</description> <bonusspell></bonusspell> </spell> - </level> <level number="1" known="0" cast="0"/> <level number="2" known="0" cast="0"/> <level number="3" known="0" cast="0"/> <level number="4" known="0" cast="0"/> <level number="5" known="0" cast="0"/> <level number="6" known="0" cast="0"/> <level number="7" known="0" cast="0"/> <level number="8" known="0" cast="0"/> <level number="9" known="0" cast="0"/> </class> + </level> + <level number="1" known="0" cast="0"/> + <level number="2" known="0" cast="0"/> + <level number="3" known="0" cast="0"/> + <level number="4" known="0" cast="0"/> + <level number="5" known="0" cast="0"/> + <level number="6" known="0" cast="0"/> + <level number="7" known="0" cast="0"/> + <level number="8" known="0" cast="0"/> + <level number="9" known="0" cast="0"/> + </class> </known_spells> <!-- ### END Known spells ### --> <!-- ### BEGIN memorized spells ### --> - <memorized_spells/><!-- ### END class Spellbook memorized spells ### --> + <memorized_spells/> +<!-- ### END class Spellbook memorized spells ### --> </spells> </character> Modified: Trunk/pcgen/code/testsuite/csheets/CleElf.xml =================================================================== --- Trunk/pcgen/code/testsuite/csheets/CleElf.xml 2006-05-26 21:54:47 UTC (rev 1038) +++ Trunk/pcgen/code/testsuite/csheets/CleElf.xml 2006-05-28 01:16:37 UTC (rev 1039) @@ -1,11 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <character> - <!-- - ==================================== - ==================================== - BIO - ==================================== - ====================================--> +<!--======================================================================== +BIO +========================================================================--> <basics> <bonuses></bonuses> <bonuses></bonuses> @@ -905,8 +902,76 @@ - <weapon> <common> <name> <short>*Club</short> <long>*Club</long> </name> <category>Simple-Both (Melee)</category> <critical> <range>20</range> <multiplier>2</multiplier> </critical> <to_hit> <hit>+1</hit> <magic_hit>+0</magic_hit> <total_hit>+1</total_hit> </to_hit> <feat></feat> <hand>Primary</hand> <num_attacks>1</num_attacks> <reach>5</reach> <size>M</size> <special_properties></special_properties> <template></template> <type>B</type> <weight>0</weight> <sequence>0</sequence> </common> <melee> <w1_h1_p> <!-- One weapon, 1 hand, primary hand --> <to_hit>+1</to_hit> <damage>1d6</damage> </w1_h1_p> <w1_h1_o> <!-- One weapon, 1 handed, offhand --> <to_hit>-3</to_hit> <damage>1d6</damage> </w1_h1_o> <w1_h2> <!-- One weapon, 2 handed --> <to_hit>+1</to_hit> <damage>1d6</damage> </w1_h2> <w2_p_oh> <!-- Two weapons, this weapon in primary hand, other hand with heavy weapon --> <to_hit>-5</to_hit> <damage>1d6</damage> </w2_p_oh> <w2_p_ol> <!-- Two weapons, this weapon in primary hand, other hand with light weapon --> <to_hit>-3</to_hit> <damage>1d6</damage> </w2_p_ol> <w2_o> <!-- Two weapons, this weapon in off-hand --> <to_hit>-9</to_hit> <damage>1d6</damage> </w2_o> </melee> - <ranges> <range> + + + + <weapon> + <common> + <name> + <short>*Club</short> + <long>*Club</long> + </name> + <category>Simple-Both (Melee)</category> + <critical> + <range>20</range> + <multiplier>2</multiplier> + </critical> + <to_hit> + <hit>+1</hit> + <magic_hit>+0</magic_hit> + <total_hit>+1</total_hit> + </to_hit> + <feat></feat> + <hand>Primary</hand> + <num_attacks>1</num_attacks> + <reach>5</reach> + <size>M</size> + <special_properties></special_properties> + <template></template> + <type>B</type> + <weight>0</weight> + <sequence>0</sequence> + </common> + <melee> + <w1_h1_p> + <!-- One weapon, 1 hand, primary hand --> + <to_hit>+1</to_hit> + <damage>1d6</damage> + </w1_h1_p> + <w1_h1_o> + <!-- One weapon, 1 handed, offhand --> + <to_hit>-3</to_hit> + <damage>1d6</damage> + </w1_h1_o> + <w1_h2> + <!-- One weapon, 2 handed --> + <to_hit>+1</to_hit> + <damage>1d6</damage> + </w1_h2> + <w2_p_oh> + <!-- Two weapons, this weapon in primary hand, other hand with heavy weapon --> + <to_hit>-5</to_hit> + <damage>1d6</damage> + </w2_p_oh> + <w2_p_ol> + <!-- Two weapons, this weapon in primary hand, other hand with light weapon --> + <to_hit>-3</to_hit> + <damage>1d6</damage> + </w2_p_ol> + <w2_o> + <!-- Two weapons, this weapon in off-hand --> + <to_hit>-9</to_hit> + <damage>1d6</damage> + </w2_o> + </melee> + + + + + + + <ranges> + <range> <distance>10 ft.</distance> <to_hit>+2</to_hit> <damage>1d6</damage> @@ -931,8 +996,76 @@ <to_hit>-6</to_hit> <damage>1d6</damage> </range> - </ranges> </weapon> - <weapon> <common> <name> <short>Handaxe</short> <long>Handaxe</long> </name> <category>Martial-Melee</category> <critical> <range>20</range> <multiplier>3</multiplier> </critical> <to_hit> <hit>-3</hit> <magic_hit>+0</magic_hit> <total_hit>-3</total_hit> </to_hit> <feat></feat> <hand>Carried</hand> <num_attacks>1</num_attacks> <reach>5</reach> <size>S</size> <special_properties></special_properties> <template></template> <type>S</type> <weight>5</weight> <sequence>2</sequence> </common> <melee> <w1_h1_p> <!-- One weapon, 1 hand, primary hand --> <to_hit>-3</to_hit> <damage>1d6</damage> </w1_h1_p> <w1_h1_o> <!-- One weapon, 1 handed, offhand --> <to_hit>-7</to_hit> <damage>1d6</damage> </w1_h1_o> <w1_h2> <!-- One weapon, 2 handed --> <to_hit>-3</to_hit> <damage>1d6</damage> </w1_h2> <w2_p_oh> <!-- Two weapons, this weapon in primary hand, other hand with heavy weapon --> <to_hit>-9</to_hit> <damage>1d6</damage> </w2_p_oh> <w2_p_ol> <!-- Two weapons, this weapon in primary hand, other hand with light weapon --> <to_hit>-7</to_hit> <damage>1d6</damage> </w2_p_ol> <w2_o> <!-- Two weapons, this weapon in off-hand --> <to_hit>-11</to_hit> <damage>1d6</damage> </w2_o> </melee> </weapon> </weapons> + </ranges> + </weapon> + + + + + + + + <weapon> + <common> + <name> + <short>Handaxe</short> + <long>Handaxe</long> + </name> + <category>Martial-Melee</category> + <critical> + <range>20</range> + <multiplier>3</multiplier> + </critical> + <to_hit> + <hit>-3</hit> + <magic_hit>+0</magic_hit> + <total_hit>-3</total_hit> + </to_hit> + <feat></feat> + <hand>Carried</hand> + <num_attacks>1</num_attacks> + <reach>5</reach> + <size>S</size> + <special_properties></special_properties> + <template></template> + <type>S</type> + <weight>5</weight> + <sequence>2</sequence> + </common> + <melee> + <w1_h1_p> + <!-- One weapon, 1 hand, primary hand --> + <to_hit>-3</to_hit> + <damage>1d6</damage> + </w1_h1_p> + <w1_h1_o> + <!-- One weapon, 1 handed, offhand --> + <to_hit>-7</to_hit> + <damage>1d6</damage> + </w1_h1_o> + <w1_h2> + <!-- One weapon, 2 handed --> + <to_hit>-3</to_hit> + <damage>1d6</damage> + </w1_h2> + <w2_p_oh> + <!-- Two weapons, this weapon in primary hand, other hand with heavy weapon --> + <to_hit>-9</to_hit> + <damage>1d6</damage> + </w2_p_oh> + <w2_p_ol> + <!-- Two weapons, this weapon in primary hand, other hand with light weapon --> + <to_hit>-7</to_hit> + <damage>1d6</damage> + </w2_p_ol> + <w2_o> + <!-- Two weapons, this weapon in off-hand --> + <to_hit>-11</to_hit> + <damage>1d6</damage> + </w2_o> + </melee> + </weapon> + </weapons> <!-- ==================================== ==================================== @@ -985,9 +1118,17 @@ <!-- Character Rage --> - <!-- Turning ability --> <turning kind="Undead"> <level>2</level> <turn_check>1d20-1</turn_check> <damage>2d6 +1</damage> <uses_per_day>6</uses_per_day> <notes>You destroy undead if you have twice as many turning levels as they have Hit Dice</notes> </turning> + <!-- Turning ability --> + <turning kind="Undead"> + <level>2</level> + <turn_check>1d20-1</turn_check> + <damage>2d6 +1</damage> + <uses_per_day>6</uses_per_day> + <notes>You destroy undead if you have twice as many turning levels as they have Hit Dice</notes> + </turning> + <!-- 3.0 stunning fist --> <!-- 3.5 stunning fist --> @@ -1393,12 +1534,14 @@ ====================================--> <spells> <!-- ### BEGIN Innate spells ### --> - <spells_innate number="none"/><!-- ### END Innate spells ### --> + <spells_innate number="none"/> +<!-- ### END Innate spells ### --> <!-- ### BEGIN Known spells ### --> <known_spells> <class number="0" spelllistclass="Cleric" spellcastertype="Divine"> - <level number="0" known="0" cast="4"> <spell> + <level number="0" known="0" cast="4"> + <spell> <name>Create Water</name> <outputname>Create Water</outputname> <times_memorized>1</times_memorized> @@ -1734,7 +1877,9 @@ <description>Subject gains 1 temporary hp.</description> <bonusspell></bonusspell> </spell> - </level> <level number="1" known="0" cast="3+1"> <spell> + </level> + <level number="1" known="0" cast="3+1"> + <spell> <name>Bane</name> <outputname>Bane</outputname> <times_memorized>1</times_memorized> @@ -2602,11 +2747,21 @@ <description>Calls outsider to fight for the caster.</description> <bonusspell></bonusspell> </spell> - </level> <level number="2" known="0" cast="0"/> <level number="3" known="0" cast="0"/> <level number="4" known="0" cast="0"/> <level number="5" known="0" cast="0"/> <level number="6" known="0" cast="0"/> <level number="7" known="0" cast="0"/> <level number="8" known="0" cast="0"/> <level number="9" known="0" cast="0"/> </class> + </level> + <level number="2" known="0" cast="0"/> + <level number="3" known="0" cast="0"/> + <level number="4" known="0" cast="0"/> + <level number="5" known="0" cast="0"/> + <level number="6" known="0" cast="0"/> + <level number="7" known="0" cast="0"/> + <level number="8" known="0" cast="0"/> + <level number="9" known="0" cast="0"/> + </class> </known_spells> <!-- ### END Known spells ### --> <!-- ### BEGIN memorized spells ### --> - <memorized_spells/><!-- ### END class Spellbook memorized spells ### --> + <memorized_spells/> +<!-- ### END class Spellbook memorized spells ### --> </spells> </character> Modified: Trunk/pcgen/code/testsuite/csheets/CloudGiantHalfDragon.xml =================================================================== --- Trunk/pcgen/code/testsuite/csheets/CloudGiantHalfDragon.xml 2006-05-26 21:54:47 UTC (rev 1038) +++ Trunk/pcgen/code/testsuite/csheets/CloudGiantHalfDragon.xml 2006-05-28 01:16:37 UTC (rev 1039) @@ -1,11 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <character> - <!-- - ==================================== - ==================================== - BIO - ==================================== - ====================================--> +<!--======================================================================== +BIO +========================================================================--> <basics> <bonuses></bonuses> <bonuses></bonuses> @@ -942,9 +939,120 @@ - <weapon> <common> <name> <short>*Bite</short> <long>*Bite (Natural/Primary)</long> </name> <category>Natural-Natural,Melee</category> <critical> <range>20</range> <multiplier>2</multiplier> </critical> <to_hit> <hit>+30</hit> <magic_hit>+0</magic_hit> <total_hit>+30</total_hit> </to_hit> <feat></feat> <hand>Primary</hand> <num_attacks>3</num_attacks> <reach>15</reach> <size>M</size> <special_properties></special_properties> <template></template> <type>BPS</type> <weight>0</weight> <sequence>0</sequence> </common> <simple> <to_hit>+30</to_hit> <damage>2d6+20</damage> <range>0 ft.</range> </simple> </weapon> - <weapon> <common> <name> <short>Slam</short> <long>Slam (Natural/Primary)</long> </name> <category>Natural-Natural,Melee</category> <critical> <range>20</range> <multiplier>2</multiplier> </critical> <to_hit> <hit>+30/+30</hit> <magic_hit>+0</magic_hit> <total_hit>+30/+30</total_hit> </to_hit> <feat></feat> <hand>Carried</hand> <num_attacks>4</num_attacks> <reach>15</reach> <size>H</size> <special_properties></special_properties> <template></template> <type>B</type> <weight>0</weight> <sequence>1</sequence> </common> <simple> <to_hit>+30/+30</to_hit> <damage>1d6+30</damage> <range>0 ft.</range> </simple> </weapon> - <weapon> <common> <name> <short>*Claw</short> <long>*Claw (Natural/Secondary)</long> </name> <category>Natural-Natural,Melee</category> <critical> <range>20</range> <multiplier>2</multiplier> </critical> <to_hit> <hit>+25/+25</hit> <magic_hit>+0</magic_hit> <total_hit>+25/+25</total_hit> </to_hit> <feat></feat> <hand>Off-hand</hand> <num_attacks>4</num_attacks> <reach>15</reach> <size>M</size> <special_properties></special_properties> <template></template> <type>PS</type> <weight>0</weight> <sequence>2</sequence> </common> <simple> <to_hit>+25/+25</to_hit> <damage>1d8+10</damage> <range>0 ft.</range> </simple> </weapon> </weapons> + + + + + <weapon> + <common> + <name> + <short>*Bite</short> + <long>*Bite (Natural/Primary)</long> + </name> + <category>Natural-Natural,Melee</category> + <critical> + <range>20</range> + <multiplier>2</multiplier> + </critical> + <to_hit> + <hit>+30</hit> + <magic_hit>+0</magic_hit> + <total_hit>+30</total_hit> + </to_hit> + <feat></feat> + <hand>Primary</hand> + <num_attacks>3</num_attacks> + <reach>15</reach> + <size>M</size> + <special_properties></special_properties> + <template></template> + <type>BPS</type> + <weight>0</weight> + <sequence>0</sequence> + </common> + <simple> + <to_hit>+30</to_hit> + <damage>2d6+20</damage> + <range>0 ft.</range> + </simple> + </weapon> + + + + + + <weapon> + <common> + <name> + <short>Slam</short> + <long>Slam (Natural/Primary)</long> + </name> + <category>Natural-Natural,Melee</category> + <critical> + <range>20</range> + <multiplier>2</multiplier> + </critical> + <to_hit> + <hit>+30/+30</hit> + <magic_hit>+0</magic_hit> + <total_hit>+30/+30</total_hit> + </to_hit> + <feat></feat> + <hand>Carried</hand> + <num_attacks>4</num_attacks> + <reach>15</reach> + <size>H</size> + <special_properties></special_properties> + <template></template> + <type>B</type> + <weight>0</weight> + <sequence>1</sequence> + </common> + <simple> + <to_hit>+30/+30</to_hit> + <damage>1d6+30</damage> + <range>0 ft.</range> + </simple> + </weapon> + + + + + + <weapon> + <common> + <name> + <short>*Claw</short> + <long>*Claw (Natural/Secondary)</long> + </name> + <category>Natural-Natural,Melee</category> + <critical> + <range>20</range> + <multiplier>2</multiplier> + </critical> + <to_hit> + <hit>+25/+25</hit> + <magic_hit>+0</magic_hit> + <total_hit>+25/+25</total_hit> + </to_hit> + <feat></feat> + <hand>Off-hand</hand> + <num_attacks>4</num_attacks> + <reach>15</reach> + <size>M</size> + <special_properties></special_properties> + <template></template> + <type>PS</type> + <weight>0</weight> + <sequence>2</sequence> + </common> + <simple> + <to_hit>+25/+25</to_hit> + <damage>1d8+10</damage> + <range>0 ft.</range> + </simple> + </weapon> + </weapons> <!-- ==================================== ==================================== @@ -1391,6 +1499,7 @@ <spells> <!-- ### BEGIN Innate spells ### --> <spells_innate> + <racial_innate> <spell> <name>Fog Cloud</name> @@ -1478,14 +1587,22 @@ </spell> </racial_innate> - <class_innate> </class_innate> </spells_innate><!-- ### END Innate spells ### --> + + <class_innate> + </class_innate> + </spells_innate> +<!-- ### END Innate spells ### --> <!-- ### BEGIN Known spells ### --> <known_spells> </known_spells> <!-- ### END Known spells ### --> <!-- ### BEGIN memorized spells ### --> - <memorized_spells> <!-- ### BEGIN innate memorized spell section --> <!-- ### BEGIN innate memorized spells ### --> + <memorized_spells> + <!-- ### BEGIN innate memorized spell section --> + +<!-- ### BEGIN innate memorized spells ### --> + <racial_innate_memorized> <spell> <name>Fog Cloud</name> @@ -1573,6 +1690,14 @@ </spell> </racial_innate_memorized> -<!-- ### END innate memorized spells ### --> <!-- ### BEGIN class innate memorized spells ### --> <class_innate_memorized> </class_innate_memorized> <!-- ### END class innate memorized spells ### --><!-- ### END innate memorized spell section --> <!-- ### BEGIN class Spellbook memorized spells ### --> </memorized_spells><!-- ### END class Spellbook memorized spells ### --> +<!-- ### END innate memorized spells ### --> + <!-- ### BEGIN class innate memorized spells ### --> + <class_innate_memorized> + </class_innate_memorized> + <!-- ### END class innate memorized spells ### --> +<!-- ### END innate memorized spell section --> + <!-- ### BEGIN class Spellbook memorized spells ### --> + </memorized_spells> +<!-- ### END class Spellbook memorized spells ### --> </spells> </character> Modified: Trunk/pcgen/code/testsuite/csheets/DrakelingSorc.xml =================================================================== --- Trunk/pcgen/code/testsuite/csheets/DrakelingSorc.xml 2006-05-26 21:54:47 UTC (rev 1038) +++ Trunk/pcgen/code/testsuite/csheets/DrakelingSorc.xml 2006-05-28 01:16:37 UTC (rev 1039) @@ -1,11 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <character> - <!-- - ==================================== - ==================================== - BIO - ==================================== - ====================================--> +<!--======================================================================== +BIO +========================================================================--> <basics> <bonuses></bonuses> <bonuses></bonuses> @@ -1062,6 +1059,7 @@ <spells> <!-- ### BEGIN Innate spells ### --> <spells_innate> + <racial_innate> <spell> <name>Cause Fear</name> @@ -1093,12 +1091,17 @@ </spell> </racial_innate> - <class_innate> </class_innate> </spells_innate><!-- ### END Innate spells ### --> + + <class_innate> + </class_innate> + </spells_innate> +<!-- ### END Innate spells ### --> <!-- ### BEGIN Known spells ### --> <known_spells> <class number="1" spelllistclass="Sorcerer" spellcastertype="Arcane"> - <level number="0" known="6" cast="6"> <spell> + <level number="0" known="6" cast="6"> + <spell> <name>Detect Poison</name> <outputname>Detect Poison</outputname> <times_memorized>1</times_memorized> @@ -1266,7 +1269,9 @@ <description>Read scrolls and spellbooks.</description> <bonusspell></bonusspell> </spell> - </level> <level number="1" known="3" cast="8"> <spell> + </level> + <level number="1" known="3" cast="8"> + <spell> <name>Endure Elements</name> <outputname>Endure Elements</outputname> <times_memorized>1</times_memorized> @@ -1350,7 +1355,9 @@ <description>Masks magic item's aura.</description> <bonusspell></bonusspell> </spell> - </level> <level number="2" known="1" cast="4"> <spell> + </level> + <level number="2" known="1" cast="4"> + <spell> <name>Flaming Sphere</name> <outputname>Flaming Sphere</outputname> <times_memorized>1</times_memorized> @@ -1378,12 +1385,24 @@ <description>Rolling ball of fire, 2d6 damage, lasts (CASTERLEVEL) rounds.</description> <bonusspell></bonusspell> </spell> - </level> <level number="3" known="0" cast="0"/> <level number="4" known="0" cast="0"/> <level number="5" known="0" cast="0"/> <level number="6" known="0" cast="0"/> <level number="7" known="0" cast="0"/> <level number="8" known="0" cast="0"/> <level number="9" known="0" cast="0"/> </class> + </level> + <level number="3" known="0" cast="0"/> + <level number="4" known="0" cast="0"/> + <level number="5" known="0" cast="0"/> + <level number="6" known="0" cast="0"/> + <level number="7" known="0" cast="0"/> + <level number="8" known="0" cast="0"/> + <level number="9" known="0" cast="0"/> + </class> </known_spells> <!-- ### END Known spells ### --> <!-- ### BEGIN memorized spells ### --> - <memorized_spells> <!-- ### BEGIN innate memorized spell section --> <!-- ### BEGIN innate memorized spells ### --> + <memorized_spells> + <!-- ### BEGIN innate memorized spell section --> + +<!-- ### BEGIN innate memorized spells ### --> + <racial_innate_memorized> <spell> <name>Cause Fear</name> @@ -1415,6 +1434,14 @@ </spell> </racial_innate_memorized> -<!-- ### END innate memorized spells ### --> <!-- ### BEGIN class innate memorized spells ### --> <class_innate_memorized> </class_innate_memorized> <!-- ### END class innate memorized spells ### --><!-- ### END innate memorized spell section --> <!-- ### BEGIN class Spellbook memorized spells ### --> </memorized_spells><!-- ### END class Spellbook memorized spells ### --> +<!-- ### END innate memorized spells ### --> + <!-- ### BEGIN class innate memorized spells ### --> + <class_innate_memorized> + </class_innate_memorized> + <!-- ### END class innate memorized spells ### --> +<!-- ### END innate memorized spell section --> + <!-- ### BEGIN class Spellbook memorized spells ### --> + </memorized_spells> +<!-- ### END class Spellbook memorized spells ### --> </spells> </character> Modified: Trunk/pcgen/code/testsuite/csheets/FigFae.xml =================================================================== --- Trunk/pcgen/code/testsuite/csheets/FigFae.xml 2006-05-26 21:54:47 UTC (rev 1038) +++ Trunk/pcgen/code/testsuite/csheets/FigFae.xml 2006-05-28 01:16:37 UTC (rev 1039) @@ -1,11 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <character> - <!-- - ==================================== - ==================================== - BIO - ==================================== - ====================================--> +<!--======================================================================== +BIO +========================================================================--> <basics> <bonuses></bonuses> <bonuses></bonuses> @@ -868,7 +865,71 @@ - <weapon> <common> <name> <short>*Rapier</short> <long>*Rapier</long> </name> <category>Martial-Melee</category> <critical> <range>18-20</range> <multiplier>2</multiplier> </critical> <to_hit> <hit>+3</hit> <magic_hit>+0</magic_hit> <total_hit>+3</total_hit> </to_hit> <feat></feat> <hand>Two-Weapons</hand> <num_attacks>1</num_attacks> <reach>5</reach> <size>M</size> <special_properties></special_properties> <template></template> <type>P</type> <weight>3</weight> <sequence>0</sequence> </common> <melee> <w1_h1_p> <!-- One weapon, 1 hand, primary hand --> <to_hit>+7</to_hit> <damage>1d6+3</damage> </w1_h1_p> <w1_h1_o> <!-- One weapon, 1 handed, offhand --> <to_hit>+7</to_hit> <damage>1d6+1</damage> </w1_h1_o> <w1_h2> <!-- One weapon, 2 handed --> <to_hit>+7</to_hit> <damage>1d6+4</damage> </w1_h2> <w2_p_oh> <!-- Two weapons, this weapon in primary hand, other hand with heavy weapon --> <to_hit>+3</to_hit> <damage>1d6+3</damage> </w2_p_oh> <w2_p_ol> <!-- Two weapons, this weapon in primary hand, other hand with light weapon --> <to_hit>+5</to_hit> <damage>1d6+3</damage> </w2_p_ol> <w2_o> <!-- Two weapons, this weapon in off-hand --> <to_hit>+3</to_hit> <damage>1d6+1</damage> </w2_o> </melee> </weapon> </weapons> + + + + + <weapon> + <common> + <name> + <short>*Rapier</short> + <long>*Rapier</long> + </name> + <category>Martial-Melee</category> + <critical> + <range>18-20</range> + <multiplier>2</multiplier> + </critical> + <to_hit> + <hit>+3</hit> + <magic_hit>+0</magic_hit> + <total_hit>+3</total_hit> + </to_hit> + <feat></feat> + <hand>Two-Weapons</hand> + <num_attacks>1</num_attacks> + <reach>5</reach> + <size>M</size> + <special_properties></special_properties> + <template></template> + <type>P</type> + <weight>3</weight> + <sequence>0</sequence> + </common> + <melee> + <w1_h1_p> + <!-- One weapon, 1 hand, primary hand --> + <to_hit>+7</to_hit> + <damage>1d6+3</damage> + </w1_h1_p> + <w1_h1_o> + <!-- One weapon, 1 handed, offhand --> + <to_hit>+7</to_hit> + <damage>1d6+1</damage> + </w1_h1_o> + <w1_h2> + <!-- One weapon, 2 handed --> + <to_hit>+7</to_hit> + <damage>1d6+4</damage> + </w1_h2> + <w2_p_oh> + <!-- Two weapons, this weapon in primary hand, other hand with heavy weapon --> + <to_hit>+3</to_hit> + <damage>1d6+3</damage> + </w2_p_oh> + <w2_p_ol> + <!-- Two weapons, this weapon in primary hand, other hand with light weapon --> + <to_hit>+5</to_hit> + <damage>1d6+3</damage> + </w2_p_ol> + <w2_o> + <!-- Two weapons, this weapon in off-hand --> + <to_hit>+3</to_hit> + <damage>1d6+1</damage> + </w2_o> + </melee> + </weapon> + </weapons> <!-- ==================================== ==================================== @@ -1188,13 +1249,15 @@ ====================================--> <spells> <!-- ### BEGIN Innate spells ### --> - <spells_innate number="none"/><!-- ### END Innate spells ### --> + <spells_innate number="none"/> +<!-- ### END Innate spells ### --> <!-- ### BEGIN Known spells ### --> <known_spells> </known_spells> <!-- ### END Known spells ### --> <!-- ### BEGIN memorized spells ### --> - <memorized_spells/><!-- ### END class Spellbook memorized spells ### --> + <memorized_spells/> +<!-- ### END class Spellbook memorized spells ### --> </spells> </character> Modified: Trunk/pcgen/code/testsuite/csheets/JimDop.xml =================================================================== --- Trunk/pcgen/code/testsuite/csheets/JimDop.xml 2006-05-26 21:54:47 UTC (rev 1038) +++ Trunk/pcgen/code/testsuite/csheets/JimDop.xml 2006-05-28 01:16:37 UTC (rev 1039) @@ -1,11 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <character> - <!-- - ==================================== - ==================================== - BIO - ==================================== - ====================================--> +<!--======================================================================== +BIO +========================================================================--> <basics> <bonuses></bonuses> <bonuses></bonuses> @@ -890,9 +887,120 @@ - <weapon> <common> <name> <short>Bite</short> <long>Bite (Natural/Primary)</long> </name> <category>Natural-Natural,Melee</category> <critical> <range>20</range> <multiplier>2</multiplier> </critical> <to_hit> <hit>+15</hit> <magic_hit>+0</magic_hit> <total_hit>+15</total_hit> </to_hit> <feat></feat> <hand>Carried</hand> <num_attacks>2</num_attacks> <reach>5</reach> <size>M</size> <special_properties></special_properties> <template></template> <type>BPS</type> <weight>0</weight> <sequence>0</sequence> </common> <simple> <to_hit>+15</to_hit> <damage>1d6+9</damage> <range>0 ft.</range> </simple> </weapon> - <weapon> <common> <name> <short>*Slam</short> <long>*Slam (Natural/Primary)</long> </name> <category>Natural-Natural,Melee</category> <critical> <range>20</range> <multiplier>2</multiplier> </critical> <to_hit> <hit>+15</hit> <magic_hit>+0</magic_hit> <total_hit>+15</total_hit> </to_hit> <feat></feat> <hand>Primary</hand> <num_attacks>2</num_attacks> <reach>5</reach> <size>M</size> <special_properties></special_properties> <template></template> <type>B</type> <weight>0</weight> <sequence>1</sequence> </common> <simple> <to_hit>+15</to_hit> <damage>1d6+13</damage> <range>0 ft.</range> </simple> </weapon> - <weapon> <common> <name> <short>*Claw</short> <long>*Claw (Natural/Secondary)</long> </name> <category>Natural-Natural,Melee</category> <critical> <range>20</range> <multiplier>2</multiplier> </critical> <to_hit> <hit>+10/+10</hit> <magic_hit>+0</magic_hit> <total_hit>+10/+10</total_hit> </to_hit> <feat></feat> <hand>Off-hand</hand> <num_attacks>3</num_attacks> <reach>5</reach> <size>M</size> <special_properties></special_properties> <template></template> <type>PS</type> <weight>0</weight> <sequence>2</sequence> </common> <simple> <to_hit>+10/+10</to_hit> <damage>1d4+4</damage> <range>0 ft.</range> </simple> </weapon> </weapons> + + + + + <weapon> + <common> + <name> + <short>Bite</short> + <long>Bite (Natural/Primary)</long> + </name> + <category>Natural-Natural,Melee</category> + <critical> + <range>20</range> + <multiplier>2</multiplier> + </critical> + <to_hit> + <hit>+15</hit> + <magic_hit>+0</magic_hit> + <total_hit>+15</total_hit> + </to_hit> + <feat></feat> + <hand>Carried</hand> + <num_attacks>2</num_attacks> + <reach>5</reach> + <size>M</size> + <special_properties></special_properties> + <template></template> + <type>BPS</type> + <weight>0</weight> + <sequence>0</sequence> + </common> + <simple> + <to_hit>+15</to_hit> + <damage>1d6+9</damage> + <range>0 ft.</range> + </simple> + </weapon> + + + + + + <weapon> + <common> + <name> + <short>*Slam</short> + <long>*Slam (Natural/Primary)</long> + </name> + <category>Natural-Natural,Melee</category> + <critical> + <range>20</range> + <multiplier>2</multiplier> + </critical> + <to_hit> + <hit>+15</hit> + <magic_hit>+0</magic_hit> + <total_hit>+15</total_hit> + </to_hit> + <feat></feat> + <hand>Primary</hand> + <num_attacks>2</num_attacks> + <reach>5</reach> + <size>M</size> + <special_properties></special_properties> + <template></template> + <type>B</type> + <weight>0</weight> + <sequence>1</sequence> + </common> + <simple> + <to_hit>+15</to_hit> + <damage>1d6+13</damage> + <range>0 ft.</range> + </simple> + </weapon> + + + + + + <weapon> + <common> + <name> + <short>*Claw</short> + <long>*Claw (Natural/Secondary)</long> + </name> + <category>Natural-Natural,Melee</category> + <critical> + <range>20</range> + <multiplier>2</multiplier> + </critical> + <to_hit> + <hit>+10/+10</hit> + <magic_hit>+0</magic_hit> + <total_hit>+10/+10</total_hit> + </to_hit> + <feat></feat> + <hand>Off-hand</hand> + <num_attacks>3</num_attacks> + <reach>5</reach> + <size>M</size> + <special_properties></special_properties> + <template></template> + <type>PS</type> + <weight>0</weight> + <sequence>2</sequence> + </common> + <simple> + <to_hit>+10/+10</to_hit> + <damage>1d4+4</damage> + <range>0 ft.</range> + </simple> + </weapon> + </weapons> <!-- ==================================== ==================================== @@ -1406,7 +1514,8 @@ ====================================--> <spells> <!-- ### BEGIN Innate spells ### --> - <spells_innate number="none"/><!-- ### END Innate spells ### --> + <spells_innate number="none"/> +<!-- ### END Innate spells ### --> <!-- ### BEGIN Known spells ### --> <known_spells> @@ -1414,6 +1523,7 @@ </known_spells> <!-- ### END Known spells ### --> <!-- ### BEGIN memorized spells ### --> - <memorized_spells/><!-- ### END class Spellbook memorized spells ### --> + <memorized_spells/> +<!-- ### END class Spellbook memorized spells ### --> </spells> </character> Modified: Trunk/pcgen/code/testsuite/csheets/MonKee.xml =================================================================== --- Trunk/pcgen/code/testsuite/csheets/MonKee.xml 2006-05-26 21:54:47 UTC (rev 1038) +++ Trunk/pcgen/code/testsuite/csheets/MonKee.xml 2006-05-28 01:16:37 UTC (rev 1039) @@ -1,11 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <character> - <!-- - ==================================== - ==================================== - BIO - ==================================== - ====================================--> +<!--======================================================================== +BIO +========================================================================--> <basics> <bonuses></bonuses> <bonuses></bonuses> @@ -1237,13 +1234,15 @@ ====================================--> <spells> <!-- ### BEGIN Innate spells ### --> - <spells_innate number="none"/><!-- ### END Innate spells ### --> + <spells_innate number="none"/> +<!-- ### END Innate spells ### --> <!-- ### BEGIN Known spells ### --> <known_spells> </known_spells> <!-- ### END Known spells ### --> <!-- ### BEGIN memorized spells ### --> - <memorized_spells/><!-- ### END class Spellbook memorized spells ### --> + <memorized_spells/> +<!-- ### END class Spellbook memorized spells ### --> </spells> </character> Modified: Trunk/pcgen/code/testsuite/csheets/SWizSam.xml =================================================================== --- Trunk/pcgen/code/testsuite/csheets/SWizSam.xml 2006-05-26 21:54:47 UTC (rev 1038) +++ Trunk/pcgen/code/testsuite/csheets/SWizSam.xml 2006-05-28 01:16:37 UTC (rev 1039) @@ -1,11 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <character> - <!-- - ==================================== - ==================================== - BIO - ==================================== - ====================================--> +<!--======================================================================== +BIO +========================================================================--> <basics> <bonuses></bonuses> <bonuses></bonuses> @@ -1085,12 +1082,14 @@ ====================================--> <spells> <!-- ### BEGIN Innate spells ### --> - <spells_innate number="none"/><!-- ### END Innate spells ### --> + <spells_innate number="none"/> +<!-- ### END Innate spells ### --> <!-- ### BEGIN Known spells ### --> <known_spells> <class number="0" spelllistclass="Wizard" spellcastertype="Arcane"> - <level number="0" known="0" cast="3+1"> <spell> + <level number="0" known="0" cast="3+1"> + <spell> <name>Arcane Mark</name> <outputname>Arcane Mark</outputname> <times_memorized>1</times_memorized> @@ -1482,7 +1481,9 @@ <description>Subject gains +1 on saving throws.</description> <bonusspell></bonusspell> </spell> - </level> <level number="1" known="0" cast="2+1"> <spell> + </level> + <level number="1" known="0" cast="2+1"> + <spell> <name>Cause Fear</name> <outputname>Cause Fear</outputname> <times_memorized>1</times_memorized> @@ -1622,11 +1623,21 @@ <description>Reveals undead within 60 ft.</description> <bonusspell></bonusspell> </spell> - </level> <level number="2" known="0" cast="0"/> <level number="3" known="0" cast="0"/> <level number="4" known="0" cast="0"/> <level number="5" known="0" cast="0"/> <level number="6" known="0" cast="0"/> <level number="7" known="0" cast="0"/> <level number="8" known="0" cast="0"/> <level number="9" known="0" cast="0"/> </class> + </level> + <level number="2" known="0" cast="0"/> + <level number="3" known="0" cast="0"/> + <level number="4" known="0" cast="0"/> + <level number="5" known="0" cast="0"/> + <level number="6" known="0" cast="0"/> + <level number="7" known="0" cast="0"/> + <level number="8" known="0" cast="0"/> + <level number="9" known="0" cast="0"/> + </class> </known_spells> <!-- ### END Known spells ### --> <!-- ### BEGIN memorized spells ### --> - <memorized_spells/><!-- ### END class Spellbook memorized spells ### --> + <memorized_spells/> +<!-- ### END class Spellbook memorized spells ### --> </spells> </character> Modified: Trunk/pcgen/code/testsuite/csheets/WizShar.xml =================================================================== --- Trunk/pcgen/code/testsuite/csheets/WizShar.xml 2006-05-26 21:54:47 UTC (rev 1038) +++ Trunk/pcgen/code/testsuite/csheets/WizShar.xml 2006-05-28 01:16:37 UTC (rev 1039) @@ -1,11 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <character> - <!-- - ==================================== - ==================================== - BIO - ==================================== - ====================================--> +<!--======================================================================== +BIO +========================================================================--> <basics> <bonuses></bonuses> <bonuses></bonuses> @@ -1098,12 +1095,14 @@ ====================================--> <spells> <!-- ### BEGIN Innate spells ### --> - <spells_innate number="none"/><!-- ### END Innate spells ### --> + <spells_innate number="none"/> +<!-- ### END Innate spells ### --> <!-- ### BEGIN Known spells ### --> <known_spells> <class number="0" spelllistclass="Wizard" spellcastertype="Arcane"> - <level number="0" known="0" cast="3"> <spell> + <level number="0" known="0" cast="3"> + <spell> <name>Arcane Mark</name> <outputname>Arcane Mark</outputname> <times_memorized>1</times_memorized> @@ -1551,7 +1550,9 @@ <description>Subject gains +1 on saving throws.</description> <bonusspell></bonusspell> </spell> - </level> <level number="1" known="0" cast="2"> <spell> + </level> + <level number="1" known="0" cast="2"> + <spell> <name>Change Self</name> <outputname>Change Self</outputname> <times_memorized>1</times_memorized> @@ -1635,11 +1636,21 @@ <description>(CASTERLEVEL) touches deal 1d6 damage and possibly 1 Str damage.</description> <bonusspell></bonusspell> </spell> - </level> <level number="2" known="0" cast="0"/> <level number="3" known="0" cast="0"/> <level number="4" known="0" cast="0"/> <level number="5" known="0" cast="0"/> <level number="6" known="0" cast="0"/> <level number="7" known="0" cast="0"/> <level number="8" known="0" cast="0"/> <level number="9" known="0" cast="0"/> </class> + </level> + <level number="2" known="0" cast="0"/> + <level number="3" known="0" cast="0"/> + <level number="4" known="0" cast="0"/> + <level number="5" known="0" cast="0"/> + <level number="6" known="0" cast="0"/> + <level number="7" known="0" cast="0"/> + <level number="8" known="0" cast="0"/> + <level number="9" known="0" cast="0"/> + </class> </known_spells> <!-- ### END Known spells ### --> <!-- ### BEGIN memorized spells ### --> - <memorized_spells/><!-- ### END class Spellbook memorized spells ### --> + <memorized_spells/> +<!-- ### END class Spellbook memorized spells ### --> </spells> </character> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <boomer70@us...> - 2006-08-06 15:09:52
|
Revision: 1266 Author: boomer70 Date: 2006-08-06 08:09:38 -0700 (Sun, 06 Aug 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=1266&view=rev Log Message: ----------- Deprecated SOURCE token. Made it function like SOURCEPAGE until it is removed. Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SourceLst.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/SourceLst.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-08-06 04:13:42 UTC (rev 1265) +++ Trunk/pcgen/code/pluginbuild.xml 2006-08-06 15:09:38 UTC (rev 1266) @@ -1995,13 +1995,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/LstToken-SOURCE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/SourceLst.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/LstToken-SOURCEDATE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -5710,6 +5703,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/LstToken-DEPRECATED-SOURCE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/deprecated/SourceLst.class" /> + </patternset> + </fileset> + </jar> </target> <target name="manifest" description="Write the Java manifest"> Modified: Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2006-08-06 04:13:42 UTC (rev 1265) +++ Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2006-08-06 15:09:38 UTC (rev 1266) @@ -3177,3 +3177,4 @@ # 1 - Source file Errors.AbilityLoader.UnknownTag=Unknown tag "{0}" in {1} +Deprecated.SourceLst.Message=SOURCE tag has been deprecated. Use SOURCEPAGE instead. Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/SourceLst.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/SourceLst.java 2006-08-06 04:13:42 UTC (rev 1265) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/SourceLst.java 2006-08-06 15:09:38 UTC (rev 1266) @@ -1,37 +0,0 @@ -/* - * Created on Sep 2, 2005 - * - */ -package plugin.lsttokens; - -import java.util.Map; - -import pcgen.core.PObject; -import pcgen.persistence.lst.GlobalLstToken; -import pcgen.persistence.lst.SourceLoader; -import pcgen.persistence.lst.SourceLstToken; - - -/** - * @author djones4 - * - * TODO This tag doesn't appear to do anything. - * - */ -public class SourceLst implements GlobalLstToken, SourceLstToken { - - public String getTokenName() { - return "SOURCE"; - } - - public boolean parse(PObject obj, String value, int anInt) { - obj.getSourceEntry().getSourceBook().setLongName( value ); - return true; - } - - public boolean parse(Map<String, String> sourceMap, String value) { - sourceMap.putAll(SourceLoader.parseSource("SOURCE:" + value)); - return true; - } -} - Added: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SourceLst.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SourceLst.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SourceLst.java 2006-08-06 15:09:38 UTC (rev 1266) @@ -0,0 +1,47 @@ +/* + * Created on Sep 2, 2005 + * + */ +package plugin.lsttokens.deprecated; + +import java.util.Map; + +import pcgen.core.PObject; +import pcgen.persistence.lst.GlobalLstToken; +import pcgen.persistence.lst.SourceLoader; +import pcgen.persistence.lst.SourceLstToken; +import pcgen.persistence.lst.Deprecated; +import pcgen.util.PropertyFactory; + + +/** + * @author djones4 + * + * Deprecated. Seems to be used as a SOURCEPAGE tag. + * + */ +public class SourceLst implements GlobalLstToken, SourceLstToken, Deprecated { + + public String getTokenName() { + return "SOURCE"; + } + + public boolean parse(PObject obj, String value, int anInt) { + obj.getSourceEntry().getSourceBook().setLongName( value ); + return true; + } + + public boolean parse(Map<String, String> sourceMap, String value) { + sourceMap.putAll(SourceLoader.parseSource("SOURCEPAGE:" + value)); + return true; + } + + /** + * @see pcgen.persistence.lst.Deprecated#getMessage(pcgen.core.PObject, java.lang.String) + */ + public String getMessage(PObject anObj, String anValue) + { + return PropertyFactory.getString( "Deprecated.SourceLst.Message" ); //$NON-NLS-1$ + } +} + Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SourceLst.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: <boomer70@us...> - 2006-09-12 04:31:02
|
Revision: 1384 http://svn.sourceforge.net/pcgen/?rev=1384&view=rev Author: boomer70 Date: 2006-09-11 21:29:17 -0700 (Mon, 11 Sep 2006) Log Message: ----------- More ability object changes. Still very much a Work in Progress. Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/Ability.java Trunk/pcgen/code/src/java/pcgen/core/AbilityCategory.java Trunk/pcgen/code/src/java/pcgen/core/AbilityUtilities.java Trunk/pcgen/code/src/java/pcgen/core/CustomData.java Trunk/pcgen/code/src/java/pcgen/core/Domain.java Trunk/pcgen/code/src/java/pcgen/core/Equipment.java Trunk/pcgen/code/src/java/pcgen/core/EquipmentList.java Trunk/pcgen/code/src/java/pcgen/core/FollowerOption.java Trunk/pcgen/code/src/java/pcgen/core/GameMode.java Trunk/pcgen/code/src/java/pcgen/core/Globals.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/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/Race.java Trunk/pcgen/code/src/java/pcgen/core/chooser/RaceChoiceManager.java Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbility.java Trunk/pcgen/code/src/java/pcgen/core/utils/IntegerKey.java Trunk/pcgen/code/src/java/pcgen/gui/CharacterInfo.java Trunk/pcgen/code/src/java/pcgen/gui/ChooseSpellDialog.java Trunk/pcgen/code/src/java/pcgen/gui/LstEditorMain.java Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java Trunk/pcgen/code/src/java/pcgen/gui/editor/RaceBasePanel.java Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties Trunk/pcgen/code/src/java/pcgen/gui/tabs/BaseCharacterInfoTab.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoAbilities.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoRaces.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSummary.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityPoolPanel.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoPreparedSpells.java Trunk/pcgen/code/src/java/pcgen/gui/utils/JTreeTable.java Trunk/pcgen/code/src/java/pcgen/gui/utils/PObjectNode.java Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatListToken.java Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatToken.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/RaceLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/utils/FeatParser.java Trunk/pcgen/code/src/java/pcgen/util/DoubleKeyMap.java Trunk/pcgen/code/src/java/pcgen/util/enumeration/Tab.java Trunk/pcgen/code/src/java/plugin/encounter/EncounterPlugin.java Trunk/pcgen/code/src/java/plugin/encounter/RaceModel.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/template/RepeatlevelToken.java Trunk/pcgen/code/src/test/pcgen/core/PCClassTest.java Trunk/pcgen/code/src/test/pcgen/core/PlayerCharacterTest.java Trunk/pcgen/code/src/test/pcgen/core/prereq/PreBaseSizeTest.java Trunk/pcgen/code/src/test/pcgen/core/prereq/PreHDTest.java Trunk/pcgen/code/src/test/pcgen/core/prereq/PreRaceTest.java Trunk/pcgen/code/src/test/pcgen/util/TestHelper.java Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/gui/tabs/IFilterableView.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoAbility.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityModel.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilitySelectionPanel.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AvailableAbilityPanel.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/IAbilityListFilter.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/IAbilitySelectionListener.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/SelectedAbilityPanel.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/ Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/AddItemPanel.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/FilterPanel.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/RemoveItemPanel.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/AbilityCategoryLoader.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/AbilityCategoryLstToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/AbilityCategoryToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/ Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/CategoryToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/DisplayNameToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/EditPoolToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/EditableToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/FractionalPoolToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/PluralToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/PoolToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/TypeToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/VisibleToken.java Removed Paths: ------------- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoFeats.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/pluginbuild.xml 2006-09-12 04:29:17 UTC (rev 1384) @@ -5120,6 +5120,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${systemlstplugins.dir}/GameModeLstToken-ABILITYCATEGORY.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/gamemode/AbilityCategoryToken.class" /> + </patternset> + </fileset> + </jar> <!-- GameMode: BaseDice tokens--> <jar jarfile="${systemlstplugins.dir}/GameMode-BaseDiceLstToken-BASEDICE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> @@ -5315,6 +5322,70 @@ </patternset> </fileset> </jar> + <!-- GameMode: AbilityCategory tokens--> + <jar jarfile="${systemlstplugins.dir}/GameMode-AbilityCategory-CATEGORY.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/gamemode/abilitycategory/CategoryToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/GameMode-AbilityCategory-DISPLAYNAME.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/gamemode/abilitycategory/DisplayNameToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/GameMode-AbilityCategory-EDITABLE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/gamemode/abilitycategory/EditableToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/GameMode-AbilityCategory-EDITPOOL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/gamemode/abilitycategory/EditPoolToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/GameMode-AbilityCategory-FRACTIONALPOOL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/gamemode/abilitycategory/FractionalPoolToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/GameMode-AbilityCategory-PLURAL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/gamemode/abilitycategory/PluralToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/GameMode-AbilityCategory-POOL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/gamemode/abilitycategory/PoolToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/GameMode-AbilityCategory-TYPE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/gamemode/abilitycategory/TypeToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${systemlstplugins.dir}/GameMode-AbilityCategory-VISIBLE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/gamemode/abilitycategory/VisibleToken.class" /> + </patternset> + </fileset> + </jar> <!-- PointBuy tokens--> <jar jarfile="${systemlstplugins.dir}/PointBuyLstToken-METHOD.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> Modified: Trunk/pcgen/code/src/java/pcgen/core/Ability.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Ability.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/Ability.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -43,17 +43,24 @@ */ public final class Ability extends PObject implements HasCost, Categorisable { - /** Ability is Normal */ - public static final int ABILITY_NORMAL = 0; - /** Ability is Automatic */ - public static final int ABILITY_AUTOMATIC = 1; - /** Ability is Virtual */ - public static final int ABILITY_VIRTUAL = 2; + /** An enum for the various types of ability options. */ + public enum Nature { + /** Ability is Normal */ + NORMAL, + /** Ability is Automatic */ + AUTOMATIC, + /** Ability is Virtual */ + VIRTUAL, + /** Ability of any type */ + ANY + } private boolean multiples = false; private boolean needsSaving = false; private boolean stacks = false; + private Nature theNature = Nature.NORMAL; + // ///////////////////////////////////// // Fields - Associations @@ -220,21 +227,14 @@ * @param type The type of this ability (normal, automatic, virtual (see * named constants)) */ - public void setFeatType(final int type) + public void setFeatType(final Nature type) { - // Sanity check - switch (type) + if ( type == Nature.ANY ) { - case ABILITY_NORMAL: - case ABILITY_AUTOMATIC: - case ABILITY_VIRTUAL: - break; - - default: - return; + return; } - integerChar.put(IntegerKey.ABILITY_TYPE, type); + theNature = type; } /** @@ -242,10 +242,9 @@ * * @return an integer representing the abilityType */ - public int getFeatType() + public Nature getFeatType() { - Integer characteristic = integerChar.get(IntegerKey.ABILITY_TYPE); - return characteristic == null ? ABILITY_NORMAL : characteristic.intValue(); + return theNature; } /** Modified: Trunk/pcgen/code/src/java/pcgen/core/AbilityCategory.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/AbilityCategory.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/AbilityCategory.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -22,9 +22,23 @@ */ package pcgen.core; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; +import java.util.TreeSet; + +import pcgen.util.PropertyFactory; + /** * This class stores and manages information about Ability categories. * + * <p>This is a higher level abstraction than the category specified by the + * ability object itself. The low-level ability category defaults to the same + * as this category key but this can be changed. For example to specify an + * <tt>AbilityCategory</tt> "Fighter Bonus Feats" you could specify + * the ability category was "FEAT" and set the ability type to + * "Fighter". + * * @author boomer70 <boomer70@...> * * @since 5.11.1 @@ -33,29 +47,238 @@ { private String theDisplayName; private String theKeyName; + private String thePluralName; - private String thePoolFormula; - private boolean theVisibleFlag; + private String theAbilityCategory; + private Set<String> theAbilityTypes = null; + private String thePoolFormula = "0"; //$NON-NLS-1$ + + private boolean theVisibleFlag = true; + private boolean theEditableFlag = true; + private boolean theModPoolFlag = true; + private boolean theAllowFractionalPoolFlag = false; - public static final AbilityCategory FEAT = new AbilityCategory("FEAT", "in_feats"); + /** A constant used to refer to the "Feat" category. */ + public static final AbilityCategory FEAT = new AbilityCategory("FEAT", "in_feats"); //$NON-NLS-1$ //$NON-NLS-2$ + /** + * Constructs a new <tt>AbilityCategory</tt> with the specified key. + * + * <p>This method sets the display and plural names to the same value as + * the key name. + * + * @param aKeyName The name to use to reference this category. + */ + public AbilityCategory( final String aKeyName ) + { + theKeyName = aKeyName; + theDisplayName = aKeyName; + thePluralName = aKeyName; + + theAbilityCategory = aKeyName; + } + + /** + * Constructor takes a key name and display name for the category. + * + * @param aKeyName The name to use to reference this category. + * @param aDisplayName The resource key to use for the display name + */ public AbilityCategory( final String aKeyName, final String aDisplayName ) { theKeyName = aKeyName; - theDisplayName = aDisplayName; + theDisplayName = PropertyFactory.getString(aDisplayName); + thePluralName = theDisplayName; + + theAbilityCategory = aKeyName; } + + /** + * Sets the low-level ability category this category refers to. + * + * @param aCategory An ability category key string. + */ + public void setAbilityCategory(final String aCategory) + { + theAbilityCategory = aCategory; + } /** + * Gets the low-level ability category this category refers to. + * + * @return An ability category key string. + */ + public String getAbilityCategory() + { + return theAbilityCategory; + } + + /** + * Sets the list of ability types to include in this category. + * + * @param aTypeList A collection of type strings. + */ + public void setAbilityTypes(final Collection<String> aTypeList) + { + if ( theAbilityTypes == null ) + { + theAbilityTypes = new TreeSet<String>(); + } + theAbilityTypes.addAll(aTypeList); + } + + /** + * Adds a new type to the list of types included in this category. + * + * @param aType A type string. + */ + public void addAbilityType(final String aType) + { + if ( theAbilityTypes == null ) + { + theAbilityTypes = new TreeSet<String>(); + } + theAbilityTypes.add(aType); + } + + /** + * Gets the <tt>Set</tt> of all the ability types to be included in this + * category. + * + * @return An unmodifiable <tt>Set</tt> of type strings. + */ + public Set<String> getAbilityTypes() + { + if ( theAbilityTypes == null ) + { + return Collections.emptySet(); + } + return Collections.unmodifiableSet(theAbilityTypes); + } + + /** * Gets the formula to use for calculating the base pool size for this * category of ability. * - * @return + * @return A formula */ public String getPoolFormula() { return thePoolFormula; } + /** + * Sets the formula to use to calculate the base pool size for this category + * of ability. + * + * @param aFormula A valid formula or variable. + */ + public void setPoolFormula( final String aFormula ) + { + thePoolFormula = aFormula; + } + + /** + * Sets the internationalized plural name for this category. + * + * @param aName A plural name. + */ + public void setPluralName(final String aName) + { + thePluralName = aName; + } + + /** + * Returns an internationalized plural version of the category name. + * + * @return The pluralized name + */ + public String getPluralName() + { + return thePluralName; + } + + /** + * Sets if abilities of this category should be displayed in the UI. + * + * @param yesNo <tt>true</tt> if these abilities should be displayed. + */ + public void setVisible(final boolean yesNo) + { + theVisibleFlag = yesNo; + } + + /** + * Checks if this category of ability should be displayed in the UI. + * + * @return <tt>true</tt> if these abilities should be displayed. + */ + public boolean isVisible() + { + return theVisibleFlag; + } + + /** + * Sets if abilities in this category should be user-editable + * + * @param yesNo <tt>true</tt> if the user should be able to add and remove + * abilities of this category. + */ + public void setEditable(final boolean yesNo) + { + theEditableFlag = yesNo; + } + + /** + * Checks if this category of abilities is user-editable. + * + * @return <tt>true</tt> if these abilities are editable. + */ + public boolean isEditable() + { + return theEditableFlag; + } + + /** + * Sets the flag to allow/disallow user editing of the pool. + * + * @param yesNo Set to <tt>true</tt> to allow user editing. + */ + public void setModPool(final boolean yesNo) + { + theModPoolFlag = yesNo; + } + + /** + * Checks if this category allows user editing of the pool. + * + * @return <tt>true</tt> to allow user editing. + */ + public boolean allowPoolMod() + { + return theModPoolFlag; + } + + /** + * Sets if the pool can use fractional amounts. + * + * @param yesNo <tt>true</tt> to allow fractions. + */ + public void setAllowFractionalPool(final boolean yesNo) + { + theAllowFractionalPoolFlag = yesNo; + } + + /** + * Checks if the pool should use whole numbers only. + * + * @return <tt>true</tt> if fractional pool amounts are valid. + */ + public boolean allowFractionalPool() + { + return theAllowFractionalPoolFlag; + } + // ------------------------------------------- // KeyedObject Support // ------------------------------------------- @@ -90,4 +313,52 @@ { theDisplayName = aName; } + + /** + * Returns the display name for this category. + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() + { + return theDisplayName; + } + + /** + * Generates a hash code using the key, category and types. + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() + { + final int PRIME = 31; + int result = 1; + result = PRIME * result + ((theKeyName == null) ? 0 : theKeyName.hashCode()); + return result; + } + + /** + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final AbilityCategory other = (AbilityCategory) obj; + if (theKeyName == null) + { + if (other.theKeyName != null) + return false; + } + else if (!theKeyName.equals(other.theKeyName)) + return false; + return true; + } } Modified: Trunk/pcgen/code/src/java/pcgen/core/AbilityUtilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/AbilityUtilities.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/AbilityUtilities.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -123,7 +123,7 @@ final ArrayList<String> choices = new ArrayList<String>(); EquipmentUtilities.getUndecoratedName(abilityName, choices); - Ability anAbility = getAbilityFromList(theAbilityList, "FEAT", abilityName, -1); + Ability anAbility = getAbilityFromList(theAbilityList, "FEAT", abilityName, Ability.Nature.ANY); if (anAbility == null) { @@ -143,6 +143,34 @@ return anAbility; } + public static Ability addCloneOfGlobalAbilityToListWithChoices( + final List<Ability> anAbilityList, + final AbilityCategory aCategory, + final String aKey) + { + final ArrayList<String> choices = new ArrayList<String>(); + EquipmentUtilities.getUndecoratedName(aKey, choices); + + Ability anAbility = getAbilityFromList(anAbilityList, aCategory.getAbilityCategory(), aKey, Ability.Nature.ANY); + + if (anAbility == null) + { + anAbility = cloneGlobalAbility(aCategory.getAbilityCategory(), aKey); + + if (anAbility != null) + { + anAbilityList.add(anAbility); + } + } + + if (anAbility != null) + { + addChoicesToAbility(anAbility, choices); + } + + return anAbility; + } + /** * Add a virtual feat to the character and include it in the List. * @@ -167,7 +195,7 @@ if (newAbility != null) { - newAbility.setFeatType(Ability.ABILITY_VIRTUAL); + newAbility.setFeatType(Ability.Nature.VIRTUAL); newAbility.clearPreReq(); if (levelInfo != null) { @@ -474,7 +502,7 @@ final List<Ability> anAbilityList, final Categorisable abilityInfo) { - return getAbilityFromList(anAbilityList, abilityInfo, -1); + return getAbilityFromList(anAbilityList, abilityInfo, Ability.Nature.ANY); } @@ -493,7 +521,7 @@ public static Ability getAbilityFromList( final List<Ability> anAbilityList, final Categorisable abilityInfo, - final int abilityType) + final Ability.Nature abilityType) { if (anAbilityList.isEmpty()) { return null; @@ -502,7 +530,7 @@ for ( Ability ability : anAbilityList ) { if (AbilityUtilities.areSameAbility(ability, abilityInfo) && - ((abilityType == -1) || (ability.getFeatType() == abilityType))) + ((abilityType == Ability.Nature.ANY) || (ability.getFeatType() == abilityType))) { return ability; } @@ -527,7 +555,7 @@ final List<Ability> anAbilityList, final String aCat, final String aName, - final int abilityType) + final Ability.Nature abilityType) { final AbilityInfo abInfo = new AbilityInfo(aCat, aName); return getAbilityFromList(anAbilityList, abInfo, abilityType); @@ -876,7 +904,7 @@ while (aTok.hasMoreTokens()) { Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, "FEAT", aTok.nextToken()); - added.setFeatType(Ability.ABILITY_AUTOMATIC); + added.setFeatType(Ability.Nature.AUTOMATIC); } } @@ -955,7 +983,7 @@ } Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, "FEAT", autoFeat); - added.setFeatType(Ability.ABILITY_AUTOMATIC); + added.setFeatType(Ability.Nature.AUTOMATIC); } } @@ -976,7 +1004,7 @@ while (aTok.hasMoreTokens()) { Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, "FEAT", aTok.nextToken()); - added.setFeatType(Ability.ABILITY_AUTOMATIC); + added.setFeatType(Ability.Nature.AUTOMATIC); } } } @@ -1002,7 +1030,7 @@ if (idx > -1) { Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, "FEAT", aString.substring(idx + 1)); - added.setFeatType(Ability.ABILITY_AUTOMATIC); + added.setFeatType(Ability.Nature.AUTOMATIC); } else { @@ -1017,7 +1045,7 @@ { final Ability abI = (Ability)anIt.next(); Ability added = addCloneOfGlobalAbilityToListWithChoices(autoFeatList, "FEAT", abI.getKeyName()); - added.setFeatType(Ability.ABILITY_AUTOMATIC); + added.setFeatType(Ability.Nature.AUTOMATIC); } } } Modified: Trunk/pcgen/code/src/java/pcgen/core/CustomData.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/CustomData.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/CustomData.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -459,7 +459,7 @@ bw.write("#"); bw.newLine(); - for ( Race race : Globals.getRaceMap().values() ) + for ( final Race race : Globals.getAllRaces() ) { if (race.isType(Constants.s_CUSTOM)) { @@ -598,8 +598,7 @@ private static void writeCustomRaces() { - writeCustomPObjects(customRaceFilePath(true), Globals.getRaceMap() - .values().iterator()); + writeCustomPObjects(customRaceFilePath(true), Globals.getAllRaces().iterator()); } private static void writeCustomSkills() Modified: Trunk/pcgen/code/src/java/pcgen/core/Domain.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Domain.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/Domain.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -293,6 +293,11 @@ return abilityStore.getUnmodifiableList("FEAT").size(); } + public Iterator<Categorisable> getAbilityIterator(final String aCategory) + { + return abilityStore.getNameIterator(aCategory); + } + void addSpellsToClassForLevels( final PCClass aClass, final int minLevel, Modified: Trunk/pcgen/code/src/java/pcgen/core/Equipment.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Equipment.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/Equipment.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -2474,16 +2474,16 @@ * * @return a list of virtual feats granted by this item. */ - public List<Ability> getVirtualFeatList() - { - List<Ability> vFeats = new ArrayList<Ability>(super.getVirtualFeatList()); +// public List<Ability> getVirtualFeatList() +// { +// List<Ability> vFeats = new ArrayList<Ability>(super.getVirtualFeatList()); +// +// vFeats = addEqModList(true, vFeats); +// vFeats = addEqModList(false, vFeats); +// +// return vFeats; +// } - vFeats = addEqModList(true, vFeats); - vFeats = addEqModList(false, vFeats); - - return vFeats; - } - /** * Returns true if the equipment modifier is visible * @@ -2828,7 +2828,7 @@ // // Remove any modifiers that this one will replace // - final List<EquipmentModifier> eqModList = getEqModifierList(bPrimary); + List<EquipmentModifier> eqModList = getEqModifierList(bPrimary); for (int i = eqModList.size() - 1; i >= 0; --i) { @@ -2961,7 +2961,7 @@ } } - Globals.sortPObjectList(eqModList); + eqModList = Globals.sortPObjectListByName(eqModList); setBase(aPC); } @@ -2989,8 +2989,8 @@ } } - final List<EquipmentModifier> eqModList = getEqModifierList(bPrimary); - Globals.sortPObjectList(eqModList); + List<EquipmentModifier> eqModList = getEqModifierList(bPrimary); + eqModList = Globals.sortPObjectListByName(eqModList); } /** Modified: Trunk/pcgen/code/src/java/pcgen/core/EquipmentList.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/EquipmentList.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/EquipmentList.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -677,10 +677,10 @@ // creatures weren't being catered for (and therefore an OutOfBounds exception // was being thrown) - Bug 937586 // + // TODO - This should not be hardcoded to 10 final int[] gensizes = new int[10]; - final List<Race> races = new ArrayList<Race>(Globals.getRaceMap().values()); - for ( Race race : races ) + for ( final Race race : Globals.getAllRaces() ) { final int iSize = Globals.sizeInt(race.getSize()); final int flag = 1; Modified: Trunk/pcgen/code/src/java/pcgen/core/FollowerOption.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/FollowerOption.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/FollowerOption.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -106,7 +106,7 @@ { raceSet = new HashSet<Race>(); final String raceType = theRaceKey.substring(10); - final Collection<Race> allRaces = Globals.getRaceMap().values(); + final Collection<Race> allRaces = Globals.getAllRaces(); for ( final Race r : allRaces ) { if ( raceType.equalsIgnoreCase(r.getRaceType()) ) @@ -118,7 +118,7 @@ else if ( theRaceKey.equals( ANY_RACE ) ) { raceSet = new HashSet<Race>(); - raceSet.addAll( Globals.getRaceMap().values() ); + raceSet.addAll( Globals.getAllRaces() ); } if ( raceSet != null ) { Modified: Trunk/pcgen/code/src/java/pcgen/core/GameMode.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/GameMode.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/GameMode.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -34,6 +34,7 @@ import pcgen.util.enumeration.Tab; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -168,6 +169,7 @@ private boolean [] summaryTabStatColumnVisible = { true, true, true, true, true, true, true }; private boolean [] skillTabColumnVisible = { true, true, true, true, true, true, true }; // Skill, Modifier, Ranks, Total, Cost, Source, Order + private static List<AbilityCategory> theAbilityCategories = new ArrayList<AbilityCategory>(5); /** * Creates a new instance of GameMode. @@ -3039,9 +3041,61 @@ return Collections.unmodifiableList(bonusStackList); } + /** + * Checks if a bonus type should stack for this game mode. + * + * @param aBonusType The bonus type + * + * @return <tt>true</tt> if bonuses of this type stack. + */ public boolean bonusStacks( final String aBonusType ) { return bonusStackList.indexOf(aBonusType) != -1; // e.g. Dodge } + + /** + * Adds an <tt>AbilityCategory</tt> definition to the game mode. + * + * @param aCategory The <tt>AbilityCategory</tt> to add. + */ + public void addAbilityCategory(final AbilityCategory aCategory) + { + theAbilityCategories.add(aCategory); + } + + /** + * Gets the <tt>AbilityCategory</tt> for the given key. + * + * @param aKey The key of the <tt>AbilityCategory</tt> to retreive. + * + * @return The requested <tt>AbilityCategory</tt> or <tt>null</tt> if the + * category is not found in this game mode. + */ + public AbilityCategory getAbilityCategory(final String aKey) + { + for ( final AbilityCategory cat : theAbilityCategories ) + { + if ( cat.getKeyName().equalsIgnoreCase(aKey) ) + { + return cat; + } + } + return null; + } + + /** + * Returns a <tt>Collection</tt> of <tt>AbilityCategory</tt> objects defined + * by this game mode. + * + * @return A <tt>Collection</tt> of <tt>AbilityCategory</tt> objects. + */ + public Collection<AbilityCategory> getAllAbilityCategories() + { + if ( !theAbilityCategories.contains(AbilityCategory.FEAT) ) + { + theAbilityCategories.add(0, AbilityCategory.FEAT); + } + return Collections.unmodifiableCollection(theAbilityCategories); + } } Modified: Trunk/pcgen/code/src/java/pcgen/core/Globals.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -27,6 +27,7 @@ import java.io.File; import java.io.IOException; +import java.text.Collator; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -189,6 +190,7 @@ private static final StringBuffer section15 = new StringBuffer(30000); private static final String spellPoints = "0"; + /** whether or not the GUI is used (false for command line) */ private static boolean useGUI = true; @@ -204,7 +206,8 @@ { public int compare(final PObject o1, final PObject o2) { - return o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName()); + final Collator collator = Collator.getInstance(); + return collator.compare(o1.getDisplayName(), o2.getDisplayName()); } }; @@ -549,7 +552,7 @@ * follower. * * @param aType The type of Follower to get mods for. - * @return Collection of COMPANIONMODs or an EMPTY_LIST + * @return An unmodifiable Collection of COMPANIONMODs or an EMPTY_LIST * * @author boomer70 <boomer70@...> * @@ -943,7 +946,7 @@ */ public static Ability getAbilityKeyed( final AbilityCategory aCategory, final String aKey ) { - return (Ability)abilityStore.getKeyed(aCategory.getKeyName(), aKey); + return (Ability)abilityStore.getKeyed(aCategory.getAbilityCategory(), aKey); } // TODO - Remove this version @@ -986,13 +989,28 @@ */ public static List<Ability> getAbilityList( final AbilityCategory aCategory ) { - final List<? extends Categorisable> abilities = abilityStore.getUnmodifiableList( aCategory.getKeyName() ); + final List<? extends Categorisable> abilities = abilityStore.getUnmodifiableList( aCategory.getAbilityCategory() ); final List<Ability> ret = new ArrayList<Ability>(abilities.size()); for ( final Categorisable ab : abilities ) { if ( ab instanceof Ability ) { - ret.add( (Ability)ab ); + final Ability ability = (Ability)ab; + if ( aCategory.getAbilityTypes().size() > 0 ) + { + for ( final String type : aCategory.getAbilityTypes() ) + { + if ( ability.isType(type) ) + { + ret.add( ability ); + break; + } + } + } + else + { + ret.add( ability ); + } } } return Collections.unmodifiableList(ret); @@ -1032,6 +1050,25 @@ return getPObjectsOfType(abilityList, aType); } + public static Collection<String> getAbilityTypes(final AbilityCategory aCategory, final boolean visibleOnly) + { + final Set<String> typeList = new TreeSet<String>(); + for ( final Categorisable c : getUnmodifiableAbilityList(aCategory.getKeyName()) ) + { + Ability ability = null; + if ( c instanceof Ability ) + { + ability = (Ability)c; + } + else if ( c instanceof AbilityInfo ) + { + ability = ((AbilityInfo)c).getAbility(); + } + typeList.addAll( ability.getTypeList(visibleOnly) ); + } + return Collections.unmodifiableSet(typeList); + } + /** * Get game mode AC abbreviation * @return game mode AC abbreviation @@ -1504,25 +1541,6 @@ } /** - * Get's Race from raceMap() based on aKey - * @param aKey - * @return keyed Race - */ - public static Race getRaceKeyed(final String aKey) - { - return getRaceMap().get(aKey); - } - - /** - * This method gets the race map - * @return race map - */ - public static Map<String, Race> getRaceMap() - { - return raceMap; - } - - /** * This method gets the available race types as a set. * @return race types */ @@ -2313,7 +2331,7 @@ public static boolean displayListsHappy() { Logging.debugPrint("Number of objects loaded. The following should all be greater than 0:"); - Logging.debugPrint("Races=" + getRaceMap().size()); + Logging.debugPrint("Races=" + raceMap.size()); Logging.debugPrint("Classes=" + getClassList().size()); Logging.debugPrint("Skills=" + getSkillList().size()); Logging.debugPrint("Feats=" + getUnmodifiableAbilityList("FEAT").size()); @@ -2325,7 +2343,7 @@ // // NOTE: If you add something here be sure to update the debug output in pcgen.gui.MainSource in loadCampaigns_actionPerformed // - if ((getRaceMap().size() == 0) || (getClassList().size() == 0) || (getSkillList().size() == 0) + if ((raceMap.size() == 0) || (getClassList().size() == 0) || (getSkillList().size() == 0) || (getUnmodifiableAbilityList("FEAT").size() == 0) || (EquipmentList.size() == 0) || (getWeaponProfSize() == 0)) { @@ -2730,15 +2748,15 @@ */ public static void sortCampaigns() { - sortPObjectList(getClassList()); - sortPObjectList(getSkillList()); + sortPObjectListByName(getClassList()); + sortPObjectListByName(getSkillList()); // sortPObjectList(getFeatList()); Obsolete data structure - sortPObjectList(getDeityList()); - sortPObjectList(getDomainList()); + sortPObjectListByName(getDeityList()); + sortPObjectListByName(getDomainList()); Collections.sort(getArmorProfList()); - sortPObjectList(getTemplateList()); - sortPObjectList(EquipmentList.getModifierList()); - sortPObjectList(getLanguageList()); + sortPObjectListByName(getTemplateList()); + sortPObjectListByName(EquipmentList.getModifierList()); + sortPObjectListByName(getLanguageList()); setD_sorted(true); } @@ -2773,8 +2791,8 @@ } else { - Globals.sortPObjectList(availableList); - Globals.sortPObjectList(selectedList); + Globals.sortPObjectListByName(availableList); + Globals.sortPObjectListByName(selectedList); } } @@ -2789,13 +2807,15 @@ return aList; } - + /** * Sort Pcgen Object list by name + * @param <T> + * * @param aList * @return Sorted list of Pcgen Objects */ - public static List<? extends PObject> sortPObjectListByName(final List<? extends PObject> aList) + public static <T extends PObject> List<T> sortPObjectListByName(final List<T> aList) { Collections.sort(aList, pObjectNameComp); @@ -3506,7 +3526,8 @@ s_EMPTYRACE.setTypeInfo("HUMANOID"); } - getRaceMap().put(Constants.s_NONESELECTED, s_EMPTYRACE); + addRace(s_EMPTYRACE); +// getRaceMap().put(Constants.s_NONESELECTED, s_EMPTYRACE); } private static String expandRelativePath(String path) @@ -3548,17 +3569,43 @@ /** * Returns a list of default genders used by the system. * @return List of gender strings + * TODO - Genders need to become objects. */ public static List<String> getAllGenders() { ArrayList<String> ret = new ArrayList<String>(); - ret.add(PropertyFactory.getString("in_genderMale")); - ret.add(PropertyFactory.getString("in_genderFemale")); - ret.add(PropertyFactory.getString("in_genderNeuter")); - ret.add(PropertyFactory.getString("in_comboNone")); - ret.add(PropertyFactory.getString("in_comboOther")); + ret.add(PropertyFactory.getString("in_genderMale")); //$NON-NLS-1$ + ret.add(PropertyFactory.getString("in_genderFemale")); //$NON-NLS-1$ + ret.add(PropertyFactory.getString("in_genderNeuter")); //$NON-NLS-1$ + ret.add(PropertyFactory.getString("in_comboNone")); //$NON-NLS-1$ + ret.add(PropertyFactory.getString("in_comboOther")); //$NON-NLS-1$ return ret; } + /** + * Get's Race from raceMap() based on aKey + * @param aKey + * @return keyed Race + */ + public static Race getRaceKeyed(final String aKey) + { + return raceMap.get(aKey.toLowerCase()); + } + + public static void addRace(final Race aRace) + { + raceMap.put(aRace.getKeyName().toLowerCase(), aRace); + } + + public static Collection<Race> getAllRaces() + { + return Collections.unmodifiableCollection(raceMap.values()); + } + + public static boolean removeRaceKeyed(final String aKey) + { + return raceMap.remove(aKey) != null; + } + } Modified: Trunk/pcgen/code/src/java/pcgen/core/PCClass.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -46,6 +46,7 @@ import pcgen.core.utils.ShowMessageDelegate; import pcgen.persistence.PersistenceLayerException; import pcgen.persistence.lst.prereq.PreParserFactory; +import pcgen.util.DoubleKeyMap; import pcgen.util.InputFactory; import pcgen.util.InputInterface; import pcgen.util.Logging; @@ -108,6 +109,7 @@ // PCLevelInfo private HashMap<Integer, List<Ability>> vFeatMap = null; + private DoubleKeyMap<AbilityCategory, Integer, List<Ability>> vAbilityMap = null; private HashMap<Integer, String> hitDieLockMap = null; @@ -213,6 +215,9 @@ private HashMap<String, String> attackCycleMap = null; + + private DoubleKeyMap<AbilityCategory, Integer, List<String>> theAutoAbilities = null; + /** * Default Constructor. Constructs an empty PCClass. */ @@ -832,6 +837,26 @@ return Collections.unmodifiableList(featAutos); } + public Collection<String> getAutoAbilityList(final AbilityCategory aCategory) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return getFeatAutos(); + } + if ( theAutoAbilities == null ) + { + return Collections.emptyList(); + } + final List<String> ret = new ArrayList<String>(); + for ( final int lvl : theAutoAbilities.getSecondaryKeySet(aCategory) ) + { + if ( lvl <= level ) + { + ret.addAll(theAutoAbilities.get(aCategory, lvl)); + } + } + return Collections.unmodifiableList(ret); + } /** * Removes an AUTO feat from the list of feats this class grants. * @@ -847,6 +872,24 @@ featAutos.remove(Integer.toString(aLevel) + Constants.PIPE + aFeat); } + public void removeAutoAbility(final AbilityCategory aCategory, final int aLevel, final String aKey) + { + if ( aCategory == AbilityCategory.FEAT ) + { + removeFeatAuto(aLevel, aKey); + return; + } + if ( theAutoAbilities == null ) + { + return; + } + final List<String> abilities = theAutoAbilities.get(aCategory, aLevel); + if ( abilities != null ) + { + abilities.remove(aKey); + } + } + public final List<String> getFeatList() { if (featList == null) { final List<String> ret = Collections.emptyList(); @@ -1966,6 +2009,25 @@ } } + public void setAutoAbilities(final AbilityCategory aCategory, final int aLevel, final List<String> aList) + { + if ( aCategory == AbilityCategory.FEAT ) + { + setFeatAutos(aLevel, CoreUtility.join(aList, Constants.PIPE)); + return; + } + if ( theAutoAbilities == null ) + { + theAutoAbilities = new DoubleKeyMap<AbilityCategory, Integer, List<String>>(); + } + List<String> abilities = theAutoAbilities.get(aCategory, aLevel); + if ( abilities == null ) + { + abilities = new ArrayList<String>(); + } + abilities.addAll(aList); + } + public void setHitPoint(final int aLevel, final Integer iRoll) { if (hitPointMap == null) { hitPointMap = new HashMap<Integer, Integer>(); @@ -2743,6 +2805,7 @@ buildPccText(pccTxt, getFeatList().iterator(), ":", "\tFEAT:", lineSep); + // TODO - Add ABILITY tokens. buildPccText(pccTxt, getFeatAutos().iterator(), Constants.PIPE, "\tFEATAUTO:", lineSep); @@ -2784,6 +2847,28 @@ return aList; } + @Override + public List<Ability> getVirtualAbilityList(final AbilityCategory aCategory) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return getVirtualFeatList(); + } + final List<Ability> ret = new ArrayList<Ability>(); + + if ( vAbilityMap != null ) + { + for ( final int lvl : vAbilityMap.getSecondaryKeySet(aCategory) ) + { + if ( lvl <= level ) + { + ret.addAll(vAbilityMap.get(aCategory, lvl)); + } + } + } + return ret; + } + /** * Here is where we do the real work of setting the vision information on * the PObject @@ -2961,6 +3046,38 @@ templates.add(template); } + @Override + public void addVirtualAbility(final AbilityCategory aCategory, final Ability anAbility) + { + if ( aCategory == AbilityCategory.FEAT ) + { + addVirtualFeat(anAbility); + } + addVirtualAbility(aCategory, -9, anAbility); + } + + public void addVirtualAbility(final AbilityCategory aCategory, + final int aLevel, + final Ability anAbility) + { + if ( aCategory == AbilityCategory.FEAT ) + { + addVirtualFeat(anAbility); + return; + } + if ( vAbilityMap == null ) + { + vAbilityMap = new DoubleKeyMap<AbilityCategory, Integer, List<Ability>>(); + } + List<Ability> abilities = vAbilityMap.get(aCategory, aLevel); + if ( abilities == null ) + { + abilities = new ArrayList<Ability>(); + } + abilities.add(anAbility); + } + + /** * Adds virtual feats to the vFeatMao * @@ -2986,6 +3103,33 @@ super.addVirtualFeats(vList); } + @Override + public void addVirtualAbilities(final AbilityCategory aCategory, final List<Ability> aList) + { + if ( aCategory == AbilityCategory.FEAT ) + { + addVirtualFeats(aList); + return; + } + addVirtualAbilities(aCategory, -9, aList); + } + + public void addVirtualAbilities(final AbilityCategory aCategory, + final int aLevel, + final List<Ability> aList) + { + if ( aCategory == AbilityCategory.FEAT ) + { + addVirtualFeats(aLevel, aList); + return; + } + if ( vAbilityMap == null ) + { + vAbilityMap = new DoubleKeyMap<AbilityCategory, Integer, List<Ability>>(); + } + vAbilityMap.put(aCategory, aLevel, aList); + } + /** * returns the value at which another attack is gained attackCycle of 4 * means a second attack is gained at a BAB of +5/+1 @@ -3145,6 +3289,10 @@ if (vFeatMap != null) { aClass.vFeatMap = new HashMap<Integer, List<Ability>>(vFeatMap); } + if ( vAbilityMap != null ) + { + aClass.vAbilityMap = new DoubleKeyMap<AbilityCategory, Integer, List<Ability>>(vAbilityMap); + } if (hitDieLockMap != null) { aClass.hitDieLockMap = new HashMap<Integer, String>( hitDieLockMap); @@ -3152,6 +3300,10 @@ if (featAutos != null) { aClass.featAutos = new ArrayList<String>(featAutos); } + if ( theAutoAbilities != null ) + { + aClass.theAutoAbilities = new DoubleKeyMap<AbilityCategory, Integer, List<String>>(theAutoAbilities); + } // TODO - Why is this not copying the skillList from the master? aClass.skillList = null; @@ -5755,4 +5907,19 @@ } return; } + + public void removeAutoAbilities(final AbilityCategory aCategory, final int aLevel) + { + if ( aCategory == AbilityCategory.FEAT ) + { + removeAllAutoFeats(aLevel); + return; + } + + if ( theAutoAbilities == null ) + { + return; + } + theAutoAbilities.put(aCategory, aLevel, null); + } } Modified: Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/PCTemplate.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -31,6 +31,8 @@ import java.util.HashMap; 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; import pcgen.core.prereq.PrereqHandler; @@ -39,6 +41,7 @@ import pcgen.core.utils.ListKey; import pcgen.persistence.PersistenceLayerException; import pcgen.persistence.lst.prereq.PreParserFactory; +import pcgen.util.DoubleKeyMap; import pcgen.util.PropertyFactory; import pcgen.util.chooser.ChooserFactory; import pcgen.util.chooser.ChooserInterface; @@ -58,11 +61,20 @@ private AbilityStore abilityCatStore = null; private ArrayList<String> featStrings = null; + /** A Map storing a List of Ability keys Keyed on AbilityCategory */ + private Map<AbilityCategory, List<String>> theAutoAbilityKeys = null; private ArrayList<String> hitDiceStrings = null; - private ArrayList<String> levelStrings = null; private ArrayList<String> templates = new ArrayList<String>(); private HashMap<String, String> chosenFeatStrings = null; + + /** + * A Map storing a Map of chosen Ability keys keyed on the level it is + * granted at with a prefix of L (level-based) or H (hitdice-based) keyed on + * AbilityCategory. + */ + private Map<AbilityCategory, Map<String, String>> theChosenAbilityKeys = null; + private List<String> templatesAdded = null; private String cost = "1"; @@ -97,6 +109,13 @@ private ArrayList<String> removedSubTypes = new ArrayList<String>(); private ArrayList<String> levelMods = new ArrayList<String>(); + + /** + * A DoubleKeyMap storing abilities to be granted at a certain level. + * The Map uses level as a primary key and the ability type as the secondary + * key. + */ + private DoubleKeyMap<Integer, String, String> theLevelAbilities = null; /** * Creates a new PCTemplate object. @@ -181,14 +200,15 @@ { int localCR = ChallengeRating; - for (int x = 0; x < getListSize(levelStrings); ++x) + if ( theLevelAbilities != null ) { - if ( - contains(levelStrings.get(x), "CR:") && - doesLevelQualify(level, x)) + for ( int lvl = 0; lvl < level; lvl++ ) { - localCR += Integer.parseInt( - getStringAfter("CR:", levelStrings.get(x))); + final String crValue = theLevelAbilities.get(lvl, "CR"); + if ( crValue != null ) + { + localCR += Integer.parseInt(crValue); + } } } @@ -206,8 +226,6 @@ return localCR; } - - /** * Get a list of Feats chosen (from those potentially granted by this * Template) by the Character it was applied to. @@ -219,7 +237,16 @@ return chosenFeatStrings; } - + // TODO - This is rather gross. The class should not give out this sort of + // internal information. + public Map<String, String> getChosenAbilityKeys(final AbilityCategory aCategory) + { + if (theChosenAbilityKeys != null ) + { + return theChosenAbilityKeys.get(aCategory); + } + return null; + } /** * Set the COST of things granted by this Template. * @@ -555,6 +582,29 @@ 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)) { @@ -596,12 +646,10 @@ txt.append("\tLANGBONUS:").append(buffer.toString()); } - if (getListSize(levelStrings) > 0) + final List<String> las = getLevelAbilities(); + for ( final String la : las ) { - for (Iterator<String> e = levelStrings.iterator(); e.hasNext();) - { - txt.append("\tLEVEL:").append(e.next()); - } + txt.append("\t").append(la); } if (!"0".equals(levelAdjustment)) @@ -888,16 +936,16 @@ { int aSR = getSR(aPC); - for (int x = 0; x < getListSize(levelStrings); ++x) + if ( theLevelAbilities != null ) { - if ( - contains(levelStrings.get(x), "SR:") && - doesLevelQualify(level, x)) + for ( int lvl = 0; lvl < level; lvl++ ) { - aSR = Math.max( - Integer.parseInt( - getStringAfter("SR:", levelStrings.get(x))), - aSR); + final String srValue = theLevelAbilities.get(lvl, "SR"); + if ( srValue != null ) + { + final int sr = Integer.parseInt(srValue); + aSR = Math.max(aSR, sr); + } } } @@ -937,18 +985,15 @@ return specialAbilityList; } - for (int x = 0; x < getListSize(levelStrings); ++x) + if ( theLevelAbilities != null ) { - if ( - contains(levelStrings.get(x), "SA:") && - doesLevelQualify(level, x)) + for ( int lvl = 0; lvl < level; lvl++ ) { - final String saString = getStringAfter( - "SA:", - levelStrings.get(x)); - final SpecialAbility sa = new SpecialAbility(saString); - - specialAbilityList.add(sa); + final String saString = theLevelAbilities.get(lvl, "SA"); + if ( saString != null ) + { + specialAbilityList.add(new SpecialAbility(saString)); + } } } @@ -1153,44 +1198,40 @@ /** * Grants the character an ability at the level specified (total character level). - * The text may contain the following tags: CR - Challenge Rating, DR - Damage - * Reduction, FEAT - Feat, SA - Special Ability, SR - Spell Resistance + * + * <p>The type parameter may contain the following tags: + * <ul> + * <li>CR - Challenge Rating</li> + * <li>DR - Damage Reduction</li> + * <li>FEAT - Feat</li> + * <li>SA - Special Ability</li> + * <li>SR - Spell Resistance</li> + * </ul> * - * Feats added by this tag are considered automatic feats and do not count against + * <p>Feats added by this tag are considered automatic feats and do not count against * a PC's feat pool. * - * 1:DR:5/+1 Grants Damage Reduction of 5/+1 at Level 1. + * <p>Example:<br /> + * <code>addLevelAbility(1,"DR", "5/+1");<br/> + * Grants Damage Reduction of 5/+1 at Level 1. + * <p> + * <code>addLevelAbility(6, "FEAT", "TYPE.Fighter");<br /> + * Produces a popup menu at Level 6 from which a PC can choose a fighter feat. * - * 2:SR:15 Grants Spell Resistance of 15 at Level 2. - * - * 3:CR:2 Grants an increase in Challenge Rating of two at Level 3. - * - * 4:SA:Uncanny Dodge Grants the "Uncanny Dodge" special ability at Level 4. - * - * 5:FEAT:Alertness Grants the "Alertness" feat at Level 5. - * - * 6:FEAT:TYPE.Fighter Produces a popup menu at Level 6 from which a PC can choose a fighter feat. - * - * @param levelString a sting in the formate specified above + * @param aLevel The level at which this ability will be granted + * @param aType One of the types listed above + * @param aValue A String to use as the value for that type + * */ - public void addLevelString(final String levelString) + public void addLevelAbility(final int aLevel, final String aType, final String aValue) { - if (".CLEAR".equals(levelString)) + if ( theLevelAbilities == null ) { - if (levelStrings != null) - { - levelStrings.clear(); - } - - return; + theLevelAbilities = new DoubleKeyMap<Integer, String, String>(); } - StringTokenizer tok = new StringTokenizer(levelString, ":"); - String levelStr = tok.nextToken(); - String typeStr = tok.nextToken(); - if ("DR".equals(typeStr)) + if ("DR".equals(aType)) { - String drVal = tok.nextToken(); - String[] values = drVal.split("/"); + String[] values = aValue.split("/"); if (values.length == 2) { DamageReduction dr = new DamageReduction(values[0], values[1]); @@ -1199,7 +1240,7 @@ try { PreParserFactory factory = PreParserFactory.getInstance(); - r = factory.parse("PRELEVEL:" + levelStr); + r = factory.parse("PRELEVEL:" + aLevel); } catch (PersistenceLayerException notUsed) { @@ -1213,41 +1254,35 @@ } return; } + theLevelAbilities.put(aLevel, aType, aValue); + } - if (levelStrings == null) + public void clearLevelAbilities() + { + theLevelAbilities = null; + } + + public List<String> getLevelAbilities() + { + final List<String> ret = new ArrayList<String>(); + + if ( theLevelAbilities != null ) { - levelStrings = new ArrayList<String>(); + for ( final int lvl : theLevelAbilities.getKeySet() ) + { + for ( final String type : theLevelAbilities.getSecondaryKeySet(lvl) ) + { + final String value = theLevelAbilities.get(lvl, type); + final StringBuffer txt = new StringBuffer(200); + txt.append("LEVEL:").append(lvl).append(":").append(type).append(":").append(value); + ret.add(txt.toString()); + } + } } - - levelStrings.add(levelString); + return ret; } - - + /** - * Grants the character an ability at the level specified (total character level). - * The text may contain the following tags: CR - Challenge Rating, DR - Damage - * Reduction, FEAT - Feat, SA - Special Ability, SR - Spell Resistance - * - * 1:DR:5/+1 Grants Damage Reduction of 5/+1 at Level 1. - * - * 2:SR:15 Grants Spell Resistance of 15 at Level 2. - * - * 3:CR:2 Grants an increase in Challenge Rating of two at Level 3. - * - * 4:SA:Uncanny Dodge Grants the "Uncanny Dodge" special ability at Level 4. - * - * 5:FEAT:Alertness Grants the "Alertness" feat at Level 5. - * - * 6:FEAT:TYPE.Fighter Produces a popup menu at Level 6 from which a PC can choose a fighter feat. - * - * @return an array of stings in the format specified - */ - public List<String> getLevelStrings() - { - return levelStrings != null ? levelStrings : Collections.EMPTY_LIST; - } - - /** * Add a list of subsidiary Templates to this template i.e. Templates (or * choices of templates) that this Template will grant. * @@ -1334,9 +1369,9 @@ final PCTemplate aTemp = (PCTemplate) super.clone(); aTemp.templates = new ArrayList<String>(templates); - if (getListSize(levelStrings) != 0) + if ( theLevelAbilities != null ) { - aTemp.levelStrings = new ArrayList<String>(levelStrings); + aTemp.theLevelAbilities = new DoubleKeyMap<Integer, String, String>(theLevelAbilities); } if (getListSize(hitDiceStrings) != 0) @@ -1344,11 +1379,6 @@ aTemp.hitDiceStrings = new ArrayList<String>(hitDiceStrings); } - // if (getArrayListSize(sizeStrings) != 0) - // { - // aTemp.sizeStrings = (ArrayList) sizeStrings.clone(); - // } - if (abilityCatStore != null) { aTemp.abilityCatStore = new AbilityStore(); aTemp.abilityCatStore.addAbilityInfo( @@ -1360,11 +1390,20 @@ 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>(chosenFeatStrings); } + if ( theChosenAbilityKeys != null ) + { + aTemp.theChosenAbilityKeys = new HashMap<AbilityCategory, Map<String, String>>(theChosenAbilityKeys); + } return aTemp; } @@ -1707,32 +1746,7 @@ (hitdice <= Integer.parseInt(tokens.nextToken())); } - /** - * Is the level greater or equal to the level in the levelString - * indexed by index - * - * @param level The level to test - * @param index index of the level String to test - * - * @return true if level is >= the level referenced by index - */ - private boolean doesLevelQualify(final int level, final int index) - { - if (index >= getListSize(levelStrings)) - { - return false; - } - - final StringTokenizer stuff = new StringTokenizer( - levelStrings.get(index), - ":"); - - return level >= Integer.parseInt(stuff.nextToken()); - } - - - /** * This is the function that implements a chooser for Feats granted by level * and/or HD by Templates. * @@ -1741,70 +1755,125 @@ * @param featKey either L<lvl> or H<lvl> * @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 levelString, + final String featString, final int lvl, - final String featKey, + final String aKey, final PlayerCharacter aPC) { - if (contains(levelString, "FEAT:")) + String featKe = null; + while (true) { - String featName = getStringAfter("FEAT:", levelString); + List<String> featList = new ArrayList<String>(); + final LevelAbility la = LevelAbility.createAbility( + this, + lvl, + "FEAT(" + featString + ")"); - while (true) + la.process(featList, aPC, null); + + switch (featList.size()) { - List<String> featList = new ArrayList<String>(); - final LevelAbility la = LevelAbility.createAbility( - this, - lvl, - "FEAT(" + featName + ")"); + case 1: + featKe = featList.get(0); - la.process(featList, aPC, null); + break; - switch (featList.size()) - { - case 1: - featName = featList.get(0); + default: - break; + if ((aPC != null) && !aPC.isImporting()) + { + Collections.sort(featList); - default: + final ChooserInterface c = ChooserFactory.getChooserInstance(); + c.setPool(1); + c.setTitle("Feat Choice"); + c.setAvailableList(featList); + c.setVisible(true); + featList = c.getSelectedList(); - if ((aPC != null) && !aPC.isImporting()) + if ((featList != null) && (featList.size() != 0)) { - Collections.sort(featList); + featKe = featList.get(0); - final ChooserInterface c = ChooserFactory.getChooserInstance(); - c.setPool(1); - c.setTitle("Feat Choice"); - c.setAvailableList(featList); - c.setVisible(true); - featList = c.getSelectedList(); + continue; + } + } - if ((featList != null) && (featList.size() != 0)) - { - featName = featList.get(0); + // fall-through intentional + case 0: + return; + } - continue; - } + break; + } + + final LevelAbility la = LevelAbility.createAbility(this, lvl, "FEAT(" + featString + ")"); + + aPC.setAllowFeatPoolAdjustment(false); + la.process(null, aPC, null); + aPC.setAllowFeatPoolAdjustment(true); + + 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; + // fall-through intentional + case 0: + return; } - final LevelAbility la = LevelAbility.createAbility(this, lvl, "FEAT(" + featName + ")"); + break; + } + final LevelAbility la = LevelAbility.createAbility(this, aLevel, "FEAT(" + abilityKey + ")"); - aPC.setAllowFeatPoolAdjustment(false); - la.process(null, aPC, null); - aPC.setAllowFeatPoolAdjustment(true); + aPC.setAllowFeatPoolAdjustment(false); + la.process(null, aPC, null); + aPC.setAllowFeatPoolAdjustment(true); - addChosenFeat(featKey, featName); - } + addChosenFeat("L"+aLevel, abilityKey); } @@ -1824,7 +1893,26 @@ chosenFeatStrings.put(mapKey, mapValue); } - + public void addChosenAbility(final AbilityCategory aCategory, final String aKey, final String aChoice) + { + if ( aCategory == AbilityCategory.FEAT ) + { + addChosenFeat(aKey, aChoice); + return; + } + if ( theChosenAbilityKeys == null ) + { + theChosenAbilityKeys = new HashMap<AbilityCategory, Map<String, String>>(); + } + Map<String, String> choices = theChosenAbilityKeys.get(aCategory); + if ( choices == null ) + { + choices = new HashMap<String, String>(); + theChosenAbilityKeys.put(aCategory, choices); + } + choices.put(aKey, aChoice); + } + /** * Add a | separated list of available abilities that this Template may * grant. This is the function called by the Lst parser to make the @@ -1872,6 +1960,26 @@ 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! @@ -1928,9 +2036,33 @@ feats.addAll(chosenFeatStrings.values()); } - for (int x = 0; x < getListSize(levelStrings); ++x) + if ( theLevelAbilities != null ) { - final String featKey = "L" + Integer.toString(x); + for ( int lvl = 0; lvl < level; lvl++ ) + { + // Check for an already selected value + final String lvlKey = "L" + String.valueOf(lvl); + String featKey = null; + if ( chosenFeatStrings != null ) + { + featKey = chosenFeatStrings.get(lvlKey); + } + + // We haven't selected one yet. Ask for one if we are allowed. + if ( featKey == null && addNew == true ) + { + final String featString = theLevelAbilities.get(lvl, "FEAT"); + if ( featString != null ) + { + getLevelFeat(featString, lvl, lvlKey, aPC); + } + } + } + } + + for (int x = 0; x < getListSize(hitDiceStrings); ++x) + { + final String featKey = "H" + Integer.toString(x); String featName = null; if (chosenFeatStrings != null) @@ -1940,13 +2072,57 @@ if ((featName == null) && addNew) { - if (doesLevelQualify(level, x)) + if (doesHitDiceQualify(hitdice, x)) { - getLevelFeat(levelStrings.get(x), level, featKey, aPC); + getLevelFeat(hitDiceStrings.get(x), -1, featKey, aPC); } } } + 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); @@ -1959,16 +2135,15 @@ if ((featName == null) && addNew) { - if (doesHitDiceQualify(hitdice, x)) + if (doesHitDiceQualify(aPC.totalHitDice(), x)) { getLevelFeat(hitDiceStrings.get(x), -1, featKey, aPC); } } } - return feats; + return ret; } - /** * Set face * @param width Modified: Trunk/pcgen/code/src/java/pcgen/core/PObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -143,6 +143,8 @@ private Map<String, List<FollowerOption>> theAvailableFollowers = null; private ArrayList<String> weaponProfBonus = null; + + private Map<AbilityCategory, List<Ability>> theVirtualAbilities = null; /* ************ * Methods @@ -760,6 +762,19 @@ return getSafeListFor(ListKey.VIRTUAL_FEATS); } + public List<Ability> getVirtualAbilityList(final AbilityCategory aCategory) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return getVirtualFeatList(); + } + if ( theVirtualAbilities != null ) + { + return theVirtualAbilities.get(aCategory); + } + return Collections.emptyList(); + } + /** * Add automatic weapon proficienies for this object * @param aString @@ -1075,6 +1090,26 @@ listChar.addToListFor(ListKey.VIRTUAL_FEATS, aFeat); } + public void addVirtualAbility(final AbilityCategory aCategory, final Ability anAbility) + { + if ( aCategory == AbilityCategory.FEAT ) + { + addVirtualFeat(anAbility); + return; + } + if ( theVirtualAbilities == null ) + { + theVirtualAbilities = new HashMap<AbilityCategory, List<Ability>>(); + } + List<Ability> abilities = theVirtualAbilities.get(aCategory); + if ( abilities == null ) + { + abilities = new ArrayList<Ability>(); + theVirtualAbilities.put(aCategory, abilities); + } + abilities.add(anAbility); + } + /** * Add a list of virtual feats to the character list * @param aFeatList @@ -1084,6 +1119,26 @@ listChar.addAllToListFor(ListKey.VIRTUAL_FEATS, aFeatList); } + public void addVirtualAbilities(final AbilityCategory aCategory, final List<Ability> aList) + { + if ( aCategory == AbilityCategory.FEAT ) + { + addVirtualFeats(aList); + return; + } + if ( theVirtualAbilities == null ) + { + theVirtualAbilities = new HashMap<AbilityCategory, List<Ability>>(); + } + List<Ability> abilities = theVirtualAbilities.get(aCategory); + if ( abilities == null ) + { + abilities = new ArrayList<Ability>(); + theVirtualAbilities.put(aCategory, abilities); + } + abilities.addAll(aList); + } + /** * Clear the variable list */ @@ -2152,6 +2207,22 @@ return aType.toString(); } + public List<String> getTypeList(final boolean visibleOnly) + { + final List<String> ret = getSafeListFor(ListKey.TYPE); + if ( visibleOnly == true ) + { + for ( int i = getMyTypeCount(); i >= 0; --i ) + { + if ( isTypeHidden(i) ) + { + ret.remove(i); + } + } + } + return Collections.unmodifiableList(ret); + } + /** * If aType begins with an " (Exclamation Mark) the " will be * removed before checking the type. Modified: Trunk/pcgen/code/src/java/pcgen/core/PObjectUtilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObjectUtilities.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/PObjectUtilities.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -798,7 +798,7 @@ { // CHOOSE:RACE|RACETYPE=x,RACESUBTYPE=y,<racename>,TYPE=z // or CHOOSE:RACE|[RACETYPE=x,RACESUBTYPE=y] - Collection races = Globals.getRaceMap().values(); + Collection races = Globals.getAllRaces(); while (aTok.hasMoreTokens()) { Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -29,8 +29,8 @@ import java.io.File; import java.io.FileInputStream; import java.io.FilenameFilter; +import java.io.IOException; import java.io.InputStreamReader; -import java.io.IOException; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; @@ -51,7 +51,13 @@ import pcgen.core.bonus.Bonus; import pcgen.core.bonus.BonusObj; -import pcgen.core.character.*; +import pcgen.core.character.CharacterSpell; +import pcgen.core.character.CompanionMod; +import pcgen.core.character.EquipSet; +import pcgen.core.character.EquipSlot; +import pcgen.core.character.Follower; +import pcgen.core.character.SpellBook; +import pcgen.core.character.SpellInfo; import pcgen.core.levelability.LevelAbility; import pcgen.core.pclevelinfo.PCLevelInfo; import pcgen.core.prereq.PrereqHandler; @@ -60,15 +66,20 @@ import pcgen.core.spell.PCSpellTracker; import pcgen.core.spell.Spell; import pcgen.core.system.GameModeRollMethod; -import pcgen.core.utils.*; +import pcgen.core.utils.CoreUtility; +import pcgen.core.utils.ListKey; +import pcgen.core.utils.MessageType; +import pcgen.core.utils.ShowMessageDelegate; +import pcgen.core.utils.StringKey; +import pcgen.core.utils.StringKeyMap; import pcgen.gui.GuiConstants; +import pcgen.io.PCGFile; import pcgen.io.exporttoken.BonusToken; -import pcgen.io.PCGFile; import pcgen.persistence.PersistenceLayerException; -import pcgen.persistence.PersistenceManager; import pcgen.persistence.lst.prereq.PreParserFactory; import pcgen.util.BigDecimalHelper; import pcgen.util.Delta; +import pcgen.util.DoubleKeyMap; import pcgen.util.Logging; import pcgen.util.PropertyFactory; import pcgen.util.enumeration.Load; @@ -93,8 +104,6 @@ // List of Armor Proficiencies private final ArrayList<String> armorProfList = new ArrayList<String>(); - // List of Feats - private final ArrayList<Ability> featList = new ArrayList<Ability>(); // List of misc items (Assets, Magic items, etc) private final ArrayList<String> miscList = new ArrayList<String>(3); @@ -160,9 +169,6 @@ // List of Kit objects private List<Kit> kitList = null; - private List<Ability> stableAggregateFeatList = null; - private List<Ability> stableAutomaticFeatList = null; - private List<Ability> stableVirtualFeatList = null; // Spells private PCSpellTracker spellTracker = null; @@ -190,8 +196,6 @@ // Movement lists private Double[] movements = Globals.EMPTY_DOUBLE_ARRAY; - // Whether one can trust the most recently calculated aggregateFeatList - private boolean aggregateFeatsStable = false; private boolean armorProfListStable = false; // whether to add auto known spells each level @@ -207,8 +211,6 @@ // Should we sort the gear automatically? private boolean autoSortGear = true; - // Whether one can trust the most recently calculated automaticFeatList - private boolean automaticFeatsStable = false; private boolean qualifyListStable = false; private final boolean useMonsterDefault = SettingsHandler.isMonsterDefault(); @@ -224,14 +226,7 @@ // Should temp mods/bonuses be used/saved? private boolean useTempMods = true; - // Whether one can trust the most recently calculated virtualFeatList - private boolean virtualFeatsStable = false; - // whether to adjust the feat pool when requested - private boolean allowFeatPoolAdjustment = true; - - // pool of feats remaining to distribute - private double feats = 0; private int age = 0; // 0 = LG to 8 = CE and 9 is <none selected> @@ -259,6 +254,19 @@ private boolean processLevelAbilities = true; + /** + * Abilities stored as a double key map. The keys are the Category and + * type (Normal, Virtual, or Automatic). The value is a list of abilities + * that match the keys. + */ + private DoubleKeyMap<AbilityCategory, Ability.Nature, List<Ability>> theAbilities = new DoubleKeyMap<AbilityCategory, Ability.Nature, List<Ability>>(); + + /** + * This map stores any user bonuses (entered through the GUI) to the + * corrisponding ability pool. + */ + private Map<AbilityCategory, BigDecimal> theUserPoolBonuses = null; + /////////////////////////////////////// //operations /** @@ -282,7 +290,7 @@ statList.addStat((PCStat)stat.clone()); } - setRace(Globals.getRaceMap().get(Constants.s_NONESELECTED)); + setRace(Globals.s_EMPTYRACE); setName(Constants.EMPTY_STRING); setFeats(0); rollStats(SettingsHandler.getGame().getRollMethod()); @@ -333,26 +341,6 @@ } /** - * Set aggregate Feats stable - * @param stable - */ - public void setAggregateFeatsStable(final boolean stable) - { - aggregateFeatsStable = stable; - //setDirty(true); - } - - /** - * Returns TRUE if all types (automatic, virtual and aggregate) - * of feats are stable - * @return TRUE or FALSE - */ - public boolean isAggregateFeatsStable() - { - return automaticFeatsStable && virtualFeatsStable && aggregateFeatsStable; - } - - /** * Alignment of this PC * @return alignment */ @@ -451,16 +439,6 @@ } /** - * Sets a 'stable' list of automatic feats - * @param stable - */ - public void setAutomaticFeatsStable(final boolean stable) - { - automaticFeatsStable = stable; - //setDirty(true); - } - - /** * Returns the Spell Stat bonus for a class * @param aClass * @return base spell stat bonus @@ -1124,6 +1102,10 @@ getVariableProcessor().setSerial(serial); } + // TODO - This is kind of strange. We probably either only want to + // notify our observers if we have gone from not dirty to dirty and not + // the reverse case. At a minimum we should probably tell them the + // state anyway. if (dirtyFlag != dirtyState) { dirtyFlag = dirtyState; @@ -1471,207 +1453,6 @@ } /** - * Add a "real" (not virtual or auto) feat to the character - * - * @param aFeat the Ability (of category FEAT) to add - * - * @return true if added successfully - */ - public boolean addRealFeat(final Ability aFeat) - { - //return abilityStore.addCategorisable(aFeat) - return featList.add(aFeat); - } - - /** - * Remove all "real" (not auto or auto) feats from the character - */ - public void clearRealFeats() - { - featList.clear(); - } - - /** - * Get number of "real" (not virtual or auto) feats the character has - * - * @return DOCUMENT ME! - */ - public int getNumberOfRealFeats() - { - return featList.size(); - } - - public List<Ability> getRealFeatsList() - { - return new ArrayList<Ability>(featList); - } - - /** - * Get an iterator over all the feats "Real" feats For Example, not virtual or auto - * - * @return an iterator - */ - public List<Ability> getRealFeatList() - { - return featList; - } - - - /** - * Returns the Feat definition searching by key (not name), as contained in - * the <b>chosen</b> feat list. - * - * @param featName String key of the feat to check for. - * - * @return the Feat (not the CharacterFeat) searched for, <code>null</code> - * if not found. - */ - public Ability getRealFeatKeyed(final String featName) - { - return getFeatKeyed(featName, featList); - } - - - /** - * Returns the Feat definition searching by name, as contained in the <b> - * chosen</b> feat list. - * - * @param featName String key of the feat to check for. - * - * @return the Feat (not the CharacterFeat) searched for, <code>null</code> - * if not found. - */ - - public Ability getRealFeatNamed(final String featName) - { - return AbilityUtilities.getAbilityFromList(featList, "FEAT", featName, -1); - } - - - /** - * Does the character have this feat (not virtual or auto). - * - * @param aFeat The Ability object (of category FEAT) to check - * - * @return True if the character has the feat - */ - public boolean hasRealFeat(final Ability aFeat) - { - //return (abilityStore.getCategorisableNamed(aCategory, aFeat) != null); - return featList.contains(aFeat); - } - - - /** - * Check if the characterFeat ArrayList contains the named Feat. - * - * @param featName String name of the feat to check for. - * @return <code>true</code> if the character has the feat, - * <code>false</code> otherwise. - */ - - public boolean hasRealFeatNamed(final String featName) - { - return AbilityUtilities.getAbilityFromList(featList, "FEAT", featName, -1) != null; - } - - - /** - * Remove a "real" (for example, not virtual or auto) feat from the character. - * - * @param aFeat the Ability (of category FEAT) to remove - * @return True if successfully removed - */ - public boolean removeRealFeat(final Ability aFeat) - { - return featList.remove(aFeat); - } - - - public void adjustFeats(final double arg) - { - if (allowFeatPoolAdjustment) - { - feats += arg; - } - setDirty(true); - } - - public void setFeats(final double arg) - { - if (allowFeatPoolAdjustment) - { - feats = arg; - } - setDirty(true); - } - - public BigDecimal getTotalAbilityPool( final AbilityCategory aCategory ) - { - if ( aCategory == AbilityCategory.FEAT ) - { - return BigDecimal.valueOf(getFeats()); - } - Float basePool = this.getVariableValue(aCategory.getPoolFormula(), getClass().toString()); - double bonus = getTotalBonusTo("ABILITYPOOL", aCategory.getKeyName()); - return BigDecimal.valueOf(basePool + bonus); - } - - public BigDecimal getAbilityPoolSpent( final AbilityCategory aCategory ) - { - double spent = 0.0d; - - final List<Ability> abilities = getSelectedAbilities( aCategory ); - for ( final Ability ability : abilities ) - { - final int subfeatCount = ability.getAssociatedCount(); - - if (subfeatCount > 1) - { - spent += subfeatCount; - } - else - { - spent += ability.getCost(this); - } - } - return BigDecimal.valueOf(spent); - } - - public BigDecimal getAvailableAbilityPool( final AbilityCategory aCategory ) - { - return getTotalAbilityPool(aCategory).subtract(getAbilityPoolSpent(aCategory)); - } - - public List<Ability> getSelectedAbilities( final AbilityCategory aCategory ) - { - if ( aCategory == AbilityCategory.FEAT ) - { - return getRealFeatList(); - } - return Collections.emptyList(); - } - - public double getFeats() - { - if (Globals.getGameModeHasPointPool()) - { - return getSkillPoints(); - } - return getRawFeats(true); - } - - public double getRawFeats(final boolean bIncludeBonus) - { - double retVal = feats; - if (bIncludeBonus) - { - retVal += getBonusFeatPool(); - } - return retVal; - } - - /** * Get a number that represents the number of feats added to this character * by BONUS statements. * @@ -1712,6 +1493,7 @@ } /** +>>>>>>> .r1382 * Checks whether a PC is allowed to level up. A PC is not allowed to * level up if the "Enforce Spending" option is set and he still has * unallocated skill points and/or feat slots remaining. @@ -1729,44 +1511,6 @@ } /** - * Query whether this PC should be able to select the ability passed - * in. That is, does the PC meet the prerequisites and is the feat not - * one the PC already has, or if the PC has the feat already, is it one that - * can be taken multiple times. - * @param anAbility the ability to test - * @return true if the PC can take, false otherwise - */ - public boolean canSelectAbility (final Ability anAbility) - { - return this.canSelectAbility(anAbility, false); - } - - /** - * Query whether this PC should be able to select the ability passed - * in. That is, does the PC meet the prerequisites and is the feat not - * one the PC already has, or if the PC has the feat already, is it one that - * can be taken multiple times. - * TODO: When the PlayerCharacter Object can have abilities of category - * other than "FEAT" it will likely have methods to test "hasRealAbility" and - * "hasVirtualAbilty", change this (or add another) to deal with them - * - * @param anAbility the ability to test - * @param autoQualify if true, the PC automatically meets the prerequisites - * @return true if the PC can take, false otherwise - */ - public boolean canSelectAbility (final Ability anAbility, final boolean autoQualify) - { - final boolean qualify = this.qualifiesForFeat(anAbility); - final boolean canTakeMult = anAbility.isMultiples(); - final boolean hasOrdinary = this.hasRealFeat(anAbility); - final boolean hasAuto = this.hasFeatAutomatic(anAbility.getKeyName()); - - final boolean notAlreadyHas = !(hasOrdinary || hasAuto); - - return (autoQualify || qualify) && (canTakeMult || notAlreadyHas); - } - - /** * Sets the filename of the character. * @param newFileName */ @@ -3279,40 +3023,6 @@ return getSafeStringFor(StringKey.TRAIT2); } - /** - * get unused feat count - * @return unused feat count - */ - public double getUsedFeatCount() - { - double iCount = 0; - - for (Ability aFeat : getRealFeatList()) - { - // - // Don't increment the count for - // hidden feats so the number - // displayed matches this number - // - //if (aFeat.getVisibility() == Visibility.HIDDEN) - //{ - // continue; - //} - final int subfeatCount = aFeat.getAssociatedCount(); - - if (subfeatCount > 1) - { - iCount += subfeatCount; - } - else - { - iCount += aFeat.getCost(this); - } - } - - return iCount; - } - public Float getVariable(final String variableString, final boolean isMax, final boolean includeBonus, final String matchSrc, final String matchSubSrc, int decrement) { return getVariable(variableString, isMax, includeBonus, matchSrc, matchSubSrc, true, decrement); @@ -3573,12 +3283,6 @@ return new Float(value); } - public void setVirtualFeatsStable(final boolean stable) - { - virtualFeatsStable = stable; - //setDirty(true); - } - public TreeSet<WeaponProf> getWeaponProfList() { final TreeSet<WeaponProf> wp = new TreeSet<WeaponProf>(weaponProfList); @@ -3697,28 +3401,6 @@ setDirty(true); } - public void addFeat(final Ability aFeat, final PCLevelInfo playerCharacterLevelInfo) - { - if (hasRealFeat(aFeat)) - { - Logging.errorPrint("Adding duplicate feat: " + aFeat.getDisplayName()); - } - - if (!addRealFeat(aFeat)) - { - Logging.errorPrint("Problem adding feat: " + aFeat.getDisplayName()); - } - - if (playerCharacterLevelInfo != null) - { - // Add this feat to the level Info - playerCharacterLevelInfo.addObject(aFeat); - } - addNaturalWeapons(aFeat.getNaturalWeapons()); - setAggregateFeatsStable(false); - calcActiveBonuses(); - } - public void addFollower(final Follower aFollower) { followerList.add(aFollower); @@ -5023,16 +4705,6 @@ return favored; } - public Ability getAbilityAutomaticKeyed(final AbilityCategory aCategory, final String anAbilityKey) - { - return AbilityUtilities.getAbilityFromList(abilityAutoList(aCategory), aCategory.getKeyName(), anAbilityKey, -1); - } - - public Ability getFeatAutomaticKeyed(final String aFeatKey) - { - return AbilityUtilities.getAbilityFromList(featAutoList(), "FEAT", aFeatKey, -1); - } - /** * Calculates total bonus from Feats * @param aType @@ -5057,10 +4729,10 @@ */ public Ability getFeatNamed(final String featName) { - return AbilityUtilities.getAbilityFromList(aggregateFeatList(), "FEAT", featName, -1); + return AbilityUtilities.getAbilityFromList(aggregateFeatList(), "FEAT", featName, Ability.Nature.ANY); } - public Ability getFeatNamed(final String featName, final int featType) + public Ability getFeatNamed(final String featName, final Ability.Nature featType) { return AbilityUtilities.getAbilityFromList(aggregateFeatList(), "FEAT", featName, featType); } @@ -5077,19 +4749,6 @@ return AbilityUtilities.getAbilityFromList(aggregateFeatList(), anAbility); } - /** - * Returns the Feat definition searching by key (not name), as - * found in the <b>aggregate</b> feat list. - * - * @param featName String key of the feat to check for. - * @return the Feat (not the CharacterFeat) searched for, - * <code>null</code> if not found. - */ - public Ability getFeatKeyed(final String featName) - { - return getFeatKeyed(featName, aggregateFeatList()); - } - public int getFirstSpellLevel(final Spell aSpell) { int anInt = 0; @@ -6662,148 +6321,6 @@ } - public List<Ability> getVirtualFeatList() - { - List<Ability> vFeatList = getStableVirtualFeatList(); - - //Did we get a valid list? If so, return it. - if (vFeatList != null) - { - return vFeatList; - } - setVirtualFeatsStable(true); - vFeatList = new ArrayList<Ability>(); - if (stableVirtualFeatList != null) - { - for ( Ability feat : stableVirtualFeatList ) - { - if (feat.needsSaving()) - { - if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { - vFeatList.add(feat); - } - } - } - } - - for ( PCClass pcClass : classList ) - { - final List<Ability> aList = pcClass.getVirtualFeatList(pcClass.getLevel()); - - for ( Ability feat : aList ) - { - if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { - vFeatList.add(feat); - } - } - } - - for (Ability aFeat : getRealFeatList()) - { - final List<Ability> aList = aFeat.getVirtualFeatList(); - - for ( Ability feat : aList ) - { - if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { - vFeatList.add(feat); - } - } - } - - for ( PCTemplate template : templateList ) - { - final List<Ability> aList = template.getVirtualFeatList(); - - for ( Ability feat : aList ) - { - if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { - vFeatList.add(feat); - } - } - } - - for ( Equipment eq : equipmentList ) - { - if (eq.isEquipped()) - { - // This already includes the EqMods - final List<Ability> aList = eq.getVirtualFeatList(); - for ( Ability feat : aList ) - { - // TODO Check for duplicates? - if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { - vFeatList.add(feat); - } - } - } - } - - if (getRace() != null) - { - final List<Ability> aList = getRace().getVirtualFeatList(); - for ( Ability feat : aList ) - { - // TODO Check for duplicates? - if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { - vFeatList.add(feat); - } - } - } - - for ( Skill skill : getSkillList() ) - { - final List<Ability> aList = skill.getVirtualFeatList(); - - for ( Ability feat : aList ) - { - if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { - vFeatList.add(feat); - } - } - } - - for ( CharacterDomain cd : characterDomainList ) - { - if (cd.getDomain() != null) - { - final List<Ability> aList = cd.getDomain().getVirtualFeatList(); - - for ( Ability feat : aList ) - { - if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { - vFeatList.add(feat); - } - } - } - } - if (deity != null) - { - final List<Ability> aList = deity.getVirtualFeatList(); - - for ( Ability feat : aList ) - { - if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { - vFeatList.add(feat); - } - } - } - for ( CompanionMod cMod : companionModList ) - { - final List<Ability> aList = cMod.getVirtualFeatList(); - - for ( Ability feat : aList ) - { - if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { - vFeatList.add(feat); - } - } - } - - setStableVirtualFeatList(vFeatList); - - return vFeatList; - } - private Map<String, String> getVisionMap() { Map<String, String> visMap = new HashMap<String, String>(); @@ -8315,107 +7832,6 @@ return ""; } - public List<Ability> aggregateFeatList() - { - final List<Ability> aggregate = getStableAggregateFeatList(); - - //Did we get a valid list? If so, return it. - if (aggregate != null) - { - return aggregate; - } - - return rebuildFeatAggreagateList(); - } - - private List<Ability> rebuildFeatAggreagateList() - { - List<Ability> aggregate = new ArrayList<Ability>(); - final Map<String, Ability> aHashMap = new HashMap<String, Ability>(); - - for (Ability aFeat : getRealFeatList()) - { - if (aFeat != null) - { - aHashMap.put(aFeat.getKeyName(), aFeat); - } - } - - for ( Ability vFeat : getVirtualFeatList() ) - { - if (!aHashMap.containsKey(vFeat.getKeyName())) - { - aHashMap.put(vFeat.getKeyName(), vFeat); - } - else if (vFeat.isMultiples()) - { - Ability aggregateFeat = aHashMap.get(vFeat.getKeyName()); - aggregateFeat = (Ability) aggregateFeat.clone(); - - for (int e1 = 0; e1 < vFeat.getAssociatedCount(); ++e1) - { - final String aString = vFeat.getAssociated(e1); - - if (aggregateFeat.isStacks() || !aggregateFeat.containsAssociated(aString)) - { - aggregateFeat.addAssociated(aString); - } - } - - aHashMap.put(vFeat.getKeyName(), aggregateFeat); - } - } - - aggregate.addAll(aHashMap.values()); - setStableAggregateFeatList(aggregate); - - for ( Ability autoFeat : featAutoList() ) - { - if (!aHashMap.containsKey(autoFeat.getKeyName())) - { - aHashMap.put(autoFeat.getKeyName(), autoFeat); - } - - else if (autoFeat.isMultiples()) - { - Ability aggregateFeat = aHashMap.get(autoFeat.getKeyName()); - aggregateFeat = (Ability) aggregateFeat.clone(); - - for (int e1 = 0; e1 < autoFeat.getAssociatedCount(); ++e1) - { - final String aString = autoFeat.getAssociated(e1); - if (aggregateFeat.isStacks() || !aggregateFeat.containsAssociated(aString)) - { - aggregateFeat.addAssociated(aString); - } - } - - aHashMap.put(autoFeat.getKeyName(), aggregateFeat); - } - } - - aggregate = new ArrayList<Ability>(); - aggregate.addAll(aHashMap.values()); - setStableAggregateFeatList(aggregate); - return aggregate; - } - - public List<Ability> aggregateVisibleFeatList() - { - final List<Ability> tempFeatList = new ArrayList<Ability>(); - - for ( Ability feat : aggregateFeatList() ) - { - if ((feat.getVisibility() == Visibility.DEFAULT) - || (feat.getVisibility() == Visibility.OUTPUT_ONLY)) - { - tempFeatList.add(feat); - } - } - - return tempFeatList; - } - /** * Calculate different kinds of bonuses to saves. * possible tokens are @@ -8686,33 +8102,6 @@ return calcACOfType("Equipment") + calcACOfType("Armor"); } - public List<Ability> abilityAutoList(final AbilityCategory aCategory) - { - if ( aCategory.equals(AbilityCategory.FEAT) ) - { - return featAutoList(); - } - return Collections.emptyList(); -// final List<Ability> autoAbilityList = getStableAutomaticAbilityList(aCategory); -// -// if ( autoAbilityList != null ) -// { -// return autoAbilityList; -// } - } - public List<Ability> featAutoList() - { - final List<Ability> autoFeatList = getStableAutomaticFeatList(); - - //Did we get a valid list? If so, return it. - if (autoFeatList != null) - { - return autoFeatList; - } - - return AbilityUtilities.rebuildAutoAbilityList(this); - } - public int flatfootedAC() { return calcACOfType("Flatfooted"); @@ -8741,7 +8130,7 @@ */ public boolean hasFeatAutomatic(final String featName) { - return AbilityUtilities.getAbilityFromList(featAutoList(), "FEAT", featName, -1) != null; + return AbilityUtilities.getAbilityFromList(featAutoList(), "FEAT", featName, Ability.Nature.ANY) != null; } /** @@ -8753,9 +8142,53 @@ */ public boolean hasFeatVirtual(final String featName) { - return AbilityUtilities.getAbilityFromList(getVirtualFeatList(), "FEAT", featName, -1) != null; + return AbilityUtilities.getAbilityFromList(getVirtualFeatList(), "FEAT", featName, Ability.Nature.ANY) != null; } + /** + * Does the character have this ability as an auto ability. + * + * @param aCategory The ability category to check. + * @param anAbility The Ability object to check + * + * @return <tt>true</tt> if the character has the ability + */ + public boolean hasAutomaticAbility(final AbilityCategory aCategory, final Ability anAbility) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return hasFeatAutomatic(anAbility.getKeyName()); + } + final List<Ability> abilities = theAbilities.get(aCategory, Ability.Nature.AUTOMATIC); + if ( abilities == null ) + { + return false; + } + return abilities.contains(anAbility); + } + + /** + * Does the character have this ability as a virtual ability. + * + * @param aCategory The ability category to check. + * @param anAbility The Ability object to check + * + * @return <tt>true</tt> if the character has the ability + */ + public boolean hasVirtualAbility(final AbilityCategory aCategory, final Ability anAbility) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return hasFeatVirtual(anAbility.getKeyName()); + } + final List<Ability> abilities = theAbilities.get(aCategory, Ability.Nature.VIRTUAL); + if ( abilities == null ) + { + return false; + } + return abilities.contains(anAbility); + } + public boolean hasMadeKitSelectionForAgeSet(final int index) { return ((index >= 0) && (index < 10) && ageSetKitSelections[index]); @@ -9697,7 +9130,7 @@ */ public void populateSkills(final int level) { - Globals.sortPObjectList(getSkillList()); + Globals.sortPObjectListByName(getSkillList()); removeExcessSkills(level); addNewSkills(level); @@ -10591,11 +10024,6 @@ return aList; } - boolean isAutomaticFeatsStable() - { - return automaticFeatsStable; - } - /** * Calculates total bonus from Checks * @param aType @@ -11243,45 +10671,6 @@ return aList; } - private List<Ability> getStableAggregateFeatList() - { - if (isAggregateFeatsStable()) - { - return stableAggregateFeatList; - } - return null; - } - - void setStableAutomaticFeatList(final List<Ability> aFeatList) - { - stableAutomaticFeatList = aFeatList; - setAutomaticFeatsStable(aFeatList != null); - } - - private List<Ability> getStableAutomaticFeatList() - { - if (isAutomaticFeatsStable()) - { - return stableAutomaticFeatList; - } - return null; - } - - private void setStableVirtualFeatList(final List<Ability> aFeatList) - { - stableVirtualFeatList = aFeatList; - setVirtualFeatsStable(aFeatList != null); - } - - private List<Ability> getStableVirtualFeatList() - { - if (isVirtualFeatsStable()) - { - return stableVirtualFeatList; - } - return null; - } - /** * Used to create the Bonus HashMap from all active bonuses * @param aBonus @@ -11731,7 +11120,7 @@ } ; - Ability anAbility = AbilityUtilities.getAbilityFromList(aFeatList, "FEAT", featKey, -1); + Ability anAbility = AbilityUtilities.getAbilityFromList(aFeatList, "FEAT", featKey, Ability.Nature.ANY); if (anAbility != null) { @@ -11769,7 +11158,7 @@ if (isAuto) { - anAbility.setFeatType(Ability.ABILITY_AUTOMATIC); + anAbility.setFeatType(Ability.Nature.AUTOMATIC); } aFeatList.add(anAbility); @@ -15112,4 +14501,1511 @@ } } */ + + // -------------------------------------------------- + // Feat/Ability stuff + // -------------------------------------------------- + + // List of Feats + private final ArrayList<Ability> featList = new ArrayList<Ability>(); + private List<Ability> stableAggregateFeatList = null; + private List<Ability> stableAutomaticFeatList = null; + private List<Ability> stableVirtualFeatList = null; + + // Whether one can trust the most recently calculated aggregateFeatList + private boolean aggregateFeatsStable = false; + // Whether one can trust the most recently calculated automaticFeatList + private boolean automaticFeatsStable = false; + // Whether one can trust the most recently calculated virtualFeatList + private boolean virtualFeatsStable = false; + + // whether to adjust the feat pool when requested + private boolean allowFeatPoolAdjustment = true; + + // pool of feats remaining to distribute + private double feats = 0; + + /** + * Set aggregate Feats stable + * @param stable + */ + public void setAggregateFeatsStable(final boolean stable) + { + aggregateFeatsStable = stable; + //setDirty(true); + } + + public void setAggregateAbilitiesStable(final AbilityCategory aCategory, + final boolean stable) + { + if ( aCategory == AbilityCategory.FEAT ) + { + setAggregateFeatsStable(stable); + } + } + + /** + * Returns TRUE if all types (automatic, virtual and aggregate) + * of feats are stable + * @return TRUE or FALSE + */ + public boolean isAggregateFeatsStable() + { + return automaticFeatsStable && virtualFeatsStable && aggregateFeatsStable; + } + + public boolean isAggregateAbilitiesStable(final AbilityCategory aCategory) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return isAggregateFeatsStable(); + } + return false; + } + + /** + * Sets a 'stable' list of automatic feats + * @param stable + */ + public void setAutomaticFeatsStable(final boolean stable) + { + automaticFeatsStable = stable; + //setDirty(true); + } + + public void setAutomaticAbilitiesStable(final AbilityCategory aCategory, + final boolean stable) + { + if ( aCategory == AbilityCategory.FEAT ) + { + setAutomaticFeatsStable(stable); + } + if ( stable == false ) + { + theAbilities.put(aCategory, Ability.Nature.AUTOMATIC, null); + } + } + + /** + * Add a "real" (not virtual or auto) feat to the character + * + * @param aFeat the Ability (of category FEAT) to add + * + * @return true if added successfully + */ + public boolean addRealFeat(final Ability aFeat) + { + //return abilityStore.addCategorisable(aFeat) + return featList.add(aFeat); + } + + public boolean addRealAbility(final AbilityCategory aCategory, + final Ability anAbility) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return addRealFeat( anAbility ); + } + + if ( anAbility == null ) + { + return false; + } + anAbility.setFeatType(Ability.Nature.NORMAL); + List<Ability> abilities = theAbilities.get(aCategory, Ability.Nature.NORMAL); + if ( abilities == null ) + { + abilities = new ArrayList<Ability>(); + theAbilities.put(aCategory, Ability.Nature.NORMAL, abilities); + } + abilities.add(anAbility); + return true; + } + + /** + * Remove all "real" (not auto or auto) feats from the character + */ + public void clearRealFeats() + { + featList.clear(); + } + + public void clearRealAbilities(final AbilityCategory aCategory) + { + if ( aCategory == AbilityCategory.FEAT ) + { + clearRealFeats(); + return; + } + + theAbilities.put(aCategory, Ability.Nature.NORMAL, null); + } + + /** + * Get number of "real" (not virtual or auto) feats the character has + * + * @return DOCUMENT ME! + */ + public int getNumberOfRealFeats() + { + return featList.size(); + } + + public int getNumberOfRealAbilities(final AbilityCategory aCategory) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return getNumberOfRealFeats(); + } + + final List<Ability> abilities = theAbilities.get(aCategory, Ability.Nature.NORMAL); + if ( abilities == null ) + { + return 0; + } + return abilities.size(); + } + + public List<Ability> getRealFeatsList() + { + return new ArrayList<Ability>(featList); + } + + public List<Ability> getRealAbilitiesList(final AbilityCategory aCategory) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return getRealFeatsList(); + } + + final List<Ability> abilities = theAbilities.get(aCategory, Ability.Nature.NORMAL); + if ( abilities == null ) + { + return Collections.emptyList(); + } + return new ArrayList<Ability>(abilities); + } + + /** + * Get an iterator over all the feats "Real" feats For Example, not virtual or auto + * + * @return an iterator + */ + public List<Ability> getRealFeatList() + { + return featList; + } + + public List<Ability> getRealAbilityList( final AbilityCategory aCategory ) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return getRealFeatList(); + } + final List<Ability> ret = theAbilities.get(aCategory, Ability.Nature.NORMAL); + if ( ret == null ) + { + return Collections.emptyList(); + } + return ret; + } + + /** + * Returns the Feat definition searching by key (not name), as contained in + * the <b>chosen</b> feat list. + * + * @param featName String key of the feat to check for. + * + * @return the Feat (not the CharacterFeat) searched for, <code>null</code> + * if not found. + */ + public Ability getRealFeatKeyed(final String featName) + { + return getFeatKeyed(featName, featList); + } + + public Ability getRealAbilityKeyed(final AbilityCategory aCategory, final String aKey) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return getRealFeatKeyed(aKey); + } + + final List<Ability> abilities = theAbilities.get(aCategory, Ability.Nature.NORMAL); + + if ( abilities != null ) + { + for ( final Ability ability : abilities ) + { + if ( ability.getKeyName().equals(aKey) ) + { + return ability; + } + } + } + + return null; + } + + /** + * Returns the Feat definition searching by name, as contained in the <b> + * chosen</b> feat list. + * + * @param featName String key of the feat to check for. + * + * @return the Feat (not the CharacterFeat) searched for, <code>null</code> + * if not found. + */ + + public Ability getRealFeatNamed(final String featName) + { + return AbilityUtilities.getAbilityFromList(featList, "FEAT", featName, Ability.Nature.ANY); + } + + + /** + * Does the character have this feat (not virtual or auto). + * + * @param aFeat The Ability object (of category FEAT) to check + * + * @return True if the character has the feat + */ + public boolean hasRealFeat(final Ability aFeat) + { + //return (abilityStore.getCategorisableNamed(aCategory, aFeat) != null); + return featList.contains(aFeat); + } + + /** + * Does the character have this ability (not virtual or auto). + * + * @param aCategory The ability category to check. + * @param anAbility The Ability object (of category FEAT) to check + * + * @return True if the character has the feat + */ + public boolean hasRealAbility(final AbilityCategory aCategory, final Ability anAbility) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return hasRealFeat(anAbility); + } + + final List<Ability> abilities = theAbilities.get(aCategory, Ability.Nature.NORMAL); + if ( abilities == null ) + { + return false; + } + return abilities.contains(anAbility); + } + + /** + * Checks if the character has the specified ability. + * + * <p>If <tt>aCategory</tt> is <tt>null</tt> then all categories that have + * the same innate ability category will be checked. + * <p>If <tt>anAbilityType</tt> is <tt>ANY</tt> then all Natures will be + * checked for the ability. + * + * @param aCategory An <tt>AbilityCategory</tt> or <tt>null</tt> + * @param anAbilityType A <tt>Nature</tt>. + * @param anAbility The <tt>Ability</tt> to check for. + * + * @return <tt>true</tt> if the character has the ability with the criteria + * specified. + */ + public boolean hasAbility(final AbilityCategory aCategory, + final Ability.Nature anAbilityType, + final Ability anAbility) + { + final List<AbilityCategory> categories; + if ( aCategory == null ) + { + // A null category means we have to check all categories for + // abilities of the same innate category as the passed in one. + categories = new ArrayList<AbilityCategory>(); + final Collection<AbilityCategory> allCategories = SettingsHandler.getGame().getAllAbilityCategories(); + for ( final AbilityCategory cat : allCategories ) + { + if ( cat.getAbilityCategory().equals(anAbility.getCategory()) ) + { + categories.add(cat); + } + } + } + else + { + categories = new ArrayList<AbilityCategory>(); + categories.add(aCategory); + } + + final int start, end; + if ( anAbilityType == Ability.Nature.ANY ) + { + start = 0; + end = Ability.Nature.values().length - 2; + } + else + { + start = end = anAbilityType.ordinal(); + } + for (int i = start; i < end; i++ ) + { + final Ability.Nature nature = Ability.Nature.values()[i]; + boolean hasIt = false; + for ( final AbilityCategory cat : categories ) + { + if ( cat == AbilityCategory.FEAT ) + { + switch ( nature ) + { + case NORMAL: + hasIt = hasRealAbility(cat, anAbility); + break; + case AUTOMATIC: + hasIt = hasAutomaticAbility(cat, anAbility); + break; + case VIRTUAL: + hasIt = hasVirtualAbility(cat, anAbility); + break; + } + } + else + { + final List<Ability> abilities = theAbilities.get(cat, nature); + if ( abilities == null ) + { + continue; + } + if ( abilities.contains(anAbility) ) + { + hasIt = true; + } + } + if ( hasIt == true ) + { + return true; + } + } + } + return false; + } + + /** + * Check if the characterFeat ArrayList contains the named Feat. + * + * @param featName String name of the feat to check for. + * @return <code>true</code> if the character has the feat, + * <code>false</code> otherwise. + */ + + public boolean hasRealFeatNamed(final String featName) + { + return AbilityUtilities.getAbilityFromList(featList, "FEAT", featName, Ability.Nature.ANY) != null; + } + + + /** + * Remove a "real" (for example, not virtual or auto) feat from the character. + * + * @param aFeat the Ability (of category FEAT) to remove + * @return True if successfully removed + */ + public boolean removeRealFeat(final Ability aFeat) + { + return featList.remove(aFeat); + } + + public boolean removeRealAbility( final AbilityCategory aCategory, final Ability anAbility ) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return removeRealFeat(anAbility); + } + + final List<Ability> abilities = theAbilities.get(aCategory, Ability.Nature.NORMAL); + if ( abilities == null ) + { + return false; + } + return abilities.remove(anAbility); + } + + public void adjustFeats(final double arg) + { + if (allowFeatPoolAdjustment) + { + feats += arg; + } + setDirty(true); + } + + public void adjustAbilities(final AbilityCategory aCategory, final BigDecimal arg) + { + if ( arg.equals(BigDecimal.ZERO) ) + { + return; + } + if ( aCategory == AbilityCategory.FEAT ) + { + adjustFeats(arg.doubleValue()); + return; + } + if ( theUserPoolBonuses == null ) + { + theUserPoolBonuses = new HashMap<AbilityCategory, BigDecimal>(); + } + BigDecimal userMods = theUserPoolBonuses.get( aCategory ); + if ( userMods != null ) + { + userMods = userMods.add(arg); + } + else + { + userMods = arg; + } + theUserPoolBonuses.put(aCategory, userMods); + setDirty(true); + } + + // TODO - This method is ridiculously dangerous. + public void setFeats(final double arg) + { + if (allowFeatPoolAdjustment) + { + feats = arg; + } + setDirty(true); + } + + public void setAbilities(final AbilityCategory aCategory, final double arg) + { + if ( aCategory == AbilityCategory.FEAT ) + { + setFeats(arg); + return; + } + } + + public double getUserPoolBonus( final AbilityCategory aCategory ) + { + if ( aCategory == AbilityCategory.FEAT ) + { + throw new IllegalArgumentException("This method is not valid for feats."); //$NON-NLS-1$ + } + BigDecimal userBonus = null; + if ( theUserPoolBonuses != null ) + { + userBonus = theUserPoolBonuses.get(aCategory); + } + if ( userBonus == null ) + { + return 0.0d; + } + return userBonus.doubleValue(); + } + + public BigDecimal getTotalAbilityPool( final AbilityCategory aCategory ) + { + Float basePool = this.getVariableValue(aCategory.getPoolFormula(), getClass().toString()); + if ( aCategory.allowFractionalPool() == false ) + { + basePool = new Float(basePool.intValue()); + } + double bonus = getTotalBonusTo("ABILITYPOOL", aCategory.getKeyName()); + if ( aCategory.allowFractionalPool() == false ) + { + bonus = Math.floor(bonus); + } + // User bonuses already handle the fractional pool flag. + final double userBonus = getUserPoolBonus(aCategory); + return BigDecimal.valueOf(basePool + bonus + userBonus); + } + + public List<Ability> getSelectedAbilities( final AbilityCategory aCategory ) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return getRealFeatList(); + } + return getRealAbilityList(aCategory); + } + + public double getFeats() + { + if (Globals.getGameModeHasPointPool()) + { + return getSkillPoints(); + } + return getRawFeats(true); + } + + public BigDecimal getAvailableAbilityPool( final AbilityCategory aCategory ) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return BigDecimal.valueOf(getFeats()); + } + return getTotalAbilityPool(aCategory).subtract(getAbilityPoolSpent(aCategory)); + } + + public double getRawFeats(final boolean bIncludeBonus) + { + double retVal = feats; + if (bIncludeBonus) + { + retVal += getBonusFeatPool(); + } + return retVal; + } + + /** + * Query whether this PC should be able to select the ability passed + * in. That is, does the PC meet the prerequisites and is the feat not + * one the PC already has, or if the PC has the feat already, is it one that + * can be taken multiple times. + * @param anAbility the ability to test + * @return true if the PC can take, false otherwise + */ + public boolean canSelectAbility (final Ability anAbility) + { + return this.canSelectAbility(anAbility, false); + } + + /** + * Query whether this PC should be able to select the ability passed + * in. That is, does the PC meet the prerequisites and is the feat not + * one the PC already has, or if the PC has the feat already, is it one that + * can be taken multiple times. + * TODO: When the PlayerCharacter Object can have abilities of category + * other than "FEAT" it will likely have methods to test "hasRealAbility" and + * "hasVirtualAbilty", change this (or add another) to deal with them + * + * @param anAbility the ability to test + * @param autoQualify if true, the PC automatically meets the prerequisites + * @return true if the PC can take, false otherwise + */ + public boolean canSelectAbility (final Ability anAbility, final boolean autoQualify) + { + final boolean qualify = this.qualifiesForFeat(anAbility); + final boolean canTakeMult = anAbility.isMultiples(); + final boolean hasOrdinary = this.hasRealFeat(anAbility); + final boolean hasAuto = this.hasFeatAutomatic(anAbility.getKeyName()); + + final boolean notAlreadyHas = !(hasOrdinary || hasAuto); + + return (autoQualify || qualify) && (canTakeMult || notAlreadyHas); + } + + /** + * get unused feat count + * @return unused feat count + */ + public double getUsedFeatCount() + { + double iCount = 0; + + for (Ability aFeat : getRealFeatList()) + { + // + // Don't increment the count for + // hidden feats so the number + // displayed matches this number + // + //if (aFeat.getVisibility() == Visibility.HIDDEN) + //{ + // continue; + //} + final int subfeatCount = aFeat.getAssociatedCount(); + + if (subfeatCount > 1) + { + iCount += subfeatCount; + } + else + { + iCount += aFeat.getCost(this); + } + } + + return iCount; + } + + public BigDecimal getAbilityPoolSpent( final AbilityCategory aCategory ) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return BigDecimal.valueOf(getUsedFeatCount()); + } + + double spent = 0.0d; + + final List<Ability> abilities = getSelectedAbilities( aCategory ); + if ( abilities != null ) + { + for ( final Ability ability : abilities ) + { + final int subfeatCount = ability.getAssociatedCount(); + + if (subfeatCount > 1) + { + spent += subfeatCount; + } + else + { + if ( aCategory.allowFractionalPool() == false ) + { + spent += (int)Math.ceil(ability.getCost(this)); + } + else + { + spent += ability.getCost(this); + } + } + } + } + if ( aCategory.allowFractionalPool() == false ) + { + return BigDecimal.valueOf((int)Math.ceil(spent)); + } + return BigDecimal.valueOf(spent); + } + + public double getUsedAbilityCount(final AbilityCategory aCategory) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return getUsedFeatCount(); + } + + return getAbilityPoolSpent(aCategory).doubleValue(); + } + + public void setVirtualFeatsStable(final boolean stable) + { + virtualFeatsStable = stable; + //setDirty(true); + } + + public void setVirtualAbilitiesStable(final AbilityCategory aCategory, final boolean stable) + { + if ( aCategory == AbilityCategory.FEAT ) + { + setVirtualFeatsStable(stable); + return; + } + if ( stable == false ) + { + theAbilities.put(aCategory, Ability.Nature.VIRTUAL, null); + } + } + + public void addFeat(final Ability aFeat, final PCLevelInfo playerCharacterLevelInfo) + { + if (hasRealFeat(aFeat)) + { + Logging.errorPrint("Adding duplicate feat: " + aFeat.getDisplayName()); + } + + if (!addRealFeat(aFeat)) + { + Logging.errorPrint("Problem adding feat: " + aFeat.getDisplayName()); + } + + if (playerCharacterLevelInfo != null) + { + // Add this feat to the level Info + playerCharacterLevelInfo.addObject(aFeat); + } + addNaturalWeapons(aFeat.getNaturalWeapons()); + setAggregateFeatsStable(false); + calcActiveBonuses(); + } + + public void addAbility(final AbilityCategory aCategory, final Ability anAbility, final PCLevelInfo aLevelInfo) + { + if ( hasRealAbility(aCategory, anAbility) ) + { + Logging.errorPrint("Adding duplicate ability: " + anAbility.getDisplayName()); + } + + if (!addRealAbility(aCategory, anAbility)) + { + Logging.errorPrint("Problem adding ability: " + anAbility.getDisplayName()); + } + if (aLevelInfo != null) + { + // Add this feat to the level Info + aLevelInfo.addObject(anAbility); + } + addNaturalWeapons(anAbility.getNaturalWeapons()); + setAggregateAbilitiesStable(aCategory, false); + calcActiveBonuses(); + } + + public Ability getFeatAutomaticKeyed(final String aFeatKey) + { + return AbilityUtilities.getAbilityFromList(featAutoList(), "FEAT", aFeatKey, Ability.Nature.ANY); + } + + public Ability getAutomaticAbilityKeyed(final AbilityCategory aCategory, final String anAbilityKey) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return getFeatAutomaticKeyed(anAbilityKey); + } + final List<Ability> abilities = getAutomaticAbilityList(aCategory); + for ( final Ability ability : abilities ) + { + if ( ability.getKeyName().equals(anAbilityKey) ) + { + return ability; + } + } + return null; + } + + public Ability getVirtualFeatKeyed(final String aKey) + { + return AbilityUtilities.getAbilityFromList(getVirtualFeatList(), "FEAT", aKey, Ability.Nature.ANY); + + } + + // TODO - Consolidate the various getXXXAbility functions to take a ability + // type parameter. + public Ability getVirtualAbilityKeyed(final AbilityCategory aCategory, final String aKey) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return getVirtualFeatKeyed(aKey); + } + + final List<Ability> abilities = getVirtualAbilityList(aCategory); + for ( final Ability ability : abilities ) + { + if ( ability.getKeyName().equals(aKey) ) + { + return ability; + } + } + return null; + } + + public int addAbility( + final PCLevelInfo LevelInfo, + final AbilityCategory aCategory, + final String aKey, + final boolean addIt, + final boolean singleChoice) + { + boolean singleChoice1 = !singleChoice; + if (!isImporting()) + { + getSpellList(); + } + + final ArrayList<String> choices = new ArrayList<String>(); + final String undoctoredKey = aKey; + final String baseKey = EquipmentUtilities.getUndecoratedName(aKey, choices); + String subKey = choices.size() > 0 ? (String) choices.get(0) : Constants.EMPTY_STRING; + + // See if our choice is not auto or virtual + Ability anAbility = getRealAbilityKeyed(aCategory, undoctoredKey); + + // if a feat keyed aFeatKey doesn't exist, and aFeatKey + // contains a (blah) descriptor, try removing it. + if (anAbility == null) + { + anAbility = getRealAbilityKeyed(aCategory, baseKey); + + if (!singleChoice1 && (anAbility != null) && (subKey.length() != 0)) + { + singleChoice1 = true; + } + } + + // (anAbility == null) means we don't have this feat, so we need to add it + if ((anAbility == null) && addIt) + { + // Adding feat for first time + anAbility = Globals.getAbilityKeyed(aCategory, baseKey); + + if (anAbility == null) + { + anAbility = Globals.getAbilityKeyed(aCategory, undoctoredKey); + + if (anAbility != null) + { + subKey = Constants.EMPTY_STRING; + } + } + + if (anAbility == null) + { + Logging.errorPrint("Ability not found: " + undoctoredKey); + + return addIt ? 1 : 0; + } + + anAbility = (Ability) anAbility.clone(); + +// addFeat(anAbility, LevelInfo); + addAbility(aCategory, anAbility, LevelInfo); + anAbility.getTemplates(isImporting(), this); + } + + /* + * Could not find the Ability: addIt true means that no global Ability called + * featName exists, addIt false means that the PC does not have this ability + */ + if (anAbility == null) + { + return addIt ? 1 : 0; + } + + return finaliseAbility(aCategory, anAbility, subKey, addIt, singleChoice1); + } + + private int finaliseAbility( + final AbilityCategory aCategory, + final Ability ability, + final String choice, + final boolean addIt, + final boolean singleChoice) + { + // how many sub-choices to make + double abilityCount = (ability.getAssociatedCount() * ability.getCost(this)); + + boolean adjustedAbilityPool = false; + + // adjust the associated List + if (singleChoice && (addIt || ability.isMultiples())) + { + if ("".equals(choice)) + { + // Get modChoices to adjust the associated list and Feat Pool + adjustedAbilityPool = ability.modChoices(this, addIt); + } + else if (addIt) + { + if (ability.canAddAssociation(choice)) + { + ability.addAssociated(choice); + } + } + else + { + ability.removeAssociated(choice); + } + } + + /* + * This modifyChoice method is a bit like mod choices, but it uses a + * different tag to set the chooser string. The Tag MODIFYABILITYCHOICE + * which doesn't appear to be used anywhere, so this code is totally + * redundant. + */ + ability.modifyChoice(this); + + if (addIt) + { + final List<String> kitList = ability.getSafeListFor(ListKey.KITS); + for (int i = 0; i < kitList.size(); i++) + { + KitUtilities.makeKitSelections(0, kitList.get(i), 1, this); + } + } + + // if no sub choices made (i.e. all of them removed in Chooser box), + // then remove the Feat + boolean removed = false; + boolean result = (ability.isMultiples() && singleChoice) ? (ability.getAssociatedCount() > 0) : addIt ; + + if (! result) + { + removed = removeRealAbility(aCategory, ability); + removeNaturalWeapons(ability); + + for (int x = 0; x < ability.templatesAdded().size(); ++x) + { + removeTemplate(getTemplateKeyed(ability.templatesAdded().get(x))); + } + ability.subAddsForLevel(-9, this); + } + + if (singleChoice && !adjustedAbilityPool) + { + if (!addIt && !ability.isMultiples() && removed) + { + abilityCount += ability.getCost(this); + } + else if (addIt && !ability.isMultiples()) + { + abilityCount -= ability.getCost(this); + } + else + { + int listSize = ability.getAssociatedCount(); + + for (final Ability myAbility : getRealAbilityList(aCategory)) + { + if (myAbility.getKeyName().equalsIgnoreCase(ability.getKeyName())) + { + listSize = myAbility.getAssociatedCount(); + } + } + + abilityCount -= (listSize * ability.getCost(this)); + } + + if ( aCategory == AbilityCategory.FEAT ) + { + adjustAbilities(aCategory, new BigDecimal(abilityCount)); + } + } + + setAutomaticAbilitiesStable(aCategory, false); + + if (addIt && !isImporting()) + { + ability.globalChecks(false, this); + ability.checkRemovals(this); + } + + return result ? 1 : 0; + } + + /** + * Returns the Feat definition searching by key (not name), as + * found in the <b>aggregate</b> feat list. + * + * @param featName String key of the feat to check for. + * @return the Feat (not the CharacterFeat) searched for, + * <code>null</code> if not found. + */ + public Ability getFeatKeyed(final String featName) + { + return getFeatKeyed(featName, aggregateFeatList()); + } + + public Ability getAbilityKeyed(final AbilityCategory aCategory, final String aKey) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return getFeatKeyed(aKey); + } + + final List<Ability> abilities = getAggregateAbilityList(aCategory); + for ( final Ability ability : abilities ) + { + if ( ability.getKeyName().equals(aKey) ) + { + return ability; + } + } + + return null; + } + + public List<Ability> aggregateFeatList() + { + final List<Ability> aggregate = getStableAggregateFeatList(); + + //Did we get a valid list? If so, return it. + if (aggregate != null) + { + return aggregate; + } + + return rebuildFeatAggreagateList(); + } + + public List<Ability> getAggregateAbilityList(final AbilityCategory aCategory) + { + if (aCategory == AbilityCategory.FEAT) + { + return aggregateFeatList(); + } + + final List<Ability> abilities = new ArrayList<Ability>(getRealAbilityList(aCategory)); + abilities.addAll(getVirtualAbilityList(aCategory)); + abilities.addAll(getAutomaticAbilityList(aCategory)); + + return abilities; + } + + private List<Ability> rebuildFeatAggreagateList() + { + List<Ability> aggregate = new ArrayList<Ability>(); + final Map<String, Ability> aHashMap = new HashMap<String, Ability>(); + + for (Ability aFeat : getRealFeatList()) + { + if (aFeat != null) + { + aHashMap.put(aFeat.getKeyName(), aFeat); + } + } + + for ( Ability vFeat : getVirtualFeatList() ) + { + if (!aHashMap.containsKey(vFeat.getKeyName())) + { + aHashMap.put(vFeat.getKeyName(), vFeat); + } + else if (vFeat.isMultiples()) + { + Ability aggregateFeat = aHashMap.get(vFeat.getKeyName()); + aggregateFeat = (Ability) aggregateFeat.clone(); + + for (int e1 = 0; e1 < vFeat.getAssociatedCount(); ++e1) + { + final String aString = vFeat.getAssociated(e1); + + if (aggregateFeat.isStacks() || !aggregateFeat.containsAssociated(aString)) + { + aggregateFeat.addAssociated(aString); + } + } + + aHashMap.put(vFeat.getKeyName(), aggregateFeat); + } + } + + aggregate.addAll(aHashMap.values()); + setStableAggregateFeatList(aggregate); + + for ( Ability autoFeat : featAutoList() ) + { + if (!aHashMap.containsKey(autoFeat.getKeyName())) + { + aHashMap.put(autoFeat.getKeyName(), autoFeat); + } + + else if (autoFeat.isMultiples()) + { + Ability aggregateFeat = aHashMap.get(autoFeat.getKeyName()); + aggregateFeat = (Ability) aggregateFeat.clone(); + + for (int e1 = 0; e1 < autoFeat.getAssociatedCount(); ++e1) + { + final String aString = autoFeat.getAssociated(e1); + if (aggregateFeat.isStacks() || !aggregateFeat.containsAssociated(aString)) + { + aggregateFeat.addAssociated(aString); + } + } + + aHashMap.put(autoFeat.getKeyName(), aggregateFeat); + } + } + + aggregate = new ArrayList<Ability>(); + aggregate.addAll(aHashMap.values()); + setStableAggregateFeatList(aggregate); + return aggregate; + } + + public List<Ability> aggregateVisibleFeatList() + { + final List<Ability> tempFeatList = new ArrayList<Ability>(); + + for ( Ability feat : aggregateFeatList() ) + { + if ((feat.getVisibility() == Visibility.DEFAULT) + || (feat.getVisibility() == Visibility.OUTPUT_ONLY)) + { + tempFeatList.add(feat); + } + } + + return tempFeatList; + } + + public List<Ability> getAggregateVisibleAbilityList(final AbilityCategory aCategory) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return aggregateVisibleFeatList(); + } + final List<Ability> abilities = getAggregateAbilityList(aCategory); + final List<Ability> ret = new ArrayList<Ability>(abilities.size()); + for ( final Ability ability : abilities ) + { + if ( ability.getVisibility() == Visibility.DEFAULT + || ability.getVisibility() == Visibility.OUTPUT_ONLY ) + { + ret.add(ability); + } + } + return Collections.unmodifiableList(ret); + } + + boolean isAutomaticFeatsStable() + { + return automaticFeatsStable; + } + + boolean isAutomaticAbilitiesStable(final AbilityCategory aCategory) + { + if (aCategory == AbilityCategory.FEAT ) + { + return isAutomaticFeatsStable(); + } + return theAbilities.get(aCategory, Ability.Nature.AUTOMATIC) != null; + } + + public List<Ability> getVirtualFeatList() + { + List<Ability> vFeatList = getStableVirtualFeatList(); + + //Did we get a valid list? If so, return it. + if (vFeatList != null) + { + return vFeatList; + } + setVirtualFeatsStable(true); + vFeatList = new ArrayList<Ability>(); + if (stableVirtualFeatList != null) + { + for ( Ability feat : stableVirtualFeatList ) + { + if (feat.needsSaving()) + { + if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { + vFeatList.add(feat); + } + } + } + } + + for ( PCClass pcClass : classList ) + { + final List<Ability> aList = pcClass.getVirtualFeatList(pcClass.getLevel()); + + for ( Ability feat : aList ) + { + if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { + vFeatList.add(feat); + } + } + } + + for (Ability aFeat : getRealFeatList()) + { + final List<Ability> aList = aFeat.getVirtualFeatList(); + + for ( Ability feat : aList ) + { + if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { + vFeatList.add(feat); + } + } + } + + for ( PCTemplate template : templateList ) + { + final List<Ability> aList = template.getVirtualFeatList(); + + for ( Ability feat : aList ) + { + if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { + vFeatList.add(feat); + } + } + } + + for ( Equipment eq : equipmentList ) + { + if (eq.isEquipped()) + { + // This already includes the EqMods + final List<Ability> aList = eq.getVirtualFeatList(); + for ( Ability feat : aList ) + { + // TODO Check for duplicates? + if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { + vFeatList.add(feat); + } + } + } + } + + if (getRace() != null) + { + final List<Ability> aList = getRace().getVirtualFeatList(); + for ( Ability feat : aList ) + { + // TODO Check for duplicates? + if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { + vFeatList.add(feat); + } + } + } + + for ( Skill skill : getSkillList() ) + { + final List<Ability> aList = skill.getVirtualFeatList(); + + for ( Ability feat : aList ) + { + if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { + vFeatList.add(feat); + } + } + } + + for ( CharacterDomain cd : characterDomainList ) + { + if (cd.getDomain() != null) + { + final List<Ability> aList = cd.getDomain().getVirtualFeatList(); + + for ( Ability feat : aList ) + { + if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { + vFeatList.add(feat); + } + } + } + } + if (deity != null) + { + final List<Ability> aList = deity.getVirtualFeatList(); + + for ( Ability feat : aList ) + { + if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { + vFeatList.add(feat); + } + } + } + for ( CompanionMod cMod : companionModList ) + { + final List<Ability> aList = cMod.getVirtualFeatList(); + + for ( Ability feat : aList ) + { + if(PrereqHandler.passesAll(feat.getPreReqList(), this, feat)) { + vFeatList.add(feat); + } + } + } + + setStableVirtualFeatList(vFeatList); + + return vFeatList; + } + + public List<Ability> getVirtualAbilityList(final AbilityCategory aCategory) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return getVirtualFeatList(); + } + List<Ability> ret = theAbilities.get(aCategory, Ability.Nature.VIRTUAL); + if ( ret == null ) + { + ret = new ArrayList<Ability>(); + for ( final PObject pobj : getPObjectList() ) + { + final List<Ability> abilities = pobj.getVirtualAbilityList(aCategory); + for ( final Ability ability : abilities ) + { + if (PrereqHandler.passesAll(ability.getPreReqList(), this, ability)) + { + ret.add(ability); + } + } + } + } + + theAbilities.put(aCategory, Ability.Nature.VIRTUAL, ret); + + return Collections.unmodifiableList(ret); + } + + public List<Ability> featAutoList() + { + final List<Ability> autoFeatList = getStableAutomaticFeatList(); + + //Did we get a valid list? If so, return it. + if (autoFeatList != null) + { + return autoFeatList; + } + + return AbilityUtilities.rebuildAutoAbilityList(this); + } + + public List<Ability> getAutomaticAbilityList(final AbilityCategory aCategory) + { + if ( aCategory == AbilityCategory.FEAT ) + { + return featAutoList(); + } + + List<Ability> abilities = theAbilities.get(aCategory, Ability.Nature.AUTOMATIC); + if ( abilities == null ) + { + abilities = new ArrayList<Ability>(); + theAbilities.put(aCategory, Ability.Nature.AUTOMATIC, abilities); + + // + // add racial feats + // + if ((getRace() != null) && !PlayerCharacterUtilities.canReassignRacialFeats()) + { + // TODO - Remove the pc parameter from getFeatList() + final List<String> abilityKeys = getRace().getAutoAbilityList(aCategory); + for ( final String key : abilityKeys ) + { + final Ability added = AbilityUtilities.addCloneOfGlobalAbilityToListWithChoices(abilities, aCategory, key); + added.setFeatType(Ability.Nature.AUTOMATIC); + } + } + + for (final PCClass aClass : getClassList()) + { + final Collection<String> abilityKeys = aClass.getAutoAbilityList(aCategory); + for ( String key : abilityKeys ) + { + final int idx = key.indexOf('['); + + if (idx >= 0) + { + final StringTokenizer bTok = new StringTokenizer(key.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); + } + } + + key = key.substring(0, idx); + + if (preReqList.size() != 0) + { + if (! PrereqHandler.passesAll(preReqList, this, null )) + { + continue; + } + } + } + + final Ability added = AbilityUtilities.addCloneOfGlobalAbilityToListWithChoices(abilities, aCategory, key); + added.setFeatType(Ability.Nature.AUTOMATIC); + } + } + + if (!PlayerCharacterUtilities.canReassignTemplateFeats() && !getTemplateList().isEmpty()) + { + for (final PCTemplate template : getTemplateList()) + { + final List<String> abilityKeys = template.getAutoAbilityKeys(aCategory, this, false); + + for ( final String key : abilityKeys ) + { + // TODO - Not sure if we need to tokenize on comma + final Ability added = AbilityUtilities.addCloneOfGlobalAbilityToListWithChoices(abilities, aCategory, key); + added.setFeatType(Ability.Nature.AUTOMATIC); + } + } + } + + for (final CharacterDomain aCD : getCharacterDomainList()) + { + final Domain domain = aCD.getDomain(); + + if (domain != null) + { + for (int e2 = 0; e2 < domain.getAssociatedCount(); ++e2) + { + final String aString = domain.getAssociated(e2); + + // TODO - This is not working + if (aString.startsWith("ABILITY")) + { + final int idx = aString.indexOf('?'); + + if (idx > -1) + { + final Ability added = AbilityUtilities.addCloneOfGlobalAbilityToListWithChoices(abilities, aCategory, aString.substring(idx + 1)); + added.setFeatType(Ability.Nature.AUTOMATIC); + } + else + { + Logging.errorPrint("no '?' in Domain assocatedList entry: " + aString); + } + } + } + + // TODO - Need to change Domain to take AbilityCategories + final Iterator<Categorisable> anIt = domain.getAbilityIterator(aCategory.getAbilityCategory()); + + for (; anIt.hasNext();) + { + final Categorisable c = anIt.next(); + final Ability added = AbilityUtilities.addCloneOfGlobalAbilityToListWithChoices(abilities, aCategory, c.getKeyName()); + added.setFeatType(Ability.Nature.AUTOMATIC); + } + } + } + + getAutoWeaponProfs(abilities); + } + return abilities; + } + + private List<Ability> getStableAggregateFeatList() + { + if (isAggregateFeatsStable()) + { + return stableAggregateFeatList; + } + return null; + } + + void setStableAutomaticFeatList(final List<Ability> aFeatList) + { + stableAutomaticFeatList = aFeatList; + setAutomaticFeatsStable(aFeatList != null); + } + + private List<Ability> getStableAutomaticFeatList() + { + if (isAutomaticFeatsStable()) + { + return stableAutomaticFeatList; + } + return null; + } + + private void setStableVirtualFeatList(final List<Ability> aFeatList) + { + stableVirtualFeatList = aFeatList; + setVirtualFeatsStable(aFeatList != null); + } + + private List<Ability> getStableVirtualFeatList() + { + if (isVirtualFeatsStable()) + { + return stableVirtualFeatList; + } + return null; + } + + + } Modified: Trunk/pcgen/code/src/java/pcgen/core/Race.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Race.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/Race.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -68,7 +68,6 @@ private String mFeatList = ""; private String monsterClass = null; private String size = ""; - private String vFeatList = ""; private String weightString = ""; //private String type = "Humanoid"; @@ -88,7 +87,8 @@ private int reach = 5; private String raceType = "None"; private ArrayList<String> racialSubTypes = new ArrayList<String>(); - + private Map<AbilityCategory, List<String>> theAutoAbilities; + { vision = new HashMap<String, String>(); } @@ -199,17 +199,40 @@ favoredClass = newClass; } - /* - public void setVFeatList(String vFeatList) - { - this.vFeatList = vFeatList; - } - */ public String getFavoredClass() { return favoredClass; } + public void setAutoAbilityList(final AbilityCategory aCategory, final List<String> anAbilityList) + { + if ( aCategory.equals(AbilityCategory.FEAT.getAbilityCategory()) ) + { + final StringBuffer buf = new StringBuffer(); + for (final String ability : anAbilityList) + { + if (buf.length() != 0) + { + buf.append(Constants.PIPE); + } + buf.append(ability); + } + setFeatList(buf.toString()); + return; + } + if ( theAutoAbilities == null ) + { + theAutoAbilities = new HashMap<AbilityCategory, List<String>>(); + } + List<String> abilities = theAutoAbilities.get(aCategory); + if ( abilities == null ) + { + abilities = new ArrayList<String>(); + theAutoAbilities.put(aCategory, abilities); + } + abilities.addAll(anAbilityList); + } + public void setFeatList(final String featList) { this.featList = featList; @@ -240,6 +263,20 @@ } } + public List<String> getAutoAbilityList(final AbilityCategory aCategory) + { + if ( theAutoAbilities == null ) + { + return Collections.emptyList(); + } + final List<String> ret = theAutoAbilities.get(aCategory); + if ( ret == null ) + { + return Collections.emptyList(); + } + return Collections.unmodifiableList(ret); + } + public void setHands(final int newHands) { hands = newHands; @@ -828,11 +865,6 @@ txt.append("\tSKILL:").append(bonusSkillList); } - if ((vFeatList != null) && (vFeatList.length() > 0)) - { - txt.append("\tVFEAT:").append(vFeatList); - } - if (bonusSkillsPerLevel != 0) { txt.append("\tXTRASKILLPTSPERLVL:").append(bonusSkillsPerLevel); @@ -889,7 +921,6 @@ aRace.heightString = heightString; aRace.weightString = weightString; aRace.featList = featList; - aRace.vFeatList = vFeatList; aRace.startingAC = new Integer(startingAC.intValue()); aRace.naturalAC = new Integer(naturalAC.intValue()); aRace.initMod = new Integer(initMod.intValue()); Modified: Trunk/pcgen/code/src/java/pcgen/core/chooser/RaceChoiceManager.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/chooser/RaceChoiceManager.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/chooser/RaceChoiceManager.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -76,7 +76,7 @@ { // CHOOSE:RACE|RACETYPE=x,RACESUBTYPE=y,<racename>,TYPE=z // or CHOOSE:RACE|[RACETYPE=x,RACESUBTYPE=y] - Collection<Race> races = Globals.getRaceMap().values(); + Collection<Race> races = Globals.getAllRaces(); Iterator<String> choiceIt = choices.iterator(); Modified: Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbility.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbility.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/levelability/LevelAbility.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -554,9 +554,8 @@ if (type == TYPE) // Favoured Enemy type listed { final String aString = tokenString.substring(5); - final List<Race> races = new ArrayList<Race>(Globals.getRaceMap().values()); - for ( Race race : races ) + for ( final Race race : Globals.getAllRaces() ) { if (race.getType().equalsIgnoreCase(aString)) { Modified: Trunk/pcgen/code/src/java/pcgen/core/utils/IntegerKey.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/utils/IntegerKey.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/core/utils/IntegerKey.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -34,7 +34,7 @@ /** Key to a characteristic defining the number of levels to be added to a spell. */ 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(); +// 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. */ Modified: Trunk/pcgen/code/src/java/pcgen/gui/CharacterInfo.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/CharacterInfo.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/CharacterInfo.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -66,7 +66,7 @@ private InfoClasses infoClasses; private InfoSkills infoSkills; private InfoAbilities infoAbilities; -// private InfoFeats infoFeats; +// private InfoAbility infoFeats; private InfoDomain infoDomain; private InfoSpells infoSpells; private JTabbedPane characterInfoTabbedPane = new JTabbedPane(); @@ -90,7 +90,7 @@ infoClasses = new InfoClasses(pc); infoSkills = new InfoSkills(pc); infoAbilities = new InfoAbilities(pc); -// infoFeats = new InfoFeats(pc); +// infoFeats = new InfoAbility(pc); infoDomain = new InfoDomain(pc); infoSpells = new InfoSpells(pc); setName(""); //$NON-NLS-1$ @@ -241,7 +241,7 @@ * Get the info feats * @return info feats */ -// public InfoFeats infoFeats() { +// public InfoAbility infoFeats() { // return infoFeats; // } Modified: Trunk/pcgen/code/src/java/pcgen/gui/ChooseSpellDialog.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/ChooseSpellDialog.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/ChooseSpellDialog.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -1304,7 +1304,7 @@ } } - Globals.sortPObjectList(classWithSpell); + Globals.sortPObjectListByName(classWithSpell); // // classWithSpell can contain the following objects: Modified: Trunk/pcgen/code/src/java/pcgen/gui/LstEditorMain.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/LstEditorMain.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/LstEditorMain.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -39,6 +39,7 @@ import java.awt.*; import java.awt.event.*; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -143,7 +144,7 @@ break; case EditorConstants.EDIT_RACE: - Globals.getRaceMap().put(editObject.getKeyName(), (Race)editObject); + Globals.addRace((Race)editObject); break; @@ -670,7 +671,7 @@ private void lstLstFileTypesValueChanged() { final String lstType = (String) lstLstFileTypes.getSelectedValue(); - List possibleSelections = null; + Collection<?> possibleSelections = null; if (lstType != null) { @@ -701,7 +702,7 @@ } else if (lstType.equalsIgnoreCase(s_EDITTYPE_RACE)) { - possibleSelections = new ArrayList(Globals.getRaceMap().values()); + possibleSelections = Globals.getAllRaces(); editType = EditorConstants.EDIT_RACE; } else if (lstType.equalsIgnoreCase(s_EDITTYPE_SKILL)) @@ -711,22 +712,21 @@ } else if (lstType.equalsIgnoreCase(s_EDITTYPE_SPELL)) { - possibleSelections = new ArrayList(Globals.getSpellMap().values().size()); + final List<Spell> spells = new ArrayList<Spell>(Globals.getSpellMap().values().size()); - for (Iterator e = Globals.getSpellMap().values().iterator(); e.hasNext();) + for ( final Object obj : Globals.getSpellMap().values() ) { - final Object obj = e.next(); - if (obj instanceof Spell) { - possibleSelections.add(obj); + spells.add((Spell)obj); } else { - possibleSelections.addAll((ArrayList) obj); + spells.addAll((List<Spell>) obj); } } - Globals.sortPObjectList(possibleSelections); + Globals.sortPObjectList(spells); + possibleSelections = spells; editType = EditorConstants.EDIT_SPELL; } else if (lstType.equalsIgnoreCase(s_EDITTYPE_TEMPLATE)) @@ -833,7 +833,7 @@ break; case EditorConstants.EDIT_RACE: - removed = Globals.getRaceMap().remove(editObject.getKeyName()) != null; + removed = Globals.removeRaceKeyed(editObject.getKeyName()); break; Modified: Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -960,7 +960,7 @@ // Save level and hit dice abilities // thisPCTemplate.addHitDiceString(".CLEAR"); - thisPCTemplate.addLevelString(".CLEAR"); + thisPCTemplate.clearLevelAbilities(); sel = pnlLevelAbilities.getSelectedList(); for (int index = 0; index < sel.length; index++) @@ -973,7 +973,22 @@ } else if (aString.startsWith("LEVEL:")) { - thisPCTemplate.addLevelString(aString.substring(6)); + final StringTokenizer tok = new StringTokenizer(aString, ":"); + tok.nextToken(); // Lose the LEVEL: + final String levelStr = tok.nextToken(); + final int level; + try + { + level = Integer.parseInt(levelStr); + } + catch (NumberFormatException ex) + { + // TODO - Add error message. + continue; + } + final String typeStr = tok.nextToken(); + + thisPCTemplate.addLevelAbility(level, typeStr, tok.nextToken()); } } @@ -1222,20 +1237,19 @@ final List raceList = ((Deity) thisPObject).getRacePantheonList(); - for (e = Globals.getRaceMap().values().iterator(); e.hasNext();) + for ( final Race race : Globals.getAllRaces() ) { - final Race aRace = (Race) e.next(); - final String raceName = aRace.getKeyName(); + final String raceName = race.getKeyName(); if (!raceName.equals(Constants.s_NONESELECTED)) { if (raceList.contains(raceName)) { - selectedList.add(aRace); + selectedList.add(race); } else { - availableList.add(aRace); + availableList.add(race); } } } @@ -1551,18 +1565,17 @@ List hairColorList = new ArrayList(); List skinToneList = new ArrayList(); - for (e = Globals.getRaceMap().keySet().iterator(); e.hasNext();) + for ( final Race race : Globals.getAllRaces() ) { - final String raceName = (String) e.next(); - final Race aRace = Globals.getRaceMap().get(raceName); - aString = aRace.getRegionString(); +// final String raceName = (String) e.next(); + aString = race.getRegionString(); if (aString == null) { aString = Constants.s_NONE; } - aList = Globals.getBioSet().getTagForRace(aString, raceName, "HAIR"); + aList = Globals.getBioSet().getTagForRace(aString, race.getKeyName(), "HAIR"); if (aList != null) { @@ -1583,7 +1596,7 @@ } } - aList = Globals.getBioSet().getTagForRace(aString, raceName, "EYES"); + aList = Globals.getBioSet().getTagForRace(aString, race.getKeyName(), "EYES"); if (aList != null) { @@ -1604,7 +1617,7 @@ } } - aList = Globals.getBioSet().getTagForRace(aString, raceName, "SKINTONE"); + aList = Globals.getBioSet().getTagForRace(aString, race.getKeyName(), "SKINTONE"); if (aList != null) { @@ -1902,19 +1915,10 @@ // selectedList.clear(); - List specialabilitiesList = ((PCTemplate) thisPObject).getLevelStrings(); + selectedList.addAll(((PCTemplate)thisPObject).getLevelAbilities()); - if (specialabilitiesList != null) - { - for (e = specialabilitiesList.iterator(); e.hasNext();) - { - aString = (String) e.next(); - selectedList.add("LEVEL:" + aString); - } - } + final List<String >specialabilitiesList = ((PCTemplate) thisPObject).getHitDiceStrings(); - specialabilitiesList = ((PCTemplate) thisPObject).getHitDiceStrings(); - if (specialabilitiesList != null) { for (e = specialabilitiesList.iterator(); e.hasNext();) @@ -2098,7 +2102,7 @@ availableList.clear(); addVariables(availableList, Globals.getClassList()); addVariables(availableList, Globals.getUnmodifiableAbilityList("FEAT")); - addVariables(availableList, Globals.getRaceMap().values()); + addVariables(availableList, Globals.getAllRaces()); addVariables(availableList, Globals.getSkillList()); addVariables(availableList, EquipmentList.getModifierList()); addVariables(availableList, Globals.getTemplateList()); Modified: Trunk/pcgen/code/src/java/pcgen/gui/editor/RaceBasePanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/editor/RaceBasePanel.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/editor/RaceBasePanel.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -461,13 +461,11 @@ List availableList = new ArrayList(); List selectedList = new ArrayList(); - for (e = Globals.getRaceMap().values().iterator(); e.hasNext();) + for ( final Race race : Globals.getAllRaces() ) { - final Race aRace = (Race) e.next(); - - for (int i = aRace.getMyTypeCount(); i > 0;) + for (int i = race.getMyTypeCount(); i > 0;) { - aString = aRace.getMyType(--i); + aString = race.getMyType(--i); if (!aString.equals(Constants.s_CUSTOM)) { Modified: Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2006-09-12 04:29:17 UTC (rev 1384) @@ -1250,9 +1250,9 @@ #InfoFeat -in_featTodoRemain={0}s remain to be selected. +in_featTodoRemain={0} remain to be selected. -in_featTodoTooMany=Too many {0}s have been selected. +in_featTodoTooMany=Too many {0} have been selected. #InfoSkill @@ -3014,6 +3014,9 @@ Errors.Save=Could not save {0} Errors.Load=Unable to load {0} Errors.LstTokens.RaceNotFound={0}: Could not find Race keyed {1} + +# 0 - Class name +# 1 - Offending text Errors.LstTokens.InvalidTokenFormat={0}: Invalid token format [{1}] Errors.TreeTableModel.NoActiveNode=No active node when doing getValueAt in {0} Errors.FollowerModel.UnknownColumn=The column {0} not handled in {1} @@ -3259,6 +3262,7 @@ InfoAbility.Menu.Remove.Tooltip=Remove the selected {0} InfoAbility.Messages.NotQualified=You do not meet the prerequisites required to take this ability. +InfoAbility.Messages.Duplicate=You already have that ability. InfoAbility.Messages.NoPoints=You cannot select any more abilities. InfoAbility.StatusLine.Info=Abilities are color coded: Red = Character does not qualify; Yellow = Automatic; Magenta = Virtual @@ -3271,5 +3275,6 @@ AbilityInfo.Title={0} Info InfoAbility.Remaining.Label={0}s remaining: InfoAbility.Pool.Description=How many {0}s you have left to choose. -InfoAbilities.Tab.Name=Abilities +in_abilities=Abilities +Exceptions.AbilityCategoryLoader.In Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/BaseCharacterInfoTab.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/BaseCharacterInfoTab.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/BaseCharacterInfoTab.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -76,7 +76,6 @@ * * @param flag <tt>true</tt> to mark the tab as needing an update. */ - // TODO - This actually doesn't seem to be used. public final void setNeedsUpdate(final boolean flag) { needsUpdate = flag; Added: Trunk/pcgen/code/src/java/pcgen/gui/tabs/IFilterableView.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/IFilterableView.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/IFilterableView.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,69 @@ +/* + * IFilterableView.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package pcgen.gui.tabs; + +import java.util.List; + +/** + * This interface defines the relationship between a filterable component and + * the <code>FilterPanel</code>. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public interface IFilterableView +{ + /** + * Return the list of view type choice strings. + * + * @return A list of view type choices. + */ + List<String> getViewChoices(); + + /** + * Return the index into the View Choices list to use as the default choice. + * + * @return An index. Must be >= 0 and less than getViewChoices().size(). + */ + int getInitialChoice(); + + /** + * This method is called when the user changes the View Choice. + * + * @param newView The new view choice index. + */ + void viewChanged(final int newView); + + /** + * This method is called when the user sets a new Quick Filter string. + * + * @param aFilter The filter string. + */ + void setQFilter(final String aFilter); + + /** + * This method is called when the Quick Filter is cleared. + */ + void clearQFilter(); +} Property changes on: Trunk/pcgen/code/src/java/pcgen/gui/tabs/IFilterableView.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoAbilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoAbilities.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoAbilities.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -23,6 +23,8 @@ */ package pcgen.gui.tabs; +import java.util.Collection; + import pcgen.core.AbilityCategory; import pcgen.core.PlayerCharacter; import pcgen.core.SettingsHandler; @@ -49,9 +51,14 @@ { super(aPC); - // TODO - Find all the tabs we need to create - addSubTab( new InfoFeats(aPC) ); -// addSubTab( new InfoAbility(aPC, AbilityCategory.FEAT) ); + final Collection<AbilityCategory> cats = SettingsHandler.getGame().getAllAbilityCategories(); + for ( AbilityCategory cat : cats ) + { + if ( cat.isVisible() ) + { + addSubTab( new InfoAbility(aPC, cat) ); + } + } } /** Added: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoAbility.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoAbility.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoAbility.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,665 @@ +/* + * InfoAbility.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * based on InfoFeats.java + * Copyright 2001 (C) Bryan McRoberts <merton_monk@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package pcgen.gui.tabs; + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.JSplitPane; +import javax.swing.SwingUtilities; + +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.AbilityUtilities; +import pcgen.core.Constants; +import pcgen.core.Globals; +import pcgen.core.PlayerCharacter; +import pcgen.core.RuleConstants; +import pcgen.core.SettingsHandler; +import pcgen.core.prereq.PrereqHandler; +import pcgen.core.utils.MessageType; +import pcgen.core.utils.ShowMessageDelegate; +import pcgen.gui.CharacterInfo; +import pcgen.gui.PCGen_Frame1; +import pcgen.gui.filter.FilterConstants; +import pcgen.gui.filter.FilterFactory; +import pcgen.gui.panes.FlippingSplitPane; +import pcgen.gui.tabs.ability.AbilityInfoPanel; +import pcgen.gui.tabs.ability.AbilityPoolPanel; +import pcgen.gui.tabs.ability.AbilitySelectionPanel; +import pcgen.gui.tabs.ability.AvailableAbilityPanel; +import pcgen.gui.tabs.ability.IAbilitySelectionListener; +import pcgen.gui.tabs.ability.SelectedAbilityPanel; +import pcgen.gui.utils.PObjectNode; +import pcgen.util.Logging; +import pcgen.util.PropertyFactory; +import pcgen.util.enumeration.Tab; + +/** + * <code>InfoAbility</code>. + * This class is responsible for drawing an ability related window - including + * indicating which abilities are available, which ones are selected, and handling + * the selection/de-selection of abilities. + * + * @author boomer70 <boomer70@...> + * @author Bryan McRoberts <merton_monk@...> + * + * @version $Revision$ + */ +public final class InfoAbility extends BaseCharacterInfoTab implements IAbilitySelectionListener +{ + private static final Tab tab = Tab.ABILITIES; + + private static final String NO_QUALIFY_MESSAGE = PropertyFactory.getString( + "InfoAbility.Messages.NotQualified"); //$NON-NLS-1$ + private static final String DUPLICATE_MESSAGE = PropertyFactory.getString( + "InfoAbility.Messages.Duplicate"); //$NON-NLS-1$ + private static String POOL_FULL_MESSAGE = PropertyFactory.getString( + "InfoAbility.Messages.NoPoints"); //$NON-NLS-1$ + private static int splitOrientation = JSplitPane.HORIZONTAL_SPLIT; + + private static final int ABILITY_OK = 0; + private static final int ABILITY_DUPLICATE = 1; + private static final int ABILITY_NOT_QUALIFIED = 2; + private static final int ABILITY_FULL = 3; + + private AbilityCategory theCategory; + + private AbilitySelectionPanel theAvailablePane = null; + private AbilitySelectionPanel theSelectedPane = null; + private AbilityInfoPanel theInfoPanel = null; + private AbilityPoolPanel thePoolPanel = null; + + private FlippingSplitPane splitBotLeftRight = null; + private FlippingSplitPane splitTopBot = null; + private FlippingSplitPane splitTopLeftRight = null; + private JCheckBox chkViewAll = new JCheckBox(); + + /** This flag is used to signal that we have set the divider locations */ + private boolean hasBeenSized = false; + + private String theOptionKey = "InfoAbility."; //$NON-NLS-1$ + + /** + * Constructor + * + * @param pc The PC this ability information is displayed for. + * @param aCategory The category of ability this tab is displaying. + */ + public InfoAbility(PlayerCharacter pc, final AbilityCategory aCategory) + { + super(pc); + theCategory = aCategory; + theOptionKey += theCategory.getKeyName(); + + setName(theCategory.getPluralName()); + + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + initComponents(); + initActionListeners(); + } + }); + } + + /** + * @see pcgen.gui.tabs.BaseCharacterInfoTab#getTabOrder() + */ + @Override + public int getTabOrder() + { + // TODO - This doesn't seem to be used. + final String opt = ".Panel." + theOptionKey + ".Order"; //$NON-NLS-1$ //$NON-NLS-2$ + return SettingsHandler.getPCGenOption(opt, tab.ordinal()); + } + + /** + * @see pcgen.gui.tabs.BaseCharacterInfoTab#setTabOrder(int) + */ + @Override + public void setTabOrder(int order) + { + // TODO - This doesn't seem to be used. + final String opt = ".Panel." + theOptionKey + ".Order"; //$NON-NLS-1$ //$NON-NLS-2$ + SettingsHandler.setPCGenOption(opt, order); + } + + /** + * Retrieve the list of tasks to be done on the tab. + * + * <p>Checks to see if any abilities of this type have to be added or + * removed. + * + * @return List of task descriptions as Strings. + * + * @see pcgen.gui.tabs.BaseCharacterInfoTab#getToDos() + */ + @Override + public List<String> getToDos() + { + List<String> toDoList = new ArrayList<String>(); + if ( getPc() != null ) + { + final BigDecimal pool = getPc().getAvailableAbilityPool(theCategory); + final int dir = pool.compareTo(BigDecimal.ZERO); + if ( dir > 0 ) + { + toDoList.add(PropertyFactory.getFormattedString("in_featTodoRemain", theCategory.getPluralName())); //$NON-NLS-1$ + } + else if ( dir < 0 ) + { + toDoList.add(PropertyFactory.getFormattedString("in_featTodoTooMany", theCategory.getPluralName())); //$NON-NLS-1$ + } + } + + return toDoList; + } + + /** + * Specifies whether the "match any" option should be available. + * + * @return Always returns <tt>true</tt>. + * + * @see pcgen.gui.filter.FilterAdapterPanel#isMatchAnyEnabled() + */ + @Override + public boolean isMatchAnyEnabled() + { + return true; + } + + /** + * Specifies whether the "negate/reverse" option should be available. + * + * @return Always returns <tt>true</tt>. + * + * @see pcgen.gui.filter.FilterAdapterPanel#isNegateEnabled() + */ + @Override + public boolean isNegateEnabled() + { + return true; + } + + /** + * Specifies the filter selection mode. + * + * @return Always returns <tt>FilterConstants.MULTI_MULTI_MODE = 2</tt> + * + * @see pcgen.gui.filter.FilterAdapterPanel#getSelectionMode() + */ + @Override + public int getSelectionMode() + { + return FilterConstants.MULTI_MULTI_MODE; + } + + /** + * Implementation of Filterable interface. + * + * <p>Returns filters for Source and Feat. + * + * @see pcgen.gui.filter.FilterAdapterPanel#initializeFilters() + */ + @Override + public void initializeFilters() + { + FilterFactory.registerAllSourceFilters(this); + FilterFactory.registerAllFeatFilters(this); + } + + /** + * Implementation of Filterable interface. + * + * <p>Forces an update of the whole tab. + * + * @see pcgen.gui.filter.FilterAdapterPanel#refreshFiltering() + */ + @Override + public void refreshFiltering() + { + forceRefresh(); + } + + private int checkAbilityQualify(final Ability anAbility) + { + final PlayerCharacter pc = getPc(); + + final String aKey = anAbility.getKeyName(); + Ability ability = pc.getAbilityKeyed(theCategory, aKey); + + final boolean pcHasIt = (ability != null); + + if (pcHasIt && !ability.isMultiples()) + { + return ABILITY_DUPLICATE; + } + + if (!pcHasIt) + { + ability = Globals.getAbilityKeyed(theCategory, aKey); + if ( + ability != null && + !PrereqHandler.passesAll( ability.getPreReqList(), pc, ability ) && + !Globals.checkRule(RuleConstants.FEATPRE)) + { + return ABILITY_NOT_QUALIFIED; + } + } + + if ((ability != null)) + { + final BigDecimal cost = BigDecimal.valueOf(ability.getCost(pc)); + if ( cost.compareTo(pc.getAvailableAbilityPool(theCategory)) > 0 ) + { + return ABILITY_FULL; + } + } + + return ABILITY_OK; + } + + /** + * This is called when the tab is shown. + */ + private void formComponentShown() + { + requestFocus(); + + PCGen_Frame1.setMessageAreaTextWithoutSaving(PropertyFactory.getString( + "InfoAbility.StatusLine.Info")); //$NON-NLS-1$ + refresh(); + + if (!hasBeenSized) + { + hasBeenSized = true; + if ( splitTopLeftRight != null ) + { + final int s = SettingsHandler.getPCGenOption(theOptionKey + ".splitTopLeftRight", //$NON-NLS-1$ + (int) ((this.getSize().getWidth() * 6) / 10)); + splitTopLeftRight.setDividerLocation(s); + } + if ( splitTopBot != null ) + { + final int t = SettingsHandler.getPCGenOption(theOptionKey + ".splitTopBot", //$NON-NLS-1$ + (int) ((this.getSize().getHeight() * 75) / 100)); + splitTopBot.setDividerLocation(t); + } + if ( splitBotLeftRight != null ) + { + final int u = SettingsHandler.getPCGenOption(theOptionKey + ".splitBotLeftRight", //$NON-NLS-1$ + (int) ((this.getSize().getWidth() * 6) / 10)); + splitBotLeftRight.setDividerLocation(u); + } + } + } + + private void initActionListeners() + { + chkViewAll.addActionListener(new ActionListener() + { + public void actionPerformed(@SuppressWarnings("unused")ActionEvent evt) + { + chkViewAllActionPerformed(); + } + }); + addComponentListener(new ComponentAdapter() + { + @Override + public void componentShown(@SuppressWarnings("unused")ComponentEvent evt) + { + formComponentShown(); + } + }); + + FilterFactory.restoreFilterSettings(this); + } + + private void initComponents() + { + if (Globals.getGameModeHasPointPool()) + { +// FEAT_FULL_MESSAGE = "You do not have enough remaining " + Globals.getGameModePointPoolName() + " to select this " + getSingularTabName() + "."; + } + + final JPanel topPane = new JPanel(); + topPane.setLayout(new BorderLayout()); + + //------------------------------------------------------------- + // Top Pane - Left Available, Right Selected + // + if ( theCategory.isEditable() ) + { + theAvailablePane = new AvailableAbilityPanel(getPc(), theCategory); + theAvailablePane.addAbilitySelectionListener(this); + } + theSelectedPane = new SelectedAbilityPanel(getPc(), theCategory); + theSelectedPane.addAbilitySelectionListener(this); + + if ( theCategory.isEditable() ) + { + splitTopLeftRight = new FlippingSplitPane(splitOrientation, theAvailablePane, theSelectedPane); + splitTopLeftRight.setOneTouchExpandable(true); + splitTopLeftRight.setDividerSize(10); + // Register a listener so that we can save the location each time it + // changes. + splitTopLeftRight.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent anEvt) + { + SettingsHandler.setPCGenOption(theOptionKey + ".splitTopLeftRight", //$NON-NLS-1$ + anEvt.getNewValue().toString()); + } + }); + + topPane.add(splitTopLeftRight, BorderLayout.CENTER); + } + else + { + topPane.add(theSelectedPane, BorderLayout.CENTER); + } + + //------------------------------------------------------------- + // Bottom Pane - Left Info, Right Options / Data + // + final JPanel botPane = new JPanel(); + botPane.setLayout(new BorderLayout()); + + theInfoPanel = new AbilityInfoPanel(getPc(), PropertyFactory.getFormattedString("InfoAbility.Title", theCategory.getDisplayName())); //$NON-NLS-1$ + if ( theCategory.isEditable() ) + { + thePoolPanel = new AbilityPoolPanel(getPc(), theCategory); + + splitBotLeftRight = new FlippingSplitPane(splitOrientation, theInfoPanel, thePoolPanel); + + splitBotLeftRight.setOneTouchExpandable(true); + + splitBotLeftRight.setDividerSize(10); + // Register a listener so that we can save the location each time it + // changes. + splitBotLeftRight.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent anEvt) + { + SettingsHandler.setPCGenOption(theOptionKey + ".splitBotLeftRight", //$NON-NLS-1$ + anEvt.getNewValue().toString()); + } + }); + + botPane.add(splitBotLeftRight, BorderLayout.CENTER); + } + else + { + botPane.add(theInfoPanel, BorderLayout.CENTER); + } + + //---------------------------------------------------------------------- + // Split Top and Bottom + splitTopBot = new FlippingSplitPane(JSplitPane.VERTICAL_SPLIT, topPane, botPane); + splitTopBot.setOneTouchExpandable(true); + splitTopBot.setDividerSize(10); + // Register a listener so that we can save the location each time it + // changes. + splitTopBot.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent anEvt) + { + SettingsHandler.setPCGenOption(theOptionKey + ".splitTopBot", //$NON-NLS-1$ + anEvt.getNewValue().toString()); + } + }); + + this.setLayout(new BorderLayout()); + this.add(splitTopBot, BorderLayout.CENTER); + + addFocusListener(new FocusAdapter() + { + @Override + public void focusGained(@SuppressWarnings("unused") + FocusEvent evt) + { + refresh(); + } + }); + } + + private void updateAvailableModel() + { + if ( theAvailablePane != null ) + { + theAvailablePane.update(); + } + } + + /** + * This recalculates the states of everything based + * upon the currently selected character. + * + * @see pcgen.gui.tabs.BaseCharacterInfoTab#updateCharacterInfo() + */ + @Override + protected void updateCharacterInfo() + { + // TODO - Fix this!!!! + PObjectNode.resetPC(getPc()); + + if ((getPc() == null) || needsUpdate() == false) + { + return; + } + + if ( theCategory == AbilityCategory.FEAT ) + { + getPc().setAggregateFeatsStable(false); + getPc().setAutomaticFeatsStable(false); + getPc().setVirtualFeatsStable(false); + // Called for side effects + getPc().aggregateFeatList(); + } + + if ( theInfoPanel != null ) + { + theInfoPanel.setAbility(null); + } + + updateAvailableModel(); + updateSelectedModel(); + + if ( thePoolPanel != null ) + { + thePoolPanel.showRemainingAbilityPoints(); + } + setNeedsUpdate(false); + } + + private void updateSelectedModel() + { + if ( theSelectedPane != null ) + { + theSelectedPane.update(); + } + } + + private void chkViewAllActionPerformed() + { + updateSelectedModel(); + } + + /** + * @see pcgen.gui.tabs.BaseCharacterInfoTab#getTab() + */ + @Override + protected Tab getTab() + { + return tab; + } + + /** + * @see pcgen.gui.tabs.ability.IAbilitySelectionListener#abilitySelected(pcgen.core.Ability) + */ + public void abilitySelected(final Ability anAbility) + { + theInfoPanel.setAbility(anAbility); + } + + /** + * Adds an ability to the character if it is legal for the character to + * take that ability. + * + * @see pcgen.gui.tabs.ability.IAbilitySelectionListener#addAbility(pcgen.core.Ability) + */ + public boolean addAbility(final Ability anAbility) + { + // TODO - There has to be a better way to do this. + final int aq = checkAbilityQualify(anAbility); + + switch (aq) + { + case ABILITY_NOT_QUALIFIED: + ShowMessageDelegate.showMessageDialog(NO_QUALIFY_MESSAGE, Constants.s_APPNAME, MessageType.INFORMATION); + + return false; + + case ABILITY_DUPLICATE: + ShowMessageDelegate.showMessageDialog(DUPLICATE_MESSAGE, Constants.s_APPNAME, MessageType.INFORMATION); + + return false; + + case ABILITY_FULL: + ShowMessageDelegate.showMessageDialog(POOL_FULL_MESSAGE, Constants.s_APPNAME, MessageType.INFORMATION); + + return false; + + case ABILITY_OK: + + // Feat is OK, so do nothing + break; + + default: + Logging.debugPrint(theCategory.getDisplayName() + " " + anAbility.getDisplayName() + " is somehow in state " + aq //$NON-NLS-1$ //$NON-NLS-2$ + + " which is not handled in InfoAbility.addAbility()"); //$NON-NLS-1$ + + break; + } + + // we can only be here if the PC can add the ability + try + { + getPc().setDirty(true); + + if ( theCategory == AbilityCategory.FEAT ) + { + AbilityUtilities.modFeat(getPc(), null, anAbility.getKeyName(), true, false); + } + else + { + getPc().addAbility(null, theCategory, anAbility.getKeyName(), true, false); + } + } + catch (Exception exc) + { + ShowMessageDelegate.showMessageDialog("Add Ability: " + exc.getMessage(), Constants.s_APPNAME, MessageType.ERROR); + } + + // update the skills tab, as feats could effect totals + CharacterInfo pane = PCGen_Frame1.getCharacterPane(); + pane.setPaneForUpdate(pane.infoSkills()); + pane.setPaneForUpdate(pane.infoInventory()); + pane.setPaneForUpdate(pane.infoSpells()); + pane.setPaneForUpdate(pane.infoSummary()); + pane.refresh(); + + getPc().aggregateFeatList(); + updateAvailableModel(); + updateSelectedModel(); + + // TODO - Make sure this is handled elsewhere. +// setAddEnabled(false); + + getPc().calcActiveBonuses(); + + thePoolPanel.showRemainingAbilityPoints(); + return true; + } + + /** + * @see pcgen.gui.tabs.ability.IAbilitySelectionListener#removeAbility(pcgen.core.Ability) + */ + public boolean removeAbility(final Ability anAbility) + { + try + { + getPc().setDirty(true); + + if ( theCategory == AbilityCategory.FEAT ) + { + AbilityUtilities.modFeat(getPc(), null, anAbility.getKeyName(), false, false); + } + else + { + // TODO - ABILITYOBJECT - This won't work + // TODO - ABILITYOBJECT - getPc().removeAbility(theCategory, anAbility); + AbilityUtilities.modAbility(getPc(), null, anAbility, null, false); + } + } + catch (Exception exc) + { + ShowMessageDelegate.showMessageDialog("Remove Ability: " + exc.getMessage(), Constants.s_APPNAME, MessageType.ERROR); + return false; + } + + // update the skills tab, as feats could effect totals + CharacterInfo pane = PCGen_Frame1.getCharacterPane(); + pane.setPaneForUpdate(pane.infoSkills()); + pane.setPaneForUpdate(pane.infoInventory()); + pane.setPaneForUpdate(pane.infoSpells()); + pane.setPaneForUpdate(pane.infoSummary()); + pane.refresh(); + + // Called for side effects + getPc().aggregateFeatList(); + + updateAvailableModel(); + updateSelectedModel(); + + getPc().calcActiveBonuses(); + thePoolPanel.showRemainingAbilityPoints(); + // TODO - Make sure this is handled by the removal +// setRemoveEnabled(false); + return true; + } +} Property changes on: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoAbility.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Deleted: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoFeats.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoFeats.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoFeats.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -1,2543 +0,0 @@ -/* - * InfoFeat.java - * Copyright 2001 (C) Bryan McRoberts <merton_monk@...> - * - * 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 waarranty 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 December 29, 2001, 6:57 PM - * - * Current Ver: $Revision$ - * Last Editor: $Author$ - * Last Edited: $Date$ - * - */ -package pcgen.gui.tabs; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.FlowLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.StringTokenizer; - -import javax.swing.DefaultListSelectionModel; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JTextField; -import javax.swing.JTree; -import javax.swing.KeyStroke; -import javax.swing.ScrollPaneConstants; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; -import javax.swing.tree.TreePath; - -import pcgen.core.Ability; -import pcgen.core.AbilityCategory; -import pcgen.core.AbilityUtilities; -import pcgen.core.Categorisable; -import pcgen.core.Constants; -import pcgen.core.Globals; -import pcgen.core.PlayerCharacter; -import pcgen.core.RuleConstants; -import pcgen.core.SettingsHandler; -import pcgen.core.prereq.PrereqHandler; -import pcgen.core.prereq.Prerequisite; -import pcgen.core.utils.MessageType; -import pcgen.core.utils.ShowMessageDelegate; -import pcgen.gui.CharacterInfo; -import pcgen.gui.GuiConstants; -import pcgen.gui.PCGen_Frame1; -import pcgen.gui.TableColumnManager; -import pcgen.gui.TableColumnManagerModel; -import pcgen.gui.filter.FilterConstants; -import pcgen.gui.filter.FilterFactory; -import pcgen.gui.panes.FlippingSplitPane; -import pcgen.gui.tabs.ability.AbilityInfoPanel; -import pcgen.gui.tabs.ability.AbilityPoolPanel; -import pcgen.gui.utils.AbstractTreeTableModel; -import pcgen.gui.utils.ClickHandler; -import pcgen.gui.utils.IconUtilitities; -import pcgen.gui.utils.JComboBoxEx; -import pcgen.gui.utils.JTreeTable; -import pcgen.gui.utils.JTreeTableMouseAdapter; -import pcgen.gui.utils.JTreeTableSorter; -import pcgen.gui.utils.LabelTreeCellRenderer; -import pcgen.gui.utils.PObjectNode; -import pcgen.gui.utils.ResizeColumnListener; -import pcgen.gui.utils.TreeTableModel; -import pcgen.gui.utils.Utility; -import pcgen.util.BigDecimalHelper; -import pcgen.util.Logging; -import pcgen.util.PropertyFactory; -import pcgen.util.enumeration.Tab; -import pcgen.util.enumeration.Visibility; - -/** - * <code>InfoFeats</code>. - * This class is responsible for drawing the feat related window - including - * indicating what feats are available, which ones are selected, and handling - * the selection/de-selection of feats - * - * @author Bryan McRoberts <merton_monk@...> - * @version $Revision$ - * TODO I18N - */ -public final class InfoFeats extends BaseCharacterInfoTab -{ - private static final Tab tab = Tab.ABILITIES; - - private static final String NO_QUALIFY_MESSAGE = "You do not meet the prerequisites required to take this " + getSingularTabName() + "."; - private static final String DUPLICATE_MESSAGE = "You already have that " + getSingularTabName() + "."; - private static String FEAT_FULL_MESSAGE = "You cannot select any more " + getSingularTabName() + "s."; - private static PObjectNode typeRoot = new PObjectNode(); - private static PObjectNode preReqTreeRoot = null; - private static PObjectNode sourceRoot = new PObjectNode(); - private static int splitOrientation = JSplitPane.HORIZONTAL_SPLIT; - - private static String singularName = null; - - // keep track of what view mode we're in for Available - private static int viewAvailMode = GuiConstants.INFOFEATS_VIEW_PREREQTREE; - private static Integer saveAvailableViewMode = null; - - // default to "Name" in Selection table viewmode - private static int viewSelectMode = GuiConstants.INFOFEATS_VIEW_NAMEONLY; - private static Integer saveSelectedViewMode = null; - - private static final int HASABILITY_NO = 0; - private static final int HASABILITY_CHOSEN = 1; - private static final int HASABILITY_AUTOMATIC = 2; - private static final int HASABILITY_VIRTUAL = 4; - static final int FEAT_OK = 0; - static final int FEAT_DUPLICATE = 1; - static final int FEAT_NOT_QUALIFIED = 2; - static final int FEAT_FULL_FEAT = 3; - private FeatModel availableModel = null; // Model for the JTreeTable. - private FeatModel selectedModel = null; // Model for the JTreeTable. - private FlippingSplitPane splitBotLeftRight; - private FlippingSplitPane splitTopBot; - private FlippingSplitPane splitTopLeftRight; - private JButton addButton; - private JButton leftButton; - private JButton clearAvailableQFilterButton = new JButton("Clear"); - private JButton clearSelectedQFilterButton = new JButton("Clear"); - private JComboBoxEx viewAvailComboBox = new JComboBoxEx(); - private JComboBoxEx viewSelectComboBox = new JComboBoxEx(); - private JCheckBox chkViewAll = new JCheckBox(); - private final JLabel lblAvailableQFilter = new JLabel("Filter:"); - private final JLabel lblSelectedQFilter = new JLabel("Filter:"); - private JMenuItem addMenu; - private JMenuItem removeMenu; - private JPanel topPane = new JPanel(); - private JTextField textAvailableQFilter = new JTextField(); - private JTextField textSelectedQFilter = new JTextField(); - private JTreeTable availableTable; // the available Feats - private JTreeTable selectedTable; // the selected Feats - private JTreeTableSorter availableSort = null; - private JTreeTableSorter selectedSort = null; - private TreePath selPath; - private boolean hasBeenSized = false; - - private boolean readyForRefresh = false; - - private AbilityInfoPanel theInfoPanel = null; - private AbilityPoolPanel thePoolPanel = null; - - /** - * Constructor - * @param pc - */ - public InfoFeats(PlayerCharacter pc) - { - super(pc); - // we will use the name to save component - // specific settings in the options.ini file - setName(tab.toString()); - - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - initComponents(); - initActionListeners(); - } - }); - } - - /** - * @see pcgen.gui.tabs.BaseCharacterInfoTab#getTabOrder() - */ - @Override - public int getTabOrder() - { - // TODO - This doesn't seem to be used. - return SettingsHandler.getPCGenOption(".Panel.Feats.Order", tab.ordinal()); //$NON-NLS-1$ - } - - /** - * @see pcgen.gui.tabs.BaseCharacterInfoTab#setTabOrder(int) - */ - @Override - public void setTabOrder(int order) - { - // TODO - This doesn't seem to be used. - SettingsHandler.setPCGenOption(".Panel.Feats.Order", order); //$NON-NLS-1$ - } - - private static String getSingularTabName() - { - if (singularName == null) - { - singularName = SettingsHandler.getGame().getSingularTabName(tab); - } - return singularName; - } - - /** - * Retrieve the list of tasks to be done on the tab. - * - * <p>Checks to see if any abilities of this type have to be added or - * removed. - * - * @return List of task descriptions as Strings. - * - * @see pcgen.gui.tabs.BaseCharacterInfoTab#getToDos() - */ - @Override - public List<String> getToDos() - { - List<String> toDoList = new ArrayList<String>(); - if (getPc() != null && getPc().getFeats() > 0.0d) - { - toDoList.add(PropertyFactory.getFormattedString("in_featTodoRemain", getSingularTabName())); //$NON-NLS-1$ - } - else if (getPc() != null && getPc().getFeats() < 0.0d) - { - toDoList.add(PropertyFactory.getFormattedString("in_featTodoTooMany", getSingularTabName())); //$NON-NLS-1$ - } - return toDoList; - } - - /** - * Specifies whether the "match any" option should be available. - * - * @return Always returns <tt>true</tt>. - * - * @see pcgen.gui.filter.FilterAdapterPanel#isMatchAnyEnabled() - */ - @Override - public boolean isMatchAnyEnabled() - { - return true; - } - - /** - * Specifies whether the "negate/reverse" option should be available. - * - * @return Always returns <tt>true</tt>. - * - * @see pcgen.gui.filter.FilterAdapterPanel#isNegateEnabled() - */ - @Override - public boolean isNegateEnabled() - { - return true; - } - - /** - * Specifies the filter selection mode. - * - * @return Always returns <tt>FilterConstants.MULTI_MULTI_MODE = 2</tt> - * - * @see pcgen.gui.filter.FilterAdapterPanel#getSelectionMode() - */ - @Override - public int getSelectionMode() - { - return FilterConstants.MULTI_MULTI_MODE; - } - - /** - * Implementation of Filterable interface. - * - * <p>Returns filters for Source and Feat. - * - * @see pcgen.gui.filter.FilterAdapterPanel#initializeFilters() - */ - @Override - public void initializeFilters() - { - FilterFactory.registerAllSourceFilters(this); - FilterFactory.registerAllFeatFilters(this); - } - - /** - * Implementation of Filterable interface. - * - * <p>Forces an update of the whole tab. - * - * @see pcgen.gui.filter.FilterAdapterPanel#refreshFiltering() - */ - @Override - public void refreshFiltering() - { - forceRefresh(); - } - - private static int getEventSelectedIndex(ListSelectionEvent e) - { - final DefaultListSelectionModel model = (DefaultListSelectionModel) e.getSource(); - - if (model == null) - { - return -1; - } - - return model.getMinSelectionIndex(); - } - - private void setAddEnabled(boolean enabled) - { - addButton.setEnabled(enabled); - addMenu.setEnabled(enabled); - } - - private void setRemoveEnabled(boolean enabled) - { - leftButton.setEnabled(enabled); - removeMenu.setEnabled(enabled); - } - - private void addFeat() - { - String aKey = null; - Object temp = availableTable.getTree().getLastSelectedPathComponent(); - - if (temp == null) - { - ShowMessageDelegate.showMessageDialog("Somehow, no " + getSingularTabName() + " was selected. Try again.", Constants.s_APPNAME, MessageType.ERROR); - - return; - } - - if (temp instanceof PObjectNode) - { - temp = ((PObjectNode) temp).getItem(); - - if (temp instanceof Ability) - { - aKey = ((Ability) temp).getKeyName(); - } - } - - // - // Make sure we are dealing with a Feat object (double clicking on an expandable node can get here) - // - if (!(temp instanceof Ability)) - { - return; - } - - //final Feat aFeat = pc.getFeatNamed(aString); - final int fq = checkFeatQualify((Ability) temp); - - switch (fq) - { - case FEAT_NOT_QUALIFIED: - ShowMessageDelegate.showMessageDialog(NO_QUALIFY_MESSAGE, Constants.s_APPNAME, MessageType.INFORMATION); - - return; - - case FEAT_DUPLICATE: - ShowMessageDelegate.showMessageDialog(DUPLICATE_MESSAGE, Constants.s_APPNAME, MessageType.INFORMATION); - - return; - - case FEAT_FULL_FEAT: - ShowMessageDelegate.showMessageDialog(FEAT_FULL_MESSAGE, Constants.s_APPNAME, MessageType.INFORMATION); - - return; - - case FEAT_OK: - - // Feat is OK, so do nothing - break; - - default: - Logging.errorPrint(getSingularTabName() + " " + ((Ability) temp).getDisplayName() + " is somehow in state " + fq - + " which is not handled" + " in InfoFeats.addFeat()"); - - break; - } - - // we can only be here if the PC can add the feat - try - { - getPc().setDirty(true); - - // modFeat(featName, adding_feat, adding_all_selections) - AbilityUtilities.modFeat(getPc(), null, aKey, true, false); - } - catch (Exception exc) - { - ShowMessageDelegate.showMessageDialog("InfoFeats1: " + exc.getMessage(), Constants.s_APPNAME, MessageType.ERROR); - } - - // update the skills tab, as feats could effect totals - CharacterInfo pane = PCGen_Frame1.getCharacterPane(); - pane.setPaneForUpdate(pane.infoSkills()); - pane.setPaneForUpdate(pane.infoInventory()); - pane.setPaneForUpdate(pane.infoSpells()); - pane.setPaneForUpdate(pane.infoSummary()); - pane.refresh(); - - getPc().aggregateFeatList(); - updateAvailableModel(); - updateSelectedModel(); - - selectedTable.getColumnModel().getColumn(0).setHeaderValue(getSingularTabName() + "s (" + BigDecimalHelper.trimBigDecimal(new BigDecimal(getPc().getUsedFeatCount())).toString() + ")"); - - setAddEnabled(false); - getPc().calcActiveBonuses(); - - thePoolPanel.showRemainingAbilityPoints(); - } - - private int checkFeatQualify(Ability anAbility) - { - String aKey = anAbility.getKeyName(); - anAbility = getPc().getRealFeatKeyed(aKey); - - final boolean pcHasIt = (anAbility != null); - - if (pcHasIt && !anAbility.isMultiples()) - { - return FEAT_DUPLICATE; - } - - if (!pcHasIt) - { - anAbility = Globals.getAbilityKeyed("FEAT", aKey); - if ( - anAbility != null && - !PrereqHandler.passesAll( anAbility.getPreReqList(), getPc(), anAbility ) && - !Globals.checkRule(RuleConstants.FEATPRE)) - { - return FEAT_NOT_QUALIFIED; - } - } - - if ((anAbility != null)) - { - if (anAbility.getCost(getPc()) > getPc().getFeats()) - { - return FEAT_FULL_FEAT; - } - } - - return FEAT_OK; - } - - private void createModelAvailable() - { - if (availableModel == null) - { - availableModel = new FeatModel(viewAvailMode, true); - } - else - { - availableModel.resetModel(viewAvailMode, true, false); - } - - if (availableSort != null) - { - availableSort.setRoot((PObjectNode) availableModel.getRoot()); - } - } - - private void createModelSelected() - { - if (selectedModel == null) - { - selectedModel = new FeatModel(viewSelectMode, false); - } - else - { - selectedModel.resetModel(viewSelectMode, false, chkViewAll.isSelected()); - } - - if (selectedSort != null) - { - selectedSort.setRoot((PObjectNode) selectedModel.getRoot()); - } - } - - /** - * Creates the FeatModel that will be used. - */ - private void createModels() - { - createModelAvailable(); - createModelSelected(); - } - - private class AvailableClickHandler implements ClickHandler - { - public void singleClickEvent() { - // Do Nothing - } - - public void doubleClickEvent() - { - // We run this after the event has been processed so that - // we don't confuse the table when we change its contents - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - addFeat(); - } - }); - } - public boolean isSelectable(Object obj) - { - return !(obj instanceof String); - } - } - - private class SelectedClickHandler implements ClickHandler - { - public void singleClickEvent() { - // Do Nothing - } - - public void doubleClickEvent() - { - // We run this after the event has been processed so that - // we don't confuse the table when we change its contents - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - removeFeat(); - } - }); - } - public boolean isSelectable(Object obj) - { - return !(obj instanceof String); - } - } - - /** - * This creates the JTreeTables for the available and selected feats - * It also creates the actions associated with the objects. - */ - private void createTreeTables() - { - availableTable = new JTreeTable(availableModel); - availableTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() - { - public void valueChanged(ListSelectionEvent e) - { - if (!e.getValueIsAdjusting()) - { - //final String aString = - //availableTable.getTree().getLastSelectedPathComponent().toString(); - ///////////////////////// - // Byngl Feb 20/2002 - // fix bug with displaying incorrect info when use cursor keys to - // navigate the tree - // - //Object temp = - // availableTable.getTree().getLastSelectedPathComponent(); - final int idx = getEventSelectedIndex(e); - - if (idx < 0) - { - return; - } - - Object temp = availableTable.getTree().getPathForRow(idx).getLastPathComponent(); - - ///////////////////////// - if (temp == null) - { - ShowMessageDelegate.showMessageDialog("Somehow, no " - + getSingularTabName() - + " was selected. Try again.", Constants.s_APPNAME, MessageType.ERROR); - return; - } - - Ability aFeat = null; - - if (temp instanceof PObjectNode) - { - temp = ((PObjectNode) temp).getItem(); - - if (temp instanceof Ability) - { - aFeat = (Ability) temp; - } - } - - if (SettingsHandler.isExpertGUI()) - { - setAddEnabled((aFeat != null) && (checkFeatQualify(aFeat) == FEAT_OK)); - } - else - { - setAddEnabled(aFeat != null); - } - - theInfoPanel.setAbility(aFeat); - } - } - }); - - final JTree tree = availableTable.getTree(); - tree.setRootVisible(false); - tree.setShowsRootHandles(true); - tree.setCellRenderer(new LabelTreeCellRenderer()); - - availableTable.addMouseListener(new JTreeTableMouseAdapter(availableTable, new AvailableClickHandler(), false)); - - selectedTable = new JTreeTable(selectedModel); - - final JTree btree = selectedTable.getTree(); - btree.setRootVisible(false); - btree.setShowsRootHandles(true); - btree.setCellRenderer(new LabelTreeCellRenderer()); - - selectedTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() - { - public void valueChanged(ListSelectionEvent e) - { - if (!e.getValueIsAdjusting()) - { - ///////////////////////// - // Byngl Feb 20/2002 - // fix bug with displaying incorrect info when use cursor - // keys to navigate the tree - // - final int idx = getEventSelectedIndex(e); - - if (idx < 0) - { - return; - } - - Object temp = btree.getPathForRow(idx).getLastPathComponent(); - - if (temp == null) - { - return; - } - - ///////////////////////// - boolean removeAllowed = false; - Ability aFeat = null; - - if (temp instanceof PObjectNode) - { - temp = ((PObjectNode) temp).getItem(); - - if (temp instanceof Ability) - { - aFeat = (Ability) temp; - removeAllowed = aFeat.getFeatType() == Ability.ABILITY_NORMAL; - - //final Feat autoFeat = - // pc.getFeatAutomaticNamed(aFeat.getName()); - //removeAllowed = !Globals.featsMatch(aFeat, autoFeat); - } - } - - setRemoveEnabled(removeAllowed); - - theInfoPanel.setAbility(aFeat); - } - } - }); - - selectedTable.addMouseListener(new JTreeTableMouseAdapter(selectedTable, new SelectedClickHandler(), false)); - - // create the rightclick popup menus - hookupPopupMenu(availableTable); - hookupPopupMenu(selectedTable); - } - - // This is called when the tab is shown. - private void formComponentShown() - { - requestFocus(); - // TODO: I18N - PCGen_Frame1.setMessageAreaTextWithoutSaving(getSingularTabName() + "s are color coded: Red = Character does not qualify; " - + "Yellow = Automatic; Magenta = Virtual"); - refresh(); - - int width; - int s = splitTopLeftRight.getDividerLocation(); - int t = splitTopBot.getDividerLocation(); - int u = splitBotLeftRight.getDividerLocation(); - - if (!hasBeenSized) - { - hasBeenSized = true; - s = SettingsHandler.getPCGenOption("InfoFeats.splitTopLeftRight", - (int) ((this.getSize().getWidth() * 6) / 10)); - t = SettingsHandler.getPCGenOption("InfoFeats.splitTopBot", (int) ((this.getSize().getHeight() * 75) / 100)); - u = SettingsHandler.getPCGenOption("InfoFeats.splitBotLeftRight", - (int) ((this.getSize().getWidth() * 6) / 10)); - - // set the prefered width on selectedTable - final TableColumnModel selectedTableColumnModel = selectedTable.getColumnModel(); - - for (int i = 0; i < selectedTable.getColumnCount(); ++i) - { - TableColumn sCol = selectedTableColumnModel.getColumn(i); - width = Globals.getCustColumnWidth("FeatSel", i); - - if (width != 0) - { - sCol.setPreferredWidth(width); - } - - sCol.addPropertyChangeListener(new ResizeColumnListener(selectedTable, "FeatSel", i)); - } - - // set the prefered width on availableTable - final TableColumnModel availableTableColumnModel = availableTable.getColumnModel(); - - for (int i = 0; i < availableTable.getColumnCount(); ++i) - { - TableColumn aCol = availableTableColumnModel.getColumn(i); - width = Globals.getCustColumnWidth("FeatAva", i); - - if (width != 0) - { - aCol.setPreferredWidth(width); - } - - aCol.addPropertyChangeListener(new ResizeColumnListener(availableTable, "FeatAva", i)); - } - } - - if (s > 0) - { - splitTopLeftRight.setDividerLocation(s); - SettingsHandler.setPCGenOption("InfoFeats.splitTopLeftRight", s); - } - - if (t > 0) - { - splitTopBot.setDividerLocation(t); - SettingsHandler.setPCGenOption("InfoFeats.splitTopBot", t); - } - - if (u > 0) - { - splitBotLeftRight.setDividerLocation(u); - SettingsHandler.setPCGenOption("InfoFeats.splitBotLeftRight", u); - } - } - - private void hookupPopupMenu(JTreeTable treeTable) - { - treeTable.addMouseListener(new FeatPopupListener(treeTable, new FeatPopupMenu(treeTable))); - } - - private void initActionListeners() - { - viewAvailComboBox.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - viewAvailComboBoxActionPerformed(); - } - }); - viewSelectComboBox.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - viewSelectComboBoxActionPerformed(); - } - }); - textAvailableQFilter.getDocument().addDocumentListener(new DocumentListener() - { - public void changedUpdate(DocumentEvent evt) - { - setAvailableQFilter(); - } - public void insertUpdate(DocumentEvent evt) - { - setAvailableQFilter(); - } - public void removeUpdate(DocumentEvent evt) - { - setAvailableQFilter(); - } - }); - clearAvailableQFilterButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - clearAvailableQFilter(); - } - }); - textSelectedQFilter.getDocument().addDocumentListener(new DocumentListener() - { - public void changedUpdate(DocumentEvent evt) - { - setSelectedQFilter(); - } - public void insertUpdate(DocumentEvent evt) - { - setSelectedQFilter(); - } - public void removeUpdate(DocumentEvent evt) - { - setSelectedQFilter(); - } - }); - clearSelectedQFilterButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - clearSelectedQFilter(); - } - }); - chkViewAll.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - chkViewAllActionPerformed(); - } - }); - addComponentListener(new ComponentAdapter() - { - public void componentShown(ComponentEvent evt) - { - formComponentShown(); - } - }); - leftButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - removeFeat(); - } - }); - addButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - addFeat(); - } - }); - - FilterFactory.restoreFilterSettings(this); - } - - private void initComponents() - { - if (Globals.getGameModeHasPointPool()) - { - FEAT_FULL_MESSAGE = "You do not have enough remaining " + Globals.getGameModePointPoolName() + " to select this " + getSingularTabName() + "."; - } - - readyForRefresh = true; - // - // Sanity check - // - int iView = SettingsHandler.getFeatTab_AvailableListMode(); - - if ((iView >= GuiConstants.INFOFEATS_VIEW_TYPENAME) && (iView <= GuiConstants.INFOFEATS_VIEW_SOURCENAME)) - { - viewAvailMode = iView; - } - - SettingsHandler.setFeatTab_AvailableListMode(viewAvailMode); - iView = SettingsHandler.getFeatTab_SelectedListMode(); - - if ((iView >= GuiConstants.INFOFEATS_VIEW_TYPENAME) && (iView <= GuiConstants.INFOFEATS_VIEW_SOURCENAME)) - { - viewSelectMode = iView; - } - - SettingsHandler.setFeatTab_SelectedListMode(viewSelectMode); - - viewAvailComboBox.addItem(PropertyFactory.getString("in_typeName")); - viewAvailComboBox.addItem(PropertyFactory.getString("in_nameLabel")); - viewAvailComboBox.addItem(PropertyFactory.getString("in_preReqTree")); - viewAvailComboBox.addItem(PropertyFactory.getString("in_sourceName")); - Utility.setDescription(viewAvailComboBox, - "You can change how the " + getSingularTabName()+ "s in the Available and Selected Tables are listed - either by name or in a directory-like structure."); - viewAvailComboBox.setSelectedIndex(viewAvailMode); - - viewSelectComboBox.addItem(PropertyFactory.getString("in_typeName")); - viewSelectComboBox.addItem(PropertyFactory.getString("in_nameLabel")); - viewSelectComboBox.addItem(PropertyFactory.getString("in_preReqTree")); - viewSelectComboBox.addItem(PropertyFactory.getString("in_sourceName")); - Utility.setDescription(viewSelectComboBox, - "You can change how the " + getSingularTabName() + "s in the Selected Tables are listed - either by name or in a directory-like structure."); - viewSelectComboBox.setSelectedIndex(viewSelectMode); - - List<String> typeList = new ArrayList<String>(); - List<String> sourceList = new ArrayList<String>(); - - for (Iterator<? extends Categorisable> it = Globals.getAbilityKeyIterator("FEAT"); it.hasNext(); ) - { - final Ability anAbility = (Ability) it.next(); - - if ((anAbility.getVisibility() != Visibility.DEFAULT) && - (anAbility.getVisibility() != Visibility.DISPLAY_ONLY)) - { - continue; - } - - final StringTokenizer aTok = new StringTokenizer(anAbility.getType(), "."); - - while (aTok.hasMoreTokens()) - { - String aString = aTok.nextToken(); - - if (!Globals.isAbilityTypeHidden(aString)) - { - if (!typeList.contains(aString)) - { - typeList.add(aString); - } - - final String sourceString = anAbility.getSourceEntry().getSourceBook().getLongName(); - if ((sourceString != null) && (!sourceList.contains(sourceString))) - { - sourceList.add(sourceString); - } - } - } - } - - Collections.sort(typeList); - PObjectNode[] ccTypes = new PObjectNode[typeList.size()]; - for (int i = 0; i < typeList.size(); ++i) - { - ccTypes[i] = new PObjectNode(); - ccTypes[i].setItem(typeList.get(i).toString()); - ccTypes[i].setParent(typeRoot); - } - typeRoot.setChildren(ccTypes); - - Collections.sort(sourceList); - PObjectNode[] ccSources = new PObjectNode[sourceList.size()]; - for (int i = 0; i < sourceList.size(); ++i) - { - ccSources[i] = new PObjectNode(); - ccSources[i].setItem(sourceList.get(i).toString()); - ccSources[i].setParent(sourceRoot); - } - sourceRoot.setChildren(ccSources); - - // initialize Models - createModels(); - - // create available table of feats - createTreeTables(); - - topPane.setLayout(new BorderLayout()); - - buildTopPanel(); - - //------------------------------------------------------------- - // Bottom Pane - Left Info, Right Options / Data - // - JPanel botPane = new JPanel(); - botPane.setLayout(new BorderLayout()); - - theInfoPanel = new AbilityInfoPanel(getPc(), getSingularTabName() + " Info"); - thePoolPanel = new AbilityPoolPanel(getPc(), AbilityCategory.FEAT); - - splitBotLeftRight = new FlippingSplitPane(splitOrientation, theInfoPanel, thePoolPanel); - splitBotLeftRight.setOneTouchExpandable(true); - splitBotLeftRight.setDividerSize(10); - - botPane.add(splitBotLeftRight, BorderLayout.CENTER); - - //---------------------------------------------------------------------- - // Split Top and Bottom - splitTopBot = new FlippingSplitPane(JSplitPane.VERTICAL_SPLIT, topPane, botPane); - splitTopBot.setOneTouchExpandable(true); - splitTopBot.setDividerSize(10); - - // splitTopBot.setDividerLocation(300); - this.setLayout(new BorderLayout()); - this.add(splitTopBot, BorderLayout.CENTER); - availableSort = new JTreeTableSorter(availableTable, (PObjectNode) availableModel.getRoot(), availableModel); - selectedSort = new JTreeTableSorter(selectedTable, (PObjectNode) selectedModel.getRoot(), selectedModel); - - addFocusListener(new FocusAdapter() - { - public void focusGained(FocusEvent evt) - { - refresh(); - } - }); - } - - private void buildTopPanel() - { - //------------------------------------------------------------- - // Top Pane - Left Available, Right Selected - // - JPanel leftPane = new JPanel(); - JPanel rightPane = new JPanel(); - - splitTopLeftRight = new FlippingSplitPane(splitOrientation, leftPane, rightPane); - splitTopLeftRight.setOneTouchExpandable(true); - splitTopLeftRight.setDividerSize(10); - - // splitTopLeftRight.setDividerLocation(350); - topPane.add(splitTopLeftRight, BorderLayout.CENTER); - - // Top Left - Available - leftPane.setLayout(new BorderLayout()); - - JLabel avaLabel = new JLabel("Available: "); - leftPane.add(InfoTabUtils.createFilterPane(avaLabel, viewAvailComboBox, lblAvailableQFilter, textAvailableQFilter, clearAvailableQFilterButton), BorderLayout.NORTH); - - JScrollPane scrollPane = new JScrollPane(availableTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - leftPane.add(scrollPane, BorderLayout.CENTER); - - addButton = new JButton(IconUtilitities.getImageIcon("Forward16.gif")); - leftPane.add(buildModSpellPanel(addButton, "Click to add the selected " + getSingularTabName() + " from the Available list of " + getSingularTabName() + "s"), BorderLayout.SOUTH); - - JButton columnButton = new JButton(); - scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, columnButton); - columnButton.setText("^"); - new TableColumnManager(availableTable, columnButton, availableModel); - - // Right Pane - Selected - rightPane.setLayout(new BorderLayout()); - - JLabel selLabel = new JLabel("Selected: "); - rightPane.add(InfoTabUtils.createFilterPane(selLabel, viewSelectComboBox, lblSelectedQFilter, textSelectedQFilter, clearSelectedQFilterButton), BorderLayout.NORTH); - - scrollPane = new JScrollPane(selectedTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - rightPane.add(scrollPane, BorderLayout.CENTER); - - leftButton = new JButton(IconUtilitities.getImageIcon("Back16.gif")); - rightPane.add(buildDelSpellPanel(leftButton, "Click to remove the selected " + getSingularTabName() + " from the Selected list of " + getSingularTabName() + "s"), BorderLayout.SOUTH); - - JButton columnButton2 = new JButton(); - scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, columnButton2); - columnButton2.setText("^"); - new TableColumnManager(selectedTable, columnButton2, selectedModel); - } - - /** - * Build the panel with the controls to add a spell to a - * prepared list. - * @param button - * @param title - * - * @return The panel. - */ - private JPanel buildModSpellPanel(JButton button, String title) - { - JPanel panel = new JPanel(); - panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 1)); - Utility.setDescription(button, title); //$NON-NLS-1$ - button.setEnabled(false); - button.setMargin(new Insets(1, 14, 1, 14)); - panel.add(button); - - return panel; - } - - /** - * Build the panel with the controls to add a spell to a - * prepared list. - * @param button - * @param title - * - * @return The panel. - */ - private JPanel buildDelSpellPanel(JButton button, String title) - { - JPanel panel = new JPanel(); - panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 1)); - Utility.setDescription(button, title); //$NON-NLS-1$ - button.setEnabled(false); - button.setMargin(new Insets(1, 14, 1, 14)); - panel.add(button); - if (SettingsHandler.allowFeatDebugging()) - { - panel.add(chkViewAll); - } - - return panel; - } - - private void removeFeat() - { - String aKey = null; - Object temp = selectedTable.getTree().getLastSelectedPathComponent(); - - if (temp == null) - { - ShowMessageDelegate.showMessageDialog("Somehow, no " + getSingularTabName() + " was selected. Try again.", Constants.s_APPNAME, MessageType.ERROR); - - return; - } - - if (temp instanceof PObjectNode) - { - temp = ((PObjectNode) temp).getItem(); - - if (temp instanceof Ability) - { - aKey = ((Ability) temp).getKeyName(); - } - } - - try - { - getPc().setDirty(true); - - // modFeat(featName, adding_feat, adding_all_selections) - AbilityUtilities.modFeat(getPc(), null, aKey, false, false); - } - catch (Exception exc) - { - ShowMessageDelegate.showMessageDialog("InfoFeats2: " + exc.getMessage(), Constants.s_APPNAME, MessageType.ERROR); - } - - // update the skills tab, as feats could effect totals - CharacterInfo pane = PCGen_Frame1.getCharacterPane(); - pane.setPaneForUpdate(pane.infoSkills()); - pane.setPaneForUpdate(pane.infoInventory()); - pane.setPaneForUpdate(pane.infoSpells()); - pane.setPaneForUpdate(pane.infoSummary()); - pane.refresh(); - - getPc().aggregateFeatList(); - updateAvailableModel(); - updateSelectedModel(); - - selectedTable.getColumnModel().getColumn(0).setHeaderValue(getSingularTabName() + "s (" + BigDecimalHelper.trimBigDecimal(new BigDecimal(getPc().getUsedFeatCount())).toString() + ")"); - - getPc().calcActiveBonuses(); - thePoolPanel.showRemainingAbilityPoints(); - setRemoveEnabled(false); - } - - private void updateAvailableModel() - { - if(availableTable != null) { - List<String> pathList = availableTable.getExpandedPaths(); - createModelAvailable(); - - if (availableSort != null) - { - availableSort.sortNodeOnColumn(); - } - availableTable.updateUI(); - availableTable.expandPathList(pathList); - } - } - - /** - * This recalculates the states of everything based - * upon the currently selected character. - * - * @see pcgen.gui.tabs.BaseCharacterInfoTab#updateCharacterInfo() - */ - @Override - protected void updateCharacterInfo() - { - PObjectNode.resetPC(getPc()); - - if ((getPc() == null) || (getPc().isAggregateFeatsStable() && !needsUpdate())) - { - return; - } - - getPc().setAggregateFeatsStable(false); - getPc().setAutomaticFeatsStable(false); - getPc().setVirtualFeatsStable(false); - getPc().aggregateFeatList(); - - if ( theInfoPanel != null ) - { - theInfoPanel.setAbility(null); - } - - updateAvailableModel(); - updateSelectedModel(); - - if(selectedTable != null) { - selectedTable.getColumnModel().getColumn(0).setHeaderValue(getSingularTabName() + "s (" + BigDecimalHelper.trimBigDecimal(new BigDecimal(getPc().getUsedFeatCount())).toString() + ")"); - } - if ( thePoolPanel != null ) - { - thePoolPanel.showRemainingAbilityPoints(); - } - setNeedsUpdate(false); - } - - private void updateSelectedModel() - { - if(selectedTable != null) { - List<String> pathList = selectedTable.getExpandedPaths(); - createModelSelected(); - - if (selectedSort != null) - { - selectedSort.sortNodeOnColumn(); - } - selectedTable.updateUI(); - selectedTable.expandPathList(pathList); - } - } - - private void viewAvailComboBoxActionPerformed() - { - final int index = viewAvailComboBox.getSelectedIndex(); - - if (index != viewAvailMode) - { - viewAvailMode = index; - SettingsHandler.setFeatTab_AvailableListMode(viewAvailMode); - updateAvailableModel(); - } - } - - private void viewSelectComboBoxActionPerformed() - { - final int index = viewSelectComboBox.getSelectedIndex(); - - if (index != viewSelectMode) - { - viewSelectMode = index; - SettingsHandler.setFeatTab_SelectedListMode(viewSelectMode); - updateSelectedModel(); - } - } - - private void chkViewAllActionPerformed() - { - updateSelectedModel(); - } - - /** - * Extends AbstractTreeTableModel to build an available or - * selected feats tree for this tab. - * <p/> - * The basic idea of the TreeTableModel is that there is a - * single <code>root</code> object. This root object has a null - * <code>parent</code>. All other objects have a parent which - * points to a non-null object. parent objects contain a list of - * <code>children</code>, which are all the objects that point - * to it as their parent. - * objects (or <code>nodes</code>) which have 0 children - * are leafs (the end of that linked list). - * nodes which have at least 1 child are not leafs. - * Leafs are like files and non-leafs are like directories. - */ - private final class FeatModel extends AbstractTreeTableModel implements TableColumnManagerModel - { - private static final int COL_NAME = 0; - private static final int COL_TYPE = 1; - private static final int COL_COST = 2; - private static final int COL_MULTIPLES = 3; - private static final int COL_STACKS = 4; - private static final int COL_REQUIREMENTS = 5; - private static final int COL_DESCRIPTION = 6; - private static final int COL_CHOICES = 7; - private static final int COL_SRC = 8; - - private static final int MODEL_TYPE_AVAIL = 0; - private static final int MODEL_TYPE_SELECTED = 1; - - // Names of the columns. - private String[] names = { - "Feat", - "Type", - "Cost", - "Mult", - "Stack", - "Requirements", - "Description", - "Choices", - "Source" - }; - private int[] widths = { 100, 100, 100, 100, 100, 100, 100, 100, 100 }; - - // Types of the columns. - private int modelType = MODEL_TYPE_AVAIL; // availableModel - private List<Boolean> displayList; - - /** - * Creates a FeatModel - * @param viewMode - * @param available - */ - private FeatModel(int viewMode, boolean available) - { - super(null); - resetModel(viewMode, available, false); - int i = 1; - displayList = new ArrayList<Boolean>(); - displayList.add(new Boolean(true)); // Feat - displayList.add(new Boolean(getColumnViewOption(names[i++], false))); // Type - displayList.add(new Boolean(getColumnViewOption(names[i++], false))); // Cost - displayList.add(new Boolean(getColumnViewOption(names[i++], false))); // Mult - displayList.add(new Boolean(getColumnViewOption(names[i++], false))); // Stack - if (available) - { - displayList.add(new Boolean(getColumnViewOption(names[i++], false))); // Requirements - displayList.add(new Boolean(getColumnViewOption(names[i++], false))); // Description - displayList.add(new Boolean(getColumnViewOption(names[i++], false))); // Choices - displayList.add(new Boolean(getColumnViewOption(names[i++], true))); // Source - } - else - { - displayList.add(new Boolean(getColumnViewOption(names[i++], false))); // Requirements - displayList.add(new Boolean(getColumnViewOption(names[i++], false))); // Description - displayList.add(new Boolean(getColumnViewOption(names[i++], true))); // Choices - displayList.add(new Boolean(getColumnViewOption(names[i++], false))); // Source - } - - } - - /** - * Returns Class for the column. - * @param column - * @return Class - */ - public Class<?> getColumnClass(int column) - { - if(column == COL_NAME) - { - return TreeTableModel.class; - } - return String.class; - } - - /* The JTreeTableNode interface. */ - - /** - * Returns int number of columns. - * @return column count - */ - public int getColumnCount() - { - return names.length; - } - - /** - * Returns String name of a column. - * @param column - * @return column name - */ - public String getColumnName(int column) - { - String colName = ""; - if(column == COL_NAME) - { - colName = getSingularTabName(); - if (modelType != MODEL_TYPE_AVAIL) - { - colName += " (" + getPc().getUsedFeatCount() + ")"; - } - } - else - { - colName = names[column]; - } - return colName; - } - - public Object getRoot() - { - return super.getRoot(); - } - - /** - * Returns Object value of the column. - * @param node - * @param column - * @return value - */ - public Object getValueAt(Object node, int column) - { - PObjectNode fn = (PObjectNode) node; - Object retVal = null; - - Ability feat = null; - Object temp = fn.getItem(); - if (temp instanceof Ability) - { - feat = (Ability) temp; - } - - switch (column) - { - case COL_NAME: - retVal = fn.toString(); - break; - case COL_TYPE: - if(feat != null) - { - retVal = feat.getTypeUsingFlag(true); - } - break; - case COL_COST: - if(feat != null) - { - retVal = feat.getCostString(); - } - break; - case COL_MULTIPLES: - if(feat != null) - { - if (feat.isMultiples()) - { - retVal = "Y"; - } - else - { - retVal = "N"; - } - } - break; - case COL_STACKS: - if(feat != null) - { - if (feat.isStacks()) - { - retVal = "Y"; - } - else - { - retVal = "N"; - } - } - break; - case COL_REQUIREMENTS: - if(feat != null) - { - retVal = feat.preReqStrings(); - } - break; - case COL_DESCRIPTION: - if(feat != null) - { - retVal = feat.piDescSubString(); - } - break; - case COL_CHOICES: - retVal = fn.getChoices(); - break; - case COL_SRC: - retVal = fn.getSource(); - break; - case -1: - retVal = fn.getItem(); - break; - default: - Logging.errorPrint("In InfoFeats.getValueAt the column " + column + " is not supported."); - break; - } - - return retVal; - } - - /** - * There must be a root object, though it can be hidden - * to make it's existence basically a convenient way to - * keep track of the objects - * @param aNode - */ - private void setRoot(PObjectNode aNode) - { - setRoot(aNode.clone()); - } - - /** - * This method gets the feat list from the current PC by calling - * <code>pc.aggregateFeatList()</code>. Because <code>aggregateFeatList()</code> - * (correctly) returns chosen/auto/virtual feats aggregated together, this - * elimiates duplicate feats. However, since we want to display feats with - * multiple choices (e.g. Weapon Focus) separately if they are chosen/auto/etc., - * we add back the chosen, virtual, and automatic feats when the <code>isMultiples()</code> - * returns <code>true</code>. Note that this <b>may</b> cause problems for - * the prerequisite tree, although the code there <b>appears</b> robust enough - * to handle it. - * The list is sorted before it is returned. - * - * @return A list of the current PCs feats. - */ - private List<Ability> buildPCFeatList() - { - List<Ability> returnValue = new ArrayList<Ability>(getPc().aggregateFeatList().size()); - - for (Ability aFeat : getPc().aggregateFeatList()) - { - if (aFeat.isMultiples()) - { - final String featKey = aFeat.getKeyName(); - - if (getPc().hasRealFeat(aFeat)) - { - returnValue.add(getPc().getRealFeatKeyed(featKey)); - } - - /*else*/ if (getPc().hasFeatAutomatic(featKey)) - { - returnValue.add(getPc().getFeatAutomaticKeyed(featKey)); - } - - /*else*/ if (getPc().hasFeatVirtual(featKey)) - { - returnValue.add(AbilityUtilities.getAbilityFromList(getPc().getVirtualFeatList(), "FEAT", featKey, -1)); - } - } - else - { - returnValue.add(aFeat); - } - } - - //Need to sort the list. - return (List<Ability>)Globals.sortPObjectList(returnValue); - } - - /** - * Populates the tree with a list of feats by name only (not much of a tree). - * Simply adds feats to the root node. - * - * @param available <code>true</code> if this is the list of feats available - * for selection, <code>false</code> if this is the selected feats - * @param showAll - */ - private void buildTreeNameOnly(boolean available, boolean showAll) - { - super.setRoot(new PObjectNode()); - String qFilter = this.getQFilter(); - - Iterator<? extends Categorisable> fI; - - if (available) - { - fI = Globals.getAbilityKeyIterator("FEAT"); - } - else - { - fI = buildPCFeatList().iterator(); - } - - while (fI.hasNext()) - { - final Ability aFeat = (Ability) fI.next(); - - /* - * update for new filtering - * author: Thomas Behr 09-02-02 - */ - if (!accept(getPc(), aFeat)) - { - continue; - } - - if (!showAll) - { - if (!((aFeat.getVisibility() == Visibility.DEFAULT) - || (aFeat.getVisibility() == Visibility.DISPLAY_ONLY))) - { - continue; - } - } - - int hasIt = HASABILITY_NO; - final String featKey = aFeat.getKeyName(); - - if (available) - { - if (getPc().hasRealFeat(aFeat)) - { - hasIt = HASABILITY_CHOSEN; - } - else if (getPc().hasFeatAutomatic(featKey)) - { - hasIt = HASABILITY_AUTOMATIC; - } - else if (getPc().hasFeatVirtual(featKey)) - { - hasIt = HASABILITY_VIRTUAL; - } - } - - // for availableModel, - // use virtual or non-acquired feats - // for selectedModel, - // use virtual, auto and chosen - if ((available && ((hasIt == HASABILITY_VIRTUAL) || (hasIt == HASABILITY_NO) || aFeat.isMultiples())) - || (!available)) - { - PObjectNode aFN = new PObjectNode(); - aFN.setParent((PObjectNode) super.getRoot()); - - if (!available) - { - aFN.setCheckFeatState(PObjectNode.CAN_USE_FEAT, getPc()); - } - - aFN.setItem(aFeat); - - //Does anyone know why we don't call - //aFN.setIsValid(aFeat.passesPreReqToGain()) here? - if (qFilter == null || - ( aFeat.getDisplayName().toLowerCase().indexOf(qFilter) >= 0 || - aFeat.getType().toLowerCase().indexOf(qFilter) >= 0 )) - { - ((PObjectNode) super.getRoot()).addChild(aFN); - } - } - } - } - - /** - * Populates the model with feats in a prerequisite tree. It retrieves - * all feats, then places the feats with no prerequisites under the root - * node. It then iterates the remaining feats and places them under - * their appropriate prerequisite feats, creating a node called "Other" at - * the end if the prerequisites were not met. - * - * @param available <code>true</code> if this is the list of feats available - * for selection, <code>false</code> if this is the selected feats - * @param showAll - */ - private void buildTreePrereqTree(boolean available, boolean showAll) - { - if ((preReqTreeRoot == null) && available) - { - preReqTreeRoot = new PObjectNode(); - } - - if (available) - { - setRoot(preReqTreeRoot); - } - else - { - setRoot(new PObjectNode()); - } - - List<Ability> aList = new ArrayList<Ability>(); - List<Ability> fList = new ArrayList<Ability>(); - - if (available) - { - Ability anAbility; - - for (Iterator<? extends Categorisable> it = Globals.getAbilityKeyIterator( - Constants.FEAT_CATEGORY); it.hasNext();) - { - anAbility = (Ability) it.next(); - - if (accept(getPc(), anAbility)) - { - if ( - (anAbility.getVisibility() == Visibility.DEFAULT) || - (anAbility.getVisibility() == Visibility.DISPLAY_ONLY)) - { - fList.add(anAbility); - } - } - } - } - else - { - // fList = (ArrayList)pc.aggregateFeatList().clone(); - // make filters work ;-) - - //My concern here in using buildPCFeatList() instead - //of pc.aggregateFeatList() is what duplicates would doo - //to the tree. I THINK that the code will find - //the first prerequisite feat and add the feats to that - //This may not be perfect, but I don't think it will blow up. - for (Ability aFeat : buildPCFeatList()) - { - if (accept(getPc(), aFeat)) - { - if ((aFeat.getVisibility() == Visibility.DEFAULT) - || (aFeat.getVisibility() == Visibility.DISPLAY_ONLY)) - { - fList.add(aFeat); - } - } - } - } - - for (int i = 0; i < fList.size(); ++i) - { - final Ability aFeat = fList.get(i); - - if (!aFeat.hasPreReqTypeOf("FEAT")) - { - fList.remove(aFeat); - aList.add(aFeat); - --i; // to counter increment - } - } - - PObjectNode rootAsPObjectNode = (PObjectNode) super.getRoot(); - - PObjectNode[] cc = new PObjectNode[aList.size()]; - - for (int i = 0; i < aList.size(); ++i) - { - cc[i] = new PObjectNode(); - cc[i].setItem(aList.get(i)); - cc[i].setParent(rootAsPObjectNode); - - if (!available) - { - cc[i].setCheckFeatState(PObjectNode.CAN_USE_FEAT, getPc()); - } - } - - rootAsPObjectNode.setChildren(cc); - - int loopmax = 6; // only go 6 levels... - - while ((fList.size() > 0) && (loopmax-- > 0)) - { - for (int i = 0; i < fList.size(); ++i) - { - final Ability aFeat = fList.get(i); - int placed = 0; - - for (int j = 0; j < rootAsPObjectNode.getChildCount(); ++j) - { - final PObjectNode po = rootAsPObjectNode.getChild(j); - - // Make a copy of the prereq - // list so we don't destroy - // the other prereqs - List<Prerequisite> preReqList = new ArrayList<Prerequisite>(); - - for (int pi = aFeat.getPreReqCount() - 1; pi >= 0; --pi) - { - final Prerequisite prereq = aFeat.getPreReq(pi); - - if ((prereq.getKind() != null) && prereq.getKind().equalsIgnoreCase("FEAT")) - { - preReqList.add(prereq); - } - } - placed = placedThisFeatInThisTree(aFeat, po, preReqList, 0, available); - - if (placed > 0) - { - break; - } - } - - if (placed == 2) // i.e. tree match - { - fList.remove(aFeat); - --i; // since we're incrementing in the for loop - } - } - } - - if (fList.size() > 0) - { - PObjectNode po = new PObjectNode(); - po.setItem("Other"); - cc = new PObjectNode[fList.size()]; - - for (int i = 0; i < fList.size(); ++i) - { - cc[i] = new PObjectNode(); - cc[i].setItem(fList.get(i)); - cc[i].setParent(po); - - - final int state; - if (modelType == MODEL_TYPE_SELECTED && available) - { - state = PObjectNode.CAN_GAIN_FEAT; - } - else if (modelType == MODEL_TYPE_SELECTED) - { - state = PObjectNode.CAN_USE_FEAT; - } - else - { - state = PObjectNode.NOT_A_FEAT; - } - cc[i].setCheckFeatState(state, getPc()); - } - - po.setChildren(cc); - rootAsPObjectNode.addChild(po); - } - } - - /** - * Populates the list of feats as a type->name tree. It sets the root - * of the tree to <code>InfoFeats.typeRoot</code>, which contains - * the types. It then iterates the feat list and adds each feat to - * all applicable types. - * - * @param available <code>true</code> if this is the list of feats available - * for selection, <code>false</code> if this is the selected feats - * @param showAll - */ - private void buildTreeTypeName(boolean available, boolean showAll) - { - setRoot(typeRoot); - - Iterator<? extends Categorisable> fI; - - if (available) - { - fI = Globals.getAbilityKeyIterator("FEAT"); - } - else - { - fI = buildPCFeatList().iterator(); - } - - while (fI.hasNext()) - { - final Ability aFeat = (Ability) fI.next(); - - // in the availableTable, if filtering out unqualified feats - // ignore any feats the PC doesn't qualify for - - /* - * update for new filtering - * author: Thomas Behr 09-02-02 - */ - if (!accept(getPc(), aFeat)) - { - continue; - } - - if (!showAll) - { - if ((aFeat.getVisibility() != Visibility.DEFAULT) - && (aFeat.getVisibility() != Visibility.DISPLAY_ONLY)) - { - continue; - } - } - - int hasIt = HASABILITY_NO; - final String featKey = aFeat.getKeyName(); - - if (available) - { - if (getPc().hasRealFeat(aFeat)) - { - hasIt = HASABILITY_CHOSEN; - } - else if (getPc().hasFeatAutomatic(featKey)) - { - hasIt = HASABILITY_AUTOMATIC; - } - else if (getPc().hasFeatVirtual(featKey)) - { - hasIt = HASABILITY_VIRTUAL; - } - } - - // if putting together availableModel, use virtual or non-acquired - // feats for selectedModel, use virtual, auto and chosen - PObjectNode rootAsPObjectNode = (PObjectNode) super.getRoot(); - - if ((available && ((hasIt == HASABILITY_VIRTUAL) || (hasIt == HASABILITY_NO) || aFeat.isMultiples())) - || (!available)) - { - for (int i = 0; i < rootAsPObjectNode.getChildCount(); ++i) - { - if (aFeat.isType(rootAsPObjectNode.getChild(i).toString())) - { - PObjectNode aFN = new PObjectNode(); - - if (!available) - { - aFN.setCheckFeatState(PObjectNode.CAN_USE_FEAT, getPc()); - } - - aFN.setParent(rootAsPObjectNode.getChild(i)); - aFN.setItem(aFeat); - if (Globals.checkRule(RuleConstants.FEATPRE)) - { - // Method no longer exists - aFN.setIsValid(true); - } - else - { - PrereqHandler.passesAll( aFeat.getPreReqList(), getPc(), aFeat ); - } - rootAsPObjectNode.getChild(i).addChild(aFN); - } - } - } - } - } - - /** - * Populates the list of feats as a source->name tree. It sets the root - * of the tree to <code>InfoFeats.sourceRoot</code>, which contains - * the sources. It then iterates the feat list and adds each feat to - * all applicable source. - * - * @param available <code>true</code> if this is the list of feats available - * for selection, <code>false</code> if this is the selected feats - * @param showAll - */ - private void buildTreeSourceName(boolean available, boolean showAll) - { - setRoot(sourceRoot); - - Iterator<? extends Categorisable> fI; - - if (available) - { - fI = Globals.getAbilityKeyIterator("FEAT"); - } - else - { - fI = buildPCFeatList().iterator(); - } - - while (fI.hasNext()) - { - final Ability aFeat = (Ability) fI.next(); - - // in the availableTable, if filtering out unqualified feats - // ignore any feats the PC doesn't qualify for - - /* - * update for new filtering - * author: Thomas Behr 09-02-02 - */ - if (!accept(getPc(), aFeat)) - { - continue; - } - - if (!showAll) - { - if (!((aFeat.getVisibility() == Visibility.DEFAULT) - || (aFeat.getVisibility() == Visibility.DISPLAY_ONLY))) - { - continue; - } - } - - int hasIt = HASABILITY_NO; - final String featKey = aFeat.getKeyName(); - - if (available) - { - if (getPc().hasRealFeat(aFeat)) - { - hasIt = HASABILITY_CHOSEN; - } - else if (getPc().hasFeatAutomatic(featKey)) - { - hasIt = HASABILITY_AUTOMATIC; - } - else if (getPc().hasFeatVirtual(featKey)) - { - hasIt = HASABILITY_VIRTUAL; - } - } - - // if putting together availableModel, use virtual or non-acquired - // feats for selectedModel, use virtual, auto and chosen - PObjectNode rootAsPObjectNode = (PObjectNode) super.getRoot(); - - if (rootAsPObjectNode != null && (available && ((hasIt == HASABILITY_VIRTUAL) || (hasIt == HASABILITY_NO) || aFeat.isMultiples())) - || (!available)) - { - for (int i = 0; i < rootAsPObjectNode.getChildCount(); ++i) - { - - final String sourceString = aFeat.getSourceEntry().getSourceBook().getLongName(); - if (sourceString != null && sourceString.equals(rootAsPObjectNode.getChild(i).toString())) - { - PObjectNode aFN = new PObjectNode(); - - if (!available) - { - aFN.setCheckFeatState(PObjectNode.CAN_USE_FEAT, getPc()); - } - - aFN.setParent(rootAsPObjectNode.getChild(i)); - aFN.setItem(aFeat); - if (Globals.checkRule(RuleConstants.FEATPRE)) - { - // Method no longer exitsts - aFN.setIsValid(true); - } - else - { - PrereqHandler.passesAll( aFeat.getPreReqList(), getPc(), aFeat ); - } - rootAsPObjectNode.getChild(i).addChild(aFN); - } else { - Logging.errorPrint("In InfoFeats.buildTreeSourceName the feat " + aFeat + " has no source long entry."); - } - } - } - } - } - - private int placedThisFeatInThisTree(final Ability aFeat, PObjectNode po, List<Prerequisite> aList, int level, boolean available) - { - final Ability bFeat = (Ability) po.getItem(); // must be a Feat - boolean trychildren = false; - boolean thisisit = false; - - for (Prerequisite prereq : aList) - { - String pString = prereq.getKey(); - - if (pString.equalsIgnoreCase(bFeat.getKeyName())) - { - thisisit = true; - } - else - { - trychildren = true; // might be a child - } - - if (thisisit) - { - PObjectNode p = new PObjectNode(); - p.setItem(aFeat); - p.setParent(po); - po.addChild(p); - - final int state; - if (modelType == MODEL_TYPE_SELECTED && available) - { - state = PObjectNode.CAN_GAIN_FEAT; - } - else if (modelType == MODEL_TYPE_SELECTED) - { - state = PObjectNode.CAN_USE_FEAT; - } - else - { - state = PObjectNode.NOT_A_FEAT; - } - p.setCheckFeatState(state, getPc()); - - return 2; // successfully added - } - else if (trychildren) - { - for (int i = 0; i < po.getChildCount(); ++i) - { - int j = placedThisFeatInThisTree(aFeat, po.getChild(i), aList, level + 1, available); - - if (j == 2) - { - return 2; - } - } - } - } - return 0; // not here - } - - /** - * This assumes the FeatModel exists but needs to be repopulated - * Calls the various <code>buildTreeXXX</code> methods based on the - * <code>mode</code> parameter. - * - * @param mode View mode for this tree, one of <code>GuiConstants.INFOFEATS_VIEW_NAMEONLY</code>, - * <code>GuiConstants.INFOFEATS_VIEW_TYPENAME</code>, or <code>GuiConstants.INFOFEATS_VIEW_PREREQTREE</code>. - * @param available <code>true</code> if this is the available feats tree, - * <code>false</code> if this is the selected feats tree. - * @param showAll - */ - private void resetModel(int mode, boolean available, boolean showAll) - { - if (!available) - { - modelType = MODEL_TYPE_SELECTED; - } - - switch (mode) - { - //NOTE: I moved the code here into private methods - //to make it more intelligible - case GuiConstants.INFOFEATS_VIEW_TYPENAME: - buildTreeTypeName(available, showAll); - - break; - - case GuiConstants.INFOFEATS_VIEW_NAMEONLY: - buildTreeNameOnly(available, showAll); - - break; - - case GuiConstants.INFOFEATS_VIEW_PREREQTREE: - buildTreePrereqTree(available, showAll); - - break; - - case GuiConstants.INFOFEATS_VIEW_SOURCENAME: - buildTreeSourceName(available, showAll); - - break; - - default: - Logging.errorPrint("In InfoFeats.resetModel the mode " + mode + " is not supported."); - - break; - } - - PObjectNode rootAsPObjectNode = (PObjectNode) super.getRoot(); - - if (rootAsPObjectNode.getChildCount() > 0) - { - fireTreeNodesChanged(super.getRoot(), new TreePath(super.getRoot())); - } - } - - public List<String> getMColumnList() - { - List<String> retList = new ArrayList<String>(); - for(int i = 1; i < names.length; i++) - { - retList.add(names[i]); - } - return retList; - } - - public boolean isMColumnDisplayed(int col) - { - return (displayList.get(col)).booleanValue(); - } - - public void setMColumnDisplayed(int col, boolean disp) - { - setColumnViewOption(names[col], disp); - displayList.set(col, new Boolean(disp)); - } - - public int getMColumnOffset() - { - return 1; - } - - public int getMColumnDefaultWidth(int col) - { - return SettingsHandler.getPCGenOption("InfoFeats.sizecol." + names[col], widths[col]); - } - - public void setMColumnDefaultWidth(int col, int width) - { - SettingsHandler.setPCGenOption("InfoFeats.sizecol." + names[col], width); - } - - private String getViewcolOptionName(String colName) - { - String strModel; - if (modelType == MODEL_TYPE_AVAIL) - { - strModel = "available"; - } - else // MODEL_TYPE_SELECTED - { - strModel = "selected"; - } - return "InfoFeats." + strModel + ".viewcol." + colName; - } - - private boolean getColumnViewOption(String colName, boolean defaultVal) - { - String strViewCol = getViewcolOptionName(colName); - - // If newer separated type exists, then use it, otherwise get value from older style - if (SettingsHandler.hasPCGenOption(strViewCol)) - { - return SettingsHandler.getPCGenOption(strViewCol, defaultVal); - } - - // Fall back to old option name, but replace save as new style. Don't - // delete it as there are two different tables using these options - boolean retVal = SettingsHandler.getPCGenOption("InfoFeats.viewcol." + colName, defaultVal); - setColumnViewOption(colName, retVal); - return retVal; - } - - private void setColumnViewOption(String colName, boolean val) - { - String strViewCol = getViewcolOptionName(colName); - SettingsHandler.setPCGenOption(strViewCol, val); - } - - public void resetMColumn(int col, TableColumn column) - { - // TODO Auto-generated method stub - switch(col) - { - case COL_COST: - case COL_MULTIPLES: - case COL_STACKS: - column.setCellRenderer(new pcgen.gui.utils.JTableEx.AlignCellRenderer(SwingConstants.CENTER)); - break; - - default: - break; - } - } - } - - private class FeatPopupListener extends MouseAdapter - { - private FeatPopupMenu menu; - private JTree tree; - - private FeatPopupListener(JTreeTable treeTable, FeatPopupMenu aMenu) - { - tree = treeTable.getTree(); - menu = aMenu; - - KeyListener myKeyListener = new KeyListener() - { - public void keyTyped(KeyEvent e) - { - dispatchEvent(e); - } - - // Walk through the list of accelerators - // to see if the user has pressed a sequence - // used by the popup. This would not - // happen unless the popup was showing - // - public void keyPressed(KeyEvent e) - { - final int keyCode = e.getKeyCode(); - - if (keyCode != KeyEvent.VK_UNDEFINED) - { - final KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(e); - - for (int i = 0; i < menu.getComponentCount(); ++i) - { - final Component menuComponent = menu.getComponent(i); - - if (menuComponent instanceof JMenuItem) - { - KeyStroke ks = ((JMenuItem) menuComponent).getAccelerator(); - - if ((ks != null) && keyStroke.equals(ks)) - { - selPath = tree.getSelectionPath(); - ((JMenuItem) menuComponent).doClick(2); - - return; - } - } - } - } - - dispatchEvent(e); - } - - public void keyReleased(KeyEvent e) - { - dispatchEvent(e); - } - }; - - treeTable.addKeyListener(myKeyListener); - } - - public void mousePressed(MouseEvent evt) - { - maybeShowPopup(evt); - } - - public void mouseReleased(MouseEvent evt) - { - maybeShowPopup(evt); - } - - private void maybeShowPopup(MouseEvent evt) - { - if (evt.isPopupTrigger()) - { - selPath = tree.getClosestPathForLocation(evt.getX(), evt.getY()); - - if (selPath == null) - { - return; - } - - if (tree.isSelectionEmpty()) - { - tree.setSelectionPath(selPath); - menu.show(evt.getComponent(), evt.getX(), evt.getY()); - } - else if (!tree.isPathSelected(selPath)) - { - tree.setSelectionPath(selPath); - menu.show(evt.getComponent(), evt.getX(), evt.getY()); - } - else - { - tree.addSelectionPath(selPath); - menu.show(evt.getComponent(), evt.getX(), evt.getY()); - } - } - } - } - - private class FeatPopupMenu extends JPopupMenu - { - private JMenuItem duplicateMenuItem; - private JMenuItem featFullMenuItem; - private JMenuItem noQualifyMenuItem; - private JTreeTable treeTable; - - private FeatPopupMenu(JTreeTable treeTable) - { - if ((this.treeTable = treeTable) == availableTable) - { - FeatPopupMenu.this.add(addMenu = Utility.createMenuItem("Add " + getSingularTabName(), - new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - addFeat(); - } - }, "infoFeats.addFeat", (char) 0, "shortcut EQUALS", "Add Feat", "Add16.gif", true)); - - // Build menus now since expert settings - // could get changed while we are running - noQualifyMenuItem = Utility.createMenuItem(NO_QUALIFY_MESSAGE, null, null, (char) 0, null, null, null, false); - duplicateMenuItem = Utility.createMenuItem(DUPLICATE_MESSAGE , null, null, (char) 0, null, null, null, false); - featFullMenuItem = Utility.createMenuItem(FEAT_FULL_MESSAGE , null, null, (char) 0, null, null, null, false); - } - else // selectedTable - { - FeatPopupMenu.this.add(removeMenu = Utility.createMenuItem("Remove " + getSingularTabName(), - new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - removeFeat(); - } - }, "infoFeats.removeFeat", (char) 0, "shortcut MINUS", "Remove Feat", "Remove16.gif", true)); - } - } - - public void show(Component source, int x, int y) - { - PObjectNode node = (PObjectNode)treeTable.getTree().getLastSelectedPathComponent(); - if (node != null && node.getItem() instanceof Ability) - { - Ability aFeat = (Ability) ( (PObjectNode) treeTable.getTree().getLastSelectedPathComponent()).getItem(); - - if (treeTable == availableTable) - { - int ok = checkFeatQualify(aFeat); - - if (ok == FEAT_OK) - { - FeatPopupMenu.this.removeAll(); - FeatPopupMenu.this.add(addMenu); - } - - if (SettingsHandler.isExpertGUI() == false) - { - switch (ok) - { - case FEAT_NOT_QUALIFIED: - FeatPopupMenu.this.removeAll(); - FeatPopupMenu.this.add(noQualifyMenuItem); - break; - - case FEAT_DUPLICATE: - FeatPopupMenu.this.removeAll(); - FeatPopupMenu.this.add(duplicateMenuItem); - break; - - case FEAT_FULL_FEAT: - FeatPopupMenu.this.removeAll(); - FeatPopupMenu.this.add(featFullMenuItem); - break; - - case FEAT_OK: - // Handled above - break; - - default: - Logging.errorPrint(getSingularTabName() + " " + - aFeat.getDisplayName() + - " is somehow in state " + ok - + " which is not handled" + - " in InfoFeats.FeatPopupMenu.show()"); - - return; - } - } - - // The selected feat menu is prebuilt so only add to - // available - } - - super.show(source, x, y); - } - else - { - FeatPopupMenu.this.removeAll(); - - super.show(source, x, y); - } - } - } - -// private void showRemainingFeatPoints() -// { -// if (getPc() != null) -// { -// numFeatsField.setText(BigDecimalHelper.trimBigDecimal(new BigDecimal(getPc().getFeats())).toString()); -// } -// } - private void clearAvailableQFilter() - { - availableModel.clearQFilter(); - if (saveAvailableViewMode != null) - { - viewAvailMode = saveAvailableViewMode.intValue(); - saveAvailableViewMode = null; - } - availableModel.resetModel(viewAvailMode, true, false); - clearAvailableQFilterButton.setEnabled(false); - viewAvailComboBox.setEnabled(true); - textAvailableQFilter.setText(null); - availableModel.setQFilter(null); - forceRefresh(); - } - - private void clearSelectedQFilter() - { - selectedModel.clearQFilter(); - if (saveAvailableViewMode != null) - { - viewSelectMode = saveSelectedViewMode.intValue(); - saveSelectedViewMode = null; - } - selectedModel.resetModel(viewSelectMode, false, false); - clearSelectedQFilterButton.setEnabled(false); - viewSelectComboBox.setEnabled(true); - textSelectedQFilter.setText(null); - selectedModel.setQFilter(null); - forceRefresh(); - } - - private void setAvailableQFilter() - { - String aString = textAvailableQFilter.getText(); - - if (aString.length() == 0) - { - clearAvailableQFilter(); - return; - } - availableModel.setQFilter(aString); - - if (saveAvailableViewMode == null) - { - saveAvailableViewMode = new Integer(viewAvailMode); - } - viewAvailMode = GuiConstants.INFOFEATS_VIEW_NAMEONLY; - availableModel.resetModel(viewAvailMode, true, false); - clearAvailableQFilterButton.setEnabled(true); - viewAvailComboBox.setEnabled(false); - forceRefresh(); - } - - private void setSelectedQFilter() - { - String aString = textSelectedQFilter.getText(); - - if (aString.length() == 0) - { - clearSelectedQFilter(); - return; - } - selectedModel.setQFilter(aString); - - if (saveSelectedViewMode == null) - { - saveSelectedViewMode = new Integer(viewSelectMode); - } - viewSelectMode = GuiConstants.INFOFEATS_VIEW_NAMEONLY; - selectedModel.resetModel(viewSelectMode, false, false); - clearSelectedQFilterButton.setEnabled(true); - viewSelectComboBox.setEnabled(false); - forceRefresh(); - } - - /** - * @see pcgen.gui.tabs.BaseCharacterInfoTab#getTab() - */ - @Override - protected Tab getTab() - { - return tab; - } -} Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoRaces.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoRaces.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoRaces.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -1172,13 +1172,13 @@ // now loop through all the races and // see which ones are not filtered out - for(Race aRace : Globals.getRaceMap().values()) + for ( final Race race : Globals.getAllRaces() ) { - if(accept(getPc(), aRace)) { + if(accept(getPc(), race)) { if (qFilter == null || - ( aRace.getDisplayName().toLowerCase().indexOf(qFilter) >= 0 || - aRace.getType().toLowerCase().indexOf(qFilter) >= 0 )) - raceList.add(aRace); + ( race.getDisplayName().toLowerCase().indexOf(qFilter) >= 0 || + race.getType().toLowerCase().indexOf(qFilter) >= 0 )) + raceList.add(race); } } @@ -1206,11 +1206,11 @@ // now loop through all the races and // see which ones are not filtered out - for (Race aRace : Globals.getRaceMap().values()) + for ( final Race race : Globals.getAllRaces() ) { - if(accept(getPc(), aRace)) { - if(!typeList.contains(aRace.getType())) { - typeList.add(aRace.getType()); + if(accept(getPc(), race)) { + if(!typeList.contains(race.getType())) { + typeList.add(race.getType()); } } } @@ -1226,18 +1226,18 @@ rt[iType] = new PObjectNode(); rt[iType].setItem(aType); - for (Race aRace : Globals.getRaceMap().values()) + for ( final Race race : Globals.getAllRaces() ) { - if (aRace == null) { + if (race == null) { continue; } - if (!aRace.getType().equals(aType)) { + if (!race.getType().equals(aType)) { continue; } PObjectNode aFN = new PObjectNode(); - aFN.setItem(aRace); + aFN.setItem(race); aFN.setParent(rt[iType]); rt[iType].addChild(aFN); } @@ -1257,10 +1257,10 @@ // now loop through all the races and // see which ones are not filtered out - for(Race aRace : Globals.getRaceMap().values()) + for ( final Race race : Globals.getAllRaces() ) { - if(accept(getPc(), aRace)) { - final String aString = aRace.getSourceEntry().getSourceBook().getLongName(); + if(accept(getPc(), race)) { + final String aString = race.getSourceEntry().getSourceBook().getLongName(); if(aString != null && !sourceList.contains(aString) && aString.length() > 0) { sourceList.add(aString); @@ -1278,19 +1278,19 @@ rs[iSource] = new PObjectNode(); rs[iSource].setItem(aSource); - for (Race aRace : Globals.getRaceMap().values()) + for ( final Race race : Globals.getAllRaces() ) { - if (aRace == null) { + if (race == null) { continue; } - final String aString = aRace.getSourceEntry().getSourceBook().getLongName(); + final String aString = race.getSourceEntry().getSourceBook().getLongName(); if (aString != null && !aString.equals(aSource)) { continue; } PObjectNode aFN = new PObjectNode(); - aFN.setItem(aRace); + aFN.setItem(race); aFN.setParent(rs[iSource]); rs[iSource].addChild(aFN); } @@ -1311,11 +1311,11 @@ // now loop through all the races and // see which ones are not filtered out - for (Race aRace : Globals.getRaceMap().values()) + for ( final Race race : Globals.getAllRaces() ) { - if (accept(getPc(), aRace)) + if (accept(getPc(), race)) { - final String raceType = aRace.getRaceType(); + final String raceType = race.getRaceType(); if (!typeList.contains(raceType)) { typeList.add(raceType); @@ -1334,20 +1334,20 @@ rt[iType] = new PObjectNode(); rt[iType].setItem(aType); - for (Race aRace : Globals.getRaceMap().values() ) + for ( final Race race : Globals.getAllRaces() ) { - if (aRace == null) + if (race == null) { continue; } - if (!aRace.getRaceType().equals(aType)) + if (!race.getRaceType().equals(aType)) { continue; } PObjectNode aFN = new PObjectNode(); - aFN.setItem(aRace); + aFN.setItem(race); aFN.setParent(rt[iType]); rt[iType].addChild(aFN); } @@ -1369,11 +1369,11 @@ // now loop through all the races and // see which ones are not filtered out - for (Race aRace : Globals.getRaceMap().values()) + for ( final Race race : Globals.getAllRaces() ) { - if (accept(getPc(), aRace)) + if (accept(getPc(), race)) { - final String raceType = aRace.getRaceType(); + final String raceType = race.getRaceType(); if (!typeList.contains(raceType)) { typeList.add(raceType); @@ -1393,22 +1393,22 @@ rt[iType].setItem(aType); HashMap<String, PObjectNode> subTypes = new HashMap<String, PObjectNode>(); - for (Race aRace : Globals.getRaceMap().values()) + for ( final Race race : Globals.getAllRaces() ) { - if (aRace == null) + if (race == null) { continue; } - if (!aRace.getRaceType().equals(aType)) + if (!race.getRaceType().equals(aType)) { continue; } - List<String> raceSubTypes = aRace.getRacialSubTypes(); + List<String> raceSubTypes = race.getRacialSubTypes(); if (raceSubTypes.size() > 0) { - for (String subTypeName : raceSubTypes) + for (final String subTypeName : raceSubTypes) { PObjectNode subTypeNode = subTypes.get(subTypeName); if (subTypeNode == null) @@ -1425,7 +1425,7 @@ subTypes.put(subTypeName, subTypeNode); } PObjectNode raceNode = new PObjectNode(); - raceNode.setItem(aRace); + raceNode.setItem(race); raceNode.setParent(subTypeNode); subTypeNode.addChild(raceNode); } @@ -1433,7 +1433,7 @@ else { PObjectNode aFN = new PObjectNode(); - aFN.setItem(aRace); + aFN.setItem(race); aFN.setParent(rt[iType]); rt[iType].addChild(aFN); } @@ -1456,16 +1456,16 @@ // now loop through all the races and // see which ones are not filtered out - for (Race aRace : Globals.getRaceMap().values()) + for ( final Race race : Globals.getAllRaces() ) { - if (accept(getPc(), aRace)) + if (accept(getPc(), race)) { - final String raceType = aRace.getRaceType(); + final String raceType = race.getRaceType(); if (!typeList.contains(raceType)) { typeList.add(raceType); } - final String type = aRace.getTypeUsingFlag(true); + final String type = race.getTypeUsingFlag(true); if (type.length() > 0) { StringTokenizer tok = new StringTokenizer(type, "."); @@ -1492,21 +1492,21 @@ rt[iType] = new PObjectNode(); rt[iType].setItem(aType); - for (Race aRace : Globals.getRaceMap().values()) + for ( final Race race : Globals.getAllRaces() ) { - if (aRace == null) + if (race == null) { continue; } boolean typeMatch = false; - if (aRace.getRaceType().equals(aType)) + if (race.getRaceType().equals(aType)) { typeMatch = true; } - if (aRace.getTypeUsingFlag(true).indexOf(aType) != -1) + if (race.getTypeUsingFlag(true).indexOf(aType) != -1) { - StringTokenizer tok = new StringTokenizer(aRace.getTypeUsingFlag(true), "."); + StringTokenizer tok = new StringTokenizer(race.getTypeUsingFlag(true), "."); while (tok.hasMoreTokens()) { final String type = tok.nextToken(); @@ -1523,7 +1523,7 @@ } PObjectNode aFN = new PObjectNode(); - aFN.setItem(aRace); + aFN.setItem(race); aFN.setParent(rt[iType]); rt[iType].addChild(aFN); } Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -451,7 +451,7 @@ buildLangLists(availableLangs, selectedLangNames, excludedLangs); - Globals.sortPObjectList(availableLangs); + Globals.sortPObjectListByName(availableLangs); ChooserInterface lc = ChooserFactory.getChooserInstance(); lc.setVisible(false); Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSummary.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSummary.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSummary.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -2844,13 +2844,11 @@ final Object pcRace = getSelectedItem(); removeAllElements(); - for (Iterator<Race> it = Globals.getRaceMap().values().iterator(); it.hasNext();) + for ( final Race race : Globals.getAllRaces() ) { - final Race aRace = it.next(); - - if (accept(pc, aRace)) + if (accept(pc, race)) { - addElement(aRace); + addElement(race); } } Added: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityModel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityModel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityModel.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,915 @@ +/* + * AbilityModel.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package pcgen.gui.tabs.ability; + +import java.util.ArrayList; +import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; + +import javax.swing.SwingConstants; +import javax.swing.table.TableColumn; +import javax.swing.tree.TreePath; + +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.Globals; +import pcgen.core.SettingsHandler; +import pcgen.core.prereq.Prerequisite; +import pcgen.gui.TableColumnManagerModel; +import pcgen.gui.utils.AbstractTreeTableModel; +import pcgen.gui.utils.PObjectNode; +import pcgen.gui.utils.TreeTableModel; +import pcgen.util.Logging; +import pcgen.util.PropertyFactory; + +/** + * Extends AbstractTreeTableModel to build an available or + * selected abilities tree for this tab. + * <p/> + * The basic idea of the TreeTableModel is that there is a + * single <code>root</code> object. This root object has a null + * <code>parent</code>. All other objects have a parent which + * points to a non-null object. parent objects contain a list of + * <code>children</code>, which are all the objects that point + * to it as their parent. + * objects (or <code>nodes</code>) which have 0 children + * are leafs (the end of that linked list). + * nodes which have at least 1 child are not leafs. + * Leafs are like files and non-leafs are like directories. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class AbilityModel extends AbstractTreeTableModel implements TableColumnManagerModel +{ + private AbilitySelectionPanel.ViewMode theViewMode = AbilitySelectionPanel.ViewMode.TYPENAME; + + private List<Ability> theAbilityList; + private AbilityCategory theCategory; + + private IAbilityListFilter theFilter = null; + + private String theOptionsRoot = "InfoAbility."; //$NON-NLS-1$ + + private PObjectNode typeRoot = null; + private PObjectNode sourceRoot = null; + + /** + * Creates an AbilityModel. + * + * @param aList The list of <tt>Ability</tt> objects to manage + * @param aCategory The <tt>AbilityCategory</tt> this list comes from. + * @param viewMode + * @param anOptionRoot The key to store options under. + */ + public AbilityModel(final List<Ability> aList, + final AbilityCategory aCategory, + final AbilitySelectionPanel.ViewMode viewMode, + final String anOptionRoot) + { + super(null); + theAbilityList = aList; + + theOptionsRoot = anOptionRoot; + + theViewMode = viewMode; + + theCategory = aCategory; + + resetModel(viewMode, false); + } + + private void buildDefaultRoots() + { + if ( typeRoot != null ) + { + return; + } + + typeRoot = new PObjectNode(); + sourceRoot = new PObjectNode(); + + final SortedSet<String> typeSet = new TreeSet<String>(); + final SortedSet<String> sourceSet = new TreeSet<String>(); + // We will use the global lists for this + for ( final Ability ability : Globals.getAbilityList(theCategory) ) + { + if ( theFilter != null && theFilter.accept(theViewMode, ability) == false ) + { + continue; + } + + typeSet.addAll(ability.getTypeList(true)); + final String sourceString = ability.getSourceEntry().getSourceBook().getLongName(); + if ( sourceString != null ) + { + sourceSet.add(sourceString); + } + } + final PObjectNode[] ccTypes = new PObjectNode[typeSet.size()]; + int i = 0; + for ( final String type : typeSet ) + { + ccTypes[i] = new PObjectNode(); + ccTypes[i].setItem(type); + ccTypes[i].setParent(typeRoot); + i++; + } + typeRoot.setChildren(ccTypes); + + final PObjectNode[] ccSources = new PObjectNode[sourceSet.size()]; + i = 0; + for ( final String source : sourceSet ) + { + ccSources[i] = new PObjectNode(); + ccSources[i].setItem(source); + ccSources[i].setParent(sourceRoot); + } + sourceRoot.setChildren(ccSources); + + } + + /** + * Set the mode used to display the tree. + * + * @param aMode A <tt>ViewMode</tt> used to display the tree. + */ + public void setViewMode( final AbilitySelectionPanel.ViewMode aMode ) + { + theViewMode = aMode; + } + + /** + * Sets an object to use to control if which abilities should be shown. + * + * @param aFilter An object implementing the <tt>IAbilityListFilter</tt> + * interface. + */ + public void setAbilityFilter( final IAbilityListFilter aFilter ) + { + theFilter = aFilter; + } + + /** + * Returns Class for the column. + * @param column + * @return Class + */ + @Override + public Class<?> getColumnClass(final int column) + { + if (column == Column.NAME.ordinal()) + { + return TreeTableModel.class; + } + return String.class; + } + + /* The JTreeTableNode interface. */ + + /** + * Returns int number of columns. + * @return column count + */ + public int getColumnCount() + { + return Column.values().length; + } + + /** + * Returns String name of a column. + * @param column + * @return column name + */ + public String getColumnName(int column) + { + return Column.values()[column].getName(); + } + + /** + * @see pcgen.gui.utils.AbstractTreeTableModel#getRoot() + */ + // TODO - Do we need to define this?? + @Override + public Object getRoot() + { + return super.getRoot(); + } + + /** + * Returns Object value of the column. + * @param node + * @param aColumn + * @return value + */ + public Object getValueAt(final Object node, final int aColumn) + { + PObjectNode fn = (PObjectNode) node; + Object retVal = null; + + Ability ability = null; + Object temp = fn.getItem(); + if (temp instanceof Ability) + { + ability = (Ability) temp; + } + + Column column = Column.values()[aColumn]; + switch (column) + { + case NAME: + retVal = fn.toString(); + break; + case TYPE: + if (ability != null) + { + retVal = ability.getTypeUsingFlag(true); + } + break; + case COST: + if (ability != null) + { + retVal = ability.getCostString(); + } + break; + case MULTIPLES: + if (ability != null) + { + if (ability.isMultiples()) + { + retVal = PropertyFactory.getString("in_yes"); //$NON-NLS-1$ + } + else + { + retVal = PropertyFactory.getString("in_no"); //$NON-NLS-1$ + } + } + break; + case STACKS: + if (ability != null) + { + if (ability.isStacks()) + { + retVal = PropertyFactory.getString("in_yes"); //$NON-NLS-1$ + } + else + { + retVal = PropertyFactory.getString("in_no"); //$NON-NLS-1$ + } + } + break; + case REQUIREMENTS: + if (ability != null) + { + retVal = ability.preReqStrings(); + } + break; + case DESCRIPTION: + if (ability != null) + { + retVal = ability.piDescSubString(); + } + break; + case CHOICES: + retVal = fn.getChoices(); + break; + case SOURCE: + retVal = fn.getSource(); + break; + } + + return retVal; + } + + /** + * There must be a root object, though it can be hidden + * to make it's existence basically a convenient way to + * keep track of the objects + * @param aNode + */ + private void setRoot(PObjectNode aNode) + { + setRoot(aNode.clone()); + } + + /** + * Populates the tree with a list of feats by name only (not much of a tree). + * Simply adds feats to the root node. + * + * @param showAll Force displaying of all abilities + */ + private void buildTreeNameOnly(final boolean showAll) + { + super.setRoot(new PObjectNode()); + String qFilter = this.getQFilter(); + + for ( final Ability ability : theAbilityList ) + { + if ( showAll == true || theFilter == null || theFilter.accept(theViewMode, ability)) + { + PObjectNode aFN = new PObjectNode(); + aFN.setParent((PObjectNode) super.getRoot()); + + switch ( ability.getFeatType() ) + { + case AUTOMATIC: + aFN.setColor(SettingsHandler.getFeatAutoColor()); + break; + case VIRTUAL: + aFN.setColor(SettingsHandler.getFeatVirtualColor()); + break; + } + + aFN.setItem(ability); + + //Does anyone know why we don't call + //aFN.setIsValid(aFeat.passesPreReqToGain()) here? + if (qFilter == null || + ( ability.getDisplayName().toLowerCase().indexOf(qFilter) >= 0 || + ability.getType().toLowerCase().indexOf(qFilter) >= 0 )) + { + ((PObjectNode) super.getRoot()).addChild(aFN); + } + } + } + } + + /** + * Populates the model with feats in a prerequisite tree. It retrieves + * all feats, then places the feats with no prerequisites under the root + * node. It then iterates the remaining feats and places them under + * their appropriate prerequisite feats, creating a node called "Other" at + * the end if the prerequisites were not met. + * + * @param showAll Force showing all abilities + */ + private void buildTreePrereqTree(final boolean showAll) + { + setRoot(new PObjectNode()); + + // This list initially contains all abilities that pass the filter. + final List<Ability> fList = new ArrayList<Ability>(); + for ( final Ability ability : theAbilityList ) + { + if ( showAll || theFilter == null || theFilter.accept(theViewMode, ability) ) + { + fList.add( ability ); + } + } + + // Loop through the list of abilities and find any that don't have a + // PREABILITY tag. These are added directly to the tree. + final List<Ability> aList = new ArrayList<Ability>(); + for (int i = 0; i < fList.size(); ++i) + { + final Ability aFeat = fList.get(i); + + // TODO - Change this when we have PRExxx tags for Ability + if (!aFeat.hasPreReqTypeOf("FEAT")) //$NON-NLS-1$ + { + fList.remove(aFeat); + aList.add(aFeat); + --i; // to counter increment + } + } + + // Add these abilities to the tree + final PObjectNode rootAsPObjectNode = (PObjectNode) super.getRoot(); + if ( rootAsPObjectNode == null ) + { + return; + } + + final PObjectNode[] directChildren = new PObjectNode[aList.size()]; + + for (int i = 0; i < aList.size(); ++i) + { + final Ability ability = aList.get(i); + + directChildren[i] = new PObjectNode(); + directChildren[i].setItem(ability); + directChildren[i].setParent(rootAsPObjectNode); + + switch ( ability.getFeatType() ) + { + case AUTOMATIC: + directChildren[i].setColor(SettingsHandler.getFeatAutoColor()); + break; + case VIRTUAL: + directChildren[i].setColor(SettingsHandler.getFeatVirtualColor()); + break; + } + } + + rootAsPObjectNode.setChildren(directChildren); + + // fList now contains only those abilities that have prereqs on other + // abilities. + int loopmax = 6; // only go 6 levels... + while ((fList.size() > 0) && (loopmax-- > 0)) + { + for (int i = 0; i < fList.size(); ++i) + { + final Ability ability = fList.get(i); + int placed = 0; + + // Make a copy of the prereq + // list so we don't destroy + // the other prereqs + List<Prerequisite> preReqList = new ArrayList<Prerequisite>(); + + for (int pi = ability.getPreReqCount() - 1; pi >= 0; --pi) + { + final Prerequisite prereq = ability.getPreReq(pi); + + // TODO - Fix this. See comment above. + if ((prereq.getKind() != null) && prereq.getKind().equalsIgnoreCase("FEAT")) //$NON-NLS-1$ + { + preReqList.add(prereq); + } + } + // TODO - What should happen if an ability has multiple pres? + for (int j = 0; j < rootAsPObjectNode.getChildCount(); ++j) + { + final PObjectNode po = rootAsPObjectNode.getChild(j); + + placed = placedThisFeatInThisTree(ability, po, preReqList); + + if (placed > 0) + { + break; + } + } + + // TODO - Make a constant for this? + if (placed == 2) // i.e. tree match + { + fList.remove(ability); + --i; // since we're incrementing in the for loop + } + } + } + + // These abilities have PREABILITY tags but we couldn't find a match + // for the ability. + // TODO - This shouldn't happen should it? + if (fList.size() > 0) + { + PObjectNode po = new PObjectNode(); + po.setItem(PropertyFactory.getString("in_other")); //$NON-NLS-1$ + final PObjectNode[] cc = new PObjectNode[fList.size()]; + + for (int i = 0; i < fList.size(); ++i) + { + final Ability ability = fList.get(i); + + cc[i] = new PObjectNode(); + cc[i].setItem(ability); + cc[i].setParent(po); + + switch ( ability.getFeatType() ) + { + case AUTOMATIC: + cc[i].setColor(SettingsHandler.getFeatAutoColor()); + break; + case VIRTUAL: + cc[i].setColor(SettingsHandler.getFeatVirtualColor()); + break; + } + } + + po.setChildren(cc); + rootAsPObjectNode.addChild(po); + } + } + + /** + * Populates the list of feats as a type->name tree. It sets the root + * of the tree to <code>InfoFeats.typeRoot</code>, which contains + * the types. It then iterates the feat list and adds each feat to + * all applicable types. + * + * @param showAll Force displaying of all abilities + */ + private void buildTreeTypeName(final boolean showAll) + { + setRoot(typeRoot); + + final PObjectNode rootAsPObjectNode = (PObjectNode) super.getRoot(); + if ( rootAsPObjectNode == null ) + { + return; + } + + for ( final Ability ability : theAbilityList ) + { + if ( showAll || theFilter == null || theFilter.accept(theViewMode, ability)) + { + for (int i = 0; i < rootAsPObjectNode.getChildCount(); ++i) + { + if (ability.isType(rootAsPObjectNode.getChild(i).toString())) + { + final PObjectNode aFN = new PObjectNode(); + + switch ( ability.getFeatType() ) + { + case AUTOMATIC: + aFN.setColor(SettingsHandler.getFeatAutoColor()); + break; + case VIRTUAL: + aFN.setColor(SettingsHandler.getFeatVirtualColor()); + break; + } + + aFN.setParent(rootAsPObjectNode.getChild(i)); + aFN.setItem(ability); +// if (!Globals.checkRule(RuleConstants.FEATPRE)) +// { +// // TODO - This seems to have no effect +// PrereqHandler.passesAll( ability.getPreReqList(), null, ability ); +// } + rootAsPObjectNode.getChild(i).addChild(aFN); + } + } + } + } + } + + /** + * Populates the list of feats as a source->name tree. It sets the root + * of the tree to <code>InfoFeats.sourceRoot</code>, which contains + * the sources. It then iterates the feat list and adds each feat to + * all applicable source. + * + * @param showAll Force displaying of all abilities + */ + private void buildTreeSourceName(final boolean showAll) + { + setRoot(sourceRoot); + + final PObjectNode rootAsPObjectNode = (PObjectNode) super.getRoot(); + // TODO - This shouldn't really be required since I just set the damn + // root node. + if ( rootAsPObjectNode == null ) + { + return; + } + + for ( final Ability ability : theAbilityList ) + { + if ( showAll || theFilter == null || theFilter.accept(theViewMode, ability) ) + { + final String sourceString = ability.getSourceEntry().getSourceBook().getLongName(); + if ( sourceString == null ) + { + Logging.errorPrint("In InfoFeats.buildTreeSourceName the feat " + ability + " has no source long entry."); + } + // + for (int i = 0; i < rootAsPObjectNode.getChildCount(); ++i) + { + if (sourceString.equals(rootAsPObjectNode.getChild(i).toString())) + { + final PObjectNode aFN = new PObjectNode(); + + switch ( ability.getFeatType() ) + { + case AUTOMATIC: + aFN.setColor(SettingsHandler.getFeatAutoColor()); + break; + case VIRTUAL: + aFN.setColor(SettingsHandler.getFeatVirtualColor()); + break; + } + + aFN.setParent(rootAsPObjectNode.getChild(i)); + aFN.setItem(ability); + + // TODO - This code appears to have no effect. +// if (Globals.checkRule(RuleConstants.FEATPRE)) +// { +// // Method no longer exitsts - aFN.setIsValid(true); +// } +// else +// { +// PrereqHandler.passesAll( aFeat.getPreReqList(), getPc(), aFeat ); +// } + rootAsPObjectNode.getChild(i).addChild(aFN); + } + } + } + } + } + + private int placedThisFeatInThisTree(final Ability anAbility, + final PObjectNode po, + final List<Prerequisite> aList) + { + final Ability parentAbility = (Ability) po.getItem(); // must be a Feat + boolean trychildren = false; + boolean thisisit = false; + + for (final Prerequisite prereq : aList) + { + final String pString = prereq.getKey(); + + if (pString.equalsIgnoreCase(parentAbility.getKeyName())) + { + thisisit = true; + } + else + { + trychildren = true; // might be a child + } + + if (thisisit) + { + final PObjectNode p = new PObjectNode(); + p.setItem(anAbility); + p.setParent(po); + po.addChild(p); + + switch ( anAbility.getFeatType() ) + { + case AUTOMATIC: + p.setColor(SettingsHandler.getFeatAutoColor()); + break; + case VIRTUAL: + p.setColor(SettingsHandler.getFeatVirtualColor()); + break; + } + + return 2; // successfully added + } + else if (trychildren) + { + for (int i = 0; i < po.getChildCount(); ++i) + { + int j = placedThisFeatInThisTree(anAbility, po.getChild(i), aList); + + if (j == 2) + { + return 2; + } + } + } + } + return 0; // not here + } + + /** + * Sets the ability list to use. + * + * @param aList A list of Abilities to manage. + */ + public void setAbilityList(final List<Ability> aList) + { + theAbilityList = aList; + resetModel(theViewMode, false); + } + + /** + * This assumes the FeatModel exists but needs to be repopulated + * Calls the various <code>buildTreeXXX</code> methods based on the + * <code>mode</code> parameter. + * + * @param mode View mode for this tree, one of the ViewModes defined in + * <tt>AbilitySelectionPanel</tt> + * @param showAll + */ + public void resetModel(final AbilitySelectionPanel.ViewMode mode, final boolean showAll) + { + // We are going to build and cache the type and source tree roots. + buildDefaultRoots(); + + switch (mode) + { + case TYPENAME: + buildTreeTypeName(showAll); + + break; + + case NAMEONLY: + buildTreeNameOnly(showAll); + + break; + + case PREREQTREE: + buildTreePrereqTree(showAll); + + break; + + case SOURCENAME: + buildTreeSourceName(showAll); + + break; + } + + fireTreeNodesChanged(super.getRoot(), new TreePath(super.getRoot())); + } + + /** + * @see pcgen.gui.TableColumnManagerModel#getMColumnList() + */ + public List<String> getMColumnList() + { + final List<String> retList = new ArrayList<String>(); + + final Column[] columns = Column.values(); + for(int i = 1; i < columns.length; i++) + { + retList.add(columns[i].getName()); + } + return retList; + } + + /** + * @see pcgen.gui.TableColumnManagerModel#isMColumnDisplayed(int) + */ + public boolean isMColumnDisplayed(final int col) + { + return Column.values()[col].isVisible(); + } + + private void setColumnOption(final Column col, final String anOption, final String val) + { + SettingsHandler.setPCGenOption(theOptionsRoot + "." + anOption + "." + col.toString(), val); //$NON-NLS-1$ //$NON-NLS-2$ + } + + private int getColumnOption(final Column aCol, final String anOption, final int aDefault) + { + return SettingsHandler.getPCGenOption(theOptionsRoot + "." + anOption + "." + aCol.toString(), aDefault); //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * @see pcgen.gui.TableColumnManagerModel#setMColumnDisplayed(int, boolean) + */ + public void setMColumnDisplayed(int col, boolean disp) + { + Column.values()[col].setVisible(disp); + setColumnOption(Column.values()[col], "viewcol", String.valueOf(disp)); //$NON-NLS-1$ + } + + /** + * @see pcgen.gui.TableColumnManagerModel#getMColumnOffset() + */ + public int getMColumnOffset() + { + return 1; + } + + /** + * @see pcgen.gui.TableColumnManagerModel#getMColumnDefaultWidth(int) + */ + public int getMColumnDefaultWidth(int col) + { + return getColumnOption(Column.values()[col], "sizecol", Column.values()[col].getWidth()); //$NON-NLS-1$ + } + + /** + * @see pcgen.gui.TableColumnManagerModel#setMColumnDefaultWidth(int, int) + */ + public void setMColumnDefaultWidth(final int col, final int width) + { + Column.values()[col].setWidth(width); + setColumnOption(Column.values()[col], "sizecol", String.valueOf(width)); //$NON-NLS-1$ + } + + /** + * @see pcgen.gui.TableColumnManagerModel#resetMColumn(int, javax.swing.table.TableColumn) + */ + public void resetMColumn(final int col, final TableColumn tColumn) + { + final Column column = Column.values()[col]; + switch(column) + { + case COST: + case MULTIPLES: + case STACKS: + tColumn.setCellRenderer(new pcgen.gui.utils.JTableEx.AlignCellRenderer(SwingConstants.CENTER)); + break; + + default: + break; + } + } + + /** + * An enum for the Columns in the table. + */ + public enum Column { + /** Name */ + NAME("AbilityModel.Columns.Name", 100, true), //$NON-NLS-1$ + /** Type */ + TYPE("AbilityModel.Columns.Type", 100, false), //$NON-NLS-1$ + /** Cost */ + COST("AbilityModel.Columns.Cost", 100, false), //$NON-NLS-1$ + /** Multiples */ + MULTIPLES("AbilityModel.Columns.Multiples", 100, false), //$NON-NLS-1$ + /** Stacks */ + STACKS("AbilityModel.Columns.Stacks", 100, false), //$NON-NLS-1$ + /** Prereqs */ + REQUIREMENTS("AbilityModel.Columns.Requirements", 100, false), //$NON-NLS-1$ + /** Description */ + DESCRIPTION("AbilityModel.Columns.Description", 100, false), //$NON-NLS-1$ + /** Choices */ + CHOICES("AbilityModel.Columns.Choices", 100, false), //$NON-NLS-1$ + /** Source */ + SOURCE("AbilityModel.Columns.Source", 100, false); //$NON-NLS-1$ + + private String theName; + private int theWidth; + private boolean theVisibleFlag; + + Column(final String aName, final int aDefaultWidth, final boolean visible) + { + theName = PropertyFactory.getString(aName); + theWidth = aDefaultWidth; + theVisibleFlag = visible; + } + + /** + * Sets the width of this column. + * + * @param aWidth An integer width. + */ + public void setWidth(final int aWidth) + { + theWidth = aWidth; + } + + /** + * Gets the width of this column. + * + * @return An integer width. + */ + public int getWidth() + { + return theWidth; + } + + /** + * Gets the display name for the column. + * + * @return An internationized string. + */ + public String getName() + { + return theName; + } + + /** + * Sets if the column is visible. + * + * @param yesNo <tt>true</tt> makes the column visible. + */ + public void setVisible(final boolean yesNo) + { + theVisibleFlag = yesNo; + } + + /** + * Checks if the column is visible. + * + * @return <tt>true</tt> if the column is visibile. + */ + public boolean isVisible() + { + return theVisibleFlag; + } + + /** + * Gets the enum for the specified ordinal. + * + * @param ordinal An ordinal + * + * @return The enum value + */ + public static Column get(final int ordinal) + { + return Column.values()[ordinal]; + } + } + +} Property changes on: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityModel.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityPoolPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityPoolPanel.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityPoolPanel.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -48,6 +48,12 @@ private AbilityCategory theCategory; private JTextField theNumAbilitiesField = new JTextField(); + /** + * Construct the panel and add all the components. + * + * @param aPC The PC + * @param aCategory The <tt>AbilityCategory</tt> this panel represents. + */ public AbilityPoolPanel(final PlayerCharacter aPC, final AbilityCategory aCategory) { super(); @@ -62,27 +68,53 @@ theNumAbilitiesField.setInputVerifier(new InputVerifier() { + @Override + public boolean verify(final JComponent input) + { + final String text = ((JTextField)input).getText(); + if ( text.length() > 0 ) + { + try + { + if ( theCategory.allowFractionalPool() == false ) + { + Integer.parseInt(text); + return true; + } + Double.parseDouble(text); + return true; + } + catch (Exception e) + { + return false; + } + } + return true; + } + + @Override public boolean shouldYieldFocus(final JComponent input) { - final boolean valueOk = verify(input); - if (theNumAbilitiesField.getText().length() > 0) + final boolean valueOk = super.shouldYieldFocus(input); + if (!valueOk ) { - // TODO - Remove setDirty() - thePC.setDirty(true); - // TODO - Change to thePC.setAbilityPool() - thePC.setFeats(Double.parseDouble(theNumAbilitiesField.getText())); + getToolkit().beep(); } else { - showRemainingAbilityPoints(); + if (theNumAbilitiesField.getText().length() > 0) + { + final BigDecimal expectedValue = thePC.getAvailableAbilityPool(theCategory); + final BigDecimal newValue = new BigDecimal(theNumAbilitiesField.getText()); + thePC.adjustAbilities(theCategory, newValue.subtract(expectedValue)); + } + else + { + showRemainingAbilityPoints(); + } } return valueOk; } - - public boolean verify(JComponent input) - { - return true; - } }); showRemainingAbilityPoints(); @@ -99,7 +131,7 @@ */ public void showRemainingAbilityPoints() { - theNumAbilitiesField.setText(BigDecimalHelper.trimBigDecimal(new BigDecimal(thePC.getFeats())).toString()); -// theNumAbilitiesField.setText(BigDecimalHelper.trimBigDecimal(thePC.getAvailableAbilityPool(theCategory)).toString()); +// theNumAbilitiesField.setText(BigDecimalHelper.trimBigDecimal(new BigDecimal(thePC.getFeats())).toString()); + theNumAbilitiesField.setText(BigDecimalHelper.trimBigDecimal(thePC.getAvailableAbilityPool(theCategory)).toString()); } } Added: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilitySelectionPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilitySelectionPanel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilitySelectionPanel.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,519 @@ +/* + * AbilitySelectionPanel.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package pcgen.gui.tabs.ability; + +import java.awt.BorderLayout; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.ScrollPaneConstants; +import javax.swing.SwingUtilities; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.PlayerCharacter; +import pcgen.core.SettingsHandler; +import pcgen.gui.TableColumnManager; +import pcgen.gui.filter.Filterable; +import pcgen.gui.tabs.IFilterableView; +import pcgen.gui.tabs.InfoTabUtils; +import pcgen.gui.tabs.ability.AbilityModel.Column; +import pcgen.gui.utils.JTreeTable; +import pcgen.gui.utils.JTreeTableSorter; +import pcgen.gui.utils.LabelTreeCellRenderer; +import pcgen.gui.utils.PObjectNode; +import pcgen.util.Logging; +import pcgen.util.PropertyFactory; +import pcgen.util.enumeration.Visibility; + +/** + * This is a common base class which handles the mundane tasks of displaying + * Abilities in a table and allowing the user to interact with them. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public abstract class AbilitySelectionPanel extends JPanel implements IFilterableView, IAbilityListFilter +{ + private PlayerCharacter thePC; + private AbilityCategory theCategory; + + /** The model that represents the list of abilities to choose from */ + protected AbilityModel theModel; + /** The table the abilities are displayed in */ + protected JTreeTable theTable; + /** The sorter object used to sort the table */ + protected JTreeTableSorter theSorter; + + /** A list of listeners registered to receive ability selection events */ + private List<IAbilitySelectionListener> theListeners = new ArrayList<IAbilitySelectionListener>(2); + + private String theOptionsRoot = "InfoAbility."; //$NON-NLS-1$ + + /** enum for the possible view modes supported */ + public enum ViewMode + { + /** view mode for Type->Name */ + TYPENAME, + /** view mode for Name (essentially a JTable) */ + NAMEONLY, + /** view in requirement tree mode */ + PREREQTREE, + /** view mode for Source->Name */ + SOURCENAME + } + + /** + * The manner in which to display the tree. + * TODO - Yuck. Why is this in GuiConstants? + */ + private ViewMode theViewMode = ViewMode.PREREQTREE; + + /** + * This is a temporary used to store the current value of the view mode + * when the QFilter changes it. + */ + private transient ViewMode theSavedViewMode = null; + + /** + * The object that is controlling the filtering (using the PCGen Filters). + */ + private Filterable theFilter = null; + + /** + * Construct and build a new panel to display a list of abilities. + * + * @param aPC + * @param aCategory + */ + public AbilitySelectionPanel(final PlayerCharacter aPC, final AbilityCategory aCategory) + { + thePC = aPC; + theCategory = aCategory; + + theOptionsRoot += aCategory.getKeyName(); + + final int vm = SettingsHandler.getPCGenOption(getFullOptionKey() + ".viewmode", getDefaultViewMode().ordinal()); //$NON-NLS-1$ + theViewMode = ViewMode.values()[vm]; + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + initComponents(); + } + }); + } + + /** + * Return the <tt>PlayerCharacter</tt> this panel is displaying info for. + * + * @return The PC + */ + public PlayerCharacter getPC() + { + return thePC; + } + + /** + * Return the <tt>AbilityCategory</tt> these abilities come from. + * + * @return The Ability category + */ + public AbilityCategory getCategory() + { + return theCategory; + } + + /** + * Returns the list of abilities to display in this panel. + * + * <p>This method is abstract and must be overridden by subclasses. + * + * @return A <tt>List</tt> of <tt>Ability</tt> objects. + */ + protected abstract List<Ability> getAbilityList(); + + /** + * Return a String key to use when saving state and options. + * + * <p>This method is abstract and must be overridden by subclasses. + * + * @return A String to use as a base key. + */ + protected abstract String getOptionKey(); + + /** + * Initializes the GUI components. + * + * <p>This method constructs the model from the ability list. It then + * builds the Tree to display the abilities in. A Scroller is added to the + * table to provide scrolling support and a Column button is provided to + * allow configuration of visible columns. + * + */ + protected void initComponents() + { + theModel = new AbilityModel(getAbilityList(), theCategory, theViewMode, + getFullOptionKey()); + + theModel.setAbilityFilter(this); + + theTable = new JTreeTable(theModel); + final TableColumnModel tableColumnModel = theTable.getColumnModel(); + + for ( int i = 0; i < tableColumnModel.getColumnCount(); i++ ) + { + final TableColumn col = tableColumnModel.getColumn(i); + + final AbilityModel.Column amCol = AbilityModel.Column.get(i); + final int colWidth = SettingsHandler.getPCGenOption(getFullOptionKey() + ".sizecol." + amCol.toString(), amCol.getWidth()); //$NON-NLS-1$ + col.setPreferredWidth(colWidth); + + col.addPropertyChangeListener(new PropertyChangeListener() { + + public void propertyChange(final PropertyChangeEvent anEvt) + { + if ( anEvt.getPropertyName().equals("width") ) //$NON-NLS-1$ + { + SettingsHandler.setPCGenOption(getFullOptionKey() + ".sizecol." + Column.get(col.getModelIndex()), Integer.parseInt(anEvt.getNewValue().toString())); //$NON-NLS-1$ + } + } + + }); + } + + theSorter = new JTreeTableSorter(theTable, + (PObjectNode) theModel.getRoot(), theModel); + + addListSelectionListener(); + + final JTree tree = theTable.getTree(); + tree.setRootVisible(false); + tree.setShowsRootHandles(true); + tree.setCellRenderer(new LabelTreeCellRenderer()); + + final JScrollPane scrollPane = new JScrollPane(theTable, + ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, + ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + add(scrollPane, BorderLayout.CENTER); + + final JButton columnButton = new JButton(); + scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, columnButton); + // TODO - This should probably be an icon. + columnButton.setText("^"); //$NON-NLS-1$ + new TableColumnManager(theTable, columnButton, theModel); + } + + /** + * Adds a new listener to the panel that will be advised of selection + * events that occur within the panel. + * + * @param aListener The object to notify + */ + public void addAbilitySelectionListener(final IAbilitySelectionListener aListener) + { + if ( theListeners.contains(aListener) == false ) + { + theListeners.add(aListener); + } + } + + /** + * Returns a list of listeners listening for ability selection events. + * + * @return An unmodifiable list of listeners. + */ + public List<IAbilitySelectionListener> getListeners() + { + return Collections.unmodifiableList(theListeners); + } + + /** + * This method adds a <tt>ListSelectionListener</tt> to the table and adds + * itself as the listener so that we will be advised of selection changes + * with the table. + * + * <p>Events are passed on to the registered listeners and the + * <tt>abilitySelected</tt> method is called. + * + * @see #abilitySelected(Ability) + * @see #addAbilitySelectionListener(IAbilitySelectionListener) + * + */ + private void addListSelectionListener() + { + theTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() + { + public void valueChanged(ListSelectionEvent e) + { + if (!e.getValueIsAdjusting()) + { + final int idx = InfoTabUtils.getSelectedIndex(e); + + if (idx < 0) + { + return; + } + + final Object temp = theTable.getTree().getPathForRow(idx).getLastPathComponent(); + final Ability ability = getAbilityFromObject(temp); + + for ( final IAbilitySelectionListener listener : theListeners ) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + abilitySelected(ability); + listener.abilitySelected(ability); + } + }); + } + } + } + }); + + } + + /** + * This method is called when an ability is selected (clicked on) in the + * table. + * + * <p>This implementation does nothing. Subclasses can override it to + * provide custom behaviour. + * + * @param anAbility The selected <tt>Ability</tt> + */ + protected void abilitySelected( @SuppressWarnings("unused")final Ability anAbility ) + { + // Placeholder. + } + + /** + * This is a utility method that safely gets an <tt>Ability</tt> object from + * the tree. + * + * @param anObject The node in the tree. + * + * @return An <tt>Ability</tt> object or <tt>null</tt> if the selected item + * is not an Ability. + */ + protected Ability getAbilityFromObject(final Object anObject) + { + if (anObject == null) + { + // This should never happen. I don't think we need a user + // message here. + Logging.debugPrint("No ability selected while processing event"); //$NON-NLS-1$ + return null; + } + + if (anObject instanceof PObjectNode) + { + final Object temp = ((PObjectNode) anObject).getItem(); + + if (temp instanceof Ability) + { + return (Ability) temp; + } + } + + return null; + } + + /** + * Gets the starting view mode if one hasn't been set. + * + * @return A view mode. + */ + public abstract ViewMode getDefaultViewMode(); + + /** + * Sets the current view mode for this panel's tree. + * + * @param aMode A mode to construct the tree in. + */ + public void setViewMode( final int aMode ) + { + theViewMode = ViewMode.values()[aMode]; + if ( theModel != null ) + { + theModel.setViewMode(theViewMode); + } + SettingsHandler.setPCGenOption(getFullOptionKey() + ".viewmode", aMode); //$NON-NLS-1$ + } + + /** + * @see pcgen.gui.tabs.IFilterableView#clearQFilter() + */ + public void clearQFilter() + { + theModel.clearQFilter(); + if (theSavedViewMode != null) + { + theViewMode = theSavedViewMode; + theSavedViewMode = null; + } + theModel.resetModel(theViewMode, false); + theTable.updateUI(); + } + + /** + * @see pcgen.gui.tabs.IFilterableView#getInitialChoice() + */ + public int getInitialChoice() + { + return theViewMode.ordinal(); + } + + /** + * @see pcgen.gui.tabs.IFilterableView#getViewChoices() + */ + public List<String> getViewChoices() + { + final List<String> viewChoices = new ArrayList<String>(4); + viewChoices.add(PropertyFactory.getString("in_typeName")); //$NON-NLS-1$ + viewChoices.add(PropertyFactory.getString("in_nameLabel")); //$NON-NLS-1$ + viewChoices.add(PropertyFactory.getString("in_preReqTree")); //$NON-NLS-1$ + viewChoices.add(PropertyFactory.getString("in_sourceName")); //$NON-NLS-1$ + return viewChoices; + } + + /** + * @see pcgen.gui.tabs.IFilterableView#setQFilter(java.lang.String) + */ + public void setQFilter(String aFilter) + { + theModel.setQFilter(aFilter); + + if (theSavedViewMode == null) + { + theSavedViewMode = theViewMode; + } + theViewMode = ViewMode.NAMEONLY; + theModel.resetModel(theViewMode, false); + theTable.updateUI(); + } + + /** + * @see pcgen.gui.tabs.IFilterableView#viewChanged(int) + */ + public void viewChanged(int aNewView) + { + setViewMode(aNewView); +// SettingsHandler.setFeatTab_SelectedListMode(viewSelectedMode); + rebuildView(); + } + + /** + * This method forces the view to be rebuilt. + * + * <p>This method should be called if <b>only</b> the view but <b>not</b> + * the data needs to be updated. This could be because the view mode has + * changed or some other setting affects the visibility of the tree + * elements. + */ + public void rebuildView() + { + if (theTable != null) + { + final List<String> pathList = theTable.getExpandedPaths(); + theModel.resetModel(theViewMode, false); + + if (theSorter != null) + { + theSorter.sortNodeOnColumn(); + } + theTable.updateUI(); + theTable.expandPathList(pathList); + } + } + + /** + * This method forces an update of the data and rebuilding of the view. + * + * <p>This method should be called if the underlying data has changed. For + * example, adding or removing an ability. + * + */ + public void update() + { + if ( theTable != null ) + { + theModel.setAbilityList(getAbilityList()); + if (theSorter != null) + { + theSorter.sortNodeOnColumn(); + } + theTable.updateUI(); + } + } + + /** + * Adds a <tt>Filterable</tt> object so that Abilities in the list will be + * filtered. + * + * @param aFilterer A Filterable object. + */ + public void addFilterer( final Filterable aFilterer ) + { + theFilter = aFilterer; + } + + /** + * @see pcgen.gui.tabs.ability.IAbilityListFilter#accept(ViewMode, pcgen.core.Ability) + */ + public boolean accept(@SuppressWarnings("unused")final ViewMode aMode, + final Ability anAbility) + { + if (!((anAbility.getVisibility() == Visibility.DEFAULT) + || (anAbility.getVisibility() == Visibility.DISPLAY_ONLY))) + { + return false; + } + + if (theFilter != null && theFilter.accept(getPC(), anAbility) == false) + { + return false; + } + + return true; + } + + private String getFullOptionKey() + { + return theOptionsRoot + "." + getOptionKey(); //$NON-NLS-1$ + } +} Property changes on: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilitySelectionPanel.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AvailableAbilityPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AvailableAbilityPanel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AvailableAbilityPanel.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,343 @@ +/* + * AvailableAbilityPanel.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package pcgen.gui.tabs.ability; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.math.BigDecimal; +import java.util.List; + +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; + +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.Globals; +import pcgen.core.PlayerCharacter; +import pcgen.gui.tabs.components.AddItemPanel; +import pcgen.gui.tabs.components.FilterPanel; +import pcgen.gui.utils.ClickHandler; +import pcgen.gui.utils.JTreeTable; +import pcgen.gui.utils.JTreeTableMouseAdapter; +import pcgen.gui.utils.PObjectNode; +import pcgen.gui.utils.Utility; +import pcgen.util.PropertyFactory; + +/** + * This class creates and manages a panel containing available Abilities for the + * user to choose from. + * + * <p>The panel consists of a <tt>FilterPanel</tt> at the top, a + * <tt>JTreeTable</tt> taking up most of the area and an <tt>AddItemPanel</tt> + * at the bottom. Methods are provided to control which components are visible + * and configure the individual components. + * + * @see pcgen.gui.tabs.components.FilterPanel + * @see pcgen.gui.tabs.components.AddItemPanel + * @see pcgen.gui.utils.JTreeTable + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + * + */ +public class AvailableAbilityPanel extends AbilitySelectionPanel +{ + private static final String AVAILABLE_LABEL = PropertyFactory.getString("in_available") + ": "; //$NON-NLS-1$//$NON-NLS-2$ + + private AddItemPanel theAddButton; + private JMenuItem theAddMenu; + + /** + * Construct the available ability panel. + * + * <p>This method adds a <tt>FilterPanel</tt> and <tt>AddItemPanel</tt> to + * the base table. + * + * @param aPC + * @param aCategory + * + * @see pcgen.gui.tabs.components.FilterPanel + * @see pcgen.gui.tabs.components.AddItemPanel + */ + public AvailableAbilityPanel(final PlayerCharacter aPC, final AbilityCategory aCategory) + { + super(aPC, aCategory); + + setLayout(new BorderLayout()); + + add( new FilterPanel(this, AVAILABLE_LABEL), BorderLayout.NORTH ); + + theAddButton = new AddItemPanel(); + theAddButton.addActionListener(new ActionListener() + { + public void actionPerformed(@SuppressWarnings("unused")final ActionEvent evt) + { + addAbility(); + } + }); + add(theAddButton, BorderLayout.SOUTH); + } + + /** + * Overrided to add a Mouse Listener and Popup menu to the table. + * + * @see pcgen.gui.tabs.ability.AbilitySelectionPanel#initComponents() + */ + @Override + protected void initComponents() + { + super.initComponents(); + + theTable.addMouseListener(new JTreeTableMouseAdapter( + theTable, + new AvailableClickHandler(), + false)); + theTable.addPopupMenu(new AbilityPopupMenu(theTable)); + } + + private void addAbility() + { + final Object temp = theTable.getTree().getLastSelectedPathComponent(); + final Ability ability = getAbilityFromObject(temp); + if ( ability == null ) + { + return; + } + + for ( final IAbilitySelectionListener listener : getListeners() ) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + listener.addAbility(ability); + } + }); + } + } + + private void setAddEnabled(final boolean enabled) + { + theAddButton.setEnabled(enabled); + theAddMenu.setEnabled(enabled); + } + + private class AbilityPopupMenu extends JPopupMenu + { + private JMenuItem poolFullMenuItem; + private JMenuItem noQualifyMenuItem; + private JTreeTable theTreeTable; + + private AbilityPopupMenu(final JTreeTable aTreeTable) + { + theTreeTable = aTreeTable; + final String menuText = PropertyFactory.getFormattedString( + "InfoAbility.Menu.Add", getCategory().getDisplayName()); //$NON-NLS-1$ + final String menuTip = PropertyFactory.getFormattedString( + "InfoAbility.Menu.Add.Tooltip", getCategory().getDisplayName()); //$NON-NLS-1$ + this.add(theAddMenu = Utility.createMenuItem(menuText, + new ActionListener() + { + public void actionPerformed( + @SuppressWarnings("unused")ActionEvent evt) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + addAbility(); + } + }); + } + }, null, (char) 0, "shortcut EQUALS", menuTip, "Add16.gif", true)); //$NON-NLS-1$ //$NON-NLS-2$ + + // Build menus now since expert settings + // could get changed while we are running + final String NO_QUALIFY_MESSAGE = PropertyFactory.getString( + "InfoAbility.Messages.NotQualified"); //$NON-NLS-1$ + final String POOL_FULL_MESSAGE = PropertyFactory.getString( + "InfoAbility.Messages.NoPoints"); //$NON-NLS-1$ + noQualifyMenuItem = Utility.createMenuItem(NO_QUALIFY_MESSAGE, null, null, (char) 0, null, null, null, false); + poolFullMenuItem = Utility.createMenuItem(POOL_FULL_MESSAGE , null, null, (char) 0, null, null, null, false); + } + + /** + * Display the appropriate menu. + * + * <p>The menu is modified to let the user know why they can't select + * an ability if they are not able to. + * + * @see javax.swing.JPopupMenu#show(java.awt.Component, int, int) + */ + @Override + public void show(final Component source, final int x, final int y) + { + final PObjectNode node = (PObjectNode)theTreeTable.getTree().getLastSelectedPathComponent(); + if (node != null && node.getItem() instanceof Ability) + { + final Ability ability = (Ability) ( (PObjectNode) theTreeTable.getTree().getLastSelectedPathComponent()).getItem(); + + if (getPC().canSelectAbility(ability)) + { + removeAll(); + add(theAddMenu); + } + else if ( getPC().getAvailableAbilityPool(getCategory()).compareTo(BigDecimal.ZERO) < 0 ) + { + removeAll(); + add(poolFullMenuItem); + } + else + { + removeAll(); + add(noQualifyMenuItem); + } + + super.show(source, x, y); + } + else + { + removeAll(); + + super.show(source, x, y); + } + } + } + + private class AvailableClickHandler implements ClickHandler + { + /** + * @see pcgen.gui.utils.ClickHandler#singleClickEvent() + */ + public void singleClickEvent() + { + // Do Nothing + } + + /** + * Select the Ability. + * + * @see pcgen.gui.utils.ClickHandler#doubleClickEvent() + */ + public void doubleClickEvent() + { + // We run this after the event has been processed so that + // we don't confuse the table when we change its contents + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + addAbility(); + } + }); + } + + /** + * @see pcgen.gui.utils.ClickHandler#isSelectable(java.lang.Object) + */ + public boolean isSelectable(Object obj) + { + return !(obj instanceof String); + } + } + + /** + * @see pcgen.gui.tabs.ability.IAbilityListFilter#accept(ViewMode, pcgen.core.Ability) + */ + @Override + public boolean accept(final ViewMode aMode, Ability anAbility) + { + if ( super.accept(aMode, anAbility) == false ) + { + return false; + } + + if ( aMode == ViewMode.PREREQTREE ) + { + // TODO - Not sure why the PREREQ tree doesn't check if the PC + // has this ability or not. Seems like a bug to me. + return true; + } + + // If this ability allows multiples we always allow it. + // TODO - We could figure out if there are any valid choices left and + // disallow it if there aren't. + if ( anAbility.isMultiples() ) + { + return true; + } + else if (getPC().hasVirtualAbility(getCategory(), anAbility)) + { + return true; + } + return !getPC().hasAbility(null, Ability.Nature.ANY, anAbility); + } + + /** + * @see pcgen.gui.tabs.ability.AbilitySelectionPanel#getAbilityList() + */ + @Override + protected List<Ability> getAbilityList() + { + return Globals.getAbilityList(getCategory()); + } + + /** + * @see pcgen.gui.tabs.ability.AbilitySelectionPanel#getOptionKey() + */ + @Override + protected String getOptionKey() + { + return "available"; //$NON-NLS-1$ + } + + /** + * @see pcgen.gui.tabs.ability.AbilitySelectionPanel#getDefaultViewMode() + */ + @Override + public ViewMode getDefaultViewMode() + { + return ViewMode.PREREQTREE; + } + + /** + * @see pcgen.gui.tabs.ability.AbilitySelectionPanel#abilitySelected(pcgen.core.Ability) + */ + @Override + protected void abilitySelected( final Ability anAbility ) + { + super.abilitySelected(anAbility); + if ( anAbility != null ) + { + setAddEnabled( getPC().canSelectAbility(anAbility) ); + } + else + { + setAddEnabled(false); + } + } +} Property changes on: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AvailableAbilityPanel.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/IAbilityListFilter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/IAbilityListFilter.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/IAbilityListFilter.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,51 @@ +/* + * IAbilityListFilter.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package pcgen.gui.tabs.ability; + +import pcgen.core.Ability; + +/** + * This interface is used to allow interested parties to filter the list of + * Abilities displayed by the <tt>AbilityModel</tt> class. + * + * + * @author boomer70 <boomer70@... + * + * @since 5.11.1 + */ +public interface IAbilityListFilter +{ + /** + * This method is called by the <tt>AbilityModel</tt> before an Ability is + * added to the model for the registered filter. + * + * <p>The filter should return <tt>true</tt> to allow the specified Ability + * to be added to the model or <tt>false</tt> if not. + * + * @param aMode The view mode the <tt>AbilityModel</tt> is building. + * @param anAbility The ability to be checked. + * + * @return <tt>true</tt> to allow the Ability to be added. + */ + boolean accept(final AbilitySelectionPanel.ViewMode aMode, final Ability anAbility); +} Property changes on: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/IAbilityListFilter.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/IAbilitySelectionListener.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/IAbilitySelectionListener.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/IAbilitySelectionListener.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,65 @@ +/* + * IAbilitySelectionListener.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package pcgen.gui.tabs.ability; + +import pcgen.core.Ability; + +/** + * This interface is used to advise interested parties about Ability Selection + * events. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public interface IAbilitySelectionListener +{ + /** + * This method is called when the user highlights an Ability in the list. + * The method can be called with <tt>null</tt> if no Ability is currently + * selected. + * + * @param anAbility The highlighted ability or <tt>null</tt> + */ + void abilitySelected(final Ability anAbility); + + /** + * This method is called when the user chooses to add an Ability to the + * character. + * + * @param anAbility The chosen Ability. + * + * @return Return <tt>true</tt> to allow the ability to be added. + */ + boolean addAbility(final Ability anAbility); + + /** + * This method is called when the user chooses to remove an Ability from + * the character. + * + * @param anAbility The Ability to remove. + * + * @return Return <tt>true</tt> to allow the Ability to be removed. + */ + boolean removeAbility(final Ability anAbility); +} Property changes on: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/IAbilitySelectionListener.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/SelectedAbilityPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/SelectedAbilityPanel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/SelectedAbilityPanel.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,354 @@ +/* + * SelectedAbilityPanel.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ + +package pcgen.gui.tabs.ability; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; + +import pcgen.core.Ability; +import pcgen.core.AbilityCategory; +import pcgen.core.Globals; +import pcgen.core.PlayerCharacter; +import pcgen.gui.tabs.components.FilterPanel; +import pcgen.gui.tabs.components.RemoveItemPanel; +import pcgen.gui.utils.ClickHandler; +import pcgen.gui.utils.JTreeTable; +import pcgen.gui.utils.JTreeTableMouseAdapter; +import pcgen.gui.utils.PObjectNode; +import pcgen.gui.utils.Utility; +import pcgen.util.PropertyFactory; + +/** + * This class encapsulates a Panel used to display and manage selected + * Abilities. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class SelectedAbilityPanel extends AbilitySelectionPanel +{ + private static final String SELECTED_LABEL = PropertyFactory + .getString("in_selected") + ": "; //$NON-NLS-1$//$NON-NLS-2$ + + private RemoveItemPanel theRemoveButton; + + private JMenuItem theRemoveMenu; + + /** + * Construct the selected panel. + * + * <p>This adds a <tt>FilterPanel</tt> and <tt>RemoveItemPanel</tt> to the + * base class table. + * + * @param aPC The PC + * @param aCategory The <tt>AbilityCategory</tt> to display selected + * Abilities for. + * + * @see pcgen.gui.tabs.ability.AbilitySelectionPanel + */ + public SelectedAbilityPanel(final PlayerCharacter aPC, + final AbilityCategory aCategory) + { + super(aPC, aCategory); + + setLayout(new BorderLayout()); + + add(new FilterPanel(this, SELECTED_LABEL), BorderLayout.NORTH); + + theRemoveButton = new RemoveItemPanel(); + theRemoveButton.addActionListener(new ActionListener() + { + public void actionPerformed(@SuppressWarnings("unused")final ActionEvent evt) + { + removeAbility(); + } + }); + + add(theRemoveButton, BorderLayout.SOUTH); + } + + /** + * Called when the user has requested the selected ability be removed. + * + * <p>This method simply informs any listeners that the request has taken + * place. + */ + public void removeAbility() + { + final Object temp = theTable.getTree().getLastSelectedPathComponent(); + final Ability ability = getAbilityFromObject(temp); + if (ability == null) + { + return; + } + + for (final IAbilitySelectionListener listener : getListeners()) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + listener.removeAbility(ability); + } + }); + } + } + + /** + * This method is overridden so that we can display a count of selected + * abilities in the table header. + * + * @see pcgen.gui.tabs.ability.AbilitySelectionPanel#update() + */ + @Override + public void update() + { + if ( theTable != null ) + { + String curVal = theTable.getColumnModel().getColumn(0).getHeaderValue().toString(); + int endInd = curVal.lastIndexOf('('); + if ( endInd != -1 ) + { + curVal = curVal.substring(0, endInd).trim(); + } + final BigDecimal spent = getPC().getAbilityPoolSpent(getCategory()); + final String txt = curVal + " (" + spent.stripTrailingZeros().toString() + ")"; //$NON-NLS-1$//$NON-NLS-2$ + theTable.getColumnModel().getColumn(0).setHeaderValue(txt); + } + super.update(); + } + + /** + * @see pcgen.gui.tabs.ability.AbilitySelectionPanel#getAbilityList() + */ + @Override + protected List<Ability> getAbilityList() + { + return buildPCAbilityList(); + } + + /** + * @see pcgen.gui.tabs.ability.AbilitySelectionPanel#getOptionKey() + */ + @Override + protected String getOptionKey() + { + return "selected"; //$NON-NLS-1$ + } + + /** + * @see pcgen.gui.tabs.ability.AbilitySelectionPanel#getDefaultViewMode() + */ + @Override + public ViewMode getDefaultViewMode() + { + return ViewMode.NAMEONLY; + } + + /** + * Overridden to add a MouseListener and Popup menu. + * + * @see pcgen.gui.tabs.ability.AbilitySelectionPanel#initComponents() + */ + @Override + protected void initComponents() + { + super.initComponents(); + + theTable.addMouseListener(new JTreeTableMouseAdapter(theTable, + new SelectedClickHandler(), false)); + theTable.addPopupMenu(new AbilityPopupMenu(theTable)); + } + + /** + * This method gets the feat list from the current PC by calling + * <code>pc.aggregateFeatList()</code>. Because + * <code>aggregateFeatList()</code> (correctly) returns + * chosen/auto/virtual feats aggregated together, this elimiates duplicate + * feats. However, since we want to display feats with multiple choices + * (e.g. Weapon Focus) separately if they are chosen/auto/etc., we add back + * the chosen, virtual, and automatic feats when the + * <code>isMultiples()</code> returns <code>true</code>. Note that this + * <b>may</b> cause problems for the prerequisite tree, although the code + * there <b>appears</b> robust enough to handle it. The list is sorted + * before it is returned. + * + * @return A list of the current PCs feats. + */ + private List<Ability> buildPCAbilityList() + { + final List<Ability> abilityList = getPC().getAggregateAbilityList(getCategory()); + final List<Ability> returnValue = new ArrayList<Ability>(abilityList.size()); + + for ( final Ability ability : abilityList ) + { + if (ability.isMultiples()) + { + final String abilityKey = ability.getKeyName(); + + Ability pcAbility = getPC().getRealAbilityKeyed(getCategory(), abilityKey); + if ( pcAbility != null ) + { + returnValue.add( pcAbility ); + } + + pcAbility = getPC().getAutomaticAbilityKeyed(getCategory(), abilityKey); + if ( pcAbility != null ) + { + returnValue.add( pcAbility ); + } + + pcAbility = getPC().getVirtualAbilityKeyed(getCategory(), abilityKey); + if ( pcAbility != null ) + { + returnValue.add( pcAbility ); + } + } + else + { + returnValue.add(ability); + } + } + + // Need to sort the list. + return Globals.sortPObjectListByName(returnValue); + } + + private void setRemoveEnabled(final boolean enabled) + { + theRemoveButton.setEnabled(enabled); + theRemoveMenu.setEnabled(enabled); + } + + private class AbilityPopupMenu extends JPopupMenu + { + private JTreeTable theTreeTable; + + private AbilityPopupMenu(final JTreeTable aTreeTable) + { + theTreeTable = aTreeTable; + final String menuText = PropertyFactory.getFormattedString( + "InfoAbility.Menu.Remove", getCategory().getDisplayName()); //$NON-NLS-1$ + final String menuTip = PropertyFactory + .getFormattedString( + "InfoAbility.Menu.Remove.Tooltip", getCategory().getDisplayName()); //$NON-NLS-1$ + this.add(theRemoveMenu = Utility.createMenuItem(menuText, + new ActionListener() + { + public void actionPerformed(@SuppressWarnings("unused") + final ActionEvent evt) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + removeAbility(); + } + }); + } + }, null, (char) 0, + "shortcut MINUS", menuTip, "Remove16.gif", true)); //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * @see javax.swing.JPopupMenu#show(java.awt.Component, int, int) + */ + @Override + public void show(final Component source, final int x, final int y) + { + final PObjectNode node = (PObjectNode) theTreeTable.getTree() + .getLastSelectedPathComponent(); + if (node != null && node.getItem() instanceof Ability) + { + super.show(source, x, y); + } + else + { + removeAll(); + + super.show(source, x, y); + } + } + } + + private class SelectedClickHandler implements ClickHandler + { + /** + * Allow double click to remove an ability. + * + * @see pcgen.gui.utils.ClickHandler#doubleClickEvent() + */ + public void doubleClickEvent() + { + removeAbility(); + } + + /** + * If this is an <tt>Ability</tt> object it is selectable. + * + * @see pcgen.gui.utils.ClickHandler#isSelectable(java.lang.Object) + */ + public boolean isSelectable(final Object obj) + { + return !(obj instanceof String); + } + + /** + * Not used. + * + * @see pcgen.gui.utils.ClickHandler#singleClickEvent() + */ + public void singleClickEvent() + { + // Do Nothing + } + } + + /** + * @see pcgen.gui.tabs.ability.AbilitySelectionPanel#abilitySelected(pcgen.core.Ability) + */ + @Override + protected void abilitySelected( final Ability anAbility ) + { + super.abilitySelected(anAbility); + if ( anAbility != null ) + { + setRemoveEnabled( anAbility.getFeatType() == Ability.Nature.NORMAL ); + } + else + { + setRemoveEnabled( false ); + } + } +} Property changes on: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/SelectedAbilityPanel.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/AddItemPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/AddItemPanel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/AddItemPanel.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,86 @@ +/* + * AddItemPanel.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package pcgen.gui.tabs.components; + +import java.awt.FlowLayout; +import java.awt.Insets; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JPanel; + +import pcgen.gui.utils.IconUtilitities; +import pcgen.gui.utils.Utility; +import pcgen.util.PropertyFactory; + +/** + * This class creates and manages an "Add" button panel. The class + * exposes the <tt>AddActionListener</tt> method to allow listening for events + * from the contained button. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class AddItemPanel extends JPanel +{ + private JButton theAddButton; + + /** + * Constructs the panel containing a single "Add" button. + * + */ + public AddItemPanel() + { + theAddButton = new JButton(IconUtilitities.getImageIcon("Forward16.gif")); //$NON-NLS-1$ + + this.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 1)); + Utility.setDescription(theAddButton, + PropertyFactory.getString("InfoTabs.AddButton.Description")); //$NON-NLS-1$ + theAddButton.setEnabled(false); + theAddButton.setMargin(new Insets(1, 14, 1, 14)); + this.add(theAddButton); + } + + /** + * Enable or disable the button. + * + * @param yesNo <tt>true</tt> enables the button <tt>false</tt> disables it. + */ + @Override + public void setEnabled(final boolean yesNo) + { + theAddButton.setEnabled(yesNo); + } + + /** + * Add a listener to the contained button. + * + * @param aListener The listener to add. + */ + public void addActionListener(final ActionListener aListener) + { + theAddButton.addActionListener( aListener ); + } +} + Property changes on: Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/AddItemPanel.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/FilterPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/FilterPanel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/FilterPanel.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,209 @@ +/* + * FilterPanel.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package pcgen.gui.tabs.components; + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +import pcgen.gui.tabs.IFilterableView; +import pcgen.gui.utils.JComboBoxEx; +import pcgen.gui.utils.Utility; +import pcgen.util.PropertyFactory; + +/** + * This class implements a panel containing a View Choice combo and Quick Filter + * edit box. + * + * <p>The class communicates information about the state of the filters through + * the <code>IFilterableView</code> interface. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class FilterPanel extends JPanel +{ + private IFilterableView theView; + + private int theViewIndex = 0; + + private JComboBoxEx theViewComboBox; + private JTextField theFilterText; + private JButton theClearButton; + + /** + * Constructs the <tt>FilterPanel</tt> object. + * + * @param aView An IFilterableView to receive notification of filter events. + * @param aLabel The label text to use for the View Choice combo. This is + * usually either Available or Selected. + */ + public FilterPanel(final IFilterableView aView, final String aLabel) + { + theView = aView; + + // TODO - GridBag is probably overkill for this simple panel but this + // is how it was done and I don't feel like breaking it now. + setLayout(new GridBagLayout()); + GridBagConstraints c = new GridBagConstraints(); + + int i = 0; + + // -------------------------------------------------------- + // Label for combo + // -------------------------------------------------------- + final JLabel treeLabel = new JLabel(aLabel); + Utility.buildConstraints(c, i++, 0, 1, 1, 0, 0); + c.insets = new Insets(1, 2, 1, 2); + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + add(treeLabel, c); + + // -------------------------------------------------------- + // View Combo + // -------------------------------------------------------- + theViewComboBox = new JComboBoxEx(); + theViewComboBox.addActionListener(new ActionListener() + { + /** + * This method is called when the combobox is changed. If the new + * selected index is different from the existing one, the listener + * will be told of the change. + */ + public void actionPerformed(@SuppressWarnings("unused")ActionEvent evt) + { + final int index = theViewComboBox.getSelectedIndex(); + if ( theViewIndex != index ) + { + theViewIndex = index; + theView.viewChanged(theViewIndex); + } + } + }); + for ( final String choice : aView.getViewChoices() ) + { + theViewComboBox.addItem(choice); + } + Utility.setDescription(theViewComboBox, + PropertyFactory.getString("InfoTabs.ViewCombo.Description")); //$NON-NLS-1$ + + theViewComboBox.setSelectedIndex(aView.getInitialChoice()); + + Utility.buildConstraints(c, i++, 0, 1, 1, 0, 0); + c.insets = new Insets(1, 2, 1, 2); + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + add(theViewComboBox, c); + + // -------------------------------------------------------- + // Filter Label + // -------------------------------------------------------- + final JLabel filterLabel = new JLabel(PropertyFactory.getString("InfoTabs.FilterLabel")); //$NON-NLS-1$ + Utility.buildConstraints(c, i++, 0, 1, 1, 0, 0); + c.insets = new Insets(1, 2, 1, 2); + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + add(filterLabel, c); + + + // -------------------------------------------------------- + // Filter text field + // -------------------------------------------------------- + theFilterText = new JTextField(); + theFilterText.getDocument().addDocumentListener(new DocumentListener() + { + public void changedUpdate(@SuppressWarnings("unused") + DocumentEvent evt) + { + setQFilter(); + } + public void insertUpdate(@SuppressWarnings("unused") + DocumentEvent evt) + { + setQFilter(); + } + public void removeUpdate(@SuppressWarnings("unused") + DocumentEvent evt) + { + setQFilter(); + } + }); + Utility.buildConstraints(c, i++, 0, 1, 1, 95, 0); + c.insets = new Insets(1, 2, 1, 2); + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.LINE_START; + add(theFilterText, c); + + // -------------------------------------------------------- + // Clear filter button + // -------------------------------------------------------- + theClearButton = new JButton(PropertyFactory.getString("in_clear")); //$NON-NLS-1$ + theClearButton.addActionListener(new ActionListener() + { + public void actionPerformed(@SuppressWarnings("unused") + ActionEvent evt) + { + clearQFilter(); + } + }); + Utility.buildConstraints(c, i++, 0, 1, 1, 0, 0); + c.insets = new Insets(0, 2, 0, 2); + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + theClearButton.setEnabled(false); + add(theClearButton, c); + } + + private void setQFilter() + { + final String filter = theFilterText.getText(); + if (filter.length() == 0) + { + clearQFilter(); + return; + } + theView.setQFilter(filter); + theClearButton.setEnabled(true); + theViewComboBox.setEnabled(false); + + } + + private void clearQFilter() + { + theClearButton.setEnabled(false); + theViewComboBox.setEnabled(true); + theFilterText.setText(null); + + theView.clearQFilter(); + } +} Property changes on: Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/FilterPanel.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/RemoveItemPanel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/RemoveItemPanel.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/RemoveItemPanel.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,86 @@ +/* + * RemoveItemPanel.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package pcgen.gui.tabs.components; + +import java.awt.FlowLayout; +import java.awt.Insets; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JPanel; + +import pcgen.gui.utils.IconUtilitities; +import pcgen.gui.utils.Utility; +import pcgen.util.PropertyFactory; + +/** + * This class creates and manages a "Remove" button panel. The class + * exposes the <tt>AddActionListener</tt> method to allow listening for events + * from the contained button. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class RemoveItemPanel extends JPanel +{ + private JButton theRemoveButton; + + /** + * Constructs the panel containing a single "Remove" button. + * + */ + public RemoveItemPanel() + { + theRemoveButton = new JButton(IconUtilitities.getImageIcon("Back16.gif")); //$NON-NLS-1$ + + this.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 1)); + Utility.setDescription(theRemoveButton, + PropertyFactory.getString("InfoTabs.RemoveButton.Description")); //$NON-NLS-1$ + theRemoveButton.setEnabled(false); + theRemoveButton.setMargin(new Insets(1, 14, 1, 14)); + this.add(theRemoveButton); + } + + /** + * Enable or disable the button. + * + * @param yesNo <tt>true</tt> enables the button <tt>false</tt> disables it. + */ + @Override + public void setEnabled(final boolean yesNo) + { + theRemoveButton.setEnabled(yesNo); + } + + /** + * Add a listener to the contained button. + * + * @param aListener The listener to add. + */ + public void addActionListener(final ActionListener aListener) + { + theRemoveButton.addActionListener( aListener ); + } +} + Property changes on: Trunk/pcgen/code/src/java/pcgen/gui/tabs/components/RemoveItemPanel.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoPreparedSpells.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoPreparedSpells.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoPreparedSpells.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -227,7 +227,7 @@ // get the list of metamagic feats for the PC characterMetaMagicFeats.clear(); List<Ability> feats = pc.aggregateFeatList(); - Globals.sortPObjectList(feats); + Globals.sortPObjectListByName(feats); for (Ability aFeat : feats) { Modified: Trunk/pcgen/code/src/java/pcgen/gui/utils/JTreeTable.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/utils/JTreeTable.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/utils/JTreeTable.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -1108,54 +1108,54 @@ theTree = treeTable.getTree(); theMenu = aMenu; - KeyListener myKeyListener = new KeyListener() - { - public void keyTyped(KeyEvent e) - { - dispatchEvent(e); - } - - // Walk through the list of accelerators - // to see if the user has pressed a sequence - // used by the popup. This would not - // happen unless the popup was showing - // - public void keyPressed(KeyEvent e) - { - final int keyCode = e.getKeyCode(); - - if (keyCode != KeyEvent.VK_UNDEFINED) - { - final KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(e); - - for (int i = 0; i < theMenu.getComponentCount(); ++i) - { - final Component menuComponent = theMenu.getComponent(i); - - if (menuComponent instanceof JMenuItem) - { - KeyStroke ks = ((JMenuItem) menuComponent).getAccelerator(); - - if ((ks != null) && keyStroke.equals(ks)) - { - ((JMenuItem) menuComponent).doClick(2); - - return; - } - } - } - } - - dispatchEvent(e); - } - - public void keyReleased(KeyEvent e) - { - dispatchEvent(e); - } - }; - - treeTable.addKeyListener(myKeyListener); +// KeyListener myKeyListener = new KeyListener() +// { +// public void keyTyped(KeyEvent e) +// { +// dispatchEvent(e); +// } +// +// // Walk through the list of accelerators +// // to see if the user has pressed a sequence +// // used by the popup. This would not +// // happen unless the popup was showing +// // +// public void keyPressed(KeyEvent e) +// { +// final int keyCode = e.getKeyCode(); +// +// if (keyCode != KeyEvent.VK_UNDEFINED) +// { +// final KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(e); +// +// for (int i = 0; i < theMenu.getComponentCount(); ++i) +// { +// final Component menuComponent = theMenu.getComponent(i); +// +// if (menuComponent instanceof JMenuItem) +// { +// KeyStroke ks = ((JMenuItem) menuComponent).getAccelerator(); +// +// if ((ks != null) && keyStroke.equals(ks)) +// { +// ((JMenuItem) menuComponent).doClick(2); +// +// return; +// } +// } +// } +// } +// +// dispatchEvent(e); +// } +// +// public void keyReleased(KeyEvent e) +// { +// dispatchEvent(e); +// } +// }; +// +// treeTable.addKeyListener(myKeyListener); } /** Modified: Trunk/pcgen/code/src/java/pcgen/gui/utils/PObjectNode.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/utils/PObjectNode.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/gui/utils/PObjectNode.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -71,6 +71,8 @@ private int checkFeatState = NOT_A_FEAT; // feat tab private String displayName = null; + private int theColor = -1; + // All this is for free when we get rid of PObjectNode[] for a // Collection. XXX private int mark = 0; @@ -553,6 +555,11 @@ throw new UnsupportedOperationException(); } + public void setColor(final int aColor) + { + theColor = aColor; + } + public String toString() { if (item == null) @@ -572,19 +579,24 @@ itemName = displayName; } + if ( theColor != -1 ) + { + return Constants.PIPE + theColor + Constants.PIPE + itemName; + + } if (checkFeatState != NOT_A_FEAT) { final Ability aFeat = (Ability) item; switch (aFeat.getFeatType()) { - case Ability.ABILITY_NORMAL: + case NORMAL: return handleCheckFeatState(aFeat, itemName); - case Ability.ABILITY_AUTOMATIC: + case AUTOMATIC: return "|" + SettingsHandler.getFeatAutoColor() + "|" + itemName; - case Ability.ABILITY_VIRTUAL: + case VIRTUAL: return "|" + SettingsHandler.getFeatVirtualColor() + "|" + itemName; default: Modified: Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatListToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatListToken.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatListToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -77,7 +77,7 @@ typeStr = aString.substring(dotpos); } - Globals.sortPObjectList(featList); + Globals.sortPObjectListByName(featList); for (Ability aFeat : featList) { Modified: Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatToken.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/io/exporttoken/FeatToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -118,7 +118,7 @@ List<Ability> aList = new ArrayList<Ability>(); - Globals.sortPObjectList(feat); + Globals.sortPObjectListByName(feat); for (Ability aFeat : feat) { Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/AbilityCategoryLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/AbilityCategoryLoader.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/AbilityCategoryLoader.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,123 @@ +/* + * AbilityCategoryLoader.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package pcgen.persistence.lst; + +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.AbilityCategory; +import pcgen.core.Constants; +import pcgen.core.GameMode; +import pcgen.core.character.WieldCategory; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.SystemLoader; +import pcgen.util.Logging; +import pcgen.util.PropertyFactory; + +/** + * This class handles parsing the whole ABILITYCATEGORY line and passing each + * token to the correct parser. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class AbilityCategoryLoader +{ + /** + * Default Constructor + */ + public AbilityCategoryLoader() + { + // Nothing to do. + } + + /** + * Parse the ABILITYCATEGORY line. + * + * @param aGameMode The <tt>GameMode</tt> this object belongs to. + * @param aLine The line to parse + * + * @throws PersistenceLayerException + */ + public void parseLine(final GameMode aGameMode, final String aLine) + throws PersistenceLayerException + { + final StringTokenizer colToken = new StringTokenizer(aLine, SystemLoader.TAB_DELIM); + + // Get all the tokens for this tag (all classes implementing the + // AbilityCategoryLstToken interface. + final Map<String, LstToken> tokenMap = TokenStore.inst().getTokenMap(AbilityCategoryLstToken.class); + + AbilityCategory cat = null; + while ( colToken.hasMoreTokens() ) + { + final String colString = colToken.nextToken().trim(); + final int idxColon = colString.indexOf(':'); + final String key; + try + { + key = colString.substring(0, idxColon); + } + catch(StringIndexOutOfBoundsException e) + { + throw new PersistenceLayerException( + PropertyFactory.getFormattedString( + "Errors.LstTokens.InvalidTokenFormat", //$NON-NLS-1$ + getClass().toString(), + colString)); + } + + final AbilityCategoryLstToken token = (AbilityCategoryLstToken) tokenMap.get(key); + + if (key.equals("ABILITYCATEGORY")) //$NON-NLS-1$ + { + final String value = colString.substring(idxColon + 1).trim(); + cat = aGameMode.getAbilityCategory(value); + + if (cat == null) + { + cat = new AbilityCategory(value); + aGameMode.addAbilityCategory(cat); + } + } + else if (token != null) + { + final String value = colString.substring(idxColon + 1).trim(); + // TODO - i18n + LstUtils.deprecationCheck(token, "Ability Category", "miscinfo.lst from the " + aGameMode.getName() + " Game Mode", value); + if (!token.parse(cat, value)) + { + // TODO - i18n + Logging.errorPrint("Error parsing ability category:" + "miscinfo.lst from the " + aGameMode.getName() + " Game Mode" + ':' + colString + "\""); + } + } + else + { + // TODO - i18n + Logging.errorPrint("Invalid sub tag " + key + " on ABILITYCATEGORY line"); + throw new PersistenceLayerException("Invalid sub tag " + key + " on ABILITYCATEGORY line"); + } + } + } +} Property changes on: Trunk/pcgen/code/src/java/pcgen/persistence/lst/AbilityCategoryLoader.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/AbilityCategoryLstToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/AbilityCategoryLstToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/AbilityCategoryLstToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,45 @@ +/* + * AbilityCategoryLstToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package pcgen.persistence.lst; + +import pcgen.core.AbilityCategory; + +/** + * Interface for tokens that parse ABILITYCATEGORY line items. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public interface AbilityCategoryLstToken extends LstToken +{ + /** + * Parse an ABILITYCATEGORY token. + * + * @param aCat The AbilityCategory object we are building + * @param aValue The token text + * + * @return <tt>true</tt> if the token is valid. + */ + public abstract boolean parse(final AbilityCategory aCat, final String aValue); +} Property changes on: Trunk/pcgen/code/src/java/pcgen/persistence/lst/AbilityCategoryLstToken.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstSystemLoader.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -342,7 +342,7 @@ // Now that those are loaded, make sure to initialize the recursive campaigns campaignLoader.initRecursivePccFiles(); - Globals.sortPObjectList(Globals.getCampaignList()); + Globals.sortPObjectListByName(Globals.getCampaignList()); } /** Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/RaceLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/RaceLoader.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/RaceLoader.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -148,7 +148,7 @@ @Override protected void performForget( final PObject objToForget ) { - Globals.getRaceMap().remove(objToForget.getKeyName()); + Globals.removeRaceKeyed(objToForget.getKeyName()); } /** @@ -157,7 +157,6 @@ @Override protected void addGlobalObject( final PObject pObj ) { - // TODO - Create Globals.addRace( final Race aRace ); - Globals.getRaceMap().put( pObj.getKeyName(), (Race)pObj ); + Globals.addRace( (Race)pObj ); } } Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/TokenStore.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -69,6 +69,7 @@ //miscinfo.lst tokenTypeList.add(GameModeLstToken.class); + tokenTypeList.add(AbilityCategoryLstToken.class); tokenTypeList.add(BaseDiceLstToken.class); tokenTypeList.add(EqSizePenaltyLstToken.class); tokenTypeList.add(RollMethodLstToken.class); Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/utils/FeatParser.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/utils/FeatParser.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/utils/FeatParser.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -77,13 +77,13 @@ { ArrayList<String> choices = new ArrayList<String>(); String abilityName = EquipmentUtilities.getUndecoratedName(aPart, choices); - Ability anAbility = AbilityUtilities.getAbilityFromList(aList, "FEAT", abilityName, -1); + Ability anAbility = AbilityUtilities.getAbilityFromList(aList, "FEAT", abilityName, Ability.Nature.ANY); if (anAbility == null) { anAbility = Globals.getAbilityKeyed("FEAT", abilityName); if (anAbility != null) { anAbility = (Ability) anAbility.clone(); - anAbility.setFeatType(Ability.ABILITY_VIRTUAL); + anAbility.setFeatType(Ability.Nature.VIRTUAL); anAbility.clearPreReq(); } } Modified: Trunk/pcgen/code/src/java/pcgen/util/DoubleKeyMap.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/util/DoubleKeyMap.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/util/DoubleKeyMap.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -26,6 +26,11 @@ super(); } + public DoubleKeyMap( final DoubleKeyMap<K1, K2, V> otherMap ) + { + map.putAll(otherMap.map); + } + /** * Put an object in a map * @param key1 @@ -108,6 +113,23 @@ } /** + * Gets a <tt>Set</tt> of the secondary keys for the given primary key. + * + * @param aPrimaryKey The primary key to retrieve keys for. + * + * @return A <tt>Set</tt> of secondary key objects. + */ + public Set<K2> getSecondaryKeySet(final K1 aPrimaryKey) + { + final Map<K2, V> localMap = map.get(aPrimaryKey); + if ( localMap == null ) + { + return Collections.emptySet(); + } + return localMap.keySet(); + } + + /** * Clear */ public void clear() Modified: Trunk/pcgen/code/src/java/pcgen/util/enumeration/Tab.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/util/enumeration/Tab.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/pcgen/util/enumeration/Tab.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -8,7 +8,7 @@ CLASSES("Class", "in_class" ), DESCRIPTION("Description", "in_descrip"), DOMAINS("Domains", "in_domains"), - ABILITIES("Feats", "InfoAbilities.Tab.Name"), + ABILITIES("Feats", "in_abilities"), INVENTORY("Inventory", "in_inventory"), RACE_MASTER("Race", "in_race"), SKILLS("Skills", "in_skills"), Modified: Trunk/pcgen/code/src/java/plugin/encounter/EncounterPlugin.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/encounter/EncounterPlugin.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/plugin/encounter/EncounterPlugin.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -760,7 +760,7 @@ } // populate critters with a list of matching monsters with the right CR. - for ( Race race : Globals.getRaceMap().values() ) + for ( final Race race : Globals.getAllRaces() ) { if (race.getCR() == crNum) { Modified: Trunk/pcgen/code/src/java/plugin/encounter/RaceModel.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/encounter/RaceModel.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/plugin/encounter/RaceModel.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -37,18 +37,16 @@ { clear(); - for (Iterator it = Globals.getRaceMap().values().iterator(); it.hasNext();) + for ( final Race race : Globals.getAllRaces() ) { - final Race aRace = (Race) it.next(); - //TODO: This is the original code. I took a wild guess at what the code was intended to do, and added braces. // if (!contains(aRace.toString())); // this.addElement(aRace.toString()); // this.removeElement(Globals.getRaceMap().get(Constants.s_NONESELECTED).toString()); - if (!contains(aRace.toString())) + if (!contains(race.toString())) { - this.addElement(aRace.toString()); - this.removeElement(Globals.getRaceMap().get(Constants.s_NONESELECTED).toString()); + this.addElement(race.toString()); + this.removeElement(Globals.s_EMPTYRACE.toString()); } } } Added: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/AbilityCategoryToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/AbilityCategoryToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/AbilityCategoryToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,73 @@ +/* + * AbilityCategoryToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package plugin.lsttokens.gamemode; + +import pcgen.core.GameMode; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.lst.AbilityCategoryLoader; +import pcgen.persistence.lst.GameModeLstToken; +import pcgen.util.Logging; + +/** + * This class handles the ABILITYCATEGORY game mode token. + * + * <p>The class deligates the loading of the various subtokens to a separate + * loader. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class AbilityCategoryToken implements GameModeLstToken +{ + + /** + * + * @see pcgen.persistence.lst.GameModeLstToken#parse(pcgen.core.GameMode, java.lang.String) + */ + public boolean parse(final GameMode aGameMode, final String aValue) + { + final AbilityCategoryLoader loader = new AbilityCategoryLoader(); + try + { + loader.parseLine(aGameMode, getTokenName() + ':' + aValue); + } + catch (PersistenceLayerException e) + { + Logging.errorPrint(e.getMessage()); + return false; + } + return true; + } + + /** + * Returns the name of the token this class handles. + * + * @see pcgen.persistence.lst.LstToken#getTokenName() + */ + public String getTokenName() + { + return "ABILITYCATEGORY"; //$NON-NLS-1$ + } + +} Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/AbilityCategoryToken.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/CategoryToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/CategoryToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/CategoryToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,54 @@ +/* + * CategoryToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package plugin.lsttokens.gamemode.abilitycategory; + +import pcgen.core.AbilityCategory; +import pcgen.persistence.lst.AbilityCategoryLstToken; + +/** + * Handles the CATEGORY token on an ABILITYCATEGORY line. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class CategoryToken implements AbilityCategoryLstToken +{ + + /** + * @see pcgen.persistence.lst.AbilityCategoryLstToken#parse(pcgen.core.AbilityCategory, java.lang.String) + */ + public boolean parse(final AbilityCategory aCat, final String aValue) + { + aCat.setAbilityCategory(aValue); + return true; + } + + /** + * @see pcgen.persistence.lst.LstToken#getTokenName() + */ + public String getTokenName() + { + return "CATEGORY"; //$NON-NLS-1$ + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/CategoryToken.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/DisplayNameToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/DisplayNameToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/DisplayNameToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,54 @@ +/* + * DisplayNameToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package plugin.lsttokens.gamemode.abilitycategory; + +import pcgen.core.AbilityCategory; +import pcgen.persistence.lst.AbilityCategoryLstToken; + +/** + * Handles the DISPLAYNAME token on an ABILITYCATEGORY line. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class DisplayNameToken implements AbilityCategoryLstToken +{ + + /** + * @see pcgen.persistence.lst.AbilityCategoryLstToken#parse(pcgen.core.AbilityCategory, java.lang.String) + */ + public boolean parse(final AbilityCategory aCat, final String aValue) + { + aCat.setName(aValue); + return true; + } + + /** + * @see pcgen.persistence.lst.LstToken#getTokenName() + */ + public String getTokenName() + { + return "DISPLAYNAME"; //$NON-NLS-1$ + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/DisplayNameToken.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/EditPoolToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/EditPoolToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/EditPoolToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,64 @@ +/* + * EditPoolToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package plugin.lsttokens.gamemode.abilitycategory; + +import pcgen.core.AbilityCategory; +import pcgen.persistence.lst.AbilityCategoryLstToken; + +/** + * Handles the EDITPOOL token on an ABILITYCATEGORY line. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class EditPoolToken implements AbilityCategoryLstToken +{ + /** + * @see pcgen.persistence.lst.AbilityCategoryLstToken#parse(pcgen.core.AbilityCategory, java.lang.String) + */ + public boolean parse(final AbilityCategory aCat, final String aValue) + { + if ( aValue.charAt(0) == 'Y' ) + { + aCat.setModPool(true); + } + else if ( aValue.charAt(0) == 'N' ) + { + aCat.setModPool(false); + } + else + { + return false; + } + return true; + } + + /** + * @see pcgen.persistence.lst.LstToken#getTokenName() + */ + public String getTokenName() + { + return "EDITPOOL"; //$NON-NLS-1$ + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/EditPoolToken.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/EditableToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/EditableToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/EditableToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,64 @@ +/* + * EditableToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package plugin.lsttokens.gamemode.abilitycategory; + +import pcgen.core.AbilityCategory; +import pcgen.persistence.lst.AbilityCategoryLstToken; + +/** + * Handles the EDITABLE token on an ABILITYCATEGORY line. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class EditableToken implements AbilityCategoryLstToken +{ + /** + * @see pcgen.persistence.lst.AbilityCategoryLstToken#parse(pcgen.core.AbilityCategory, java.lang.String) + */ + public boolean parse(final AbilityCategory aCat, final String aValue) + { + if ( aValue.charAt(0) == 'Y' ) + { + aCat.setEditable(true); + } + else if ( aValue.charAt(0) == 'N' ) + { + aCat.setEditable(false); + } + else + { + return false; + } + return true; + } + + /** + * @see pcgen.persistence.lst.LstToken#getTokenName() + */ + public String getTokenName() + { + return "EDITABLE"; //$NON-NLS-1$ + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/EditableToken.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/FractionalPoolToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/FractionalPoolToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/FractionalPoolToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,64 @@ +/* + * FractionalPoolToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package plugin.lsttokens.gamemode.abilitycategory; + +import pcgen.core.AbilityCategory; +import pcgen.persistence.lst.AbilityCategoryLstToken; + +/** + * Handles the FRACTIONALPOOL token on an ABILITYCATEGORY line. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class FractionalPoolToken implements AbilityCategoryLstToken +{ + /** + * @see pcgen.persistence.lst.AbilityCategoryLstToken#parse(pcgen.core.AbilityCategory, java.lang.String) + */ + public boolean parse(final AbilityCategory aCat, final String aValue) + { + if ( aValue.charAt(0) == 'Y' ) + { + aCat.setAllowFractionalPool(true); + } + else if ( aValue.charAt(0) == 'N' ) + { + aCat.setAllowFractionalPool(false); + } + else + { + return false; + } + return true; + } + + /** + * @see pcgen.persistence.lst.LstToken#getTokenName() + */ + public String getTokenName() + { + return "FRACTIONALPOOL"; //$NON-NLS-1$ + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/FractionalPoolToken.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/PluralToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/PluralToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/PluralToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,54 @@ +/* + * PluralToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package plugin.lsttokens.gamemode.abilitycategory; + +import pcgen.core.AbilityCategory; +import pcgen.persistence.lst.AbilityCategoryLstToken; + +/** + * Handles the PLURAL token on an ABILITYCATEGORY line. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class PluralToken implements AbilityCategoryLstToken +{ + /** + * @see pcgen.persistence.lst.AbilityCategoryLstToken#parse(pcgen.core.AbilityCategory, java.lang.String) + */ + public boolean parse(final AbilityCategory aCat, final String aValue) + { + // TODO - Should allow for a string in an external file. Resource file? + aCat.setPluralName(aValue); + return true; + } + + /** + * @see pcgen.persistence.lst.LstToken#getTokenName() + */ + public String getTokenName() + { + return "PLURAL"; //$NON-NLS-1$ + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/PluralToken.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/PoolToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/PoolToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/PoolToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,56 @@ +/* + * PoolToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package plugin.lsttokens.gamemode.abilitycategory; + +import pcgen.core.AbilityCategory; +import pcgen.persistence.lst.AbilityCategoryLstToken; + +/** + * Handles the POOL token on an ABILITYCATEGORY line. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class PoolToken implements AbilityCategoryLstToken +{ + + /** + * @see pcgen.persistence.lst.AbilityCategoryLstToken#parse(pcgen.core.AbilityCategory, java.lang.String) + */ + public boolean parse(final AbilityCategory aCat, final String aValue) + { + // TODO - Add a validate() method to VariableProcessor + aCat.setPoolFormula(aValue); + return true; + } + + /** + * @see pcgen.persistence.lst.LstToken#getTokenName() + */ + public String getTokenName() + { + return "POOL"; //$NON-NLS-1$ + } + +} Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/PoolToken.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/TypeToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/TypeToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/TypeToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,60 @@ +/* + * TypeToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package plugin.lsttokens.gamemode.abilitycategory; + +import java.util.StringTokenizer; + +import pcgen.core.AbilityCategory; +import pcgen.persistence.lst.AbilityCategoryLstToken; + +/** + * Handles the TYPE token on an ABILITYCATEGORY line. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class TypeToken implements AbilityCategoryLstToken +{ + + /** + * @see pcgen.persistence.lst.AbilityCategoryLstToken#parse(pcgen.core.AbilityCategory, java.lang.String) + */ + public boolean parse(final AbilityCategory aCat, final String aValue) + { + final StringTokenizer tok = new StringTokenizer(aValue, "."); //$NON-NLS-1$ + while (tok.hasMoreTokens()) + { + aCat.addAbilityType(tok.nextToken()); + } + return true; + } + + /** + * @see pcgen.persistence.lst.LstToken#getTokenName() + */ + public String getTokenName() + { + return "TYPE"; //$NON-NLS-1$ + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/TypeToken.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/VisibleToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/VisibleToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/VisibleToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -0,0 +1,65 @@ +/* + * VisibleToken.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package plugin.lsttokens.gamemode.abilitycategory; + +import pcgen.core.AbilityCategory; +import pcgen.persistence.lst.AbilityCategoryLstToken; + +/** + * Handles the VISIBLE token on an ABILITYCATEGORY line. + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public class VisibleToken implements AbilityCategoryLstToken +{ + /** + * @see pcgen.persistence.lst.AbilityCategoryLstToken#parse(pcgen.core.AbilityCategory, java.lang.String) + */ + public boolean parse(final AbilityCategory aCat, final String aValue) + { + if ( aValue.charAt(0) == 'Y' ) + { + aCat.setVisible(true); + } + else if ( aValue.charAt(0) == 'N' ) + { + aCat.setVisible(false); + } + else + { + return false; + } + return true; + } + + /** + * @see pcgen.persistence.lst.LstToken#getTokenName() + */ + public String getTokenName() + { + return "VISIBLE"; //$NON-NLS-1$ + } + +} Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/gamemode/abilitycategory/VisibleToken.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelToken.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/LevelToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -1,5 +1,7 @@ package plugin.lsttokens.template; +import java.util.StringTokenizer; + import pcgen.core.PCTemplate; import pcgen.persistence.lst.PCTemplateLstToken; @@ -13,8 +15,29 @@ return "LEVEL"; } - public boolean parse(PCTemplate template, String value) { - template.addLevelString(value); + public boolean parse(PCTemplate template, String value) + { + if (".CLEAR".equals(value)) + { + template.clearLevelAbilities(); + return true; + } + + final StringTokenizer tok = new StringTokenizer(value, ":"); + final String levelStr = tok.nextToken(); + final int level; + try + { + level = Integer.parseInt(levelStr); + } + catch (NumberFormatException ex) + { + // TODO - Add error message. + return false; + } + final String typeStr = tok.nextToken(); + + template.addLevelAbility(level, typeStr, tok.nextToken()); return true; } } Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/template/RepeatlevelToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/template/RepeatlevelToken.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/template/RepeatlevelToken.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -36,8 +36,10 @@ int count = consecutive; for(; iLevel <= maxLevel; iLevel += lvlIncrement) { if ((consecutive == 0) || (count != 0)) { - template.addLevelString(Integer.toString(iLevel) + ":" + - value.substring(endLevel + 1)); + final StringTokenizer tok = new StringTokenizer(value.substring(endLevel + 1)); + final String type = tok.nextToken(); + + template.addLevelAbility(iLevel, type, tok.nextToken()); } if (consecutive != 0) { if (count == 0) { Modified: Trunk/pcgen/code/src/test/pcgen/core/PCClassTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/PCClassTest.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/test/pcgen/core/PCClassTest.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -29,7 +29,6 @@ package pcgen.core; import java.util.List; -import java.util.Map; import java.util.StringTokenizer; import junit.framework.Test; @@ -47,6 +46,7 @@ /** * @author wardc */ +@SuppressWarnings("nls") public class PCClassTest extends AbstractCharacterTestCase { PCClass humanoidClass; @@ -323,7 +323,7 @@ assertEquals("All spell should have been reconstituted.", startSpells.size(), reconstSpells.size()); assertEquals("Spell names should been preserved.", - ((PCSpell)startSpells.get(0)).getKeyName(), ((PCSpell)reconstSpells.get(0)).getKeyName()); + startSpells.get(0).getKeyName(), reconstSpells.get(0).getKeyName()); } @@ -451,12 +451,15 @@ bugbearRace.setSize("M"); bugbearRace.setAdvancementUnlimited(true); bugbearRace.setInitialSkillMultiplier(1); + Globals.addRace(bugbearRace); + bigBugbearRace = new Race(); bigBugbearRace.setName("BigBugbear"); bigBugbearRace.setKeyName("KEY_BigBugbear"); bigBugbearRace.setSize("L"); bigBugbearRace.setAdvancementUnlimited(true); bigBugbearRace.setInitialSkillMultiplier(1); + Globals.addRace(bigBugbearRace); // Create the Nymph race nymphRace = new Race(); @@ -464,12 +467,8 @@ nymphRace.setKeyName("KEY_Nymph"); nymphRace.setSize("M"); nymphRace.setAdvancementUnlimited(true); + Globals.addRace(nymphRace); - final Map<String, Race> raceMap = Globals.getRaceMap(); - raceMap.put("KEY_Bugbear", bugbearRace); - raceMap.put("KEY_BigBugbear", bigBugbearRace); - raceMap.put("KEY_Nymph", nymphRace); - // Setup class with prereqs and var based abilities with prereqs. PreVariableParser parser = new PreVariableParser(); prereq = parser.parse("VARGTEQ", "Foo,1", false, Modified: Trunk/pcgen/code/src/test/pcgen/core/PlayerCharacterTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/PlayerCharacterTest.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/test/pcgen/core/PlayerCharacterTest.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -56,6 +56,7 @@ * @author wardc * */ +@SuppressWarnings("nls") public class PlayerCharacterTest extends AbstractCharacterTestCase { Race giantRace = null; PCClass giantClass = null; @@ -76,106 +77,6 @@ return new TestSuite(PlayerCharacterTest.class); } - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception - { - super.setUp(); - final PreParserFactory factory = PreParserFactory.getInstance(); - - // Human - human = new Race(); - final BonusObj humanRaceFeatBonus = Bonus.newBonus("FEAT|POOL|2"); - final StringBuffer buf = new StringBuffer(); - - buf.append("PREMULT:1,[PREDEFAULTMONSTER:N],[!PREHD:1]"); - - final Prerequisite humanFeatPrereq = factory.parse(buf.toString()); - - humanRaceFeatBonus.addPreReq(humanFeatPrereq); - human.setBonusInitialFeats(humanRaceFeatBonus); - - - // Giant Race - giantRace = new Race(); - giantRace.setName("Ogre"); - giantRace.setMonsterClass("Giant"); - giantRace.setMonsterClassLevels(4); - giantRace.setHitDiceAdvancement(new int[] {100}); - final BonusObj babBonus = Bonus.newBonus("COMBAT|BAB|3|PREDEFAULTMONSTER:Y|TYPE=Base.REPLACE"); - giantRace.addBonusList(babBonus); - - final BonusObj giantRaceFeatBonus = Bonus.newBonus("FEAT|POOL|1"); - final Prerequisite giantFeatPrereq = factory.parse(buf.toString()); - giantRaceFeatBonus.addPreReq(giantFeatPrereq); - - giantRace.setBonusInitialFeats(giantRaceFeatBonus); - - Globals.getRaceMap().put("Ogre", giantRace); - - // Giant Class - giantClass = new PCClass(); - giantClass.setName("Giant"); - giantClass.setAbbrev("Gnt"); - giantClass.addMyType("MONSTER"); - final BonusObj babClassBonus = Bonus.newBonus("1|COMBAT|BAB|CL*3/4"); - giantClass.addBonusList(babClassBonus); - giantClass.setLevelsPerFeat(new Integer(4)); - Globals.getClassList().add(giantClass); - - - pcClass = new PCClass(); - pcClass.setName("MyClass"); - pcClass.setAbbrev("My"); - pcClass.setSpellType("ARCANE"); - Globals.getClassList().add(pcClass); - - classWarmind = new PCClass(); - classWarmind.setName("Warmind"); - classWarmind.setAbbrev("WM"); - Globals.getClassList().add(classWarmind); - - Ability toughness = new Ability(); - toughness.setName("Toughness"); - toughness.setMultiples("Y"); - toughness.setStacks("Y"); - toughness.setChoiceString("NOCHOICE"); - toughness.setCategory("FEAT"); - Globals.addAbility(toughness); - - Ability exoticWpnProf = TestHelper.makeAbility("Exotic Weapon Proficiency", "FEAT", "General.Fighter"); - exoticWpnProf.setMultiples("YES"); - exoticWpnProf.setChoiceString("CHOOSE:PROFICIENCY|WEAPON|UNIQUE|TYPE.Exotic"); - exoticWpnProf.addAutoArray("WEAPONPROF|%LIST"); - - WeaponProf wpnProfTestA = new WeaponProf(); - wpnProfTestA.setName("Weapon A"); - wpnProfTestA.setKeyName("Weapon A"); - wpnProfTestA.setTypeInfo("Exotic"); - Globals.addWeaponProf(wpnProfTestA); - - WeaponProf wpnProfTestB = new WeaponProf(); - wpnProfTestB.setName("Weapon B"); - wpnProfTestB.setKeyName("Weapon B"); - wpnProfTestB.setTypeInfo("Exotic"); - Globals.addWeaponProf(wpnProfTestB); - - WeaponProf wpnProfTestC = new WeaponProf(); - wpnProfTestC.setName("Weapon C"); - wpnProfTestC.setKeyName("Weapon C"); - wpnProfTestC.setTypeInfo("Exotic"); - Globals.addWeaponProf(wpnProfTestC); - - - SettingsHandler .setSingleChoicePreference(Constants.CHOOSER_SINGLECHOICEMETHOD_SELECTEXIT); - ChooserFactory.setInterfaceClassname(SwingChooser.class.getName()); - - pcClass.addAddList(1, "FEAT(KEY_Exotic Weapon Proficiency (Weapon A))"); - pcClass.addAddList(2, "FEAT(KEY_Exotic Weapon Proficiency (Weapon B))"); - pcClass.addAddList(3, "FEAT(KEY_Exotic Weapon Proficiency (Weapon C))"); - } - /** * @throws Exception */ @@ -471,6 +372,107 @@ assertTrue("Proficient in Weapon B", character.hasWeaponProfKeyed("Weapon B")); assertTrue("Proficient in Weapon C", character.hasWeaponProfKeyed("Weapon C")); } + + /** + * @see junit.framework.TestCase#setUp() + */ + @Override + protected void setUp() throws Exception + { + super.setUp(); + + final PreParserFactory factory = PreParserFactory.getInstance(); + + // Human + human = new Race(); + final BonusObj humanRaceFeatBonus = Bonus.newBonus("FEAT|POOL|2"); + final StringBuffer buf = new StringBuffer(); + + buf.append("PREMULT:1,[PREDEFAULTMONSTER:N],[!PREHD:1]"); + + final Prerequisite humanFeatPrereq = factory.parse(buf.toString()); + + humanRaceFeatBonus.addPreReq(humanFeatPrereq); + human.setBonusInitialFeats(humanRaceFeatBonus); + + // Giant Race + giantRace = new Race(); + giantRace.setName("Ogre"); + giantRace.setMonsterClass("Giant"); + giantRace.setMonsterClassLevels(4); + giantRace.setHitDiceAdvancement(new int[] {100}); + final BonusObj babBonus = Bonus.newBonus("COMBAT|BAB|3|PREDEFAULTMONSTER:Y|TYPE=Base.REPLACE"); + giantRace.addBonusList(babBonus); + + final BonusObj giantRaceFeatBonus = Bonus.newBonus("FEAT|POOL|1"); + final Prerequisite giantFeatPrereq = factory.parse(buf.toString()); + giantRaceFeatBonus.addPreReq(giantFeatPrereq); + + giantRace.setBonusInitialFeats(giantRaceFeatBonus); + + Globals.addRace(giantRace); + + // Giant Class + giantClass = new PCClass(); + giantClass.setName("Giant"); + giantClass.setAbbrev("Gnt"); + giantClass.addMyType("MONSTER"); + final BonusObj babClassBonus = Bonus.newBonus("1|COMBAT|BAB|CL*3/4"); + giantClass.addBonusList(babClassBonus); + Globals.getClassList().add(giantClass); + + + pcClass = new PCClass(); + pcClass.setName("MyClass"); + pcClass.setAbbrev("My"); + pcClass.setSpellType("ARCANE"); + Globals.getClassList().add(pcClass); + + classWarmind = new PCClass(); + classWarmind.setName("Warmind"); + classWarmind.setAbbrev("WM"); + Globals.getClassList().add(classWarmind); + + Ability toughness = new Ability(); + toughness.setName("Toughness"); + toughness.setMultiples("Y"); + toughness.setStacks("Y"); + toughness.setChoiceString("NOCHOICE"); + toughness.setCategory("FEAT"); + Globals.addAbility(toughness); + + Ability exoticWpnProf = TestHelper.makeAbility("Exotic Weapon Proficiency", "FEAT", "General.Fighter"); + exoticWpnProf.setMultiples("YES"); + exoticWpnProf.setChoiceString("CHOOSE:PROFICIENCY|WEAPON|UNIQUE|TYPE.Exotic"); + exoticWpnProf.addAutoArray("WEAPONPROF|%LIST"); + + WeaponProf wpnProfTestA = new WeaponProf(); + wpnProfTestA.setName("Weapon A"); + wpnProfTestA.setKeyName("Weapon A"); + wpnProfTestA.setTypeInfo("Exotic"); + Globals.addWeaponProf(wpnProfTestA); + + WeaponProf wpnProfTestB = new WeaponProf(); + wpnProfTestB.setName("Weapon B"); + wpnProfTestB.setKeyName("Weapon B"); + wpnProfTestB.setTypeInfo("Exotic"); + Globals.addWeaponProf(wpnProfTestB); + + WeaponProf wpnProfTestC = new WeaponProf(); + wpnProfTestC.setName("Weapon C"); + wpnProfTestC.setKeyName("Weapon C"); + wpnProfTestC.setTypeInfo("Exotic"); + Globals.addWeaponProf(wpnProfTestC); + + + SettingsHandler .setSingleChoicePreference(Constants.CHOOSER_SINGLECHOICEMETHOD_SELECTEXIT); + ChooserFactory.setInterfaceClassname(SwingChooser.class.getName()); + + pcClass.addAddList(1, "FEAT(KEY_Exotic Weapon Proficiency (Weapon A))"); + pcClass.addAddList(2, "FEAT(KEY_Exotic Weapon Proficiency (Weapon B))"); + pcClass.addAddList(3, "FEAT(KEY_Exotic Weapon Proficiency (Weapon C))"); + } + public void testGetClassVar() throws Exception { Logging.setDebugMode(true); Modified: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreBaseSizeTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/prereq/PreBaseSizeTest.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/test/pcgen/core/prereq/PreBaseSizeTest.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -21,18 +21,16 @@ */ package pcgen.core.prereq; -import java.util.Map; - import junit.framework.Test; import junit.framework.TestSuite; import pcgen.AbstractCharacterTestCase; import pcgen.core.Globals; +import pcgen.core.PCTemplate; import pcgen.core.PlayerCharacter; import pcgen.core.Race; -import pcgen.persistence.lst.prereq.PreParserFactory; -import pcgen.core.PCTemplate; import pcgen.core.bonus.Bonus; import pcgen.core.bonus.BonusObj; +import pcgen.persistence.lst.prereq.PreParserFactory; /** * <code>PreBaseSizeTest</code> tests that the PREBASESIZE tag is @@ -44,6 +42,7 @@ * @author Aaron Divinsky <boomer70@...> * @version $Revision$ */ +@SuppressWarnings("nls") public class PreBaseSizeTest extends AbstractCharacterTestCase { Race race = new Race(); @@ -221,8 +220,7 @@ race.setName("Human"); race.setSize("M"); - final Map<String, Race> raceMap = Globals.getRaceMap(); - raceMap.put("Human", race); + Globals.addRace(race); template.setTemplateSize("L"); } Modified: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreHDTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/prereq/PreHDTest.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/test/pcgen/core/prereq/PreHDTest.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -21,8 +21,6 @@ */ package pcgen.core.prereq; -import java.util.Map; - import junit.framework.Test; import junit.framework.TestSuite; import pcgen.AbstractCharacterTestCase; @@ -43,12 +41,17 @@ * @author Aaron Divinsky <boomer70@...> * @version $Revision$ */ +@SuppressWarnings("nls") public class PreHDTest extends AbstractCharacterTestCase { Race race = new Race(); Race race1 = new Race(); PCClass monClass = new PCClass(); + /** + * Main method. Runs the test. + * @param args + */ public static void main(final String[] args) { junit.swingui.TestRunner.run(PreHDTest.class); @@ -72,8 +75,7 @@ race.setName("Human"); race.setSize("M"); race.setHitDice(3); - final Map<String, Race> raceMap = Globals.getRaceMap(); - raceMap.put("Human", race); + Globals.addRace(race); final PlayerCharacter character = getCharacter(); character.setRace(race); @@ -127,8 +129,7 @@ race1.setSize("L"); race1.setMonsterClass("Humanoid"); race1.setMonsterClassLevels(3); - final Map<String, Race> raceMap = Globals.getRaceMap(); - raceMap.put("Bugbear", race1); + Globals.addRace(race1); SettingsHandler.setMonsterDefault(false); final PlayerCharacter character = new PlayerCharacter(); @@ -167,11 +168,4 @@ assertFalse("Character doesn't have 2 or less HD", PrereqHandler.passes(prereq, character, null)); } - - protected void setUp() - throws Exception - { - super.setUp(); - - } } Modified: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreRaceTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/prereq/PreRaceTest.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/test/pcgen/core/prereq/PreRaceTest.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -28,8 +28,6 @@ */ package pcgen.core.prereq; -import java.util.Map; - import junit.framework.Test; import junit.framework.TestSuite; import pcgen.AbstractCharacterTestCase; @@ -41,14 +39,21 @@ * @author wardc * */ +@SuppressWarnings("nls") public class PreRaceTest extends AbstractCharacterTestCase { + /** + * Runs the test. + * @param args + */ public static void main(final String[] args) { junit.swingui.TestRunner.run(PreRaceTest.class); } /** + * Returns a TestSuite consisting of all the tests in this class. + * * @return Test */ public static Test suite() @@ -57,6 +62,8 @@ } /** + * Test to ensure that we return false when races don't match. + * * @throws Exception */ public void testFail() throws Exception @@ -65,8 +72,7 @@ final Race race = new Race(); race.setName("Human"); - final Map<String, Race> raceMap = Globals.getRaceMap(); - raceMap.put("Human", race); + Globals.addRace(race); character.setRace(race); @@ -80,6 +86,8 @@ } /** + * Test to make sure we return false when race is equal but NOT is specificed. + * * @throws Exception */ public void testNeqFails() throws Exception @@ -88,8 +96,7 @@ final Race race = new Race(); race.setName("Human"); - final Map<String, Race> raceMap = Globals.getRaceMap(); - raceMap.put("Human", race); + Globals.addRace(race); character.setRace(race); @@ -103,6 +110,8 @@ } /** + * Test to make sure that NOT returns true if races don't match. + * * @throws Exception */ public void testNeqPasses() throws Exception @@ -111,8 +120,7 @@ final Race race = new Race(); race.setName("Human"); - final Map<String, Race> raceMap = Globals.getRaceMap(); - raceMap.put("Human", race); + Globals.addRace(race); character.setRace(race); @@ -126,6 +134,8 @@ } /** + * Test to make sure that we return true when races are equal. + * * @throws Exception */ public void testPass() throws Exception @@ -134,8 +144,7 @@ final Race race = new Race(); race.setName("Human"); - final Map<String, Race> raceMap = Globals.getRaceMap(); - raceMap.put("Human", race); + Globals.addRace(race); character.setRace(race); Modified: Trunk/pcgen/code/src/test/pcgen/util/TestHelper.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/util/TestHelper.java 2006-09-12 02:15:39 UTC (rev 1383) +++ Trunk/pcgen/code/src/test/pcgen/util/TestHelper.java 2006-09-12 04:29:17 UTC (rev 1384) @@ -24,15 +24,13 @@ package pcgen.util; -import java.lang.String; -import java.net.URL; -import java.util.StringTokenizer; +import gmgen.pluginmgr.PluginLoader; import java.lang.reflect.Field; +import java.net.URL; import java.util.Arrays; +import java.util.StringTokenizer; -import gmgen.pluginmgr.PluginLoader; - import pcgen.core.Ability; import pcgen.core.Constants; import pcgen.core.Equipment; @@ -40,10 +38,10 @@ import pcgen.core.GameMode; import pcgen.core.Globals; import pcgen.core.Race; +import pcgen.core.SettingsHandler; import pcgen.core.SizeAdjustment; import pcgen.core.Skill; import pcgen.core.SystemCollections; -import pcgen.core.SettingsHandler; import pcgen.core.WeaponProf; import pcgen.core.bonus.Bonus; import pcgen.core.bonus.BonusObj; @@ -55,6 +53,7 @@ /** * Helps Junit tests */ +@SuppressWarnings("nls") public class TestHelper { private static boolean loaded = false; @@ -131,9 +130,10 @@ static public Object findField (Class<?> aClass, String fieldName) { try { + Class<?> clazz = aClass; while (true) { - for (Field f : Arrays.asList(aClass.getDeclaredFields())) + for (Field f : Arrays.asList(clazz.getDeclaredFields())) { if (f.getName().equals(fieldName)) { @@ -141,9 +141,9 @@ return f; } } - if (!aClass.getName().equals("Object")) + if (!clazz.getName().equals("Object")) { - aClass = aClass.getSuperclass(); + clazz = clazz.getSuperclass(); } else { @@ -249,7 +249,7 @@ Logging.errorPrint("Caught " + e); } - Globals.getRaceMap().put(name, aRace); + Globals.addRace(aRace); return aRace; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <boomer70@us...> - 2006-09-19 04:21:27
|
Revision: 1404 http://svn.sourceforge.net/pcgen/?rev=1404&view=rev Author: boomer70 Date: 2006-09-18 21:20:38 -0700 (Mon, 18 Sep 2006) Log Message: ----------- Misc fix ups. Beginings of a refactoring of bonus code to allow proper stacking of bonuses. Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/gmgen/plugin/PlayerCharacterOutput.java Trunk/pcgen/code/src/java/pcgen/core/Ability.java Trunk/pcgen/code/src/java/pcgen/core/BioSet.java Trunk/pcgen/code/src/java/pcgen/core/Equipment.java Trunk/pcgen/code/src/java/pcgen/core/GameMode.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/Race.java Trunk/pcgen/code/src/java/pcgen/core/Skill.java Trunk/pcgen/code/src/java/pcgen/core/bonus/Bonus.java Trunk/pcgen/code/src/java/pcgen/core/bonus/BonusObj.java Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoClasses.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoResources.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSummary.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityModel.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstUtils.java Trunk/pcgen/code/src/java/pcgen/util/Delta.java Trunk/pcgen/code/src/java/plugin/exporttokens/BonusListToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/GameToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/LicensedToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SourceLst.java Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SpellLst.java Trunk/pcgen/code/src/java/plugin/pretokens/test/PreCheckBaseTester.java Trunk/pcgen/code/src/java/plugin/pretokens/test/PreCheckTester.java Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/persistence/lst/DeprecatedToken.java Trunk/pcgen/code/src/java/plugin/bonustokens/AbilityPool.java Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/BabToken.java Removed Paths: ------------- Trunk/pcgen/code/src/java/pcgen/persistence/lst/Deprecated.java Trunk/pcgen/code/src/java/plugin/lsttokens/race/BabToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/pluginbuild.xml 2006-09-19 04:20:38 UTC (rev 1404) @@ -896,6 +896,13 @@ <target name="jar-bonus-plugins" depends="makeplugindirs" description="Build (Link) plugin Bonus Token jar files"> <!-- Bonus tokens--> + <jar jarfile="${bonusplugins.dir}/BonusToken-ABILITYPOOL.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/bonustokens/AbilityPool.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${bonusplugins.dir}/BonusToken-ACVALUE.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/gmgen/plugin/PlayerCharacterOutput.java =================================================================== --- Trunk/pcgen/code/src/java/gmgen/plugin/PlayerCharacterOutput.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/gmgen/plugin/PlayerCharacterOutput.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -240,17 +240,17 @@ public String getSaveFort() { - return "+" + new Double(pc.getBonus(1, true)).intValue(); + return "+" + pc.getTotalCheck(0); } public String getSaveRef() { - return "+" + new Double(pc.getBonus(2, true)).intValue(); + return "+" + pc.getTotalCheck(1); } public String getSaveWill() { - return "+" + new Double(pc.getBonus(3, true)).intValue(); + return "+" + pc.getTotalCheck(2); } public String getSize() Modified: Trunk/pcgen/code/src/java/pcgen/core/Ability.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Ability.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/core/Ability.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -52,7 +52,26 @@ /** Ability is Virtual */ VIRTUAL, /** Ability of any type */ - ANY + ANY; + + /** + * Find a nature by a string key. + * + * @param aKey The key to find. + * + * @return A <tt>Nature</tt> or <tt>null</tt> if not found. + */ + public static Nature get(final String aKey) + { + for ( final Nature nature : Nature.values() ) + { + if ( nature.toString().equalsIgnoreCase(aKey) ) + { + return nature; + } + } + return null; + } } private boolean multiples = false; Modified: Trunk/pcgen/code/src/java/pcgen/core/BioSet.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/BioSet.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/core/BioSet.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -25,6 +25,8 @@ */ package pcgen.core; +import pcgen.core.bonus.Bonus; +import pcgen.core.bonus.BonusObj; import pcgen.core.utils.ListKey; import pcgen.util.Logging; @@ -924,4 +926,47 @@ return ageSets; } + + /** + * This overrides the PObject method since the bonuses are not stored in + * the normal fashion. + * + * @see pcgen.core.PObject#getActiveBonuses(pcgen.core.PlayerCharacter) + */ + @Override + public List<BonusObj> getActiveBonuses( final PlayerCharacter aPC ) + { + final List<BonusObj> ret = new ArrayList<BonusObj>(); + + ret.addAll(super.getActiveBonuses(aPC)); + + final String ageSetLine = Globals.getBioSet().getAgeSetLine(aPC); + if (ageSetLine == null) + { + return ret; + } + + final StringTokenizer aTok = new StringTokenizer(ageSetLine, "\t"); + aTok.nextToken(); // name of ageSet, e.g.: Middle Aged + + while (aTok.hasMoreTokens()) + { + final String b = aTok.nextToken(); + + // TODO - Could these bonuses have a PRE? + if (b.startsWith("BONUS:")) //$NON-NLS-1$ + { + final BonusObj aBonus = Bonus.newBonus(b.substring(6)); + + if (aBonus != null) + { + aBonus.setCreatorObject(Globals.getBioSet()); + aBonus.setApplied(true); + ret.add(aBonus); + } + } + } + + return ret; + } } Modified: Trunk/pcgen/code/src/java/pcgen/core/Equipment.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Equipment.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/core/Equipment.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -1153,25 +1153,23 @@ } } -/* - for (Iterator e = eqModifierList.iterator(); e.hasNext();) - { - EquipmentModifier eqMod = (EquipmentModifier) e.next(); - for (Iterator mI = eqMod.getBonusList().iterator(); mI.hasNext();) - { - BonusObj aBonus = (BonusObj) mI.next(); - String eqModBonus = aBonus.toString(); - if ((eqModBonus.length() != 0) && !eqModBonus.startsWith("EQM")) - { - if (s.length() != 0) - { - s.append(", "); - } - s.append(eqModBonus); - } - } - } - */ +// for (final Iterator<EquipmentModifier> e = eqModifierList.iterator(); e.hasNext();) +// { +// final EquipmentModifier eqMod = e.next(); +// for (final Iterator<BonusObj> mI = eqMod.getBonusList().iterator(); mI.hasNext();) +// { +// final BonusObj aBonus = mI.next(); +// final String eqModBonus = aBonus.toString(); +// if ((eqModBonus.length() != 0) && !eqModBonus.startsWith("EQM")) +// { +// if (s.length() != 0) +// { +// s.append(", "); +// } +// s.append(eqModBonus); +// } +// } +// } if (t.length() != 0) { if (s.length() != 0) Modified: Trunk/pcgen/code/src/java/pcgen/core/GameMode.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/GameMode.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/core/GameMode.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -1779,6 +1779,18 @@ return Collections.unmodifiableList(checkList); } + /** + * Returns the check key of the check at the index specified. + * + * @param anIndex Index of the check in the game mode check list. + * + * @return A key for the check. + */ + public String getCheckKey( final int anIndex ) + { + return checkList.get(anIndex).getKeyName(); + } + //ALIGNMENTLIST /** Modified: Trunk/pcgen/code/src/java/pcgen/core/PObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -43,6 +43,7 @@ import pcgen.core.bonus.Bonus; import pcgen.core.bonus.BonusObj; import pcgen.core.bonus.BonusUtilities; +import pcgen.core.bonus.TypedBonus; import pcgen.core.chooser.ChooserUtilities; import pcgen.core.levelability.LevelAbility; import pcgen.core.pclevelinfo.PCLevelInfo; @@ -52,6 +53,7 @@ import pcgen.persistence.PersistenceLayerException; import pcgen.persistence.lst.output.prereq.PrerequisiteWriter; import pcgen.persistence.lst.prereq.PreParserFactory; +import pcgen.util.DoubleKeyMap; import pcgen.util.Logging; import pcgen.util.PropertyFactory; import pcgen.util.chooser.ChooserFactory; @@ -4703,6 +4705,21 @@ } } +// public List<TypedBonus> getBonuses(final PlayerCharacter aPC, final String aBonusType, final String aBonusName) +// { +// if (!PrereqHandler.passesAll(this.getPreReqList(), aPC, this)) +// { +// return Collections.emptyList(); +// } +// +// for ( final BonusObj bonus : getBonusList() ) +// { +// if ( bonus.getTypeOfBonus().equalsIgnoreCase(aBonusType) && bonus.getBonusName().equalsIgnoreCase(aBonusName) ) +// { +// +// } +// } +// } /* ************************************************ * End methods for the KeyedListContainer Interface @@ -4871,7 +4888,37 @@ } return options; } + + private DoubleKeyMap<AbilityCategory, Ability.Nature, List<QualifiedObject<String>>> theAbilities = new DoubleKeyMap<AbilityCategory, Ability.Nature, List<QualifiedObject<String>>>(); + public void addAbility(final AbilityCategory aCategory, final Ability.Nature aNature, final QualifiedObject<String> anAbility) + { + List<QualifiedObject<String>> abilities = theAbilities.get(aCategory, aNature); + if ( abilities == null ) + { + abilities = new ArrayList<QualifiedObject<String>>(); + theAbilities.put(aCategory, aNature, abilities); + } + abilities.add(anAbility); + } + public List<String> getAbilityKeys(final PlayerCharacter aPC, final AbilityCategory aCategory, final Ability.Nature aNature) + { + final List<QualifiedObject<String>> abilities = theAbilities.get(aCategory, aNature); + if ( abilities == null ) + { + return Collections.emptyList(); + } + final List<String> ret = new ArrayList<String>(abilities.size()); + for ( final QualifiedObject<String> str : abilities ) + { + if ( str.qualifies(aPC) ) + { + ret.add(str.getObject(aPC)); + } + } + return ret; + } + // /** // * Add a Spell-Like Ability granted by this object. // * Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -51,6 +51,7 @@ import pcgen.core.bonus.Bonus; import pcgen.core.bonus.BonusObj; +//import pcgen.core.bonus.TypedBonus; import pcgen.core.character.CharacterSpell; import pcgen.core.character.CompanionMod; import pcgen.core.character.EquipSet; @@ -267,6 +268,8 @@ */ private Map<AbilityCategory, BigDecimal> theUserPoolBonuses = null; +// private Map<String, List<TypedBonus>> theBonusMap = new HashMap<String, List<TypedBonus>>(); + /////////////////////////////////////// //operations /** @@ -382,7 +385,7 @@ * Retrieve those skills in the character's skill list that match the * supplied visibility level. * - * @param visibility What level of visibility skills are desired. + * @param vis What level of visibility skills are desired. * * @return A list of the character's skills matching the visibility * criteria. @@ -459,6 +462,10 @@ if (statIndex>=0) { baseSpellStat = getStatList().getTotalStatFor(statString); +// final List<TypedBonus> bonuses = getBonusesTo("STAT", "BASESPELLSTAT"); +// bonuses.addAll( getBonusesTo("STAT", "BASESPELLSTAT;CLASS."+aClass.getKeyName()) ); +// bonuses.addAll( getBonusesTo("STAT", "CAST." + statString) ); +// baseSpellStat += TypedBonus.totalBonuses(bonuses); baseSpellStat += (int) getTotalBonusTo("STAT", "BASESPELLSTAT"); baseSpellStat += (int) getTotalBonusTo("STAT", "BASESPELLSTAT;CLASS." + aClass.getKeyName()); baseSpellStat += (int) getTotalBonusTo("STAT", "CAST." + statString); @@ -551,7 +558,7 @@ // so we need to find one they do have for (EquipSet eSet : equipSetList) { - if (eSet.getParentIdPath().equals("0")) + if (eSet.getParentIdPath().equals(EquipSet.ROOT_ID)) { calcEquipSetId = eSet.getIdPath(); @@ -588,7 +595,7 @@ if (eSet == null) { - Logging.debugPrint("No EquipSet has been selected for calculations yet."); + Logging.debugPrint("No EquipSet has been selected for calculations yet."); //$NON-NLS-1$ return; } @@ -614,8 +621,8 @@ // then set status to equipped and add to PC's equipment list for (EquipSet es : pcEquipSetList) { - final String abCalcId = calcId + "."; - final String abParentId = es.getParentIdPath() + "."; + final String abCalcId = calcId + EquipSet.PATH_SEPARATOR; + final String abParentId = es.getParentIdPath() + EquipSet.PATH_SEPARATOR; // calcId = 0.1. // parentIdPath = 0.10. @@ -638,7 +645,7 @@ final String aLoc = es.getName(); final String aNote = es.getNote(); Float num = es.getQty(); - final StringTokenizer aTok = new StringTokenizer(es.getIdPath(), "."); + final StringTokenizer aTok = new StringTokenizer(es.getIdPath(), EquipSet.PATH_SEPARATOR); // if the eSet.getIdPath() is longer than 3 // it's inside a container, don't try to equip @@ -921,7 +928,10 @@ * * @return a List of Strings where each String is a type that the * character has. The list returned will never be null + * + * @deprecated Use getRaceType() and getRaceSubTypes() instead */ + @Deprecated public List<String> getTypes() { final List<String> list = new ArrayList<String>(); @@ -944,6 +954,7 @@ } + @Deprecated public String getCritterType() { final StringBuffer critterType = new StringBuffer(); @@ -974,9 +985,14 @@ return critterType.toString(); } + /** + * Returns a String with the characters Race Type (e.g. Humanoid). + * + * @return The character's race type or "None" + */ public String getRaceType() { - String raceType = "None"; + String raceType = Constants.s_NONE; if (race != null) { raceType = race.getRaceType(); @@ -986,7 +1002,7 @@ for (CompanionMod cm : companionModList) { final String aType = cm.getRaceType(); - if (!"".equals(aType)) + if (!Constants.EMPTY_STRING.equals(aType)) { raceType = aType; } @@ -998,7 +1014,7 @@ { final String aType = t.getRaceType(); - if (!"".equals(aType)) + if (!Constants.EMPTY_STRING.equals(aType)) { raceType = aType; } @@ -1007,19 +1023,24 @@ return raceType; } + /** + * Gets a <tt>List</tt> of racial subtypes for the character (e.g. Good). + * + * @return A unmodifiable <tt>List</tt> of subtypes. + */ public List<String> getRacialSubTypes() { - ArrayList<String> racialSubTypes = new ArrayList<String>(race.getRacialSubTypes()); + final ArrayList<String> racialSubTypes = new ArrayList<String>(race.getRacialSubTypes()); if (!templateList.isEmpty()) { - Set<String> added = new TreeSet<String>(); - Set<String> removed = new TreeSet<String>(); + final Set<String> added = new TreeSet<String>(); + final Set<String> removed = new TreeSet<String>(); for (PCTemplate aTemplate : templateList) { added.addAll(aTemplate.getAddedSubTypes()); removed.addAll(aTemplate.getRemovedSubTypes()); } - for (String subType : added) + for (final String subType : added) { if (!racialSubTypes.contains(subType)) { @@ -1141,13 +1162,14 @@ { final String custom = getTabName(); - if (!"".equals(custom)) + if (!Constants.EMPTY_STRING.equals(custom)) { return custom; } final StringBuffer displayName = new StringBuffer().append(getName()); + // TODO - i18n switch (SettingsHandler.getNameDisplayStyle()) { case Constants.DISPLAY_STYLE_NAME: @@ -1180,11 +1202,13 @@ /** * set display update - * @param displayUpdate + * TODO - This probably doesn't belong here. It seems to only be used + * by InfoSkills. + * @param aDisplayUpdate */ - public void setDisplayUpdate(final boolean displayUpdate) + public void setDisplayUpdate(final boolean aDisplayUpdate) { - this.displayUpdate = displayUpdate; + this.displayUpdate = aDisplayUpdate; } /** @@ -1286,8 +1310,8 @@ for (EquipSet es : equipSetList) { - final String abIdPath = idPath + "."; - final String esIdPath = es.getIdPath() + "."; + final String abIdPath = idPath + EquipSet.PATH_SEPARATOR; + final String esIdPath = es.getIdPath() + EquipSet.PATH_SEPARATOR; if (!esIdPath.startsWith(abIdPath)) { @@ -1326,8 +1350,8 @@ float count = 0; for (EquipSet eSet : getEquipSet()) { - final String esID = eSet.getIdPath() + "."; - final String abID = idPath + "."; + final String esID = eSet.getIdPath() + EquipSet.PATH_SEPARATOR; + final String abID = idPath + EquipSet.PATH_SEPARATOR; if (esID.startsWith(abID)) { if (eSet.getValue().equals(aName)) @@ -1417,6 +1441,19 @@ return EquipmentUtilities.mergeEquipmentList(getEquipmentMasterList(), Constants.MERGE_NONE); } + /** + * Search for a piece of equipment in the specified list by name. + * + * TODO - This does not belong in PlayerCharacter. Move to Equipment if + * needed. + * + * TODO - This probably won't work with i18n. Should always search by key. + * + * @param aString The name of the equipment. + * @param aList The list of equipment to search in. + * + * @return The <tt>Equipment</tt> object or <tt>null</tt> + */ public Equipment getEquipmentNamed(final String aString, final List<Equipment> aList) { Equipment match = null; @@ -1430,7 +1467,7 @@ } return match; - } + } /** * Set the characters eye colour @@ -1462,21 +1499,26 @@ { String aString = Globals.getBonusFeatString(); - final StringTokenizer aTok = new StringTokenizer(aString, "|", false); + final StringTokenizer aTok = new StringTokenizer(aString, Constants.PIPE, false); final int startLevel = Integer.parseInt(aTok.nextToken()); final int rangeLevel = Integer.parseInt(aTok.nextToken()); + // TODO - Should this stuff follow stacking rules? + // TODO - Does it even matter anymore. +// double pool = getBonusValue("FEAT", "POOL"); +// double pcpool = getBonusValue("FEAT", "PCPOOL"); +// double mpool = getBonusValue("FEAT", "MONSTERPOOL"); double pool = getTotalBonusTo("FEAT", "POOL"); double pcpool = getTotalBonusTo("FEAT", "PCPOOL"); double mpool = getTotalBonusTo("FEAT", "MONSTERPOOL"); - Logging.debugPrint(""); - Logging.debugPrint("=============="); - Logging.debugPrint("level " + this.getTotalPlayerLevels()); + Logging.debugPrint(""); //$NON-NLS-1$ + Logging.debugPrint("=============="); //$NON-NLS-1$ + Logging.debugPrint("level " + this.getTotalPlayerLevels()); //$NON-NLS-1$ - Logging.debugPrint("POOL: " + pool); - Logging.debugPrint("PCPOOL: " + pcpool); - Logging.debugPrint("MPOOL: " + mpool); + Logging.debugPrint("POOL: " + pool); //$NON-NLS-1$ + Logging.debugPrint("PCPOOL: " + pcpool); //$NON-NLS-1$ + Logging.debugPrint("MPOOL: " + mpool); //$NON-NLS-1$ double startAdjust = startLevel/rangeLevel; @@ -1484,16 +1526,15 @@ 1.0d + pcpool - startAdjust + 0.0001 : 0); pool += Math.floor(mpool + 0.0001); - Logging.debugPrint(""); - Logging.debugPrint("Total Bonus: " + pool); - Logging.debugPrint("=============="); - Logging.debugPrint(""); + Logging.debugPrint(""); //$NON-NLS-1$ + Logging.debugPrint("Total Bonus: " + pool); //$NON-NLS-1$ + Logging.debugPrint("=============="); //$NON-NLS-1$ + Logging.debugPrint(""); //$NON-NLS-1$ return pool; } /** ->>>>>>> .r1382 * Checks whether a PC is allowed to level up. A PC is not allowed to * level up if the "Enforce Spending" option is set and he still has * unallocated skill points and/or feat slots remaining. @@ -1528,11 +1569,23 @@ return getSafeStringFor(StringKey.FILE_NAME); } + /** + * Returns the followers associated with this character. + * + * @return A <tt>List</tt> of <tt>Follower</tt> objects. + */ public List<Follower> getFollowerList() { return followerList; } + /** + * Returns a very descriptive name for the character. + * + * <p>The format is [name] the [level]th level [race name] [classes] + * + * @return A descriptive string name for the character. + */ public String getFullDisplayName() { final int levels = getTotalLevels(); @@ -1544,7 +1597,8 @@ } /** - * Selector + * Returns a region (including subregion) string for the character. + * * <p/> * Build on-the-fly so removing templates won't mess up region * @@ -1563,6 +1617,17 @@ return tempRegName.toString(); } + /** + * Sets the character's gender. + * + * <p>The gender will only be set if the character does not have a template + * that locks the character's gender. + * + * <p><b>WARNING:</b> This method has a side effect that it will actually + * set the gender to the locked template gender. + * + * @param argGender A gender to try and set. + */ public void setGender(final String argGender) { final String templateGender = findTemplateGender(); @@ -1579,6 +1644,16 @@ setDirty(true); } + /** + * Returns a string for the character's gender. + * + * <p>This method will return the stored gender or the template locked + * gender if there is one. This means the <tt>setGender()</tt> side effect + * is not really required. + * + * @return A <tt>String</tt> version of the character's gender. + * TODO - Gender should be an object so it can be i18n. + */ public String getGender() { final String tGender = findTemplateGender(); @@ -1586,6 +1661,13 @@ return tGender.equals(Constants.s_NONE) ? gender : tGender; } + /** + * Checks if the user is allowed to change the character's gender. + * + * <p>That is, if no template with a gender lock has been specified. + * + * @return <tt>true</tt> if the user can freely set the character's gender. + */ public boolean canSetGender() { final String tGender = findTemplateGender(); @@ -1593,58 +1675,131 @@ return tGender.equals(Constants.s_NONE); } + /** + * Sets the character's wealth. + * + * <p>Gold here is used as a character's total purchase power not + * actual gold pieces. + * + * @param aString A String gold amount. + * TODO - Do this parsing elsewhere. + */ public void setGold(final String aString) { gold = new BigDecimal(aString); setDirty(true); } + /** + * Returns the character's total wealth. + * + * @see pcgen.core.PlayerCharacter#setGold(String) + * + * @return A <tt>BigDecimal</tt> value for the character's wealth. + */ public BigDecimal getGold() { return gold; } + /** + * Sets the character's hair color as a string. + * + * @param aString The hair color to set. + */ public void setHairColor(final String aString) { setStringFor(StringKey.HAIR_COLOR, aString); } + /** + * Gets the character's hair color. + * + * @return A hair color string. + */ public String getHairColor() { return getSafeStringFor(StringKey.HAIR_COLOR); } + /** + * Sets the character's hair style. + * + * @param aString A hair style. + */ public void setHairStyle(final String aString) { setStringFor(StringKey.HAIR_STYLE, aString); } + /** + * Gets the character's hair style. + * + * @return The character's hair style. + */ public String getHairStyle() { return getSafeStringFor(StringKey.HAIR_STYLE); } + /** + * Sets the character's handedness. + * + * @param aString A String to use as a handedness. + * + * TODO - This should probably be an object as some systems may use the + * information. + */ public void setHanded(final String aString) { setStringFor(StringKey.HANDED, aString); } + /** + * Returns the character's handedness string. + * + * @return A String for handedness. + */ public String getHanded() { return getSafeStringFor(StringKey.HANDED); } + /** + * Sets the character's height in inches. + * + * @param i A height in inches. + * + * TODO - This should be a double value stored in CM + */ public void setHeight(final int i) { heightInInches = i; setDirty(true); } + /** + * Gets the character's height in inches. + * + * @return The character's height in inches. + */ public int getHeight() { return heightInInches; } + /** + * Marks the character as being in the process of being loaded. + * + * <p>This information is used to prevent the system from trying to + * calculate values on partial information or values that should be set + * from the saved character. + * + * <p>TODO - This is pretty dangerous. + * + * @param newIsImporting <tt>true</tt> to mark the character as being + * imported. + */ public void setImporting(final boolean newIsImporting) { this.importing = newIsImporting; @@ -1655,8 +1810,9 @@ * feats from levelling. * * @return count of initial, non-leveling feats - * @deprecated + * @deprecated Now handled by a BONUS object. */ + @Deprecated public double getInitialFeats() { double initFeats = 0.0; @@ -1685,26 +1841,64 @@ return initFeats; } + /** + * Sets the character's interests. + * + * @param aString A string of interests for the character. + */ public void setInterests(final String aString) { setStringFor(StringKey.INTERESTS, aString); } + /** + * Gets a string of interests for the character. + * + * @return A String of interests or an empty string. + */ public String getInterests() { return getSafeStringFor(StringKey.INTERESTS); } - public TreeSet<Language> getLanguagesList() + /** + * Gets the character's list of languages. + * + * @return An unmodifiable langauge set. + */ + public SortedSet<Language> getLanguagesList() { - return languages; + return Collections.unmodifiableSortedSet(languages); } + /** + * Removes all the character's languages. + */ + public void clearLanguages() + { + languages.clear(); + } + + /** + * Adds a <tt>Collection</tt> of languages to the character. + * + * @param aList A <tt>Collection</tt> of <tt>Language</tt> objects. + */ + public void addLanguages( final Collection<Language> aList ) + { + languages.addAll(aList); + } + + /** + * TODO - This doesn't need to be a PlayerCharacter method. + * + * @return + */ public String getLanguagesListNames() { final StringBuffer b = new StringBuffer(); - for (Language l : getLanguagesList()) + for ( final Language l : languages ) { if (b.length() > 0) { @@ -1717,11 +1911,21 @@ return b.toString(); } + /** + * Sets the character's location. + * + * @param aString A location. + */ public void setLocation(final String aString) { setStringFor(StringKey.LOCATION, aString); } + /** + * Gets the character's location. + * + * @return The character's location. + */ public String getLocation() { return getSafeStringFor(StringKey.LOCATION); @@ -1971,13 +2175,14 @@ } for ( String formula : formulas ) { - final int val = this.getVariableValue( formula, "", this ).intValue(); + final int val = this.getVariableValue( formula, Constants.EMPTY_STRING, this ).intValue(); ret = Math.max( ret, val ); } } if ( ret != -1 ) { +// ret += (int)getBonusValue("FOLLOWERS", aType.toUpperCase()); ret += this.getTotalBonusTo("FOLLOWERS", aType.toUpperCase()); } else @@ -1989,7 +2194,7 @@ { for ( String varName : cMod.getVarMap().keySet() ) { - if ( this.getVariableValue(varName, "").intValue() > 0 ) + if ( this.getVariableValue(varName, Constants.EMPTY_STRING).intValue() > 0 ) { return -1; } @@ -2080,16 +2285,32 @@ return null; } + /** + * Returns the state of the default monster flag when the character was + * created. + * + * @return <tt>true</tt> if the character used the default monster flag. + */ public boolean isMonsterDefault() { return useMonsterDefault; } + /** + * Sets the character's name. + * + * @param aString A name to set. + */ public void setName(final String aString) { setStringFor(StringKey.NAME, aString); } + /** + * Gets the character's name. + * + * @return The name + */ public String getName() { return getSafeStringFor(StringKey.NAME); @@ -2154,16 +2375,31 @@ return npp; } + /** + * Gets a list of notes associated with the character. + * + * @return A list of <tt>NoteItem</tt> objects. + */ public ArrayList<NoteItem> getNotesList() { return notesList; } + /** + * Sets a string of phobias for the character. + * + * @param aString A string to set. + */ public void setPhobias(final String aString) { setStringFor(StringKey.PHOBIAS, aString); } + /** + * Gets the phobia string for the character. + * + * @return A phobia string. + */ public String getPhobias() { return getSafeStringFor(StringKey.PHOBIAS); @@ -3546,8 +3782,8 @@ for (Iterator<EquipSet> e = equipSetList.iterator(); e.hasNext();) { final EquipSet es = e.next(); - final String abParentId = es.getParentIdPath() + "."; - final String abPid = pid + "."; + final String abParentId = es.getParentIdPath() + EquipSet.PATH_SEPARATOR; + final String abPid = pid + EquipSet.PATH_SEPARATOR; if (abParentId.startsWith(abPid)) { @@ -3819,7 +4055,7 @@ masterBAB = nPC.baseAttackBonus(); final String copyMasterBAB = replaceMasterString(getCopyMasterBAB(), masterBAB); - masterBAB = getVariableValue(copyMasterBAB, "").intValue(); + masterBAB = getVariableValue(copyMasterBAB, Constants.EMPTY_STRING).intValue(); masterTotal = masterBAB + TOHITBonus; } @@ -3958,19 +4194,19 @@ if (".CLEARRACIAL".equals(aString)) { clearRacials = true; - getLanguagesList().removeAll(getRace().getSafeListFor(ListKey. + languages.removeAll(getRace().getSafeListFor(ListKey. AUTO_LANGUAGES)); } else if (".CLEARALL".equals(aString) || ".CLEAR".equals(aString)) { clearRacials = true; autoLangs.clear(); - getLanguagesList().clear(); + languages.clear(); } else if (".CLEARTEMPLATES".equals(aString)) { autoLangs.clear(); - getLanguagesList().removeAll(templateAutoLanguages); + languages.removeAll(templateAutoLanguages); } else { @@ -3988,7 +4224,7 @@ autoLangs.addAll(pObj.getSafeListFor(ListKey.AUTO_LANGUAGES)); } - getLanguagesList().addAll(autoLangs); + languages.addAll(autoLangs); return autoLangs; } @@ -4077,33 +4313,23 @@ this.useHigherPreppedSlots = useHigher; } - /** - * type 0 = attack bonus; 1 = check1; 2 = check2; 3 = check3; etc, last one is = Unarmed - * @param type - * @param addBonuses - * @return bonus - */ - public double getBonus(final int type, final boolean addBonuses) + public int getBaseCheck( final int checkInd ) { - final String cacheLookup = "getBonus:" + type + "," + addBonuses; + final String cacheLookup = "getBaseCheck:" + checkInd; final Float total = getVariableProcessor().getCachedVariable(cacheLookup); if (total != null) { - return total.doubleValue(); + return total.intValue(); } - + double bonus = 0; final int totalClassLevels; Map<String, String> totalLvlMap = null; final Map<String, String> classLvlMap; - - if (type == 0) + + if (checkInd < SettingsHandler.getGame().getUnmodifiableCheckList().size()) { - bonus = race.getBAB(this); - } - else if (type <= SettingsHandler.getGame().getUnmodifiableCheckList().size()) - { totalClassLevels = getTotalCharacterLevel(); if (totalClassLevels > SettingsHandler.getGame().getChecksMaxLvl()) { @@ -4113,8 +4339,8 @@ setClassLevelsBrazenlyTo(classLvlMap); // insure class-levels total is below some value (e.g. 20) } - bonus = getTotalBonusTo("CHECKS", - "BASE." + SettingsHandler.getGame().getUnmodifiableCheckList().get(type - 1).toString()); + final String checkName = SettingsHandler.getGame().getUnmodifiableCheckList().get(checkInd).toString(); + bonus = getTotalBonusTo("CHECKS", "BASE." + checkName); // // now we see if this PC is a Familiar/Mount @@ -4122,15 +4348,8 @@ if ((nPC != null) && (getCopyMasterCheck().length() > 0)) { - int masterBonus; - final PlayerCharacter curPC = this; - Globals.setCurrentPC(nPC); + int masterBonus = nPC.getBaseCheck(checkInd); - // calculate the Masters Save Bonus - masterBonus = nPC.calculateSaveBonus(type, - SettingsHandler.getGame().getUnmodifiableCheckList().get(type - 1).toString(), "BASE"); - Globals.setCurrentPC(curPC); - final String copyMasterCheck = replaceMasterString(getCopyMasterCheck(), masterBonus); masterBonus = getVariableValue(copyMasterCheck, "").intValue(); @@ -4144,39 +4363,115 @@ getVariableProcessor().restartCache(); } } + return (int)bonus; + } - if (addBonuses) - { - if (type == 0) - { - bonus += getTotalBonusTo("TOHIT", "TOHIT"); - bonus += getSizeAdjustmentBonusTo("TOHIT", "TOHIT"); - } - else if (type <= SettingsHandler.getGame().getUnmodifiableCheckList().size()) - { - bonus += getTotalBonusTo("CHECKS", SettingsHandler.getGame().getUnmodifiableCheckList().get(type - 1).toString()); - } - else - { - bonus += getSizeAdjustmentBonusTo("TOHIT", "TOHIT"); - } - } - - int cBonus = 0; - - for ( PCClass pcClass : classList ) - { - if ((type == 0) || (type > SettingsHandler.getGame().getUnmodifiableCheckList().size())) - { - cBonus += pcClass.baseAttackBonus(this); - } - } - - bonus += cBonus; - - getVariableProcessor().addCachedVariable(cacheLookup, new Float(bonus)); - return bonus; + public int getTotalCheck( final int aCheck ) + { + int bonus = getBaseCheck(aCheck); + return bonus + (int)getTotalBonusTo("CHECKS", SettingsHandler.getGame().getCheckKey(aCheck)); } + +// /** +// * type 0 = attack bonus; 1 = check1; 2 = check2; 3 = check3; etc, last one is = Unarmed +// * @param type +// * @param addBonuses +// * @return bonus +// */ +// public double getBonus(final int type, final boolean addBonuses) +// { +// final String cacheLookup = "getBonus:" + type + "," + addBonuses; +// final Float total = getVariableProcessor().getCachedVariable(cacheLookup); +// +// if (total != null) +// { +// return total.doubleValue(); +// } +// +// double bonus = 0; +// final int totalClassLevels; +// Map<String, String> totalLvlMap = null; +// final Map<String, String> classLvlMap; +// +// if (type == 0) +// { +//// bonus = race.getBAB(this); +// } +// else if (type <= SettingsHandler.getGame().getUnmodifiableCheckList().size()) +// { +// totalClassLevels = getTotalCharacterLevel(); +// if (totalClassLevels > SettingsHandler.getGame().getChecksMaxLvl()) +// { +// totalLvlMap = getTotalLevelHashMap(); +// classLvlMap = getCharacterLevelHashMap(SettingsHandler.getGame().getChecksMaxLvl()); +// getVariableProcessor().pauseCache(); +// setClassLevelsBrazenlyTo(classLvlMap); // insure class-levels total is below some value (e.g. 20) +// } +// +// bonus = getTotalBonusTo("CHECKS", +// "BASE." + SettingsHandler.getGame().getUnmodifiableCheckList().get(type - 1).toString()); +// +// // +// // now we see if this PC is a Familiar/Mount +// final PlayerCharacter nPC = getMasterPC(); +// +// if ((nPC != null) && (getCopyMasterCheck().length() > 0)) +// { +// int masterBonus; +// final PlayerCharacter curPC = this; +// Globals.setCurrentPC(nPC); +// +// // calculate the Masters Save Bonus +// masterBonus = nPC.calculateSaveBonus(type, +// SettingsHandler.getGame().getUnmodifiableCheckList().get(type - 1).toString(), "BASE"); +// Globals.setCurrentPC(curPC); +// +// final String copyMasterCheck = replaceMasterString(getCopyMasterCheck(), masterBonus); +// masterBonus = getVariableValue(copyMasterCheck, "").intValue(); +// +// // use masters save if better +// bonus = Math.max(bonus, masterBonus); +// } +// +// if (totalLvlMap != null) +// { +// setClassLevelsBrazenlyTo(totalLvlMap); +// getVariableProcessor().restartCache(); +// } +// } +// +// if (addBonuses) +// { +// if (type == 0) +// { +// bonus += getTotalBonusTo("TOHIT", "TOHIT"); +// bonus += getSizeAdjustmentBonusTo("TOHIT", "TOHIT"); +// } +// else if (type <= SettingsHandler.getGame().getUnmodifiableCheckList().size()) +// { +// bonus += getTotalBonusTo("CHECKS", SettingsHandler.getGame().getUnmodifiableCheckList().get(type - 1).toString()); +// } +// else +// { +// bonus += getSizeAdjustmentBonusTo("TOHIT", "TOHIT"); +// } +// } +// +// int cBonus = 0; +// +// for ( PCClass pcClass : classList ) +// { +// if ((type == 0) || (type > SettingsHandler.getGame().getUnmodifiableCheckList().size())) +// { +// cBonus += pcClass.baseAttackBonus(this); +// } +// } +// +// bonus += cBonus; +// +// getVariableProcessor().addCachedVariable(cacheLookup, new Float(bonus)); +// return bonus; +// } /** * return bonus total for a specific bonusType @@ -4193,6 +4488,19 @@ return sumActiveBonusMap(typeString); } +// public List<TypedBonus> getBonusesOfType(final String aBonusName, final String aBonusType, final String aType ) +// { +// final List<TypedBonus> bonuses = this.getBonusesTo(aBonusName, aBonusType); +// final List<TypedBonus> ret = new ArrayList<TypedBonus>(bonuses.size()); +// for ( final TypedBonus bonus : bonuses ) +// { +// if ( bonus.getType().equals(aType) ) +// { +// ret.add( bonus ); +// } +// } +// return ret; +// } /** * If the class passed in has the Levels * @param newLevelClass The class the new level has been taken in. @@ -5163,7 +5471,7 @@ } } - getLanguagesList().removeAll(oldRace.getSafeListFor(ListKey.AUTO_LANGUAGES)); + languages.removeAll(oldRace.getSafeListFor(ListKey.AUTO_LANGUAGES)); if (oldRace.getWeaponProfAutos() != null) { @@ -5836,6 +6144,19 @@ return sumActiveBonusMap(prefix); } +// public List<TypedBonus> getBonusesTo(final String bonusType, final String bonusName) +// { +// final String prefix = new StringBuffer(bonusType).append('.').append(bonusName).toString(); +// +// final List<TypedBonus> ret = theBonusMap.get(prefix); +// if ( ret == null ) +// { +// return Collections.emptyList(); +// } +// +// return ret; +// } + public int getTotalLevels() { int totalLevels = 0; @@ -6011,8 +6332,9 @@ int getTotalCasterLevelWithSpellBonus(final Spell aSpell, final String spellType, final String classOrRace, final int casterLev) { - if(aSpell != null && aSpell.getFixedCasterLevel() != null) { - return getVariableValue(aSpell.getFixedCasterLevel(), "").intValue(); + if(aSpell != null && aSpell.getFixedCasterLevel() != null) + { + return getVariableValue(aSpell.getFixedCasterLevel(), Constants.EMPTY_STRING).intValue(); } int tBonus = casterLev; @@ -6020,10 +6342,12 @@ String tType; String tStr; - final ArrayList<CasterLevelSpellBonus> bonuses = new ArrayList<CasterLevelSpellBonus>(); +// final List<TypedBonus> bonuses = new ArrayList<TypedBonus>(); + final List<CasterLevelSpellBonus> bonuses = new ArrayList<CasterLevelSpellBonus>(); if (classOrRace != null) { +// bonuses.addAll(getBonusesTo("CASTERLEVEL", classOrRace)); tBonus = (int)getTotalBonusTo("CASTERLEVEL", classOrRace); if (tBonus > 0) { @@ -6033,8 +6357,10 @@ //Support both types of syntax for CLASS: //BONUS:CASTERLEVEL|Sorcerer|1 and BONUS:CASTERLEVEL|CLASS.Sorcerer|1 - if (!classOrRace.startsWith("RACE.")) { + if (!classOrRace.startsWith("RACE.")) + { tStr = "CLASS." + classOrRace; +// bonuses.addAll( getBonusesTo("CASTERLEVEL", tStr) ); tBonus = (int)getTotalBonusTo("CASTERLEVEL", tStr); if (tBonus > 0) { @@ -6052,6 +6378,7 @@ if (!spellType.equals(Constants.s_NONE)) { tStr = "TYPE." + spellType; +// bonuses.addAll( getBonusesTo("CASTERLEVEL", tStr) ); tBonus = (int)getTotalBonusTo("CASTERLEVEL", tStr); if (tBonus > 0) { @@ -6059,6 +6386,12 @@ bonuses.add(new CasterLevelSpellBonus(tBonus, tType)); } tStr += ".RESET"; +// final List<TypedBonus> reset = getBonusesTo("CASTERLEVEL", tStr); +// if ( reset.size() > 0 ) +// { +// bonuses.addAll(reset); +// replaceCasterLevel = true; +// } tBonus = (int)getTotalBonusTo("CASTERLEVEL", tStr); if (tBonus > 0) { @@ -6069,6 +6402,7 @@ } tStr = "SPELL." + aSpell.getKeyName(); +// bonuses.addAll( getBonusesTo("CASTERLEVEL", tStr) ); tBonus = (int)getTotalBonusTo("CASTERLEVEL", tStr); if (tBonus > 0) { @@ -6076,6 +6410,12 @@ bonuses.add(new CasterLevelSpellBonus(tBonus, tType)); } tStr += ".RESET"; +// final List<TypedBonus> reset = getBonusesTo("CASTERLEVEL", tStr); +// if ( reset.size() > 0 ) +// { +// bonuses.addAll(reset); +// replaceCasterLevel = true; +// } tBonus = (int)getTotalBonusTo("CASTERLEVEL", tStr); if (tBonus > 0) { @@ -6087,6 +6427,7 @@ for ( String school : aSpell.getSchools() ) { tStr = "SCHOOL." + school; +// bonuses.addAll( getBonusesTo("CASTERLEVEL", tStr) ); tBonus = (int)getTotalBonusTo("CASTERLEVEL", tStr); if (tBonus > 0) { @@ -6094,6 +6435,12 @@ bonuses.add(new CasterLevelSpellBonus(tBonus, tType)); } tStr += ".RESET"; +// final List<TypedBonus> reset1 = getBonusesTo("CASTERLEVEL", tStr); +// if ( reset.size() > 0 ) +// { +// bonuses.addAll(reset1); +// replaceCasterLevel = true; +// } tBonus = (int)getTotalBonusTo("CASTERLEVEL", tStr); if (tBonus > 0) { @@ -6106,6 +6453,7 @@ for ( String subschool : aSpell.getSubschools() ) { tStr = "SUBSCHOOL." + subschool; +// bonuses.addAll( getBonusesTo("CASTERLEVEL", tStr) ); tBonus = (int)getTotalBonusTo("CASTERLEVEL", tStr); if (tBonus > 0) { @@ -6113,6 +6461,12 @@ bonuses.add(new CasterLevelSpellBonus(tBonus, tType)); } tStr += ".RESET"; +// final List<TypedBonus> reset1 = getBonusesTo("CASTERLEVEL", tStr); +// if ( reset.size() > 0 ) +// { +// bonuses.addAll(reset1); +// replaceCasterLevel = true; +// } tBonus = (int)getTotalBonusTo("CASTERLEVEL", tStr); if (tBonus > 0) { @@ -6125,6 +6479,7 @@ for ( String desc : aSpell.getDescriptorList() ) { tStr = "DESCRIPTOR." + desc; +// bonuses.addAll( getBonusesTo("CASTERLEVEL", tStr) ); tBonus = (int)getTotalBonusTo("CASTERLEVEL", tStr); if (tBonus > 0) { @@ -6132,6 +6487,12 @@ bonuses.add(new CasterLevelSpellBonus(tBonus, tType)); } tStr += ".RESET"; +// final List<TypedBonus> reset1 = getBonusesTo("CASTERLEVEL", tStr); +// if ( reset.size() > 0 ) +// { +// bonuses.addAll(reset1); +// replaceCasterLevel = true; +// } tBonus = (int)getTotalBonusTo("CASTERLEVEL", tStr); if (tBonus > 0) { @@ -6149,6 +6510,7 @@ if (mKey.startsWith("DOMAIN|")) { tStr = "DOMAIN." + mKey.substring(7); +// bonuses.addAll( getBonusesTo("CASTERLEVEL", tStr) ); tBonus = (int)getTotalBonusTo("CASTERLEVEL", tStr); if (tBonus > 0) { @@ -6156,6 +6518,12 @@ bonuses.add(new CasterLevelSpellBonus(tBonus, tType)); } tStr += ".RESET"; +// final List<TypedBonus> reset1 = getBonusesTo("CASTERLEVEL", tStr); +// if ( reset.size() > 0 ) +// { +// bonuses.addAll(reset1); +// replaceCasterLevel = true; +// } tBonus = (int)getTotalBonusTo("CASTERLEVEL", tStr); if (tBonus > 0) { @@ -6257,6 +6625,7 @@ result += casterLev; } +// result += TypedBonus.totalBonuses(bonuses); //Now go through bonuses and add it up for ( CasterLevelSpellBonus resultBonus : bonuses ) { @@ -6490,11 +6859,8 @@ public void addLanguage(final Language aLang) { - if (!getLanguagesList().contains(aLang)) - { - getLanguagesList().add(aLang); - setDirty(true); - } + languages.add(aLang); + setDirty(true); } public void addLanguageKeyed(final String aKey) @@ -7183,7 +7549,8 @@ // Need to create movement entries if there is a BONUS:MOVEADD // associated with that type of movement - for ( BonusObj bonus : getActiveBonusList() ) + for ( final BonusObj bonus : getActiveBonusList() ) +// for ( final BonusObj bonus : getAllActiveBonuses() ) { if (bonus.getTypeOfBonus().equals("MOVEADD")) { @@ -7332,6 +7699,7 @@ } + // TODO - Fix this to do 90% of the parsing work up front. public int calcACOfType(final String ACType) { final List<String> addList = SettingsHandler.getGame().getACTypeAddString(ACType); @@ -7348,6 +7716,7 @@ if (addList != null) { +// final List<TypedBonus> bonuses = new ArrayList<TypedBonus>(); for ( String aString : addList ) { final PObject aPObj = new PObject(); @@ -7357,12 +7726,19 @@ { final StringTokenizer aTok = new StringTokenizer(aString, "|"); AC += subCalcACOfType(aTok); +// while ( aTok.hasMoreTokens() ) +// { +// bonuses.addAll( TypedBonus.getBonusesOfType(getBonusesTo("COMBAT", "AC"), aTok.nextToken()) ); +// +// } +// AC += TypedBonus.totalBonuses(bonuses); } } } if (removeList != null) { +// final List<TypedBonus> bonuses = new ArrayList<TypedBonus>(); for ( String rString : removeList ) { final PObject aPObj = new PObject(); @@ -7372,6 +7748,12 @@ { final StringTokenizer aTok = new StringTokenizer(rString, "|"); AC -= subCalcACOfType(aTok); +// while ( aTok.hasMoreTokens() ) +// { +// bonuses.addAll( TypedBonus.getBonusesOfType(getBonusesTo("COMBAT", "AC"), aTok.nextToken()) ); +// +// } +// AC -= TypedBonus.totalBonuses(bonuses); } } } @@ -7401,6 +7783,7 @@ // value until after the map has been completely created. // Get the original value of the map. +// String origMapVal = theBonusMap.toString(); String origMapVal = activeBonusMap.toString(); // ensure that the values for the looked up variables are the most up to date @@ -7408,21 +7791,51 @@ calcActiveBonusLoop(); // Get the new contents of the map +// String mapVal = theBonusMap.toString(); String mapVal = activeBonusMap.toString(); // As the map is a TreeMap we know that the contents will be in // alphabetical order, so doing a straight string compare is // the easiest way to compare the whole tree. - while (!mapVal.equals(origMapVal)) { + while (!mapVal.equals(origMapVal)) + { // If the newly calculated bonus map is different to the old one // loop again until they are the same. setDirty(true); calcActiveBonusLoop(); origMapVal = mapVal; +// mapVal = theBonusMap.toString(); mapVal = activeBonusMap.toString(); } } +// private List<BonusObj> getAllActiveBonuses() +// { +// List<BonusObj> ret = new ArrayList<BonusObj>(); +// +// for ( final PObject pobj : getPObjectList() ) +// { +// if ( pobj != null ) +// { +// pobj.activateBonuses(this); +// +// // TODO - Class bonuses only get added if level is greater than +// // zero. Is this check required? Should it be part of +// // getPObjectList()? +// ret.addAll( pobj.getActiveBonuses(this) ); +// } +// } +// +// ret.addAll( getPurchaseModeBonuses() ); +// +// if (getUseTempMods()) +// { +// ret.addAll( getTempBonuses() ); +// } +// ret = Bonus.sortBonusList(ret); +// return ret; +// } + private void calcActiveBonusLoop() { // First we clear the current list @@ -7431,25 +7844,40 @@ // walk through all the possible bonus granters // to build up the active list of bonuses // + // Campaigns + // ArmorProf + + // Stat (PCStat) calcStatBonuses(); + // SizeAdjustment calcSizeAdjustmentBonuses(); + // BioSet (ageSet) calcAgeBonuses(); + // Check (PObject) calcCheckBonuses(); + // Alignment (PCAlignment) calcAlignmentBonuses(); + // Feat (virtual feats, auto feats) calcFeatBonuses(); + // Class (PCClass) calcClassBonuses(); + // CompanionMod calcCompanionModBonuses(); + // Equipment (includes EqMods) calcEquipmentBonuses(); + // Template (PCTemplate) calcTemplateBonuses(); + // Domain (CharacterDomain) calcDomainBonuses(); + // Race calcRaceBonuses(); + // Deity calcDeityBonuses(); + // Skill calcSkillBonuses(); calcPurchaseModeBonuses(); - //calcWeaponProfBonuses(); - //calcArmorProfBonuses(); if (getUseTempMods()) { calcTempBonuses(); @@ -7460,6 +7888,9 @@ // // Now build the activeBonusMap from all the bonuses // + +// final List<BonusObj> bonuses = getAllActiveBonuses(); +// buildBonusMap(bonuses); buildActiveBonusMap(); } @@ -7695,6 +8126,7 @@ } SR += (int) getTotalBonusTo("MISC", "SR"); +// SR += (int) getBonusValue("MISC", "SR"); // // This would make more sense to just not add in the first place... @@ -7873,7 +8305,7 @@ { final StringTokenizer aTok = new StringTokenizer(tokenString, "."); final String[] tokens = new String[aTok.countTokens()]; - final int checkIndex = SettingsHandler.getGame().getIndexOfCheck(saveType) + 1; + final int checkIndex = SettingsHandler.getGame().getIndexOfCheck(saveType); int save = 0; for (int i = 0; aTok.hasMoreTokens(); ++i) @@ -7882,11 +8314,11 @@ if ("TOTAL".equals(tokens[i])) { - save += (int) getBonus(checkIndex, true); + save += getTotalCheck(checkIndex); } else if ("BASE".equals(tokens[i])) { - save += (int) getBonus(checkIndex, false); + save += getBaseCheck(checkIndex); } else if ("MISC".equals(tokens[i])) { @@ -8431,12 +8863,21 @@ * Lists all the tokens that match prefix with associated values * @param prefix * @return String + * TODO - Not sure what this is trying to do. */ public String listBonusesFor(final String prefix) { final StringBuffer buf = new StringBuffer(); final List<String> aList = new ArrayList<String>(); +// final List<TypedBonus> bonuses = theBonusMap.get(prefix); +// if ( bonuses == null ) +// { +// return Constants.EMPTY_STRING; +// } +// final List<String> bonusStrings = TypedBonus.totalBonusesByType(bonuses); +// return CoreUtility.commaDelimit(bonusStrings); + for (String aKey : getActiveBonusMap().keySet()) { if (aKey.startsWith(prefix)) @@ -9242,7 +9683,7 @@ } } - getLanguagesList().removeAll(inTmpl.getSafeListFor(ListKey.AUTO_LANGUAGES)); // remove template languages. + languages.removeAll(inTmpl.getSafeListFor(ListKey.AUTO_LANGUAGES)); // remove template languages. templateAutoLanguages.removeAll(inTmpl.getSafeListFor(ListKey.AUTO_LANGUAGES)); // remove them from the local listing. Don't clear though in case of multiple templates. templateLanguages.removeAll(inTmpl.getLanguageBonus()); @@ -9895,12 +10336,9 @@ void addFreeLanguage(final Language aLang) { - if (!getLanguagesList().contains(aLang)) - { - getLanguagesList().add(aLang); - ++freeLangs; - setDirty(true); - } + this.languages.add(aLang); + ++freeLangs; + setDirty(true); } void addFreeLanguageKeyed(final String aKey) @@ -10671,149 +11109,6 @@ return aList; } - /** - * Used to create the Bonus HashMap from all active bonuses - * @param aBonus - * @param anObj - * - * @return a List of BONUS strings - */ - private List<String> getStringListFromBonus(final BonusObj aBonus, final PObject anObj) - { - final List<String> aList = new ArrayList<String>(); - - final String bInfoString = aBonus.getBonusInfo(); - final StringTokenizer aTok = new StringTokenizer(bInfoString, ","); - int listindex = 0; - - while (aTok.hasMoreTokens()) - { - final String bonusInfo = aTok.nextToken(); - - // Some BONUS statements use %LIST to represent - // a possible list or selection made - // Need to deconstruct for proper bonus stacking - if (anObj.getAssociatedCount() > 0) - { - // There are three forms: - // 1) has %LIST in the bonusName - // 2) has %LIST in the bonusInfo - // 3) has no %LIST at all - if (aBonus.getBonusName().indexOf("%LIST") >= 0) - { - // Must use getBonusName because it - // contains the unaltered bonusType - final String bonusName = aBonus.getBonusName(); - - for (int i = 0; i < anObj.getAssociatedCount(); ++i) - { - final StringBuffer ab = new StringBuffer(); - final String tName = CoreUtility.replaceFirst(bonusName, "%LIST", anObj.getAssociated(i)); - ab.append(tName).append('.'); - ab.append(bonusInfo); - - if (aBonus.hasTypeString()) - { - ab.append(':').append(aBonus.getTypeString()); - } - - aList.add(ab.toString().toUpperCase()); - } - } - else if (bonusInfo.indexOf("%LIST") >= 0) - { - for (int i = 0; i < anObj.getAssociatedCount(true); ++i) - { - final StringBuffer ab = new StringBuffer(); - final String tName = CoreUtility.replaceFirst(bonusInfo, "%LIST", anObj.getAssociated(i, true)); - ab.append(aBonus.getTypeOfBonus()).append('.'); - ab.append(tName); - - if (aBonus.hasTypeString()) - { - ab.append(':').append(aBonus.getTypeString()); - } - aList.add(ab.toString().toUpperCase()); - } - } - else - { - final int cnt = anObj.getAssociatedCount(); - - if (cnt <= listindex && bonusInfo.equals("LIST")) - { - continue; - } - - while (true) - { - final StringBuffer ab = new StringBuffer(); - ab.append(aBonus.getTypeOfBonus()).append('.'); - if (bonusInfo.equals("LIST")) - { - ab.append(anObj.getAssociated(listindex)); - } - else - { - ab.append(bonusInfo); - } - - if (aBonus.hasTypeString()) - { - ab.append(':').append(aBonus.getTypeString()); - } - - listindex++; - - aList.add(ab.toString().toUpperCase()); - - // If we have processed all of the entries, or if this object - // has multiple bonuses, don't add any more copies. - if (aTok.countTokens() > 0 - || listindex >= cnt - || anObj.getBonusList().size() > 1) - { - break; - } - } - } - } - else if (aBonus.hasVariable()) - { - // Some bonuses have a variable as part - // of their name, such as - // BONUS:WEAPONPROF=AbcXyz|TOHIT|3 - // so parse out the correct value - final StringBuffer ab = new StringBuffer(); - ab.append(aBonus.getTypeOfBonus()); - ab.append(aBonus.getVariable()).append('.'); - ab.append(bonusInfo); - - if (aBonus.hasTypeString()) - { - ab.append(':').append(aBonus.getTypeString()); - } - - aList.add(ab.toString().toUpperCase()); - } - else - { - final StringBuffer ab = new StringBuffer(); - ab.append(aBonus.getTypeOfBonus()).append('.'); - ab.append(bonusInfo); - - if (aBonus.hasTypeString()) - { - ab.append(':').append(aBonus.getTypeString()); - } - - aList.add(ab.toString().toUpperCase()); - } - } - - return aList; - } - private String getSubRegion(final boolean useTemplates) { String pcSubRegion = getStringFor(StringKey.SUB_REGION); @@ -11446,23 +11741,19 @@ // Possible object types include: // Campaigns // Alignment (PCAlignment) - // ArmorProf // BioSet (ageSet) // Check (PObject) // Class (PCClass) // CompanionMod // Deity // Domain (CharacterDomain) - // Equipment + // Equipment (includes EqMods) // Feat (virtual feats, auto feats) // Race - // ShieldProf // SizeAdjustment // Skill // Stat (PCStat) - // TempBonus // Template (PCTemplate) - // WeaponProf // final ArrayList<PObject> results = new ArrayList<PObject>(); @@ -11895,6 +12186,53 @@ return available; } +// private Map<String, List<TypedBonus>> buildBonusMap( final List<BonusObj> aBonusList ) +// { +// final Map<String, List<TypedBonus>> ret = new HashMap<String, List<TypedBonus>>(); +// +// final List<BonusObj> processedList = new ArrayList<BonusObj>(); +// +// for ( final BonusObj bonus : aBonusList ) +// { +// // TODO - The list should be sorted so that static bonuses come first +// // we could break out of the loop at this point. +// if (!bonus.isValueStatic()) +// { +// continue; +// } +// +// final PObject anObj = (PObject) bonus.getCreatorObject(); +// +// if (anObj == null) +// { +// continue; +// } +// +// // Keep track of which bonuses have been calculated +// processedList.add(bonus); +// +// ret.putAll(bonus.getTypedBonuses(this)); +// } +// +// // TODO - I don't understand this. The list is sorted with static +// // bonuses coming first, why not just process the list once? +// for ( final BonusObj bonus : aBonusList ) +// { +// if ( processedList.contains(bonus) ) +// { +// continue; +// } +// +// final PObject anObj = (PObject) bonus.getCreatorObject(); +// +// if (anObj == null) +// { +// continue; +// } +// processBonus(bonus, ret, aBonusList, new ArrayList<BonusObj>(), processedList); +// } +// return ret; +// } /** * Build the bonus HashMap from all active BonusObj's */ @@ -11926,7 +12264,7 @@ // Keep track of which bonuses have been calculated processedBonusList.add(bonus); - for (String bString : getStringListFromBonus(bonus, anObj)) + for (String bString : bonus.getStringListFromBonus(anObj)) { final double iBonus = bonus.getValueAsdouble(); setActiveBonusStack(iBonus, bString, getActiveBonusMap()); @@ -12174,8 +12512,9 @@ } private void calcPurchaseModeBonuses() +// private List<BonusObj> getPurchaseModeBonuses() { - GameMode gm = SettingsHandler.getGame(); + final GameMode gm = SettingsHandler.getGame(); final String purchaseMethodName = gm.getPurchaseModeMethodName(); if (gm.isPurchaseStatMode()) { @@ -12184,14 +12523,18 @@ final List<BonusObj> tempList = pbm.getActiveBonuses(); addListToActiveBonuses(tempList); +// return pbm.getActiveBonuses(); } +// return Collections.emptyList(); } private void calcTempBonuses() +// private List<BonusObj> getTempBonuses() { final List<BonusObj> tempList = getFilteredTempBonusList(); if(tempList.isEmpty()) { +// return Collections.emptyList(); return; } for (Iterator<BonusObj> tempIter = tempList.iterator(); tempIter.hasNext();) @@ -12220,6 +12563,7 @@ } } addListToActiveBonuses(tempList); +// return tempList; } private void calcTemplateBonuses() @@ -12841,7 +13185,7 @@ // do the following only if adding a level of a class for the first time if (numberOfLevels > 0) { - getLanguagesList().addAll(pcClassClone.getSafeListFor(ListKey.AUTO_LANGUAGES)); + languages.addAll(pcClassClone.getSafeListFor(ListKey.AUTO_LANGUAGES)); } } else @@ -12895,6 +13239,67 @@ //setDirty(true); } +// private void processBonus( final BonusObj aBonus, +// Map<String, List<TypedBonus>> aBonusMap, +// final List<BonusObj> aBonusList, +// final List<BonusObj> prevProcessed, +// final List<BonusObj> processed ) +// { +// // Make sure we don't get into an infinite loop - can occur due to LST coding or best guess dependancy mapping +// if (prevProcessed.contains(aBonus)) +// { +// Logging.debugPrint("Ignoring bonus loop for " + aBonus + " as it was already processed. Bonuses already processed: " + prevProcessed); //$NON-NLS-1$//$NON-NLS-2$ +// return; +// } +// prevProcessed.add(aBonus); +// +// final List<BonusObj> dependantBonuses = new ArrayList<BonusObj>(); +// +// // Go through all bonuses and check to see if they add to +// // aBonus's dependencies and have not already been processed +// for ( final BonusObj newBonus : aBonusList ) +// { +// if (processed.contains(newBonus)) +// { +// continue; +// } +// +// if (aBonus.getDependsOn(newBonus.getBonusInfo())) +// { +// dependantBonuses.add(newBonus); +// } +// } +// +// // go through all the BonusObj's that aBonus depends on +// // and process them first +// for ( final BonusObj newBonus : dependantBonuses ) +// { +// // Recursively call itself +// processBonus(newBonus, aBonusMap, aBonusList, prevProcessed, processed); +// } +// +// // Double check that it hasn't been processed yet +// if (processed.contains(aBonus)) +// { +// return; +// } +// +// // Add to processed list +// processed.add(aBonus); +// +// final PObject anObj = (PObject) aBonus.getCreatorObject(); +// +// if (anObj == null) +// { +// prevProcessed.remove(aBonus); +// return; +// } +// +// aBonusMap.putAll(aBonus.getTypedBonuses(this)); +// +// prevProcessed.remove(aBonus); +// } + /** * - Get's a list of dependencies from aBonus * - Finds all active bonuses that add to those dependencies and @@ -12956,7 +13361,7 @@ } // calculate bonus and add to activeBonusMap - for ( String bString : getStringListFromBonus(aBonus, anObj) ) + for ( String bString : aBonus.getStringListFromBonus(anObj) ) { final double iBonus = anObj.calcBonusFrom(aBonus, this, bString, this); setActiveBonusStack(iBonus, bString, getActiveBonusMap()); @@ -13138,7 +13543,7 @@ this.setPoolAmount(0); this.costPool = 0; - getLanguagesList().clear(); + languages.clear(); getAutoLanguages(); setPoolAmount(0); } @@ -13462,8 +13867,10 @@ * @param useEquip Should equipment bonuses be included? * @return The bonus to the stat. */ + @Deprecated public int getPartialStatBonusFor(String statAbbr, boolean useTemp, boolean useEquip) { +// List<BonusObj> abl = getAllActiveBonuses(); List<BonusObj> abl = getActiveBonusList(); final String prefix = "STAT." + statAbbr; Map<String, String> bonusMap = new HashMap<String, String>(); @@ -13505,7 +13912,7 @@ { // Grab the list of relevant types so that we can build up the // bonuses with the stacking rules applied. - List<String> typeList = getStringListFromBonus(bonus, (PObject) bonus.getCreatorObject()); + List<String> typeList = bonus.getStringListFromBonus((PObject) bonus.getCreatorObject()); for ( String element : typeList ) { if (element.startsWith(prefix)) @@ -14098,7 +14505,8 @@ } // if the item takes more slots, return false - if (existNum > (eSlot.getSlotCount() + (int) this.getTotalBonusTo("SLOTS", eSlot.getContainType()))) + if (existNum > (eSlot.getSlotCount() + (int) getTotalBonusTo("SLOTS", eSlot.getContainType()))) +// if (existNum > (eSlot.getSlotCount() + (int) getBonusValue("SLOTS", eSlot.getContainType()))) { return false; } @@ -15013,6 +15421,7 @@ basePool = new Float(basePool.intValue()); } double bonus = getTotalBonusTo("ABILITYPOOL", aCategory.getKeyName()); +// double bonus = getBonusValue("ABILITYPOOL", aCategory.getKeyName()); if ( aCategory.allowFractionalPool() == false ) { bonus = Math.floor(bonus); @@ -15838,6 +16247,17 @@ return AbilityUtilities.rebuildAutoAbilityList(this); } + /** + * Returns the list of automatic abilities of the specified category the + * character possesses. + * + * @param aCategory The <tt>AbilityCategory</tt> to check. + * + * @return A <tt>List</tt> of <tt>Abiltity</tt> objects. + * + * @author boomer70 + * @since 5.11.1 + */ public List<Ability> getAutomaticAbilityList(final AbilityCategory aCategory) { if ( aCategory == AbilityCategory.FEAT ) @@ -15856,7 +16276,6 @@ // if ((getRace() != null) && !PlayerCharacterUtilities.canReassignRacialFeats()) { - // TODO - Remove the pc parameter from getFeatList() final List<String> abilityKeys = getRace().getAutoAbilityList(aCategory); for ( final String key : abilityKeys ) { @@ -16006,6 +16425,8 @@ return null; } - - +// public double getBonusValue(final String aBonusType, final String aBonusName ) +// { +// return TypedBonus.totalBonuses(getBonusesTo(aBonusType, aBonusName)); +// } } Modified: Trunk/pcgen/code/src/java/pcgen/core/Race.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Race.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/core/Race.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -36,9 +36,6 @@ import pcgen.core.utils.CoreUtility; import pcgen.core.utils.MessageType; import pcgen.core.utils.ShowMessageDelegate; -import pcgen.persistence.PersistenceLayerException; -import pcgen.persistence.lst.prereq.PreParserFactory; -import pcgen.util.Logging; /** * <code>Race</code>. @@ -51,29 +48,31 @@ { private ArrayList<String> monCCSkillList = null; private ArrayList<String> monCSkillList = null; + // TODO - Why do we need a hit point map in the race? private HashMap<String, Integer> hitPointMap = new HashMap<String, Integer>(); private Integer initMod = new Integer(0); private Integer naturalAC = new Integer(0); private Integer startingAC = new Integer(10); - private String hitDieLock = ""; - private String ageString = ""; - private String bonusSkillList = ""; + private String hitDieLock = Constants.EMPTY_STRING; + private String ageString = Constants.EMPTY_STRING; + private String bonusSkillList = Constants.EMPTY_STRING; //private String face = "5 ft. by 5 ft."; private Point2D.Double face = new Point2D.Double(5, 0); - private String favoredClass = ""; - private String featList = ""; - private String heightString = ""; + private String favoredClass = Constants.EMPTY_STRING; + // TODO - ABILITYOBJECT - Remove this. + private String featList = Constants.EMPTY_STRING; + private String heightString = Constants.EMPTY_STRING; private String levelAdjustment = "0"; //now a string so that we can handle formulae - private String mFeatList = ""; + private String mFeatList = Constants.EMPTY_STRING; private String monsterClass = null; - private String size = ""; - private String weightString = ""; + private String size = Constants.EMPTY_STRING; + private String weightString = Constants.EMPTY_STRING; //private String type = "Humanoid"; private int[] hitDiceAdvancement; private boolean unlimitedAdvancement = false; - private int BAB = 0; +// private int BAB = 0; private int CR = 0; private int bonusInitialFeats = 0; private int bonusSkillsPerLevel = 0; @@ -85,7 +84,7 @@ private int legs = 2; private int monsterClassLevels = 0; private int reach = 5; - private String raceType = "None"; + private String raceType = Constants.s_NONE; private ArrayList<String> racialSubTypes = new ArrayList<String>(); private Map<AbilityCategory, List<String>> theAutoAbilities; @@ -93,25 +92,38 @@ vision = new HashMap<String, String>(); } - public void setAdvancementUnlimited(final boolean unlimitedAdvancement) + /** + * Sets this races advancement to not be limited. + * + * @param yesNo <tt>true</tt> if this race allows unlimited + * advancement. + * + * TODO - Why do we need a special flag for this? + */ + public void setAdvancementUnlimited(final boolean yesNo) { - this.unlimitedAdvancement = unlimitedAdvancement; + this.unlimitedAdvancement = yesNo; } + /** + * Checks if this race's advancement is limited. + * + * @return <tt>true</tt> if this race advances unlimitedly. + */ public boolean isAdvancementUnlimited() { return unlimitedAdvancement; } - public void setAgeString(final String aString) - { - ageString = aString; - } +// public void setAgeString(final String aString) +// { +// ageString = aString; +// } - public void setBAB(final int newBAB) - { - BAB = newBAB; - } +// public void setBAB(final int newBAB) +// { +// BAB = newBAB; +// } public void setBonusInitialFeats(final BonusObj bon) { @@ -928,7 +940,7 @@ aRace.initialSkillMultiplier = initialSkillMultiplier; aRace.levelAdjustment = levelAdjustment; aRace.CR = CR; - aRace.BAB = BAB; +// aRace.BAB = BAB; aRace.hitDice = hitDice; aRace.hitDiceSize = hitDiceSize; aRace.hitPointMap = new HashMap<String, Integer>(hitPointMap); @@ -1030,18 +1042,18 @@ int getBAB(final PlayerCharacter aPC) { - if ((aPC != null) && aPC.isMonsterDefault()) - { - // "BAB" not being used on races any more; instead using a BONUS tag. - // This will fix a bug this causes for default monsters. Bug #647163 - // sage_sam 03 Dec 2002 - if (BAB == 0) - { - BAB = (int) bonusTo("COMBAT", "BAB", aPC, aPC); - } - - return BAB; - } +// if ((aPC != null) && aPC.isMonsterDefault()) +// { +// // "BAB" not being used on races any more; instead using a BONUS tag. +// // This will fix a bug this causes for default monsters. Bug #647163 +// // sage_sam 03 Dec 2002 +// if (BAB == 0) +// { +// BAB = (int) bonusTo("COMBAT", "BAB", aPC, aPC); +// } +// +// return BAB; +// } return 0; } Modified: Trunk/pcgen/code/src/java/pcgen/core/Skill.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Skill.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/core/Skill.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -793,7 +793,7 @@ // // Do not give choice of selected bonus languages // - for ( Language lang : aPC.getLanguagesList() ) + for ( final Language lang : aPC.getLanguagesList() ) { if (!selected.contains(lang)) { @@ -815,11 +815,11 @@ lc.setPoolFlag(false); lc.setVisible(true); - aPC.getLanguagesList().clear(); - aPC.getLanguagesList().addAll(selected); + aPC.clearLanguages(); + aPC.addLanguages(selected); // Add in all choice-excluded languages - aPC.getLanguagesList().addAll(excludedLangs); + aPC.addLanguages(excludedLangs); languageSkill.clearAssociated(); // TODO Fix this to allow Language objects. for ( Iterator<?> i = lc.getSelectedList().iterator(); i.hasNext(); ) Modified: Trunk/pcgen/code/src/java/pcgen/core/bonus/Bonus.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/bonus/Bonus.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/core/bonus/Bonus.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -25,12 +25,15 @@ */ package pcgen.core.bonus; +import pcgen.core.bonus.BonusObj.StackType; import pcgen.persistence.PersistenceLayerException; import pcgen.persistence.lst.prereq.PreParserFactory; import pcgen.util.Logging; +import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; +import java.util.List; import java.util.StringTokenizer; import java.util.jar.JarFile; import java.util.jar.JarEntry; @@ -98,6 +101,80 @@ } /** + * Sorts a list of <tt>BonusObj</tt> objects so that dependant bonuses come + * after the bonuses they depend on. + * + * @param listToSort The <tt>List</tt> of bonuses to sort. + */ + public static List<BonusObj> sortBonusList(List<BonusObj> listToSort) + { + final List<BonusObj> tempList = new ArrayList<BonusObj>(); + + // 'BONUS:blah|blah|Foo' depends on + // 'BONUS:VAR|Foo|MyGoo' which depends on + // 'BONUS:VAR|MyGoo|2' + + // BONUS: type | info | value + + // BONUS:COMBAT |TOHIT |STR + // BONUS:STAT |STR |rage + // BONUS:VAR |rage |2 + + for ( final BonusObj bonus : listToSort ) + { + int iFound = 0; + for (int ii = 0; ii < tempList.size(); ii++) + { + final BonusObj tempBonus = tempList.get(ii); + if (tempBonus.getDependsOn(bonus.getBonusInfo())) + { + iFound = ii; + } + } + tempList.add(iFound, bonus); + } + + int iCount = tempList.size(); + for (int i = 0; i < iCount; ) + { + final BonusObj bonus = tempList.get(i); + // + // Move to end of list + // + if (bonus.getDependsOn("JEPFORMULA")) //$NON-NLS-1$ + { + tempList.remove(i); + tempList.add(bonus); + --iCount; + } + else + { + ++i; + } + } + + listToSort = tempList; + + tempList.clear(); + + // go through and move all the static bonuses to the front + final int aSize = listToSort.size(); + for (int i = 0; i < aSize; i++) + { + final BonusObj bonus = listToSort.get(i); + if (bonus.isValueStatic()) + { + tempList.add(0, bonus); + } + else + { + tempList.add(bonus); + } + } + return tempList; + } + + /** * Create a new Bonus * @param bonusString * @return BonusObj @@ -202,7 +279,26 @@ } else if (aString.startsWith("TYPE=") || aString.startsWith("TYPE.")) { - final boolean result = aBonus.addType(aString.substring(5)); + String bonusType = aString.substring(5).toUpperCase(); + if ( bonusType.indexOf('.') != -1 ) + { + final String[] splits = bonusType.split("\\."); + final String stackingFlag = splits[1]; + // TODO - Need to reset bonusType to exclude this but + // there is too much dependancy on it being there + // built into the code. + if ( stackingFlag.equals("REPLACE") ) //$NON-NLS-1$ + { + aBonus.setStackingFlag( StackType.REPLACE ); +// bonusType = splits[0]; + } + else if ( stackingFlag.equals("STACK") ) //$NON-NLS-1$ + { + aBonus.setStackingFlag( StackType.STACK ); +// bonusType = splits[0]; + } + } + final boolean result = aBonus.addType(bonusType); if (!result) { Modified: Trunk/pcgen/code/src/java/pcgen/core/bonus/BonusObj.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/bonus/BonusObj.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/core/bonus/BonusObj.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -25,6 +25,15 @@ */ package pcgen.core.bonus; +import java.io.Serializable; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; + +import pcgen.core.Constants; import pcgen.core.Equipment; import pcgen.core.PObject; import pcgen.core.PlayerCharacter; @@ -35,10 +44,6 @@ import pcgen.util.Delta; import pcgen.util.Logging; -import java.io.Serializable; -import java.io.StringWriter; -import java.util.*; - /** * <code>BonusObj</code> * @@ -52,18 +57,43 @@ private Object bonusValue; private Object creatorObj; private Object targetObj; - private String bonusName = ""; - private String bonusType = ""; - private String varPart = ""; + /** The name of the bonus e.g. STAT or COMBAT */ + private String bonusName = Constants.EMPTY_STRING; + /** The type of the bonus e.g. Enhancement or Dodge */ + private String bonusType = Constants.EMPTY_STRING; + private String varPart = Constants.EMPTY_STRING; private boolean isApplied; private boolean valueIsStatic = true; private int pcLevel = -1; private int typeOfBonus = Bonus.BONUS_UNDEFINED; private String stringRepresentation; + /** An enum for the possible stacking modifiers a bonus can have */ + public enum StackType { + /** This bonus will follow the normal stacking rules. */ + NORMAL, + /** This bonus will always stack regardless of its type. */ + STACK, + /** + * This bonus will stack with other bonuses of its own type but not + * with bonuses of other types. + */ + REPLACE + }; + private StackType theStackingFlag = StackType.NORMAL; + + private static final String LIST_TOKEN_REPLACEMENT = "%LIST"; //$NON-NLS-1$ + private static final String VALUE_TOKEN_REPLACEMENT = "LIST"; //$NON-NLS-1$ + /** - * Set Applied - * @param aBool + * Sets the Applied flag on the bonus. + * + * <p><b>Note</b>: This flag is not used in the bonus object. Therefore, + * what being applied means is up to the setter and getter of the flag. + * + * <p>TODO - This method does not belong here. + * + * @param aBool <tt>true</tt> to mark this bonus as "applied" */ public void setApplied(final boolean aBool) { @@ -71,8 +101,11 @@ } /** - * isApplied - * @return True if applied + * Returns the state of the Applied flag. + * + * @return <tt>true</tt> if the applied flag is set. + * + * @see #setApplied(boolean) */ public boolean isApplied() { @@ -773,6 +806,26 @@ return false; } + /** + * Sets the stacking flag for this bonus. + * + * @param aFlag A <tt>StackType</tt> to set. + */ + public void setStackingFlag( final StackType aFlag ) + { + theStackingFlag = aFlag; + } + + /** + * Gets the stacking flag for this bonus. + * + * @return A <tt>StackType</tt>. + */ + public StackType getStackingFlag() + { + return theStackingFlag; + } + protected boolean parseToken(final String token) { System.err.println("Need to override parseToken in " + getClass().getName()); @@ -953,4 +1006,326 @@ } } +// // TODO - Why do we need to do this processing all the time. +// // It should be possible to parse almost all this stuff out once. +// public Map<String, List<TypedBonus>> getTypedBonuses(final PlayerCharacter aPC) +// { +// final Map<String, List<TypedBonus>> ret = new HashMap<String, List<TypedBonus>>(); +// +// // TODO - Can any other object type be a creator? The code elsewhere +// // seems to assume not, but then why isn't creator object a PObject? +// if ( getCreatorObject() == null || ! (getCreatorObject() instanceof PObject) ) +// { +// return Collections.emptyMap(); +// } +// final PObject pObj = (PObject)getCreatorObject(); +// +// int listindex = 0; // Counter for number of replacements we have done +// +// // We may have a bonus something like +// // BONUS:SKILL|Hide,Move Silently|2 +// // This needs to become two independant bonuses for processing purposes. +// final String bInfoString = getBonusInfo(); +// final StringTokenizer aTok = new StringTokenizer(bInfoString, ","); +// +// while (aTok.hasMoreTokens()) +// { +// String info = aTok.nextToken(); +// +// final TypedBonus.StackType stackType; +// if ( info.endsWith(".STACK") || info.endsWith(".REPLACE") ) +// { +// info = info.substring( 0, info.lastIndexOf('.') ); +// if ( info.endsWith(".STACK") ) +// { +// stackType = TypedBonus.StackType.STACK; +// } +// else +// { +// stackType = TypedBonus.StackType.REPLACE; +// } +// } +// else +// { +// stackType = TypedBonus.StackType.NORMAL; +// } +// +// if (pObj.getAssociatedCount() > 0) +// { +// final String name = getBonusName(); +// if (name.indexOf(LIST_TOKEN_REPLACEMENT) >= 0) +// { +// // BONUS:%LIST|Foo|1 +// for (int i = 0; i < pObj.getAssociatedCount(); ++i) +// { +// final StringBuffer ab = new StringBuffer(); +// final String tName = CoreUtility.replaceFirst(name, LIST_TOKEN_REPLACEMENT, pObj.getAssociated(i)); +// ab.append(tName).append('.'); +// ab.append(info); +// +// final String key = ab.toString().toUpperCase(); +// final TypedBonus typedBonus = new TypedBonus(getCalculatedValue(aPC), key, stackType); +// List<TypedBonus> bonusList = ret.get(key); +// if ( bonusList == null ) +// { +// bonusList = new ArrayList<TypedBonus>(); +// ret.put(key, bonusList); +// } +// bonusList.add(typedBonus); +// } +// } +// else if (info.indexOf(LIST_TOKEN_REPLACEMENT) >= 0) +// { +// // BONUS:FOO|%LIST|1 +// for (int i = 0; i < pObj.getAssociatedCount(true); ++i) +// { +// final StringBuffer ab = new StringBuffer(); +// final String tName = CoreUtility.replaceFirst(info, LIST_TOKEN_REPLACEMENT, pObj.getAssociated(i, true)); +// ab.append(getTypeOfBonus()).append('.'); +// ab.append(tName); +// +// final String key = ab.toString().toUpperCase(); +// final TypedBonus typedBonus = new TypedBonus(getCalculatedValue(aPC), key, stackType); +// List<TypedBonus> bonusList = ret.get(key); +// if ( bonusList == null ) +// { +// bonusList = new ArrayList<TypedBonus>(); +// ret.put(key, bonusList); +// } +// bonusList.add(typedBonus); +// } +// } +// else +// { +// final int cnt = pObj.getAssociatedCount(); +// +// if (cnt <= listindex && info.equals(VALUE_TOKEN_REPLACEMENT)) +// { +// continue; +// } +// +// while (true) +// { +// final StringBuffer ab = new StringBuffer(); +// ab.append(getTypeOfBonus()).append('.'); +// if (info.equals(VALUE_TOKEN_REPLACEMENT)) +// { +// ab.append(pObj.getAssociated(listindex)); +// } +// else +// { +// ab.append(info); +// } +// +// listindex++; +// +// final String key = ab.toString().toUpperCase(); +// final TypedBonus typedBonus = new TypedBonus(getCalculatedValue(aPC), key, stackType); +// List<TypedBonus> bonusList = ret.get(key); +// if ( bonusList == null ) +// { +// bonusList = new ArrayList<TypedBonus>(); +// ret.put(key, bonusList); +// } +// bonusList.add(typedBonus); +// +// // If we have processed all of the entries, or if this object +// // has multiple bonuses, don't add any more copies. +// if (aTok.countTokens() > 0 +// || listindex >= cnt +// || pObj.getBonusList().size() > 1) +// { +// break; +// } +// } +// } +// } +// else if (hasVariable()) +// { +// // Some bonuses have a variable as part +// // of their name, such as +// // BONUS:WEAPONPROF=AbcXyz|TOHIT|3 +// // so parse out the correct value +// final StringBuffer ab = new StringBuffer(); +// ab.append(getTypeOfBonus()); +// ab.append(getVariable()).append('.'); +// ab.append(info); +// +// final String key = ab.toString().toUpperCase(); +// final TypedBonus typedBonus = new TypedBonus(getCalculatedValue(aPC), key, stackType); +// List<TypedBonus> bonusList = ret.get(key); +// if ( bonusList == null ) +// { +// bonusList = new ArrayList<TypedBonus>(); +// ret.put(key, bonusList); +// } +// bonusList.add(typedBonus); +// } +// else +// { +// final StringBuffer ab = new StringBuffer(); +// ab.append(getTypeOfBonus()).append('.'); +// ab.append(info); +// +// final String key = ab.toString().toUpperCase(); +// final TypedBonus typedBonus = new TypedBonus(getCalculatedValue(aPC), key, stackType); +// List<TypedBonus> bonusList = ret.get(key); +// if ( bonusList == null ) +// { +// bonusList = new ArrayList<TypedBonus>(); +// ret.put(key, bonusList); +// } +// bonusList.add(typedBonus); +// } +// } +// return ret; +// } + + /** + * TODO - This method should be changed to not return a string. + * <p> + * This method builds a string of the form: + * <code>BONUSNAME.BONUSTYPE:TYPEOFBONUS </code> + * + * @param anObj The bonus owner. + * + * @return List of bonus strings + */ + public List<String> getStringListFromBonus(final PObject anObj) + { + final List<String> aList = new ArrayList<String>(); + + final String bInfoString = getBonusInfo(); + final StringTokenizer aTok = new StringTokenizer(bInfoString, ","); + int listindex = 0; + + while (aTok.hasMoreTokens()) + { + final String info = aTok.nextToken(); + + // Some BONUS statements use %LIST to represent + // a possible list or selection made + // Need to deconstruct for proper bonus stacking + if (anObj.getAssociatedCount() > 0) + { + // There are three forms: + // 1) has %LIST in the bonusName + // 2) has %LIST in the bonusInfo + // 3) has no %LIST at all + + + // Must use getBonusName because it + // contains the unaltered bonusType + final String name = getBonusName(); + if (name.indexOf(LIST_TOKEN_REPLACEMENT) >= 0) + { + for (int i = 0; i < anObj.getAssociatedCount(); ++i) + { + final StringBuffer ab = new StringBuffer(); + final String tName = CoreUtility.replaceFirst(name, LIST_TOKEN_REPLACEMENT, anObj.getAssociated(i)); + ab.append(tName).append('.'); + ab.append(info); + + if (hasTypeString()) + { + ab.append(':').append(getTypeString()); + } + + aList.add(ab.toString().toUpperCase()); + } + } + else if (info.indexOf(LIST_TOKEN_REPLACEMENT) >= 0) + { + for (int i = 0; i < anObj.getAssociatedCount(true); ++i) + { + final StringBuffer ab = new StringBuffer(); + final String tName = CoreUtility.replaceFirst(info, LIST_TOKEN_REPLACEMENT, anObj.getAssociated(i, true)); + ab.append(getTypeOfBonus()).append('.'); + ab.append(tName); + + if (hasTypeString()) + { + ab.append(':').append(getTypeString()); + } + aList.add(ab.toString().toUpperCase()); + } + } + else + { + final int cnt = anObj.getAssociatedCount(); + + if (cnt <= listindex && info.equals(VALUE_TOKEN_REPLACEMENT)) + { + continue; + } + + while (true) + { + final StringBuffer ab = new StringBuffer(); + ab.append(getTypeOfBonus()).append('.'); + if (info.equals(VALUE_TOKEN_REPLACEMENT)) + { + ab.append(anObj.getAssociated(listindex)); + } + else + { + ab.append(info); + } + + if (hasTypeString()) + { + ab.append(':').append(getTypeString()); + } + + listindex++; + + aList.add(ab.toString().toUpperCase()); + + // If we have processed all of the entries, or if this object + // has multiple bonuses, don't add any more copies. + if (aTok.countTokens() > 0 + || listindex >= cnt + || anObj.getBonusList().size() > 1) + { + break; + } + } + } + } + else if (hasVariable()) + { + // Some bonuses have a variable as part + // of their name, such as + // BONUS:WEAPONPROF=AbcXyz|TOHIT|3 + // so parse out the correct value + final StringBuffer ab = new StringBuffer(); + ab.append(getTypeOfBonus()); + ab.append(getVariable()).append('.'); + ab.append(info); + + if (hasTypeString()) + { + ab.append(':').append(getTypeString()); + } + + aList.add(ab.toString().toUpperCase()); + } + else + { + final StringBuffer ab = new StringBuffer(); + ab.append(getTypeOfBonus()).append('.'); + ab.append(info); + + if (hasTypeString()) + { + ab.append(':').append(getTypeString()); + } + + aList.add(ab.toString().toUpperCase()); + } + } + + return aList; + } + } Modified: Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2006-09-19 04:20:38 UTC (rev 1404) @@ -3028,6 +3028,7 @@ Errors.FollowerModel.UnknownColumn=The column {0} not handled in {1} Warnings.LstTokens.Deprecated={0} deprecated. Tag was {1} in {2} of {3}. {4} +Warnings.LstTokens.Deprecated.BabToken=Use BONUS:COMBAT|BAB|formula instead. in_plusSign=+ in_caretSymbol=^ Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoClasses.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoClasses.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoClasses.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -1418,7 +1418,7 @@ { final PObject obj = checkList.get(i); lblCheck[i].setText(obj.getDisplayName()); - lCheck[i].setText(Delta.toString((int) pc.getBonus(i + 1, true))); + lCheck[i].setText(Delta.toString(pc.getTotalCheck(i))); } } } Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoResources.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoResources.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoResources.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -1003,7 +1003,7 @@ for (int z = 0; z < SettingsHandler.getGame().getUnmodifiableCheckList().size(); z++) { - bonus = (int) newPC.getBonus(z + 1, true); + bonus = newPC.getTotalCheck(z); 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$ } Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSpecialAbilities.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -496,9 +496,9 @@ } } - pc.getLanguagesList().clear(); - pc.getLanguagesList().addAll(selLangs); - pc.getLanguagesList().addAll(excludedLangs); + pc.clearLanguages(); + pc.addLanguages(selLangs); + pc.addLanguages(excludedLangs); refresh(); ensureFocus(); } Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSummary.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSummary.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoSummary.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -1012,7 +1012,7 @@ statBuf.append("<br>"); //$NON-NLS-1$ statBuf.append("<b>").append(PropertyFactory.getString("in_sumSaves")).append("</b>: "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } - bonus = (int) pc.getBonus(z + 1, true); + bonus = pc.getTotalCheck(z); statBuf.append(" <i>").append(SettingsHandler.getGame().getUnmodifiableCheckList().get(z).toString()) //$NON-NLS-1$ .append("</i>: ").append(Delta.toString(bonus)); //$NON-NLS-1$ } Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityModel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityModel.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/ability/AbilityModel.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -42,6 +42,7 @@ import pcgen.gui.utils.TreeTableModel; import pcgen.util.Logging; import pcgen.util.PropertyFactory; +import pcgen.util.enumeration.Visibility; /** * Extends AbstractTreeTableModel to build an available or @@ -116,7 +117,8 @@ // We will use the global lists for this for ( final Ability ability : Globals.getAbilityList(theCategory) ) { - if ( theFilter != null && theFilter.accept(theViewMode, ability) == false ) + if (!((ability.getVisibility() == Visibility.DEFAULT) + || (ability.getVisibility() == Visibility.DISPLAY_ONLY))) { continue; } @@ -146,6 +148,7 @@ ccSources[i] = new PObjectNode(); ccSources[i].setItem(source); ccSources[i].setParent(sourceRoot); + i++; } sourceRoot.setChildren(ccSources); @@ -515,6 +518,10 @@ */ private void buildTreeTypeName(final boolean showAll) { + if ( typeRoot == null ) + { + return; + } setRoot(typeRoot); final PObjectNode rootAsPObjectNode = (PObjectNode) super.getRoot(); @@ -567,6 +574,10 @@ */ private void buildTreeSourceName(final boolean showAll) { + if ( sourceRoot == null ) + { + return; + } setRoot(sourceRoot); final PObjectNode rootAsPObjectNode = (PObjectNode) super.getRoot(); @@ -726,7 +737,10 @@ break; } - fireTreeNodesChanged(super.getRoot(), new TreePath(super.getRoot())); + if (super.getRoot() != null ) + { + fireTreeNodesChanged(super.getRoot(), new TreePath(super.getRoot())); + } } /** Deleted: Trunk/pcgen/code/src/java/pcgen/persistence/lst/Deprecated.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/Deprecated.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/Deprecated.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -1,26 +0,0 @@ -/* - * Created on Sep 2, 2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ - -package pcgen.persistence.lst; - -import pcgen.core.PObject; - - -/** - * @author djones4 - */ - -public interface Deprecated { - - /** - * Get the message - * @param obj - * @param value - * @return message - */ - public String getMessage(PObject obj, String value); -} Added: Trunk/pcgen/code/src/java/pcgen/persistence/lst/DeprecatedToken.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/DeprecatedToken.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/DeprecatedToken.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -0,0 +1,29 @@ +/* + * Created on Sep 2, 2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ + +package pcgen.persistence.lst; + +import pcgen.core.PObject; + + +/** + * @author djones4 + */ + +public interface DeprecatedToken { + + /** + * Get the message to output. + * + * @param obj The object being built when the deprecated token was encountered. + * @param value The value of the deprecated token. + * + * @return A message to display to the user about why the token was deprecated + * and how they can fix it. This message should be i18n. + */ + public String getMessage(PObject obj, String value); +} Property changes on: Trunk/pcgen/code/src/java/pcgen/persistence/lst/DeprecatedToken.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstUtils.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstUtils.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstUtils.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -44,7 +44,7 @@ * @param value */ public static void deprecationCheck(LstToken token, PObject obj, String value) { - if(token instanceof Deprecated) + if(token instanceof DeprecatedToken) { final String msg = PropertyFactory.getFormattedString( "Warnings.LstTokens.Deprecated", //$NON-NLS-1$ @@ -52,7 +52,7 @@ value, obj.getDisplayName(), obj.getDefaultSourceString(), - ((Deprecated)token).getMessage(obj, value) + ((DeprecatedToken)token).getMessage(obj, value) ); deprecationWarning(msg); } @@ -66,7 +66,7 @@ * @param value */ public static void deprecationCheck(LstToken token, String name, String source, String value) { - if(token instanceof Deprecated) + if(token instanceof DeprecatedToken) { final String msg = PropertyFactory.getFormattedString( "Warnings.LstTokens.Deprecated", //$NON-NLS-1$ @@ -74,7 +74,7 @@ value, name, source, - ((Deprecated)token).getMessage(null, value) + ((DeprecatedToken)token).getMessage(null, value) ); deprecationWarning( msg ); } Modified: Trunk/pcgen/code/src/java/pcgen/util/Delta.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/util/Delta.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/pcgen/util/Delta.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -98,18 +98,21 @@ } /** - * toString - * @param v - * @return String + * Returns a String representation of an integer value. If the value is + * positive a plus sign (+) will be prepended. + * + * @param v An integer to convert. + * + * @return String value of integer. */ - public static String toString(int v) + public static String toString(final int v) { if (v >= 0) { return "+" + v; } - return v + ""; + return String.valueOf(v); } /** Added: Trunk/pcgen/code/src/java/plugin/bonustokens/AbilityPool.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/bonustokens/AbilityPool.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/bonustokens/AbilityPool.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -0,0 +1,81 @@ +/* + * AbilityPool.java + * Copyright 2006 (C) Aaron Divinsky <boomer70@...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: nuance $ + * Last Edited: $Date$ + * + */ +package plugin.bonustokens; + +import java.util.Collection; + +import pcgen.core.AbilityCategory; +import pcgen.core.SettingsHandler; +import pcgen.core.bonus.BonusObj; + + +/** + * Handles <code>BONUS:ABILITYPOOL|<ability category>|<number> + * </code> token + * + * @author boomer70 <boomer70@...> + * + * @since 5.11.1 + */ +public final class AbilityPool extends BonusObj +{ + private static final String[] bonusHandled = + { + "ABILITYPOOL" //$NON-NLS-1$ + }; + + /** + * @see pcgen.core.bonus.BonusObj#parseToken(java.lang.String) + */ + @Override + protected boolean parseToken(final String token) + { + final AbilityCategory cat = SettingsHandler.getGame().getAbilityCategory(token); + if ( cat != null ) + { + addBonusInfo(token); + return true; + } + + return false; + } + + /** + * @see pcgen.core.bonus.BonusObj#unparseToken(java.lang.Object) + */ + @Override + protected String unparseToken(final Object obj) + { + return (String) obj; + } + + /** + * @see pcgen.core.bonus.BonusObj#getBonusesHandled() + */ + @Override + protected String[] getBonusesHandled() + { + return bonusHandled; + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/bonustokens/AbilityPool.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/java/plugin/exporttokens/BonusListToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/BonusListToken.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/BonusListToken.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -26,10 +26,12 @@ package plugin.exporttokens; import pcgen.core.PlayerCharacter; +import pcgen.core.bonus.TypedBonus; import pcgen.io.ExportHandler; import pcgen.io.exporttoken.Token; import java.util.Iterator; +import java.util.List; import java.util.StringTokenizer; /** @@ -99,6 +101,7 @@ if ("TOTAL".equals(typeSeparator)) { + // TODO - Shouldn't this return retString? retString += total; return ""; @@ -106,6 +109,18 @@ boolean needDelim = false; String prefix = bonusString + "." + substring + "."; + +// final List<String> bonuses = TypedBonus.totalBonusesByType( pc.getBonusesTo(bonusString, substring)); +// for ( final String str : bonuses ) +// { +// if ( needDelim ) +// { +// retString += delim; +// } +// +// retString += str; +// needDelim = true; +// } for (Iterator bi = pc.getActiveBonusMap().keySet().iterator(); bi.hasNext();) { Added: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/BabToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/BabToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/BabToken.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -0,0 +1,51 @@ +package plugin.lsttokens.deprecated; + +import pcgen.core.PObject; +import pcgen.core.Race; +import pcgen.core.bonus.Bonus; +import pcgen.core.bonus.BonusObj; +import pcgen.persistence.lst.DeprecatedToken; +import pcgen.persistence.lst.RaceLstToken; +import pcgen.util.PropertyFactory; + +/** + * Class deals with BAB Token + */ +public class BabToken implements RaceLstToken, DeprecatedToken +{ + /** + * @see pcgen.persistence.lst.LstToken#getTokenName() + */ + public String getTokenName() + { + return "BAB"; //$NON-NLS-1$ + } + + /** + * @see pcgen.persistence.lst.RaceLstToken#parse(pcgen.core.Race, java.lang.String) + */ + public boolean parse(Race race, String value) + { + try + { + final int bonus = Integer.parseInt(value); + final BonusObj babBonus = Bonus.newBonus( "BONUS:COMBAT|BAB|" + bonus ); //$NON-NLS-1$ + babBonus.setCreatorObject(race); + race.addBonusList(babBonus); + return true; + } + catch(NumberFormatException nfe) + { + 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("Warnings.LstTokens.Deprecated.BabToken"); //$NON-NLS-1$ + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/BabToken.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/GameToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/GameToken.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/GameToken.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -3,14 +3,14 @@ import pcgen.core.Campaign; import pcgen.core.PObject; import pcgen.persistence.lst.CampaignLstToken; -import pcgen.persistence.lst.Deprecated; +import pcgen.persistence.lst.DeprecatedToken; import java.net.URL; /** * Class deals with GAME Token */ -public class GameToken implements CampaignLstToken, Deprecated { +public class GameToken implements CampaignLstToken, DeprecatedToken { public String getTokenName() { return "GAME"; Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/LicensedToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/LicensedToken.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/LicensedToken.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -3,14 +3,14 @@ import pcgen.core.Campaign; import pcgen.core.PObject; import pcgen.persistence.lst.CampaignLstToken; -import pcgen.persistence.lst.Deprecated; +import pcgen.persistence.lst.DeprecatedToken; import java.net.URL; /** * Class deals with LICENSED Token */ -public class LicensedToken implements CampaignLstToken, Deprecated { +public class LicensedToken implements CampaignLstToken, DeprecatedToken { public String getTokenName() { return "LICENSED"; Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SourceLst.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SourceLst.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SourceLst.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -10,17 +10,17 @@ import pcgen.persistence.lst.GlobalLstToken; import pcgen.persistence.lst.SourceLoader; import pcgen.persistence.lst.SourceLstToken; -import pcgen.persistence.lst.Deprecated; +import pcgen.persistence.lst.DeprecatedToken; import pcgen.util.PropertyFactory; /** * @author djones4 * - * Deprecated. Seems to be used as a SOURCEPAGE tag. + * DeprecatedToken. Seems to be used as a SOURCEPAGE tag. * */ -public class SourceLst implements GlobalLstToken, SourceLstToken, Deprecated { +public class SourceLst implements GlobalLstToken, SourceLstToken, DeprecatedToken { public String getTokenName() { return "SOURCE"; @@ -37,11 +37,11 @@ } /** - * @see pcgen.persistence.lst.Deprecated#getMessage(pcgen.core.PObject, java.lang.String) + * @see pcgen.persistence.lst.DeprecatedToken#getMessage(pcgen.core.PObject, java.lang.String) */ public String getMessage(PObject anObj, String anValue) { - return PropertyFactory.getString( "Deprecated.SourceLst.Message" ); //$NON-NLS-1$ + return PropertyFactory.getString( "DeprecatedToken.SourceLst.Message" ); //$NON-NLS-1$ } } Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SpellLst.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SpellLst.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SpellLst.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -5,7 +5,7 @@ package plugin.lsttokens.deprecated; import pcgen.core.PObject; import pcgen.persistence.PersistenceLayerException; -import pcgen.persistence.lst.Deprecated; +import pcgen.persistence.lst.DeprecatedToken; import pcgen.persistence.lst.GlobalLstToken; import pcgen.persistence.lst.prereq.PreParserFactory; import pcgen.util.Logging; @@ -19,7 +19,7 @@ * @author djones4 * */ -public class SpellLst implements GlobalLstToken, Deprecated { +public class SpellLst implements GlobalLstToken, DeprecatedToken { public String getTokenName() { return "SPELL"; Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/race/BabToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/race/BabToken.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/race/BabToken.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -1,24 +0,0 @@ -package plugin.lsttokens.race; - -import pcgen.core.Race; -import pcgen.persistence.lst.RaceLstToken; - -/** - * Class deals with BAB Token - */ -public class BabToken implements RaceLstToken { - - public String getTokenName() { - return "BAB"; - } - - public boolean parse(Race race, String value) { - try { - race.setBAB(Integer.parseInt(value)); - return true; - } - catch(NumberFormatException nfe) { - return false; - } - } -} Modified: Trunk/pcgen/code/src/java/plugin/pretokens/test/PreCheckBaseTester.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/pretokens/test/PreCheckBaseTester.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/plugin/pretokens/test/PreCheckBaseTester.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -58,7 +58,7 @@ final int operand = character.getVariableValue(prereq.getOperand(), "").intValue(); //$NON-NLS-1$ final int characterCheckVal = SettingsHandler.getGame().getIndexOfCheck(checkName); if (characterCheckVal>=0) { - final int characterCheckBonus = (int) character.getBonus(characterCheckVal + 1, false); + final int characterCheckBonus = character.getBaseCheck(characterCheckVal); runningTotal = prereq.getOperator().compare(characterCheckBonus, operand) > 0 ? 1 : 0; } return countedTotal(prereq, runningTotal); Modified: Trunk/pcgen/code/src/java/plugin/pretokens/test/PreCheckTester.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/pretokens/test/PreCheckTester.java 2006-09-18 04:06:55 UTC (rev 1403) +++ Trunk/pcgen/code/src/java/plugin/pretokens/test/PreCheckTester.java 2006-09-19 04:20:38 UTC (rev 1404) @@ -42,7 +42,7 @@ final int operand = character.getVariableValue(prereq.getOperand(), "").intValue(); //$NON-NLS-1$ final int characterCheckVal = SettingsHandler.getGame().getIndexOfCheck(checkName); if (characterCheckVal>=0) { - final int characterCheckBonus = (int) character.getBonus(characterCheckVal + 1, true); + final int characterCheckBonus = character.getTotalCheck(characterCheckVal); runningTotal = prereq.getOperator().compare(characterCheckBonus, operand) > 0 ? 1 : 0; } return countedTotal(prereq, runningTotal); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jdempsey@us...> - 2006-10-16 22:11:04
|
Revision: 1482 http://svn.sourceforge.net/pcgen/?rev=1482&view=rev Author: jdempsey Date: 2006-10-16 15:10:37 -0700 (Mon, 16 Oct 2006) Log Message: ----------- FReq #1578536 - New Output Tag - TEXT Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/exporttokens/TextToken.java Trunk/pcgen/code/src/test/pcgen/io/exporttoken/TextTokenTest.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-10-15 12:19:52 UTC (rev 1481) +++ Trunk/pcgen/code/pluginbuild.xml 2006-10-16 22:10:37 UTC (rev 1482) @@ -828,6 +828,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${outputplugins.dir}/ExportToken-TEXT.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/exporttokens/TextToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${outputplugins.dir}/ExportToken-TOTALLEVELS.jar" manifest="${src.java.dir}/plugin/exporttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Added: Trunk/pcgen/code/src/java/plugin/exporttokens/TextToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/TextToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/TextToken.java 2006-10-16 22:10:37 UTC (rev 1482) @@ -0,0 +1,128 @@ +/* + * TextToken.java + * Copyright 2006 (C) James Dempsey <jdempsey@...> + * + * 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 October 15, 2003, 10:23 PM + * + * Current Ver: $Revision: 199 $ + * Last Editor: $Author: nuance $ + * Last Edited: $Date: 2006-03-15 10:11:06 +1100 (Wed, 15 Mar 2006) $ + * + */ +package plugin.exporttokens; + +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.StringWriter; +import java.util.StringTokenizer; + +import pcgen.core.PlayerCharacter; +import pcgen.io.ExportHandler; +import pcgen.io.exporttoken.Token; +import pcgen.util.Logging; + +/** + * <code>TextToken</code> produces the output for the output token TEXT. + * Possible tag formats are:<pre> + * TEXT.x.y + * </pre> + * Where x is the action and y is the export tag to be processed. + */ +public class TextToken extends Token +{ + /** Token Name */ + public static final String TOKENNAME = "TEXT"; + + /** + * @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) + { + String retString = ""; + + StringTokenizer aTok = new StringTokenizer(tokenSource, "."); + aTok.nextToken(); //this should be VAR + + String action = ""; + String varName = ""; + if (aTok.hasMoreElements()) + { + action = aTok.nextToken(); + } + if (aTok.hasMoreElements()) + { + varName = aTok.nextToken(); + } + while (aTok.hasMoreElements()) + { + varName += "." + aTok.nextToken(); + } + + StringWriter writer = new StringWriter(); + BufferedWriter bw = new BufferedWriter(writer); + eh.replaceToken(varName, bw, pc); + try + { + bw.flush(); + } + catch (IOException e) + { + e.printStackTrace(); + } + retString = writer.getBuffer().toString(); + + if (action.equalsIgnoreCase("UPPER") + || action.equalsIgnoreCase("UPPERCASE")) + { + retString = retString.toUpperCase(); + } + else if (action.equalsIgnoreCase("LOWER") + || action.equalsIgnoreCase("LOWERCASE")) + { + retString = retString.toLowerCase(); + } + else if (action.equalsIgnoreCase("NUMSUFFIX")) + { + int intVal = Integer.parseInt(retString); + if (intVal % 10 == 1 && intVal % 100 != 11) + { + retString = "st"; + } + else if (intVal % 10 == 2 && intVal % 100 != 12) + { + retString = "nd"; + } + else if (intVal % 10 == 3 && intVal % 100 != 13) + { + retString = "rd"; + } + else + { + retString = "th"; + } + } + return retString; + } +} Property changes on: Trunk/pcgen/code/src/java/plugin/exporttokens/TextToken.java ___________________________________________________________________ Name: keywords + "Author Revision Date Id" Name: svn:eol-style + native Added: Trunk/pcgen/code/src/test/pcgen/io/exporttoken/TextTokenTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/io/exporttoken/TextTokenTest.java (rev 0) +++ Trunk/pcgen/code/src/test/pcgen/io/exporttoken/TextTokenTest.java 2006-10-16 22:10:37 UTC (rev 1482) @@ -0,0 +1,160 @@ +/* + * TextTokenTest.java + * Copyright 2006 (C) James Dempsey <jdempsey@...> + * + * 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: VarTokenTest.java 201 2006-03-14 23:19:50Z nuance $ + * + */ +package pcgen.io.exporttoken; + +import junit.framework.Test; +import junit.framework.TestSuite; +import pcgen.AbstractCharacterTestCase; +import pcgen.core.PlayerCharacter; +import pcgen.io.ExportHandler; +import plugin.exporttokens.TextToken; + +/** + * <code>TextTokenTest</code> tests the functioning of the TEXT + * token processing code. + * + * Last Editor: $Author: nuance $ + * Last Edited: $Date: 2006-03-15 10:19:50 +1100 (Wed, 15 Mar 2006) $ + * + * @author James Dempsey <jdempsey@...> + * @version $Revision: 201 $ + */ +public class TextTokenTest extends AbstractCharacterTestCase +{ + + /** + * Quick test suite creation - adds all methods beginning with "test" + * @return The Test suite + */ + public static Test suite() + { + return new TestSuite(TextTokenTest.class); + } + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + PlayerCharacter character = getCharacter(); + character.setName("The Vitamins are in my Fresh Brussels Sprouts"); + } + + /** + * Test the output for positive numbers with fractions. + */ + public void testTextFormatting() + { + TextToken tok = new TextToken(); + ExportHandler eh = new ExportHandler(null); + + assertEquals("TEXT.LOWER.NAME", + "the vitamins are in my fresh brussels sprouts", tok + .getToken("TEXT.LOWER.NAME", getCharacter(), eh)); + assertEquals("TEXT.UPPER.NAME", + "THE VITAMINS ARE IN MY FRESH BRUSSELS SPROUTS", tok + .getToken("TEXT.UPPER.NAME", getCharacter(), eh)); +// assertEquals("TEXT.SENTANCE.NAME", +// "The vitamins are in my fresh brussels sprouts", tok +// .getToken("TEXT.SENTANCE.NAME", getCharacter(), eh)); +// assertEquals("TEXT.TITLE.NAME", +// "The Vitamins Are In My Fresh Brussels Sprouts", tok +// .getToken("TEXT.TITLE.NAME", getCharacter(), eh)); + } + + /** + * Test the output for negative numbers with fractions. + */ + public void testNumSuffix() + { + TextToken tok = new TextToken(); + ExportHandler eh = new ExportHandler(null); + PlayerCharacter character = getCharacter(); + + character.setAge(1); + assertEquals("Suffix 1", "st", tok.getToken("TEXT.NUMSUFFIX.AGE", + getCharacter(), eh)); + character.setAge(2); + assertEquals("Suffix 2", "nd", tok.getToken("TEXT.NUMSUFFIX.AGE", + getCharacter(), eh)); + character.setAge(3); + assertEquals("Suffix 3", "rd", tok.getToken("TEXT.NUMSUFFIX.AGE", + getCharacter(), eh)); + character.setAge(4); + assertEquals("Suffix 4", "th", tok.getToken("TEXT.NUMSUFFIX.AGE", + getCharacter(), eh)); + character.setAge(11); + assertEquals("Suffix 11", "th", tok.getToken("TEXT.NUMSUFFIX.AGE", + getCharacter(), eh)); + character.setAge(12); + assertEquals("Suffix 12", "th", tok.getToken("TEXT.NUMSUFFIX.AGE", + getCharacter(), eh)); + character.setAge(13); + assertEquals("Suffix 13", "th", tok.getToken("TEXT.NUMSUFFIX.AGE", + getCharacter(), eh)); + character.setAge(14); + assertEquals("Suffix 14", "th", tok.getToken("TEXT.NUMSUFFIX.AGE", + getCharacter(), eh)); + character.setAge(21); + assertEquals("Suffix 21", "st", tok.getToken("TEXT.NUMSUFFIX.AGE", + getCharacter(), eh)); + character.setAge(22); + assertEquals("Suffix 22", "nd", tok.getToken("TEXT.NUMSUFFIX.AGE", + getCharacter(), eh)); + character.setAge(23); + assertEquals("Suffix 23", "rd", tok.getToken("TEXT.NUMSUFFIX.AGE", + getCharacter(), eh)); + character.setAge(24); + assertEquals("Suffix 24", "th", tok.getToken("TEXT.NUMSUFFIX.AGE", + getCharacter(), eh)); + character.setAge(133); + assertEquals("Suffix 133", "rd", tok.getToken("TEXT.NUMSUFFIX.AGE", + getCharacter(), eh)); + } + + /** + * Test the output for negative numbers with fractions. + */ + public void testNumSuffixDirect() + { + TextToken tok = new TextToken(); + ExportHandler eh = new ExportHandler(null); + + assertEquals("Suffix 1", "st", tok.getToken("TEXT.NUMSUFFIX.1", + getCharacter(), eh)); + assertEquals("Suffix 2", "nd", tok.getToken("TEXT.NUMSUFFIX.2", + getCharacter(), eh)); + assertEquals("Suffix 3", "rd", tok.getToken("TEXT.NUMSUFFIX.3", + getCharacter(), eh)); + assertEquals("Suffix 4", "th", tok.getToken("TEXT.NUMSUFFIX.4", + getCharacter(), eh)); + assertEquals("Suffix 12", "th", tok.getToken("TEXT.NUMSUFFIX.12", + getCharacter(), eh)); + assertEquals("Suffix 133", "rd", tok.getToken("TEXT.NUMSUFFIX.133", + getCharacter(), eh)); + } + + +} \ No newline at end of file Property changes on: Trunk/pcgen/code/src/test/pcgen/io/exporttoken/TextTokenTest.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: <jdempsey@us...> - 2006-10-23 22:00:25
|
Revision: 1519 http://svn.sourceforge.net/pcgen/?rev=1519&view=rev Author: jdempsey Date: 2006-10-23 14:59:50 -0700 (Mon, 23 Oct 2006) Log Message: ----------- Correct building of SA string in templates (noted by Tom Parker) Modified Paths: -------------- Trunk/pcgen/code/src/java/plugin/exporttokens/TemplateToken.java Trunk/pcgen/code/testsuite/csheets/CloudGiantHalfDragon.xml Trunk/pcgen/code/testsuite/csheets/DrakelingSorc.xml Trunk/pcgen/code/testsuite/csheets/JimDop.xml Modified: Trunk/pcgen/code/src/java/plugin/exporttokens/TemplateToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/exporttokens/TemplateToken.java 2006-10-22 22:53:33 UTC (rev 1518) +++ Trunk/pcgen/code/src/java/plugin/exporttokens/TemplateToken.java 2006-10-23 21:59:50 UTC (rev 1519) @@ -244,10 +244,10 @@ { if (x++ > 0) { - retString = ", "; + retString += ", "; } - retString = e.next().toString(); + retString += e.next().toString(); } return retString; Modified: Trunk/pcgen/code/testsuite/csheets/CloudGiantHalfDragon.xml =================================================================== --- Trunk/pcgen/code/testsuite/csheets/CloudGiantHalfDragon.xml 2006-10-22 22:53:33 UTC (rev 1518) +++ Trunk/pcgen/code/testsuite/csheets/CloudGiantHalfDragon.xml 2006-10-23 21:59:50 UTC (rev 1519) @@ -1449,7 +1449,7 @@ <cr>0</cr> <dr></dr> <feat></feat> - <sa>Breath Weapon (Ex) 60' Line of Fire 1/day 6d8 (DC%)|HalfDragonBreathDC</sa> + <sa>Immunity to Fire (Ex), Breath Weapon (Ex) 60' Line of Fire 1/day 6d8 (DC%)|HalfDragonBreathDC</sa> <sr>0</sr> <bonuslist></bonuslist> </template> Modified: Trunk/pcgen/code/testsuite/csheets/DrakelingSorc.xml =================================================================== --- Trunk/pcgen/code/testsuite/csheets/DrakelingSorc.xml 2006-10-22 22:53:33 UTC (rev 1518) +++ Trunk/pcgen/code/testsuite/csheets/DrakelingSorc.xml 2006-10-23 21:59:50 UTC (rev 1519) @@ -1024,7 +1024,7 @@ <cr>0</cr> <dr></dr> <feat></feat> - <sa>Energy Substitution for element</sa> + <sa>CHOOSE:Acid Resistance 10|Cold Resistance 10|Electricity Resistance 10|Fire Resistance 10, Energy Substitution for element</sa> <sr>0</sr> <bonuslist></bonuslist> </template> Modified: Trunk/pcgen/code/testsuite/csheets/JimDop.xml =================================================================== --- Trunk/pcgen/code/testsuite/csheets/JimDop.xml 2006-10-22 22:53:33 UTC (rev 1518) +++ Trunk/pcgen/code/testsuite/csheets/JimDop.xml 2006-10-23 21:59:50 UTC (rev 1519) @@ -1465,7 +1465,7 @@ <cr>0</cr> <dr></dr> <feat></feat> - <sa>Breath Weapon (Ex) 60' Line of Fire 1/day 6d8 (DC%)|HalfDragonBreathDC</sa> + <sa>Immunity to Fire (Ex), Breath Weapon (Ex) 60' Line of Fire 1/day 6d8 (DC%)|HalfDragonBreathDC</sa> <sr>0</sr> <bonuslist></bonuslist> </template> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <thpr@us...> - 2006-11-05 01:02:38
|
Revision: 1587 http://svn.sourceforge.net/pcgen/?rev=1587&view=rev Author: thpr Date: 2006-11-04 17:02:21 -0800 (Sat, 04 Nov 2006) Log Message: ----------- PCClass: Eliminate SUBCLASS and SUBSTITUTIONCLASS Tags and associated code (all unused) Note SUBCLASS and SUBSTITUTIONCLASS processing in PCClassLoader is unchanged. Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/PCClass.java Trunk/pcgen/code/src/java/pcgen/gui/ChooseSpellDialog.java Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SubclassToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SubstitutionclassToken.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/SubclassToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/SubstitutionclassToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-11-05 00:23:31 UTC (rev 1586) +++ Trunk/pcgen/code/pluginbuild.xml 2006-11-05 01:02:21 UTC (rev 1587) @@ -2770,20 +2770,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/ClassLstToken-SUBCLASS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/pcclass/SubclassToken.class" /> - </patternset> - </fileset> - </jar> - <jar jarfile="${lstplugins.dir}/ClassLstToken-SUBSTITUTIONCLASS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/pcclass/SubstitutionclassToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/ClassLstToken-TEMPLATE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -5857,6 +5843,20 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/ClassLstToken-DEPRECATED-SUBCLASS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/deprecateds/SubclassToken.class" /> + </patternset> + </fileset> + </jar> + <jar jarfile="${lstplugins.dir}/ClassLstToken-DEPRECATED-SUBSTITUTIONCLASS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/deprecated/SubstitutionclassToken.class" /> + </patternset> + </fileset> + </jar> </target> <target name="manifest" description="Write the Java manifest"> Modified: Trunk/pcgen/code/src/java/pcgen/core/PCClass.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2006-11-05 00:23:31 UTC (rev 1586) +++ Trunk/pcgen/code/src/java/pcgen/core/PCClass.java 2006-11-05 01:02:21 UTC (rev 1587) @@ -583,22 +583,12 @@ private String subClassKey = Constants.s_NONE; /* - * DELETEVARIABLE from ancient code - can delete - */ - private String subClassString = Constants.s_NONE; - - /* * ALLCLASSLEVELS This goes into each PCClassLevel from PCClass in order to * store what the substitution level actually is. This is NOT set by a tag, so it is * PCCLASSLEVELONLY */ private Map<Integer, String> substitutionClassKey = null; - /* - * DELETEVARIABLE Unused variable - */ - private String substitutionClassString = Constants.s_NONE; - // private TreeSet<Language> languageBonus = new TreeSet<Language>(); /* @@ -2876,20 +2866,6 @@ } /* - * DELETEMETHOD - unused variable - */ - public final void setSubClassString(final String aString) { - subClassString = aString; - } - - /* - * DELETEMETHOD Per Tir, this is from the 3.0/4.0 cleanup and is unused code. - */ - public final String getSubClassString() { - return subClassString; - } - - /* * PCCLASSONLY This is really an item that the PCClass knows, and then the * selected substitutionClass, if any, is structured into the PCClassLevel * during the construction of the PCClassLevel @@ -2911,20 +2887,6 @@ } /* - * DELETEMETHOD - variable is unused - */ - public final void setSubstitutionClassString(final String aString) { - substitutionClassString = aString; - } - - /* - * DELETEMETHOD unused method - */ - public final String getSubstitutionClassString() { - return substitutionClassString; - } - - /* * Note: Since this is local access, it does not need to override * getTemplateList from PObject (although it is probably confusing that it * doesn't). The key point is ensuring that getTemplates(final boolean flag, Modified: Trunk/pcgen/code/src/java/pcgen/gui/ChooseSpellDialog.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/ChooseSpellDialog.java 2006-11-05 00:23:31 UTC (rev 1586) +++ Trunk/pcgen/code/src/java/pcgen/gui/ChooseSpellDialog.java 2006-11-05 01:02:21 UTC (rev 1587) @@ -27,7 +27,6 @@ import pcgen.core.*; import pcgen.core.spell.Spell; -import pcgen.core.utils.CoreUtility; import pcgen.core.utils.MessageType; import pcgen.core.utils.ShowMessageDelegate; import pcgen.gui.utils.IconUtilitities; @@ -83,7 +82,6 @@ private List<Spell> classSpells = null; private List<String> levelList = null; private List<String> subTypeList = new ArrayList<String>(); - private Map<String, List<String>> specialists = null; private PObject castingClass = null; private Spell theSpell = null; private String choiceString = ""; @@ -240,94 +238,6 @@ } } - private void getSpecialists() - { - specialists = new HashMap<String, List<String>>(); - - for (PCClass aClass : Globals.getClassList()) - { - final List<String> subClasses = CoreUtility.split(aClass.getSubClassString(), '|'); - - if (subClasses.size() > 1) - { - subClasses.remove(0); // level - } - - for (int idx = 0; idx < subClasses.size(); idx++) - { - String fileName = subClasses.get(idx); - int i = fileName.indexOf('('); - - if (i >= 0) - { - fileName = fileName.substring(0, i); - } - - if (fileName.startsWith("FILE=")) - { - CoreUtility.fixFilenamePath(fileName); - i = 5; - - if (fileName.charAt(6) == File.separatorChar) - { - i = 6; - } - - fileName = fileName.substring(i); - fileName = SettingsHandler.getPccFilesLocation() + File.separator + fileName; - - File aFile = new File(fileName); - - try - { - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(aFile), - "UTF-8")); - - String line = reader.readLine(); - - while (line != null) - { - if (!((line.length() > 0) && (line.charAt(0) == '#'))) - { - final StringTokenizer aTok = new StringTokenizer(line.trim(), "\t"); - - if (aTok.countTokens() > 2) - { - final String specialty = aTok.nextToken(); - final String cost = aTok.nextToken(); - final String className = aTok.nextToken(); - List<String> aList = new ArrayList<String>(5); - aList.add(aClass.getKeyName()); - aList.add(specialty); - aList.add(cost); - - //specialists.put(className, aClass.getName() + "\t" + specialty + "\t" + cost); - specialists.put(className, aList); - } - } - - line = reader.readLine(); - } - - reader.close(); - } - catch (FileNotFoundException exception) - { - //TODO: Should we really ignore this? - } - catch (UnsupportedEncodingException exception) - { - //TODO: Should we really ignore this? - } - catch (IOException exception) - { - //TODO: Should we really ignore this? - } - } - } - } - } - private boolean isSpellOfSubType(Spell aSpell) { if (subTypeList.size() == 0) @@ -1195,8 +1105,6 @@ if (unfoundItems.size() > 0) { - specialists = null; - for (String eMsg : unfoundItems) { String bMsg = null; @@ -1209,37 +1117,7 @@ switch (eMsg.charAt(0)) { case 'C': - - // - // Get a list of all possible specialists - // - if (specialists == null) - { - getSpecialists(); - } - - final String sub = eMsg.substring(1); - final List<String> specInfo = specialists.get(sub); - - if (specInfo == null) - { - bMsg = "Class"; - } - else - { - // - // hack: specialists used to appear in in PObjects somehow, make it look similar - // - PObject pobj = new PObject(); - pobj.setName(sub); - pobj.addAllToAssociated(specInfo); - - if (!classWithSpell.contains(pobj)) - { - classWithSpell.add(pobj); - } - } - + bMsg = "Class"; break; case 'D': Copied: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SubclassToken.java (from rev 1579, Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/SubclassToken.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SubclassToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SubclassToken.java 2006-11-05 01:02:21 UTC (rev 1587) @@ -0,0 +1,27 @@ +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.Logging; + +/** + * Class deals with SUBCLASS Token + */ +public class SubclassToken implements PCClassLstToken, DeprecatedToken { + + public String getTokenName() { + return "SUBCLASS"; + } + + public boolean parse(PCClass pcclass, String value, int level) { + Logging.errorPrint("You have used a Tag (SUBCLASS) which was never processed in PCGen - it has been removed"); + return false; + } + + public String getMessage(PObject obj, String value) { + return "You have used a Tag (SUBCLASS) NOT at the start of a line..." + + "this was never processed in PCGen - it has been removed"; + } +} Copied: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SubstitutionclassToken.java (from rev 1579, Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/SubstitutionclassToken.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SubstitutionclassToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SubstitutionclassToken.java 2006-11-05 01:02:21 UTC (rev 1587) @@ -0,0 +1,27 @@ +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.Logging; + +/** + * Class deals with SUBSTITUTIONCLASS Token + */ +public class SubstitutionclassToken implements PCClassLstToken, DeprecatedToken { + + public String getTokenName() { + return "SUBSTITUTIONCLASS"; + } + + public boolean parse(PCClass pcclass, String value, int level) { + Logging.errorPrint("You have used a Tag (SUBSTITUTIONCLASS) which was never processed in PCGen - it has been removed"); + return false; + } + + public String getMessage(PObject obj, String value) { + return "You have used a Tag (SUBSTITUTIONCLASS) NOT at the start of a line..." + + "this was never processed in PCGen - it has been removed"; + } +} Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/SubclassToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/SubclassToken.java 2006-11-05 00:23:31 UTC (rev 1586) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/SubclassToken.java 2006-11-05 01:02:21 UTC (rev 1587) @@ -1,20 +0,0 @@ -package plugin.lsttokens.pcclass; - -import pcgen.core.PCClass; -import pcgen.persistence.lst.PCClassLoader; -import pcgen.persistence.lst.PCClassLstToken; - -/** - * Class deals with SUBCLASS Token - */ -public class SubclassToken implements PCClassLstToken { - - public String getTokenName() { - return "SUBCLASS"; - } - - public boolean parse(PCClass pcclass, String value, int level) { - pcclass.setSubClassString(PCClassLoader.fixParameter(level, value)); - return true; - } -} Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/SubstitutionclassToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/SubstitutionclassToken.java 2006-11-05 00:23:31 UTC (rev 1586) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/pcclass/SubstitutionclassToken.java 2006-11-05 01:02:21 UTC (rev 1587) @@ -1,20 +0,0 @@ -package plugin.lsttokens.pcclass; - -import pcgen.core.PCClass; -import pcgen.persistence.lst.PCClassLoader; -import pcgen.persistence.lst.PCClassLstToken; - -/** - * Class deals with SUBSTITUTIONCLASS Token - */ -public class SubstitutionclassToken implements PCClassLstToken { - - public String getTokenName() { - return "SUBSTITUTIONCLASS"; - } - - public boolean parse(PCClass pcclass, String value, int level) { - pcclass.setSubstitutionClassString(PCClassLoader.fixParameter(level, value)); - return true; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <thpr@us...> - 2006-11-26 17:30:35
|
Revision: 1702 http://svn.sourceforge.net/pcgen/?rev=1702&view=rev Author: thpr Date: 2006-11-26 09:30:35 -0800 (Sun, 26 Nov 2006) Log Message: ----------- [ 1599062 ] Deprecate RACENAME in Race Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/RacenameToken.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/race/RacenameToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-11-26 17:26:38 UTC (rev 1701) +++ Trunk/pcgen/code/pluginbuild.xml 2006-11-26 17:30:35 UTC (rev 1702) @@ -3564,13 +3564,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/RaceLstToken-RACENAME.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/race/RacenameToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/RaceLstToken-RACESUBTYPE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -5906,13 +5899,20 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/RaceLstToken-BAB.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <jar jarfile="${lstplugins.dir}/RaceLstToken-DEPRECATED-BAB.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> <include name="plugin/lsttokens/deprecated/BabToken.class" /> </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/RaceLstToken-DEPRECATED-RACENAME.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/deprecated/RacenameToken.class" /> + </patternset> + </fileset> + </jar> </target> <target name="manifest" description="Write the Java manifest"> Copied: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/RacenameToken.java (from rev 1700, Trunk/pcgen/code/src/java/plugin/lsttokens/race/RacenameToken.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/RacenameToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/RacenameToken.java 2006-11-26 17:30:35 UTC (rev 1702) @@ -0,0 +1,25 @@ +package plugin.lsttokens.deprecated; + +import pcgen.core.PObject; +import pcgen.core.Race; +import pcgen.persistence.lst.DeprecatedToken; +import pcgen.persistence.lst.RaceLstToken; + +/** + * Class deals with RACENAME Token + */ +public class RacenameToken implements RaceLstToken, DeprecatedToken { + + public String getTokenName() { + return "RACENAME"; + } + + public boolean parse(Race race, String value) { + race.setName(value); + return true; + } + + public String getMessage(PObject obj, String value) { + return "This was a PCGen 2.X Tag. Use OUTPUTNAME instead"; + } +} Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/race/RacenameToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/race/RacenameToken.java 2006-11-26 17:26:38 UTC (rev 1701) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/race/RacenameToken.java 2006-11-26 17:30:35 UTC (rev 1702) @@ -1,19 +0,0 @@ -package plugin.lsttokens.race; - -import pcgen.core.Race; -import pcgen.persistence.lst.RaceLstToken; - -/** - * Class deals with RACENAME Token - */ -public class RacenameToken implements RaceLstToken { - - public String getTokenName() { - return "RACENAME"; - } - - public boolean parse(Race race, String value) { - race.setName(value); - return true; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <thpr@us...> - 2006-11-26 17:36:05
|
Revision: 1704 http://svn.sourceforge.net/pcgen/?rev=1704&view=rev Author: thpr Date: 2006-11-26 09:36:02 -0800 (Sun, 26 Nov 2006) Log Message: ----------- [ 1599064 ] Deprecate SKILL tag in Race Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SkillToken.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/race/SkillToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-11-26 17:33:35 UTC (rev 1703) +++ Trunk/pcgen/code/pluginbuild.xml 2006-11-26 17:36:02 UTC (rev 1704) @@ -3592,13 +3592,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/RaceLstToken-SKILL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/race/SkillToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/RaceLstToken-STARTFEATS.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-SKILL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/deprecated/SkillToken.class" /> + </patternset> + </fileset> + </jar> </target> <target name="manifest" description="Write the Java manifest"> Copied: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SkillToken.java (from rev 1700, Trunk/pcgen/code/src/java/plugin/lsttokens/race/SkillToken.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SkillToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SkillToken.java 2006-11-26 17:36:02 UTC (rev 1704) @@ -0,0 +1,25 @@ +package plugin.lsttokens.deprecated; + +import pcgen.core.PObject; +import pcgen.core.Race; +import pcgen.persistence.lst.DeprecatedToken; +import pcgen.persistence.lst.RaceLstToken; + +/** + * Class deals with SKILL Token + */ +public class SkillToken implements RaceLstToken, DeprecatedToken { + + public String getTokenName() { + return "SKILL"; + } + + public boolean parse(Race race, String value) { + race.setBonusSkillList(value); + return true; + } + + public String getMessage(PObject obj, String value) { + return "SKILL in Race Files is deprecated. Use BONUS|SKILL instead"; + } +} Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/race/SkillToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/race/SkillToken.java 2006-11-26 17:33:35 UTC (rev 1703) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/race/SkillToken.java 2006-11-26 17:36:02 UTC (rev 1704) @@ -1,19 +0,0 @@ -package plugin.lsttokens.race; - -import pcgen.core.Race; -import pcgen.persistence.lst.RaceLstToken; - -/** - * Class deals with SKILL Token - */ -public class SkillToken implements RaceLstToken { - - public String getTokenName() { - return "SKILL"; - } - - public boolean parse(Race race, String value) { - race.setBonusSkillList(value); - return true; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <thpr@us...> - 2006-11-26 17:39:06
|
Revision: 1705 http://svn.sourceforge.net/pcgen/?rev=1705&view=rev Author: thpr Date: 2006-11-26 09:39:05 -0800 (Sun, 26 Nov 2006) Log Message: ----------- [ 1600646 ] Deprecate ROOT: Tag in Skill Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/RootToken.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/skill/RootToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-11-26 17:36:02 UTC (rev 1704) +++ Trunk/pcgen/code/pluginbuild.xml 2006-11-26 17:39:05 UTC (rev 1705) @@ -3652,13 +3652,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/SkillLstToken-ROOT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/skill/RootToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/SkillLstToken-USEUNTRAINED.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}/SkillLstToken-DEPRECATED-ROOT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/deprecated/RootToken.class" /> + </patternset> + </fileset> + </jar> </target> <target name="manifest" description="Write the Java manifest"> Copied: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/RootToken.java (from rev 1700, Trunk/pcgen/code/src/java/plugin/lsttokens/skill/RootToken.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/RootToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/RootToken.java 2006-11-26 17:39:05 UTC (rev 1705) @@ -0,0 +1,25 @@ +package plugin.lsttokens.deprecated; + +import pcgen.core.PObject; +import pcgen.core.Skill; +import pcgen.persistence.lst.DeprecatedToken; +import pcgen.persistence.lst.SkillLstToken; + +/** + * Class deals with ROOT Token + */ +public class RootToken implements SkillLstToken, DeprecatedToken { + + public String getTokenName() { + return "ROOT"; + } + + public boolean parse(Skill skill, String value) { + skill.setRootName(value); + return true; + } + + public String getMessage(PObject obj, String value) { + return "ROOT is a non-functioning Token - predates COST, TYPE breakdowns for Skills"; + } +} Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/skill/RootToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/skill/RootToken.java 2006-11-26 17:36:02 UTC (rev 1704) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/skill/RootToken.java 2006-11-26 17:39:05 UTC (rev 1705) @@ -1,19 +0,0 @@ -package plugin.lsttokens.skill; - -import pcgen.core.Skill; -import pcgen.persistence.lst.SkillLstToken; - -/** - * Class deals with ROOT Token - */ -public class RootToken implements SkillLstToken { - - public String getTokenName() { - return "ROOT"; - } - - public boolean parse(Skill skill, String value) { - skill.setRootName(value); - return true; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <thpr@us...> - 2006-12-09 14:58:12
|
Revision: 1744 http://svn.sourceforge.net/pcgen/?rev=1744&view=rev Author: thpr Date: 2006-12-09 06:58:12 -0800 (Sat, 09 Dec 2006) Log Message: ----------- Fix Typo in pluginbuild.xml Fix Misnamed Tokens *NOTE* This change requires build clean to avoid warnings due to duplicate tokens for Spell and Skill LST files Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/skill/AcheckToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/spell/DomainsToken.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/skill/AccheckToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/spell/DomainToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-12-08 22:49:58 UTC (rev 1743) +++ Trunk/pcgen/code/pluginbuild.xml 2006-12-09 14:58:12 UTC (rev 1744) @@ -3610,10 +3610,10 @@ <target name="jar-lst-skill-plugins" depends="makeplugindirs" description="Build (Link) Skill Lst Token plugin jar files"> <!-- Skill tokens--> - <jar jarfile="${lstplugins.dir}/SkillLstToken-ACCHECK.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <jar jarfile="${lstplugins.dir}/SkillLstToken-ACHECK.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> - <include name="plugin/lsttokens/skill/AccheckToken.class" /> + <include name="plugin/lsttokens/skill/AcheckToken.class" /> </patternset> </fileset> </jar> @@ -3705,10 +3705,10 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/SpellLstToken-DOMAIN.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <jar jarfile="${lstplugins.dir}/SpellLstToken-DOMAINS.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> - <include name="plugin/lsttokens/spell/DomainToken.class" /> + <include name="plugin/lsttokens/spell/DomainsToken.class" /> </patternset> </fileset> </jar> @@ -5916,7 +5916,7 @@ <jar jarfile="${lstplugins.dir}/EquipmentLstToken-DEPRECATED-AC.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> - <include name="plugin/lsttokens/deprecate/AcToken.class" /> + <include name="plugin/lsttokens/deprecated/AcToken.class" /> </patternset> </fileset> </jar> Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/skill/AccheckToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/skill/AccheckToken.java 2006-12-08 22:49:58 UTC (rev 1743) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/skill/AccheckToken.java 2006-12-09 14:58:12 UTC (rev 1744) @@ -1,19 +0,0 @@ -package plugin.lsttokens.skill; - -import pcgen.core.Skill; -import pcgen.persistence.lst.SkillLstToken; - -/** - * Class deals with ACHECK Token - */ -public class AccheckToken implements SkillLstToken { - - public String getTokenName() { - return "ACHECK"; - } - - public boolean parse(Skill skill, String value) { - skill.setACheck(value); - return true; - } -} Copied: Trunk/pcgen/code/src/java/plugin/lsttokens/skill/AcheckToken.java (from rev 1735, Trunk/pcgen/code/src/java/plugin/lsttokens/skill/AccheckToken.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/skill/AcheckToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/skill/AcheckToken.java 2006-12-09 14:58:12 UTC (rev 1744) @@ -0,0 +1,19 @@ +package plugin.lsttokens.skill; + +import pcgen.core.Skill; +import pcgen.persistence.lst.SkillLstToken; + +/** + * Class deals with ACHECK Token + */ +public class AcheckToken implements SkillLstToken { + + public String getTokenName() { + return "ACHECK"; + } + + public boolean parse(Skill skill, String value) { + skill.setACheck(value); + return true; + } +} Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/spell/DomainToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/spell/DomainToken.java 2006-12-08 22:49:58 UTC (rev 1743) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/spell/DomainToken.java 2006-12-09 14:58:12 UTC (rev 1744) @@ -1,28 +0,0 @@ -package plugin.lsttokens.spell; - -import pcgen.core.spell.Spell; -import pcgen.persistence.lst.SpellLoader; -import pcgen.persistence.lst.SpellLstToken; -import pcgen.util.Logging; - -/** - * Class deals with DOMAINS Token - */ -public class DomainToken implements SpellLstToken { - - public String getTokenName() { - return "DOMAINS"; - } - - public boolean parse(Spell spell, String value) { - try { - SpellLoader.setLevelList(spell, "DOMAIN", value); - return true; - } - catch(Exception e) { - Logging.errorPrint("Error in DOMAIN token: " + e.getMessage()); - e.printStackTrace(); - return false; - } - } -} Copied: Trunk/pcgen/code/src/java/plugin/lsttokens/spell/DomainsToken.java (from rev 1735, Trunk/pcgen/code/src/java/plugin/lsttokens/spell/DomainToken.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/spell/DomainsToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/spell/DomainsToken.java 2006-12-09 14:58:12 UTC (rev 1744) @@ -0,0 +1,28 @@ +package plugin.lsttokens.spell; + +import pcgen.core.spell.Spell; +import pcgen.persistence.lst.SpellLoader; +import pcgen.persistence.lst.SpellLstToken; +import pcgen.util.Logging; + +/** + * Class deals with DOMAINS Token + */ +public class DomainsToken implements SpellLstToken { + + public String getTokenName() { + return "DOMAINS"; + } + + public boolean parse(Spell spell, String value) { + try { + SpellLoader.setLevelList(spell, "DOMAIN", value); + return true; + } + catch(Exception e) { + Logging.errorPrint("Error in DOMAIN token: " + e.getMessage()); + e.printStackTrace(); + return false; + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jdempsey@us...> - 2007-01-02 06:51:50
|
Revision: 1856 http://svn.sourceforge.net/pcgen/?rev=1856&view=rev Author: jdempsey Date: 2007-01-01 22:51:50 -0800 (Mon, 01 Jan 2007) Log Message: ----------- Freq #1262317 - Ability Object: Add ability tags - Remove obsolete Domain-specific Ability tag. Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/Domain.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/domain/AbilityToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2007-01-02 06:42:02 UTC (rev 1855) +++ Trunk/pcgen/code/pluginbuild.xml 2007-01-02 06:51:50 UTC (rev 1856) @@ -3020,13 +3020,6 @@ <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"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/domain/AbilityToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/DomainLstToken-FEAT.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/core/Domain.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Domain.java 2007-01-02 06:42:02 UTC (rev 1855) +++ Trunk/pcgen/code/src/java/pcgen/core/Domain.java 2007-01-02 06:51:50 UTC (rev 1856) @@ -48,27 +48,13 @@ private boolean isLocked; /** - * Add an Ability or list of Abilities to the Abilities that the domain grants. - * The Ability may be a single Ability, or a list of Abilitiess separated by "|" - * or ",". The AbilityList may be interspersed with "CATEGORY=FOO" entries. - * This will change the category of all Abilities entered by this call until - * a further Category entry is found. In addition, if .CLEAR is received, - * the existing ability store will be cleared. This string must begin with a - * "CATEGORY=" statement. + * Add an Ability or list of Abilities to the Abilities that the domain + * grants. The Ability may be a single Ability, or a list of Abilitiess + * separated by "|" or ",". If .CLEAR is received, the existing ability + * store will be cleared. This string must begin with a "CATEGORY=" + * statement. All abilities added by this method are assumed to be + * category FEAT. "CATEGORY=" entries are ignored. * - * @param abilities - */ - public void addAbility(final String abilities) - { - abilityStore.addAbilityInfo(abilities, "", "|,", false, false); - } - - /** - * @see #addAbility(String) - * - * this is a variation of addAbilityToList, it ignores "CATEGORY=" entries - * All abilities added by this method are assumed to be category FEAT. - * * @param feats */ public void addFeat(final String feats) @@ -293,11 +279,6 @@ { return abilityStore.getUnmodifiableList("FEAT").size(); } - - public Iterator<Categorisable> getAbilityIterator(final String aCategory) - { - return abilityStore.getNameIterator(aCategory); - } void addSpellsToClassForLevels( final PCClass aClass, @@ -348,32 +329,7 @@ final StringBuffer txt = new StringBuffer(200); txt.append(super.getPCCText(true)); - // - // For custom domains, we need to save the domain list as it won't be saved with the spell (unless the spell is also custom) - // in which case it will be saved in the spell's DOMAIN tag - // - boolean bFirst = true; - final SpellSupport ss = getSpellSupport(); - for (Iterator<?> e = Globals.getSpellMap().values().iterator(); e.hasNext();) - { - final Object obj = e.next(); - if (obj instanceof Spell) - { - String spellName = obj.toString(); - if (ss.containsInfoFor("DOMAIN", spellName)) - { - if (bFirst) - { - txt.append('\t').append("SPELLLEVEL:DOMAIN"); - bFirst = false; - } - final int spellLevel = ss.getInfo("DOMAIN", spellName).level; - txt.append('|').append(getKeyName()).append('=').append(spellLevel).append('|').append(obj.toString()); - } - } - } - // Granted feats StringBuffer featString = new StringBuffer(); for (Iterator<Categorisable> iter = getFeatIterator(); iter.hasNext();) @@ -389,6 +345,7 @@ { txt.append('\t').append("FEAT:").append(featString); } + return txt.toString(); } Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/domain/AbilityToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/domain/AbilityToken.java 2007-01-02 06:42:02 UTC (rev 1855) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/domain/AbilityToken.java 2007-01-02 06:51:50 UTC (rev 1856) @@ -1,33 +0,0 @@ -package plugin.lsttokens.domain; - -import pcgen.core.Domain; -import pcgen.persistence.lst.DomainLstToken; - -/** - * Deals with ABILITY token - */ -public class AbilityToken implements DomainLstToken -{ - - /** - * get token name - * @return token name - */ - public String getTokenName() - { - return "ABILITY"; - } - - /** - * Parse ABILITY token for domain - * - * @param domain - * @param value - * @return true - */ - public boolean parse(Domain domain, String value) - { - domain.addAbility(value); - return true; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jdempsey@us...> - 2007-01-23 21:51:25
|
Revision: 2017 http://svn.sourceforge.net/pcgen/?rev=2017&view=rev Author: jdempsey Date: 2007-01-23 13:51:17 -0800 (Tue, 23 Jan 2007) Log Message: ----------- Freq#1642779 - PREABILITY tag Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/prereq/Prerequisite.java Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties Trunk/pcgen/code/src/test/pcgen/persistence/lst/output/prereq/PrerequisiteWriterTest.java Trunk/pcgen/code/src/test/pcgen/util/TestHelper.java Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/pretokens/parser/PreAbilityParser.java Trunk/pcgen/code/src/java/plugin/pretokens/test/PreAbilityTester.java Trunk/pcgen/code/src/java/plugin/pretokens/writer/PreAbilityWriter.java Trunk/pcgen/code/src/test/pcgen/core/prereq/PreAbilityTest.java Trunk/pcgen/code/src/test/pcgen/persistence/lst/prereq/PreAbilityParserTest.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2007-01-23 16:01:42 UTC (rev 2016) +++ Trunk/pcgen/code/pluginbuild.xml 2007-01-23 21:51:17 UTC (rev 2017) @@ -1322,6 +1322,15 @@ <target name="jar-pre-plugins" depends="makeplugindirs" description="Build (Link) Prereq Token plugin jar files"> <!-- Pre tokens--> + <jar jarfile="${preplugins.dir}/PreToken-PREABILITY.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/pretokens/parser/PreAbilityParser.class" /> + <include name="plugin/pretokens/test/PreAbilityTester.class" /> + <include name="plugin/pretokens/writer/PreAbilityWriter.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${preplugins.dir}/PreToken-PREALIGN.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/core/prereq/Prerequisite.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/prereq/Prerequisite.java 2007-01-23 16:01:42 UTC (rev 2016) +++ Trunk/pcgen/code/src/java/pcgen/core/prereq/Prerequisite.java 2007-01-23 21:51:17 UTC (rev 2017) @@ -14,7 +14,9 @@ * * Created on September 16, 2002, 3:30 PM * - * Current Ver: $Revision$ Last Editor: $Author$ Last Edited: $Date$ + * Current Ver: $Revision$ + * Last Editor: $Author$ + * Last Edited: $Date$ * */ package pcgen.core.prereq; @@ -51,6 +53,7 @@ private boolean countMultiples; private boolean overrideQualify = false; private int levelQualifier = -1; // used for classes only - classlevel at which this prereq is checked + private String categoryName; // used for abilities only - category to restrict matches to. public Prerequisite() { @@ -240,6 +243,14 @@ buf.append(PropertyFactory.getString("Prerequisite.total-values")); //$NON-NLS-1$ } + if (categoryName != null) + { + buf.append(PropertyFactory.getString("Prerequisite.category")); //$NON-NLS-1$ + buf.append("=\""); //$NON-NLS-1$ + buf.append(categoryName); + buf.append("\" "); //$NON-NLS-1$ + } + if (key != null) { buf.append(PropertyFactory.getString("Prerequisite.key")); //$NON-NLS-1$ @@ -381,6 +392,14 @@ } + if (categoryName != null && !shortForm) + { + buf.append("of category "); + buf.append(categoryName+":"); + buf.append(' '); //$NON-NLS-1$ + + } + if (kind != null && !shortForm) { buf.append(kind); @@ -441,4 +460,20 @@ levelQualifier = qualifier; } + /** + * @return the categoryName + */ + public String getCategoryName() + { + return categoryName; + } + + /** + * @param categoryName the categoryName to set + */ + public void setCategoryName(String categoryName) + { + this.categoryName = categoryName; + } + } Modified: Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2007-01-23 16:01:42 UTC (rev 2016) +++ Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2007-01-23 21:51:17 UTC (rev 2017) @@ -2687,6 +2687,8 @@ Prerequisite.key=key +Prerequisite.category=category + Prerequisite.sub-key=sub-key Prerequisite.operator=operator @@ -2804,6 +2806,10 @@ PreFeat.toHtml={2} {3} {1} {0} PreFeat.type.toHtml={0} {1} {2}(s) of type {3} +PreAbility.toHtml={2} {3} {1} {0} +PreAbility.type.toHtml={0} {1} {2}(s) of type {3} +PreAbility.type.noCat.toHtml={0} {1} ability(s) of type {3} + PrerequisiteOperator.display.eq=exactly PrerequisiteOperator.display.lt=less than Added: Trunk/pcgen/code/src/java/plugin/pretokens/parser/PreAbilityParser.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/pretokens/parser/PreAbilityParser.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/pretokens/parser/PreAbilityParser.java 2007-01-23 21:51:17 UTC (rev 2017) @@ -0,0 +1,196 @@ +/* + * PreAbilityParser.java + * Copyright 2007 (C) James Dempsey <jdempsey@...> + * + * 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 January 23, 2006 + * + * Current Ver: $Revision: 1777 $ + * Last Editor: $Author: jdempsey $ + * Last Edited: $Date: 2006-12-17 15:36:01 +1100 (Sun, 17 Dec 2006) $ + * + */ +package plugin.pretokens.parser; + +import java.util.ArrayList; +import java.util.List; + +import pcgen.core.prereq.Prerequisite; +import pcgen.persistence.PersistenceLayerException; +import pcgen.persistence.lst.prereq.AbstractPrerequisiteListParser; +import pcgen.persistence.lst.prereq.PrerequisiteParserInterface; + +/** + * <code>PreAbilityParser</code> parses PREABILITY prerequisite tokens. + * + * Last Editor: $Author: jdempsey $ + * Last Edited: $Date: 2006-12-17 15:36:01 +1100 (Sun, 17 Dec 2006) $ + * + * @author James Dempsey <jdempsey@...> + * @version $Revision: 1777 $ + */ +public class PreAbilityParser extends AbstractPrerequisiteListParser implements + PrerequisiteParserInterface +{ + private static final String CATEGORY = "CATEGORY."; + + /** + * Create a new PreFeatParser instance. + */ + public PreAbilityParser() + { + super(); + } + + /** + * @see pcgen.persistence.lst.prereq.PrerequisiteParserInterface#kindsHandled() + */ + public String[] kindsHandled() + { + return new String[]{"ability"}; + } + + /** + * @see pcgen.persistence.lst.prereq.PrerequisiteParserInterface#parse(java.lang.String, java.lang.String, boolean, boolean) + */ + @Override + public Prerequisite parse(String kind, String formula, + boolean invertResult, boolean overrideQualify) + throws PersistenceLayerException + { + Prerequisite prereq = + super.parse(kind, formula, invertResult, overrideQualify); + + // Extract category + extractCategory(prereq); + + // + // Negate the feat names wrapped in []'s. Then need to bump up the required number of matches + // + if (formula.indexOf('[') >= 0) + { + negateAbilityChoice(prereq); + } + + // Convert all of the key="feat (subfeat)" to key="feat" subkey="subfeat" + convertKeysToSubKeys(prereq, "ability"); + + //Removed invert stuff because super.parse already does this, and these lines re-invert. + prereq.setOverrideQualify(overrideQualify); + + return prereq; + } + + /** + * Extract a category restriction from the list of entries and + * ensure it is applied to all keys. + * @param prereq The prereq to be processed. + */ + private void extractCategory(Prerequisite prereq) + { + String categoryName = ""; + if (prereq.getPrerequisites().size() == 0) + { + String preKey = prereq.getKey(); + if (preKey.toUpperCase().startsWith(CATEGORY)) + { + String tempCat = preKey.substring((CATEGORY.length())); + if (!tempCat.toUpperCase().trim().equals("ANY")) + { + categoryName = tempCat; + } + prereq.setKey("ANY"); + prereq.setCategoryName(categoryName); + } + } + + // Copy to a temporary list as we wil be adjusting the main one. + List<Prerequisite> prereqList = + new ArrayList<Prerequisite>(prereq.getPrerequisites()); + for (Prerequisite p : prereqList) + { + if (p.getKind() == null) // PREMULT + { + extractCategory(p); + } + else + { + String preKey = p.getKey(); + if (preKey.toUpperCase().startsWith(CATEGORY)) + { + String tempCat = preKey.substring((CATEGORY.length())); + if (!tempCat.toUpperCase().trim().equals("ANY")) + { + categoryName = tempCat; + } + prereq.getPrerequisites().remove(p); + } + } + } + if (categoryName.length() > 0) + { + for (Prerequisite p : prereq.getPrerequisites()) + { + p.setCategoryName(categoryName); + } + } + } + + /** + * Process prereq keys wrapped in []. If the key is wrapped in [], the + * prereq will be negated to check that the prereq is not passed, and + * the number of required matches is increased by the number of negated + * tests. Can handle nested prereqs. + * + * @param prereq The prereq to be negated. + */ + private void negateAbilityChoice(Prerequisite prereq) + { + int modified = 0; + for (Prerequisite p : prereq.getPrerequisites()) + { + if (p.getKind() == null) // PREMULT + { + negateAbilityChoice(p); + } + else + { + String preKey = p.getKey(); + if (preKey.startsWith("[") && preKey.endsWith("]")) + { + preKey = preKey.substring(1, preKey.length() - 1); + p.setKey(preKey); + p.setOperator(p.getOperator().invert()); + ++modified; + } + } + } + if (modified > 0) + { + String oper = prereq.getOperand(); + try + { + oper = Integer.toString(Integer.parseInt(oper) + modified); + } + catch (NumberFormatException nfe) + { + oper = "(" + oper + ")+" + Integer.toString(modified); + } + prereq.setOperand(oper); + } + } + +} Property changes on: Trunk/pcgen/code/src/java/plugin/pretokens/parser/PreAbilityParser.java ___________________________________________________________________ Name: keywords + Author Revision Date Id Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/pretokens/test/PreAbilityTester.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/pretokens/test/PreAbilityTester.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/pretokens/test/PreAbilityTester.java 2007-01-23 21:51:17 UTC (rev 2017) @@ -0,0 +1,469 @@ +/* + * PreAbilityTester.java + * Copyright 2007 (C) James Dempsey <jdempsey@...> + * + * 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 January 23, 2006 + * + * Current Ver: $Revision: 1777 $ + * Last Editor: $Author: jdempsey $ + * Last Edited: $Date: 2006-12-17 15:36:01 +1100 (Sun, 17 Dec 2006) $ + * + */ +package plugin.pretokens.test; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import pcgen.core.*; +import pcgen.core.prereq.AbstractPrerequisiteTest; +import pcgen.core.prereq.Prerequisite; +import pcgen.core.prereq.PrerequisiteException; +import pcgen.core.prereq.PrerequisiteTest; +import pcgen.core.spell.Spell; +import pcgen.util.PropertyFactory; + +/** + * <code>PreAbilityParser</code> tests whether a character passes ability + * prereqs. + * + * Last Editor: $Author: jdempsey $ + * Last Edited: $Date: 2006-12-17 15:36:01 +1100 (Sun, 17 Dec 2006) $ + * + * @author James Dempsey <jdempsey@...> + * @version $Revision: 1777 $ + */ +public class PreAbilityTester extends AbstractPrerequisiteTest implements + PrerequisiteTest +{ + + /* (non-Javadoc) + * @see pcgen.core.prereq.PrerequisiteTest#passes(pcgen.core.PlayerCharacter) + */ + @Override + public int passes(final Prerequisite prereq, final Equipment equipment, + final PlayerCharacter aPC) throws PrerequisiteException + { + if (aPC == null) + { + return 0; + } + return passes(prereq, aPC); + } + + @Override + public int passes(final Prerequisite prereq, final PlayerCharacter character) + throws PrerequisiteException + { + final boolean countMults = prereq.isCountMultiples(); + + final int number; + try + { + number = Integer.parseInt(prereq.getOperand()); + } + catch (NumberFormatException exceptn) + { + throw new PrerequisiteException(PropertyFactory.getFormattedString( + "PreAbility.error", prereq.toString())); //$NON-NLS-1$ + } + + GameMode gameMode = SettingsHandler.getGame(); + String key = prereq.getKey(); + String subKey = prereq.getSubKey(); + String categoryName = prereq.getCategoryName(); + AbilityCategory category = gameMode.getAbilityCategory(categoryName); + final boolean keyIsAny = + key.equalsIgnoreCase("ANY"); //$NON-NLS-1$ + final boolean keyIsType = + key.startsWith("TYPE=") || key.startsWith("TYPE."); //$NON-NLS-1$ //$NON-NLS-2$ + final boolean subKeyIsType = + subKey != null + && (subKey.startsWith("TYPE=") || subKey.startsWith("TYPE.")); //$NON-NLS-1$ //$NON-NLS-2$ + if (keyIsType) + { + key = key.substring(5); + } + if (subKeyIsType) + { + subKey = subKey.substring(5); + } + + int runningTotal = 0; + final List<Ability> abilityList = + buildAbilityList(character, categoryName, category); + if (!abilityList.isEmpty()) + { + for (Ability ability : abilityList) + { + final String abilityKey = ability.getKeyName(); + if (keyIsAny || (!keyIsType && abilityKey.equalsIgnoreCase(key)) + || (keyIsType && ability.isType(key))) + { + // either this feat has matched on the name, or the type + + if (subKey != null) + { + runningTotal += + checkForSubKeyMatch(character, countMults, key, + subKey, subKeyIsType, ability); + } + else + { + // Subkey == null + + runningTotal++; + if (ability.isMultiples() && countMults) + { + runningTotal += (ability.getAssociatedCount() - 1); + } + } + } + else + { + if (subKey != null) + { + final String s1 = key + " (" + subKey + ")"; + final String s2 = key + "(" + subKey + ")"; + if (abilityKey.equalsIgnoreCase(s1) + || ability.getKeyName().equalsIgnoreCase(s2)) + { + runningTotal++; + if (!countMults) + { + break; + } + } + } + } + } + } + + runningTotal = prereq.getOperator().compare(runningTotal, number); + return countedTotal(prereq, runningTotal); + } + + /** + * Having matched the ability on the other criteria, check for a match + * against the sub-key. + * + * @param character The character being tested. + * @param countMults Should multiple occurrences be counted? + * @param key The key that needs to be matched + * @param subKey The sub key that needs to be matched. + * @param subKeyIsType Does the subkey refer to a type? + * @param aFeat The ability being checked for a match. + * @return The number of matches made + */ + private int checkForSubKeyMatch(final PlayerCharacter character, final boolean countMults, String key, String subKey, final boolean subKeyIsType, Ability aFeat) + { + final String cType = subKey; + final List availableList = new ArrayList(); + final List selectedList = new ArrayList(); + final String aChoiceString = aFeat.getChoiceString(); + int runningTotal = 0; + + aFeat.modChoices(availableList, selectedList, false, + character, true); + availableList.clear(); + + if (subKeyIsType) // TYPE syntax + { + if (aChoiceString.startsWith("SKILL")) //$NON-NLS-1$ + { + runningTotal = + subKeySkill(countMults, runningTotal, + cType, selectedList); + } + else if (aChoiceString.startsWith("WEAPONPROFS")) //$NON-NLS-1$ + { + runningTotal = + subKeyWeaponProf(countMults, + runningTotal, cType, selectedList); + } + else if (aChoiceString.startsWith("DOMAIN")) //$NON-NLS-1$ + { + runningTotal = + subKeyDomain(countMults, runningTotal, + cType, selectedList); + } + else if (aChoiceString.startsWith("SPELL")) //$NON-NLS-1$ + { + runningTotal = + subKeySpell(countMults, runningTotal, + cType, selectedList); + } + // End. subKeyIsType + } + else + { + if (aFeat.getKeyName().equalsIgnoreCase(key) + && aFeat.containsAssociated(subKey)) + { + runningTotal++; + if (aFeat.isMultiples() && countMults) + { + runningTotal += + (aFeat.getAssociatedCount() - 1); + } + } + else + { + final int wildCardPos = subKey.indexOf('%'); + + if (wildCardPos > -1) + { + for (int k = 0; k < aFeat + .getAssociatedCount(); ++k) + { + + final String fString = + aFeat.getAssociated(k) + .toUpperCase(); + if (wildCardPos == 0 + || fString.startsWith(subKey + .substring(0, wildCardPos - 1) + .toUpperCase())) + { + runningTotal++; + if (!countMults) + { + break; + } + } + } + } + } + } + return runningTotal; + } + + /** + * Build up a list of the character's abilities which match the category requirements. + * @param character The character to be tested. + * @param categoryName The name of the required category, null if any category will be matched. + * @param category The category to be matched + * @return A list of categories matching. + */ + private List<Ability> buildAbilityList(final PlayerCharacter character, String categoryName, AbilityCategory category) + { + final List<Ability> abilityList = new ArrayList<Ability>(); + if (character != null) + { + if (categoryName == null) + { + Collection<AbilityCategory> allCats = SettingsHandler.getGame().getAllAbilityCategories(); + for (AbilityCategory aCat : allCats) + { + abilityList.addAll(character.getAggregateAbilityList(aCat)); + } + } + else + { + abilityList.addAll(character.getAggregateAbilityList(category)); + } + } + return abilityList; + } + + /** + * @param countMults + * @param runningTotal + * @param cType + * @param selectedList + * @return int + */ + private int subKeySpell(final boolean countMults, int runningTotal, + final String cType, final List selectedList) + { + int returnTotal = runningTotal; + for (Object aObj : selectedList) + { + final Spell sp; + String spellKey = null; + if (aObj instanceof PObject) + { + spellKey = ((PObject) aObj).getKeyName(); + } + else + { + spellKey = aObj.toString(); + } + sp = Globals.getSpellKeyed(spellKey); + if (sp == null) + { + continue; + } + if (sp.isType(cType)) + { + returnTotal++; + if (!countMults) + { + break; + } + } + } + return returnTotal; + } + + /** + * @param countMults + * @param runningTotal + * @param cType + * @param selectedList + * @return int + */ + private int subKeyDomain(final boolean countMults, int runningTotal, + final String cType, final List selectedList) + { + int returnTotal = runningTotal; + for (Object aObj : selectedList) + { + final Domain dom; + dom = Globals.getDomainKeyed(aObj.toString()); + if (dom == null) + { + continue; + } + if (dom.isType(cType)) + { + returnTotal++; + if (!countMults) + { + break; + } + } + } + return returnTotal; + } + + /** + * @param countMults + * @param runningTotal + * @param cType + * @param selectedList + * @return int + */ + private int subKeyWeaponProf(final boolean countMults, int runningTotal, + final String cType, final List selectedList) + { + int returnTotal = runningTotal; + for (Object aObj : selectedList) + { + final WeaponProf wp; + wp = Globals.getWeaponProfKeyed(aObj.toString()); + if (wp == null) + { + continue; + } + final Equipment eq; + eq = EquipmentList.getEquipmentKeyed(wp.getKeyName()); + if (eq == null) + { + continue; + } + if (eq.isType(cType)) + { + returnTotal++; + if (!countMults) + { + break; + } + } + } + return returnTotal; + } + + /** + * @param countMults + * @param runningTotal + * @param cType + * @param selectedList + * @return int + */ + private int subKeySkill(final boolean countMults, int runningTotal, + final String cType, final List selectedList) + { + int returnTotal = runningTotal; + for (Object aObj : selectedList) + { + final Skill sk; + sk = Globals.getSkillKeyed(aObj.toString()); + if (sk == null) + { + continue; + } + if (sk.isType(cType)) + { + returnTotal++; + if (!countMults) + { + break; + } + } + } + return returnTotal; + } + + @Override + public String toHtmlString(final Prerequisite prereq) + { + String aString = prereq.getKey(); + if ((prereq.getSubKey() != null) && !prereq.getSubKey().equals("")) + { + aString = aString + " ( " + prereq.getSubKey() + " )"; + } + + if (aString.startsWith("TYPE=")) //$NON-NLS-1$ + { + if (prereq.getCategoryName().length() > 0) + { + // {0} {1} {2}(s) of type {3} + return PropertyFactory.getFormattedString("PreAbility.type.toHtml", //$NON-NLS-1$ + new Object[]{prereq.getOperator().toDisplayString(), + prereq.getOperand(), + prereq.getCategoryName(), + aString.substring(5)}); + } + else + { + // {0} {1} ability(s) of type {2} + return PropertyFactory.getFormattedString("PreAbility.type.noCat.toHtml", //$NON-NLS-1$ + new Object[]{prereq.getOperator().toDisplayString(), + prereq.getOperand(), + aString.substring(5)}); + } + + } + // {2} {3} {1} {0} + return PropertyFactory.getFormattedString("PreAbility.toHtml", //$NON-NLS-1$ + new Object[]{prereq.getCategoryName(), + aString, prereq.getOperator().toDisplayString(), + prereq.getOperand()}); + } + + /* + * (non-Javadoc) + * + * @see pcgen.core.prereq.PrerequisiteTest#kindsHandled() + */ + public String kindHandled() + { + return "ABILITY"; //$NON-NLS-1$ + } + +} Property changes on: Trunk/pcgen/code/src/java/plugin/pretokens/test/PreAbilityTester.java ___________________________________________________________________ Name: keywords + Author Revision Date Id Name: svn:eol-style + native Added: Trunk/pcgen/code/src/java/plugin/pretokens/writer/PreAbilityWriter.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/pretokens/writer/PreAbilityWriter.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/pretokens/writer/PreAbilityWriter.java 2007-01-23 21:51:17 UTC (rev 2017) @@ -0,0 +1,108 @@ +/* + * PrerequisiteFeatWriter.java + * + * Copyright 2004 (C) Frugal <frugal@...> + * + * 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 17:12:38 +1100 (Thu, 28 Dec 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; + +/** + * <code>PreAbilityWriter</code> outputs ability prereqs. + * + * Last Editor: $Author: jdempsey $ + * Last Edited: $Date: 2006-12-17 15:36:01 +1100 (Sun, 17 Dec 2006) $ + * + * @author James Dempsey <jdempsey@...> + * @version $Revision: 1777 $ + */ +public class PreAbilityWriter extends AbstractPrerequisiteWriter implements + PrerequisiteWriterInterface +{ + + /* (non-Javadoc) + * @see pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface#kindHandled() + */ + public String kindHandled() + { + return "ability"; + } + + /* (non-Javadoc) + * @see pcgen.persistence.lst.output.prereq.PrerequisiteWriterInterface#operatorsHandled() + */ + public PrerequisiteOperator[] operatorsHandled() + { + return new PrerequisiteOperator[]{PrerequisiteOperator.GTEQ, + PrerequisiteOperator.LT}; + } + + /* (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 + { + checkValidOperator(prereq, operatorsHandled()); + try + { + if (prereq.getOperator().equals(PrerequisiteOperator.LT)) + { + writer.write('!'); + } + writer.write("PREABILITY:" + (prereq.isOverrideQualify() ? "Q:":"")); + writer.write(prereq.getOperand()); + writer.write(','); + if (prereq.isCountMultiples()) + { + writer.write("CHECKMULT,"); + } + if (prereq.getCategoryName().length() >0) + { + writer.write("CATEGORY." + prereq.getCategoryName() + ","); + } + writer.write(prereq.getKey()); + if (prereq.getSubKey() != null) + { + writer.write(" ("); + writer.write(prereq.getSubKey()); + writer.write(")"); + } + } + catch (IOException e) + { + throw new PersistenceLayerException(e.getMessage()); + } + } + +} Property changes on: Trunk/pcgen/code/src/java/plugin/pretokens/writer/PreAbilityWriter.java ___________________________________________________________________ Name: keywords + Author Revision Date Id Name: svn:eol-style + native Added: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreAbilityTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/core/prereq/PreAbilityTest.java (rev 0) +++ Trunk/pcgen/code/src/test/pcgen/core/prereq/PreAbilityTest.java 2007-01-23 21:51:17 UTC (rev 2017) @@ -0,0 +1,161 @@ +/* + * PreAbilityTest.java + * Copyright 2007 (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 24/01/2007 + * + * $Id: $ + */ + +package pcgen.core.prereq; + +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.prereq.Prerequisite; +import pcgen.persistence.PersistenceLayerException; +import pcgen.util.TestHelper; +import plugin.pretokens.parser.PreAbilityParser; + +/** + * <code>PreAbilityTest</code> verifies the function of the + * PreAbilityTester. + * + * Last Editor: $Author: $ + * Last Edited: $Date: $ + * + * @author James Dempsey <jdempsey@...> + * @version $Revision: $ + */ +public class PreAbilityTest extends AbstractCharacterTestCase +{ + + /** + * @return Test + */ + public static Test suite() + { + return new TestSuite(PreAbilityTest.class); + } + + /** + * Test the function of the ANY key + * @throws PersistenceLayerException + */ + public void testAnyMatch() throws PersistenceLayerException + { + PlayerCharacter character = getCharacter(); + PreAbilityParser parser = new PreAbilityParser(); + Prerequisite prereq = + parser.parse("ability", "1,CATEGORY.ANY,ANY", + false, false); + assertFalse("Test any match with no abilities.", PrereqHandler.passes( + prereq, character, null)); + + Ability ab2 = + TestHelper.makeAbility("Dancer", "BARDIC", + "General.Bardic"); + ab2.setMultiples("NO"); + character.addAbility(TestHelper.getAbilityCategory(ab2), ab2, null); + + assertTrue("Test any match with an ability.", PrereqHandler.passes( + prereq, character, null)); + + } + + /** + * Test the function of the catgeory matching + * @throws PersistenceLayerException + */ + public void testCategoryMatch() throws PersistenceLayerException + { + PlayerCharacter character = getCharacter(); + PreAbilityParser parser = new PreAbilityParser(); + Prerequisite prereq = + parser.parse("ability", "1,CATEGORY.ANY,ANY", + false, false); + assertFalse("Test any match with no abilities.", PrereqHandler.passes( + prereq, character, null)); + Prerequisite prereq2 = + parser.parse("ability", "1,CATEGORY.BARDIC,ANY", + false, false); + assertFalse("Test bardic match with no abilities.", PrereqHandler.passes( + prereq2, character, null)); + Prerequisite prereq3 = + parser.parse("ability", "1,CATEGORY.FEAT,ANY", + false, false); + assertFalse("Test feat match with no abilities.", PrereqHandler.passes( + prereq3, character, null)); + + Ability ab2 = + TestHelper.makeAbility("Dancer", "BARDIC", + "General.Bardic"); + ab2.setMultiples("NO"); + character.addAbility(TestHelper.getAbilityCategory(ab2), ab2, null); + + assertTrue("Test any match with an ability.", PrereqHandler.passes( + prereq, character, null)); + assertTrue("Test bardic match with an ability.", PrereqHandler.passes( + prereq2, character, null)); + assertFalse("Test feat match with an ability.", PrereqHandler.passes( + prereq3, character, null)); + + } + + /** + * Test the function of the catgeory matching + * @throws PersistenceLayerException + */ + public void testKeyMatch() throws PersistenceLayerException + { + PlayerCharacter character = getCharacter(); + PreAbilityParser parser = new PreAbilityParser(); + Prerequisite prereq = + parser.parse("ability", "1,CATEGORY.ANY,KEY_Dancer", + false, false); + assertFalse("Test any match with no abilities.", PrereqHandler.passes( + prereq, character, null)); + Prerequisite prereq2 = + parser.parse("ability", "1,KEY_Alertness", + false, false); + assertFalse("Test bardic match with no abilities.", PrereqHandler.passes( + prereq2, character, null)); + Prerequisite prereq3 = + parser.parse("ability", "1,CATEGORY.FEAT,KEY_Dancer", + false, false); + assertFalse("Test feat match with no abilities.", PrereqHandler.passes( + prereq3, character, null)); + + Ability ab2 = + TestHelper.makeAbility("Dancer", "BARDIC", + "General.Bardic"); + ab2.setMultiples("NO"); + character.addAbility(TestHelper.getAbilityCategory(ab2), ab2, null); + + assertTrue("Test any match with an ability.", PrereqHandler.passes( + prereq, character, null)); + assertFalse("Test bardic match with an ability.", PrereqHandler.passes( + prereq2, character, null)); + assertFalse("Test feat match with an ability.", PrereqHandler.passes( + prereq3, character, null)); + + } + +} Property changes on: Trunk/pcgen/code/src/test/pcgen/core/prereq/PreAbilityTest.java ___________________________________________________________________ Name: keywords + Author Revision Date Id Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/test/pcgen/persistence/lst/output/prereq/PrerequisiteWriterTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/persistence/lst/output/prereq/PrerequisiteWriterTest.java 2007-01-23 16:01:42 UTC (rev 2016) +++ Trunk/pcgen/code/src/test/pcgen/persistence/lst/output/prereq/PrerequisiteWriterTest.java 2007-01-23 21:51:17 UTC (rev 2017) @@ -78,6 +78,7 @@ // // Examples from the PCGen documentation - note that there are two columns for each entry below // + "PREABILITY:1,Sneak Attack,CATEGORY.Special Attack", "PREABILITY:1,CHECKMULT,CATEGORY.Special Attack,Sneak Attack", "PREALIGN:LG,NG,CG", "PREMULT:1,[PREALIGN:LG],[PREALIGN:NG],[PREALIGN:CG]", "PREALIGN:2,5,8", "PREMULT:1,[PREALIGN:LE],[PREALIGN:NE],[PREALIGN:CE]", "PREALIGN:LG,Deity", "PREMULT:1,[PREALIGN:LG],[PREALIGN:Deity]", Added: Trunk/pcgen/code/src/test/pcgen/persistence/lst/prereq/PreAbilityParserTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/persistence/lst/prereq/PreAbilityParserTest.java (rev 0) +++ Trunk/pcgen/code/src/test/pcgen/persistence/lst/prereq/PreAbilityParserTest.java 2007-01-23 21:51:17 UTC (rev 2017) @@ -0,0 +1,130 @@ +/* + * PreAbilityParserTest.java + * Copyright 2007 (C) James Dempsey <jdempsey@...> + * + * 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 January 23, 2006 + * + * Current Ver: $Revision: 1777 $ + * Last Editor: $Author: jdempsey $ + * Last Edited: $Date: 2006-12-17 15:36:01 +1100 (Sun, 17 Dec 2006) $ + * + */ +package pcgen.persistence.lst.prereq; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.textui.TestRunner; +import pcgen.core.Globals; +import pcgen.core.SettingsHandler; +import pcgen.core.prereq.Prerequisite; +import plugin.pretokens.parser.PreAbilityParser; + +/** + * <code>PreAbilityParserTest</code> tests the function of the + * PREABILITY parser. + * + * Last Editor: $Author: jdempsey $ + * Last Edited: $Date: 2006-12-17 15:36:01 +1100 (Sun, 17 Dec 2006) $ + * + * @author James Dempsey <jdempsey@...> + * @version $Revision: 1777 $ + */ +public class PreAbilityParserTest extends TestCase +{ + public static void main(String args[]) + { + TestRunner.run(PreAbilityParserTest.class); + } + + /** + * @return Test + */ + public static Test suite() + { + return new TestSuite(PreAbilityParserTest.class); + } + + /** + * @throws Exception + */ + public void testCategoryInterpretation() throws Exception + { + + PreAbilityParser parser = new PreAbilityParser(); + Prerequisite prereq = parser.parse("ability", "1,CATEGORY.Mutation,Sneak Attack", false, false); + assertEquals("Category specified for single key", + "<prereq operator=\"gteq\" operand=\"1\" >\n" + + "<prereq kind=\"ability\" count-multiples=\"true\" category=\"Mutation\" key=\"Sneak Attack\" operator=\"gteq\" operand=\"1\" >\n" + + "</prereq>\n" + "</prereq>\n" + "", prereq.toString()); + + prereq = parser.parse("ability", "2,CATEGORY.Mutation,Foo,Bar", false, false); + assertEquals("Category specified for multiple keys", + "<prereq operator=\"gteq\" operand=\"2\" >\n" + + "<prereq kind=\"ability\" count-multiples=\"true\" category=\"Mutation\" key=\"Foo\" operator=\"gteq\" operand=\"1\" >\n" + + "</prereq>\n" + + "<prereq kind=\"ability\" count-multiples=\"true\" category=\"Mutation\" key=\"Bar\" operator=\"gteq\" operand=\"1\" >\n" + + "</prereq>\n" + "</prereq>\n" + "", prereq.toString()); + + prereq = parser.parse("ability", "1,CATEGORY.ANY,Sneak Attack", false, false); + assertEquals("Category of ANY specified for single key", + "<prereq operator=\"gteq\" operand=\"1\" >\n" + + "<prereq kind=\"ability\" count-multiples=\"true\" key=\"Sneak Attack\" operator=\"gteq\" operand=\"1\" >\n" + + "</prereq>\n" + "</prereq>\n" + "", prereq.toString()); + + prereq = parser.parse("ability", "1,CATEGORY.ANY,Foo,Bar", false, false); + assertEquals("Category specified for multiple key", + "<prereq operator=\"gteq\" operand=\"1\" >\n" + + "<prereq kind=\"ability\" count-multiples=\"true\" key=\"Foo\" operator=\"gteq\" operand=\"1\" >\n" + + "</prereq>\n" + + "<prereq kind=\"ability\" count-multiples=\"true\" key=\"Bar\" operator=\"gteq\" operand=\"1\" >\n" + + "</prereq>\n" + + "</prereq>\n" + "", prereq.toString()); + } + + /** + * @throws Exception + */ + public void testSingleEntry() throws Exception + { + + PreAbilityParser parser = new PreAbilityParser(); + Prerequisite prereq = parser.parse("ability", "1,Sneak Attack", false, false); + assertEquals("Category not specified for single key", + "<prereq kind=\"ability\" key=\"Sneak Attack\" operator=\"gteq\" operand=\"1\" >\n" + + "</prereq>\n" + "", prereq.toString()); + } + + /** + * @throws Exception + */ + public void testNoKey() throws Exception + { + + PreAbilityParser parser = new PreAbilityParser(); + Prerequisite prereq = parser.parse("ability", "1,CATEGORY.Mutation", false, false); + assertEquals("Category specified for no key", + "<prereq kind=\"ability\" category=\"Mutation\" key=\"ANY\" operator=\"gteq\" operand=\"1\" >\n" + + "</prereq>\n" + "", prereq.toString()); + } + protected void setUp() throws Exception + { + Globals.setUseGUI(false); + Globals.emptyLists(); + SettingsHandler.setGame("3.5"); + } +} \ No newline at end of file Property changes on: Trunk/pcgen/code/src/test/pcgen/persistence/lst/prereq/PreAbilityParserTest.java ___________________________________________________________________ Name: keywords + Author Revision Date Id Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/test/pcgen/util/TestHelper.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/util/TestHelper.java 2007-01-23 16:01:42 UTC (rev 2016) +++ Trunk/pcgen/code/src/test/pcgen/util/TestHelper.java 2007-01-23 21:51:17 UTC (rev 2017) @@ -29,6 +29,7 @@ import java.util.Arrays; import java.util.StringTokenizer; import pcgen.core.Ability; +import pcgen.core.AbilityCategory; import pcgen.core.Campaign; import pcgen.core.Constants; import pcgen.core.Equipment; @@ -254,4 +255,20 @@ return aRace; } + /** + * @param ability + * @return + */ + public static AbilityCategory getAbilityCategory(Ability ability) + { + AbilityCategory aCategory = + SettingsHandler.getGame().getAbilityCategory(ability.getCategory()); + if (aCategory == null) + { + aCategory = new AbilityCategory(ability.getCategory()); + SettingsHandler.getGame().addAbilityCategory(aCategory); + } + return aCategory; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <thpr@us...> - 2007-02-17 03:18:31
|
Revision: 2153 http://svn.sourceforge.net/pcgen/?rev=2153&view=rev Author: thpr Date: 2007-02-16 19:18:31 -0800 (Fri, 16 Feb 2007) Log Message: ----------- [ 1662066 ] Deprecate NAME Token Issue#: 1662066 Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/NameLst.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/NameLst.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2007-02-17 01:05:14 UTC (rev 2152) +++ Trunk/pcgen/code/pluginbuild.xml 2007-02-17 03:18:31 UTC (rev 2153) @@ -2043,13 +2043,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/LstToken-NAME.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/NameLst.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/LstToken-NAMEISPI.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -5891,6 +5884,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/LstToken-DEPRECATED-NAME.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/deprecated/NameLst.class" /> + </patternset> + </fileset> + </jar> </target> <target name="manifest" description="Write the Java manifest"> Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/NameLst.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/NameLst.java 2007-02-17 01:05:14 UTC (rev 2152) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/NameLst.java 2007-02-17 03:18:31 UTC (rev 2153) @@ -1,27 +0,0 @@ -/* - * Created on Sep 2, 2005 - * - */ -package plugin.lsttokens; - -import pcgen.core.PObject; -import pcgen.persistence.lst.GlobalLstToken; - -/** - * @author djones4 - * - */ -public class NameLst implements GlobalLstToken -{ - - public String getTokenName() - { - return "NAME"; - } - - public boolean parse(PObject obj, String value, int anInt) - { - obj.setName(value); - return true; - } -} Copied: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/NameLst.java (from rev 2134, Trunk/pcgen/code/src/java/plugin/lsttokens/NameLst.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/NameLst.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/NameLst.java 2007-02-17 03:18:31 UTC (rev 2153) @@ -0,0 +1,35 @@ +/* + * Created on Sep 2, 2005 + * + */ +package plugin.lsttokens.deprecated; + +import pcgen.core.PObject; +import pcgen.persistence.lst.DeprecatedToken; +import pcgen.persistence.lst.GlobalLstToken; +import pcgen.util.Logging; + +/** + * @author djones4 + * + */ +public class NameLst implements GlobalLstToken, DeprecatedToken +{ + + public String getTokenName() + { + return "NAME"; + } + + public boolean parse(PObject obj, String value, int anInt) + { + Logging.errorPrint("You are performing a dangerous action: " + + "You should not use the NAME Token"); + obj.setName(value); + return true; + } + + public String getMessage(PObject obj, String value) { + return "You are performing a dangerous action: You should not use the NAME Token"; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <thpr@us...> - 2007-02-28 21:04:47
|
Revision: 2246 http://svn.sourceforge.net/pcgen/?rev=2246&view=rev Author: thpr Date: 2007-02-28 13:04:48 -0800 (Wed, 28 Feb 2007) Log Message: ----------- [ 1671219 ] Deprecate Race's AC Token Issue#: 1671219 Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/RaceAcToken.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/race/AcToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2007-02-28 20:50:51 UTC (rev 2245) +++ Trunk/pcgen/code/pluginbuild.xml 2007-02-28 21:04:48 UTC (rev 2246) @@ -3427,13 +3427,6 @@ <target name="jar-lst-race-plugins" depends="makeplugindirs" description="Build (Link) Race Lst Token plugin jar files"> <!-- Race tokens--> - <jar jarfile="${lstplugins.dir}/RaceLstToken-AC.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/race/AcToken.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> @@ -5930,6 +5923,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/RaceLstToken-DEPRECATED-AC.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/deprecated/RaceAcToken.class" /> + </patternset> + </fileset> + </jar> </target> <target name="manifest" description="Write the Java manifest"> Added: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/RaceAcToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/RaceAcToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/RaceAcToken.java 2007-02-28 21:04:48 UTC (rev 2246) @@ -0,0 +1,36 @@ +package plugin.lsttokens.deprecated; + +import pcgen.core.PObject; +import pcgen.core.Race; +import pcgen.persistence.lst.DeprecatedToken; +import pcgen.persistence.lst.RaceLstToken; + +/** + * Class deals with AC Token + */ +public class RaceAcToken implements RaceLstToken, DeprecatedToken +{ + + public String getTokenName() + { + return "AC"; + } + + public boolean parse(Race race, String value) + { + try + { + race.setStartingAC(Integer.valueOf(value)); + return true; + } + catch (NumberFormatException nfe) + { + return false; + } + } + + public String getMessage(PObject obj, String value) + { + return "AC in Race is a non-functioning Token"; + } +} Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/race/AcToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/race/AcToken.java 2007-02-28 20:50:51 UTC (rev 2245) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/race/AcToken.java 2007-02-28 21:04:48 UTC (rev 2246) @@ -1,29 +0,0 @@ -package plugin.lsttokens.race; - -import pcgen.core.Race; -import pcgen.persistence.lst.RaceLstToken; - -/** - * Class deals with AC Token - */ -public class AcToken implements RaceLstToken -{ - - public String getTokenName() - { - return "AC"; - } - - public boolean parse(Race race, String value) - { - try - { - race.setStartingAC(Integer.valueOf(value)); - return true; - } - catch (NumberFormatException nfe) - { - return false; - } - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <thpr@us...> - 2007-03-05 00:06:55
|
Revision: 2384 http://svn.sourceforge.net/pcgen/?rev=2384&view=rev Author: thpr Date: 2007-03-04 16:06:55 -0800 (Sun, 04 Mar 2007) Log Message: ----------- [ 1673230 ] CLEAR behavior in DOMAINS: and CLASSES: Tokens Formally Deprecate Spell's SPELLLEVEL Token (has had a deprecation message in it for some time, replaced by CLASSES and DOMAINS) Issue#: 1673230 Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/spell/Spell.java Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/SpellLoader.java Trunk/pcgen/code/src/java/plugin/lsttokens/spell/ClassesToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/spell/DomainsToken.java Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SpelllevelToken.java Removed Paths: ------------- Trunk/pcgen/code/src/java/plugin/lsttokens/spell/SpelllevelToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2007-03-04 23:52:08 UTC (rev 2383) +++ Trunk/pcgen/code/pluginbuild.xml 2007-03-05 00:06:55 UTC (rev 2384) @@ -3754,13 +3754,6 @@ </patternset> </fileset> </jar> - <jar jarfile="${lstplugins.dir}/SpellLstToken-SPELLLEVEL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> - <fileset dir="${build.classes.dir}"> - <patternset> - <include name="plugin/lsttokens/spell/SpelllevelToken.class" /> - </patternset> - </fileset> - </jar> <jar jarfile="${lstplugins.dir}/SpellLstToken-SPELLRES.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> @@ -5955,6 +5948,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/SpellLstToken-DEPRECATED-SPELLLEVEL.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/deprecated/SpelllevelToken.class" /> + </patternset> + </fileset> + </jar> </target> <target name="manifest" description="Write the Java manifest"> Modified: Trunk/pcgen/code/src/java/pcgen/core/spell/Spell.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/spell/Spell.java 2007-03-04 23:52:08 UTC (rev 2383) +++ Trunk/pcgen/code/src/java/pcgen/core/spell/Spell.java 2007-03-05 00:06:55 UTC (rev 2384) @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -520,30 +521,35 @@ } } + public void clearLevelInfo(String type) + { + String typeBar = type + "|"; + for (Iterator<String> it = levelInfo.keySet().iterator(); it.hasNext(); ) + { + if (it.next().startsWith(typeBar)) + { + it.remove(); + } + } + } + public void setLevelInfo(final String key, final int level) { - if (".CLEAR".equals(key)) + if (level == -1) { - levelInfo = null; + if (levelInfo != null) + { + levelInfo.remove(key); + } } else { - if (level == -1) + if (levelInfo == null) { - if (levelInfo != null) - { - levelInfo.remove(key); - } + levelInfo = new HashMap<String, Integer>(); } - else - { - if (levelInfo == null) - { - levelInfo = new HashMap<String, Integer>(); - } - levelInfo.put(key, Integer.valueOf(level)); - } + levelInfo.put(key, Integer.valueOf(level)); } } @@ -927,6 +933,7 @@ } } + @Deprecated public void clearLevelInfo() { levelInfo = null; Modified: Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2007-03-04 23:52:08 UTC (rev 2383) +++ Trunk/pcgen/code/src/java/pcgen/gui/editor/EditorMainForm.java 2007-03-05 00:06:55 UTC (rev 2384) @@ -871,7 +871,8 @@ case EditorConstants.EDIT_SPELL: ((SpellBasePanel2) pnlBase2).updateData(thisPObject); - ((Spell) thisPObject).setLevelInfo(".CLEAR", 0); + ((Spell) thisPObject).clearLevelInfo("CLASS"); + ((Spell) thisPObject).clearLevelInfo("DOMAIN"); sel = pnlQClasses.getSelectedList(); for (int i = 0; i < sel.length; ++i) Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/SpellLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/SpellLoader.java 2007-03-04 23:52:08 UTC (rev 2383) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/SpellLoader.java 2007-03-05 00:06:55 UTC (rev 2384) @@ -217,13 +217,6 @@ public static void setLevelList(Spell spell, final String typeString, String listString) throws PersistenceLayerException { - if (listString.equals(".CLEAR")) - { - spell.clearLevelInfo(); - - return; - } - String preReqTag = null; final int i = listString.lastIndexOf('['); int j = listString.lastIndexOf(']'); Copied: Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SpelllevelToken.java (from rev 2381, Trunk/pcgen/code/src/java/plugin/lsttokens/spell/SpelllevelToken.java) =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SpelllevelToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/deprecated/SpelllevelToken.java 2007-03-05 00:06:55 UTC (rev 2384) @@ -0,0 +1,39 @@ +package plugin.lsttokens.deprecated; + +import java.util.StringTokenizer; + +import pcgen.core.PObject; +import pcgen.core.spell.Spell; +import pcgen.persistence.lst.DeprecatedToken; +import pcgen.persistence.lst.SpellLstToken; + +/** + * Class deals with SPELLLEVEL Token + */ +public class SpelllevelToken implements SpellLstToken, DeprecatedToken +{ + + public String getTokenName() + { + return "SPELLLEVEL"; + } + + public boolean parse(Spell spell, String value) + { + final StringTokenizer slTok = new StringTokenizer(value, "|"); + + while (slTok.countTokens() >= 3) + { + final String typeString = slTok.nextToken(); + final String mainString = slTok.nextToken(); + spell + .setLevelInfo(typeString + "|" + mainString, slTok.nextToken()); + } + return true; + } + + public String getMessage(PObject obj, String value) + { + return "Warning: tag 'SPELLLEVEL' has been deprecated. Use CLASSES or DOMAINS tag instead."; + } +} Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/spell/ClassesToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/spell/ClassesToken.java 2007-03-04 23:52:08 UTC (rev 2383) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/spell/ClassesToken.java 2007-03-05 00:06:55 UTC (rev 2384) @@ -18,6 +18,19 @@ public boolean parse(Spell spell, String value) { + if (value.equals(".CLEAR")) + { + Logging.errorPrint(".CLEAR is deprecated in " + getTokenName() + + " because it has side effects on DOMAINS:"); + Logging.errorPrint(" please use .CLEARALL to clear only CLASSES"); + spell.clearLevelInfo(); + return true; + } + else if (value.equals(".CLEARALL")) + { + spell.clearLevelInfo("CLASS"); + return true; + } try { SpellLoader.setLevelList(spell, "CLASS", value); Modified: Trunk/pcgen/code/src/java/plugin/lsttokens/spell/DomainsToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/spell/DomainsToken.java 2007-03-04 23:52:08 UTC (rev 2383) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/spell/DomainsToken.java 2007-03-05 00:06:55 UTC (rev 2384) @@ -18,6 +18,19 @@ public boolean parse(Spell spell, String value) { + if (value.equals(".CLEAR")) + { + Logging.errorPrint(".CLEAR is deprecated in " + getTokenName() + + " because it has side effects on CLASSES:"); + Logging.errorPrint(" please use .CLEARALL to clear only DOMAINS"); + spell.clearLevelInfo(); + return true; + } + else if (value.equals(".CLEARALL")) + { + spell.clearLevelInfo("DOMAIN"); + return true; + } try { SpellLoader.setLevelList(spell, "DOMAIN", value); Deleted: Trunk/pcgen/code/src/java/plugin/lsttokens/spell/SpelllevelToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/spell/SpelllevelToken.java 2007-03-04 23:52:08 UTC (rev 2383) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/spell/SpelllevelToken.java 2007-03-05 00:06:55 UTC (rev 2384) @@ -1,38 +0,0 @@ -package plugin.lsttokens.spell; - -import java.util.StringTokenizer; - -import pcgen.core.spell.Spell; -import pcgen.persistence.lst.SpellLstToken; -import pcgen.util.Logging; - -/** - * Class deals with SPELLLEVEL Token - */ -public class SpelllevelToken implements SpellLstToken -{ - - public String getTokenName() - { - return "SPELLLEVEL"; - } - - public boolean parse(Spell spell, String value) - { - //TODO: When will this deprecated tag be removed? Or will it remain indefinitely? - Logging - .errorPrint("Warning: tag 'SPELLLEVEL' has been deprecated. Use CLASSES or DOMAINS tag instead."); - - final StringTokenizer slTok = new StringTokenizer(value, "|"); - - while (slTok.countTokens() >= 3) - { - final String typeString = slTok.nextToken(); - final String mainString = slTok.nextToken(); - // TODO SPELLLIST need to figure out what this syntax is - spell - .setLevelInfo(typeString + "|" + mainString, slTok.nextToken()); - } - return true; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <thpr@us...> - 2007-03-15 22:05:49
|
Revision: 2513 http://svn.sourceforge.net/pcgen/?rev=2513&view=rev Author: thpr Date: 2007-03-15 15:05:50 -0700 (Thu, 15 Mar 2007) Log Message: ----------- [ 1681079 ] Gamemode tag LOAD to accept negative Strength values Issue#: 1681079 Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/GameMode.java Trunk/pcgen/code/src/java/pcgen/core/Globals.java Trunk/pcgen/code/src/java/pcgen/core/system/LoadInfo.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/AbilityCategoryLoader.java Added Paths: ----------- Trunk/pcgen/code/src/java/plugin/lsttokens/load/LoadmultstepToken.java Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2007-03-15 17:12:38 UTC (rev 2512) +++ Trunk/pcgen/code/pluginbuild.xml 2007-03-15 22:05:50 UTC (rev 2513) @@ -5733,6 +5733,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${systemlstplugins.dir}/Load-LOADMULTSTEP.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/load/LoadmultstepToken.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${systemlstplugins.dir}/Load-MODIFIER.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-03-15 17:12:38 UTC (rev 2512) +++ Trunk/pcgen/code/src/java/pcgen/core/GameMode.java 2007-03-15 22:05:50 UTC (rev 2513) @@ -94,7 +94,7 @@ private String displayVariable3Text = ""; private String displayVariableName = ""; private String displayVariableText = ""; - private String folderName = "";; + private String folderName = ""; private String hpAbbrev = ""; private String hpName = ""; private String levelUpMessage = ""; @@ -3153,6 +3153,17 @@ */ public AbilityCategory getAbilityCategory(final String aKey) { + AbilityCategory ac = silentlyGetAbilityCategory(aKey); + if (ac == null) + { + Logging.errorPrint("Attempt to fetch AbilityCategory: " + aKey + + "... but it does not exist"); + } + return ac; + } + + public AbilityCategory silentlyGetAbilityCategory(final String aKey) + { for ( final AbilityCategory cat : getAllAbilityCategories() ) { if ( cat.getKeyName().equalsIgnoreCase(aKey) ) Modified: Trunk/pcgen/code/src/java/pcgen/core/Globals.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2007-03-15 17:12:38 UTC (rev 2512) +++ Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2007-03-15 22:05:50 UTC (rev 2513) @@ -2493,11 +2493,6 @@ */ public static Load loadTypeForLoadScore(int loadScoreValue, final Float weight, final PlayerCharacter aPC) { - if (loadScoreValue < 0) - { - loadScoreValue = 0; - } - final double dbl = weight.doubleValue() / maxLoadForLoadScore(loadScoreValue, aPC).doubleValue(); if (SystemCollections.getLoadInfo().getLoadMultiplier("LIGHT") != null && Modified: Trunk/pcgen/code/src/java/pcgen/core/system/LoadInfo.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/system/LoadInfo.java 2007-03-15 17:12:38 UTC (rev 2512) +++ Trunk/pcgen/code/src/java/pcgen/core/system/LoadInfo.java 2007-03-15 22:05:50 UTC (rev 2513) @@ -25,10 +25,10 @@ */ package pcgen.core.system; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; /** * <code>LoadInfo</code> describes the data associated with a loads and encumbrance @@ -37,8 +37,9 @@ * @version $Revision$ */ public class LoadInfo { - private List<Float> loadScoreList = new ArrayList<Float>(); + private SortedMap<Integer, Float> loadScoreList = new TreeMap<Integer, Float>(); private Float loadScoreMultiplier = new Float(0); + private int loadMultStep = 10; private Map<String, Float> sizeAdjustmentMap = new HashMap<String, Float>(); private Map<String, LoadInfo.LoadMapEntry> loadMultiplierMap = new HashMap<String, LoadInfo.LoadMapEntry>(); private int minScore = 0; @@ -61,12 +62,12 @@ */ public void addLoadScoreValue(int score, Float value) { - loadScoreList.add(score, value); + loadScoreList.put(score, value); if (score > maxScore) { maxScore = score; } - if (score < maxScore) + if (score < minScore) { minScore = score; } @@ -89,13 +90,22 @@ { return getLoadScoreValue(minScore); } - return new Float(loadScoreMultiplier.doubleValue() * getLoadScoreValue(score - 10).doubleValue()); + return new Float(loadScoreMultiplier.doubleValue() * getLoadScoreValue(score - loadMultStep).doubleValue()); } - else if (loadScoreList.get(score) == null) + else { - return getLoadScoreValue(score - 1); + Float loadScore = loadScoreList.get(score); + if (loadScore == null) + { + SortedMap<Integer, Float> headMap = loadScoreList.headMap(score); + /* + * Assume headMap is populated, since minScore is tested, above + * - thpr Mar 14, 2007 + */ + return loadScoreList.get(headMap.lastKey()); + } + return loadScore; } - return loadScoreList.get(score); } /** @@ -250,5 +260,10 @@ return checkPenalty.intValue(); } } + + public void setLoadMultStep(int step) + { + loadMultStep = step; + } } Modified: Trunk/pcgen/code/src/java/pcgen/persistence/lst/AbilityCategoryLoader.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/persistence/lst/AbilityCategoryLoader.java 2007-03-15 17:12:38 UTC (rev 2512) +++ Trunk/pcgen/code/src/java/pcgen/persistence/lst/AbilityCategoryLoader.java 2007-03-15 22:05:50 UTC (rev 2513) @@ -93,7 +93,7 @@ if (key.equals("ABILITYCATEGORY")) //$NON-NLS-1$ { final String value = colString.substring(idxColon + 1).trim(); - cat = aGameMode.getAbilityCategory(value); + cat = aGameMode.silentlyGetAbilityCategory(value); if (cat == null) { Added: Trunk/pcgen/code/src/java/plugin/lsttokens/load/LoadmultstepToken.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/lsttokens/load/LoadmultstepToken.java (rev 0) +++ Trunk/pcgen/code/src/java/plugin/lsttokens/load/LoadmultstepToken.java 2007-03-15 22:05:50 UTC (rev 2513) @@ -0,0 +1,51 @@ +/* + * LoadmultstepToken.java + * Copyright (c) 2007 Tom Parker <thpr@...> + * + * 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 March 14, 2007 + * + * Current Ver: $Revision: 1777 $ + * Last Editor: $Author: jdempsey $ + * Last Edited: $Date: 2006-12-16 23:36:01 -0500 (Sat, 16 Dec 2006) $ + * + */ +package plugin.lsttokens.load; + +import pcgen.core.system.LoadInfo; +import pcgen.persistence.lst.LoadInfoLstToken; + +public class LoadmultstepToken implements LoadInfoLstToken +{ + + public String getTokenName() + { + return "LOADMULTSTEP"; + } + + public boolean parse(LoadInfo loadInfo, String value) + { + try + { + loadInfo.setLoadMultStep(Integer.parseInt(value)); + } + catch (Exception e) + { + return false; + } + return true; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nuance@us...> - 2007-03-29 23:45:19
|
Revision: 2613 http://svn.sourceforge.net/pcgen/?rev=2613&view=rev Author: nuance Date: 2007-03-29 16:45:16 -0700 (Thu, 29 Mar 2007) Log Message: ----------- [ 1411229 ] count("x") JEP function Finish adding support for boolean operators in the new jep count function. now uses [or] and [and] as the operators. Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java Trunk/pcgen/code/src/java/pcgen/util/ParameterTree.java Trunk/pcgen/code/src/java/plugin/jepcommands/CountCommand.java Trunk/pcgen/code/src/test/pcgen/io/exporttoken/AbilityListTokenTest.java Trunk/pcgen/code/src/test/pcgen/util/ParameterTreeTest.java Trunk/pcgen/code/testsuite/base.xml Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2007-03-29 22:32:32 UTC (rev 2612) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2007-03-29 23:45:16 UTC (rev 2613) @@ -15872,9 +15872,9 @@ return st; } - st.get(Ability.Nature.VIRTUAL).addAll(getVirtualFeatList()); - st.get(Ability.Nature.AUTOMATIC).addAll(featAutoList()); - st.get(Ability.Nature.NORMAL).addAll(getRealFeatList()); + st.get(Ability.Nature.VIRTUAL) .addAll(getAbilitySetByNature(Ability.Nature.VIRTUAL)); + st.get(Ability.Nature.AUTOMATIC).addAll(getAbilitySetByNature(Ability.Nature.AUTOMATIC)); + st.get(Ability.Nature.NORMAL) .addAll(getAbilitySetByNature(Ability.Nature.NORMAL)); st.get(Ability.Nature.ANY).addAll(st.get(Ability.Nature.NORMAL)); st.get(Ability.Nature.ANY).addAll(st.get(Ability.Nature.AUTOMATIC)); @@ -16962,6 +16962,45 @@ return vFeatList; } + public Set<Ability> getAbilitySetByNature(Ability.Nature n) + { + GameMode gm = SettingsHandler.getGame(); + + Set<AbilityCategory> Sc = new HashSet<AbilityCategory>(); + Sc.addAll(gm.getAllAbilityCategories()); + + Set<Ability> Sa = new HashSet<Ability>(); + + switch (n) + { + case AUTOMATIC : + for (AbilityCategory Ac: Sc) + { + Sa.addAll(this.getAutomaticAbilityList(Ac)); + } + break; + + case NORMAL : + for (AbilityCategory Ac: Sc) + { + Sa.addAll(this.getRealAbilitiesList(Ac)); + } + break; + + case VIRTUAL : + for (AbilityCategory Ac: Sc) + { + Sa.addAll(this.getVirtualAbilityList(Ac)); + } + break; + + default: + Logging.errorPrint("Attempt to get abilities of Nature: " + n); + } + + return Sa; + } + public List<Ability> getVirtualAbilityList(final AbilityCategory aCategory) { if (aCategory == AbilityCategory.FEAT) Modified: Trunk/pcgen/code/src/java/pcgen/util/ParameterTree.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/util/ParameterTree.java 2007-03-29 22:32:32 UTC (rev 2612) +++ Trunk/pcgen/code/src/java/pcgen/util/ParameterTree.java 2007-03-29 23:45:16 UTC (rev 2613) @@ -30,13 +30,20 @@ public class ParameterTree { - String data; - ParameterTree left; - ParameterTree right; - static Pattern pat = Pattern.compile("(\\(|\\)|\\|\\||\\&\\&)"); + String data; + ParameterTree left; + ParameterTree right; + static public String orString = "[or]"; + static public String andString = "[and]"; + static String orPatString = "\\[or\\]"; + static String andPatString = "\\[and\\]"; + + static String patString = "(\\(|\\)|" + orPatString + "|" + andPatString + ")"; + + static Pattern pat = Pattern.compile(patString); - static ParameterTree makeTree (final String source) throws ParseException + public static ParameterTree makeTree (final String source) throws ParseException { Matcher mat = ParameterTree.pat.matcher(source); Modified: Trunk/pcgen/code/src/java/plugin/jepcommands/CountCommand.java =================================================================== --- Trunk/pcgen/code/src/java/plugin/jepcommands/CountCommand.java 2007-03-29 22:32:32 UTC (rev 2612) +++ Trunk/pcgen/code/src/java/plugin/jepcommands/CountCommand.java 2007-03-29 23:45:16 UTC (rev 2613) @@ -23,24 +23,26 @@ package plugin.jepcommands; -import java.util.ArrayList; -import java.util.List; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; 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; +import pcgen.util.ParameterTree; +import pcgen.util.enumeration.Visibility; /** * <code>CountCommand</code> deals with the count() JEP command. - * The first parameter will be the type of objetc being counted + * The first parameter will be the type of object being counted * and further parameters will specify the criteria. * * Last Editor: $Author: $ @@ -52,10 +54,20 @@ public class CountCommand extends PCGenCommand { + public enum JepAbilityCountEnum + { + CATEGORY, + NATURE, + TYPE, + VISIBILITY + } + public enum JepCountEnum { - ABILITIES + ABILITIES { + public HashMap<Ability.Nature, Set<Ability>> abdata; + /** * Count a character's abiltiies. * @@ -72,82 +84,162 @@ "Count of abilities had too few parameters."); } - String visibility = "VISIBLE"; - String category = null; - String nature = "NORMAL"; + abdata = pc.getAbilitiesSet(); - // Parse the parameters passed in + ParameterTree pt = null; + for (int i = 1; i < params.length; i++) { - if (!(params[i] instanceof String)) + try { - throw new ParseException( - "Invalid parameter type for parameter #" + (i + 1) + " - " - + String.valueOf(params[i])); + if (pt == null) + { + pt = ParameterTree.makeTree((String) params[i]); + } + else + { + ParameterTree npt = new ParameterTree(ParameterTree.andString); + npt.setLeftTree(pt); + pt = npt; + npt = ParameterTree.makeTree((String) params[i]); + pt.setRightTree(npt); + } } - - String[] keyValue = ((String) params[i]).split("="); - if ("CATEGORY".equalsIgnoreCase(keyValue[0])) + catch (ParseException pe) { - category = keyValue[1]; + Logging.errorPrint("Malformed parameter to count(ABILITY) " + (String) params[i], pe); } - else if ("VISIBILITY".equalsIgnoreCase(keyValue[0])) + } + + Set<Ability> filtered = FilterAbilities(pt); + +// Logging.errorPrint("Number remaining: " + filtered.size()); + + double accum = 0; + + for (Ability ab: filtered) + { + double ac = ab.getAssociatedCount(); + accum += (ac <= 1.01) ? 1 : ab.getAssociatedCount(); + } + return Double.valueOf(accum); + } + + //@SuppressWarnings("unchecked") //Uses JEP, which doesn't use generics + public Set<Ability> FilterAbilities (ParameterTree pt) + { + String c = pt.getContents(); +// System.err.println(c); + + if (c.equalsIgnoreCase(ParameterTree.orString) || c.equalsIgnoreCase(ParameterTree.andString)) + { + Set<Ability> a = FilterAbilities(pt.getLeftTree()); + Set<Ability> b = FilterAbilities(pt.getRightTree()); + if (c.equalsIgnoreCase(ParameterTree.orString)) { - visibility = keyValue[1]; + a.addAll(b); } - else if ("NATURE".equalsIgnoreCase(keyValue[0])) - { - nature = keyValue[1]; - } else { - throw new ParseException( - "Invalid parameter key for parameter #" + (i + 1) + " - " - + String.valueOf(params[i])); + a.retainAll(b); } + return a; } + + String[] keyValue = c.split("="); - // Fetch the requested list of abilities - final AbilityCategory aCategory = - SettingsHandler.getGame().getAbilityCategory(category); - if (aCategory == null) + JepAbilityCountEnum en = JepAbilityCountEnum.valueOf(keyValue[0]); + Set<Ability> cs = null; + Ability a; + + switch (en) { - 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)); - } + case CATEGORY: + String cat = keyValue[1]; + cs = new HashSet<Ability>(abdata.get(Ability.Nature.ANY)); + + Iterator It = cs.iterator(); + + while (It.hasNext()) + { + a = (Ability) It.next(); + if (!a.getCategory().equalsIgnoreCase(cat)) + { + It.remove(); + } + } + break; + + case NATURE: ; + Ability.Nature n; + try + { + n = Ability.Nature.valueOf(keyValue[1]); + } + catch (IllegalArgumentException ex) + { + Logging.errorPrint("Bad paramter to count(\"Ability\"), no such NATURE " + c); + n = Ability.Nature.ANY; + } + cs = new HashSet<Ability>(abdata.get(n)); + break; - // 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++; - } + case TYPE: ; + String ty = keyValue[1]; + cs = new HashSet<Ability>(abdata.get(Ability.Nature.ANY)); + + It = cs.iterator(); + + while (It.hasNext()) + { + a = (Ability) It.next(); + if (!a.isType(ty)) + { + It.remove(); + } + } + break; + + case VISIBILITY : + Visibility vi; + cs = new HashSet<Ability>(abdata.get(Ability.Nature.ANY)); + + try + { + vi = Visibility.valueOf(keyValue[1]); + + It = cs.iterator(); + + while(It.hasNext()) + { + a = (Ability) It.next(); + if (!a.getVisibility().equals(vi)) + { + It.remove(); + } + } + } + catch (IllegalArgumentException ex) + { + Logging.errorPrint("Bad paramter to count(\"Ability\"), no such Visibility " + keyValue[1]); + } + + } - return new Double(count); +// System.err.println("--- start ---"); +// System.err.println(keyValue[0]); +// System.err.println(keyValue[1]); +// +// for (Ability ab : cs) +// { +// System.err.println(ab); +// } +// +// System.err.println("--- end ---"); + return cs; } + }, CLASSES { Modified: Trunk/pcgen/code/src/test/pcgen/io/exporttoken/AbilityListTokenTest.java =================================================================== --- Trunk/pcgen/code/src/test/pcgen/io/exporttoken/AbilityListTokenTest.java 2007-03-29 22:32:32 UTC (rev 2612) +++ Trunk/pcgen/code/src/test/pcgen/io/exporttoken/AbilityListTokenTest.java 2007-03-29 23:45:16 UTC (rev 2613) @@ -32,6 +32,7 @@ import pcgen.core.PlayerCharacter; import pcgen.core.SettingsHandler; import pcgen.io.ExportHandler; +import pcgen.util.Logging; import pcgen.util.TestHelper; import pcgen.util.enumeration.Visibility; @@ -65,56 +66,39 @@ super.setUp(); PlayerCharacter character = getCharacter(); + // Make some ability categories and add them to the game mode + AbilityCategory featCategory = + SettingsHandler.getGame().getAbilityCategory("Feat"); + + if (featCategory == null) + { + featCategory = new AbilityCategory("Feat"); + SettingsHandler.getGame().addAbilityCategory(featCategory); + } + + AbilityCategory bardCategory = new AbilityCategory("BARDIC"); + SettingsHandler.getGame().addAbilityCategory(bardCategory); + Ability ab1 = - TestHelper.makeAbility("Perform (Dance)", "FEAT", + TestHelper.makeAbility("Perform (Dance)", "Feat", "General.Fighter"); ab1.setMultiples("NO"); ab1.setVisibility(Visibility.DEFAULT); - AbilityCategory aCategory = - SettingsHandler.getGame().getAbilityCategory(ab1.getCategory()); - if (aCategory == null) - { - aCategory = new AbilityCategory(ab1.getCategory()); - SettingsHandler.getGame().addAbilityCategory(aCategory); - } - character.addAbility(aCateg |