示例#1
0
bool GameItem::goRight()
{
    //qDebug("going right");
    if(move(Right)){
        setAnimationStep(square,QPoint(square.x(),square.y() + 1), Right);
        return true;
    }
    qDebug("action right failed");
    emit actionFailed();
    return false;
}
示例#2
0
bool GameItem::goLeft()
{
    //qDebug("going left");
    if(move(Left)){
        setAnimationStep(square,QPoint(square.x(),square.y() + 1), Left);
        return true;
    }
    qDebug("action left failed");
    emit actionFailed();
    return false;
}
示例#3
0
bool GameItem::goUp()
{
    //qDebug("going up");
    if(move(Up)){
        setAnimationStep(square,QPoint(square.x(),square.y() + 1), Up);
        return true;
    }
    qDebug("action up failed");
    emit actionFailed();
    return false;
}
示例#4
0
LastfmService::Result LastfmService::fetch(Args &args)
{
	Result result;
	
	std::string url = baseURL;
	url += methodName();
	for (Args::const_iterator it = args.begin(); it != args.end(); ++it)
	{
		url += "&";
		url += it->first;
		url += "=";
		url += Curl::escape(it->second);
	}
	
	std::string data;
	CURLcode code = Curl::perform(data, url);
	
	if (code != CURLE_OK)
	{
		result.second = curl_easy_strerror(code);
		return result;
	}
	
	if (actionFailed(data))
	{
		StripHtmlTags(data);
		result.second = data;
		return result;
	}
	
	if (!parse(data))
	{
		// if relevant part of data was not found and one of arguments
		// was language, try to fetch it again without that parameter.
		// otherwise just report failure.
		Args::iterator lang = args.find("lang");
		if (lang != args.end())
		{
			args.erase(lang);
			return fetch(args);
		}
		else
		{
			// parse should change data to error msg, if it fails
			result.second = data;
			return result;
		}
	}
	
	result.first = true;
	result.second = data;
	return result;
}
示例#5
0
bool GameItem::goDown()
{
    //qDebug("going down");
    if(move(Down)){
        //qDebug("going down 2");

        setAnimationStep(square,QPoint(square.x(),square.y() + 1), Down);
        return true;
    }
    qDebug("action down failed");
    emit actionFailed();
    return false;
}
示例#6
0
Service::Result Service::fetch()
{
	Result result;
	result.first = false;
	
	std::string url = apiUrl;
	url += methodName();
	for (auto &arg : m_arguments)
	{
		url += "&";
		url += arg.first;
		url += "=";
		url += Curl::escape(arg.second);
	}
	
	std::string data;
	CURLcode code = Curl::perform(data, url);
	
	if (code != CURLE_OK)
		result.second = curl_easy_strerror(code);
	else if (actionFailed(data))
		result.second = msgInvalidResponse;
	else
	{
		result = processData(data);
		
		// if relevant part of data was not found and one of arguments
		// was language, try to fetch it again without that parameter.
		// otherwise just report failure.
		if (!result.first && !m_arguments["lang"].empty())
		{
			m_arguments.erase("lang");
			result = fetch();
		}
	}
	
	return result;
}