PageRenderTime 45ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/doc/design/client_stuff/index.html

https://bitbucket.org/bahman/comp3001-group-blokus
HTML | 169 lines | 138 code | 31 blank | 0 comment | 0 complexity | 522fec9a8e4e4dcb6897eb25bf4d1dbf MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3. <head>
  4. <script src="js/lib/jquery.js"></script>
  5. <script src="js/lib/underscore.js"></script>
  6. <script src="js/lib/backbone.js"></script>
  7. <title>Blockus</title>
  8. <script>
  9. window.blokus = (function () {
  10. // URLs for REST
  11. var urls = {
  12. game: "/api/rest/game/",
  13. pieceMaster: "/api/rest/piece-master/",
  14. piece: "/api/rest/piece/",
  15. player: "/api/rest/player/"
  16. },
  17. // MODELS
  18. Game = Backbone.Model.extend({
  19. defaults: {
  20. id: undefined,
  21. playerIds: undefined,
  22. colourTurn: undefined // Colour whose turn it is
  23. }
  24. }),
  25. PieceMaster = Backbone.Model.extend({
  26. defaults: {
  27. id: undefined,
  28. data: undefined
  29. }
  30. }),
  31. Piece = Backbone.Model.extend({
  32. defaults: {
  33. id: undefined,
  34. x: undefined,
  35. y: undefined,
  36. rotation: undefined,
  37. flip: undefined
  38. }
  39. }),
  40. Player = Backbone.Model.extend({
  41. defaults: {
  42. id: undefined,
  43. colours: undefined
  44. }
  45. }),
  46. // COLLECTIONs
  47. GameCollection = Backbone.Collection.extend({
  48. model: Game,
  49. url: urls.game
  50. }),
  51. PieceMasterCollection = Backbone.Collection.extend({
  52. model: PieceMaster,
  53. url: urls.pieceMaster
  54. }),
  55. PieceCollection = Backbone.Collection.extend({
  56. model: Piece,
  57. url: urls.piece
  58. }),
  59. PlayerCollection = Backbone.Collection.extend({
  60. model: Player,
  61. url: urls.player
  62. });
  63. // Define the collection of piece masters
  64. var pieceMasters = new PieceMasterCollection()
  65. // TODO: replace with pieceMasters.fetch();
  66. pieceMasters.add([
  67. {
  68. id: 0,
  69. data: [ [0, 1, 0],
  70. [1, 1, 1],
  71. [0, 0, 1] ]
  72. },
  73. {
  74. id: 1,
  75. data: [ [0, 1, 0],
  76. [1, 1, 0] ]
  77. },
  78. {
  79. id: 2,
  80. data: [ [1, 1],
  81. [1, 1],
  82. [0, 1] ]
  83. }
  84. ]);
  85. pieces = new PieceCollection();
  86. // TODO: replace the pieces.fetch()
  87. pieces.add([
  88. {
  89. pieceMaster: 2,
  90. rotation: 0,
  91. x: 2,
  92. y: 9,
  93. flip: true,
  94. colour: "red"
  95. },
  96. {
  97. pieceMaster: 0,
  98. rotation: 1,
  99. x: 4,
  100. y: 2,
  101. flip: false,
  102. colour: "blue"
  103. }
  104. ]);
  105. var createBoard = function () {
  106. };
  107. $(document).ready(function () {
  108. createBoard();
  109. });
  110. var Board = function () {
  111. }
  112. _(Board.prototype).extend({
  113. addPiece: function() {},
  114. removePiece: function () {}
  115. })
  116. var board1 = new Board();
  117. return {
  118. urls: urls,
  119. // Models
  120. Game: Game,
  121. PieceMaster: PieceMaster,
  122. Piece: Piece,
  123. Player: Player,
  124. // Collections
  125. GameCollection: GameCollection,
  126. PieceMasterCollection: PieceMasterCollection,
  127. PieceCollection: PieceCollection,
  128. PlayerCollection: PlayerCollection,
  129. pieceMasters: pieceMasters,
  130. pieces: pieces,
  131. /*createBoard: createBoard*/
  132. };
  133. }(jQuery));
  134. </script>
  135. </head>
  136. <body>
  137. </body>
  138. </html>