Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/splits-io. a speedrunning data store and analysis engine splits.io
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182class Segment < ApplicationRecord belongs_to :run # dependent: :delete_all requires there be no child items that need to be deleted # If SegmentHistory is changed to have child records, change this back to just :destroy has_many :histories, -> { order(attempt_number: :asc) }, class_name: 'SegmentHistory', dependent: :delete_all
def start_ms(timing) case timing when Run::REAL realtime_start_ms when Run::GAME gametime_start_ms end end
def end_ms(timing) case timing when Run::REAL realtime_end_ms when Run::GAME gametime_end_ms end end
def duration_ms(timing) case timing when Run::REAL realtime_duration_ms when Run::GAME gametime_duration_ms end end
def shortest_duration_ms(timing) case timing when Run::REAL realtime_shortest_duration_ms when Run::GAME gametime_shortest_duration_ms end end
def first? segment_number.zero? end
def last? segment_number == run.segments.count - 1 end
def second_half?(timing) (end_ms(timing) - (duration_ms(timing) / 2)) > (run.duration_ms(timing) / 2) end
def gold?(timing) case timing when Run::REAL realtime_gold? when Run::GAME gametime_gold? end end
def reduced?(timing) case timing when Run::REAL realtime_reduced? when Run::GAME gametime_reduced? end end
def skipped?(timing) case timing when Run::REAL realtime_skipped? when Run::GAME gametime_skipped? end endend