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

Centralised place to store all data #38

Open
farazxameer opened this issue Oct 3, 2018 · 14 comments
Open

Centralised place to store all data #38

farazxameer opened this issue Oct 3, 2018 · 14 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@farazxameer
Copy link
Contributor

We should be storing the game data in some centralised folder like/usr/lib/2048/ .

@plibither8
Copy link
Owner

Sounds like a great idea. But what about Windows?

@farazxameer
Copy link
Contributor Author

farazxameer commented Oct 4, 2018

Yes I thought about that, I guess in windows we run this game on git-bash, I saw there was a directory /usr/lib/ and we can access this dir with git-bash , so it will be cross platform.

@farazxameer
Copy link
Contributor Author

I'll try to implement this and test it both on Windows and linux, and with this I also want to properly deploy the binary and able to play the game from anywhere just like a command.

@plibither8
Copy link
Owner

This will be great! Waiting on it :)

@VishwasTamta
Copy link

We can use code for checking the operating system and if it find windows then the files can be saved in the windows user/documents directly or if it finds linux then /use/lib/2048.

@plibither8
Copy link
Owner

@farazxameer, @VishwasT has made a good point

@plibither8
Copy link
Owner

@farazxameer Any progress? 😄

@plibither8 plibither8 added enhancement New feature or request hacktoberfest labels Oct 8, 2018
@Carlovan
Copy link

I think it would be better to use ~/.config/2048.cpp/data in Linux and C:\Users\%USERNAME%\AppData\2048.cpp\data

@plibither8 plibither8 added the help wanted Extra attention is needed label Oct 11, 2018
@ronflima
Copy link

Instead of checking the operating system and write a lot of code to do so, use conditional compiling. After all, where data will be stored is dependent on the operating system. So, it makes little sense make system calls to evaluate what is the operating system in order to decide where to save stuff.

The best approach is to save data into user's home folder. For *nix operating systems you can do it on a single file on $HOME in a name like .2048. If you need several files, it can be a directory.

For Windows users, it should be a file or directory under user's home directory. There is a special directory only for that. The best is to encapsulate the way user's home directory is determined and let the implementation do the job. So, you can conditionally compile the implementation, letting the interface independent.

@plibither8
Copy link
Owner

Hey @ronflima! Thanks a lot for your inputs, your way certainly seems like the neatest and most correct way to do so. If you have time in your hands, please consider proposing a PR to implement the same. Thanks again 😄!

@tiendq
Copy link
Contributor

tiendq commented Oct 26, 2018

You can take a look at this repo for finding user data folder on operating systems, but I'd do as what @ronflima suggested.

@farazxameer
Copy link
Contributor Author

Hi, I got busy with my exam, it will be really good if anybody wants to implement this functionality.

@plibither8
Copy link
Owner

No problem! You can try implementing it, I don't think anyone has taken it up right now 😄

@aadit-n3rdy
Copy link

Hey! Can I try writing creating a PR if nobody is working on it already? I'm comfortable with C++ but this would be my first PR ever

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants