Class: Basketball::Draft::FrontOffice

Inherits:
Entity
  • Object
show all
Defined in:
lib/basketball/draft/front_office.rb

Overview

A team will send their front office to a draft room to make draft selections.

Instance Attribute Summary collapse

Attributes inherited from Entity

#id

Instance Method Summary collapse

Methods inherited from Entity

#<=>, #==, #comparable_id, #hash, #to_s

Constructor Details

#initialize(id:, name: '', prioritized_positions: [], risk_level: rand(0..DEFAULT_MAX_RISK_LEVEL), star_level: rand(0..DEFAULT_MAX_STAR_LEVEL)) ⇒ FrontOffice

Returns a new instance of FrontOffice.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/basketball/draft/front_office.rb', line 21

def initialize(
  id:,
  name: '',
  prioritized_positions: [],
  risk_level: rand(0..DEFAULT_MAX_RISK_LEVEL),
  star_level: rand(0..DEFAULT_MAX_STAR_LEVEL)
)
  super(id)

  @name                  = name.to_s
  @risk_level            = risk_level.to_i
  @star_level            = star_level.to_i
  @prioritized_positions = prioritized_positions
  @scout                 = Scout.new

  # fill in the rest of the queue here
  need_count = MAX_POSITIONS - @prioritized_positions.length

  @prioritized_positions += random_positions_queue[0...need_count]

  freeze
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/basketball/draft/front_office.rb', line 19

def name
  @name
end

#prioritized_positionsObject (readonly)

Returns the value of attribute prioritized_positions.



19
20
21
# File 'lib/basketball/draft/front_office.rb', line 19

def prioritized_positions
  @prioritized_positions
end

#risk_levelObject (readonly)

Returns the value of attribute risk_level.



19
20
21
# File 'lib/basketball/draft/front_office.rb', line 19

def risk_level
  @risk_level
end

#scoutObject (readonly)

Returns the value of attribute scout.



19
20
21
# File 'lib/basketball/draft/front_office.rb', line 19

def scout
  @scout
end

#star_levelObject (readonly)

Returns the value of attribute star_level.



19
20
21
# File 'lib/basketball/draft/front_office.rb', line 19

def star_level
  @star_level
end

Instance Method Details

#pick(assessment) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/basketball/draft/front_office.rb', line 44

def pick(assessment)
  players = []
  players = adaptive_search(assessment) if star_level >= assessment.round
  players = balanced_search(assessment) if players.empty?
  players = top_players(assessment)     if players.empty?

  players[0..risk_level].sample
end