forked from NaiJi/project-kyoku
40 lines
767 B
C++
40 lines
767 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::offset() const noexcept
|
|
{
|
|
return _offset;
|
|
}
|
|
|
|
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 < 412162)
|
|
{
|
|
ret.score = 50;
|
|
ret.rating = NoteGrade::Rating::GREAT;
|
|
}
|
|
|
|
return ret;
|
|
}
|