stattr 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/stattr.rb +58 -0
  2. metadata +46 -0
data/lib/stattr.rb ADDED
@@ -0,0 +1,58 @@
1
+ $statlist = ['STR', 'DEX', 'CHA', 'INT', 'WIS', 'CON']
2
+
3
+ # Roll a D(sides) size die.
4
+ def rollD(sides)
5
+ return rand(sides) + 1
6
+ end
7
+
8
+
9
+ # Rolls a number of dice of particular sizes.
10
+ def rollmanyD(dice, sides)
11
+ rolls = 0
12
+ #for i in (1..dice)
13
+ #rolls = rolls + rollD(sides)
14
+ #end
15
+ (1..dice).each do |i|
16
+ rolls = rolls + rollD(sides)
17
+ end
18
+ rolls
19
+ end
20
+
21
+ def modstat(r)
22
+ modlist = []
23
+ case r
24
+ when 3
25
+ modlist = [r, -4]
26
+ when (4..5)
27
+ modlist = [r, -3]
28
+ when (6..7)
29
+ modlist = [r, -2]
30
+ when (8..9)
31
+ modlist = [r, -1]
32
+ when (10..11)
33
+ modlist = [r, 0]
34
+ when (12..13)
35
+ modlist = [r, 1]
36
+ when (14..15)
37
+ modlist = [r, 2]
38
+ when (16..17)
39
+ modlist = [r, 3]
40
+ when 18
41
+ modlist = [r, 4]
42
+ else
43
+ puts "nothing"
44
+ end
45
+ modlist
46
+ end
47
+
48
+
49
+
50
+ #This iterates through the Stat list and turns each stat into a key. It then rolls 3 d6's to get the starting value for that stat.
51
+ def statroll
52
+ stathash = {}
53
+ $statlist.each do |stat|
54
+ stathash[stat] = modstat(rollmanyD(3,6))
55
+ end
56
+ stathash
57
+ end
58
+
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stattr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alex Jarvis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-07 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Stattr is a Gem that includes a number of useful functions for rolling
15
+ dice in a game like Dungeons and Dragions.
16
+ email: alxjrvs@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/stattr.rb
22
+ homepage: http://rubygems.org/gems/stattr
23
+ licenses: []
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 1.8.24
43
+ signing_key:
44
+ specification_version: 3
45
+ summary: Stattr; a Way To Get Stats
46
+ test_files: []