/** * The spin event is received after the value has changed, making it difficult to set the increment * correctly. Here we detect that the value has not changed correctly and fix it. */ void OddsSpinCtrl::AdjustValue() { double value = GetValue(); std::map<unsigned, std::pair<double, double> >::const_iterator it; for (it = ranges.begin(); it != ranges.end(); ++it) { if (DoubleEquals(previousValue, it->first)) { if (DoubleEquals(value, it->first - it->second.second)) { // eg previous value == 2, new value 1.98, adjust to 1.99 value = it->first - it->second.first; } else if (DoubleEquals(value, it->first + it->second.first)) { // eg previous value == 2, new value 2.01, adjust to 2.02 value = it->first + it->second.second; } } } // snap to nearest tick value = round(value / GetIncrement()) * GetIncrement(); if (!DoubleEquals(value, GetValue())) { SetValue(value); } }
void Market::SetKeyLineIndex( std::vector<PageRunner> handicapPage, greentop::KeyLineDescription keyLineDescription, unsigned handicapIndex ) { bool found = false; if (keyLineDescription.isValid()) { for (const greentop::KeyLineSelection& keyLine : keyLineDescription.getKeyLine()) { for (const PageRunner& runner : handicapPage) { if (DoubleEquals(keyLine.getHandicap(), runner.handicap) && keyLine.getSelectionId() == runner.selectionId) { defaultHandicapIndex = handicapIndex; found = true; break; } } if (found) { break; } } } }
static void RejectDifficultyMismatch(double difficulty, double expected_difficulty) { BOOST_CHECK_MESSAGE( DoubleEquals(difficulty, expected_difficulty, 0.00001), "Difficulty was " + std::to_string(difficulty) + " but was expected to be " + std::to_string(expected_difficulty)); }