🚀 [GAME] Play SOLITAIRE!!! another awesome game! 🚀
RolandJLevy (759)

This game is so addictive - it tests your speed, logic and skill - it’s a race against time….

I built this from scratch in 10 days using vanilla JS and CSS. It's really fun to play. Below is a demo and instructions. See if you can finish with just one marble remaining in the centre of the board - there is a 1,000 point bonus if you can do it! 😄

⚡ Solitaire ⚡

Links 🔗

Demo 🏁

https://github.com/rolandjlevy/js-solitaire-game/blob/master/images/solitaire-demo-large.gif?raw=true

How to Play 👉

  • Aim of the game
    Take away as many marbles as possible in the 100 seconds countdown.
  • How to take away marbles
    Select a marble by clicking on it so it turns blue, then place it over an adjacent marble into an empty space. The marble you move over will be taken. To deselect a marble, click on it again so it turns from blue to gold. See the demo above ⬆
  • Scoring
    Each marble removed updates the score by the total marbles taken multiplied by the total seconds remaining. Eg, 20 marbles taken in 40 seconds scores 800. Finish the game at any time to submit your score to the Leader Board.
  • Bonus points
    If you finish with just one marble remaining, which is 'Solitaire', you get a bonus 500 points, and if your last marble finishes in the centre of the board the bonus is 1,000 points!

Features 💡

  • Built from scratch with Vanilla JavaScript and CSS; no front-end frameworks or libraries like React, Vue etc...
  • Completely responsive and mobile friendly
  • Includes Help section and Leader board
  • Scores are saved on the back-end with Google Firebase
You are viewing a single comment. View All
AmazingMech2418 (1016)

You need to amp up your security. Great game though!

AmazingMech2418 (1016)

@AmazingMech2418 Also, it appears as though you include your Firebase DB key in the obfuscated JS files. I'd recommend using Node and an ENV file instead.

RolandJLevy (759)

Hi @AmazingMech2418, thanks for pointing that out. Yes, I normally use a .env file in Node to hide API keys but this started as an HTML / CSS repl and I don't know how to convert it to a Node project without starting a new repl from scratch. Any ideas?

AmazingMech2418 (1016)

@rjlevy Unfortunately, HTML/CSS/JS repls don't work the same way as normal repls, so you can't use a .replit file for it, but you could potentially just create another repl as a server that contains all of your API keys and sends requests to the Firebase API.

RolandJLevy (759)

@AmazingMech2418 are .env files always hidden from other repl users?

AmazingMech2418 (1016)

@rjlevy Yes. However, strangely, any files that have anything before the "." are visible, so you must make sure the file is just .env.

RolandJLevy (759)

@AmazingMech2418 thanks, what do you mean by files that have anything before the "." are visible? Do you mean we shouldn't name files like this: name.env or name.gitignore?

AmazingMech2418 (1016)

@rjlevy You're welcome! Yes, that is what I mean.

RolandJLevy (759)

Hi @AmazingMech2418, thanks so another repl with the API keys sends the request but how would the game receive the responses if it's in another repl?

AmazingMech2418 (1016)

@rjlevy Yes. You'd just use the other repl as a middle-way between the database and the game just to prevent you from sharing the API keys.

RolandJLevy (759)

@AmazingMech2418, thanks - that sounds good. Where in the game would the response from the db be loaded and how?

AmazingMech2418 (1016)

@rjlevy Basically, you'll just create your own API endpoint in the new repl using Express or just a plain Node.js server that will communicate with the server so your API key isn't given away.

RolandJLevy (759)

@AmazingMech2418 ok, thanks. I can make an endpoint in express but when I access that endpoint from the game in an HTML repl will I be exposing the response from the API (the API keys) in the game anyway?

AmazingMech2418 (1016)

@rjlevy The API keys would only be used in the new server to access the database API. The only things that would be exposed are the database responses which are public in the leaderboard anyways.

RolandJLevy (759)

Hi @AmazingMech2418, thanks a lot for your help - I think it's much clearer for me now so I made a simple example of what you suggested...

This has been a great learning experience, so thanks again!