Developer: Orna Reynolds
đź’» Visit live website
This is a command-line version of the bluff card game Bullshit for 3 players. Many versions of this game exist and the classic game is best played in a group of people.
The classic game generally is played with relatively no rules, all cards in deck and players can discard cards to communal pile in any order with any amount of matching cards. My game is played where the user can only discard one card at a time and only one suit in deck is used.
The objective of the game is to be the first one to get rid of all your cards.
- Project Goals
- User Experience
- Technical Design
- Technologies Used
- Features
- Validation
- Testing
- Bugs
- Deployment
- Credits
- Acknowledgements
I want to challenge myself to code a card game I like playing in real life that may not be the easiest to adapt to play against a computer.
- Enjoy a fun and straightforward card game
- Have the option to view over the rules of the game or play game straightaway.
- Remember my name, how many times i have played the game and won
- Build a game that is simple and straightforward to use.
- Make sure players understand the goal of the game and how to achieve that
- Design a game that asks for user input, validates and manipulates it and also provides feedback to players while they play
Those of all ages who enjoy card games and more specifically card bluffing games.
- I want the name of the game clearly displayed and have an idea how to play it from first look.
- I want to be asked if I want to start the game or read the rules first
- I want to be able to start the game after I have read the rules of the game
- I would like the cards in my hand to display as a graphic picture and for them to update when I play a card
- I want to receive feedback from the game about the my inputs and have the opportunity ti input them again if I am wrong.
- I want the option to play again once the game is over
- If I play the game multiple times, I want how many times I have won to be saved
- I want to enter my name at start of game to personalise it
- I want the communal cards pile displayed so I know how many cards the next loser of the round could get
- I want the back of the computer's cards to display as a graphic and for them to update when hand is updated. Seeing the front of the cards would ruin the game for the user because they would know if the computer was lying
- I want the user to have the option to play the game again without having to exit. This is to enhance user experience.
- I want the user's name and how many times they have won to be saved to google sheets.
- I want user inputs to undergo extensive validation so game execution is not affected.
This was the flowchart designed at the beginning of project before I started coding. As you can see my project has quite a few changes to that project idea, but the basic logic of the game is similar.
The code is contained in 1 file for this project: run.py. I found writing the different functions in one file helpful for this project as my game followed a set pathway which I could easily follow through my code and access to make changes. In future however I would like to separate python files to make the code more decentralized making the code more accessible for other people to digest, and thus coming in line with industry standards for python.
I collect 3 pieces of data from the user, both directly and indirectly.
- username (name) through input of user, this value underwent validatation that only alphabetic number names could be included and name given was capitalized as a personal preefernce of mine
- number of games played through how many times the player replayed the game, google sheet specific cell was updated each new game to collect this data
- number of wins through how many times the user had zero hands first and the game loop was stopped, google sheet specific cell was updated each win to collect this data
- Python
- Git was used for version control
- GitHub was used as a remote repository to store project code
- Google Sheets were used to store player usernames
- Lucid Chart was used to create flowchart diagram in beginning
- os - used to add a seperate line to terminal underneath text
- random - used to shuffle deck, control computer choices of card selection and calling bullshit
- sys & sleep - used to create a typing effect within the games rules
- time - create pause between lines of text
- colorama - used this library to add color to the terminal to differentiate players
- gspread - used to add and manipulate data in my Google spreadsheet and to interact with Google APIs
- Provides name of game in pleasant graphic
- Gives short description of game to user has idea of what game is about immediately
- User stories covered: 1
- Gives user option to play the game or read the rules first
- User stories covered: 2, 3
- Displays clear game rules
- Allows user to start game once they are ready
- User stories covered: 3
- Displays all players cards
- Shows user their number cards
- Hides other player cards from user seeing type
- User stories covered: 4, 10
- Ask user their name
- Relay back to user at various points throughout the games
- User stories covered: 8, 12
- Counts number of cards user discarded in to pile
- Pile increases or decreases as game is played
- User stories covered: 9
- Gives user option to restart game whether they win or lose
- User stories covered: 7
My code was validated through CI Python Linter with no errors
title() function toilet displaying was kept even though lines were longer than 79 characters. I could have removed as per screen of code validation above but i felt it added personality to the game and help me potray that light-hearted feeling to the user.
- I want the name of the game clearly displayed and have an idea how to play it from first look.
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Title screen | Press "Run Programme" | Users are greeted with graphic title and short explanation of game | Works as expected |
- I want to be asked if I want to start the game or read the rules first
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Menu | Select 1 | Game begins | Works as expected |
Menu | Select 2 | User is presented with rules | Works as expected |
- I want to be able to start the game after I have read the rules of the game
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Game Rules | Press enter | Users is prompted to give enter name | Works as expected |
- I would like the cards in my hand to display as a graphic picture and for them to update when I play a card
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Cards display | Play the game | Cards updating when user loses or gains cards | Works as expected |
- I want to receive feedback from the game about the my inputs and have the opportunity ti input them again if I am wrong.
- I want the option to play again once the game is over
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Play again | Win or lose game | Congratualations or hard luck message displays along with y/n to play again | Works as expected |
- If I play the game multiple times, I want how many times I have won to be saved
- I want to enter my name at start of game to personalise it
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Name prompt | Enter name | Repeats name back to you capitalized | Works as expected |
- I want the communal cards pile displayed so I know how many cards the next loser of the round could get
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Communal cards pile counter | Players discard cards to communal pile | Number updates dynamically depending on number of cards in pile | Works as expected |
- I want the back of the computer's cards to display as a graphic and for them to update when hand is updated. Seeing the front of the cards would ruin the game for the user because they would know if the computer was lying
Feature | Action | Expected Result | Actual Result |
---|---|---|---|
Cards display | Play the game | Cards updating when computer players lose or gain cards | Works as expected |
- I want the user's name and how many times they have won to be saved to google sheets.
- I want user inputs to undergo extensive validation so game execution is not affected. | Feature | Action | Expected Result | Actual Result | | ------------- | ----------------------------- | ---------------------------- | ----------------- | | Any user input | Make invalid entry for question| Error message and loop to reask orginal question | Works as expected |
Bug | Fix |
---|---|
menu_select() bug: This function was not executing its if or else ==1,2 when incorrect value enter first followed by 1 or 2. | Fixed by setting the start_option_selected variable to input() to get the user's input and using this in loop rather than other value. See commit ea2de49 for further details. |
computer2_card_select(), computer3_card_select() bug: These function were throwing IndexError: list index out of range as computer3_card_chosen = hands[current_player + 2][x - 1] x value randomly chosen 1-4 was not in lower list values | Fixed by setting x to length of hands so list never out of range. See commit 5d884ac for further details (scroll to bottom of commit, readme file was added to also in this commit). |
### Bugs to be fixed
- Issue with display of 10 card pushing other cards display askew, did not fix urgentluy as did not affect the user's ability to understand and play the game
- Valid data failing validation check if user inputting data before question finished asking, can add specific errors message in future to outline to user to be more patient
- Possible leader board that pulls data from google sheet to compare. For this to work may need more robust username credentials so player with same name do not get their scores jumbled together.
- More competitive game with computers beiing more likely to be telling the truth when they discard a card so the user finds it harder to win if they call bullshit
- This game can be easily be beat if the user tells the truth when discarding and never calls bullshit. A future feature could include togglinng what user goes first to prevent non-interaction of the user with elements in the game
- Update requirements.txt file by using this command in the terminal Pip3 freeze > requirements.txt. This populates this file with necessary dependencies.
- Login to heroku and navigate to dashboard where have option to creat a new app
- Choose a unique name and select Europe as destination
- Once app is created navigate to settings and press button “reveal config vars”
- Add creds key and content from creds file as value
- Add port key and 800 value to to config var also
- Scroll down and add python build pack and save changes
- Add node.js build pack also. It is important to make sure python buildpack is added first and hence ontop of node.js buildpack.
- Scroll back to top of page and click deploy tab
- From the deploy methods displayed select GitHub
- Search for repo name and click connect to link the two up
- Deploy from branch and follow link to deployed site after it loads
- Slack Overflow posts
- How to Use Colorama in Python
- W3 Schools
- Typewriter effect on inputs (python)
- Code Institute's Love sandwiches to connect google sheets api for user data manipulation
- Increment and Decrement operators in Python
- The Big Book of Small Python Projects by Al Sweigart, in particular #4 BLACKJACK and #9 CARROT IN A BOX
- Creating a Deck of Cards in Python
- String Validators in Python
- I'd like to thank my mentor Martina for her helpful advice and kind words of encouragment and my boyfriend Ciaran for patiently playing my game again and again helping me find errors"
This was my favourite of the portfolio projects to complete so far. While I found implementing and adapting the card game I know and play through coding difficult, I really enjoyed the problem-solving and out of the box thinking I used to get this game to the finish line. I found logically designing the game from start to finish and adding elements to enhance the user experience and robustness of validation extremely rewarding as I could see the improvement in what I was creating. While I feel there are functions that could be optimised to make the code more verstaile, I am excited to keep learning and soon be able to get my code to this place.