void MessageOverlordConnection::sendAchievements(set<Achievement*> achievements)
	{
		stringstream s;

		s << "{";
		s << "\"achievements\":";

			s << "{";
			bool first = true;
			set<Achievement*>::const_iterator it;
			for (it = achievements.begin(); it != achievements.end(); it++)
			{
				if (!first)
				{
					s << ",";
				}
				else
				{
					first = false;
				}

				Achievement *achievement = *it;

				string achievementName = achievement->getName();

				s << "\"" << achievementName << "\": {}";
			}
			s << "}";

		s << "}";

		string jsonMessage = s.str();
		messageInterface.sendMessage(jsonMessage);
	}
Beispiel #2
0
bool SQLiteConnector::createAchievement(Achievement saved)
{
    char sentence[256];
    if(dbConnect())
    {
            // sprintf(sentence,"UPDATE Achievements SET Ach_name='%s', Description='%s', Status='%s' WHERE Id='%s');",saved.getName(),saved.getDescription(),saved.getStatus(),saved.getId());
            sprintf(sentence,"INSERT OR REPLACE INTO Achievements (Id, Ach_name, Description, Status) Values ('%s', '%s', '%s', '%s');",saved.getId(),saved.getName(),saved.getDescription(),saved.getStatus());
            msg = sqlite3_exec(db,sentence,NULL,NULL,&error);
            if (msg != SQLITE_OK)
            {
                //cout << error << endl;
                return false;
            }

       dbDisconnect();
       return true;
    }
    return false;
}