module Scoring
Constants
- LowerScores
- UpperScores
Public Instance Methods
@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
@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
@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
@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
@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