-
Notifications
You must be signed in to change notification settings - Fork 0
/
point_calc.rb
28 lines (27 loc) · 1.12 KB
/
point_calc.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class PointCalculator
def calc(values)
@score = 0
@score += 1000 + ((values.count(1) - 3) * 100) if values.count(1) >= 3
@score += 500 + ((values.count(5) - 3) * 50) if values.count(5) >= 5
@score += 200 if values.count(2) >= 3
@score += 300 if values.count(3) >= 3
@score += 400 if values.count(4) >= 3
@score += 600 if values.count(6) >= 3
@score += (values.count(1) * 100) if values.count(1) < 3
@score += (values.count(5) * 50) if values.count(5) < 3
@scoring = scoring_dies(values)
@non_scoring = values.length - @scoring
puts "\nScoring Dies: #{@scoring}"
puts "\nNon-Scoring Dies: #{@non_scoring}"
return @score, @scoring, @non_scoring
end
def scoring_dies(values)
@count = 0
@count += values.count(1) + values.count(5)
@count += values.count(2) if values.count(2) - 3 == 0
@count += values.count(3) if values.count(3) - 3 == 0
@count += values.count(4) if values.count(4) - 3 == 0
@count += values.count(6) if values.count(6) - 3 == 0
return @count
end
end