-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from phi1010/sr5
ShadowRun 5 Dice Roll
- Loading branch information
Showing
8 changed files
with
267 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/net/rptools/common/expression/function/ShadowRun5Dice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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 | ||
* <http://www.gnu.org/licenses/> and specifically the Affero license | ||
* text at <http://www.gnu.org/licenses/agpl.html>. | ||
*/ | ||
package net.rptools.common.expression.function; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.List; | ||
import net.rptools.parser.Parser; | ||
import net.rptools.parser.VariableResolver; | ||
import net.rptools.parser.function.AbstractNumberFunction; | ||
import net.rptools.parser.function.EvaluationException; | ||
|
||
public class ShadowRun5Dice extends AbstractNumberFunction { | ||
|
||
public ShadowRun5Dice() { | ||
super(1, 2, true, "sr5"); | ||
} | ||
|
||
@Override | ||
public Object childEvaluate( | ||
Parser parser, VariableResolver resolver, String functionName, List<Object> parameters) | ||
throws EvaluationException { | ||
|
||
int n = 0; | ||
int gremlins = 0; | ||
int times = ((BigDecimal) parameters.get(n++)).intValue(); | ||
if (parameters.size() == 2) gremlins = ((BigDecimal) parameters.get(n++)).intValue(); | ||
|
||
return DiceHelper.countShadowRun(times, gremlins, false, DiceHelper.ShadowrunEdition.EDITION_5); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/net/rptools/common/expression/function/ShadowRun5ExplodeDice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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 | ||
* <http://www.gnu.org/licenses/> and specifically the Affero license | ||
* text at <http://www.gnu.org/licenses/agpl.html>. | ||
*/ | ||
package net.rptools.common.expression.function; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.List; | ||
import net.rptools.parser.Parser; | ||
import net.rptools.parser.VariableResolver; | ||
import net.rptools.parser.function.AbstractNumberFunction; | ||
import net.rptools.parser.function.EvaluationException; | ||
|
||
public class ShadowRun5ExplodeDice extends AbstractNumberFunction { | ||
|
||
public ShadowRun5ExplodeDice() { | ||
super(1, 2, true, "sr5e"); | ||
} | ||
|
||
@Override | ||
public Object childEvaluate( | ||
Parser parser, VariableResolver resolver, String functionName, List<Object> parameters) | ||
throws EvaluationException { | ||
|
||
int n = 0; | ||
int gremlins = 0; | ||
int times = ((BigDecimal) parameters.get(n++)).intValue(); | ||
if (parameters.size() == 2) gremlins = ((BigDecimal) parameters.get(n++)).intValue(); | ||
|
||
return DiceHelper.countShadowRun(times, gremlins, true, DiceHelper.ShadowrunEdition.EDITION_5); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters