Created
May 5, 2014 18:52
-
-
Save zph/11544586 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| require 'minitest/autorun' # => true | |
| require 'minitest/spec' # => false | |
| require 'minitest/pride' # => true | |
| require_relative 'dicebag' # ~> LoadError: cannot load such file -- /Users/zph/tmp/seeing_is_believing_temp_dir20140505-47830-1l8fiz5/dicebag | |
| describe DiceDSL do | |
| subject { DiceDSL } | |
| describe '5d6' do | |
| let(:str) { '5d6' } | |
| it 'parses correctly' do | |
| subject.string_to_dice_array(str).must_equal 'd^6,d^6,d^6,d^6,d^6' | |
| end | |
| end | |
| describe '[2d6]*' do | |
| # let(:str) { '[2d6]*' } | |
| # it 'roll 2 d6 and reroll any sixes' do | |
| # subject.string_to_dice_array(str).must_equal 'd^6,d^6,d^6,d^6,d^6' | |
| # end | |
| end | |
| describe '3[5d8]' do | |
| let(:str) { '3[5d8]' } | |
| it 'roll 5d8 three times' do | |
| subject.string_to_dice_array(str).must_equal 'd^8,d^8,d^8' | |
| end | |
| end | |
| describe '[1d4+1d6+1d8+1d10+1d12+1d20]' do | |
| let(:str) { '[1d4+1d6+1d8+1d10+1d12+1d20]' } | |
| it 'roll one of each' do | |
| subject.string_to_dice_array(str).must_equal 'd^4,d^6,d^8,d^10,d^12,d^20' | |
| end | |
| end | |
| SIMPLE_SUBTRACTION = "[2d6]=7-" | |
| describe SIMPLE_SUBTRACTION do | |
| let(:str) { SIMPLE_SUBTRACTION } | |
| it '(Roll 2 six sided dice, counting anything 7 or lower as a "hit"' do | |
| subject.string_to_dice_array(str).must_equal 'd^6,d^6' | |
| end | |
| end | |
| ALL_THE_JUNK = "b3[4d6]+2=18+" | |
| describe ALL_THE_JUNK do | |
| let(:str) { ALL_THE_JUNK } | |
| it '(Take the bottom 3 dice from 4 six sided dice, add 2 and count anything at 18 or above as a "hit" ' do | |
| subject.string_to_dice_array(str).must_equal 'd^6,d^6,d^6' | |
| end | |
| end | |
| end | |
| # EXAMPLES = { "[5d6]" => , | |
| # "[2d6]*" => , | |
| # "3[5d8]" => , | |
| # "[2d6]=7-" => , | |
| # "[1d4+1d6+1d8+1d10+1d12+1d20]" => , | |
| # "b3[4d6]+2=18+" => , | |
| # } | |
| # [5d6] (A Yahtzee roll) | |
| # [2d6]* (Roll 2 six sided dice and re-roll any sixes rolled) | |
| # 3[5d8] (Take the top 3 dice from five eight sided dice) | |
| # [2d6]=7- (Roll 2 six sided dice, counting anything 7 or lower as a "hit" | |
| # [1d4+1d6+1d8+1d10+1d12+1d20] (Let's roll them all!) | |
| # b3[4d6]+2=18+ (Take the bottom 3 dice from 4 six sided dice, add 2 and count anything at 18 or above as a "hit" | |
| # >> Run options: --seed 46420 | |
| # >> | |
| # >> # Running: | |
| # >> | |
| # >> | |
| # >> | |
| # >> [38;5;154mF[0m[38;5;154ma[0m[38;5;148mb[0m[38;5;184mu[0m[38;5;184ml[0m[38;5;214mo[0m[38;5;214mu[0m[38;5;208ms[0m[38;5;208m [0m[38;5;203mr[0m[38;5;203mu[0m[38;5;198mn[0m in 0.000695s, 0.0000 runs/s, 0.0000 assertions/s. | |
| # >> | |
| # >> 0 runs, 0 assertions, 0 failures, 0 errors, 0 skips | |
| # ~> LoadError | |
| # ~> cannot load such file -- /Users/zph/tmp/seeing_is_believing_temp_dir20140505-47830-1l8fiz5/dicebag | |
| # ~> | |
| # ~> /Users/zph/tmp/seeing_is_believing_temp_dir20140505-47830-1l8fiz5/program.rb:4:in `require_relative' | |
| # ~> /Users/zph/tmp/seeing_is_believing_temp_dir20140505-47830-1l8fiz5/program.rb:4:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment