class SciolyFF::Interpreter::Placing

Models the result of a team participating (or not) in an event

Attributes

event[R]
subdivision_placing[R]
team[R]

Public Instance Methods

considered_for_team_points?() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 81
def considered_for_team_points?
  initially_considered_for_team_points? &&
    !dropped_as_part_of_worst_placings?
end
did_not_participate?() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 52
def did_not_participate?
  !participated?
end
disqualified?() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 24
def disqualified?
  @rep[:disqualified] || false
end
dropped_as_part_of_worst_placings?() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 60
def dropped_as_part_of_worst_placings?
  team.worst_placings_to_be_dropped.include?(self)
end
exempt?() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 28
def exempt?
  @rep[:exempt] || false
end
initially_considered_for_team_points?() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 86
def initially_considered_for_team_points?
  !(event.trial? || event.trialed? || exempt?)
end
isolated_points() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 70
def isolated_points
  max_place = event.maximum_place
  n = max_place + tournament.n_offset

  if    disqualified? then n + 2
  elsif did_not_participate? then n + 1
  elsif participation_only? || unknown? then n
  else  [calculate_points, max_place].min
  end
end
participated?() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 20
def participated?
  @rep[:participated] || @rep[:participated].nil?
end
participation_only?() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 56
def participation_only?
  participated? && !place && !disqualified? && !unknown?
end
place() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 40
def place
  raw? ? @place ||= event.raws.find_index(raw) + 1 : @rep[:place]
end
points() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 64
def points
  @points ||= if !considered_for_team_points? then 0
              else isolated_points
              end
end
points_affected_by_exhibition?() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 90
def points_affected_by_exhibition?
  considered_for_team_points? && place && !exhibition_placings_behind.zero?
end
points_limited_by_maximum_place?() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 94
def points_limited_by_maximum_place?
  tournament.custom_maximum_place? &&
    (unknown? ||
     (place &&
      (calculate_points > event.maximum_place ||
       calculate_points == event.maximum_place && tie?
      )))
end
raw() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 44
def raw
  @raw ||= Raw.new(@rep[:raw], event.low_score_wins?) if raw?
end
raw?() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 48
def raw?
  @rep.key? :raw
end
tie?() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 36
def tie?
  raw? ? @tie ||= event.raws.count(raw) > 1 : @rep[:tie] == true
end
unknown?() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 32
def unknown?
  @rep[:unknown] || false
end

Private Instance Methods

calculate_points() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 105
def calculate_points
  return place if event.trial?

  place - exhibition_placings_behind
end
exhibition_placings_behind() click to toggle source
# File lib/sciolyff/interpreter/placing.rb, line 111
def exhibition_placings_behind
  @exhibition_placings_behind ||= event.placings.count do |p|
    (p.exempt? || p.team.exhibition?) &&
      p.place &&
      p.place < place
  end
end