/doc/design/client_stuff/index.html
HTML | 169 lines | 138 code | 31 blank | 0 comment | 0 complexity | 522fec9a8e4e4dcb6897eb25bf4d1dbf MD5 | raw file
Possible License(s): BSD-3-Clause
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <script src="js/lib/jquery.js"></script>
- <script src="js/lib/underscore.js"></script>
- <script src="js/lib/backbone.js"></script>
- <title>Blockus</title>
- <script>
- window.blokus = (function () {
- // URLs for REST
- var urls = {
- game: "/api/rest/game/",
- pieceMaster: "/api/rest/piece-master/",
- piece: "/api/rest/piece/",
- player: "/api/rest/player/"
- },
- // MODELS
- Game = Backbone.Model.extend({
- defaults: {
- id: undefined,
- playerIds: undefined,
- colourTurn: undefined // Colour whose turn it is
- }
- }),
- PieceMaster = Backbone.Model.extend({
- defaults: {
- id: undefined,
- data: undefined
- }
- }),
- Piece = Backbone.Model.extend({
- defaults: {
- id: undefined,
- x: undefined,
- y: undefined,
- rotation: undefined,
- flip: undefined
- }
- }),
- Player = Backbone.Model.extend({
- defaults: {
- id: undefined,
- colours: undefined
- }
- }),
-
- // COLLECTIONs
- GameCollection = Backbone.Collection.extend({
- model: Game,
- url: urls.game
- }),
-
- PieceMasterCollection = Backbone.Collection.extend({
- model: PieceMaster,
- url: urls.pieceMaster
- }),
- PieceCollection = Backbone.Collection.extend({
- model: Piece,
- url: urls.piece
- }),
- PlayerCollection = Backbone.Collection.extend({
- model: Player,
- url: urls.player
- });
- // Define the collection of piece masters
- var pieceMasters = new PieceMasterCollection()
-
- // TODO: replace with pieceMasters.fetch();
- pieceMasters.add([
- {
- id: 0,
- data: [ [0, 1, 0],
- [1, 1, 1],
- [0, 0, 1] ]
- },
- {
- id: 1,
- data: [ [0, 1, 0],
- [1, 1, 0] ]
- },
- {
- id: 2,
- data: [ [1, 1],
- [1, 1],
- [0, 1] ]
- }
- ]);
- pieces = new PieceCollection();
- // TODO: replace the pieces.fetch()
- pieces.add([
- {
- pieceMaster: 2,
- rotation: 0,
- x: 2,
- y: 9,
- flip: true,
- colour: "red"
- },
- {
- pieceMaster: 0,
- rotation: 1,
- x: 4,
- y: 2,
- flip: false,
- colour: "blue"
- }
- ]);
- var createBoard = function () {
-
- };
- $(document).ready(function () {
- createBoard();
- });
- var Board = function () {
-
- }
- _(Board.prototype).extend({
- addPiece: function() {},
- removePiece: function () {}
- })
-
- var board1 = new Board();
- return {
- urls: urls,
- // Models
- Game: Game,
- PieceMaster: PieceMaster,
- Piece: Piece,
- Player: Player,
- // Collections
- GameCollection: GameCollection,
- PieceMasterCollection: PieceMasterCollection,
- PieceCollection: PieceCollection,
- PlayerCollection: PlayerCollection,
- pieceMasters: pieceMasters,
- pieces: pieces,
- /*createBoard: createBoard*/
- };
- }(jQuery));
- </script>
- </head>
- <body>
- </body>
- </html>