Class: Shithead::AI::Offer

Inherits:
Object
  • Object
show all
Defined in:
lib/shithead/ai/offer.rb

Constant Summary collapse

EMPTY_SET =
Shithead::Set.new

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(player, top) ⇒ Offer

Returns a new instance of Offer.



8
9
10
11
# File 'lib/shithead/ai/offer.rb', line 8

def initialize(player, top)
  @player = player
  @top    = top
end

Class Method Details

.call(player, top) ⇒ Object



4
5
6
# File 'lib/shithead/ai/offer.rb', line 4

def self.call(player, top)
  new(player, top).call
end

Instance Method Details

#callObject



13
14
15
16
17
18
# File 'lib/shithead/ai/offer.rb', line 13

def call
  draw_from_hidden if empty_hand?
  return EMPTY_SET if lowest_possible.nil?

  available.take lowest_possible
end