diff --git a/your-project/.gitignore b/your-project/.gitignore new file mode 100644 index 0000000..e679a69 --- /dev/null +++ b/your-project/.gitignore @@ -0,0 +1,47 @@ +# Created by https://www.toptal.com/developers/gitignore/api/jupyternotebooks,macos +# Edit at https://www.toptal.com/developers/gitignore?templates=jupyternotebooks,macos + +### JupyterNotebooks ### +# gitignore template for Jupyter Notebooks +# website: http://jupyter.org/ + +.ipynb_checkpoints +*/.ipynb_checkpoints/* + +# IPython +profile_default/ +ipython_config.py + +# Remove previous ipynb_checkpoints +# git rm -r .ipynb_checkpoints/ + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# End of https://www.toptal.com/developers/gitignore/api/jupyternotebooks,macos \ No newline at end of file diff --git a/your-project/Hangman.ipynb b/your-project/Hangman.ipynb new file mode 100644 index 0000000..c3aa02e --- /dev/null +++ b/your-project/Hangman.ipynb @@ -0,0 +1,362 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# The German Hangman Game\n", + "Here you will find my awesome code for the ultrahard German Hangman Game." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "# START GAME\n", + "# user input \"name\" > all characters can be accepted\n", + "# print \"Hi \"name\", are you ready to get owned by German Hangman?\"\n", + "# wait 2 seconds, start game\n", + "\n", + "# CHOOSE RANDOM WORD\n", + "# get a random word from word_list\n", + "# convert all words from word_list to upper case \n", + "# store word in variable \"word\"\n", + "\n", + "# GAMEPLAY FUNCTION\n", + "# set 10 tries (user can guess as much as he wants, but fail only 10 times)\n", + "# display the length of \"word\" to the user with _ _ _ underscores\n", + "# Hidden letters are shown as underscores, guessed letters will be unmasked\n", + "# prompt the user to guess a letter or word \n", + " # user input convert to uppercase always\n", + "# while loop until word is guessed or user runs out of tries\n", + " # letter is in secret word > show letter in secret word, ask for user input again, show remaining tries, print \"Nice try!\"\n", + " # letter is not in secret word > -1 try and ask for user input again, show remaining tries, print \"This letter is not in the word, try again!\"\n", + "# if user runs out of tries (10) and looses:\n", + " # secret word is displayed, print \"\"name\" you loose, guess you got owned by German hangman\", start play again function\n", + "# if user wins or guesses the word right\n", + " # word is displayed, print \"\"name\" you win, you are ready to move to Berlin now!\", start play again function\n", + " \n", + "# PLAY AGAIN FUNCTION\n", + "# print \"Are you ready to play again?\"\n", + "# print \"enter \"Y\" to start \"N\" \n", + " # make sure that only Y and N is possible (not weird other input > error message \" wow you are already failing here\"\n", + " # gameplay function starts again\n", + "\n", + "# possible problems with user input > error messages:\n", + " # not a letter\n", + " # same letter twice (show the user which letters he already used?)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "word_list = [\n", + " 'Heizoelrueckstossabdaempfung',\n", + " 'Donaudampfschifffahrtskapitaensgeselltschaftsmuetzenhalterung',\n", + " 'Lokomotivdampfkesseldruckventilverschlussklappe',\n", + " 'Kirschkernweitspuckwettbewerb',\n", + " 'Weihnachtsmannschokoladeneinpackpapier',\n", + " 'Atmosphaere',\n", + " 'Destinationslebenszyklusmodell',\n", + " 'Desoxyribonukleinsaeure',\n", + " 'Papierschnipselchen',\n", + " 'Arbeitsunfaehigkeitsbescheinigung',\n", + " 'Hundehaftpflichtversicherung']" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "import random" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "import time" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "What is your name? Sarah\n", + "Hello, Sarah are you ready to get owned by German Hangman?\n", + "Start guessing...\n", + "\n", + "\n" + ] + } + ], + "source": [ + "#Start of the game\n", + "\n", + "name = input(\"What is your name? \")\n", + "\n", + "print (\"Hello, \" + name, \"are you ready to get owned by German Hangman?\")\n", + "\n", + "time.sleep(2)\n", + "\n", + "print (\"Start guessing...\")\n", + "print(\"\\n\")\n", + "time.sleep(1)" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [], + "source": [ + "#Functions\n", + "\n", + "def get_word():\n", + " word = random.choice(word_list)\n", + " return word.upper()\n", + "\n", + "def play (word):\n", + " word_completion = (\"_\" * len(word))\n", + " guessed = False\n", + " guessed_letters = []\n", + " guessed_words = []\n", + " tries = 5\n", + "\n", + " print(word_completion)\n", + " print(\"\\n\")\n", + "\n", + " while guessed == False and tries > 0: #guessed letter\n", + " guess = input(\"Please guess a letter or word: \").upper()\n", + " if len(guess) == 1 and guess.isalpha():\n", + " if guess in guessed_letters:\n", + " print(\"You already guessed the letter\", guess)\n", + " print(\"\\n\")\n", + " elif guess not in word:\n", + " print(guess, \"is not in the word.\")\n", + " print(\"\\n\")\n", + " tries -= 1\n", + " guessed_letters.append(guess)\n", + " else:\n", + " print(\"Good job,\", guess, \"is in the word!\")\n", + " print(\"\\n\")\n", + " guessed_letters.append(guess)\n", + " word_as_list = list(word_completion)\n", + " indices = [i for i, letter in enumerate(word) if letter == guess]\n", + " for index in indices:\n", + " word_as_list[index] = guess\n", + " word_completion = \"\".join(word_as_list)\n", + " if \"_\" not in word_completion:\n", + " guessed = True\n", + " elif len(guess) == len(word) and guess.isalpha(): #guessed word\n", + " if guess in guessed_words:\n", + " print(\"You already guessed the word\", guess)\n", + " print(\"\\n\")\n", + " elif guess != word:\n", + " print(guess, \"is not the word.\")\n", + " print(\"\\n\")\n", + " tries -= 1\n", + " guessed_words.append(guess)\n", + " else:\n", + " guessed = True\n", + " word_completion = word\n", + " else:\n", + " print(\"Not a valid guess.\")\n", + " print(\"\\n\")\n", + " print(word_completion)\n", + " print(\"\\n\")\n", + " if guessed:\n", + " print(\"You win, you are ready to move to Berlin now!\")\n", + " print(\"\\n\")\n", + " else:\n", + " print(\"Sorry, you ran out of tries. The word was \" + word + \". Maybe next time!\")\n", + " print(\"\\n\")\n", + "\n", + "\n", + "def play_again():\n", + " again = input(\"Ready to play Again? Input (Y/N) \").upper()\n", + " print(\"\\n\")\n", + " if again == \"Y\":\n", + " play(word = get_word())\n", + " play_again()\n", + " elif again == \"N\":\n", + " print(\"Ciao Kakao!\")\n", + " else:\n", + " print(\"Y or N, no other input please...\")\n", + " print(\"\\n\")\n", + " play_again()" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "_____________________________\n", + "\n", + "\n", + "Please guess a letter or word: ü\n", + "Ü is not in the word.\n", + "\n", + "\n", + "_____________________________\n", + "\n", + "\n", + "Please guess a letter or word: ä\n", + "Ä is not in the word.\n", + "\n", + "\n", + "_____________________________\n", + "\n", + "\n", + "Sorry, you ran out of tries. The word was KIRSCHKERNWEITSPUCKWETTBEWERB. Maybe next time!\n", + "\n", + "\n", + "Ready to play Again? Input (Y/N) y\n", + "\n", + "\n", + "____________________________\n", + "\n", + "\n", + "Please guess a letter or word: ü\n", + "Ü is not in the word.\n", + "\n", + "\n", + "____________________________\n", + "\n", + "\n", + "Please guess a letter or word: ä\n", + "Ä is not in the word.\n", + "\n", + "\n", + "____________________________\n", + "\n", + "\n", + "Sorry, you ran out of tries. The word was HUNDEHAFTPFLICHTVERSICHERUNG. Maybe next time!\n", + "\n", + "\n", + "Ready to play Again? Input (Y/N) y\n", + "\n", + "\n", + "______________________________\n", + "\n", + "\n", + "Please guess a letter or word: ü\n", + "Ü is not in the word.\n", + "\n", + "\n", + "______________________________\n", + "\n", + "\n", + "Please guess a letter or word: q\n", + "Q is not in the word.\n", + "\n", + "\n", + "______________________________\n", + "\n", + "\n", + "Sorry, you ran out of tries. The word was DESTINATIONSLEBENSZYKLUSMODELL. Maybe next time!\n", + "\n", + "\n", + "Ready to play Again? Input (Y/N) n\n", + "\n", + "\n", + "Ciao Kakao!\n" + ] + } + ], + "source": [ + "play(word = get_word())\n", + "play_again()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false + }, + "varInspector": { + "cols": { + "lenName": 16, + "lenType": 16, + "lenVar": 40 + }, + "kernels_config": { + "python": { + "delete_cmd_postfix": "", + "delete_cmd_prefix": "del ", + "library": "var_list.py", + "varRefreshCmd": "print(var_dic_list())" + }, + "r": { + "delete_cmd_postfix": ") ", + "delete_cmd_prefix": "rm(", + "library": "var_list.r", + "varRefreshCmd": "cat(var_dic_list()) " + } + }, + "types_to_exclude": [ + "module", + "function", + "builtin_function_or_method", + "instance", + "_Feature" + ], + "window_display": false + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/your-project/Hangman.py b/your-project/Hangman.py new file mode 100644 index 0000000..cecf62f --- /dev/null +++ b/your-project/Hangman.py @@ -0,0 +1,180 @@ +#!/usr/bin/env python +# coding: utf-8 + +# # The German Hangman Game +# Here you will find my awesome code for the ultrahard German Hangman Game. + +# In[1]: + + +# START GAME +# user input "name" > all characters can be accepted +# print "Hi "name", are you ready to get owned by German Hangman?" +# wait 2 seconds, start game + +# CHOOSE RANDOM WORD +# get a random word from word_list +# convert all words from word_list to upper case +# store word in variable "word" + +# GAMEPLAY FUNCTION +# set 10 tries (user can guess as much as he wants, but fail only 10 times) +# display the length of "word" to the user with _ _ _ underscores +# Hidden letters are shown as underscores, guessed letters will be unmasked +# prompt the user to guess a letter or word + # user input convert to uppercase always +# while loop until word is guessed or user runs out of tries + # letter is in secret word > show letter in secret word, ask for user input again, show remaining tries, print "Nice try!" + # letter is not in secret word > -1 try and ask for user input again, show remaining tries, print "This letter is not in the word, try again!" +# if user runs out of tries (10) and looses: + # secret word is displayed, print ""name" you loose, guess you got owned by German hangman", start play again function +# if user wins or guesses the word right + # word is displayed, print ""name" you win, you are ready to move to Berlin now!", start play again function + +# PLAY AGAIN FUNCTION +# print "Are you ready to play again?" +# print "enter "Y" to start "N" + # make sure that only Y and N is possible (not weird other input > error message " wow you are already failing here" + # gameplay function starts again + +# possible problems with user input > error messages: + # not a letter + # same letter twice (show the user which letters he already used?) + + +# In[2]: + + +word_list = [ + 'Heizoelrueckstoßabdaempfung', + 'Donaudampfschifffahrtskapitaensgeselltschaftsmuetzenhalterung', + 'Lokomotivdampfkesseldruckventilverschlussklappe', + 'Kirschkernweitspuckwettbewerb', + 'Weihnachtsmannschokoladeneinpackpapier', + 'Atmosphaere', + 'Destinationslebenszyklusmodell', + 'Desoxyribonukleinsaeure', + 'Papierschnipselchen', + 'Arbeitsunfaehigkeitsbescheinigung', + 'Hundehaftpflichtversicherung'] + + +# In[3]: + + +import random + + +# In[4]: + + +import time + + +# In[5]: + + +#Start of the game + +name = input("What is your name? ") + +print ("Hello, " + name, "are you ready to get owned by German Hangman?") + +time.sleep(2) + +print ("Start guessing...") +print("\n") +time.sleep(1) + + +# In[21]: + + +#Functions + +def get_word(): + word = random.choice(word_list) + return word.upper() + +def play (word): + word_completion = ("_" * len(word)) + guessed = False + guessed_letters = [] + guessed_words = [] + tries = 5 + + print(word_completion) + print("\n") + + while guessed == False and tries > 0: #guessed letter + guess = input("Please guess a letter or word: ").upper() + if len(guess) == 1 and guess.isalpha(): + if guess in guessed_letters: + print("You already guessed the letter", guess) + elif guess not in word: + print(guess, "is not in the word.") + print("\n") + tries -= 1 + guessed_letters.append(guess) + else: + print("Good job,", guess, "is in the word!") + print("\n") + guessed_letters.append(guess) + word_as_list = list(word_completion) + indices = [i for i, letter in enumerate(word) if letter == guess] + for index in indices: + word_as_list[index] = guess + word_completion = "".join(word_as_list) + if "_" not in word_completion: + guessed = True + elif len(guess) == len(word) and guess.isalpha(): #guessed word + if guess in guessed_words: + print("You already guessed the word", guess) + print("\n") + elif guess != word: + print(guess, "is not the word.") + print("\n") + tries -= 1 + guessed_words.append(guess) + else: + guessed = True + word_completion = word + else: + print("Not a valid guess.") + print("\n") + print(word_completion) + print("\n") + if guessed: + print("You win, you are ready to move to Berlin now!") + print("\n") + else: + print("Sorry, you ran out of tries. The word was " + word + ". Maybe next time!") + print("\n") + + +def play_again(): + again = input("Ready to play Again? Input (Y/N) ").upper() + print("\n") + if again == "Y": + play(word = get_word()) + play_again() + elif again == "N": + print("Ciao Kakao!") + else: + print("Y or N, no other input please...") + print("\n") + play_again() + + +# In[20]: + + +play(word = get_word()) +play_again() + + +# In[ ]: + + + + diff --git a/your-project/README.md b/your-project/README.md index 2a8493d..5d13d1c 100644 --- a/your-project/README.md +++ b/your-project/README.md @@ -1,9 +1,9 @@ Ironhack Logo -# Title of Your Project -*[Your Name]* +# German ultrahard Hangman +*Sarah Vonderberg* -*[Your Cohort, Campus & Date]* +*[DAFT, Remote Campus & MAR21]* ## Content - [Project Description](#project-description) @@ -13,22 +13,33 @@ - [Links](#links) ## Project Description -Write a short description of your project. Write 1-2 sentences about the game you chose to build and why. +This is a classic hangman game with a German twist. All words that you have to guess are in German and extremely hard. ## Rules -Briefly describe the rules of the game. +You have to guess the letter or the complete word in order to win. +As long as your guess is right you can keep on guessing. However you only have 5 wrong guesses before you loose the game. Don't worry, you can play again! ## Workflow -Outline the workflow you used in your project. What are the steps you went through? +First I researched the game and played it a couple of times to outlines the rules and exceptions. +Then I started to organize my trello board, to see which tasks I need to finish (and by when) in order to have all things needed for the project. +After that I wrote my pseudocode to figure out what type of functions I will be needing for my game. I added the functions to my trello board to not loose oversight. +I started to build my git repo by forking the TA's repo, adding a gitignore and making sure it looks nice and clean. +After all the organizing I started to code. +During the coding I tested many of my gaming options to not miss any case. +After the raw version of the code was finished, I started testing for bugs, exceptions and to "prettyfie" the game adding breaks and timing. +After finalizing everything I made my presentation and added the updated readme file. + ## Organization -How did you organize your work? Did you use any tools like a kanban board? +I organised my project with trello into tasks which are either in progress, almost done , done or in review. I also assigned deadlines to some tasks in order to be reminded. -What does your repository look like? Explain your folder and file structure. +I tried to keep it as clean and lean as possible, so it contains a gitignore, a readme, my code in a jupyter notebook, as well as my code in .py file so people can run it on their terminal. ## Links Include links to your repository, slides and kanban board. Feel free to include any other links associated with your project. -[Repository](https://github.com/) -[Slides](https://slides.com/) -[Trello](https://trello.com/en) +[Repository](https://github.com/Salevo/Project-Week-1-Build-Your-Own-Game) + +[Slides](https://drive.google.com/file/d/17tHtBMUqGDMOZoJVluFwWxX4IPsRyH6o/view?usp=sharing) + +[Trello](https://trello.com/b/HFYxcpUn/project-1-german-hangman)