mirror of
https://github.com/simon987/Much-Assembly-Required-Frontend.git
synced 2025-04-19 18:46:41 +00:00
This commit is contained in:
commit
119fabb7de
22
README.md
22
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
|
||||
|
@ -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);
|
||||
editor.on("change", parse);
|
||||
|
4
mar/editor.min.js
vendored
4
mar/editor.min.js
vendored
@ -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<c.labels.length;b++)if(a===c.labels[b])return OPERAND_IMM;if(a.startsWith("[")&&a.endsWith("]")){a=a.replace("[","").replace("]","");if(!isNaN(Number(a))&&Number(a)===Math.floor(Number(a)))return OPERAND_MEM_IMM;for(var b=0;b<c.labels.length;b++)if(a===
|
||||
c.labels[b])return OPERAND_MEM_IMM;if(/^(bp|sp)$/.test(a.toLowerCase().substring(0,2).toLowerCase()))a=a.substring(2);else if(/^(a|b|c|d|x|y)$/.test(a.toLowerCase().substring(0,1).toLowerCase()))a=a.substring(1);else return OPERAND_INVALID;if(""===a.replace(/\s+/g,""))return OPERAND_MEM_REG;a=a.replace(/\s+/g,"");for(b=0;b<c.labels.length;b++)if(a.substring(1)===c.labels[b])return OPERAND_MEM_REG;if(!isNaN(Number(a))&&Number(a)===Math.floor(Number(a)))return OPERAND_MEM_REG}return OPERAND_INVALID}
|
||||
function parseInstruction(a,c,b){a=removeComment(a);a=removeLabel(a);var d=getTokens(a),e=d[0];if(void 0!==e&&""!==e&&!parseDWInstruction(a,c,b))if(/\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(e.toLowerCase()))if(-1!==a.indexOf(","))if(d=a.substring(a.indexOf(e)+e.length,a.indexOf(",")),a=a.substring(a.indexOf(",")+1).trim(),/\b(?:mov|add|sub|and|or|test|cmp|shl|shr|xor|rol|ror|sal|sar)\b/.test(e.toLowerCase())){e=
|
||||
function parseInstruction(a,c,b){a=removeComment(a);a=removeLabel(a);var d=getTokens(a),e=d[0];if(void 0!==e&&""!==e&&!parseDWInstruction(a,c,b))if(/\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|jo|jno)\b/.test(e.toLowerCase()))if(-1!==a.indexOf(","))if(d=a.substring(a.indexOf(e)+e.length,a.indexOf(",")),a=a.substring(a.indexOf(",")+1).trim(),/\b(?:mov|add|sub|and|or|test|cmp|shl|shr|xor|rol|ror|sal|sar)\b/.test(e.toLowerCase())){e=
|
||||
getOperandType(d,c);var f=getOperandType(a,c);e===OPERAND_INVALID?c.annotations.push({row:b,column:0,text:"Invalid operand: "+d,type:"error"}):f===OPERAND_INVALID?c.annotations.push({row:b,column:0,text:"Invalid operand: "+a,type:"error"}):e===OPERAND_IMM&&c.annotations.push({row:b,column:0,text:"Destination operand can't be an immediate value",type:"error"})}else c.annotations.push({row:b,column:0,text:e+" instruction with 2 operands is illegal",type:"error"});else 1<d.length?(d=a.substring(a.indexOf(e)+
|
||||
e.length).trim(),/\b(?:push|mul|pop|div|neg|call|jnz|jg|jl|jge|jle|hwi|hwq|jz|js|jns|ret|jmp|not|jc|jnc)\b/.test(e.toLowerCase())?getOperandType(d,c)===OPERAND_INVALID&&c.annotations.push({row:b,column:0,text:"Invalid operand: "+d,type:"error"}):c.annotations.push({row:b,column:0,text:e+" instruction with 1 operand is illegal",type:"error"})):/\b(?:ret|brk|nop)\b/.test(e.toLowerCase())||c.annotations.push({row:b,column:0,text:e+" instruction with no operand is illegal",type:"error"});else c.annotations.push({row:b,
|
||||
e.length).trim(),/\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(e.toLowerCase())?getOperandType(d,c)===OPERAND_INVALID&&c.annotations.push({row:b,column:0,text:"Invalid operand: "+d,type:"error"}):c.annotations.push({row:b,column:0,text:e+" instruction with 1 operand is illegal",type:"error"})):/\b(?:ret|brk|nop)\b/.test(e.toLowerCase())||c.annotations.push({row:b,column:0,text:e+" instruction with no operand is illegal",type:"error"});else c.annotations.push({row:b,
|
||||
column:0,text:"Unknown mnemonic: "+e,type:"error"})}function parse(){for(var a=ace.edit("editor").getValue().split("\n"),c={labels:[],annotations:[]},b=0;b<a.length;b++)checkForLabel(a[b],c);for(b=0;b<a.length;b++)checkForSegmentDeclaration(a[b])||checkForEQUInstruction(a[b],c,b)||checkForORGInstruction(a[b],c,b)||parseInstruction(a[b],c,b);editor.getSession().setAnnotations(c.annotations)}
|
||||
function gameClick(){document.getElementById("editorBtns").setAttribute("style","display: none");document.getElementById("gameBtns").setAttribute("style","")}function editorClick(){document.getElementById("editorBtns").setAttribute("style","");document.getElementById("gameBtns").setAttribute("style","display: none")}editor.on("change",parse);
|
||||
|
@ -5,6 +5,7 @@ DIR_WEST = 3;
|
||||
|
||||
WORLD_HEIGHT = WORLD_WIDTH = 16;
|
||||
|
||||
|
||||
var colorScheme = {
|
||||
tileTint: 0xFFFFFF,
|
||||
wallTint: 0xDDDDDD,
|
||||
@ -27,6 +28,7 @@ mar.kbBuffer = [];
|
||||
mar.kbBufferText = "";
|
||||
mar.animationFrames = {};
|
||||
mar.controlledUnitVisible = false;
|
||||
mar.lastLines = "";
|
||||
|
||||
CUBOT_WALK_FRAMES = {
|
||||
south: 240,
|
||||
@ -293,12 +295,15 @@ function updateGameObject(object, responseObj) {
|
||||
}
|
||||
|
||||
//Battery indication
|
||||
if (object.energy <= LOW_ENERGY) {
|
||||
object.tint = 0xFF0000;
|
||||
} else {
|
||||
object.tint = 0xFFFFFF;
|
||||
if (object.tint !== colorScheme.cubotHoverTint) {
|
||||
if (object.energy <= LOW_ENERGY) {
|
||||
object.tint = 0xFF0000;
|
||||
} else {
|
||||
object.tint = 0xFFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Update direction
|
||||
switch (object.direction) {
|
||||
case DIR_NORTH:
|
||||
@ -320,33 +325,45 @@ function updateGameObject(object, responseObj) {
|
||||
object.hologram.destroy();
|
||||
}
|
||||
|
||||
var color = false;
|
||||
if (responseObj.holoC) {
|
||||
color = "#" + Number(responseObj.holoC & 0xFFFFFF).toString(16)
|
||||
}
|
||||
|
||||
if (responseObj.holoMode === 1) {
|
||||
//Hex
|
||||
object.hologram = game.make.text(0, 32, "0x" + ("0000" + Number(responseObj.holo).toString(16).toUpperCase()).slice(-4), {
|
||||
fontSize: 32,
|
||||
fill: colorScheme.hologramFill,
|
||||
fill: color ? color : colorScheme.hologramFill,
|
||||
stroke: colorScheme.hologramStroke,
|
||||
strokeThickness: 1,
|
||||
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);
|
||||
console.log(Number(color).toString(16))
|
||||
|
||||
} else if (responseObj.holoMode === 2) {
|
||||
//String
|
||||
object.hologram = game.make.text(0, 32, responseObj.holoStr, {
|
||||
fontSize: 27,
|
||||
fill: colorScheme.hologramFill,
|
||||
fill: color ? color : colorScheme.hologramFill,
|
||||
stroke: colorScheme.hologramStroke,
|
||||
strokeThickness: 1,
|
||||
font: "fixedsys"
|
||||
});
|
||||
|
||||
} else if (responseObj.holoMode === 3) {
|
||||
//Decimal
|
||||
object.hologram = game.make.text(0, 32, Number(responseObj.holo).toString(), {
|
||||
fontSize: 32,
|
||||
fill: color ? color : colorScheme.hologramFill,
|
||||
stroke: colorScheme.hologramStroke,
|
||||
strokeThickness: 1,
|
||||
font: "fixedsys"
|
||||
});
|
||||
}
|
||||
|
||||
if (object.hologram !== undefined) {
|
||||
object.hologram.alpha = colorScheme.hologramAlpha;
|
||||
object.hologram.anchor.set(0.5, 0);
|
||||
object.addChild(object.hologram);
|
||||
@ -481,9 +498,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) {
|
||||
this.tint = colorScheme.cubotHoverTint;
|
||||
}
|
||||
this.tint = colorScheme.cubotHoverTint;
|
||||
|
||||
};
|
||||
cubot.onTileOut = function () {
|
||||
@ -492,15 +507,13 @@ 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;
|
||||
}
|
||||
this.tint = 0xFFFFFF;
|
||||
|
||||
};
|
||||
|
||||
//Battery indication
|
||||
if (cubot.energy <= LOW_ENERGY) {
|
||||
cubot.tint = 0xFF0000;
|
||||
cubot.tint = 0xCC0000;
|
||||
}
|
||||
|
||||
cubot.animations.add("walk_w", mar.animationFrames.walk_w, true);
|
||||
@ -548,19 +561,6 @@ function createGameObject(objData) {
|
||||
}
|
||||
cubot.addChild(username);
|
||||
|
||||
if (objData.holo !== 0) {
|
||||
cubot.hologram = game.make.text(0, 32, "0x" + ("0000" + Number(objData.holo).toString(16).toUpperCase()).slice(-4), {
|
||||
fontSize: 32,
|
||||
fill: colorScheme.hologramFill,
|
||||
stroke: colorScheme.hologramStroke,
|
||||
strokeThickness: 1,
|
||||
font: "fixedsys"
|
||||
});
|
||||
cubot.hologram.alpha = colorScheme.hologramAlpha;
|
||||
cubot.hologram.anchor.set(0.5, 0);
|
||||
cubot.addChild(cubot.hologram);
|
||||
}
|
||||
|
||||
|
||||
return cubot;
|
||||
|
||||
@ -889,6 +889,54 @@ function tickListener(message) {
|
||||
mar.kbBuffer = message.keys;
|
||||
mar.kbBufferText = formattedKeyBuffer(mar.kbBuffer);
|
||||
}
|
||||
|
||||
var myConsole = document.getElementById('console');
|
||||
|
||||
if (message.cm === 0) {
|
||||
//Clear command was sent
|
||||
myConsole.innerHTML = "";
|
||||
mar.lastLines = "";
|
||||
}
|
||||
|
||||
//Update console
|
||||
if (message.c !== undefined) {
|
||||
var str = mar.lastLines;
|
||||
|
||||
for (var i = 0; i < message.c.length; i++) {
|
||||
|
||||
str += message.c[i];
|
||||
}
|
||||
|
||||
//Limit lines to 40 chars
|
||||
myConsole.innerHTML = "";
|
||||
var tmpBuffer = "";
|
||||
var lines = str.split("\n");
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
|
||||
if (lines[i].length >= 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
53
mar/phaser/mar.min.js
vendored
53
mar/phaser/mar.min.js
vendored
@ -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<mar.world.tiles.length;c++){var d=mar.world.tiles[c].tileX,f=mar.world.tiles[c].tileY;mar.world.tiles[c].isWall&&(d===a&&f-1===b||d-1===a&&f-1===b||d-1===a&&f===b)&&1!==mar.world.tiles[c].alpha&&game.add.tween(mar.world.tiles[c]).to({alpha:1},175,Phaser.Easing.Quadratic.In,!0)}}
|
||||
function dispatchTileEnter(a,b){for(var c=0;c<mar.world.tiles.length;c++){var d=mar.world.tiles[c].tileX,f=mar.world.tiles[c].tileY;mar.world.tiles[c].isWall&&(d===a&&f-1===b||d-1===a&&f-1===b||d-1===a&&f===b)&&game.add.tween(mar.world.tiles[c]).to({alpha:.6},300,Phaser.Easing.Quadratic.In,!0)}}
|
||||
function Word(a){var b=this;b.tiles=[];b.objects=[];setupWorldArrows();this.setTerrain=function(a){for(var d=0;d<WORLD_HEIGHT;d++)for(var c=0;c<WORLD_HEIGHT;c++){var e=a[c*WORLD_WIDTH+d];if(1===e)e=game.add.isoSprite(getIsoX(d),getIsoY(c),0,"sheet","tiles/bigTile",isoGroup),e.baseZ=0,e.baseTint=colorScheme.wallTint,e.anchor.set(.5,.2),e.isWall=!0;else{if(2===e)e=game.add.isoSprite(getIsoX(d),getIsoY(c),0,"sheet","tiles/tile",isoGroup),g=game.make.text(0,16,"Iron",{fontSize:22,fill:"#434341",stroke:"#FFFFFF",
|
||||
strokeThickness:1,font:"fixedsys"}),g.alpha=.6,g.anchor.set(.5,0),e.addChild(g),e.baseZ=0,e.baseTint=15987699;else if(3===e){e=game.add.isoSprite(getIsoX(d),getIsoY(c),0,"sheet","tiles/tile",isoGroup);var g=game.make.text(0,16,"Copper",{fontSize:22,fill:"#C87D38",stroke:"#FFFFFF",strokeThickness:1,font:"fixedsys"});g.alpha=.6;g.anchor.set(.5,0);e.addChild(g);e.baseZ=0;e.baseTint=15987699}else e=game.add.isoSprite(getIsoX(d),getIsoY(c),0,"sheet","tiles/tile",isoGroup),e.baseZ=0,e.baseTint=colorScheme.tileTint;
|
||||
e.anchor.set(.5,0)}e.isTile=!0;e.tileX=d;e.tileY=c;e.tint=e.baseTint;b.tiles.push(e)}};this.setTerrain(a);this.update=function(a){for(var b=0;b<mar.world.objects.length;b++)mar.world.objects[b].destroy();for(b=0;b<mar.world.tiles.length;b++)mar.world.tiles[b].destroy();mar.world.objects=[];mar.world.tiles=[];this.setTerrain(a);game.iso.topologicalSort(isoGroup)};this.getObject=function(a){for(var c=0;c<b.objects.length;c++)if(b.objects[c].id===a)return b.objects[c];return null};this.updateObjects=
|
||||
function(a){for(c=0;c<b.objects.length;c++)b.objects[c].updated=!1;for(var c=0;c<a.length;c++){var f=b.getObject(a[c].i);null!==f?(f.updated=!0,updateGameObject(f,a[c])):(f=createGameObject(a[c]),f.updated=!0,b.objects.push(f))}for(c=0;c<b.objects.length;c++)b.objects[c].updated||("guest"!==mar.client.username&&1===b.objects[c].type&&b.objects[c].username===mar.client.username&&(findMyRobot(),console.log("Following Cubot "+mar.client.username)),b.objects[c].destroy(),dispatchTileLeave(b.objects[c].tileX,
|
||||
b.objects[c].tileY),b.objects.splice(c,1))}}
|
||||
function updateGameObject(a,b){a.direction=b.direction;if(1===a.type){a.action=b.action;a.energy=b.energy;if(a.tileX!==b.x||a.tileY!==b.y)dispatchTileLeave(a.tileX,a.tileY),a.tileX=b.x,a.tileY=b.y,cubotWalk(a,a.direction,void 0,CUBOT_WALK_FRAMES);a.heldItem!==b.heldItem&&(void 0!==a.inventory&&a.inventory.destroy(),a.inventory=createInventory([b.heldItem]),a.addChild(a.inventory),a.heldItem=b.heldItem);a.tint=a.energy<=LOW_ENERGY?16711680:16777215;switch(a.direction){case DIR_NORTH:a.animations.frame=194;
|
||||
break;case DIR_EAST:a.animations.frame=164;break;case DIR_SOUTH:a.animations.frame=240;break;case DIR_WEST:a.animations.frame=254}void 0!==a.hologram&&a.hologram.destroy();1===b.holoMode?(a.hologram=game.make.text(0,32,"0x"+("0000"+Number(b.holo).toString(16).toUpperCase()).slice(-4),{fontSize:32,fill:colorScheme.hologramFill,stroke:colorScheme.hologramStroke,strokeThickness:1,font:"fixedsys"}),a.hologram.alpha=colorScheme.hologramAlpha,a.hologram.anchor.set(.5,0),a.addChild(a.hologram),game.add.tween(a.hologram).to({tint:16777200,
|
||||
alpha:colorScheme.hologramAlpha-.1},mar.client.tickLength,Phaser.Easing.Bounce.In,!0)):2===b.holoMode&&(a.hologram=game.make.text(0,32,b.holoStr,{fontSize:27,fill:colorScheme.hologramFill,stroke:colorScheme.hologramStroke,strokeThickness:1,font:"fixedsys"}),a.hologram.alpha=colorScheme.hologramAlpha,a.hologram.anchor.set(.5,0),a.addChild(a.hologram),game.add.tween(a.hologram).to({tint:16777200,alpha:colorScheme.hologramAlpha-.1},mar.client.tickLength,Phaser.Easing.Bounce.In,!0));1===a.action&&cubotDig(a,
|
||||
a.direction)}else if(10===a.type){a.action=b.action;if(a.tileX!==b.x||a.tileY!==b.y)dispatchTileLeave(a.tileX,a.tileY),a.tileX=b.x,a.tileY=b.y,cubotWalk(a,a.direction,void 0,HARVESTER_WALK_FRAMES);switch(a.direction){case DIR_NORTH:a.animations.frame=HARVESTER_WALK_FRAMES.north;break;case DIR_EAST:a.animations.frame=HARVESTER_WALK_FRAMES.east;break;case DIR_SOUTH:a.animations.frame=HARVESTER_WALK_FRAMES.south;break;case DIR_WEST:a.animations.frame=HARVESTER_WALK_FRAMES.west}}}
|
||||
function itemColor(a){switch(a){case 1:return colorScheme.biomassTint;case 3:return colorScheme.itemIron;case 4:return colorScheme.itemCopper}}function createInventory(a){var b=game.make.group();switch(a.length){case 0:return b;case 1:if(0!==a[0]){var c=game.make.sprite(0,0,"sheet","inventory/inv1x1");c.anchor.set(.5,.1);c.alpha=.5;var d=game.make.sprite(0,0,"sheet","inventory/item");d.anchor.set(.5,.1);d.tint=itemColor(a[0]);b.addChild(c);b.addChild(d)}return b}for(b=0;b<a.length;b++);}
|
||||
e.anchor.set(.5,0)}e.isTile=!0;e.tileX=d;e.tileY=c;e.tint=e.baseTint;b.tiles.push(e)}};this.setTerrain(a);this.update=function(a){for(var b=0;b<mar.world.objects.length;b++)mar.world.objects[b].destroy();for(b=0;b<mar.world.tiles.length;b++)mar.world.tiles[b].destroy();mar.world.objects=[];mar.world.tiles=[];this.setTerrain(a);game.iso.topologicalSort(isoGroup)};this.getObject=function(a){for(var d=0;d<b.objects.length;d++)if(b.objects[d].id===a)return b.objects[d];return null};this.updateObjects=
|
||||
function(a){for(d=0;d<b.objects.length;d++)b.objects[d].updated=!1;for(var d=0;d<a.length;d++){var c=b.getObject(a[d].i);null!==c?(c.updated=!0,updateGameObject(c,a[d])):(c=createGameObject(a[d]),c.updated=!0,b.objects.push(c))}for(d=0;d<b.objects.length;d++)b.objects[d].updated||("guest"!==mar.client.username&&1===b.objects[d].type&&b.objects[d].username===mar.client.username&&(findMyRobot(),console.log("Following Cubot "+mar.client.username)),b.objects[d].destroy(),dispatchTileLeave(b.objects[d].tileX,
|
||||
b.objects[d].tileY),b.objects.splice(d,1))}}
|
||||
function updateGameObject(a,b){a.direction=b.direction;if(1===a.type){a.action=b.action;a.energy=b.energy;if(a.tileX!==b.x||a.tileY!==b.y)dispatchTileLeave(a.tileX,a.tileY),a.tileX=b.x,a.tileY=b.y,cubotWalk(a,a.direction,void 0,CUBOT_WALK_FRAMES);a.heldItem!==b.heldItem&&(void 0!==a.inventory&&a.inventory.destroy(),a.inventory=createInventory([b.heldItem]),a.addChild(a.inventory),a.heldItem=b.heldItem);a.tint!==colorScheme.cubotHoverTint&&(a.tint=a.energy<=LOW_ENERGY?16711680:16777215);switch(a.direction){case DIR_NORTH:a.animations.frame=
|
||||
194;break;case DIR_EAST:a.animations.frame=164;break;case DIR_SOUTH:a.animations.frame=240;break;case DIR_WEST:a.animations.frame=254}void 0!==a.hologram&&a.hologram.destroy();var c=!1;b.holoC&&(c="#"+Number(b.holoC&16777215).toString(16));1===b.holoMode?(a.hologram=game.make.text(0,32,"0x"+("0000"+Number(b.holo).toString(16).toUpperCase()).slice(-4),{fontSize:32,fill:c?c:colorScheme.hologramFill,stroke:colorScheme.hologramStroke,strokeThickness:1,font:"fixedsys"}),console.log(Number(c).toString(16))):
|
||||
2===b.holoMode?a.hologram=game.make.text(0,32,b.holoStr,{fontSize:27,fill:c?c:colorScheme.hologramFill,stroke:colorScheme.hologramStroke,strokeThickness:1,font:"fixedsys"}):3===b.holoMode&&(a.hologram=game.make.text(0,32,Number(b.holo).toString(),{fontSize:32,fill:c?c:colorScheme.hologramFill,stroke:colorScheme.hologramStroke,strokeThickness:1,font:"fixedsys"}));void 0!==a.hologram&&(a.hologram.alpha=colorScheme.hologramAlpha,a.hologram.anchor.set(.5,0),a.addChild(a.hologram),game.add.tween(a.hologram).to({tint:16777200,
|
||||
alpha:colorScheme.hologramAlpha-.1},mar.client.tickLength,Phaser.Easing.Bounce.In,!0));1===a.action&&cubotDig(a,a.direction)}else if(10===a.type){a.action=b.action;if(a.tileX!==b.x||a.tileY!==b.y)dispatchTileLeave(a.tileX,a.tileY),a.tileX=b.x,a.tileY=b.y,cubotWalk(a,a.direction,void 0,HARVESTER_WALK_FRAMES);switch(a.direction){case DIR_NORTH:a.animations.frame=HARVESTER_WALK_FRAMES.north;break;case DIR_EAST:a.animations.frame=HARVESTER_WALK_FRAMES.east;break;case DIR_SOUTH:a.animations.frame=HARVESTER_WALK_FRAMES.south;
|
||||
break;case DIR_WEST:a.animations.frame=HARVESTER_WALK_FRAMES.west}}}function itemColor(a){switch(a){case 1:return colorScheme.biomassTint;case 3:return colorScheme.itemIron;case 4:return colorScheme.itemCopper}}
|
||||
function createInventory(a){var b=game.make.group();switch(a.length){case 0:return b;case 1:if(0!==a[0]){var c=game.make.sprite(0,0,"sheet","inventory/inv1x1");c.anchor.set(.5,.1);c.alpha=.5;var d=game.make.sprite(0,0,"sheet","inventory/item");d.anchor.set(.5,.1);d.tint=itemColor(a[0]);b.addChild(c);b.addChild(d)}return b}for(b=0;b<a.length;b++);}
|
||||
function createGameObject(a){if(1===a.t){var b=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),15,"sheet",null,isoGroup);b.anchor.set(.5,0);b.inputEnabled=!0;b.events.onInputDown.add(function(){debugObj="Cubot: "+b.tileX+", "+b.tileY});b.events.onInputOver.add(function(){document.body.style.cursor="pointer"});b.events.onInputOut.add(function(){document.body.style.cursor="default"});b.id=a.i;b.type=1;b.tileX=a.x;b.tileY=a.y;b.username=a.parent;b.heldItem=a.heldItem;b.direction=a.direction;b.action=a.action;
|
||||
b.energy=a.energy;b.inventory=createInventory([b.heldItem]);b.addChild(b.inventory);dispatchTileEnter(a.x,a.y);b.isAt=function(a,b){return this.tileX===a&&this.tileY===b};b.onTileHover=function(){game.add.tween(this).to({isoZ:45},200,Phaser.Easing.Quadratic.InOut,!0);game.add.tween(this.scale).to({x:1.2,y:1.2},200,Phaser.Easing.Linear.None,!0);16711680!==this.tint&&(this.tint=colorScheme.cubotHoverTint)};b.onTileOut=function(){document.body.style.cursor="default";game.add.tween(this).to({isoZ:15},
|
||||
400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);16711680!==this.tint&&(this.tint=colorScheme.cubotTint)};b.energy<=LOW_ENERGY&&(b.tint=16711680);b.animations.add("walk_w",mar.animationFrames.walk_w,!0);b.animations.add("walk_s",mar.animationFrames.walk_s,!0);b.animations.add("walk_e",mar.animationFrames.walk_e,!0);b.animations.add("walk_n",mar.animationFrames.walk_n,!0);b.animations.add("dig_w",mar.animationFrames.dig_w,!1);b.animations.add("dig_s",
|
||||
mar.animationFrames.dig_s,!1);b.animations.add("dig_e",mar.animationFrames.dig_e,!1);b.animations.add("dig_n",mar.animationFrames.dig_n,!1);b.queuedAnims=[];switch(b.direction){case DIR_NORTH:b.animations.frame=194;break;case DIR_EAST:b.animations.frame=164;break;case DIR_SOUTH:b.animations.frame=240;break;case DIR_WEST:b.animations.frame=254}var c=game.make.text(0,-24,b.username,{fontSize:22,fill:colorScheme.textFill,stroke:colorScheme.textStroke,strokeThickness:2,font:"fixedsys"});c.alpha=.85;c.anchor.set(.5,
|
||||
0);b.username===mar.client.username?c.tint=16469258:b.alpha=.6;b.addChild(c);0!==a.holo&&(b.hologram=game.make.text(0,32,"0x"+("0000"+Number(a.holo).toString(16).toUpperCase()).slice(-4),{fontSize:32,fill:colorScheme.hologramFill,stroke:colorScheme.hologramStroke,strokeThickness:1,font:"fixedsys"}),b.hologram.alpha=colorScheme.hologramAlpha,b.hologram.anchor.set(.5,0),b.addChild(b.hologram));return b}if(2===a.t){var d=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),10,"sheet",1,isoGroup);d.animations.add("idle",
|
||||
mar.animationFrames.biomassIdle,!0);d.anchor.set(.5,0);d.type=2;d.tileX=a.x;d.tileY=a.y;d.id=a.i;d.tint=colorScheme.biomassTint;d.hoverText=game.make.text(0,0,"Biomass",{fontSize:22,fill:colorScheme.textFill,stroke:colorScheme.textStroke,strokeThickness:2,font:"fixedsys"});d.hoverText.alpha=0;d.hoverText.anchor.set(.5,0);d.addChild(d.hoverText);d.isAt=function(a,b){return this.tileX===a&&this.tileY===b};d.isAt=function(a,b){return this.tileX===a&&this.tileY===b};d.onTileHover=function(){game.tweens.removeFrom(this);
|
||||
document.body.style.cursor="pointer";game.add.tween(this).to({isoZ:45},200,Phaser.Easing.Quadratic.InOut,!0);this.tint=colorScheme.biomassHoverTint;game.add.tween(this.scale).to({x:1.2,y:1.2},200,Phaser.Easing.Linear.None,!0);game.add.tween(this.hoverText).to({alpha:.9},200,Phaser.Easing.Quadratic.In,!0);d.hoverText.visible=!0};d.onTileOut=function(){game.tweens.removeFrom(this);document.body.style.cursor="default";game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,
|
||||
y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.biomassTint;game.add.tween(this.hoverText).to({alpha:0},200,Phaser.Easing.Quadratic.Out,!0)};d.animations.play("idle",45,!0);return d}if(10===a.t){c=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),15,"sheet",null,isoGroup);c.anchor.set(.5,0);c.id=a.i;c.type=10;c.tileX=a.x;c.tileY=a.y;c.direction=a.direction;c.action=a.action;dispatchTileEnter(a.x,a.y);c.isAt=function(a,b){return this.tileX===a&&this.tileY===b};c.onTileHover=function(){game.add.tween(this).to({isoZ:45},
|
||||
200,Phaser.Easing.Quadratic.InOut,!0);game.add.tween(this.scale).to({x:1.2,y:1.2},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotHoverTint};c.onTileOut=function(){game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotTint};c.animations.add("walk_w",mar.animationFrames.harvester_walk_w,!0);c.animations.add("walk_s",mar.animationFrames.harvester_walk_s,!0);c.animations.add("walk_e",
|
||||
mar.animationFrames.harvester_walk_e,!0);c.animations.add("walk_n",mar.animationFrames.harvester_walk_n,!0);c.queuedAnims=[];switch(c.direction){case DIR_NORTH:c.animations.frame=HARVESTER_WALK_FRAMES.north;break;case DIR_EAST:c.animations.frame=HARVESTER_WALK_FRAMES.east;break;case DIR_SOUTH:c.animations.frame=HARVESTER_WALK_FRAMES.south;break;case DIR_WEST:c.animations.frame=HARVESTER_WALK_FRAMES.west}return c}if(3===a.t){var f=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),15,"sheet","objects/factory",
|
||||
isoGroup);f.anchor.set(.5,.25);f.id=a.i;f.type=3;f.tileX=a.x;f.tileY=a.y;f.hoverText=game.make.text(0,0,"Factory",{fontSize:22,fill:colorScheme.textFill,stroke:colorScheme.textStroke,strokeThickness:2,font:"fixedsys"});f.hoverText.alpha=0;f.hoverText.anchor.set(.5,0);f.addChild(f.hoverText);f.isAt=function(a,b){return(this.tileX===a||this.tileX+1===a)&&(this.tileY+1===b||this.tileY===b)};f.onTileHover=function(){game.tweens.removeFrom(this);game.add.tween(this).to({isoZ:25},200,Phaser.Easing.Quadratic.InOut,
|
||||
!0);game.add.tween(this.scale).to({x:1.06,y:1.06},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotHoverTint;game.add.tween(this.hoverText).to({alpha:.9},200,Phaser.Easing.Quadratic.In,!0);f.hoverText.visible=!0};f.onTileOut=function(){game.tweens.removeFrom(this);game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotTint;game.add.tween(this.hoverText).to({alpha:0},200,Phaser.Easing.Quadratic.Out,
|
||||
!0)};return f}if(4===a.t){var e=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),15,"sheet","objects/RadioTower",isoGroup);e.anchor.set(.5,.64);e.id=a.i;e.type=4;e.tileX=a.x;e.tileY=a.y;e.hoverText=game.make.text(0,0,"Radio Tower",{fontSize:22,fill:colorScheme.textFill,stroke:colorScheme.textStroke,strokeThickness:2,font:"fixedsys"});e.hoverText.alpha=0;e.hoverText.anchor.set(.5,0);e.addChild(e.hoverText);e.isAt=function(a,b){return this.tileX===a&&this.tileY===b};e.onTileHover=function(){game.tweens.removeFrom(this);
|
||||
game.add.tween(this).to({isoZ:45},200,Phaser.Easing.Quadratic.InOut,!0);game.add.tween(this.scale).to({x:1.15,y:1.15},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotHoverTint;game.add.tween(this.hoverText).to({alpha:.9},200,Phaser.Easing.Quadratic.In,!0);e.hoverText.visible=!0};e.onTileOut=function(){game.tweens.removeFrom(this);game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotTint;
|
||||
game.add.tween(this.hoverText).to({alpha:0},200,Phaser.Easing.Quadratic.Out,!0)};return e}}function manhanttanDistance(a,b,c,d){return Math.abs(a-c)+Math.abs(b-d)}function codeListener(a){"code"===a.t&&ace.edit("editor").setValue(a.code)}function authListener(a){"auth"===a.t&&("ok"===a.m?(console.log("Auth successful"),mar.client.requestUserInfo()):alert("Authentication failed. Please make sure you are logged in and reload the page."))}
|
||||
function codeResponseListener(a){"codeResponse"===a.t&&alert("Uploaded and assembled "+a.bytes+" bytes")}function userInfoListener(a){"userInfo"===a.t&&(console.log(a),mar.worldX=a.worldX,mar.worldY=a.worldY,mar.maxWidth=a.maxWidth,mar.client.requestTerrain())}
|
||||
b.energy=a.energy;b.inventory=createInventory([b.heldItem]);b.addChild(b.inventory);dispatchTileEnter(a.x,a.y);b.isAt=function(a,b){return this.tileX===a&&this.tileY===b};b.onTileHover=function(){game.add.tween(this).to({isoZ:45},200,Phaser.Easing.Quadratic.InOut,!0);game.add.tween(this.scale).to({x:1.2,y:1.2},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotHoverTint};b.onTileOut=function(){document.body.style.cursor="default";game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,
|
||||
!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);this.tint=16777215};b.energy<=LOW_ENERGY&&(b.tint=13369344);b.animations.add("walk_w",mar.animationFrames.walk_w,!0);b.animations.add("walk_s",mar.animationFrames.walk_s,!0);b.animations.add("walk_e",mar.animationFrames.walk_e,!0);b.animations.add("walk_n",mar.animationFrames.walk_n,!0);b.animations.add("dig_w",mar.animationFrames.dig_w,!1);b.animations.add("dig_s",mar.animationFrames.dig_s,!1);b.animations.add("dig_e",
|
||||
mar.animationFrames.dig_e,!1);b.animations.add("dig_n",mar.animationFrames.dig_n,!1);b.queuedAnims=[];switch(b.direction){case DIR_NORTH:b.animations.frame=194;break;case DIR_EAST:b.animations.frame=164;break;case DIR_SOUTH:b.animations.frame=240;break;case DIR_WEST:b.animations.frame=254}a=game.make.text(0,-24,b.username,{fontSize:22,fill:colorScheme.textFill,stroke:colorScheme.textStroke,strokeThickness:2,font:"fixedsys"});a.alpha=.85;a.anchor.set(.5,0);b.username===mar.client.username?a.tint=16469258:
|
||||
b.alpha=.6;b.addChild(a);return b}if(2===a.t){var c=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),10,"sheet",1,isoGroup);c.animations.add("idle",mar.animationFrames.biomassIdle,!0);c.anchor.set(.5,0);c.type=2;c.tileX=a.x;c.tileY=a.y;c.id=a.i;c.tint=colorScheme.biomassTint;c.hoverText=game.make.text(0,0,"Biomass",{fontSize:22,fill:colorScheme.textFill,stroke:colorScheme.textStroke,strokeThickness:2,font:"fixedsys"});c.hoverText.alpha=0;c.hoverText.anchor.set(.5,0);c.addChild(c.hoverText);c.isAt=function(a,
|
||||
b){return this.tileX===a&&this.tileY===b};c.isAt=function(a,b){return this.tileX===a&&this.tileY===b};c.onTileHover=function(){game.tweens.removeFrom(this);document.body.style.cursor="pointer";game.add.tween(this).to({isoZ:45},200,Phaser.Easing.Quadratic.InOut,!0);this.tint=colorScheme.biomassHoverTint;game.add.tween(this.scale).to({x:1.2,y:1.2},200,Phaser.Easing.Linear.None,!0);game.add.tween(this.hoverText).to({alpha:.9},200,Phaser.Easing.Quadratic.In,!0);c.hoverText.visible=!0};c.onTileOut=function(){game.tweens.removeFrom(this);
|
||||
document.body.style.cursor="default";game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.biomassTint;game.add.tween(this.hoverText).to({alpha:0},200,Phaser.Easing.Quadratic.Out,!0)};c.animations.play("idle",45,!0);return c}if(10===a.t){var d=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),15,"sheet",null,isoGroup);d.anchor.set(.5,0);d.id=a.i;d.type=10;d.tileX=a.x;d.tileY=a.y;d.direction=a.direction;
|
||||
d.action=a.action;dispatchTileEnter(a.x,a.y);d.isAt=function(a,b){return this.tileX===a&&this.tileY===b};d.onTileHover=function(){game.add.tween(this).to({isoZ:45},200,Phaser.Easing.Quadratic.InOut,!0);game.add.tween(this.scale).to({x:1.2,y:1.2},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotHoverTint};d.onTileOut=function(){game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotTint};
|
||||
d.animations.add("walk_w",mar.animationFrames.harvester_walk_w,!0);d.animations.add("walk_s",mar.animationFrames.harvester_walk_s,!0);d.animations.add("walk_e",mar.animationFrames.harvester_walk_e,!0);d.animations.add("walk_n",mar.animationFrames.harvester_walk_n,!0);d.queuedAnims=[];switch(d.direction){case DIR_NORTH:d.animations.frame=HARVESTER_WALK_FRAMES.north;break;case DIR_EAST:d.animations.frame=HARVESTER_WALK_FRAMES.east;break;case DIR_SOUTH:d.animations.frame=HARVESTER_WALK_FRAMES.south;
|
||||
break;case DIR_WEST:d.animations.frame=HARVESTER_WALK_FRAMES.west}return d}if(3===a.t){var f=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),15,"sheet","objects/factory",isoGroup);f.anchor.set(.5,.25);f.id=a.i;f.type=3;f.tileX=a.x;f.tileY=a.y;f.hoverText=game.make.text(0,0,"Factory",{fontSize:22,fill:colorScheme.textFill,stroke:colorScheme.textStroke,strokeThickness:2,font:"fixedsys"});f.hoverText.alpha=0;f.hoverText.anchor.set(.5,0);f.addChild(f.hoverText);f.isAt=function(a,b){return(this.tileX===a||
|
||||
this.tileX+1===a)&&(this.tileY+1===b||this.tileY===b)};f.onTileHover=function(){game.tweens.removeFrom(this);game.add.tween(this).to({isoZ:25},200,Phaser.Easing.Quadratic.InOut,!0);game.add.tween(this.scale).to({x:1.06,y:1.06},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotHoverTint;game.add.tween(this.hoverText).to({alpha:.9},200,Phaser.Easing.Quadratic.In,!0);f.hoverText.visible=!0};f.onTileOut=function(){game.tweens.removeFrom(this);game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,
|
||||
!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotTint;game.add.tween(this.hoverText).to({alpha:0},200,Phaser.Easing.Quadratic.Out,!0)};return f}if(4===a.t){var e=game.add.isoSprite(getIsoX(a.x),getIsoY(a.y),15,"sheet","objects/RadioTower",isoGroup);e.anchor.set(.5,.64);e.id=a.i;e.type=4;e.tileX=a.x;e.tileY=a.y;e.hoverText=game.make.text(0,0,"Radio Tower",{fontSize:22,fill:colorScheme.textFill,stroke:colorScheme.textStroke,strokeThickness:2,font:"fixedsys"});
|
||||
e.hoverText.alpha=0;e.hoverText.anchor.set(.5,0);e.addChild(e.hoverText);e.isAt=function(a,b){return this.tileX===a&&this.tileY===b};e.onTileHover=function(){game.tweens.removeFrom(this);game.add.tween(this).to({isoZ:45},200,Phaser.Easing.Quadratic.InOut,!0);game.add.tween(this.scale).to({x:1.15,y:1.15},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotHoverTint;game.add.tween(this.hoverText).to({alpha:.9},200,Phaser.Easing.Quadratic.In,!0);e.hoverText.visible=!0};e.onTileOut=function(){game.tweens.removeFrom(this);
|
||||
game.add.tween(this).to({isoZ:15},400,Phaser.Easing.Bounce.Out,!0);game.add.tween(this.scale).to({x:1,y:1},200,Phaser.Easing.Linear.None,!0);this.tint=colorScheme.cubotTint;game.add.tween(this.hoverText).to({alpha:0},200,Phaser.Easing.Quadratic.Out,!0)};return e}}function manhanttanDistance(a,b,c,d){return Math.abs(a-c)+Math.abs(b-d)}function codeListener(a){"code"===a.t&&ace.edit("editor").setValue(a.code)}
|
||||
function authListener(a){"auth"===a.t&&("ok"===a.m?(console.log("Auth successful"),mar.client.requestUserInfo()):alert("Authentication failed. Please make sure you are logged in and reload the page."))}function codeResponseListener(a){"codeResponse"===a.t&&alert("Uploaded and assembled "+a.bytes+" bytes")}function userInfoListener(a){"userInfo"===a.t&&(console.log(a),mar.worldX=a.worldX,mar.worldY=a.worldY,mar.maxWidth=a.maxWidth,mar.client.requestTerrain())}
|
||||
function terrainListener(a){"terrain"===a.t&&(void 0!==mar.world?(mar.client.socket.send(JSON.stringify({t:"object",x:mar.worldX,y:mar.worldY})),mar.world.update(a.terrain)):(mar.world=new Word(a.terrain),console.log("Gameloop started"),game.input.keyboard.onDownCallback=function(a){document.activeElement===document.getElementById("game")&&((37<=a.keyCode&&40>=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='<i class="fa fa-long-arrow-down" aria-hidden="true"></i> <i class="fa fa-floppy-o" aria-hidden="true"></i>';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<a.c.length;d++)c+=a.c[d];a=b.innerHTML="";var f=c.split("\n");for(d=0;d<f.length;d++)if(40<=f[d].length)for(var e=f[d].match(/.{1,40}/g),g=0;g<e.length;g++)g!==
|
||||
e.length-1&&(a+="\n");else a+=f[d]+"\n";b.innerHTML=a;mar.lastLines=c;b.scrollTop=b.scrollHeight}}}
|
||||
var GameClient=function(a){var b=this,c=[],d=new XMLHttpRequest;d.open("GET","./getServerInfo.php",!0);d.onreadystatechange=function(){4===d.readyState&&200===d.status&&(console.log("Received server info "+d.responseText),setTimeout(function(){var f=JSON.parse(d.responseText);console.log(f.address);b.socket=new WebSocket(f.address);b.username=f.username;b.tickLength=f.tickLength;b.serverName=f.serverName;mar.client.socket.binaryType="arraybuffer";b.socket.onopen=function(){b.socket.send(f.token);
|
||||
c.push(authListener);c.push(userInfoListener);c.push(terrainListener);c.push(tickListener);c.push(objectListener);c.push(codeListener);c.push(codeResponseListener);mar.client.socket.onmessage=function(a){try{var b=JSON.parse(a.data)}catch(h){console.log(h),floppyListener(a)}for(a=0;a<c.length;a++)c[a](b)};b.reloadCode();void 0!==a&&a()};b.socket.onerror=function(a){alert("Can't connect to game server at address "+f.address);console.log(a)};b.socket.onclose=function(a){alert("Disconnected from server");
|
||||
console.log(a)}},100))};d.send(null);this.requestUserInfo=function(){this.socket.send(JSON.stringify({t:"userInfo"}))};this.requestTerrain=function(){this.socket.send(JSON.stringify({t:"terrain",x:mar.worldX,y:mar.worldY}))};this.uploadCode=function(a){console.log("Uploaded code");this.socket.send(JSON.stringify({t:"uploadCode",code:a}))};this.reloadCode=function(){this.socket.send(JSON.stringify({t:"codeRequest"}))};this.sendKeypress=function(a){0!==a&&this.socket.send(JSON.stringify({t:"k",k:a}))};
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user