-- UPDATE Level SET deleted = 0 WHERE renderer in (80,81,82,83);
UPDATE Level SET difficulty = 1000 WHERE deleted = 0 AND difficulty >= 80;

UPDATE Level SET difficulty = 80 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 7) temp);
UPDATE Level SET difficulty = 80 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 7) temp);
UPDATE Level SET difficulty = 80 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 8) temp);
UPDATE Level SET difficulty = 80 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 83 AND difficulty = 1000 LIMIT 7) temp);

UPDATE Level SET deleted = 0, difficulty = 1000 WHERE id in (SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND deleted = 1 LIMIT 14) temp);

UPDATE Level SET difficulty = 90 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 4) temp);
UPDATE Level SET difficulty = 90 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 4) temp);
UPDATE Level SET difficulty = 90 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 3) temp);
UPDATE Level SET difficulty = 90 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 83 AND difficulty = 1000 LIMIT 4) temp);
UPDATE Level SET difficulty = 90 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 100 AND difficulty = 1000 LIMIT 5) temp);

UPDATE Level SET deleted = 0, difficulty = 1000 WHERE id in (SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND deleted = 1 LIMIT 10) temp);

UPDATE Level SET difficulty = 100 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 2) temp);
UPDATE Level SET difficulty = 100 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 2) temp);
UPDATE Level SET difficulty = 100 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 3) temp);
UPDATE Level SET difficulty = 100 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 83 AND difficulty = 1000 LIMIT 3) temp);
UPDATE Level SET difficulty = 100 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 100 AND difficulty = 1000 LIMIT 10) temp);

UPDATE Level SET deleted = 0, difficulty = 1000 WHERE id in (SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND deleted = 1 LIMIT 9) temp);

UPDATE Level SET words = REPLACE(words, "\\u00fc", "Ü");
UPDATE Level SET words = REPLACE(words, "\\u00dc", "Ü");
UPDATE Level SET words = REPLACE(words, "\\u00f6", "Ö");
UPDATE Level SET words = REPLACE(words, "\\u00df", "ß");
UPDATE Level SET words = REPLACE(words, "\\u00e4", "Ä");
UPDATE Word SET Word.used = 0;
UPDATE Word SET Word.used = 1 WHERE deleted = 0 AND (SELECT count(*) FROM Level WHERE words LIKE CONCAT("%\"", Word.word, "\"%") AND deleted = 0) > 0

-- GENERATE LEVELS!!!

UPDATE Level SET difficulty = 110 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 2) temp);
UPDATE Level SET difficulty = 110 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 110 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 110 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 83 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 110 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 100 AND difficulty = 1000 LIMIT 15) temp);

UPDATE Level SET difficulty = 120 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 120 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 2) temp);
UPDATE Level SET difficulty = 120 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 120 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 83 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 120 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 100 AND difficulty = 1000 LIMIT 10) temp);
UPDATE Level SET difficulty = 120 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 110 AND difficulty = 1000 LIMIT 5) temp);



UPDATE Level SET difficulty = 130 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 130 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 130 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 2) temp);
UPDATE Level SET difficulty = 130 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 83 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 130 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 100 AND difficulty = 1000 LIMIT 10) temp);

UPDATE Level SET difficulty = 140 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 2) temp);
UPDATE Level SET difficulty = 140 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 140 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 140 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 83 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 140 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 100 AND difficulty = 1000 LIMIT 5) temp);

UPDATE Level SET difficulty = 150 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 150 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 150 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 150 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 83 AND difficulty = 1000 LIMIT 2) temp);
UPDATE Level SET difficulty = 150 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 100 AND difficulty = 1000 LIMIT 5) temp);


UPDATE Level SET difficulty = 160 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 160 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 160 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 160 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 83 AND difficulty = 1000 LIMIT 2) temp);
UPDATE Level SET difficulty = 160 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 100 AND difficulty = 1000 LIMIT 5) temp);

UPDATE Level SET difficulty = 170 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 80 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 170 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 81 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 170 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 82 AND difficulty = 1000 LIMIT 1) temp);
UPDATE Level SET difficulty = 170 WHERE id in ( SELECT * FROM (SELECT id FROM Level WHERE renderer = 100 AND difficulty = 1000 LIMIT 10) temp);

