From ebe14ed5dca965c5da689fe5601d4e16396df680 Mon Sep 17 00:00:00 2001 From: samuelmaddock Date: Sat, 6 Oct 2012 18:42:05 -0400 Subject: [PATCH] Starting on docks --- client/js/catan.js | 4 + client/js/controls.js | 6 + client/js/main.js | 7 + server/game.js | 16 +- shared/board.js | 351 ++++++++++++++-------------------- shared/entities/BaseEntity.js | 4 +- shared/entities/HexCorner.js | 38 +++- shared/entities/HexTile.js | 227 +++++++++++----------- shared/enums.js | 15 +- shared/modules/ents.js | 8 +- shared/schemas/classic.js | 19 +- 11 files changed, 361 insertions(+), 334 deletions(-) diff --git a/client/js/catan.js b/client/js/catan.js index 5b3d764..1d4b5b1 100644 --- a/client/js/catan.js +++ b/client/js/catan.js @@ -56,6 +56,10 @@ CATAN.getState = function() { return this.state; } +CATAN.getBoard = function() { + return this.board; +} + CATAN.getSchema = function() { return this.Schemas.get("Classic"); // static for now } diff --git a/client/js/controls.js b/client/js/controls.js index e80d29d..21e9691 100644 --- a/client/js/controls.js +++ b/client/js/controls.js @@ -149,6 +149,12 @@ THREE.CatanControls = function ( object, domElement ) { * Math.cos( this.theta * Math.PI / 360 ) * Math.cos( this.phi * Math.PI / 360 ); + /*if(CATAN.board) { + this.target = CATAN.board.getWorldHexOffset(); + this.object.position.x += this.target.x; + this.object.position.z += this.target.z; + }*/ + this.object.lookAt( this.target ); this.object.updateMatrix(); diff --git a/client/js/main.js b/client/js/main.js index 406e75b..de2595b 100644 --- a/client/js/main.js +++ b/client/js/main.js @@ -20,6 +20,13 @@ CATAN._init = function() { this.socket.on( 'CServerList', this.Lobby.loadServerList ); } + // Request desktop notification permissions + document.addEventListener("mousedown", function(event) { + if(webkitNotifications.checkPermission() > 0) { + webkitNotifications.requestPermission(); + } + }, false); + }; CATAN.createServer = function() { diff --git a/server/game.js b/server/game.js index 4336f8c..d8a06f5 100644 --- a/server/game.js +++ b/server/game.js @@ -559,9 +559,21 @@ CATAN.Game.prototype = { } // Send tiles + var docks = []; + for(var i in this.getBoard().getDocks()) { + var dock = this.getBoard().getDocks()[i]; + docks.push({ + id: dock.getEntId(), + dock: true, + dockTo: dock.dockTo.getEntId() + }); + }; + ply.emit('CBoardEntities', { ents: docks }); + + // Send docks var tiles = []; - for(var i=0; i < board.hexTiles.length; i++) { - var tile = board.hexTiles[i]; + for(var i=0; i < this.getBoard().getTiles().length; i++) { + var tile = this.getBoard().getTiles()[i]; tiles.push({ id: tile.getEntId(), resource: tile.getResource(), diff --git a/shared/board.js b/shared/board.js index 685c455..ae94a0f 100644 --- a/shared/board.js +++ b/shared/board.js @@ -18,15 +18,18 @@ CATAN.Board = function(game) { CATAN.EntityCount = 0; // reset this.game = game; - - this.cellWidth = 5; - this.cellHeight = 5; this.hexRadius = 64; + this.seaTiles = []; this.hexTiles = []; this.hexCorners = []; this.hexEdges = []; + this.docks = []; + + this.tiles = null; + this.corners = null; + this.edges = null; this.robber = CATAN.ents.create('Robber'); @@ -42,153 +45,158 @@ CATAN.Board = function(game) { ------------------------------------------------*/ CATAN.Board.prototype = { + setTile: function(x, y, value) { + this.tiles[y][x] = value; + }, + + getTile: function(x, y) { + if( (x < 0) || (y < 0) || (x > this.getGridWidth()-1) || + (y > this.getGridHeight()-1) ) { + return undefined; + } + return this.tiles[y][x]; + }, + + getCorner: function(x, y) { + /*if( (x < 0) || (y < 0) || (x > this.getGridWidth()-1) || + (y > this.getGridHeight()-1) ) { + return undefined; + }*/ + return this.corners[y][x]; + }, + + getGridWidth: function() { + return this.tiles[0].length; + }, + + getGridHeight: function() { + return this.tiles.length; + }, + setup: function() { if(SERVER) { this.Schema = this.game.getSchema(); - this.Grid = this.game.getSchema().getGrid(); + this.tiles = this.game.getSchema().getGrid(); this.resourceCount = this.Schema.getResources(); this.numTokens = this.Schema.getNumberTokens(); } else { this.Schema = CATAN.getSchema(); - this.Grid = CATAN.getSchema().getGrid(); + this.tiles = CATAN.getSchema().getGrid(); } - // Update later for possible expansions? - this.cellHeight = this.Grid.length; - this.cellWidth = this.Grid[0].length; - // Setup hex grid tiles - for (y = 0; y < this.cellHeight; y++) { - for (x = 0; x < this.cellWidth; x++) { + for (y = 0; y < this.getGridHeight(); y++) { + for (x = 0; x < this.getGridWidth(); x++) { - var tile = this.Grid[y][x]; - - if (tile != 0) { // Check if grid coordinate is valid + var tile = this.getTile(x, y); - tile = this.setupHexTile(x,y); - this.hexTiles.push( tile ); - - this.Grid[y][x] = tile; - - } + if (tile == TILE_LAND) { // Check if grid coordinate is valid - } - } + tile = this.setupTile(x, y, TILE_LAND); + this.hexTiles.push(tile); - // Create corner and edge entities - var corners = []; - var edges = []; - for(var i in this.hexTiles) { - - var tile = this.hexTiles[i]; - - // Get corner positions - var positions = [ - tile.getCornerPosition(CORNER_L), - tile.getCornerPosition(CORNER_TL), - tile.getCornerPosition(CORNER_TR), - tile.getCornerPosition(CORNER_R), - tile.getCornerPosition(CORNER_BR), - tile.getCornerPosition(CORNER_BL) - ]; - - for(var j in positions) { - - var pos = positions[j]; // get corner vector - var posStr = Math.floor(pos.x) + "," + Math.floor(pos.Y) + "," + Math.floor(pos.z); // hash string - - var corner; - if (!corners[posStr]) { // create new corner entity - - corner = CATAN.ents.create('HexCorner'); - corner.setPosition(positions[j]); - - corners[posStr] = corner; // set reference for later - - this.hexCorners.push(corner); + this.setTile(x, y, tile); if(SERVER) { - this.game.entities.push(corner); + this.setupResource(tile); + this.setupNumberToken(tile); + this.game.entities.push(tile); } - - } else { // duplicate corner - - corner = corners[posStr]; - + + } else if (tile == TILE_SEA) { + + tile = this.setupTile(x, y, TILE_SEA); + this.seaTiles.push(tile); + + this.setTile(x, y, tile); + } - tile.AdjacentCorners.push(corner); - corner.AdjacentTiles.push(tile); - } + } - // Get edge orientations - var orientations = [ - tile.getEdgePosAng(EDGE_T), - tile.getEdgePosAng(EDGE_TR), - tile.getEdgePosAng(EDGE_BR), - tile.getEdgePosAng(EDGE_B), - tile.getEdgePosAng(EDGE_BL), - tile.getEdgePosAng(EDGE_TL) - ]; - - for(var j in orientations) { - - var pos = orientations[j].pos; // get edge vector - var ang = orientations[j].ang; // get edge vector - - var posStr = Math.floor(pos.x) + "," + Math.floor(pos.Y) + "," + Math.floor(pos.z); // hash string - - var edge; - if (!edges[posStr]) { // create new edge entity - - edge = CATAN.ents.create('HexEdge'); - edge.setPosition(orientations[j].pos); - edge.setAngle(orientations[j].ang); - - edges[posStr] = edge; // set reference for later - - this.hexEdges.push(edge); + // Initialize vertex arrays + this.corners = new Array( 2*this.getGridHeight() + 2 ); + for (var y = 0; y < this.corners.length; y++) { + this.corners[y] = []; + } - if(SERVER) { - this.game.entities.push(edge); - } - - } else { // duplicate edge - - edge = edges[posStr]; - + if(SERVER) return; + + // Create corner entities + for(var y = 0; y < this.getGridHeight(); y++) { + for(var x = 0; x < this.getGridWidth(); x++) { + var i = x; + var j; + if(x % 2 == 0) { + j = 2*y; + } else { + j = (2*y) + 1; } - - tile.AdjacentEdges.push(edge); - edge.AdjacentTiles.push(tile); - + + this.setupCorner(i, j); + this.setupCorner(i+1, j); + this.setupCorner(i+1, j+1); + this.setupCorner(i+1, j+2); + this.setupCorner(i, j+2); + this.setupCorner(i, j+1); } - } - delete corners; - delete edges; - // Establish adjacencies - this.findAdjacentCorners() - this.findAdjacentEdges() + }, + setupCorner: function(i, j) { + if(this.corners[j][i] != undefined) { + return; + } + var c = CATAN.ents.create('HexCorner'); + c.x = i; + c.y = j; + c.board = this; + + var r = this.hexRadius, // radius + w = r * 2, // width + h = r * Math.sqrt(3), // height + s = r * 3 / 2; // side + + var vx = i * s, + vz = j * (h/2) + + if( (i % 2 == 1) && (j % 2 == 1) || + (i % 2 == 0) && (j % 2 == 0) ) { + vx += (w-s); + } - // Create docks + // Set corner position + c.setPosition( + vx, + 0, + vz + ); + this.hexCorners.push(c); + this.corners[j][i] = c; }, - setupHexTile: function(x, y) { - var offset = this.getWorldHexOffset() + setupTile: function(x, y, type) { var tile = CATAN.ents.create('HexTile'); - tile.setGridIndex(x, y, this.hexRadius, offset); - - if(SERVER) { - this.setupResource(tile); - this.setupNumberToken(tile); - this.game.entities.push(tile); - } - + tile.setTileType(type); + + tile.board = this; + tile.x = x; + tile.y = y; + + var r = this.hexRadius, // radius + w = r * 2, // width + h = r * Math.sqrt(3), // height + s = r * 3 / 2; // side + + tile.setPosition( + x * s, + 0, + (y * h) + (x % 2) * (h / 2) + ); + return tile; }, @@ -206,11 +214,6 @@ CATAN.Board.prototype = { } }, - /* ----------------------------------------------- - CATAN.Board.prototype.setupNumberToken( HexTile ) - - Desc: Assign number token to hex tile - ------------------------------------------------*/ setupNumberToken: function(tile) { if(tile.Resource == RESOURCE_DESERT) return; // Desert doesn't have a number token var randToken = Math.floor( Math.random() * this.numTokens.length ) @@ -218,94 +221,30 @@ CATAN.Board.prototype = { this.numTokens.splice(randToken,1); // remove resource }, - findAdjacentCorners: function() { - // for corners - for(var i in this.hexCorners) { - - var c = this.hexCorners[i]; // get corner - - // Loop through all other corners - for(var j in this.hexCorners) { - - var c2 = this.hexCorners[j]; // get corner to be compared - - if(c.getEntId() != c2.getEntId()) { // check for same corner - - var distance = Math.floor( c.position.distanceTo(c2.position) ); - - if (distance <= this.hexRadius) { // if the distance is small enough, the corner is adjacent - c.AdjacentCorners.push(c2); - } - - } - - } + getWorldHexOffset: function() { + var list = []; - // Loop through all edges - for(var j in this.hexEdges) { - - var e = this.hexEdges[j]; // get edge to be compared - var distance = Math.floor( c.position.distanceTo(e.position) ); - - if (distance <= this.hexRadius) { // if the distance is small enough, the edge is adjacent - c.AdjacentEdges.push(e); - e.AdjacentCorners.push(c); - } - + for(var i in this.hexTiles) { + if(this.hexTiles[i].isLand()) { + list.push(this.hexTiles[i].getPosition()); } - } - }, - - findAdjacentEdges: function() { - for(var i in this.hexEdges) { - - var e = this.hexEdges[i]; // get edge - - // Loop through all other corners - for(var j in this.hexEdges) { - - var e2 = this.hexEdges[j]; // get edge to be compared - - if(e.getEntId() != e2.getEntId()) { // check for same edge - var distance = Math.floor( e.position.distanceTo(e2.position) ); - - if (distance <= this.hexRadius) { // if the distance is small enough, the edge is adjacent - e.AdjacentEdges.push(e2); - } - - } - - } + var x = 0, + y = 0, + z = 0; - // Loop through all edges - for(var j in this.hexEdges) { - - var e2 = this.hexEdges[j]; // get edge to be compared - var distance = Math.floor( e.position.distanceTo(e2.position) ); - - if (distance <= this.hexRadius) { // if the distance is small enough, the edge is adjacent - e.AdjacentEdges.push(e2); - } - - } - + for(var i in list) { + x += list[i].x; + y += list[i].y; + z += list[i].z; } - }, - - /* ----------------------------------------------- - CATAN.Board.prototype.getWorldHexOffset - - Desc: Returns the grid offset to center - the board - ------------------------------------------------*/ - getWorldHexOffset: function() { - var r = this.hexRadius, - w = r * 2, - h = r * Math.sqrt(3); - return new THREE.Vector3( ( (this.cellWidth * w) - r ) / 2, 0, (this.cellHeight * h) / 2 ); + return new THREE.Vector3( + x / list.length, + y / list.length, + z / list.length + ); }, getTiles: function() { @@ -320,6 +259,10 @@ CATAN.Board.prototype = { return this.hexEdges; }, + getDocks: function() { + return this.docks; + }, + getRobber: function() { return this.robber; } diff --git a/shared/entities/BaseEntity.js b/shared/entities/BaseEntity.js index af31c4d..b5fd64a 100644 --- a/shared/entities/BaseEntity.js +++ b/shared/entities/BaseEntity.js @@ -87,7 +87,9 @@ CATAN.ents.register('BaseEntity', (function() { Desc: Entity's world position ------------------------------------------------*/ ENT.prototype.getPosition = function() { return this.position; } - ENT.prototype.setPosition = function(pos) { this.position = pos; } + ENT.prototype.setPosition = function(x, y, z) { + this.position = new THREE.Vector3(x, y, z); + } ENT.prototype.getAngle = function() { return this.angle; } ENT.prototype.setAngle = function(ang) { this.angle = ang; } diff --git a/shared/entities/HexCorner.js b/shared/entities/HexCorner.js index 9ace6f8..36fedc1 100644 --- a/shared/entities/HexCorner.js +++ b/shared/entities/HexCorner.js @@ -9,9 +9,8 @@ CATAN.ents.register('HexCorner', (function() { this.create(); this.setType(BUILDING_SETTLEMENT); - this.AdjacentTiles = []; - this.AdjacentEdges = []; - this.AdjacentCorners = []; + this.x = -1; + this.y = -1; this.build = function(ply) { if(this.hasOwner()) { @@ -26,6 +25,39 @@ CATAN.ents.register('HexCorner', (function() { ENT.prototype = CATAN.ents.create('BaseEntity'); + ENT.prototype.getAdjacentTiles = function() { + var list = [], + x = this.getX(), + y = this.getY(); + + var xOdd = (x % 2 == 1), + yOdd = (y % 2 == 1); + + if(xOdd) { + if(yOdd) { + list.push( this.board.getTile(x, y)) ); + list.push( this.board.getTile(x, y)) ); + list.push( this.board.getTile(x, y)) ); + } else { + list.push( this.board.getTile(x, y)) ); + list.push( this.board.getTile(x, y)) ); + list.push( this.board.getTile(x, y)) ); + } + } else { + if(yOdd) { + list.push( this.board.getTile(x, y)) ); + list.push( this.board.getTile(x, y)) ); + list.push( this.board.getTile(x, y)) ); + } else { + list.push( this.board.getTile(x, y - ((y/2) + 1)) ); + list.push( this.board.getTile(x - 1, y - ((y/2) + 1))) ); + list.push( this.board.getTile(x, y - (y/2)) ); + } + } + + return list.filter(function(e){return e}); + } + ENT.prototype.canBuild = function(ply) { if(this.hasOwner()) { if((this.getOwner() != ply) || ply.isInSetup()) { diff --git a/shared/entities/HexTile.js b/shared/entities/HexTile.js index be1e213..ce02615 100644 --- a/shared/entities/HexTile.js +++ b/shared/entities/HexTile.js @@ -8,22 +8,16 @@ CATAN.ents.register('HexTile', (function() { var ENT = function() { this.create(); - // Catan + this.board = null; + + this.tileType = TILE_SEA; this.Resource = -1; this.NumberToken = -1; this.bHasRobber = false; - - this.AdjacentCorners = []; - this.AdjacentEdges = []; + this.bDock = false; this.x = -1; this.y = -1; - - this.cornersX = []; - this.cornersY = []; - - this.edgesX = []; - this.edgesY = []; this.bVisible = true; @@ -33,16 +27,84 @@ CATAN.ents.register('HexTile', (function() { ENT.prototype = CATAN.ents.create('BaseEntity'); + ENT.prototype.getX = function() { + return this.x; + } + ENT.prototype.getY = function() { + return this.y; + } + + ENT.prototype.getAdjacentTiles = function() { + var list = [], + x = this.getX(), + y = this.getY(); + + list.push( this.board.getTile(x-1, y) ); + list.push( this.board.getTile(x, y-1) ); + list.push( this.board.getTile(x+1, y) ); + list.push( this.board.getTile(x+1, y+1) ); + list.push( this.board.getTile(x, y+1) ); + list.push( this.board.getTile(x-1, y+1) ); + + return list.filter(function(e){return e}); + } + + ENT.prototype.getAdjacentCorners = function() { + var list = [], + x = this.getX(), + y = this.getY(); + + var i = x; + var j; + if(x % 2 == 0) { + j = 2*y; + } else { + j = (2*y) + 1; + } + + list.push( this.board.getCorner(i, j) ); + list.push( this.board.getCorner(i+1, j) ); + list.push( this.board.getCorner(i+1, j+1) ); + list.push( this.board.getCorner(i+1, j+2) ); + list.push( this.board.getCorner(i, j+2) ); + list.push( this.board.getCorner(i, j+1) ); + + return list.filter(function(e){return e}); + } + + /* + Tile type + */ + ENT.prototype.setTileType = function(type) { + this.tileType = type; + } + ENT.prototype.getTileType = function() { + return this.tileType; + } + ENT.prototype.isLand = function() { + return this.getTileType() == TILE_LAND; + } + ENT.prototype.isSea = function() { + return this.getTileType() == TILE_SEA; + } + + /* + Dock + */ + ENT.prototype.isDock = function() { + return this.bDock; + } + ENT.prototype.setDock = function(tile) { + this.dockTo = tile; + this.bDock = true; + } + /* Resources */ ENT.prototype.getResource = function() { return this.Resource; }; ENT.prototype.setResource = function(resource) { this.Resource = resource; }; - ENT.prototype.isDesert = function() { - return this.getResource() == RESOURCE_DESERT; - } - /* Tokens */ @@ -89,118 +151,57 @@ CATAN.ents.register('HexTile', (function() { ENT.prototype.hasRobber = function() { return this.bHasRobber; }; ENT.prototype.setRobber = function(bRobber) { this.bHasRobber = bRobber; }; - /* - Hex Geometry - */ - ENT.prototype.setRadius = function(r) { - this.Radius = r; - this.Width = r * 2; - this.Height = r * Math.sqrt(3); - this.Side = r * 3 / 2; - } - - /* ----------------------------------------------- - ENT.setGridIndex( x, y ) - - Desc: Sets the hex tile grid index and - calculates the appropriate offsets - ------------------------------------------------*/ - ENT.prototype.setGridIndex = function(x, y, r, offset) { - this.setRadius(r); - - this.x = x; - this.y = y; + if(CLIENT) { - var w = this.Width, - h = this.Height, - s = this.Side; - - this.mX = (x * s), - this.mY = h * (2 * y + (x % 2)) / 2; - - // Corner positions from center of tile - this.cornersX = [ -r/2, r/2, r, r/2, -r/2, -r ]; - this.cornersY = [ -h/2, -h/2, 0, h/2, h/2, 0 ]; - - // Edge positions from center of tile - this.edgesX = [ 0, r/4 + r/2, r/4 + r/2, 0, -r/4 - r/2, -r/4 - r/2 ]; - this.edgesY = [ -h/2, -h/4, h/4, h/2, h/4, -h/4 ]; + ENT.prototype.setup = function(data) { + this._setup(data); - var rad = 60 * Math.PI/180 - this.edgesAngle = [ 0, -rad, rad, 0, -rad, rad ]; + if(this.isLand()) { + this.setResource(data.resource); + this.setToken(data.token); + this.setupMesh(); + this.getMesh().rotation.y = data.yaw; + } - this.position = new THREE.Vector3( - this.mX - offset.x + s, - 0, - this.mY - offset.z + h/2 - ); + if(this.isSea()) { + /*this.dockTo = CATAN.ents.getById(data.dockTo); + this.setupDock(); + CATAN.getBoard().docks.push(this);*/ - } + var res = CATAN.getSchema().Resources[0]; - /* ----------------------------------------------- - ENT.getNeighborXY - - Desc: Returns adjacent hex tile in accordance - to the BOARD.Grid - ------------------------------------------------*/ - ENT.prototype.getNeighborX = function() {}; - ENT.prototype.getNeighborY = function() {}; - - /* ----------------------------------------------- - ENT.getCornerPosition( CORNER_ENUM ) - - Desc: Returns the world position for the - requested corner of the tile (See enums.js) - ------------------------------------------------*/ - ENT.prototype.getCornerPosition = function(CORNER_ENUM) { - var pos = this.getPosition(); - var corner = new THREE.Vector3( - pos.x + this.cornersX[CORNER_ENUM], - pos.y, - pos.z + this.cornersY[CORNER_ENUM] - ); - - return corner; - } + this.Mesh = new THREE.Mesh( + CATAN.AssetManager.get(res.url), + new THREE.MeshLambertMaterial({ + map: CATAN.AssetManager.get(res.mat) + }) + ); - /* ----------------------------------------------- - ENT.getEdgePosition( EDGE_ENUM ) - - Desc: Returns the world position for the - requested edge of the tile (See enums.js) - ------------------------------------------------*/ - ENT.prototype.getEdgePosAng = function(EDGE_ENUM) { - var angle = new THREE.Vector3( - 0, - this.edgesAngle[EDGE_ENUM], - 0 - ); - - var hexpos = this.getPosition(); - var position = new THREE.Vector3( - hexpos.x + this.edgesX[EDGE_ENUM], - hexpos.y, - hexpos.z + this.edgesY[EDGE_ENUM] - ); - - return { pos: position, ang: angle }; - } + this.Mesh.position = this.position; + this.Mesh.Parent = this; - if(CLIENT) { + CATAN.Game.scene.add( this.Mesh ); + } + } - ENT.prototype.setup = function(data) { - this._setup(data); + ENT.prototype.setupMesh = function() { + var res = CATAN.getSchema().Resources[this.getResource()]; - this.setResource(data.resource); - this.setToken(data.token); + this.Mesh = new THREE.Mesh( + CATAN.AssetManager.get(res.url), + new THREE.MeshLambertMaterial({ + map: CATAN.AssetManager.get(res.mat) + }) + ); - this.setupMesh(); + this.Mesh.position = this.position; + this.Mesh.Parent = this; - this.Mesh.rotation.y = data.yaw; + CATAN.Game.scene.add( this.Mesh ); } - ENT.prototype.setupMesh = function() { - var res = CATAN.getSchema().Resources[this.getResource()]; + ENT.prototype.setupDock = function() { + var res = CATAN.getSchema().Resources[0]; this.Mesh = new THREE.Mesh( CATAN.AssetManager.get(res.url), diff --git a/shared/enums.js b/shared/enums.js index 1b107b3..0e4c6d8 100644 --- a/shared/enums.js +++ b/shared/enums.js @@ -3,6 +3,11 @@ // Global variable var g = SERVER ? GLOBAL : window; + // Grid tiles + g.TILE_INVALID = 0; + g.TILE_LAND = 1; + g.TILE_SEA = 2; + // Resource types g.RESOURCE_DESERT = 0; g.RESOURCE_LUMBER = 1; @@ -40,11 +45,11 @@ if(SERVER) { // Game state - g.STATE_NONE = 0 - g.STATE_WAITING = 1 - g.STATE_SETUP = 2 - g.STATE_PLAYING = 3 - g.STATE_END = 4 + g.STATE_NONE = 0; + g.STATE_WAITING = 1; + g.STATE_SETUP = 2; + g.STATE_PLAYING = 3; + g.STATE_END = 4; // Player Status g.PLAYER_LOBBY = 0; diff --git a/shared/modules/ents.js b/shared/modules/ents.js index bb09c81..7dc6529 100644 --- a/shared/modules/ents.js +++ b/shared/modules/ents.js @@ -21,11 +21,15 @@ CATAN.ents = (function(CATAN) { this.spawned.push(e); return e; } - }; + } + + module.get = function(name) { + return this.registered[name]; + } module.register = function(name,ent) { this.registered[name] = ent; - }; + } module.getAll = function() { return this.spawned; diff --git a/shared/schemas/classic.js b/shared/schemas/classic.js index 2863fdd..e0cec8b 100644 --- a/shared/schemas/classic.js +++ b/shared/schemas/classic.js @@ -149,19 +149,30 @@ GAMEMODE.Special = [ // Default Catan Board Arrangement // 0 = No tile -// 1 = Resource -// 2 = Dock? +// 1 = Land (resources) +// 2 = Sea GAMEMODE.getGrid = function() { - return [[0,1,1,1,0], + /*return [[0,1,1,1,0], [1,1,1,1,1], [1,1,1,1,1], [1,1,1,1,1], - [0,0,1,0,0]]; + [0,0,1,0,0]];*/ + + return [ + [0,0,0,2,0,0,0], + [0,2,2,1,2,2,0], + [2,1,1,1,1,1,2], + [2,1,1,1,1,1,2], + [2,1,1,1,1,1,2], + [0,2,1,1,1,2,0], + [0,0,2,2,2,0,0] + ]; } if(SERVER) { GAMEMODE.MaxPlayers = 4; + GAMEMODE.NumDocks = 5; GAMEMODE.getResources = function() {