class Shithead::Turn
Attributes
deck[R]
discards[R]
offer[R]
player[R]
stack[R]
Public Class Methods
call(deck, stack, discards, player)
click to toggle source
# File lib/shithead/turn.rb, line 2 def self.call(deck, stack, discards, player) new(deck, stack, discards, player).call end
new(deck, stack, discards, player)
click to toggle source
# File lib/shithead/turn.rb, line 6 def initialize(deck, stack, discards, player) @deck = deck @stack = stack @player = player @discards = discards @offer = Shithead::AI::Offer.call player, stack.top end
Public Instance Methods
call()
click to toggle source
# File lib/shithead/turn.rb, line 14 def call if offer.empty? puts "Picking up", "" stack.release_to player else puts "Playing: #{offer.to_s}", "" offer.release_to stack while player.hand.size < 3 && !deck.empty? player.add deck.draw end end if player.clear? raise Shithead::GameOverError, "Game over, #{player.name} has won." end if stack.clearable? puts "> Clearing", "" stack.release_to discards Shithead::Turn.call deck, stack, discards, player end end