Home > Net >  Does hangman game needs a database?
Does hangman game needs a database?

Time:01-17

I am trying to design a hangman game in lucidchart. Just start to thinking about the data. If I decide to store them in database, what kinds of columns do I need?

I can think of columns:

(1) word: To store the actual word; (2) numberOfWrongGuesses: To store the wrong guess number (3) currentWord: The word currently has guessed etc.

One problem is once the user done the game or prepare to start a new game, the database needs to be cleaned up right?

CodePudding user response:

Not necessary, you can create a js file with let object like this:

data.js

const words = [
    { id: 1, name: 'spring' },
    { id: 2, name: 'promise' },
];

after you import this file to your html file.

CodePudding user response:

If I decide to store them in database, what kinds of columns do I need?

It depends on how you want the game to work, not just gameplay (guessing the current word) but also managing what happens once the current game is finished - did you want to keep score, etc?

I don't know how Lucid chart works (what sort of runtime, API and programming environment it supports; or how users will interact with it, can it maintain state, etc), but you may be able to run the game entirely in-memory and not need a database at all.

Before diving straight into the physical columns, do a logical design on paper or a whiteboard.

One problem is once the user done the game or prepare to start a new game, the database needs to be cleaned up right?

That also depends on how you want the game to work. It also depends how many people will be playing this - if two people play it at once, they'll need their own separate set of data.

Cleaning up the data helps keep the database size smaller over time, but it also means you wouldn't be able to track a players history, or allow you to see things like "hardest 5 letter words of all time" etc.

  •  Tags:  
  • Related