From 1b0f429c4d3a516afd832d476f6681d468dcf456 Mon Sep 17 00:00:00 2001 From: Kevin Ramharak Date: Sat, 30 Dec 2017 20:42:31 +0100 Subject: [PATCH 1/5] added `JO` and `JNO` to the correct regexes These were forgotten so the highlighter says they are errors --- mar/editor.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mar/editor.js b/mar/editor.js index 8fe5b21..f88dcd5 100644 --- a/mar/editor.js +++ b/mar/editor.js @@ -257,7 +257,7 @@ function parseInstruction(line, result, currentLine) { if (!parseDWInstruction(line, result, currentLine)) { if (new RegExp('\\b(?:mov|add|sub|and|or|test|cmp|shl|shr|mul|push|pop|div|xor|hwi|hwq|nop|neg|' + - 'call|ret|jmp|jnz|jg|jl|jge|jle|int|jz|js|jns|brk|not|jc|jnc|ror|rol|sal|sar)\\b').test(mnemonic.toLowerCase())) { + 'call|ret|jmp|jnz|jg|jl|jge|jle|int|jz|js|jns|brk|not|jc|jnc|ror|rol|sal|sar|jo|jno)\\b').test(mnemonic.toLowerCase())) { if (line.indexOf(",") !== -1) { @@ -315,7 +315,7 @@ function parseInstruction(line, result, currentLine) { strO1 = line.substring(line.indexOf(mnemonic) + mnemonic.length).trim(); //Validate operand number - if (!new RegExp('\\b(?:push|mul|pop|div|neg|call|jnz|jg|jl|jge|jle|hwi|hwq|jz|js|jns|ret|jmp|not|jc|jnc)\\b').test(mnemonic.toLowerCase())) { + if (!new RegExp('\\b(?:push|mul|pop|div|neg|call|jnz|jg|jl|jge|jle|hwi|hwq|jz|js|jns|ret|jmp|not|jc|jnc|jo|jno)\\b').test(mnemonic.toLowerCase())) { result.annotations.push({ row: currentLine, column: 0, @@ -404,4 +404,4 @@ function editorClick() { document.getElementById("gameBtns").setAttribute("style", "display: none"); } -editor.on("change", parse); \ No newline at end of file +editor.on("change", parse); From e3fc607cdced58aafce565f3d7aee2377793ae0a Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 30 Dec 2017 15:33:22 -0500 Subject: [PATCH 2/5] Cubot color support, Console output support. --- mar/phaser/mar.js | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/mar/phaser/mar.js b/mar/phaser/mar.js index 52b2d0e..11311b3 100644 --- a/mar/phaser/mar.js +++ b/mar/phaser/mar.js @@ -5,6 +5,7 @@ DIR_WEST = 3; WORLD_HEIGHT = WORLD_WIDTH = 16; + var colorScheme = { tileTint: 0xFFFFFF, wallTint: 0xDDDDDD, @@ -28,6 +29,7 @@ mar.kbBufferText = ""; mar.animationFrames = {}; mar.controlledUnitVisible = false; + CUBOT_WALK_FRAMES = { south: 240, north: 194, @@ -331,12 +333,6 @@ function updateGameObject(object, responseObj) { font: "fixedsys" }); - object.hologram.alpha = colorScheme.hologramAlpha; - object.hologram.anchor.set(0.5, 0); - object.addChild(object.hologram); - - game.add.tween(object.hologram).to({tint: 0xFFFFF0, alpha: colorScheme.hologramAlpha - 0.1}, - mar.client.tickLength, Phaser.Easing.Bounce.In, true); } else if (responseObj.holoMode === 2) { //String @@ -347,6 +343,22 @@ function updateGameObject(object, responseObj) { strokeThickness: 1, font: "fixedsys" }); + + } else if (responseObj.holoMode === 3) { + //Decimal + object.hologram = game.make.text(0, 32, Number(responseObj.holo).toString(), { + fontSize: 32, + fill: colorScheme.hologramFill, + stroke: colorScheme.hologramStroke, + strokeThickness: 1, + font: "fixedsys" + }); + } else if (responseObj.holoMode === 4) { + //Color + object.oldTint = object.tint = responseObj.holo; + } + + if (object.hologram !== undefined) { object.hologram.alpha = colorScheme.hologramAlpha; object.hologram.anchor.set(0.5, 0); object.addChild(object.hologram); @@ -481,7 +493,7 @@ function createGameObject(objData) { game.add.tween(this).to({isoZ: 45}, 200, Phaser.Easing.Quadratic.InOut, true); game.add.tween(this.scale).to({x: 1.2, y: 1.2}, 200, Phaser.Easing.Linear.None, true); - if (this.tint !== 0xFF0000) { + if (this.tint === 0xFFFFFF) { this.tint = colorScheme.cubotHoverTint; } @@ -492,8 +504,8 @@ function createGameObject(objData) { game.add.tween(this).to({isoZ: 15}, 400, Phaser.Easing.Bounce.Out, true); game.add.tween(this.scale).to({x: 1, y: 1}, 200, Phaser.Easing.Linear.None, true); - if (this.tint !== 0xFF0000) { - this.tint = colorScheme.cubotTint; + if (this.tint === 0xFFFFFF) { + this.tint = this.oldTint; } }; @@ -889,6 +901,18 @@ function tickListener(message) { mar.kbBuffer = message.keys; mar.kbBufferText = formattedKeyBuffer(mar.kbBuffer); } + + //Update console + if (message.c !== undefined) { + + for (var i = 0; i < message.c.length; i++) { + document.getElementById('console').innerHTML += message.c[i]; + } + } + if (message.cm === 0) { + //Clear command was sent + document.getElementById('console').innerHTML = ""; + } } } From 0374a07e35e2c643d6a7b767f4202e8419618cc7 Mon Sep 17 00:00:00 2001 From: Kevin Ramharak Date: Sun, 31 Dec 2017 11:43:33 +0100 Subject: [PATCH 3/5] Update README.md Added mysql instructions --- README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a55eb54..070a55b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,28 @@ # Much-Assembly-Required-Frontend Files for https://muchassemblyrequired.com/ frontend. -Requires a PHP environnment and a MySQL server (Database installation script: [database.sql](https://github.com/simon987/Much-Assembly-Required-Frontend/blob/master/database.sql)). +Requires a PHP environnment and a MySQL server (Database installation script: [database.sql](https://github.com/simon987/Much-Assembly-Required-Frontend/blob/master/database.sql)). + +Easiest way to configure the database: +```bash +$ pwd +~/Much-Assembly-Required-Frontend/ +$ mysql -u root -p +Enter password: # type your MySQL root user password + +MariaDB [(none)]> +MariaDB [(none)]> CREATE DATABASE mar; +MariaDB [(none)]> GRANT ALL PRIVILEGES ON mar.* to 'mar'@'localhost' identified by 'mar'; +MariaDB [(none)]> FLUSH PRIVILEGES; +MariaDB [(none)]> USE mar; +MariaDB [mar]> \. database.sql +MariaDB [(none)]> exit +Bye +$ # if '\. database.sql' failed you were not in the right directory. make sure you are in the repo root directory +$ # before running these commands +``` Make sure to change the configuration in /include/config.php. +> Tough if you used the snippet above there is nothing to change (except the title if you want) More information about the game [here.](https://github.com/simon987/Much-Assembly-Required) HTML template by ajlkn From b5da942878121faad613048ef0bd8ed45052114c Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 31 Dec 2017 09:58:29 -0500 Subject: [PATCH 4/5] Added console area --- game.php | 23 ++++++++++ mar/editor.min.js | 4 +- mar/phaser/mar.js | 100 ++++++++++++++++++++++++++---------------- mar/phaser/mar.min.js | 53 +++++++++++----------- 4 files changed, 114 insertions(+), 66 deletions(-) diff --git a/game.php b/game.php index a079138..99b2c92 100644 --- a/game.php +++ b/game.php @@ -95,6 +95,21 @@ if (isset($user)) { display: inline; } + #console { + font-family: fixedsys, monospace; + font-size: 24pt; + line-height: 21px; + resize: none; + overflow-y: scroll; + width: 680px; + height: 180px; + } + + #consoleContainer { + margin: 20px; + text-align: center; + } + @@ -169,6 +184,14 @@ if (isset($user)) { + +
+ + + Clear +
+
diff --git a/mar/editor.min.js b/mar/editor.min.js index 2c3ddcf..0898478 100644 --- a/mar/editor.min.js +++ b/mar/editor.min.js @@ -10,8 +10,8 @@ function parseDWInstruction(a,c,b){a=a.trim();if("dw"===a.substr(0,2).toLowerCas column:0,text:"Usage: DW IMM, IMM ...",type:"error"});break}}return!0}return!1} function getOperandType(a,c){a=a.trim();if(""===a)return OPERAND_INVALID;if(!isNaN(Number(a))&&Number(a)===Math.floor(Number(a))&&-1===a.indexOf("o")&&-1===a.indexOf("e"))return OPERAND_IMM;if(/^(a|b|c|d|x|y|bp|sp)$/.test(a.toLowerCase()))return OPERAND_REG;for(b=0;b= 40) { + + //Split the line... + var subLines = lines[i].match(/.{1,40}/g); + + for (var j = 0; j < subLines.length; j++) { + + //Don't put a newline at the end + if (j !== subLines.length - 1) { + tmpBuffer += "\n"; + } + } + + } else { + tmpBuffer += lines[i] + "\n"; + } + } + + myConsole.innerHTML = tmpBuffer; + mar.lastLines = str; + + //Autoscroll + myConsole.scrollTop = myConsole.scrollHeight; } } } diff --git a/mar/phaser/mar.min.js b/mar/phaser/mar.min.js index 01c08f3..9edf3f8 100644 --- a/mar/phaser/mar.min.js +++ b/mar/phaser/mar.min.js @@ -1,36 +1,37 @@ -DIR_NORTH=0;DIR_EAST=1;DIR_SOUTH=2;DIR_WEST=3;WORLD_HEIGHT=WORLD_WIDTH=16;var colorScheme={tileTint:16777215,wallTint:14540253,cubotHoverTint:65280,cubotTint:16777215,textFill:"#FFFFFF",textStroke:"#9298a8",biomassTint:6535263,biomassHoverTint:65280,tileHoverTint:65280,itemIron:4408129,itemCopper:13139256,hologramFill:"#0aced6",hologramStroke:"#12FFB0",hologramAlpha:.9},mar={kbBuffer:[],kbBufferText:"",animationFrames:{},controlledUnitVisible:!1};CUBOT_WALK_FRAMES={south:240,north:194,west:254,east:164}; -HARVESTER_WALK_FRAMES={south:347,north:317,west:377,east:287};LOW_ENERGY=100;fullscreen?(RENDERER_WIDTH=window.innerWidth-4,RENDERER_HEIGHT=window.innerHeight-4):(RENDERER_WIDTH=document.getElementById("game").clientWidth,RENDERER_HEIGHT=window.innerHeight/1.25);var game=new Phaser.Game(RENDERER_WIDTH,RENDERER_HEIGHT,Phaser.AUTO,"game",null,!0,!1); +DIR_NORTH=0;DIR_EAST=1;DIR_SOUTH=2;DIR_WEST=3;WORLD_HEIGHT=WORLD_WIDTH=16;var colorScheme={tileTint:16777215,wallTint:14540253,cubotHoverTint:65280,cubotTint:16777215,textFill:"#FFFFFF",textStroke:"#9298a8",biomassTint:6535263,biomassHoverTint:65280,tileHoverTint:65280,itemIron:4408129,itemCopper:13139256,hologramFill:"#0aced6",hologramStroke:"#12FFB0",hologramAlpha:.9},mar={kbBuffer:[],kbBufferText:"",animationFrames:{},controlledUnitVisible:!1,lastLines:""}; +CUBOT_WALK_FRAMES={south:240,north:194,west:254,east:164};HARVESTER_WALK_FRAMES={south:347,north:317,west:377,east:287};LOW_ENERGY=100;fullscreen?(RENDERER_WIDTH=window.innerWidth-4,RENDERER_HEIGHT=window.innerHeight-4):(RENDERER_WIDTH=document.getElementById("game").clientWidth,RENDERER_HEIGHT=window.innerHeight/1.25);var game=new Phaser.Game(RENDERER_WIDTH,RENDERER_HEIGHT,Phaser.AUTO,"game",null,!0,!1); function dispatchTileLeave(a,b){for(var c=0;c=a.keyCode||116===a.keyCode||32===a.keyCode)&&a.preventDefault(),"guest"!==mar.client.username&&16>=mar.kbBuffer.length&&(mar.client.sendKeypress(a.keyCode), mar.kbBuffer.push(a.keyCode),mar.kbBufferText=formattedKeyBuffer(mar.kbBuffer)))},game.input.onDown.add(function(){document.getElementById("game").focus()})))}function objectListener(a){"object"===a.t&&mar.world.updateObjects(a.objects)}function floppyListener(a){document.getElementById("floppyDown").innerHTML=' ';a=new Blob([a.data],{type:"application/octet-stream"});saveAs(a,"floppy.bin")} -function tickListener(a){"tick"===a.t&&(mar.client.socket.send(JSON.stringify({t:"object",x:mar.worldX,y:mar.worldY})),void 0!==a.keys&&(mar.kbBuffer=a.keys,mar.kbBufferText=formattedKeyBuffer(mar.kbBuffer)))} +function tickListener(a){if("tick"===a.t){mar.client.socket.send(JSON.stringify({t:"object",x:mar.worldX,y:mar.worldY}));void 0!==a.keys&&(mar.kbBuffer=a.keys,mar.kbBufferText=formattedKeyBuffer(mar.kbBuffer));var b=document.getElementById("console");0===a.cm&&(b.innerHTML="",mar.lastLines="");if(void 0!==a.c){for(var c=mar.lastLines,d=0;d Date: Sun, 31 Dec 2017 12:20:46 -0500 Subject: [PATCH 5/5] Increased maximum password length --- register.re.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/register.re.php b/register.re.php index 75695b5..110f696 100644 --- a/register.re.php +++ b/register.re.php @@ -17,9 +17,9 @@ if (strlen($username) < 5 || strlen($username) > 20) { $msg->setCookie(); header("Location: login.php#register"); -} else if (strlen($password) < 8 || strlen($password) > 32) { +} else if (strlen($password) < 8 || strlen($password) > 96) { - (new MessageCookie("Password must be 8-32 characters", "register"))->setCookie(); + (new MessageCookie("Password must be 8-96 characters", "register"))->setCookie(); header("Location: login.php#register"); } else {