diff --git a/.gitignore b/.gitignore
index 471958e..94690a6 100755
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,3 @@
-.gradle
-build/
-maven-repo/
-
# OS generated files
################################################################################
.DS_Store
@@ -16,11 +12,21 @@ Thumbs.db
# Others
################################################################################
-*.log
-*~
-target/
+.gradle
build/
+/bin/
+target/
out/
+/releases/
+*.log
+*~
+\${sys:appHome}/
+
+
+# Automatically Generated
+################################################################################
+package/windows/MapTool.iss
+src/main/resources/sentry.properties
# IDEs
@@ -33,3 +39,7 @@ out/
.settings/
.classpath
.history
+workbench.xmi
+
+# Keystore
+build-resources/rptools-keystore
\ No newline at end of file
diff --git a/README.md b/README.md
index e70536e..199cbd8 100755
--- a/README.md
+++ b/README.md
@@ -1,3 +1,5 @@
+[![](https://jitpack.io/v/RPTools/dicelib.svg)](https://jitpack.io/#RPTools/dicelib)
+
# dicelib
Dice Roll Library used by RPTools programs.
diff --git a/build.gradle b/build.gradle
index d4a5e8a..6b4d2c9 100755
--- a/build.gradle
+++ b/build.gradle
@@ -1,41 +1,97 @@
-import org.apache.tools.ant.filters.ReplaceTokens
import java.text.SimpleDateFormat
-import org.ajoberstar.grgit.*
+buildscript {
+ dependencies {
+ classpath "com.diffplug.spotless:spotless-plugin-gradle:3.13.0"
+ }
+
+ repositories {
+ mavenCentral()
+ }
+}
+// Access Git info from build script
+plugins {
+ id "org.ajoberstar.grgit" version "3.0.0"
+}
-apply plugin: 'java'
-apply plugin: 'findbugs'
-apply plugin: 'pmd'
-apply plugin: 'application'
-apply plugin: 'maven'
+
+apply plugin: 'java-library'
apply plugin: 'com.diffplug.gradle.spotless'
+apply plugin: 'maven'
+
+
+
+sourceCompatibility = 10
+targetCompatibility = 10
+
+
+// In this section you declare where to find the dependencies of your project
+repositories {
+ mavenCentral()
+ mavenLocal()
+ maven { url = 'http://maptool.craigs-stuff.net/repo/' }
+ maven { url = 'https://jitpack.io' }
+}
-sourceCompatibility = 1.7
-targetCompatibility = 1.7
-if (version == 'unspecified') {
- version = getVersionName()
+dependencies {
+ compile 'rhino:js:1.6R5'
+ compile 'antlr:antlr:2.7.6'
+// compile 'net.rptools.parser:parser:1.1.b24'
+ implementation 'com.github.RPTools:parser:1.5.5'
+ testCompile group: 'junit', name: 'junit', version: '4.11'
}
-ext.repo = Grgit.open(project.file('.'))
+// Custom properties
+ext {
+ // Get tag and commit info from Git to use for version numbering
+ def repo = org.ajoberstar.grgit.Grgit.open(currentDir: file('.'))
+ def head = repo.head()
+ def tags = repo.tag.list().find {
+ it.commit == head
+ }
+ if (tags) {
+ tagVersion = tags.getName()
+ project.version = tagVersion
+ }
+
+ revision = head.abbreviatedId
+ revisionFull = head.id
+
+// println 'Configuring for ' + project.name + " " + tagVersion + " by " + vendor
+}
+group = "net.rptools.dicelib"
spotless {
java {
- eclipseFormatFile 'build-resources/eclipse.prefs.formatter.xml'
+ licenseHeaderFile 'spotless.license.java'
+ // Now using the Google Java style guide
+ //eclipse().configFile('build-resources/eclipse.prefs.formatter.xml')
+ googleJavaFormat()
+ // If you get exceptions thrown by spotlessApply, this might
+ // help. Enable it here if the problem is with a Java file, and
+ // below if it is not. Don't leave it enabled, as nothing will
+ // actually be updated if you do.
+ // https://github.com/diffplug/spotless/blob/master/PADDEDCELL.md
+ //paddedCell()
}
-}
+ format 'misc', {
+ target '**/*.gradle', '**/.gitignore'
-configurations {
- deployerJars
+ // spotless has built-in rules for most basic formatting tasks
+ trimTrailingWhitespace()
+ // or spaces. Takes an integer argument if you don't like 4
+ indentWithSpaces(4)
+ //paddedCell()
+ }
}
-
-task wrapper(type: Wrapper) {
- gradleVersion='2.1'
+configurations {
+ deployerJars
}
install {
@@ -57,75 +113,6 @@ uploadArchives {
}
}
-buildscript {
- repositories {
- mavenCentral()
- jcenter()
- maven {
- url 'https://plugins.gradle.org/m2/'
- }
- }
- dependencies {
- classpath 'org.ajoberstar:gradle-git:0.11.2'
- classpath 'com.diffplug.gradle.spotless:spotless:1.3.0-SNAPSHOT'
- }
-}
-
-
-dependencies {
- compile 'rhino:js:1.6R5'
- compile 'antlr:antlr:2.7.6'
- compile 'net.rptools.parser:parser:1.1.b24'
- testCompile group: 'junit', name: 'junit', version: '4.11'
- deployerJars 'org.apache.maven.wagon:wagon-ssh:2.2'
-}
-
-ext.compileDate = new Date();
-ext.yyyymmdd = (new SimpleDateFormat('yyyyMMDD')).format(ext.compileDate);
-
-
-repositories {
- mavenCentral()
- mavenLocal()
- maven {
- url = 'http://maptool.craigs-stuff.net/repo/'
- }
-}
-
-
-/*
- * Gets the version name from the latest Git tag
- */
-
-def getVersionName() {
-
-
- if (project.hasProperty('buildVersion')) {
- return buildVersion
- } else {
- String vtxtVersionNo = new File('build-resources/version.txt').text.trim()
-
- return vtxtVersionNo
- }
-}
-
-findbugs {
- ignoreFailures = true
- toolVersion = '3.0.0'
- effort = 'max'
- sourceSets = [] // Empty source set so it wont run during build/check
-}
-
-pmd {
- ignoreFailures = true
- sourceSets = [] // Empty source set so it wont run during tebuild/check
-}
-
-
-
-task showBuildVersion() << {
- println 'Build Version Number = ' + project.version
-}
jar {
manifest {
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
old mode 100755
new mode 100644
index b761216..87b738c
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
old mode 100755
new mode 100644
index c9c27e8..ea13fdf
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Sun May 03 01:01:06 CST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-bin.zip
diff --git a/gradlew b/gradlew
index 91a7e26..af6708f 100755
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
##############################################################################
##
@@ -6,20 +6,38 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m"'
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,31 +59,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
+ NONSTOP* )
+ nonstop=true
+ ;;
esac
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -90,7 +89,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -114,6 +113,7 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@@ -154,11 +154,19 @@ if $cygwin ; then
esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
old mode 100755
new mode 100644
index aec9973..6d57edc
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,90 +1,84 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/jitpack.yml b/jitpack.yml
new file mode 100644
index 0000000..246d32f
--- /dev/null
+++ b/jitpack.yml
@@ -0,0 +1,2 @@
+jdk:
+ - oraclejdk10
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..4719553
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,10 @@
+/*
+ * This file was generated by the Gradle 'init' task.
+ *
+ * The settings file is used to specify which projects to include in your build.
+ *
+ * Detailed information about configuring a multi-project build in Gradle can be found
+ * in the user manual at https://docs.gradle.org/5.2.1/userguide/multi_project_builds.html
+ */
+
+rootProject.name = 'dicelib'
diff --git a/spotless.license.java b/spotless.license.java
new file mode 100644
index 0000000..25bfe7b
--- /dev/null
+++ b/spotless.license.java
@@ -0,0 +1,14 @@
+/*
+ * This software Copyright by the RPTools.net development team, and
+ * licensed under the Affero GPL Version 3 or, at your option, any later
+ * version.
+ *
+ * MapTool Source Code 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.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License * along with this source Code. If not, please visit
+ * and specifically the Affero license
+ * text at .
+ */
diff --git a/src/main/java/net/rptools/common/expression/ExpressionParser.java b/src/main/java/net/rptools/common/expression/ExpressionParser.java
index e3a95fe..89aa69b 100755
--- a/src/main/java/net/rptools/common/expression/ExpressionParser.java
+++ b/src/main/java/net/rptools/common/expression/ExpressionParser.java
@@ -1,15 +1,16 @@
/*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
+ * This software Copyright by the RPTools.net development team, and
+ * licensed under the Affero GPL Version 3 or, at your option, any later
+ * version.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * MapTool Source Code 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.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
+ * You should have received a copy of the GNU Affero General Public
+ * License * along with this source Code. If not, please visit
+ * and specifically the Affero license
+ * text at .
*/
package net.rptools.common.expression;
@@ -22,159 +23,204 @@
import net.rptools.parser.transform.StringLiteralTransformer;
public class ExpressionParser {
- private static String[][] DICE_PATTERNS = new String[][] {
- // Comments
- new String[] { "//.*", "" },
-
- // Color hex strings #FFF or #FFFFFF or #FFFFFFFF (with alpha)
- new String[] { "(? and specifically the Affero license
+ * text at .
*/
package net.rptools.common.expression;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
public class Result {
- private final String expression;
- private String detailExpression;
- private Object value;
- private String description;
-
- private final Map properties = new HashMap();
-
- public Result(String expression) {
- this.expression = expression;
- }
-
- public String getExpression() {
- return expression;
- }
-
- public String getDetailExpression() {
- return detailExpression;
- }
-
- public void setDetailExpression(String detailExpression) {
- this.detailExpression = detailExpression;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Object getValue() {
- return value;
- }
-
- public void setValue(Object value) {
- this.value = value;
- }
-
- public Map getProperties() {
- return this.properties;
- }
-
- public String format() {
- StringBuilder sb = new StringBuilder(64);
- sb.append(expression).append(" = ");
-
- if (detailExpression != null && !detailExpression.equals(value.toString())) {
- sb.append("(").append(detailExpression).append(") = ");
- }
-
- sb.append(value);
- if (description != null) {
- sb.append(" // ").append(description);
- }
- return sb.toString();
- }
+ private final String expression;
+ private String detailExpression;
+ private Object value;
+ private String description;
+ private List rolled;
+
+ private final Map properties = new HashMap();
+
+ public Result(String expression) {
+ this.expression = expression;
+ }
+
+ public String getExpression() {
+ return expression;
+ }
+
+ public String getDetailExpression() {
+ return detailExpression;
+ }
+
+ public void setDetailExpression(String detailExpression) {
+ this.detailExpression = detailExpression;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ public Map getProperties() {
+ return this.properties;
+ }
+
+ public void setRolled(List rolls) {
+ rolled = new ArrayList<>(rolls);
+ }
+
+ public List getRolled() {
+ return Collections.unmodifiableList(rolled);
+ }
+
+ public String format() {
+ StringBuilder sb = new StringBuilder(64);
+ sb.append(expression).append(" = ");
+
+ if (detailExpression != null && !detailExpression.equals(value.toString())) {
+ sb.append("(").append(detailExpression).append(") = ");
+ }
+
+ sb.append(value);
+ if (description != null) {
+ sb.append(" // ").append(description);
+ }
+ return sb.toString();
+ }
}
diff --git a/src/main/java/net/rptools/common/expression/RunData.java b/src/main/java/net/rptools/common/expression/RunData.java
index f112246..3a4b93e 100755
--- a/src/main/java/net/rptools/common/expression/RunData.java
+++ b/src/main/java/net/rptools/common/expression/RunData.java
@@ -1,100 +1,107 @@
/*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
+ * This software Copyright by the RPTools.net development team, and
+ * licensed under the Affero GPL Version 3 or, at your option, any later
+ * version.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * MapTool Source Code 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.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
+ * You should have received a copy of the GNU Affero General Public
+ * License * along with this source Code. If not, please visit
+ * and specifically the Affero license
+ * text at .
*/
package net.rptools.common.expression;
import java.security.SecureRandom;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Random;
public class RunData {
- private static ThreadLocal current = new ThreadLocal();
- public static Random RANDOM = new SecureRandom();
-
- private final Result result;
-
- private long randomValue;
- private long randomMax;
- private long randomMin;
-
- public RunData(Result result) {
- this.result = result;
- }
-
- /**
- * Returns a random integer between 1 and maxValue
- */
- public int randomInt(int maxValue) {
- return randomInt(1, maxValue);
- }
-
- /**
- * Returns a list of random integers between 1 and maxValue
- */
- public int[] randomInts(int num, int maxValue) {
- int[] ret = new int[num];
- for (int i = 0; i < num; i++)
- ret[i] = randomInt(maxValue);
- return ret;
- }
-
- /**
- * Returns a random integer between minValue and maxValue
- */
- public int randomInt(int minValue, int maxValue) {
- randomMin += minValue;
- randomMax += maxValue;
-
- int result = RANDOM.nextInt(maxValue - minValue + 1) + minValue;
-
- randomValue += result;
-
- return result;
- }
-
- /**
- * Returns a list of random integers between minValue and maxValue
- * @return
- */
- public int[] randomInts(int num, int minValue, int maxValue) {
- int[] ret = new int[num];
- for (int i = 0; i < num; i++)
- ret[i] = randomInt(minValue, maxValue);
- return ret;
- }
-
- public Result getResult() {
- return result;
- }
-
- public static boolean hasCurrent() {
- return current.get() != null;
- }
-
- public static RunData getCurrent() {
- RunData data = current.get();
- if (data == null) {
- throw new NullPointerException("data cannot be null");
- }
- return data;
- }
-
- public static void setCurrent(RunData data) {
- current.set(data);
- }
-
- // If a seed is set we need to switch from SecureRandom to
- // random.
- public static void setSeed(long seed) {
- RANDOM = new Random(seed);
- }
+ private static ThreadLocal current = new ThreadLocal();
+ public static Random RANDOM = new SecureRandom();
+
+ private final Result result;
+
+ private long randomValue;
+ private long randomMax;
+ private long randomMin;
+
+ private List rolled = new LinkedList<>();
+
+ public RunData(Result result) {
+ this.result = result;
+ }
+
+ /** Returns a random integer between 1 and maxValue */
+ public int randomInt(int maxValue) {
+ return randomInt(1, maxValue);
+ }
+
+ /** Returns a list of random integers between 1 and maxValue */
+ public int[] randomInts(int num, int maxValue) {
+ int[] ret = new int[num];
+ for (int i = 0; i < num; i++) {
+ ret[i] = randomInt(maxValue);
+ }
+ return ret;
+ }
+
+ /** Returns a random integer between minValue and maxValue */
+ public int randomInt(int minValue, int maxValue) {
+ randomMin += minValue;
+ randomMax += maxValue;
+
+ int result = RANDOM.nextInt(maxValue - minValue + 1) + minValue;
+
+ rolled.add(result);
+
+ randomValue += result;
+
+ return result;
+ }
+
+ /**
+ * Returns a list of random integers between minValue and maxValue
+ *
+ * @return
+ */
+ public int[] randomInts(int num, int minValue, int maxValue) {
+ int[] ret = new int[num];
+ for (int i = 0; i < num; i++) ret[i] = randomInt(minValue, maxValue);
+ return ret;
+ }
+
+ public Result getResult() {
+ return result;
+ }
+
+ public static boolean hasCurrent() {
+ return current.get() != null;
+ }
+
+ public static RunData getCurrent() {
+ RunData data = current.get();
+ if (data == null) {
+ throw new NullPointerException("data cannot be null");
+ }
+ return data;
+ }
+
+ public static void setCurrent(RunData data) {
+ current.set(data);
+ }
+
+ // If a seed is set we need to switch from SecureRandom to
+ // random.
+ public static void setSeed(long seed) {
+ RANDOM = new Random(seed);
+ }
+
+ public List getRolled() {
+ return Collections.unmodifiableList(rolled);
+ }
}
diff --git a/src/main/java/net/rptools/common/expression/function/CountSuccessDice.java b/src/main/java/net/rptools/common/expression/function/CountSuccessDice.java
index ac741d7..7d194d5 100755
--- a/src/main/java/net/rptools/common/expression/function/CountSuccessDice.java
+++ b/src/main/java/net/rptools/common/expression/function/CountSuccessDice.java
@@ -1,39 +1,39 @@
/*
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
+ * This software Copyright by the RPTools.net development team, and
+ * licensed under the Affero GPL Version 3 or, at your option, any later
+ * version.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * MapTool Source Code 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.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
+ * You should have received a copy of the GNU Affero General Public
+ * License * along with this source Code. If not, please visit
+ * and specifically the Affero license
+ * text at .
*/
package net.rptools.common.expression.function;
import java.math.BigDecimal;
import java.util.List;
-
import net.rptools.parser.Parser;
import net.rptools.parser.function.AbstractNumberFunction;
import net.rptools.parser.function.EvaluationException;
public class CountSuccessDice extends AbstractNumberFunction {
- public CountSuccessDice() {
- super(3, 3, false, "countsuccess", "success");
- }
-
- @Override
- public Object childEvaluate(Parser parser, String functionName, List