Class: Yahtzee::Controller
- Inherits:
-
Object
- Object
- Yahtzee::Controller
- Defined in:
- lib/yahtzee.rb
Overview
class API < Grape::API
version 'v1.1', using: :header, vendor: :yahtzee
end
Instance Method Summary collapse
- #get_data ⇒ Object
- #get_dice ⇒ Object
- #get_potential ⇒ Object
-
#initialize ⇒ Controller
constructor
A new instance of Controller.
- #next_turn ⇒ Object
- #reroll(a) ⇒ Object
- #roll ⇒ Object
- #score(a) ⇒ Object
- #set_dice(a) ⇒ Object
Constructor Details
#initialize ⇒ Controller
Returns a new instance of Controller.
9 10 11 12 13 14 15 |
# File 'lib/yahtzee.rb', line 9 def initialize @message = "" @sc = Scorecard.new @turn = Turn.new end |
Instance Method Details
#get_data ⇒ Object
50 51 52 |
# File 'lib/yahtzee.rb', line 50 def get_data return @sc.get_cats end |
#get_dice ⇒ Object
42 43 44 |
# File 'lib/yahtzee.rb', line 42 def get_dice return @turn.get_dice end |
#get_potential ⇒ Object
54 55 56 |
# File 'lib/yahtzee.rb', line 54 def get_potential return sc.calculate_dice @turn.get_dice end |
#reroll(a) ⇒ Object
21 22 23 |
# File 'lib/yahtzee.rb', line 21 def reroll a @turn.reroll a end |
#score(a) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/yahtzee.rb', line 25 def score a case @sc.score a, @turn.get_dice, @turn.joker? when -1 return -1 when 0 @turn.set_joker true return 0 else next_turn return 1 end end |
#set_dice(a) ⇒ Object
46 47 48 |
# File 'lib/yahtzee.rb', line 46 def set_dice a @turn.set_dice a end |