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