Skip to content

Commit

Permalink
fix bug in updating stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdullah Jamal committed Jan 28, 2024
1 parent 2ec1f5a commit 62cdbdc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ________________________________________________________________________________
- [x] save game statistics in localStorage
- [x] add PWA support [article followed for PWA support](https://cloudbytes.dev/snippets/convert-a-pelican-website-to-pwa-using-workbox)
- [x] deploy PWA to play store [article for converting PWA to android app](https://developers.google.com/codelabs/pwa-in-play#0)
- [x] add support for chrome extension [article for adding support](https://dev.to/chromiumdev/shipping-pwas-as-chrome-extensions-3l5c)
- [ ] add audio in game
________________________________________________________________________________________________________

16 changes: 9 additions & 7 deletions js/setup/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,19 @@
statTable[i] = new Array(6);
}

// initializing statistics table
if(localStorage.getItem("stats") === null){
// initializing statistics table

for (var i = 0; i < 3; i++) {
for (var j = 0; j < 6; j++) {
statTable[i][j] = 0;
for (var i = 0; i < 3; i++) {
for (var j = 0; j < 6; j++) {
statTable[i][j] = 0;
}
}
}

if(localStorage.getItem("stats") == null){
localStorage.setItem("stats", Base64.encode(JSON.stringify(statTable)));
}
else{
statTable = JSON.parse(Base64.decode(localStorage.getItem("stats")));
}



0 comments on commit 62cdbdc

Please sign in to comment.