35 lines
704 B
C++
35 lines
704 B
C++
|
#include "note.h"
|
||
|
#include <cmath>
|
||
|
|
||
|
Note::Note(microsec offset, microsec death_offset, Note::Arrow type) :
|
||
|
_offset(offset),
|
||
|
_death_offset(death_offset),
|
||
|
_type(type)
|
||
|
{}
|
||
|
|
||
|
microsec Note::deathOffset() const noexcept
|
||
|
{
|
||
|
return _death_offset;
|
||
|
}
|
||
|
|
||
|
NoteGrade Note::onTap(Arrow arrow_type, microsec tap_time_stamp) const
|
||
|
{
|
||
|
if (arrow_type != _type)
|
||
|
return {0, NoteGrade::Rating::WRONG};
|
||
|
|
||
|
microsec odds = std::abs(tap_time_stamp - _offset);
|
||
|
return calculatePrecision(odds);
|
||
|
}
|
||
|
|
||
|
NoteGrade Note::calculatePrecision(microsec odds) const
|
||
|
{
|
||
|
NoteGrade ret;
|
||
|
if (odds < 500000)
|
||
|
{
|
||
|
ret.score = 50;
|
||
|
ret.rating = NoteGrade::Rating::GREAT;
|
||
|
}
|
||
|
|
||
|
return ret;
|
||
|
}
|