|
| 1 | +# Days 97-99 Online Games via a JSON API |
| 2 | + |
| 3 | +This one was a big one wasn't it? Hopefully the real-world nature made it well worth it! Your goal will be to create an online game for another simple game: Hi-lo. |
| 4 | + |
| 5 | +The output looks something like this: |
| 6 | + |
| 7 | +``` |
| 8 | +--------------------------------- |
| 9 | + GUESS THAT NUMBER GAME |
| 10 | +--------------------------------- |
| 11 | +
|
| 12 | +Player what is your name? Michael |
| 13 | +Guess a number between 0 and 100: 50 |
| 14 | +Sorry Michael, your guess of 50 was too HIGH. |
| 15 | +Guess a number between 0 and 100: 30 |
| 16 | +Sorry Michael, your guess of 20 was too HIGH. |
| 17 | +Guess a number between 0 and 100: 10 |
| 18 | +Sorry Michael, your guess of 10 was too LOW. |
| 19 | +Guess a number between 0 and 100: 15 |
| 20 | +Sorry Michael, your guess of 15 was too LOW. |
| 21 | +Guess a number between 0 and 100: 19 |
| 22 | +Excellent work Michael, you won, it was 19! |
| 23 | +done |
| 24 | +``` |
| 25 | + |
| 26 | +There is already an app you can use to get started from here: |
| 27 | + |
| 28 | +**HI-LO GAME**: [`program.py`](https://github.com/mikeckennedy/python-jumpstart-course-demos/blob/master/apps/02-guess-number-app/final/program.py) |
| 29 | + |
| 30 | +## Day N: Add database persistence to the game |
| 31 | + |
| 32 | +On this first day, you already watched the videos. Now you'll need to design what data to store in the database and model that with SQLAlchemy. |
| 33 | + |
| 34 | +Feel free to borrow heavily from our code we already wrote for the **[SQLAlchemy day](https://github.com/talkpython/100daysofcode-with-python-course/tree/master/days/91-93-sqlalchemy)**. |
| 35 | + |
| 36 | +Note that you'll probably want a virtual environment for this one as it involves plenty of external packages. |
| 37 | + |
| 38 | +## Day N+1: Create the web services |
| 39 | + |
| 40 | +Today you'll create a Flask-based web app. For the general structure, feel free to copy from the demo code in this block of days. |
| 41 | + |
| 42 | +You will need to determine the actions that need to happen on the server. For example: |
| 43 | + |
| 44 | +* Create user |
| 45 | +* Find user |
| 46 | +* Game status |
| 47 | +* Play round |
| 48 | +* ... ? |
| 49 | + |
| 50 | +Add a web method for each of these and consider the appropriate URLs and endpoints for the data exchange. |
| 51 | + |
| 52 | +Once you have your methods written, test it with a simple tool like [**Postman**](https://www.getpostman.com/). |
| 53 | + |
| 54 | +## Day N+2: Create the program / game app that users use |
| 55 | + |
| 56 | +Final day! Today, write the `uplink` client (or just raw `request` code if you'd rather). Take each method you wrote yesterday for the API and create a client version. If you need a hint, just look at the client we wrote for this block of days. |
| 57 | + |
| 58 | +Once it's working, then write the code for user interaction on the client. |
| 59 | + |
| 60 | +This python application is the stand-in for the full video game each person plays locally but works with data on the server. |
| 61 | + |
| 62 | +Looking for a bonus? Try to deploy your web app somewhere like Heroku. Here's their quick start: |
| 63 | + |
| 64 | +**[github.com/heroku/python-getting-started](https://github.com/heroku/python-getting-started)** |
| 65 | + |
| 66 | +### Time to share what you've accomplished! |
| 67 | + |
| 68 | +Be sure to share your last couple of days work on Twitter or Facebook. Use the hashtag **#100DaysOfCode**. |
| 69 | + |
| 70 | +Here are [some examples](https://twitter.com/search?q=%23100DaysOfCode) to inspire you. Consider including [@talkpython](https://twitter.com/talkpython) and [@pybites](https://twitter.com/pybites) in your tweets. |
| 71 | + |
| 72 | +*See a mistake in these instructions? Please [submit a new issue](https://github.com/talkpython/100daysofcode-with-python-course/issues) or fix it and [submit a PR](https://github.com/talkpython/100daysofcode-with-python-course/pulls).* |
0 commit comments