class Tundengine::Player::InRound
Attributes
bonus_points[W]
declarations[R]
hand[R]
in_match[R]
round[RW]
Public Class Methods
new(player_in_match)
click to toggle source
# File lib/tundengine/player/in_round.rb, line 12 def initialize(player_in_match) @in_match = player_in_match @round = :no_round_set @hand = Hand.new([]) @baza = [] @declarations = [] @round_points = 0 @bonus_points = 0 end
Public Instance Methods
after_declaring!(declaration)
click to toggle source
# File lib/tundengine/player/in_round.rb, line 30 def after_declaring!(declaration) if declaration.is_declarable?(hand, round.trump_suit) declarations << declaration round.after_declaring!(declaration) else raise "cannot declare #{declaration} after trick #{round.current_trick.summary} with hand #{hand}" end end
declare!(declaration = Declarations::Null.instance)
click to toggle source
# File lib/tundengine/player/in_round.rb, line 26 def declare!(declaration = Declarations::Null.instance) strategy.declare!(self, declaration) end
has_empty_baza?()
click to toggle source
# File lib/tundengine/player/in_round.rb, line 53 def has_empty_baza? @baza.empty? end
has_empty_hand?()
click to toggle source
# File lib/tundengine/player/in_round.rb, line 49 def has_empty_hand? hand.empty? end
on_winning_trick!(trick)
click to toggle source
# File lib/tundengine/player/in_round.rb, line 39 def on_winning_trick!(trick) take! trick declare! end
summary()
click to toggle source
# File lib/tundengine/player/in_round.rb, line 61 def summary { name: name, hand: hand.map(&:to_s), baza: @baza.map(&:to_s) } end
take!(trick)
click to toggle source
# File lib/tundengine/player/in_round.rb, line 44 def take!(trick) @baza = @baza.concat trick.cards @round_points += trick.points end
take_card!(card)
click to toggle source
# File lib/tundengine/player/in_round.rb, line 22 def take_card!(card) hand << card end
total_round_points()
click to toggle source
# File lib/tundengine/player/in_round.rb, line 57 def total_round_points @round_points + @bonus_points end