module Scoring

Constants

LowerScores
UpperScores

Public Instance Methods

LS(dice)
Alias for: large_straight
SS(dice)
Alias for: small_straight
chance(dice) click to toggle source

@param dice [Array<Fixnum>] the dice to be evaluated @return [Fixnum] the sum of all the dice

end

# File lib/scoring.rb, line 95
def chance(dice)
        dice.reduce :+
end
fives(d) click to toggle source

@param d [Array<Fixnum>] the dice to be tested @return [Fixnum] the score

end

# File lib/scoring.rb, line 69
def fives(d)
        single_face d, 5
end
four_of_a_kind(dice) click to toggle source

@param dice [Array<Fixnum>] The dice to be tested Checks to see if you have 4 of the same dice @return [Fixnum] 0 if <= 4 indices have the same value @return [Fixnum] dice.reduce(:+) if >= 4 indices have the same value @see (three_of_a_kind)

end

# File lib/scoring.rb, line 29
def four_of_a_kind(dice)
        of_a_kind dice, 4
end
fours(d) click to toggle source

@param d [Array<Fixnum>] the dice to be tested @return [Fixnum] the score

end

# File lib/scoring.rb, line 61
def fours(d)
        single_face d, 4
end
full_house(dice) click to toggle source

@param dice [Array<Fixnum>] The dice to be tested Checks to see if dice has 3 of one kind of dice and 2 of another @return [Fixnum] 25 if dice contains 3 of one Fixnum and 2 of another @return [Fixnum] 0 if dice does not contain 3 of one Fixnum and 2 of another

end

# File lib/scoring.rb, line 15
def full_house(dice)
        f_table = freq dice
        if (f_table.length == 2 && f_table.has_value?(3)) || f_table.length == 1 then return 25                       
        else; return 0
        end
end
large_straight(dice) click to toggle source

@param dice [Array<Fixnum>] the dice to be tested @return [Fixnum] 40 if there are 4 consecutive Fixnums in dice @return [Fixnum] 0 if there are not three conscecutive Fixnums in dice @see (small_straight)

end

# File lib/scoring.rb, line 116
def large_straight(dice)
        straight dice, 5, 40
end
Also aliased as: LS
ones(d) click to toggle source

@param d [Array<Fixnum>] the dice to be tested @return [Fixnum] the total of all the ones

end

# File lib/scoring.rb, line 37
def ones(d)
        single_face d, 1
end
sixes(d) click to toggle source

@param d [Array<Fixnum>] the dice to be tested @return [Fixnum] the score

end

# File lib/scoring.rb, line 77
def sixes(d)   # @see (#ones)
        single_face d, 6
end
small_straight(dice) click to toggle source

@param dice [Array<Fixnum>] the dice to be tested @return [Fixnum] 30 if there are 3 consecutive Fixnums in dice @return [Fixnum] 0 if there are not three conscecutive Fixnums in dice @see (large_straight)

end

# File lib/scoring.rb, line 105
def small_straight(dice)
        straight dice, 4, 30
end
Also aliased as: SS
three_of_a_kind(dice) click to toggle source

@see (four_of_a_kind) Checks to see if you have 3 of the same dice @return [Fixnum] dice.reduce(:+) if there is <= 3 of the same value @return [Fixnum] 0 if you do not have a three of a kind

end

# File lib/scoring.rb, line 87
def three_of_a_kind(dice)
        of_a_kind dice, 3
end
threes(d) click to toggle source

@param d [Array<Fixnum>] the dice to be tested @return [Fixnum] the score

end

# File lib/scoring.rb, line 53
def threes(d)
        single_face d, 3
end
twos(d) click to toggle source

@param d [Array<Fixnum>] the dice to be tested @return [Fixnum] the total of all the twos

end

# File lib/scoring.rb, line 45
def twos(d)
        single_face d, 2
end