From: JBM Date: Sun, 31 May 2020 14:52:19 +0000 (+0200) Subject: Activate cheating X-Git-Url: https://troll.desast.re/troll.git/commitdiff_plain/04f2c0a927385cae3c11009179c21c72780d40b7?ds=inline;hp=6ee812987dd1b5e42e23ae463838c4c15a2c3e86 Activate cheating --- diff --git a/src/main/java/com/codingame/game/View.java b/src/main/java/com/codingame/game/View.java index 0820190..38548dc 100644 --- a/src/main/java/com/codingame/game/View.java +++ b/src/main/java/com/codingame/game/View.java @@ -345,6 +345,18 @@ class View { .setSkewX((random.nextDouble() - 0.5) /4) .setSkewY((random.nextDouble() - 0.5) /8); } + + // base png: 514×387 + Sprite f7u12 = graphicEntityModule.createSprite() + .setImage("f7u12.png") + .setX(1920 / 2) + .setY(1080 / 2) + .setAnchorX(0.5) + .setAnchorY(0.5) + .setBaseWidth(514*1080/387) + .setBaseHeight(1080) + .setZIndex(200); + pantsModule.displayOnToggleState(f7u12, "troll", true); } enum TrollRace { diff --git a/src/main/resources/view/assets/f7u12.png b/src/main/resources/view/assets/f7u12.png new file mode 100644 index 0000000..5e5c60b Binary files /dev/null and b/src/main/resources/view/assets/f7u12.png differ diff --git a/src/main/resources/view/assets/f7u12.xcf b/src/main/resources/view/assets/f7u12.xcf new file mode 100644 index 0000000..97de0cb Binary files /dev/null and b/src/main/resources/view/assets/f7u12.xcf differ diff --git a/src/main/resources/view/config.js b/src/main/resources/view/config.js index 933976f..d29faf0 100644 --- a/src/main/resources/view/config.js +++ b/src/main/resources/view/config.js @@ -13,9 +13,19 @@ export const modules = [ , ToggleModule ]; +function ip_shuffle(array) { + for (var i = array.length-1; i > 0; i--) { + var s = Math.floor((i+1) * Math.random()); + var selected = array[s]; + array[s] = array[i]; + array[i] = selected; + } + return array; +} + function trollCase(string) { return string.split('') - .map(c => c < 64 ? c : String.fromCharCode(c.charCodeAt(0) ^ (32 * (Math.floor(2*Math.random()))))) + .map(c => Math.random() < 0.5 ? c.toUpperCase() : c.toLowerCase()) .join(''); } @@ -24,9 +34,9 @@ function trollToggle(toggle, title, def) { obj['toggle'] = toggle; obj['title'] = trollCase(title); obj['values'] = {}; - for (var i = 3; i < arguments.length; i += 2) { - obj['values'][trollCase(arguments[i])] = arguments[i+1]; - } + var indices = []; + for (var i = 3; i < arguments.length; i += 2) indices.push(i); + ip_shuffle(indices).forEach(i => obj['values'][trollCase(arguments[i])] = arguments[i+1]); obj['default'] = def; if (def == undefined) { if (obj['values'].length > 2) { @@ -39,9 +49,24 @@ function trollToggle(toggle, title, def) { return ToggleModule.defineToggle(obj); } -export const options = [ - // TODO: detroll this a bit - trollToggle('konami', 'unused', undefined, +function konamiToggle() { + var t = trollToggle.apply(this, arguments); + var sequence = [2, 2, 1, 1, 0, 3, 0, 3, 4, 5]; + var idx = 0; + t.set = (value) => { + if (value === sequence[idx]) { + if (++idx >= sequence.length) { + ToggleModule.toggles['troll'] = true; + ToggleModule.refreshContent(); + } + } + else { idx = 0; } + } + return t; +} + +export const options = ip_shuffle ([ + konamiToggle('troll', "Do not touch this", false, '←', 0, '↓', 1, '↑', 2, '→', 3, 'B', 4, 'A', 5), trollToggle('pants', 'pants', 1 + Math.floor(3 * Math.random()), 'red', 1, 'green', 2, 'blue', 3, 'you perv', 4), @@ -49,11 +74,4 @@ export const options = [ 'on', true, 'off', false), trollToggle('debug', 'Detroll Mode', false, 'on', true, 'off', false) -]; - -for (var i = options.length-1; i > 1; i--) { - var s = Math.floor((i+1) * Math.random()); - var selected = options[s]; - options[s] = options[i]; - options[i] = selected; -} +]);