var React = require('react'); var _ = require('lodash'); var cx = require('classnames'); var RollDice = require('naturalCrit/rollDice'); var DmDice = React.createClass({ getInitialState: function() { return { lastRoll:{ }, diceNotation : { a : "1d20", b : "6d6 + 3", c : "1d20 - 1" } }; }, roll : function(id){ this.state.lastRoll[id] = RollDice(this.state.diceNotation[id]); this.setState({ lastRoll : this.state.lastRoll }); }, handleChange : function(id, e){ this.state.diceNotation[id] = e.target.value; this.setState({ diceNotation : this.state.diceNotation }); e.stopPropagation(); e.preventDefault(); }, renderRolls : function(){ var self = this; return _.map(['a', 'b', 'c'], function(id){ return
{self.state.lastRoll[id]}
}) }, render : function(){ var self = this; return(

DM Dice

{this.renderRolls()}
); } }); module.exports = DmDice;