Hangman with specific functionality

I’m in the process of building Hangman with plain JavaScript and I’m having trouble figuring out the following:

  • Single letter and full word guesses

  • Allowing the use of turns to be bookmarked to be able to come back later

  • Keeping the URL short as the game progresses, preferably 80 characters or under

  • Shareable URL so whomever has the link can start where the last person left off

  • URL and program shouldn’t give any details about the game to prevent cheating

  • Undo function that goes back to previous turn URL, works with single letters or words, can go back to previous word challenge, and also works when shared.

  • Works behind an HTTP reverse proxy. It can’t rely on any other server side software, databases, or disk storage. Can work without the proxy.

I know it’s a lot, and I’m trying to build through it as we speak. The main things that I’m having issue with are the link security, sharing, and the HTTP reverse proxy. Since these are new concepts for me, I’m having trouble finding resources for this stuff because I’m not sure what I’m looking for, as ridiculous as it sounds. Are the things I bulleted about even possible with plain JS? Would I need to use node.js?

Thanks for your help!

How are you going to persist the state of a game between two players with no server storage and in a way that does not allow them to “cheat”? You could allow for some sort of client querying either through the query string, cookies, local storage, but how would you persist the moves another player makes to that link so that the other players would see them? Not to mention you can change this data yourself.

As far as the page design, you could build the page dynamically so it generates itself according to which move you are on and which words are revealed. If it’s the 3rd move and there are so many mistakes render the hangman at 3/4ths drawn and reveal “abc” from “abcdefg”. Non of this solves your problem with handling the data.

And by a dynamic page I really mean a static page, according to your specifications, however it would render according to the provided variables, which is your first concern. You could do this if you don’t mind cheating, just pass values to the page through a client method.

query strings seem like the best options for the URL, no? Meaning, as letters and turns are used the URL gets updated with that information. But then I think, what needs to be done in conjunction with that to keep the URL under 80 characters? I want to say some use of regular expressions to manipulate the query strings into something shorter, but I feel like that’s wrong.

In regards to persisting the game state between two players, are the requirements I have listed even realistic to achieve what I’m looking for? I can find some results on the web with people using an HTTP reverse proxy with node, but seeing as I can’t use databases or disk storage I’m kind of lost. It is ok to lose all the data when the server process exits though.

In my opinion your requirements do not align well. Someone with more experience could advise further. You could perhaps use Node to host an instance that runs live and users can connect to that instance via a link and changes made are sent to all connected users. However you could not bookmark this instance as it would not persist. But if you have absolutely no server use, again I don’t see how you can do any of this.