You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
project-kyoku/note.cpp

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;
}