Skip to content

Commit

Permalink
docs: fix reference to word guessing game
Browse files Browse the repository at this point in the history
  • Loading branch information
roedoejet committed Mar 6, 2024
1 parent 3046745 commit b7c4a9d
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 88 deletions.
32 changes: 5 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Any-Language Wordle Clone
# Any-Language Word Guessing Game

## Changes in this fork

Expand All @@ -24,7 +24,7 @@ _To adapt for your language (the basics):_
4. Change the file in `src/constants/config.ts` to include meta data about your language. If your language needs words longer or shorter than 5, you can set that in this file and also set the number of tries.
5. Publish on GitHub Pages by changing the `homepage` key in `package.json` and running `npm run deploy` or just committing to the main branch (and a GitHub workflow will take care of the rest).

For more information, including how to localize the interface to your language, visit the blog article: https://blog.mothertongues.org/wordle/.
For more information, including how to localize the interface to your language, visit the blog article: https://blog.mothertongues.org/word-guessing-game/.

The interface is translated by default in English, Kiswahili, Mandarin and Spanish - other translations are very welcome! To add translations please submit a pull request with the following steps:

Expand All @@ -36,40 +36,18 @@ Thanks to Carolyn O'Meara (https://github.com/ckomeara) for providing the Spanis
Thanks to Haowen Jiang (https://github.com/howard-haowen) for providing the 中文 translation.
Thanks to Benson Muite (https://github.com/bkmgit) for providing the Kiswahili translation.

## On to the original stuff from @hannahcode...

- Go play the real Wordle [here](https://www.powerlanguage.co.uk/wordle/)
- Read the story behind it [here](https://www.nytimes.com/2022/01/03/technology/wordle-word-game-creator.html)
- Try a demo of this clone project [here](https://wordle.hannahmariepark.com)

_Inspiration:_
This game is an open source clone of the immensely popular online word guessing game Wordle. Like many others all over the world, I saw the signature pattern of green, yellow, and white squares popping up all over social media and the web and had to check it out. After a few days of play, I decided it would be great for my learning to try to rebuild Wordle in React!

_Design Decisions:_
I used a combination of React, Typescript, and Tailwind to build this Wordle Clone. When examining the original Wordle, I assumed the list might come from an external API or database, but after investigating in chrome dev tools I found that the list of words is simply stored in an array on the front end. I'm using the same list as the OG Wordle uses, but watch out for spoilers if you go find the file in this repo! The word match functionality is simple: the word array index increments each day from a fixed game epoch timestamp (only one puzzle per day!) roughly like so:

```
WORDS[Math.floor((NOW_IN_MS - GAME_EPOCH_IN_MS) / ONE_DAY_IN_MS)]
```

React enabled me to componentize the littlest parts of the game - keys and letter cells - and use them as the building blocks for the keyboard, word grid, and winning solution graphic. As for handling state, I used the built in useState and useEffect hooks to track guesses, whether the game is won, and to conditionally render popups.

In addition to other things, Typescript helped ensure type safety for the statuses of each guessed letter, which were used in many areas of the app and needed to be accurate for the game to work correctly.

I implemented Tailwind mostly because I wanted to learn how to use Tailwind CSS, but I also took advantage of [Tailwind UI](https://tailwindui.com/) with their [headless package](https://headlessui.dev/) to build the modals and notifications. This was such an easy way to build simple popups for how to play, winning the game, and invalid words.

_To Run Locally:_
Clone the repository and perform the following command line actions:
```bash
$ cd wordle
$ cd anylanguage-word-guessing-game
$ npm install
$ npm run start
```

_To build/run docker container:_
```bash
$ docker build -t notwordle .
$ docker run -d -p 3000:3000 notwordle
$ docker build -t anylanguage-word-guessing-game .
$ docker run -d -p 3000:3000 anylanguage-word-guessing-game
```
open http://localhost:3000 in browser.

44 changes: 17 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "any-language-wordle",
"name": "any-language-word-guessing-game",
"version": "0.1.0",
"homepage": "https://roedoejet.github.io/AnyLanguage-Wordle",
"homepage": "https://roedoejet.github.io/AnyLanguage-Word-Guessing-Game",
"private": true,
"dependencies": {
"@bcgov/bc-sans": "^1.0.1",
Expand Down
20 changes: 10 additions & 10 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>

<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
Expand All @@ -24,9 +22,10 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Wordle Clone</title>
</head>
<body>
<title>AnyLanguage Word Guessing Game</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
Expand All @@ -39,5 +38,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</body>

</html>
6 changes: 3 additions & 3 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"about": "About this game",
"gameName": "Not Wordle - {{language}}",
"gameName": "Word Guessing Game - {{language}}",
"enterKey": "Enter",
"deleteKey": "Delete",
"notEnoughLetters": "Not enough letters",
Expand Down Expand Up @@ -89,7 +89,7 @@
"highlight": false
}
],
"aboutAuthorSentence": "This is an open source clone of the game Wordle adapted to {{language}} by <3>{{author}}</3>. ",
"aboutAuthorSentence": "This is an open source word guessing game adapted to {{language}} by <3>{{author}}</3>. ",
"aboutCodeSentence": "Check out <1>the original code</1> by <3>Hannah Park</3> or have a look at <5>Aidan Pine's fork</5> and customize it for another language! ",
"aboutDataSentence": "The words for this game were sourced from <1>{{wordListSource}}</1>. ",
"aboutOriginalSentence": "You can also play the original <1>here</1>",
Expand All @@ -99,4 +99,4 @@
"sw": "Kiswahili",
"zh": "中文"
}
}
}
20 changes: 3 additions & 17 deletions src/components/modals/AboutModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,16 @@ export const AboutModal = ({ isOpen, handleClose }: Props) => {
i18nKey="aboutAuthorSentence"
values={{ language: CONFIG.language, author: CONFIG.author }}
>
This is an open source clone of the game Wordle adapted to
This is an open source word guessing game adapted to
{CONFIG.language} by
<a href={CONFIG.authorWebsite} className="underline font-bold">
{CONFIG.author}
</a>{' '}
</Trans>
<Trans i18nKey="aboutCodeSentence">
Check out
Have a look at
<a
href="https://github.com/hannahcode/wordle"
className="underline font-bold"
>
the original code
</a>
by
<a
href="https://www.hannahmariepark.com/"
className="underline font-bold"
>
Hannah Park
</a>
or have a look at
<a
href="https://github.com/roedoejet/AnyLanguage-Wordle"
href="https://github.com/roedoejet/AnyLanguage-Word-Guessing-Game"
className="underline font-bold"
>
Aidan Pine's fork
Expand Down
4 changes: 2 additions & 2 deletions src/constants/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const CONFIG = {
tries: 6, // This changes how many tries you get to finish the wordle
tries: 6, // This changes how many tries you get to finish the game
language: 'YourLanguageHere', // This changes the display name for your language
wordLength: 5, // This sets how long each word is based on how many characters (as defined in orthography.ts) are in each word
author: 'YourNameHere', // Put your name here so people know who made this Wordle!
author: 'YourNameHere', // Put your name here so people know who made this game!
authorWebsite: 'YourLinkHere', // Put a link to your website or social media here
wordListSource: 'YourDictionarySource', // Describe the source material for your words here
wordListSourceLink: 'YourDictionaryLink', // Put a link to the source material for your words here
Expand Down

0 comments on commit b7c4a9d

Please sign in to comment.