diff --git a/app/controllers/MathSwipeController.coffee b/app/controllers/MathSwipeController.coffee index 60211f2..5121364 100644 --- a/app/controllers/MathSwipeController.coffee +++ b/app/controllers/MathSwipeController.coffee @@ -34,12 +34,13 @@ class MathSwipeController TrackingService.desktopView() @cursorToPointer() ShareGameService.setMessage() - @initialize window.location.hash, 3 + @initialize() # # Uncomment the following line to perform general tests # GeneralTests.tests @board - initialize: (hash, length = 3) -> + initialize: -> + length = 3 solutionPlacements = [] inputLengths = [] boardValues = [] @@ -91,7 +92,8 @@ class MathSwipeController @gameScene.clear() @goalContainer.clearGoals() ResetButton.unbindClick() - @initialize (window.location.hash = '') + HashingService.emptyHash() + @initialize() createGameScene: -> gameDom = document.getElementById('game') @@ -125,7 +127,9 @@ class MathSwipeController generateBoard: (inputs, length, solutionPlacements) -> DFS.setEquationsOnGrid length, inputs, AdjacentCellsCalculator, solutionPlacements - generateInputs: (inputLengths, goals = [], inputs = []) -> + generateInputs: (inputLengths) -> + goals = [] + inputs = [] for inputSize in inputLengths value = -1 while value < 1 or value > 300 diff --git a/app/services/HashingService.coffee b/app/services/HashingService.coffee index f62abaa..07e40cb 100644 --- a/app/services/HashingService.coffee +++ b/app/services/HashingService.coffee @@ -1,5 +1,10 @@ class HashingService + alphabet = ['"', '{', '}', '[', ']', ',', ':', + 'b', 'g', 'p', '1', '2', '3', '4', + '5', '6', '7', '8', '9', '0', + '+', '-', '*'] + @reloadPageWithHash: (board, solutionPlacements, SolutionService) -> unless @checkSolutionPlacements board, solutionPlacements, SolutionService @emptyHash() @@ -23,9 +28,9 @@ class HashingService btoa(JSON.stringify {b: boardValues, g: goals, p: solutionPlacements}) - @decodeMap: () -> + @decodeMap: -> try - decoded_s = atob window.location.hash.substr(1, window.location.hash.length) + decoded_s = atob window.location.hash.substr(1, window.location.hash.length) decoded = JSON.parse decoded_s catch e decoded = null @@ -47,10 +52,6 @@ class HashingService @regexPass decoded @regexPass: (decoded) -> - alphabet = ['"', '{', '}', '[', ']', ',', ':', - 'b', 'g', 'p', '1', '2', '3', '4', - '5', '6', '7', '8', '9', '0', - '+', '-', '*'] for char in decoded return false if char not in alphabet true @@ -122,4 +123,4 @@ class HashingService @tempBoard.boardValues[r1][c1] = @tempBoard.boardValues[r2][c2] @tempBoard.boardValues[r2][c2] = temp -module.exports = HashingService \ No newline at end of file +module.exports = HashingService diff --git a/app/services/ShareGameService.coffee b/app/services/ShareGameService.coffee index 6c61d59..75ca1ff 100644 --- a/app/services/ShareGameService.coffee +++ b/app/services/ShareGameService.coffee @@ -1,14 +1,8 @@ -$ = require 'jquery' +TwitterGameService = require './TwitterGameService' class ShareGameService @setMessage: -> - possible = ['Play MathSwipe with me! Try to beat my score at', - 'Play MathSwipe with me! Try to solve my board at', - 'Play MathSwipe with me! Solve my puzzle at'] - text = possible[Math.floor(Math.random() * 3)] - $( '#tweet' ).attr( 'data-text' , text ) - console.log $('#fb-share') - $( '#fb-share' ).attr( 'data-href' , window.location.hash ) + TwitterGameService.setTweet() module.exports = ShareGameService diff --git a/app/services/SolutionService.coffee b/app/services/SolutionService.coffee index b82286c..77e2028 100644 --- a/app/services/SolutionService.coffee +++ b/app/services/SolutionService.coffee @@ -20,7 +20,7 @@ class SolutionService @RunningSum.display @RunningSum.solutionOperatorString false - finished: -> @solution[@solution.length - 1] not in "+-*" + finished: -> @solution[@solution.length - 1] not in '+-*' isCompleteExpression: -> @solution.search(/-?\d+[-+\*]\d+/g) is 0 diff --git a/app/services/TwitterGameService.coffee b/app/services/TwitterGameService.coffee new file mode 100644 index 0000000..aeb8702 --- /dev/null +++ b/app/services/TwitterGameService.coffee @@ -0,0 +1,12 @@ +$ = require 'jquery' + +class TwitterGameService + + @setTweet: -> + possible = ['Play MathSwipe with me! Try to beat my score at', + 'Play MathSwipe with me! Try to solve my board at', + 'Play MathSwipe with me! Solve my puzzle at'] + text = possible[Math.floor(Math.random() * 3)] + $( '#tweet' ).attr( 'data-text' , text ) + +module.exports = TwitterGameService diff --git a/bundle.js b/bundle.js index 1591352..7a8cc0a 100644 --- a/bundle.js +++ b/bundle.js @@ -65,7 +65,7 @@ Tuple = __webpack_require__(/*! ./app/models/Tuple */ 5); - Two = __webpack_require__(/*! two.js */ 26); + Two = __webpack_require__(/*! two.js */ 27); game = new MathSwipeController; @@ -9324,21 +9324,21 @@ ShareGameService = __webpack_require__(/*! ../services/ShareGameService */ 18); - SolutionService = __webpack_require__(/*! ../services/SolutionService */ 19); + SolutionService = __webpack_require__(/*! ../services/SolutionService */ 20); - Title = __webpack_require__(/*! ../services/Title */ 20); + Title = __webpack_require__(/*! ../services/Title */ 21); TrackingService = __webpack_require__(/*! ../services/TrackingService */ 8); - Board = __webpack_require__(/*! ../views/Board */ 21); + Board = __webpack_require__(/*! ../views/Board */ 22); - Cell = __webpack_require__(/*! ../views/Cell */ 22); + Cell = __webpack_require__(/*! ../views/Cell */ 23); - Colors = __webpack_require__(/*! ../views/Colors */ 23); + Colors = __webpack_require__(/*! ../views/Colors */ 24); - GoalContainer = __webpack_require__(/*! ../views/GoalContainer */ 24); + GoalContainer = __webpack_require__(/*! ../views/GoalContainer */ 25); - GeneralTests = __webpack_require__(/*! ../../tests/controllers/GeneralTests */ 25); + GeneralTests = __webpack_require__(/*! ../../tests/controllers/GeneralTests */ 26); MathSwipeController = (function() { function MathSwipeController() { @@ -9354,14 +9354,12 @@ this.cursorToPointer(); } ShareGameService.setMessage(); - this.initialize(window.location.hash, 3); + this.initialize(); } - MathSwipeController.prototype.initialize = function(hash, length) { - var boardValues, decoded, goals, inputLengths, inputs, ref, ref1, solutionPlacements; - if (length == null) { - length = 3; - } + MathSwipeController.prototype.initialize = function() { + var boardValues, decoded, goals, inputLengths, inputs, length, ref, ref1, solutionPlacements; + length = 3; solutionPlacements = []; inputLengths = []; boardValues = []; @@ -9419,7 +9417,8 @@ this.gameScene.clear(); this.goalContainer.clearGoals(); ResetButton.unbindClick(); - return this.initialize((window.location.hash = '')); + HashingService.emptyHash(); + return this.initialize(); }; MathSwipeController.prototype.createGameScene = function() { @@ -9462,14 +9461,10 @@ return DFS.setEquationsOnGrid(length, inputs, AdjacentCellsCalculator, solutionPlacements); }; - MathSwipeController.prototype.generateInputs = function(inputLengths, goals, inputs) { - var expression, i, inputSize, len, value; - if (goals == null) { - goals = []; - } - if (inputs == null) { - inputs = []; - } + MathSwipeController.prototype.generateInputs = function(inputLengths) { + var expression, goals, i, inputSize, inputs, len, value; + goals = []; + inputs = []; for (i = 0, len = inputLengths.length; i < len; i++) { inputSize = inputLengths[i]; value = -1; @@ -10140,8 +10135,12 @@ indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; HashingService = (function() { + var alphabet; + function HashingService() {} + alphabet = ['"', '{', '}', '[', ']', ',', ':', 'b', 'g', 'p', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '+', '-', '*']; + HashingService.reloadPageWithHash = function(board, solutionPlacements, SolutionService) { if (!this.checkSolutionPlacements(board, solutionPlacements, SolutionService)) { this.emptyHash(); @@ -10203,8 +10202,7 @@ }; HashingService.regexPass = function(decoded) { - var alphabet, char, k, len; - alphabet = ['"', '{', '}', '[', ']', ',', ':', 'b', 'g', 'p', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '+', '-', '*']; + var char, k, len; for (k = 0, len = decoded.length; k < len; k++) { char = decoded[k]; if (indexOf.call(alphabet, char) < 0) { @@ -10618,20 +10616,15 @@ \**********************************************/ /***/ function(module, exports, __webpack_require__) { - var $, ShareGameService; + var ShareGameService, TwitterGameService; - $ = __webpack_require__(/*! jquery */ 2); + TwitterGameService = __webpack_require__(/*! ./TwitterGameService */ 19); ShareGameService = (function() { function ShareGameService() {} ShareGameService.setMessage = function() { - var possible, text; - possible = ['Play MathSwipe with me! Try to beat my score at', 'Play MathSwipe with me! Try to solve my board at', 'Play MathSwipe with me! Solve my puzzle at']; - text = possible[Math.floor(Math.random() * 3)]; - $('#tweet').attr('data-text', text); - console.log($('#fb-share')); - return $('#fb-share').attr('data-href', window.location.hash); + return TwitterGameService.setTweet(); }; return ShareGameService; @@ -10643,6 +10636,34 @@ /***/ }, /* 19 */ +/*!************************************************!*\ + !*** ./app/services/TwitterGameService.coffee ***! + \************************************************/ +/***/ function(module, exports, __webpack_require__) { + + var $, TwitterGameService; + + $ = __webpack_require__(/*! jquery */ 2); + + TwitterGameService = (function() { + function TwitterGameService() {} + + TwitterGameService.setTweet = function() { + var possible, text; + possible = ['Play MathSwipe with me! Try to beat my score at', 'Play MathSwipe with me! Try to solve my board at', 'Play MathSwipe with me! Solve my puzzle at']; + text = possible[Math.floor(Math.random() * 3)]; + return $('#tweet').attr('data-text', text); + }; + + return TwitterGameService; + + })(); + + module.exports = TwitterGameService; + + +/***/ }, +/* 20 */ /*!*********************************************!*\ !*** ./app/services/SolutionService.coffee ***! \*********************************************/ @@ -10682,7 +10703,7 @@ SolutionService.prototype.finished = function() { var ref; - return ref = this.solution[this.solution.length - 1], indexOf.call("+-*", ref) < 0; + return ref = this.solution[this.solution.length - 1], indexOf.call('+-*', ref) < 0; }; SolutionService.prototype.isCompleteExpression = function() { @@ -10708,7 +10729,7 @@ /***/ }, -/* 20 */ +/* 21 */ /*!***********************************!*\ !*** ./app/services/Title.coffee ***! \***********************************/ @@ -10735,7 +10756,7 @@ /***/ }, -/* 21 */ +/* 22 */ /*!********************************!*\ !*** ./app/views/Board.coffee ***! \********************************/ @@ -10954,7 +10975,7 @@ /***/ }, -/* 22 */ +/* 23 */ /*!*******************************!*\ !*** ./app/views/Cell.coffee ***! \*******************************/ @@ -10964,7 +10985,7 @@ $ = __webpack_require__(/*! jquery */ 2); - Colors = __webpack_require__(/*! ./Colors */ 23); + Colors = __webpack_require__(/*! ./Colors */ 24); Cell = (function() { function Cell(col1, row1, size, scene, board, clickHandler, symbolBlueprint) { @@ -11162,7 +11183,7 @@ /***/ }, -/* 23 */ +/* 24 */ /*!*********************************!*\ !*** ./app/views/Colors.coffee ***! \*********************************/ @@ -11185,7 +11206,7 @@ /***/ }, -/* 24 */ +/* 25 */ /*!****************************************!*\ !*** ./app/views/GoalContainer.coffee ***! \****************************************/ @@ -11240,7 +11261,7 @@ /***/ }, -/* 25 */ +/* 26 */ /*!***********************************************!*\ !*** ./tests/controllers/GeneralTests.coffee ***! \***********************************************/ @@ -11339,7 +11360,7 @@ /***/ }, -/* 26 */ +/* 27 */ /*!*******************************!*\ !*** ./~/two.js/build/two.js ***! \*******************************/ diff --git a/index.html b/index.html index 76c6514..b7c1082 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,8 @@ + + - - - - - - - -
-
- -

MathSwipe

@@ -57,13 +28,11 @@
-
+

Reset

New Game

-
-

diff --git a/public/assets/images/favicon.ico b/public/assets/images/favicon.ico new file mode 100644 index 0000000..43402f5 Binary files /dev/null and b/public/assets/images/favicon.ico differ diff --git a/public/assets/stylesheets/GameBackground.css b/public/assets/stylesheets/GameBackground.css index 845f3d1..640ef04 100644 --- a/public/assets/stylesheets/GameBackground.css +++ b/public/assets/stylesheets/GameBackground.css @@ -31,7 +31,7 @@ body { text-align: center; font-size: 30px; } .center-column .game-desc-hr { - margin: 40px 0px 20px 0px; } + margin: 10px 0px 20px 0px; } .center-column #how-to-play { margin: 10px auto 10px auto; width: 95%; @@ -62,14 +62,12 @@ body { .game-button-wrapper { text-align: center; margin: 10px 0px 20px 0px; } - .game-button-wrapper .reset-button { - margin: 6px 0 0 0; } .game-button-wrapper .game-btn { height: 40px; word-wrap: break-word; display: inline-block; width: 40%; - margin: 0px 10px; + margin: 0 0 10px; background-color: Transparent; border-style: solid; border-color: #a7acb0; diff --git a/public/assets/stylesheets/GameBackground.sass b/public/assets/stylesheets/GameBackground.sass index 1d42672..1431462 100644 --- a/public/assets/stylesheets/GameBackground.sass +++ b/public/assets/stylesheets/GameBackground.sass @@ -36,7 +36,7 @@ body font-size: 30px .game-desc-hr - margin: 40px 0px 20px 0px + margin: 10px 0px 20px 0px #how-to-play margin: 10px auto 10px auto @@ -72,15 +72,12 @@ body text-align: center margin: 10px 0px 20px 0px - .reset-button - margin: 6px 0 0 0 - .game-btn height: 40px word-wrap: break-word display: inline-block width: 40% - margin: 0px 10px + margin: 0 0 10px background-color: Transparent border-style: solid border-color: #a7acb0