Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am having issues with the num generator not always seeing that a sq… #550

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1. Replace `<your_account>` with your Github username in the link
- [DEMO LINK](https://<your_account>.github.io/js_2048_game/)
- [DEMO LINK](https://spencerspe.github.io/js_2048_game/)
2. Follow [this instructions](https://mate-academy.github.io/layout_task-guideline/)
- Run `npm run test` command to test your code;
- Run `npm run test:only -- -n` to run fast test ignoring linter;
Expand All @@ -10,7 +10,7 @@
Hey! Are you ready for a real hard check of your JavaScript skills, ninja?
If you are still here, let's do it.

In this task, you need to implement the 2048 game like in [this reference](https://play2048.co/)
In this task, you need to implement the 2048 game like in [this reference] )
Don't play for too long! We need you to write the code!

Okay, what do we have?
Expand All @@ -34,7 +34,7 @@ Okay, okay. Also, we have some rules:
10) Change the `Start` button to `Restart` after the first move.
11) Increase score with each move. The score should be increased by the sum of all merged cells.

Hints:
Hints:
- You have class `field-cell--%cell_value%`, for styling cell in the game.
- Use `hidden` class for hiding elements on page.
- Use `start`, `restart` classes for the main button for different styles.
Expand Down
Binary file added reports/assets/MaterialIcons-Regular.woff
Binary file not shown.
Binary file added reports/assets/MaterialIcons-Regular.woff2
Binary file not shown.
14 changes: 14 additions & 0 deletions reports/assets/app.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions reports/assets/app.js

Large diffs are not rendered by default.

Binary file added reports/assets/roboto-light-webfont.woff
Binary file not shown.
Binary file added reports/assets/roboto-light-webfont.woff2
Binary file not shown.
Binary file added reports/assets/roboto-medium-webfont.woff
Binary file not shown.
Binary file added reports/assets/roboto-medium-webfont.woff2
Binary file not shown.
Binary file added reports/assets/roboto-regular-webfont.woff
Binary file not shown.
Binary file added reports/assets/roboto-regular-webfont.woff2
Binary file not shown.
2 changes: 2 additions & 0 deletions reports/report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!doctype html>
<html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Mochawesome Report</title><link rel="stylesheet" href="assets/app.css"/></head><body data-raw="{&quot;stats&quot;:{&quot;suites&quot;:1,&quot;tests&quot;:7,&quot;passes&quot;:7,&quot;pending&quot;:0,&quot;failures&quot;:0,&quot;start&quot;:&quot;2023-11-14T09:34:02.792Z&quot;,&quot;end&quot;:&quot;2023-11-14T09:34:32.616Z&quot;,&quot;duration&quot;:29759,&quot;testsRegistered&quot;:7,&quot;passPercent&quot;:100,&quot;pendingPercent&quot;:0,&quot;other&quot;:0,&quot;hasOther&quot;:false,&quot;skipped&quot;:0,&quot;hasSkipped&quot;:false},&quot;results&quot;:[{&quot;uuid&quot;:&quot;833d9ab8-a0ae-4751-970e-820a2a244b5a&quot;,&quot;title&quot;:&quot;&quot;,&quot;fullFile&quot;:&quot;cypress/integration/js2048Game.spec.js&quot;,&quot;file&quot;:&quot;cypress/integration/js2048Game.spec.js&quot;,&quot;beforeHooks&quot;:[],&quot;afterHooks&quot;:[],&quot;tests&quot;:[],&quot;suites&quot;:[{&quot;uuid&quot;:&quot;4d6daf4b-f43a-42bd-8f18-7a4406acf4c3&quot;,&quot;title&quot;:&quot;2048 game&quot;,&quot;fullFile&quot;:&quot;&quot;,&quot;file&quot;:&quot;&quot;,&quot;beforeHooks&quot;:[],&quot;afterHooks&quot;:[],&quot;tests&quot;:[{&quot;title&quot;:&quot;should show the initial score&quot;,&quot;fullTitle&quot;:&quot;2048 game should show the initial score&quot;,&quot;timedOut&quot;:null,&quot;duration&quot;:295,&quot;state&quot;:&quot;passed&quot;,&quot;speed&quot;:&quot;slow&quot;,&quot;pass&quot;:true,&quot;fail&quot;:false,&quot;pending&quot;:false,&quot;context&quot;:null,&quot;code&quot;:&quot;cy.get(&#x27;.button.start&#x27;).click();\ncy.get(&#x27;.game-score&#x27;).should(&#x27;have.value&#x27;, &#x27;&#x27;);&quot;,&quot;err&quot;:{},&quot;uuid&quot;:&quot;96e50567-4ad5-434a-8edf-99b2963ec379&quot;,&quot;parentUUID&quot;:&quot;4d6daf4b-f43a-42bd-8f18-7a4406acf4c3&quot;,&quot;isHook&quot;:false,&quot;skipped&quot;:false},{&quot;title&quot;:&quot;should show the score shuffling to the left and up only&quot;,&quot;fullTitle&quot;:&quot;2048 game should show the score shuffling to the left and up only&quot;,&quot;timedOut&quot;:null,&quot;duration&quot;:555,&quot;state&quot;:&quot;passed&quot;,&quot;speed&quot;:&quot;slow&quot;,&quot;pass&quot;:true,&quot;fail&quot;:false,&quot;pending&quot;:false,&quot;context&quot;:null,&quot;code&quot;:&quot;cy.shuffleBoxes(&#x27;{leftArrow}&#x27;, &#x27;{upArrow}&#x27;, 3);\ncy.get(&#x27;.game-score&#x27;).invoke(&#x27;text&#x27;).then(parseFloat).should(&#x27;be.gt&#x27;, 1);&quot;,&quot;err&quot;:{},&quot;uuid&quot;:&quot;4a4b4b3c-aec8-4e81-a49b-5a1746d7102e&quot;,&quot;parentUUID&quot;:&quot;4d6daf4b-f43a-42bd-8f18-7a4406acf4c3&quot;,&quot;isHook&quot;:false,&quot;skipped&quot;:false},{&quot;title&quot;:&quot;should show the score shuffling to the right and up only&quot;,&quot;fullTitle&quot;:&quot;2048 game should show the score shuffling to the right and up only&quot;,&quot;timedOut&quot;:null,&quot;duration&quot;:543,&quot;state&quot;:&quot;passed&quot;,&quot;speed&quot;:&quot;slow&quot;,&quot;pass&quot;:true,&quot;fail&quot;:false,&quot;pending&quot;:false,&quot;context&quot;:null,&quot;code&quot;:&quot;cy.shuffleBoxes(&#x27;{rightArrow}&#x27;, &#x27;{upArrow}&#x27;, 3);\ncy.get(&#x27;.game-score&#x27;).invoke(&#x27;text&#x27;).then(parseFloat).should(&#x27;be.gt&#x27;, 1);&quot;,&quot;err&quot;:{},&quot;uuid&quot;:&quot;f4b2e1bf-5376-4afc-af3d-897ab5a4bdd2&quot;,&quot;parentUUID&quot;:&quot;4d6daf4b-f43a-42bd-8f18-7a4406acf4c3&quot;,&quot;isHook&quot;:false,&quot;skipped&quot;:false},{&quot;title&quot;:&quot;should show the score shuffling to the right and down only&quot;,&quot;fullTitle&quot;:&quot;2048 game should show the score shuffling to the right and down only&quot;,&quot;timedOut&quot;:null,&quot;duration&quot;:551,&quot;state&quot;:&quot;passed&quot;,&quot;speed&quot;:&quot;slow&quot;,&quot;pass&quot;:true,&quot;fail&quot;:false,&quot;pending&quot;:false,&quot;context&quot;:null,&quot;code&quot;:&quot;cy.shuffleBoxes(&#x27;{rightArrow}&#x27;, &#x27;{downArrow}&#x27;, 3);\ncy.get(&#x27;.game-score&#x27;).invoke(&#x27;text&#x27;).then(parseFloat).should(&#x27;be.gt&#x27;, 1);&quot;,&quot;err&quot;:{},&quot;uuid&quot;:&quot;ba2c8e7e-0787-400e-8110-4114b6403c18&quot;,&quot;parentUUID&quot;:&quot;4d6daf4b-f43a-42bd-8f18-7a4406acf4c3&quot;,&quot;isHook&quot;:false,&quot;skipped&quot;:false},{&quot;title&quot;:&quot;should show the score shuffling to the left and down only&quot;,&quot;fullTitle&quot;:&quot;2048 game should show the score shuffling to the left and down only&quot;,&quot;timedOut&quot;:null,&quot;duration&quot;:536,&quot;state&quot;:&quot;passed&quot;,&quot;speed&quot;:&quot;slow&quot;,&quot;pass&quot;:true,&quot;fail&quot;:false,&quot;pending&quot;:false,&quot;context&quot;:null,&quot;code&quot;:&quot;cy.shuffleBoxes(&#x27;{leftArrow}&#x27;, &#x27;{downArrow}&#x27;, 3);\ncy.get(&#x27;.game-score&#x27;).invoke(&#x27;text&#x27;).then(parseFloat).should(&#x27;be.gt&#x27;, 1);&quot;,&quot;err&quot;:{},&quot;uuid&quot;:&quot;2c7b76d9-816f-4904-a5f0-600e050bbdd0&quot;,&quot;parentUUID&quot;:&quot;4d6daf4b-f43a-42bd-8f18-7a4406acf4c3&quot;,&quot;isHook&quot;:false,&quot;skipped&quot;:false},{&quot;title&quot;:&quot;should reset the score&quot;,&quot;fullTitle&quot;:&quot;2048 game should reset the score&quot;,&quot;timedOut&quot;:null,&quot;duration&quot;:623,&quot;state&quot;:&quot;passed&quot;,&quot;speed&quot;:&quot;slow&quot;,&quot;pass&quot;:true,&quot;fail&quot;:false,&quot;pending&quot;:false,&quot;context&quot;:null,&quot;code&quot;:&quot;cy.shuffleBoxes(&#x27;{leftArrow}&#x27;, &#x27;{downArrow}&#x27;, 3);\ncy.get(&#x27;.game-score&#x27;).invoke(&#x27;text&#x27;).then(parseFloat).should(&#x27;be.gt&#x27;, 1);\ncy.get(&#x27;.button.restart&#x27;).click();\ncy.get(&#x27;.game-score&#x27;).should(&#x27;have.value&#x27;, &#x27;&#x27;);&quot;,&quot;err&quot;:{},&quot;uuid&quot;:&quot;b431a7c6-2df2-435f-8c52-d2e7195b8587&quot;,&quot;parentUUID&quot;:&quot;4d6daf4b-f43a-42bd-8f18-7a4406acf4c3&quot;,&quot;isHook&quot;:false,&quot;skipped&quot;:false},{&quot;title&quot;:&quot;should show message in case of the loss&quot;,&quot;fullTitle&quot;:&quot;2048 game should show message in case of the loss&quot;,&quot;timedOut&quot;:null,&quot;duration&quot;:26656,&quot;state&quot;:&quot;passed&quot;,&quot;speed&quot;:&quot;slow&quot;,&quot;pass&quot;:true,&quot;fail&quot;:false,&quot;pending&quot;:false,&quot;context&quot;:null,&quot;code&quot;:&quot;cy.get(&#x27;.button.start&#x27;).click();\nfor (var n = 0; n &lt; 100; n++) {\n cy.get(&#x27;body&#x27;).type(&#x27;{rightArrow}&#x27;);\n cy.get(&#x27;body&#x27;).type(&#x27;{downArrow}&#x27;);\n cy.get(&#x27;body&#x27;).type(&#x27;{leftArrow}&#x27;);\n cy.get(&#x27;body&#x27;).type(&#x27;{upArrow}&#x27;);\n}\ncy.contains(&#x27;You lose! Restart the game?&#x27;).should(&#x27;be.visible&#x27;);&quot;,&quot;err&quot;:{},&quot;uuid&quot;:&quot;800e0bf0-6d0a-492a-9cbe-d9d31cea233e&quot;,&quot;parentUUID&quot;:&quot;4d6daf4b-f43a-42bd-8f18-7a4406acf4c3&quot;,&quot;isHook&quot;:false,&quot;skipped&quot;:false}],&quot;suites&quot;:[],&quot;passes&quot;:[&quot;96e50567-4ad5-434a-8edf-99b2963ec379&quot;,&quot;4a4b4b3c-aec8-4e81-a49b-5a1746d7102e&quot;,&quot;f4b2e1bf-5376-4afc-af3d-897ab5a4bdd2&quot;,&quot;ba2c8e7e-0787-400e-8110-4114b6403c18&quot;,&quot;2c7b76d9-816f-4904-a5f0-600e050bbdd0&quot;,&quot;b431a7c6-2df2-435f-8c52-d2e7195b8587&quot;,&quot;800e0bf0-6d0a-492a-9cbe-d9d31cea233e&quot;],&quot;failures&quot;:[],&quot;pending&quot;:[],&quot;skipped&quot;:[],&quot;duration&quot;:29759,&quot;root&quot;:false,&quot;rootEmpty&quot;:false,&quot;_timeout&quot;:2000}],&quot;passes&quot;:[],&quot;failures&quot;:[],&quot;pending&quot;:[],&quot;skipped&quot;:[],&quot;duration&quot;:0,&quot;root&quot;:true,&quot;rootEmpty&quot;:true,&quot;_timeout&quot;:2000}],&quot;meta&quot;:{&quot;mocha&quot;:{&quot;version&quot;:&quot;7.0.1&quot;},&quot;mochawesome&quot;:{&quot;options&quot;:{&quot;quiet&quot;:false,&quot;reportFilename&quot;:&quot;mochawesome&quot;,&quot;saveHtml&quot;:false,&quot;saveJson&quot;:true,&quot;consoleReporter&quot;:&quot;spec&quot;,&quot;useInlineDiffs&quot;:false,&quot;code&quot;:true},&quot;version&quot;:&quot;6.2.1&quot;},&quot;marge&quot;:{&quot;options&quot;:{&quot;reportDir&quot;:&quot;raw_reports&quot;,&quot;overwrite&quot;:false,&quot;html&quot;:false,&quot;json&quot;:true},&quot;version&quot;:&quot;5.1.0&quot;}}}" data-config="{&quot;reportFilename&quot;:&quot;report&quot;,&quot;reportDir&quot;:&quot;/Users/spencer/projects/js_2048_game/reports&quot;,&quot;reportTitle&quot;:&quot;js_2048_game&quot;,&quot;reportPageTitle&quot;:&quot;Mochawesome Report&quot;,&quot;inline&quot;:false,&quot;inlineAssets&quot;:false,&quot;cdn&quot;:false,&quot;charts&quot;:false,&quot;enableCharts&quot;:false,&quot;code&quot;:true,&quot;enableCode&quot;:true,&quot;autoOpen&quot;:false,&quot;overwrite&quot;:true,&quot;timestamp&quot;:false,&quot;ts&quot;:false,&quot;showPassed&quot;:true,&quot;showFailed&quot;:true,&quot;showPending&quot;:true,&quot;showSkipped&quot;:false,&quot;showHooks&quot;:&quot;failed&quot;,&quot;saveJson&quot;:false,&quot;saveHtml&quot;:true,&quot;dev&quot;:false,&quot;assetsDir&quot;:&quot;/Users/spencer/projects/js_2048_game/reports/assets&quot;,&quot;htmlFile&quot;:&quot;/Users/spencer/projects/js_2048_game/reports/report.html&quot;}"><div id="report"></div><script src="assets/app.js"></script></body></html>
219 changes: 219 additions & 0 deletions reports/report.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
{
"stats": {
"suites": 1,
"tests": 7,
"passes": 7,
"pending": 0,
"failures": 0,
"start": "2023-11-14T09:34:02.792Z",
"end": "2023-11-14T09:34:32.616Z",
"duration": 29759,
"testsRegistered": 7,
"passPercent": 100,
"pendingPercent": 0,
"other": 0,
"hasOther": false,
"skipped": 0,
"hasSkipped": false
},
"results": [
{
"uuid": "833d9ab8-a0ae-4751-970e-820a2a244b5a",
"title": "",
"fullFile": "cypress/integration/js2048Game.spec.js",
"file": "cypress/integration/js2048Game.spec.js",
"beforeHooks": [],
"afterHooks": [],
"tests": [],
"suites": [
{
"uuid": "4d6daf4b-f43a-42bd-8f18-7a4406acf4c3",
"title": "2048 game",
"fullFile": "",
"file": "",
"beforeHooks": [],
"afterHooks": [],
"tests": [
{
"title": "should show the initial score",
"fullTitle": "2048 game should show the initial score",
"timedOut": null,
"duration": 295,
"state": "passed",
"speed": "slow",
"pass": true,
"fail": false,
"pending": false,
"context": null,
"code": "cy.get('.button.start').click();\ncy.get('.game-score').should('have.value', '');",
"err": {},
"uuid": "96e50567-4ad5-434a-8edf-99b2963ec379",
"parentUUID": "4d6daf4b-f43a-42bd-8f18-7a4406acf4c3",
"isHook": false,
"skipped": false
},
{
"title": "should show the score shuffling to the left and up only",
"fullTitle": "2048 game should show the score shuffling to the left and up only",
"timedOut": null,
"duration": 555,
"state": "passed",
"speed": "slow",
"pass": true,
"fail": false,
"pending": false,
"context": null,
"code": "cy.shuffleBoxes('{leftArrow}', '{upArrow}', 3);\ncy.get('.game-score').invoke('text').then(parseFloat).should('be.gt', 1);",
"err": {},
"uuid": "4a4b4b3c-aec8-4e81-a49b-5a1746d7102e",
"parentUUID": "4d6daf4b-f43a-42bd-8f18-7a4406acf4c3",
"isHook": false,
"skipped": false
},
{
"title": "should show the score shuffling to the right and up only",
"fullTitle": "2048 game should show the score shuffling to the right and up only",
"timedOut": null,
"duration": 543,
"state": "passed",
"speed": "slow",
"pass": true,
"fail": false,
"pending": false,
"context": null,
"code": "cy.shuffleBoxes('{rightArrow}', '{upArrow}', 3);\ncy.get('.game-score').invoke('text').then(parseFloat).should('be.gt', 1);",
"err": {},
"uuid": "f4b2e1bf-5376-4afc-af3d-897ab5a4bdd2",
"parentUUID": "4d6daf4b-f43a-42bd-8f18-7a4406acf4c3",
"isHook": false,
"skipped": false
},
{
"title": "should show the score shuffling to the right and down only",
"fullTitle": "2048 game should show the score shuffling to the right and down only",
"timedOut": null,
"duration": 551,
"state": "passed",
"speed": "slow",
"pass": true,
"fail": false,
"pending": false,
"context": null,
"code": "cy.shuffleBoxes('{rightArrow}', '{downArrow}', 3);\ncy.get('.game-score').invoke('text').then(parseFloat).should('be.gt', 1);",
"err": {},
"uuid": "ba2c8e7e-0787-400e-8110-4114b6403c18",
"parentUUID": "4d6daf4b-f43a-42bd-8f18-7a4406acf4c3",
"isHook": false,
"skipped": false
},
{
"title": "should show the score shuffling to the left and down only",
"fullTitle": "2048 game should show the score shuffling to the left and down only",
"timedOut": null,
"duration": 536,
"state": "passed",
"speed": "slow",
"pass": true,
"fail": false,
"pending": false,
"context": null,
"code": "cy.shuffleBoxes('{leftArrow}', '{downArrow}', 3);\ncy.get('.game-score').invoke('text').then(parseFloat).should('be.gt', 1);",
"err": {},
"uuid": "2c7b76d9-816f-4904-a5f0-600e050bbdd0",
"parentUUID": "4d6daf4b-f43a-42bd-8f18-7a4406acf4c3",
"isHook": false,
"skipped": false
},
{
"title": "should reset the score",
"fullTitle": "2048 game should reset the score",
"timedOut": null,
"duration": 623,
"state": "passed",
"speed": "slow",
"pass": true,
"fail": false,
"pending": false,
"context": null,
"code": "cy.shuffleBoxes('{leftArrow}', '{downArrow}', 3);\ncy.get('.game-score').invoke('text').then(parseFloat).should('be.gt', 1);\ncy.get('.button.restart').click();\ncy.get('.game-score').should('have.value', '');",
"err": {},
"uuid": "b431a7c6-2df2-435f-8c52-d2e7195b8587",
"parentUUID": "4d6daf4b-f43a-42bd-8f18-7a4406acf4c3",
"isHook": false,
"skipped": false
},
{
"title": "should show message in case of the loss",
"fullTitle": "2048 game should show message in case of the loss",
"timedOut": null,
"duration": 26656,
"state": "passed",
"speed": "slow",
"pass": true,
"fail": false,
"pending": false,
"context": null,
"code": "cy.get('.button.start').click();\nfor (var n = 0; n < 100; n++) {\n cy.get('body').type('{rightArrow}');\n cy.get('body').type('{downArrow}');\n cy.get('body').type('{leftArrow}');\n cy.get('body').type('{upArrow}');\n}\ncy.contains('You lose! Restart the game?').should('be.visible');",
"err": {},
"uuid": "800e0bf0-6d0a-492a-9cbe-d9d31cea233e",
"parentUUID": "4d6daf4b-f43a-42bd-8f18-7a4406acf4c3",
"isHook": false,
"skipped": false
}
],
"suites": [],
"passes": [
"96e50567-4ad5-434a-8edf-99b2963ec379",
"4a4b4b3c-aec8-4e81-a49b-5a1746d7102e",
"f4b2e1bf-5376-4afc-af3d-897ab5a4bdd2",
"ba2c8e7e-0787-400e-8110-4114b6403c18",
"2c7b76d9-816f-4904-a5f0-600e050bbdd0",
"b431a7c6-2df2-435f-8c52-d2e7195b8587",
"800e0bf0-6d0a-492a-9cbe-d9d31cea233e"
],
"failures": [],
"pending": [],
"skipped": [],
"duration": 29759,
"root": false,
"rootEmpty": false,
"_timeout": 2000
}
],
"passes": [],
"failures": [],
"pending": [],
"skipped": [],
"duration": 0,
"root": true,
"rootEmpty": true,
"_timeout": 2000
}
],
"meta": {
"mocha": {
"version": "7.0.1"
},
"mochawesome": {
"options": {
"quiet": false,
"reportFilename": "mochawesome",
"saveHtml": false,
"saveJson": true,
"consoleReporter": "spec",
"useInlineDiffs": false,
"code": true
},
"version": "6.2.1"
},
"marge": {
"options": {
"reportDir": "raw_reports",
"overwrite": false,
"html": false,
"json": true
},
"version": "5.1.0"
}
}
}
Loading
Loading