Top Level Namespace

Defined Under Namespace

Classes: Playerchar, Statlist

Constant Summary collapse

Normstats =
['STR', 'DEX', 'CHA', 'INT', 'WIS', 'CON']

Instance Method Summary collapse

Instance Method Details

#modstat(r) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/stattr.rb', line 18

def modstat(r)
modlist = []
    case r
    when 3
       modlist = [r, -4]
    when (4..5) 
       modlist = [r, -3]
    when (6..7)
       modlist = [r, -2]
    when (8..9)
       modlist = [r, -1]
    when (10..11)
       modlist = [r, 0]
    when (12..13)
       modlist = [r, 1]
    when (14..15)
       modlist = [r, 2]
    when (16..17)
       modlist = [r, 3]
    when 18
       modlist = [r, 4]
   else 
        puts "nothing"
    end
modlist
end

#rolld(sides) ⇒ Object

Roll a D(sides) size die.



4
5
6
# File 'lib/stattr.rb', line 4

def rolld(sides)
rand(sides) + 1  
end

#rollmanyd(sides, dice) ⇒ Object

Rolls a number of dice of particular sizes.



10
11
12
13
14
15
16
# File 'lib/stattr.rb', line 10

def rollmanyd(sides, dice)
    rolls = 0 
    (1..dice).each do |i|
        rolls = rolls + rolld(sides)
    end
rolls
end

#statrollObject

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.



48
49
50
51
52
53
54
# File 'lib/stattr.rb', line 48

def statroll 
    stathash = {} 
        Normstats.each do |stat|
            stathash[stat] = modstat(rollmanyd(6,3))
        end
    stathash
end