Пример #1
0
MatchResult MatchUp(const InputEventQueue::FilteredQueue & Queue, InputEventQueue::FilteredQueue::const_iterator InputEventIterator)
{
	if (Queue.end() == InputEventIterator)
		return MatchResult(1);

	if (IsPointerButtonEvent<Pointer::VirtualCategory::POINTING, 0, false>(**InputEventIterator))
	{
		InputEventQueue::FilteredQueue Events;
		Events.push_back(*InputEventIterator);
		++InputEventIterator;
		return MatchResult(InputEventIterator, Events);
	}

	return MatchResult();
}
Пример #2
0
MatchResult MatchSpace(const InputEventQueue::FilteredQueue & Queue, InputEventQueue::FilteredQueue::const_iterator InputEventIterator)
{
	if (Queue.end() == InputEventIterator)
		return MatchResult(1);

	if (IsPointerButtonEvent<Pointer::VirtualCategory::TYPING, GLFW_KEY_SPACE, true>(**InputEventIterator))
	{
		InputEventQueue::FilteredQueue Events;
		Events.push_back(*InputEventIterator);
		++InputEventIterator;
		return MatchResult(InputEventIterator, Events);
	}

	return MatchResult();
}
Пример #3
0
MatchResult MatchManipulationEnd(const InputEventQueue::FilteredQueue & Queue, InputEventQueue::FilteredQueue::const_iterator InputEventIterator, bool InManipulationTEST, Input::InputId ButtonId)
{
	if (true != InManipulationTEST)
		return MatchResult();

	if (Queue.end() == InputEventIterator)
		return MatchResult(1);

	if (IsPointerButtonEvent<Pointer::VirtualCategory::POINTING, false>(**InputEventIterator, ButtonId))
	{
		InputEventQueue::FilteredQueue Events;
		Events.push_back(*InputEventIterator);
		++InputEventIterator;
		return MatchResult(InputEventIterator, Events);
	}

	return MatchResult();
}
Пример #4
0
MatchResult MatchManipulationUpdate(const InputEventQueue::FilteredQueue & Queue, InputEventQueue::FilteredQueue::const_iterator InputEventIterator, bool InManipulationTEST)
{
	if (true != InManipulationTEST)
		return MatchResult();

	if (Queue.end() == InputEventIterator)
		return MatchResult(1);

	if (IsPointerPointingMoveEvent<0>(**InputEventIterator))
	{
		InputEventQueue::FilteredQueue Events;
		Events.push_back(*InputEventIterator);
		++InputEventIterator;
		return MatchResult(InputEventIterator, Events);
	}

	return MatchResult();
}
Пример #5
0
    Rule::MatchResult Rule::match(const char* first, const char* last, size_t pos /* = 0 */)
    {
#ifdef _DEBUG
        if (pos < 0 || pos >= (size_t)(last - first)) throw error<const char*>("invalid position of input", __FILE__, __LINE__);
#endif
        const char* b = first;

        char*  output = NULL;
        size_t size;

        for (const char* i = first + pos; i != last; ++i)
        {
            if (parse(i, last, output, size))
            {
                return MatchResult(output, i - b);
            }
        }
        return MatchResult(output, -1);
    }
MatchResult CompositeWidget::InnerMatchEventQueue(InputEventQueue::FilteredQueue & UnreservedEvents)
{
	for (auto & Widget : reverse(m_Widgets))
	{
		auto Match = Widget->MatchEventQueue(UnreservedEvents);

		if (Match.AnySuccess())
			return Match;
	}

	return MatchResult();
}
Пример #7
0
MatchResult RegExp::match(VM& vm, const String& s, unsigned startOffset)
{
#if ENABLE(REGEXP_TRACING)
    m_rtMatchOnlyCallCount++;
    m_rtMatchOnlyTotalSubjectStringLen += (double)(s.length() - startOffset);
#endif

    ASSERT(m_state != ParseError);
    compileIfNecessaryMatchOnly(vm, s.is8Bit() ? Yarr::Char8 : Yarr::Char16);

#if ENABLE(YARR_JIT)
    if (m_state == JITCode) {
        MatchResult result = s.is8Bit() ?
            m_regExpJITCode.execute(s.characters8(), startOffset, s.length()) :
            m_regExpJITCode.execute(s.characters16(), startOffset, s.length());
#if ENABLE(REGEXP_TRACING)
        if (!result)
            m_rtMatchOnlyFoundCount++;
#endif
        return result;
    }
#endif

    int offsetVectorSize = (m_numSubpatterns + 1) * 2;
    int* offsetVector;
    Vector<int, 32> nonReturnedOvector;
    nonReturnedOvector.resize(offsetVectorSize);
    offsetVector = nonReturnedOvector.data();
    int r = Yarr::interpret(m_regExpBytecode.get(), s, startOffset, reinterpret_cast<unsigned*>(offsetVector));
#if REGEXP_FUNC_TEST_DATA_GEN
    RegExpFunctionalTestCollector::get()->outputOneTest(this, s, startOffset, offsetVector, result);
#endif

    if (r >= 0) {
#if ENABLE(REGEXP_TRACING)
        m_rtMatchOnlyFoundCount++;
#endif
        return MatchResult(r, reinterpret_cast<unsigned*>(offsetVector)[1]);
    }

    return MatchResult::failed();
}
Пример #8
0
	const Selector::MatchResult AttributeSelector::Match(const Node* node) const
	{		
		switch (m_operator)
		{
			case SelectorOperator::Exists:
			{						
				if (node->HasAttribute(m_attributeNameRef))
				{
					return MatchResult(node);
				}
			}
			break;

			case SelectorOperator::ValueContains:
			{
				auto attributeValue = node->GetAttributeValue(m_attributeNameRef);

				if (attributeValue.size() == 0)
				{
					return false;
				}

				// Just do a search
				auto searchResult = attributeValue.find(m_attributeValueRef);

				// Simply return whether or not we got any matches.
				if (searchResult != boost::string_ref::npos)
				{
					return MatchResult(node);
				}
			}
			break;

			case SelectorOperator::ValueEquals:
			{
				auto attributeValue = node->GetAttributeValue(m_attributeNameRef);

				auto oneSize = attributeValue.size();
				auto twoSize = m_attributeValueRef.size();

				if (oneSize == 0 || oneSize != twoSize)
				{
					return false;
				}

				if (oneSize >= 4)
				{
					if ((attributeValue[0] == m_attributeValueRef[0]) &&
						(attributeValue[1] == m_attributeValueRef[1]) &&
						(attributeValue[oneSize - 1] == m_attributeValueRef[oneSize - 1]) &&
						(attributeValue[oneSize - 2] == m_attributeValueRef[oneSize - 2]))
					{
						if (std::memcmp(attributeValue.begin(), m_attributeValueRef.begin(), oneSize) == 0)
						{
							return MatchResult(node);
						}
					}
				}
				else
				{
					if (std::memcmp(attributeValue.begin(), m_attributeValueRef.begin(), oneSize) == 0)
					{
						return MatchResult(node);
					}
				}

				return false;
			}
			break;

			case SelectorOperator::ValueHasPrefix:
			{
				auto attributeValue = node->GetAttributeValue(m_attributeNameRef);
						
				auto subSize = m_attributeValueRef.size();

				if (attributeValue.size() == 0 || attributeValue.size() <= subSize)
				{					
					return false;
				}				

				auto sub = attributeValue.substr(0, subSize);

				subSize = sub.size();

				if (subSize == m_attributeValueRef.size())
				{
					if (subSize >= 4)
					{
						if ((sub[0] == m_attributeValueRef[0]) &&
							(sub[1] == m_attributeValueRef[1]) &&
							(sub[subSize - 1] == m_attributeValueRef[subSize - 1]) &&
							(sub[subSize - 2] == m_attributeValueRef[subSize - 2]))
						{
							if (std::memcmp(sub.begin(), m_attributeValueRef.begin(), subSize) == 0)
							{
								return MatchResult(node);
							}
						}
					}
					else
					{
						if (std::memcmp(sub.begin(), m_attributeValueRef.begin(), subSize) == 0)
						{
							return MatchResult(node);
						}
					}
				}

				return false;
			}
			break;

			case SelectorOperator::ValueHasSuffix:
			{
				auto attributeValue = node->GetAttributeValue(m_attributeNameRef);

				auto subSize = m_attributeValueRef.size();

				// If our suffix is greater than the attribute value, we can just move on.
				if (attributeValue.size() == 0 || subSize >= attributeValue.size())
				{
					return false;
				}

				// Test equality of same-length substring taken from the end.
				boost::string_ref sub = attributeValue.substr((attributeValue.size() - subSize));

				subSize = sub.size();

				if (subSize == m_attributeValueRef.size())
				{
					if (subSize >= 4)
					{
						if ((sub[0] == m_attributeValueRef[0]) &&
							(sub[1] == m_attributeValueRef[1]) &&
							(sub[subSize - 1] == m_attributeValueRef[subSize - 1]) &&
							(sub[subSize - 2] == m_attributeValueRef[subSize - 2]))
						{
							if (std::memcmp(sub.begin(), m_attributeValueRef.begin(), subSize) == 0)
							{
								return MatchResult(node);
							}
						}
					}
					else
					{
						if (std::memcmp(sub.begin(), m_attributeValueRef.begin(), subSize) == 0)
						{
							return MatchResult(node);
						}
					}
				}

				return false;
			}
			break;

			case SelectorOperator::ValueContainsElementInWhitespaceSeparatedList:
			{
				auto attributeValue = node->GetAttributeValue(m_attributeNameRef);

				// If the attribute value to check is smaller than our value, then we can just
				// return false right away.
				if (attributeValue.size() == 0 || attributeValue.size() < m_attributeValueRef.size())
				{
					return false;
				}

				if (attributeValue.size() == m_attributeValueRef.size())
				{
					// If the two values match exactly, this is considered a match with this
					// selector type. If they do not match, the only other possible type of match
					// this operator can make is the match the selector value PLUS whitespace, in
					// which case this isn't possible (being the two strings equal length), so
					// letting boost::iequals return false or true is the right answer either way.

					auto oneSize = attributeValue.size();

					if (oneSize >= 4)
					{
						if ((attributeValue[0] == m_attributeValueRef[0]) && 
							(attributeValue[1] == m_attributeValueRef[1]) &&
							(attributeValue[oneSize - 1] == m_attributeValueRef[oneSize - 1]) &&
							(attributeValue[oneSize - 2] == m_attributeValueRef[oneSize - 2]))
						{
							if (std::memcmp(attributeValue.begin(), m_attributeValueRef.begin(), oneSize) == 0)
							{
								return MatchResult(node);
							}
						}
					}
					else
					{
						if (std::memcmp(attributeValue.begin(), m_attributeValueRef.begin(), oneSize) == 0)
						{
							return MatchResult(node);
						}
					}

					return false;
				}

				// If there isn't anything that qualifies as whitespace in the CSS selector world,
				// then we can just immediately return false.
				auto anySpacePosition = attributeValue.find(' ');

				if (anySpacePosition == boost::string_ref::npos)
				{
					return false;
				}				
				
				auto firstSpace = attributeValue.find(' ');

				while (firstSpace != boost::string_ref::npos && attributeValue.size() > 0)
				{					
					if (firstSpace > 0 && firstSpace == m_attributeValueRef.size())
					{
						auto sub = attributeValue.substr(0, firstSpace);

						auto subSize = sub.size();

						if (subSize == m_attributeValueRef.size())
						{
							if (subSize >= 4)
							{
								if ((sub[0] == m_attributeValueRef[0]) &&
									(sub[1] == m_attributeValueRef[1]) &&
									(sub[subSize - 1] == m_attributeValueRef[subSize - 1]) &&
									(sub[subSize - 2] == m_attributeValueRef[subSize - 2]))
								{
									if (std::memcmp(sub.begin(), m_attributeValueRef.begin(), subSize) == 0)
									{
										return MatchResult(node);
									}
								}
							}
							else
							{
								if (std::memcmp(sub.begin(), m_attributeValueRef.begin(), subSize) == 0)
								{
									return MatchResult(node);
								}
							}
						}						
					}

					attributeValue = attributeValue.substr(firstSpace + 1);
					firstSpace = attributeValue.find(' ');
				}

				return false;
			}
			break;

			case SelectorOperator::ValueIsHyphenSeparatedListStartingWith:
			{
				auto attributeValue = node->GetAttributeValue(m_attributeNameRef);

				// If the attribute value to check is smaller than our value, then we can just
				// return false right away.
				if (attributeValue.size() == 0 || attributeValue.size() < m_attributeValueRef.size())
				{
					return false;
				}

				if (attributeValue.size() == m_attributeValueRef.size())
				{
					// If the two values match exactly, this is considered a match with this
					// selector type. If they do not match, the only other possible type of match
					// this operator can make is the match the selector value PLUS a dash, in which
					// case this isn't possible (being the two strings equal length), so letting
					// boost::iequals return false or true is the right answer either way.

					auto oneSize = attributeValue.size();

					if (oneSize >= 4)
					{
						if ((attributeValue[0] == m_attributeValueRef[0]) &&
							(attributeValue[1] == m_attributeValueRef[1]) &&
							(attributeValue[oneSize - 1] == m_attributeValueRef[oneSize - 1]) &&
							(attributeValue[oneSize - 2] == m_attributeValueRef[oneSize - 2]))
						{
							if (std::memcmp(attributeValue.begin(), m_attributeValueRef.begin(), oneSize) == 0)
							{
								return MatchResult(node);
							}
						}
					}
					else
					{
						if (std::memcmp(attributeValue.begin(), m_attributeValueRef.begin(), oneSize) == 0)
						{
							return MatchResult(node);
						}
					}

					return false;
				}

				// If we didn't find an exact match, then the only hope of a match now is finding
				// the selector value at the start of the attribute value, immediately followed by a
				// hyphen. Therefore, if we can't find a hypen, then we simply return false right
				// away.
				auto anyHyphen = attributeValue.find('-');

				if (anyHyphen == boost::string_ref::npos)
				{
					return false;
				}

				// A hyphen was found, so all we have to do is make a case-insensitive match against
				// a substring of equal length to our member value.
				boost::string_ref sub = attributeValue.substr(0, m_attributeValueRef.size() + 1);

				if (sub[sub.length() - 1] != '-')
				{
					// If the last character in the substring isn't a dash, it can't possibly be a match anyway.
					return false;
				}

				sub = attributeValue.substr(0, m_attributeValueRef.size());

				auto subSize = sub.size();

				if (subSize == m_attributeValueRef.size())
				{
					if (subSize >= 4)
					{
						if ((sub[0] == m_attributeValueRef[0]) &&
							(sub[1] == m_attributeValueRef[1]) &&
							(sub[subSize - 1] == m_attributeValueRef[subSize - 1]) &&
							(sub[subSize - 2] == m_attributeValueRef[subSize - 2]))
						{
							if (std::memcmp(sub.begin(), m_attributeValueRef.begin(), subSize) == 0)
							{
								return MatchResult(node);
							}
						}
					}
					else
					{
						if (std::memcmp(sub.begin(), m_attributeValueRef.begin(), subSize) == 0)
						{
							return MatchResult(node);
						}
					}
				}		

				return false;
			}
			break;
		}

		return false;
	}
Пример #9
0
extern void CommandRelationalAddMatch(char *sz)
{
	DBProvider *pdb;
	char *buf, *buf2, *date;
	char warnings[1024] = "";
	int session_id, existing_id, player_id0, player_id1;
	char *arg = NULL;
	gboolean quiet = FALSE;

	arg = NextToken(&sz);
	if (arg)
		quiet = !strcmp(arg, "quiet");

	if (ListEmpty(&lMatch))
	{
		outputl( _("No match is being played.") );
		return;
	}

	/* Warn if match is not finished or fully analyzed */
	if (!quiet && !GameOver())
		strcat(warnings, _("The match is not finished\n"));
	if (!quiet && !MatchAnalysed())
		strcat(warnings, _("All of the match is not analyzed\n"));

	if (*warnings)
	{
		strcat(warnings, _("\nAdd match anyway?"));
		if (!GetInputYN(warnings))
			return;
	}

	if ((pdb = ConnectToDB(dbProviderType)) == NULL)
		return;

	existing_id = RelationalMatchExists(pdb);
	if (existing_id != -1)
	{
		if (!quiet && !GetInputYN(_("Match exists, overwrite?")))
			return;

		/* Remove any game stats and games */
		buf2 = g_strdup_printf("FROM game WHERE session_id = %d", existing_id);
		buf = g_strdup_printf("DELETE FROM gamestat WHERE game_id in (SELECT game_id %s)", buf2);
		pdb->UpdateCommand(buf);
		g_free(buf);
		buf = g_strdup_printf("DELETE %s", buf2);
		pdb->UpdateCommand(buf);
		g_free(buf);
		g_free(buf2);

		/* Remove any match stats and session */
		buf = g_strdup_printf("DELETE FROM matchstat WHERE session_id = %d", existing_id);
		pdb->UpdateCommand(buf);
		g_free(buf);
		buf = g_strdup_printf("DELETE FROM session WHERE session_id = %d", existing_id);
		pdb->UpdateCommand(buf);
		g_free(buf);
	}

	session_id = GetNextId(pdb, "session");
	player_id0 = AddPlayer(pdb, ap[0].szName);
	player_id1 = AddPlayer(pdb, ap[1].szName);
	if (session_id == -1 || player_id0 == -1 || player_id1 == -1)
	{
		outputl( _("Error adding match.") );
		return;
	}

	if( mi.nYear )
		date = g_strdup_printf("%04d-%02d-%02d", mi.nYear, mi.nMonth, mi.nDay);
	else
		date = NULL;

	buf = g_strdup_printf("INSERT INTO session(session_id, checksum, player_id0, player_id1, "
              "result, length, added, rating0, rating1, event, round, place, annotator, comment, date) "
              "VALUES (%d, '%s', %d, %d, %d, %d, CURRENT_TIMESTAMP, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
				session_id, GetMatchCheckSum(), player_id0, player_id1,
				MatchResult(ms.nMatchTo), ms.nMatchTo, NS(mi.pchRating[0]), NS(mi.pchRating[1]),
				NS(mi.pchEvent), NS(mi.pchRound), NS(mi.pchPlace), NS(mi.pchAnnotator), NS(mi.pchComment), NS(date));

	updateStatisticsMatch ( &lMatch );

	if (pdb->UpdateCommand(buf))
	{
		if (AddStats(pdb, session_id, player_id0, 0, "matchstat", ms.nMatchTo, &scMatch) &&
			AddStats(pdb, session_id, player_id1, 1, "matchstat", ms.nMatchTo, &scMatch))
		{
			if (storeGameStats)
				AddGames(pdb, session_id, player_id0, player_id1);
			pdb->Commit();
		}
	}
	g_free(buf);
	g_free(date);
	pdb->Disconnect();
}
Пример #10
0
MatchResult GestureRecognizer::MatchEventQueue(InputEventQueue::FilteredQueue & UnreservedEvents)
{
	auto InputEventIterator = UnreservedEvents.begin();
	auto & InputEvent = **InputEventIterator;

#if 1
	// If the pointer is not connected to this GR (meaning a failed HitTest), return failed match
	// DEBUG: Is this the right way to go about it? Or a temporary hack? Figure it out.
	if (   nullptr != InputEvent.m_Pointer
		&& GetConnected().end() == GetConnected().find(InputEvent.m_Pointer)
		&& nullptr == dynamic_cast<TypingModule *>(&m_Owner))		// HACK!! (To enable TypingModule to work, i.e. get input while not being pointed to)
	{
		m_InManipulation = false;		// HACK: Not sure if this is the best way of doing it

		return MatchResult();
	}
#else
	Vector2n GlobalPosition(InputEvent.m_PreEventState.GetAxisState(0).GetPosition(), InputEvent.m_PreEventState.GetAxisState(1).GetPosition());
	//printf("Global Pos %d, %d.\n", GlobalPosition.X(), GlobalPosition.Y());
	if (/*   !m_InManipulation
		&& */!static_cast<Widget &>(m_Owner).IsHit(static_cast<Widget &>(m_Owner).GlobalToParent(GlobalPosition))
		&& (   nullptr != InputEvent.m_Pointer
			&& GetConnected().end() == GetConnected().find(InputEvent.m_Pointer)))
	{
		return MatchResult();
	}
#endif

// DEBUG: I don't think the following is neccessary anymore, so I will try just setting Hit to true at all times and see if that breaks anything. If not, might as well remove this (unneccessary?) check
#if 0
	Vector2n GlobalPosition(InputEvent.m_PreEventState.GetAxisState(0).GetPosition(), InputEvent.m_PreEventState.GetAxisState(1).GetPosition());
	auto Hit = static_cast<Widget &>(m_Owner).IsHit(static_cast<Widget &>(m_Owner).GlobalToParent(GlobalPosition));
	/*if (!Hit) {
		std::cout << "OMGGG LOOK HERE!!!! Hit IS false\n";
	}*/
#else
	auto Hit = true;
#endif

	MatchResult Match;
	if (m_RecognizeDoubleTap && (Match = MatchDoubleTap2(UnreservedEvents, InputEventIterator)).AnySuccess())
	{
		if (2 == Match.Status)
		{
			m_Owner.ProcessDoubleTap(InputEvent, Vector2n((*InputEventIterator)->m_PostEventState.GetAxisState(0).GetPosition(), (*InputEventIterator)->m_PostEventState.GetAxisState(1).GetPosition()));
		}
	}
	else if (m_RecognizeTap && (Match = MatchTap2(UnreservedEvents, InputEventIterator)).AnySuccess())
	{
		if (2 == Match.Status)
		{
			m_Owner.ProcessTap(InputEvent, Vector2n((*InputEventIterator)->m_PostEventState.GetAxisState(0).GetPosition(), (*InputEventIterator)->m_PostEventState.GetAxisState(1).GetPosition()));
		}
	}
	else if (m_RecognizeManipulationTranslate && (Match = MatchManipulationBegin(UnreservedEvents, InputEventIterator, m_InManipulation, Hit, m_RecognizeManipulationTranslateButtonId)).AnySuccess())
	{
		if (2 == Match.Status)
		{
			m_InManipulation = true;
			m_Owner.ProcessManipulationBegin(InputEvent);
		}
	}
	else if (m_RecognizeManipulationTranslate && (Match = MatchManipulationUpdate(UnreservedEvents, InputEventIterator, m_InManipulation)).AnySuccess())
	{
		if (2 == Match.Status)
		{
			m_Owner.ProcessManipulationUpdate(InputEvent);
		}
	}
	else if (m_RecognizeManipulationTranslate && (Match = MatchManipulationEnd(UnreservedEvents, InputEventIterator, m_InManipulation, m_RecognizeManipulationTranslateButtonId)).AnySuccess())
	{
		if (2 == Match.Status)
		{
			m_Owner.ProcessManipulationEnd(InputEvent);
			m_InManipulation = false;
		}
	}
	else if (ProcessShortcuts(InputEvent))
	{
		Match.Status = 2;
		Match.Events.push_back(*InputEventIterator);
	}
	else if (ProcessEventHandledTEST(InputEvent))
	{
		Match.Status = 2;
		Match.Events.push_back(*InputEventIterator);
	}

	return Match;
}
Пример #11
0
MatchResult MatchDoubleTap2(const InputEventQueue::FilteredQueue & Queue, InputEventQueue::FilteredQueue::const_iterator InputEventIterator)
{
	auto Match = MatchDown(Queue, InputEventIterator);
	if (2 == Match.Status)
	{
		Vector2n DownPosition((*InputEventIterator)->m_PostEventState.GetAxisState(0).GetPosition(), (*InputEventIterator)->m_PostEventState.GetAxisState(1).GetPosition());
		auto DownTime = (*InputEventIterator)->GetTimestamp();
		auto PointingPointer = (*InputEventIterator)->m_Pointer;

		uint8 NumberOfTaps = 0;

		auto FilteredQueue2 = InputEventQueue::FilterByPointer(InputEventQueue::CreateFilteredQueue(Queue, Match.End), PointingPointer);
		for (auto InputEventIterator2 = FilteredQueue2.begin(); FilteredQueue2.end() != InputEventIterator2; ++InputEventIterator2)
		{
			Match.Events.push_back(*InputEventIterator2);

			if (IsPointerButtonEvent<Pointer::VirtualCategory::POINTING, 0, false>(**InputEventIterator2))
			{
				Vector2n UpPosition((*InputEventIterator2)->m_PostEventState.GetAxisState(0).GetPosition(), (*InputEventIterator2)->m_PostEventState.GetAxisState(1).GetPosition());
				auto UpTime = (*InputEventIterator2)->GetTimestamp();

				if (   (UpPosition - DownPosition).LengthSquared() <= (TapRadius * TapRadius)
					&& (UpTime - DownTime) <= DoubleTapTime)
				{
					if (1 == NumberOfTaps)
					{
						++InputEventIterator2;
						return MatchResult(InputEventIterator2, Match.Events);
					}
					else
						++NumberOfTaps;
				}
				else
				{
					return MatchResult();
				}
			}
			else if (IsPointerPointingMoveEvent<0>(**InputEventIterator2))
			{
				Vector2n MovePosition((*InputEventIterator2)->m_PostEventState.GetAxisState(0).GetPosition(), (*InputEventIterator2)->m_PostEventState.GetAxisState(1).GetPosition());
				auto NewTime = (*InputEventIterator2)->GetTimestamp();

				if (   (MovePosition - DownPosition).LengthSquared() <= (TapRadius * TapRadius)
					&& (NewTime - DownTime) <= TapTime)
				{}
				else
				{
					return MatchResult();
				}
			}
			else if (IsPointerButtonEvent<Pointer::VirtualCategory::POINTING, 0, true>(**InputEventIterator2))
			{
				Vector2n DownAgainPosition((*InputEventIterator2)->m_PostEventState.GetAxisState(0).GetPosition(), (*InputEventIterator2)->m_PostEventState.GetAxisState(1).GetPosition());
				auto NewTime = (*InputEventIterator2)->GetTimestamp();

				if (   (DownAgainPosition - DownPosition).LengthSquared() <= (TapRadius * TapRadius)
					&& (NewTime - DownTime) <= TapTime)
				{}
				else
				{
					return MatchResult();
				}
			}
			else
			{
				return MatchResult();
			}
		}

		// Only if there's still a chance a new event can come in time to make a match
		if ((glfwGetTime() - DownTime) <= DoubleTapTime)
		{
			Match.Status = 1;
			return Match;
		}
	}
	else
	{
		return Match;
	}

	return MatchResult();
}
Пример #12
0
MatchResult flipResult(const MatchResult& result) {
  return MatchResult(result.index2, result.index1, result.distance);
}
Пример #13
0
MatchResult pairToMatchResult(const std::pair<Match, double>& pair) {
  return MatchResult(pair.first, pair.second);
}
Пример #14
0
	void AIModule::saveGameResult(bool isBotWinner)
	{
		MatchResult result = MatchResult(game, isBotWinner);
		result.save("result.txt");
	}