diff --git a/client/naturalCrit/encounter/monsterCard/attackSlot/attackSlot.jsx b/client/naturalCrit/encounter/monsterCard/attackSlot/attackSlot.jsx
index f2dcd9bde..5e3bf7fc2 100644
--- a/client/naturalCrit/encounter/monsterCard/attackSlot/attackSlot.jsx
+++ b/client/naturalCrit/encounter/monsterCard/attackSlot/attackSlot.jsx
@@ -2,6 +2,8 @@ var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
+var RollDice = require('naturalCrit/rollDice');
+
var AttackSlot = React.createClass({
getDefaultProps: function() {
return {
@@ -18,27 +20,7 @@ var AttackSlot = React.createClass({
},
rollDice : function(key, notation){
- var additive = 0;
- var dice = _.reduce([/\+(.*)/, /\-(.*)/], function(r, regexp){
- var res = r.match(regexp);
- if(res){
- additive = res[0]*1;
- r = r.replace(res[0], '')
- }
- return r;
- }, notation)
-
- var numDice = dice.split('d')[0];
- var die = dice.split('d')[1];
-
- var diceRoll = _.times(numDice, function(){
- return _.random(1, die);
- });
- var res = _.sum(diceRoll) + additive;
- if(numDice == 1 && die == 20){
- if(diceRoll[0] == 1) res = 'Fail!';
- if(diceRoll[0] == 20) res = 'Crit!';
- }
+ var res = RollDice(notation);
this.state.lastRoll[key] = res
this.state.lastRoll[key + 'key'] = _.uniqueId(key);
this.setState({
diff --git a/client/naturalCrit/sidebar/dmDice/dmDice.jsx b/client/naturalCrit/sidebar/dmDice/dmDice.jsx
new file mode 100644
index 000000000..f8f932091
--- /dev/null
+++ b/client/naturalCrit/sidebar/dmDice/dmDice.jsx
@@ -0,0 +1,17 @@
+var React = require('react');
+var _ = require('lodash');
+var cx = require('classnames');
+
+var DmDice = React.createClass({
+
+ render : function(){
+ var self = this;
+ return(
+
+ DmDice Ready!
+
+ );
+ }
+});
+
+module.exports = DmDice;
diff --git a/client/naturalCrit/sidebar/dmDice/dmDice.less b/client/naturalCrit/sidebar/dmDice/dmDice.less
new file mode 100644
index 000000000..2c1685bf9
--- /dev/null
+++ b/client/naturalCrit/sidebar/dmDice/dmDice.less
@@ -0,0 +1,3 @@
+.dmDice{
+
+}
\ No newline at end of file
diff --git a/client/naturalCrit/sidebar/encounters/encounters.jsx b/client/naturalCrit/sidebar/encounters/encounters.jsx
new file mode 100644
index 000000000..a2cd44d4c
--- /dev/null
+++ b/client/naturalCrit/sidebar/encounters/encounters.jsx
@@ -0,0 +1,17 @@
+var React = require('react');
+var _ = require('lodash');
+var cx = require('classnames');
+
+var Encounters = React.createClass({
+
+ render : function(){
+ var self = this;
+ return(
+
+ Encounters Ready!
+
+ );
+ }
+});
+
+module.exports = Encounters;
diff --git a/client/naturalCrit/sidebar/encounters/encounters.less b/client/naturalCrit/sidebar/encounters/encounters.less
new file mode 100644
index 000000000..1144cab67
--- /dev/null
+++ b/client/naturalCrit/sidebar/encounters/encounters.less
@@ -0,0 +1,3 @@
+.encounters{
+
+}
\ No newline at end of file
diff --git a/client/naturalCrit/sidebar/sidebar.jsx b/client/naturalCrit/sidebar/sidebar.jsx
index 181c7a5f1..127b34414 100644
--- a/client/naturalCrit/sidebar/sidebar.jsx
+++ b/client/naturalCrit/sidebar/sidebar.jsx
@@ -103,8 +103,13 @@ var Sidebar = React.createClass({
Players
-
+
+
+
+
DM Dice
+
+ ah yeah
diff --git a/client/naturalCrit/sidebar/sidebar.less b/client/naturalCrit/sidebar/sidebar.less
index 60149e1bf..f0e74e44a 100644
--- a/client/naturalCrit/sidebar/sidebar.less
+++ b/client/naturalCrit/sidebar/sidebar.less
@@ -111,7 +111,6 @@
}
.addPlayers{
h3{
- //background-color : fade(@purple, 25%);
color : white;
background-color: @purple;
}
@@ -121,5 +120,13 @@
margin : 10px;
}
}
+
+ .dmDice{
+ h3{
+ color : white;
+ background-color: @teal;
+ }
+
+ }
}
}
\ No newline at end of file
diff --git a/shared/naturalCrit/rollDice.js b/shared/naturalCrit/rollDice.js
new file mode 100644
index 000000000..b7bfae2f5
--- /dev/null
+++ b/shared/naturalCrit/rollDice.js
@@ -0,0 +1,32 @@
+var _ = require('lodash');
+
+module.exports = function(notation){
+ notation = notation.replace(/ /g,'');
+ var parts = notation.split(/(?=[\-\+])/g);
+
+ return _.reduce(parts, function(r, part){
+ if(!_.isNumber(r)) return r;
+ var res = 0;
+ var neg = false;
+ if(part[0] == '-') neg = true;
+ if(part[0] == '-' || part[0] == '+') part = part.substring(1);
+
+ //Check for dice
+ if(part.indexOf('d') !== -1){
+ var numDice = part.split('d')[0];
+ var die = part.split('d')[1];
+
+ var diceRolls = _.times(numDice, function(){
+ return _.random(1, die);
+ });
+ res = _.sum(diceRolls);
+ if(numDice == 1 && die == 20){
+ if(diceRolls[0] == 1) return 'Fail!';
+ if(diceRolls[0] == 20) return 'Crit!';
+ }
+ }else{
+ res = part * 1;
+ }
+ return r + (neg ? -res : res);
+ }, 0)
+}