mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-29 19:52:43 +00:00
yay for waindows pathing
This commit is contained in:
23
shared/naturalcrit2/combat/combat.actions.js
Normal file
23
shared/naturalcrit2/combat/combat.actions.js
Normal file
@@ -0,0 +1,23 @@
|
||||
var dispatch = require('pico-flux').dispatch;
|
||||
|
||||
module.exports = {
|
||||
updateMonsterManual : function(json){
|
||||
dispatch('UDPATE_MONSTER_MANUAL', json);
|
||||
},
|
||||
addEncounter : function(){
|
||||
dispatch('ADD_ENCOUNTER');
|
||||
},
|
||||
updateEncounter : function(index, json){
|
||||
dispatch('UPDATE_ENCOUNTER', index, json);
|
||||
},
|
||||
removeEncounter : function(index){
|
||||
dispatch('REMOVE_ENCOUNTER', index);
|
||||
},
|
||||
updatePlayers : function(text){
|
||||
dispatch('UPDATE_PLAYERS', text);
|
||||
},
|
||||
selectEncounter : function(index){
|
||||
dispatch('SELECT_ENCOUNTER', index);
|
||||
},
|
||||
|
||||
}
|
||||
69
shared/naturalcrit2/combat/combat.store.js
Normal file
69
shared/naturalcrit2/combat/combat.store.js
Normal file
@@ -0,0 +1,69 @@
|
||||
var flux = require('pico-flux');
|
||||
var _ = require('lodash');
|
||||
|
||||
var defaultMonsterManual = require('naturalcrit/defaultMonsterManual.js');
|
||||
var GetRandomEncounter = require('naturalcrit/randomEncounter.js');
|
||||
|
||||
var Store = {
|
||||
selectedEncounterIndex : 0,
|
||||
encounters : JSON.parse(localStorage.getItem('encounters')) || [GetRandomEncounter()],
|
||||
monsterManual : JSON.parse(localStorage.getItem('monsterManual')) || defaultMonsterManual,
|
||||
players : localStorage.getItem('players') || 'jasper 13\nzatch 19',
|
||||
};
|
||||
|
||||
|
||||
module.exports = flux.createStore({
|
||||
UDPATE_MONSTER_MANUAL : function(json){
|
||||
Store.monsterManual = json;
|
||||
return true;
|
||||
},
|
||||
ADD_ENCOUNTER : function(){
|
||||
Store.encounters.push(GetRandomEncounter());
|
||||
return true;
|
||||
},
|
||||
UPDATE_ENCOUNTER : function(index, json){
|
||||
Store.encounters[index] = json;
|
||||
return true;
|
||||
},
|
||||
REMOVE_ENCOUNTER : function(index){
|
||||
Store.encounters.splice(index, 1);
|
||||
return true;
|
||||
},
|
||||
UPDATE_PLAYERS : function(text){
|
||||
Store.players = text;
|
||||
return true;
|
||||
},
|
||||
SELECT_ENCOUNTER : function(index){
|
||||
Store.selectedEncounterIndex = index;
|
||||
return true;
|
||||
},
|
||||
|
||||
},{
|
||||
getMonsterManual : function(){
|
||||
return Store.monsterManual;
|
||||
},
|
||||
getSelectedEncounterIndex : function(){
|
||||
return Store.selectedEncounterIndex;
|
||||
},
|
||||
getSelectedEncounter : function(){
|
||||
return Store.encounters[Store.selectedEncounterIndex];
|
||||
},
|
||||
getEncounter : function(index){
|
||||
return Store.encounters[index];
|
||||
},
|
||||
getEncounters : function(index){
|
||||
return Store.encounters;
|
||||
},
|
||||
getPlayersText : function(){
|
||||
return Store.players;
|
||||
},
|
||||
getPlayers : function(){
|
||||
return _.reduce(Store.players.split('\n'), function(r, line){
|
||||
var idx = line.lastIndexOf(' ');
|
||||
if(idx !== -1){
|
||||
r[line.substring(0, idx)] = line.substring(idx)*1;
|
||||
}
|
||||
return r;
|
||||
}, {})
|
||||
},
|
||||
})
|
||||
140
shared/naturalcrit2/combat/defaultMonsterManual.js
Normal file
140
shared/naturalcrit2/combat/defaultMonsterManual.js
Normal file
@@ -0,0 +1,140 @@
|
||||
module.exports = {
|
||||
goblin : {
|
||||
size : 'small',
|
||||
type : 'beast',
|
||||
alignment : 'unaligned',
|
||||
stats : {
|
||||
hp : 40,
|
||||
mov: 30,
|
||||
ac : 13,
|
||||
},
|
||||
scores : {
|
||||
str : 8,
|
||||
con : 8,
|
||||
dex : 8,
|
||||
int : 8,
|
||||
wis : 8,
|
||||
cha : 8
|
||||
},
|
||||
attr : {
|
||||
skills : ['Stealth +5'],
|
||||
lang : ['common'],
|
||||
cr : 0.25,
|
||||
},
|
||||
abilities : {
|
||||
"pack tactics" : "Does a thing",
|
||||
"fancy dance" : "dances fancy"
|
||||
},
|
||||
actions : {
|
||||
bite : {
|
||||
type : "Melee weapon attack",
|
||||
atk : "+4 to hit",
|
||||
rng : "5ft",
|
||||
target : "one target",
|
||||
dmg : "4 (1d4 + 2) piercing damage",
|
||||
desc: ""
|
||||
},
|
||||
scare : {
|
||||
uses : "1/day",
|
||||
desc : "scares you"
|
||||
}
|
||||
},
|
||||
items : ['rat on a stick']
|
||||
},
|
||||
|
||||
"Goat Slime" : {
|
||||
hp : 80,
|
||||
mov: 10,
|
||||
cr : 0.5,
|
||||
ac : 16,
|
||||
attr : {
|
||||
str : 8,
|
||||
con : 8,
|
||||
dex : 6,
|
||||
int : 4,
|
||||
wis : 8,
|
||||
cha : 8
|
||||
},
|
||||
attacks : {
|
||||
caress : {
|
||||
atk : "1d20+1",
|
||||
dmg : "3d4+1",
|
||||
type : "sensual"
|
||||
},
|
||||
},
|
||||
abilities : {
|
||||
"Agnostic Gel" : "Immune to magical damage"
|
||||
},
|
||||
items : []
|
||||
},
|
||||
"badass psycho" : {
|
||||
hp : 100,
|
||||
mov: 50,
|
||||
ac : 14,
|
||||
cr : 5,
|
||||
attr : {
|
||||
str : 17,
|
||||
con : 18,
|
||||
dex : 16,
|
||||
int : 7,
|
||||
wis : 7,
|
||||
cha : 7
|
||||
},
|
||||
attacks : {
|
||||
"throwing axe" : {
|
||||
atk : "1d20+5",
|
||||
dmg : "1d12+5",
|
||||
type : "piercing",
|
||||
rng : "30",
|
||||
notes : "returns to baddie after throw"
|
||||
},
|
||||
shoot : {
|
||||
atk : "1d20+2",
|
||||
dmg : "4d4",
|
||||
rng : "120"
|
||||
}
|
||||
},
|
||||
spells : {
|
||||
"meat popsicle" : {
|
||||
dmg : "4d6",
|
||||
uses : 8
|
||||
},
|
||||
"sanity check" : {
|
||||
dmg : "2d8+4",
|
||||
uses : 6
|
||||
}
|
||||
},
|
||||
abilities : {
|
||||
"rampage" : "when damaged, can choose to take damage from opportunity attacks for allies"
|
||||
},
|
||||
items : ['buzz_axe', 'healing_potion', 'tuna_fish']
|
||||
},
|
||||
toxicologist : {
|
||||
hp : 40,
|
||||
mov: 30,
|
||||
ac : 11,
|
||||
cr : 0.5,
|
||||
attr : {
|
||||
str : 7,
|
||||
con : 11,
|
||||
dex : 10,
|
||||
int : 18,
|
||||
wis : 15,
|
||||
cha : 7
|
||||
},
|
||||
spells : {
|
||||
"publish paper" : {
|
||||
dmg : "4d6",
|
||||
uses : 4
|
||||
},
|
||||
"tox test" : {
|
||||
heal : "2d8+4",
|
||||
uses : 6
|
||||
}
|
||||
},
|
||||
abilities : {
|
||||
"conference" : "when around more than 30 other toxicologists, consume 1 drink every 15 minutes"
|
||||
},
|
||||
items : ['grad_student', 'imposter_syndrome', 'ring']
|
||||
},
|
||||
}
|
||||
13
shared/naturalcrit2/combat/homebrewIcon.svg.jsx
Normal file
13
shared/naturalcrit2/combat/homebrewIcon.svg.jsx
Normal file
@@ -0,0 +1,13 @@
|
||||
var React = require('react');
|
||||
|
||||
var Logo = React.createClass({
|
||||
render : function(){
|
||||
return <svg version="1.1" x="0px" y="0px" viewBox="0 0 90 112.5" enable-background="new 0 0 90 90" >
|
||||
<path d="M25.363,25.54c0,1.906,8.793,3.454,19.636,3.454c10.848,0,19.638-1.547,19.638-3.454c0-1.12-3.056-2.117-7.774-2.75 c-1.418,1.891-3.659,3.133-6.208,3.133c-2.85,0-5.315-1.547-6.67-3.833C33.617,22.185,25.363,23.692,25.363,25.54z"/><path d="M84.075,54.142c0-8.68-2.868-17.005-8.144-23.829c1.106-1.399,1.41-2.771,1.41-3.854c0-6.574-10.245-9.358-19.264-10.533 c0.209,0.706,0.359,1.439,0.359,2.215c0,0.09-0.022,0.17-0.028,0.26l0,0c-0.028,0.853-0.195,1.667-0.479,2.429 c9.106,1.282,14.508,3.754,14.508,5.63c0,2.644-10.688,6.486-27.439,6.486c-16.748,0-27.438-3.842-27.438-6.486 c0-2.542,9.904-6.183,25.559-6.459c-0.098-0.396-0.159-0.807-0.2-1.223c0.006,0,0.013,0,0.017,0 c-0.017-0.213-0.063-0.417-0.063-0.636c0-1.084,0.226-2.119,0.628-3.058c-6.788,0.129-30.846,1.299-30.846,11.376 c0,1.083,0.305,2.455,1.411,3.854c-5.276,6.823-8.145,15.149-8.145,23.829c0,11.548,5.187,20.107,14.693,25.115 c-0.902,3.146-1.391,7.056,1.111,8.181c2.626,1.178,5.364-2.139,7.111-5.005c4.73,1.261,10.13,1.923,16.161,1.923 c6.034,0,11.428-0.661,16.158-1.922c1.75,2.865,4.493,6.18,7.112,5.004c2.504-1.123,2.014-5.035,1.113-8.179 C78.889,74.249,84.075,65.689,84.075,54.142z M70.39,31.392c5.43,6.046,8.78,14,8.78,22.75c0,20.919-18.582,25.309-34.171,25.309 c-15.587,0-34.17-4.39-34.17-25.309c0-8.75,3.35-16.7,8.781-22.753c5.561,2.643,15.502,4.009,25.389,4.009 C54.886,35.397,64.829,34.031,70.39,31.392z"/><path d="M50.654,23.374c2.892,0,5.234-2.341,5.234-5.233c0-2.887-2.343-5.23-5.234-5.23c-2.887,0-5.231,2.343-5.231,5.23 C45.423,21.032,47.768,23.374,50.654,23.374z"/>
|
||||
<circle cx="62.905" cy="10.089" r="3.595"/>
|
||||
<circle cx="52.616" cy="5.048" r="2.73"/>
|
||||
</svg>
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = Logo;
|
||||
3375
shared/naturalcrit2/combat/html2canvas.js
Normal file
3375
shared/naturalcrit2/combat/html2canvas.js
Normal file
File diff suppressed because it is too large
Load Diff
195
shared/naturalcrit2/combat/randomEncounter.js
Normal file
195
shared/naturalcrit2/combat/randomEncounter.js
Normal file
@@ -0,0 +1,195 @@
|
||||
var _ = require('lodash');
|
||||
|
||||
|
||||
|
||||
var getName = function(){
|
||||
return _.sample([
|
||||
"Assault of the Vampire",
|
||||
"Beyond Horror",
|
||||
"Bloodthirsty Odyssey to Saturn",
|
||||
"Claw of the Breed",
|
||||
"Curse of Samson",
|
||||
"Electrical Christmas",
|
||||
"Joseph Clark Loves",
|
||||
"Mind of the Finder",
|
||||
"Mudslide",
|
||||
"Nun of Insanity",
|
||||
"Odyssey to The Hollow Earth",
|
||||
"Reaper Battle",
|
||||
"The Bird-Man goes to The Hollow Earth",
|
||||
"The Bloodthirsty Kiss of The Decadent Bird",
|
||||
"The Diseased Assasin",
|
||||
"The Elephant-Person goes to Mars",
|
||||
"The Evil Saga of the Grizzly-Women",
|
||||
"The Octopus-Person",
|
||||
"The Whorehouse of Medusa",
|
||||
"Assignment: Sensuality, A New Beginning",
|
||||
"Avalanche 2010",
|
||||
"Body of Plague",
|
||||
"Bones of the Zombie",
|
||||
"Clone Snatchers",
|
||||
"Curse of Lizzie Borden",
|
||||
"Damnation Breakers",
|
||||
"Disease Pit",
|
||||
"Emperor Beauty",
|
||||
"Fate of The Abominable Indestructible Women",
|
||||
"Love Festival",
|
||||
"The Beta Person, Part 8",
|
||||
"The Horrible Undead Men",
|
||||
"The Inhuman People",
|
||||
"The Love of The Psychedelic Beast",
|
||||
"The Mutant Depraved",
|
||||
"The Policeman Corrupted, Part 5",
|
||||
"The Psychedelic Operation",
|
||||
"The Terrible Policewoman",
|
||||
"War Beyond El Dorado",
|
||||
"Battle of London",
|
||||
"Gold Love",
|
||||
"I Married Aladdin",
|
||||
"Johnny Walker Loves",
|
||||
"King Love",
|
||||
"Lancelot versus Dracula, The Next Generation",
|
||||
"Licentious Forest",
|
||||
"Passion Festival",
|
||||
"Passion Harvesters",
|
||||
"Sinbad meets Lizzie Borden",
|
||||
"Son of The Impossible Ant-People",
|
||||
"The Blood Ravagers",
|
||||
"The Body Fighter",
|
||||
"The Cat-Men Posessed, Chapter 2",
|
||||
"The Dog-Women from The Past",
|
||||
"The New York Sensation",
|
||||
"The Nurse Destroyed",
|
||||
"The Soulless Spy",
|
||||
"The Soulless Swindler",
|
||||
"The Terrifying Vampires",
|
||||
"Beyond Shangri-La",
|
||||
"Brood of Disease",
|
||||
"Claw of Courage",
|
||||
"Fate of The Gamma Boy, The Revenge",
|
||||
"Festival of the Controller",
|
||||
"Forest Fire",
|
||||
"Genocide!",
|
||||
"Heart of the Devil",
|
||||
"I was a Swindler for the SS",
|
||||
"I was an Executioner for the FBI",
|
||||
"Life Land",
|
||||
"She was a teenaged Annie Oakley",
|
||||
"The Blind Vigilante",
|
||||
"The Cybernetic Eternity",
|
||||
"The Diabolical Tiffany Parker",
|
||||
"The Diseased Alien",
|
||||
"The Legend of Lizzie Borden",
|
||||
"The Legless Hunter",
|
||||
"The Moscow Terror",
|
||||
"Wonder Festival"
|
||||
]);
|
||||
};
|
||||
|
||||
var getPlot = function(){
|
||||
return _.sample([
|
||||
"In a cursed galaxy, in an age of illusions, four barbarians and a conjurer battle a horde of murderers.",
|
||||
"In a wicked kingdom, in a time of war, a philosopher tries to find the cure for a deadly disease.",
|
||||
"In a godless land of terror, in a time of war and blood, a swordsman and a chemist battle evil.",
|
||||
"In a terrifying land of ghosts, a robot and a sailor try to find revenge.",
|
||||
"In a kingdom of misery, in a time of danger, two ambassadors oppose a conspiracy intent on on taking over the world.",
|
||||
"In a demon-haunted land, in a time of lost souls and suffering, a xenobiologist and an engineer oppose lawlessness.",
|
||||
"In a dark kingdom, in a time of deception and deception, a secret agent seeks an ancient treasure.",
|
||||
"In a distant galaxy, two policemans and a scientist try to find love.",
|
||||
"In a universe of prophecy and lies, in a time of wonder and warfare, a virtual reality engineer tries to stop the destruction of mankind.",
|
||||
"In a land of confusion, five monks oppose evil.",
|
||||
"In a world of prophecy and panic, in an era of mysticism and doom, a hacker battles evil.",
|
||||
"In a city of fear, a cleric and a magician hope to save the last living fertile woman.",
|
||||
"On a crime-ridden world of illusion, a prostitute seeks justice and combats an army of assasins intent on on destroying humanity.",
|
||||
"In a kingdom of demons, three businesspersons and an ambassador quest for hope and battle evil.",
|
||||
"On a planet of magic and suffering, in an era of doom, eight aliens quest for fame and combat a cabal of fallen angels intent on stealing the souls of the innocent.",
|
||||
"In a terrifying universe of lost souls, a seer hopes to save a kidnapped princess.",
|
||||
"On an infernal planet of blood, four secret agents battle a syndicate of zombies intent on on summoning an evil god.",
|
||||
"In a dark kingdom, in an age of hate, a computer programmer fights evil.",
|
||||
"In an ominous land, in an age of panic, four wanderers and a linguist search for revenge and oppose terrorism.",
|
||||
"In a universe of madness and devils, in a time of lies and danger, a mutant seeks a mysterious artifact.",
|
||||
"On an infernal planet of terror, in a time of secrets and prophecy, five dutchesses try to save a kidnapped physicist.",
|
||||
"In a galaxy of devils, in an era of virutal reality, a necromancer attempts to avert the apocalypse.",
|
||||
"In a sinful universe, in an era of enchantment and devils, two champions seek revenge.",
|
||||
"In a land of murder, a farmer hopes to solve the ultimate crime.",
|
||||
"In a barbaric kingdom of hate, three theologians and a noble seek an ancient treasure and combat a horde of undead.",
|
||||
"On a planet of chaos, in an age of magic, a student and a spirit try to find freedom and fight crime.",
|
||||
"On a barbaric planet, in an era of prophecy and wonder, two bodyguards hope to find the cure for a deadly disease.",
|
||||
"In a crime-infested galaxy, a champion and a jailer try to find the ultimate weapon and fight a horde of mages intent on on destroying humanity.",
|
||||
"In a land of prophecy and mysteries, a clone seeks hope and combats crime.",
|
||||
"In a galaxy of mysticism and pain, four secretaries and a gambler hope to stop the apocalypse.",
|
||||
"On a planet of illusion and horror, three novelists and a professor try to find vengance.",
|
||||
"In a galaxy of enchantment and hate, in a time of barbarism and danger, four tomb-robbers combat the forces of hell.",
|
||||
"In a kingdom of mysteries and agony, in an era of illusion, a rascal and a barbarian attempt to solve the ultimate crime.",
|
||||
"In a demon-haunted land of warfare, in a time of prophecy and prophecy, four farmers and a conjurer search for fame and combat a mob of aliens intent on on taking over the world.",
|
||||
"In a forbidden land, in a time of doom, two chemists and a queen hope to find the cure for a deadly disease.",
|
||||
"In a kingdom of insanity, in an age of sorcery, three cyborgs and a theologian try to find justice and combat lawlessness.",
|
||||
"In a demon-haunted city, in an age of horror, six virtual reality programmers hope to save a kidnapped occultist.",
|
||||
"In an empire of dreams and mysteries, a gigolo seeks love and opposes terrorism.",
|
||||
"On a planet of insanity, six cyborgs hope to solve the ultimate crime.",
|
||||
"On a godforsaken world of insanity, in an era of computerization, two computer programmers and a bartender try to find the cure for a deadly disease.",
|
||||
"In a crime-infested empire, a farmer fights terrorism.",
|
||||
"In a universe of ghosts, in an age of enchantment, a virtual reality engineer and a dungeon delver hope to solve the ultimate crime.",
|
||||
"In a hellish land, in a time of blood and virutal reality, a magician combats terrorism.",
|
||||
"On a wicked planet of lost souls, two princesses try to save a kidnapped fletcher.",
|
||||
"In a hellish galaxy, two magicians and a grave robber combat corrupt politicians."
|
||||
]);
|
||||
}
|
||||
|
||||
var getTwist = function(){
|
||||
return _.sample([
|
||||
"A character is shown to have a dangerous compulsion, this is revealed when someone has a psychic vision.",
|
||||
"A character suddenly falls out of love with the antagonist's twin.",
|
||||
"In order to fulfill their goals, a character must kill their true love - and they do it.",
|
||||
"Because of a time of political turmoil, the antagonist is revealed to be being manipulated by someone else",
|
||||
"Because of a tornado, the protagonist is revealed to be having their own hidden plans",
|
||||
"It's revealed that everything that is happening is in a hallucination. That's when everything becomes hilarious.",
|
||||
"We discover that, thanks to a sudden discovery, that a character has a mental illness.",
|
||||
"The antagonist discovers everyone else actually is addicted to a substance - this is due to a simple miscommunication.",
|
||||
"The antagonist thinks that everything happening a misinterpretation of something else - and this is due to being lied to by others.",
|
||||
"The antagonist discovers everyone else actually is an artifical life form.",
|
||||
"The lead suddenly reveals a witty side - which makes things much more complicated",
|
||||
"We discover that, thanks to a heartfelt confession, that a character is a clone.",
|
||||
"A string of numbers turns out to refer to a combination on a safe - which someone uses to their advantage.",
|
||||
"The alternate antagonist turns out to be the protagonist's brother.",
|
||||
"We discover that, once a specific name is analyzed, that everything is exactly what it seems - despite evidence to the contrary.",
|
||||
"A character suddenly falls in love with the antagonist - but this is due to a dangerous compulsion.",
|
||||
"Thanks to strange technology, the characters end up in the earth's future.",
|
||||
"The alternate antagonist turns out to be the alternate protagonist's father.",
|
||||
"In order to fulfill their goals, a character must betray their best friend - and they can't bring themselves to do it.",
|
||||
"The antagonist discovers everyone else actually is a demonic entity.",
|
||||
"A character suddenly falls in love with the secondary protagonist - this brings out magical gifts.",
|
||||
"The alternate protagonist turns out to be the antagonist's brother.",
|
||||
"What people think of as witchcraft is really genetic engineering.",
|
||||
"A supposedly accidental hug is actually caused by strange technology.",
|
||||
"The world is revealed to be dependent on nanotechnology.",
|
||||
"Because of a tornado, the antagonist is revealed to be being manipulated by someone else",
|
||||
"At the start of the story some money is introduced - and of course it is used by the story's end.",
|
||||
"A character is shown to have strange powers - this is revealed by a series of strange co-incidences.",
|
||||
"In order to fulfill their goals, a character must kill their aunt - and they do it.",
|
||||
"Because of a discovery, the secondary protagonist is revealed to be hallucinating."
|
||||
]);
|
||||
}
|
||||
|
||||
var getReward = function(){
|
||||
return _.sample([
|
||||
'goat sac', '10 gold', '100 gold', '101 gold', 'curved horn', 'wand of wand creation',
|
||||
'bag of hand-holding', '1 copper', 'true friendship', 'magical stick'
|
||||
], _.random(1,5)).join(', ');
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports = function(monsterManual){
|
||||
|
||||
return {
|
||||
name : getName(),
|
||||
desc : getPlot() + ' ' + getTwist(),
|
||||
reward : getReward(),
|
||||
enemies : _.sample(_.keys(monsterManual), _.random(2,6)),
|
||||
unique : {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
32
shared/naturalcrit2/combat/rollDice.js
Normal file
32
shared/naturalcrit2/combat/rollDice.js
Normal file
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user