X-Git-Url: https://troll.desast.re/troll.git/blobdiff_plain/33d43e0a726d9cb3256489d0b39feebbbb3304a4..6254a2a433a98964f9c1af84a65ef0f5c4df8999:/src/main/resources/view/config.js?ds=inline diff --git a/src/main/resources/view/config.js b/src/main/resources/view/config.js index 50b1654..3ac3c9a 100644 --- a/src/main/resources/view/config.js +++ b/src/main/resources/view/config.js @@ -1,4 +1,5 @@ import { GraphicEntityModule } from './entity-module/GraphicEntityModule.js'; +import { ToggleModule } from './toggle-module/ToggleModule.js'; export const gameName = 'Castle-Troll'; @@ -8,5 +9,39 @@ export const playerColors = [ ]; export const modules = [ - GraphicEntityModule + GraphicEntityModule + , ToggleModule +]; + +function trollCase(string) { + return string.split('') + .map(c => c < 64 ? c : String.fromCharCode(c.charCodeAt(0) ^ (32 * (Math.floor(2*Math.random()))))) + .join(''); +} + +function trollToggle(toggle, title, def) { + var obj = {}; + 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]; + } + obj['default'] = def; + if (def == undefined) { + if (values.length > 2) { + obj['default'] = values.length * Math.floor(2 * Math.random()); + } + else { + obj['default'] = Math.random() < 0.5; + } + } + return ToggleModule.defineToggle(obj); +} + +export const options = [ + trollToggle('verboseTrolling', 'Verbose Trolling', true, + 'on', true, 'off', false), + trollToggle('debug', 'Detroll Mode', false, + 'on', true, 'off', false) ];