Esempio n. 1
0
TimeControl::TimeControl(const QString& str)
	: m_movesPerTc(0),
	  m_timePerTc(0),
	  m_timePerMove(0),
	  m_increment(0),
	  m_timeLeft(0),
	  m_movesLeft(0),
	  m_plyLimit(0),
	  m_nodeLimit(0),
	  m_lastMoveTime(0),
	  m_expiryMargin(0),
	  m_expired(false),
	  m_infinite(false)
{
	if (str == "inf")
	{
		setInfinity(true);
		return;
	}

	QStringList list = str.split('+');

	// increment
	if (list.size() == 2)
	{
		int inc = (int)(list.at(1).toDouble() * 1000);
		if (inc >= 0)
			setTimeIncrement(inc);
	}

	list = list.at(0).split('/');
	QString strTime;

	// moves per tc
	if (list.size() == 2)
	{
		int nmoves = list.at(0).toInt();
		if (nmoves >= 0)
			setMovesPerTc(nmoves);
		strTime = list.at(1);
	}
	else
		strTime = list.at(0);

	// time per tc
	int ms = 0;
	list = strTime.split(':');
	if (list.size() == 2)
		ms = (int)(list.at(0).toDouble() * 60000 + list.at(1).toDouble() * 1000);
	else
		ms = (int)(list.at(0).toDouble() * 1000);

	if (ms > 0)
		setTimePerTc(ms);
}
Esempio n. 2
0
FinalTimer::FinalTimer()
: Timer()
{
	setTimeIncrement(100);
	addTime();
}