Created
June 22, 2010 12:54
-
-
Save ugisozols/448432 to your computer and use it in GitHub Desktop.
This file contains 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
def score(dice) | |
points = 0 | |
roll = { 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0 } | |
dice.each { |i| roll[i] += 1} | |
roll.each do |key, value| | |
case key | |
when 1 | |
if value >= 3 | |
points += 1000 | |
value = value - 3 | |
end | |
points += 100 * value | |
when 5 | |
if value >= 3 | |
points += 100 * 5 | |
value = value - 3 | |
end | |
points += 50 * value | |
else | |
points += 100 * key if value >= 3 | |
end | |
end | |
return points | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment