Solitaire game implemented by scratch on react.
In this project, it is possible to not only play solitaire (with drag and drop or by double clicking), but also visualize the previous scores and statistics of either an online player (subscribed by Firebase) or a local player. The main differences between these two types of players are the possibility for the online player to save their data through different devices or sessions and access to the top 10 highscores of every registered user. It also has support for english, portuguese, spanish and german.
npm install
npm start
Since this is a frontend project, there was no need to complicate and create a database, therefore it is used a backend-as-a-service, the Firebase.
The base structure of a user is the following:
{
createdAt: "04/08/2020, 10:31",
userName: "solitaireLover",
email: "solitaireLover@netlify.com",
hasSavedGame: false,
savedGame: {},
maxMoves: 170,
maxTime: 112,
nGames: 1,
settings: {
joyride: {
game: false,
gameOptions: false,
main: false,
scores: true,
statistics: true
}
},
history: [
{
date: "04/08/2020, 10:36",
finalScore: 170,
moves: 170,
nHints: 0,
seconds: 112,
time: "0:01:
}
],
graphs: {
moves: {
data: [
{ moves: 0, name: "]0, 34]" },
{ moves: 0, name: "]34, 68]" },
{ moves: 0, name: "]68, 102]" },
{ moves: 0, name: "]102, 136]" },
{ moves: 1, name: "]136, 170]" }
],
label: {
"]0, 34]": 0,
"]34, 68]": 0,
"]68, 102]": 0,
"]102, 136]": 0,
"]136, 170]": 1
}
},
time: {
data: [
{ seconds: 0, name: "]0, 23]" },
{ seconds: 0, name: "]23, 46]" },
{ seconds: 0, name: "]46, 69]" },
{ seconds: 0, name: "]69, 92]" },
{ seconds: 1, name: "]92, 115]" }
],
label: {
"]0, 23]": 0,
"]23, 46]": 0,
"]46, 69]": 0,
"]69, 92]": 0,
"]92, 115]": 1
}
},
winsRation: [
{ name: "Wins", value: 1 },
{ name: "Losts", value: 0 }
]
},
}
The base structure of the top highscores is the following:
highScores: [
{
userName: "solitaireLover",
finalScore: 170
}
]
For an user to sign up or sign in, it was given the options to either use the Google login or an email and password login (the password must follow a base set of rules).
As it was previously mentioned, this game can be played either by dragging and droping the cards or by double clicking. This moves make sure that:
- when a card is dropped in a wrong place, it goes back to the original position;
- more than one card can be dragged at once;
- when a card is double clicked it first tries to go to the goal spot, then to the bottom of a column and then to the first available empty spot;
- when a card is double clicked and there are no options to go, it stays at the original position;
- when a card is removed from a column and there are cards right bellow it that are not flipped, then the first one is flipped automatically.
Besides the normal solitaire gameplay, more options are available:
- undo and redo;
- pause and resume;
- show hints;
- restart;
- start new;
- exit;
- save.
When the user finishes a game, a modal is shown with all the game status, this information is stored and can be seen at the scores page as well.
The scores page is divided in two parts, the first is the user scores (by default is sorted by final scores) and the top ten highscores. This last part is different for online and local users. Online users see a list of the top ten highscores of all registered users and, since the local user has no access to others, it is listed the top ten highscores currently stored in the device session.
In the statistics page, the user can evaluate its win/loss ration, number of moves and time per game through graphs (pie and bar) displayed in a carousel or in a dashboard.
Is in the configuration page that an user can alter his username and language (english, portuguese, german and spanish). It is also possible to deactivate or activate the helps shown throughout the website.
- Refactor to Saga;
- Unit tests with jest;
- End-to-end tests with cypress;
- Button to send all the possible cards to the goal spots;
- Customization (background color and cards backs image);
- "Forgot password" option at sign in;
- Search for other users and visualize their scores.