/pp3-bull

Primary LanguagePython

Developer: Orna Reynolds

đź’» Visit live website

About

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.

Table of Contents

Project Goals

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.

User Goals

  • 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

Site Owner Goals

  • 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

User Experience

Target Audience

Those of all ages who enjoy card games and more specifically card bluffing games.

User Stories

Users

  1. I want the name of the game clearly displayed and have an idea how to play it from first look.
  2. I want to be asked if I want to start the game or read the rules first
  3. I want to be able to start the game after I have read the rules of the game
  4. I would like the cards in my hand to display as a graphic picture and for them to update when I play a card
  5. I want to receive feedback from the game about the my inputs and have the opportunity ti input them again if I am wrong.
  6. I want the option to play again once the game is over
  7. If I play the game multiple times, I want how many times I have won to be saved
  8. I want to enter my name at start of game to personalise it
  9. I want the communal cards pile displayed so I know how many cards the next loser of the round could get

Site Owner

  1. 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
  2. I want the user to have the option to play the game again without having to exit. This is to enhance user experience.
  3. I want the user's name and how many times they have won to be saved to google sheets.
  4. I want user inputs to undergo extensive validation so game execution is not affected.

Back to Table Of Contents

Technical Design

Flowchart

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.

Screenshot

Data Model

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
Screenshot

Technologies Used

Languages

  • Python

Frameworks & Tools

  • 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

Libraries

Python Libraries

  • 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

Third Party Libraries

  • 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

Back to Table Of Contents

Features

Title screen

  • 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
Screenshot

Menu

  • Gives user option to play the game or read the rules first
  • User stories covered: 2, 3
Screenshot

Game rules

  • Displays clear game rules
  • Allows user to start game once they are ready
  • User stories covered: 3
Screenshot

Cards display

  • Displays all players cards
  • Shows user their number cards
  • Hides other player cards from user seeing type
  • User stories covered: 4, 10
Screenshot

Name prompt

  • Ask user their name
  • Relay back to user at various points throughout the games
  • User stories covered: 8, 12
Screenshot

Communal cards pile counter

  • Counts number of cards user discarded in to pile
  • Pile increases or decreases as game is played
  • User stories covered: 9
Screenshot

Play again

  • Gives user option to restart game whether they win or lose
  • User stories covered: 7
Screenshot

Back to Table Of Contents

Validation

My code was validated through CI Python Linter with no errors

Screenshot

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.

Testing

Manual Testing

Users stories

  1. 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
Screenshot
  1. 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
Screenshots
  1. 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
Screenshot
  1. 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
Screenshot
  1. I want to receive feedback from the game about the my inputs and have the opportunity ti input them again if I am wrong.

See validation section

  1. 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
Screenshot
  1. If I play the game multiple times, I want how many times I have won to be saved
  2. 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
Screenshot
  1. 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
Screenshot

Site Owner

  1. 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
Screenshot
  1. I want the user's name and how many times they have won to be saved to google sheets.
Screenshot
  1. 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 |
Screenshot

Back to Table Of Contents

Bugs

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

Future features

  • 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

Deployment

  1. Update requirements.txt file by using this command in the terminal Pip3 freeze > requirements.txt. This populates this file with necessary dependencies.
Screenshot
  1. Login to heroku and navigate to dashboard where have option to creat a new app
Screenshot
  1. Choose a unique name and select Europe as destination
Screenshot
  1. Once app is created navigate to settings and press button “reveal config vars”
Screenshot
  1. Add creds key and content from creds file as value
Screenshot
  1. Add port key and 800 value to to config var also
Screenshot
  1. Scroll down and add python build pack and save changes
Screenshot
  1. Add node.js build pack also. It is important to make sure python buildpack is added first and hence ontop of node.js buildpack.
Screenshot
  1. Scroll back to top of page and click deploy tab
Screenshot
  1. From the deploy methods displayed select GitHub
Screenshot
  1. Search for repo name and click connect to link the two up
Screenshot
  1. Deploy from branch and follow link to deployed site after it loads
Screenshot

Back to Table Of Contents

Credits

Code

Acknowledgements

  • 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"

Final thoughts

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.