Git Product home page Git Product logo

third-project-ci-2's Introduction

Three of a Kind Game

Three of a Kind Game was developed to entertain the user/player, and force him/her to use his/her memory to make better decisions. It is a card game where the player faces the computer. Each player (user/computer) receives 4 cards, in each round has to discard an unwanted card and draw a new one from two options, current deck game (hidden) or discard deck (revealed), being able to take only the top card. The player who gets 3 of the same cards wins.

The game is deployed on Heroku and is strictly terminal-based for user interaction.

  • This application is designed to run on desktop, not responsive for mobile and tablets.

Contents

Summary

UX/UI Design

Strategy

Site owner goals

  • The game targets those who are excited by card games and challenges. The project was designed to be an alternative game, a way to train your mind and pass your time. People who are interested in different games and games that involve cards could be a potential audience.

User stories

  • As a user, I want to understand the purpose of the website, so I can know if it's of interest to me.
  • As a user, I want to easily navigate the site/game, so I don't get lost trying to navigate/play.
  • As a user, I want to be able to check my points and those of my opponent, to know my performance.
  • As a user, I want to be able to restart/quit the game, if it is in my interest to start again for some reason.

Scope

  • For the Three of a Kind Game I have planned the following features.
    • Use of the python language efficiently to make the game don't show any problems.
    • Through the terminal-based, display as clearly as possible the cards and dynamics of the game

Structure

  • The Three of a Kind Game structure is based on a single static web page with the terminal-based to run the game.

Skeleton

Flowchart

  • The flowchart was elaborated to guide the development of the game steps.
Flowchart

Surface

Colour scheme

  • To make the game more intuitive and to highlight certain aspects such as suits, selection options or to highlight one information differently from another. I chose to use ANSI colors in the terminal.

Features

This project consists of a single page with the layout and configuration provided by the Code Institute, this template was dedicated to Heroku deployment. The program will be executed in a terminal.

Existing Features

Main menu

  • When you start the program, the main menu is displayed. In which the name of the game/project appears in yellow followed by the initial options for the player to run. These are [P] to play, [R] to show the rules, and [Q] to close the program.

Rules

  • When selecting the rules, the terminal will show a list containing gameplay instructions and the objective of the game.

Quit

  • When you execute the exit option, the program will be closed. It will no longer give the player the option to execute any commands, only after restarting the page or through the run button

Flip Coin

  • Is executed right after the player chooses option [P] to play. Before starting he must choose between heads or tails to decide if he will start or if it will be the machine. It has the options [H] for heads or [T] for tails.
  • The program tosses the coin and returns 50/50 odds. If the selected option is the result, it will return a winning message to the player. The image of the result will always be shown on the terminal.
  • If the selected option is not the one chosen by the player, the result of the coin toss will be displayed on the screen. And the message that the choice was not the right one. Then the computer will start the game.

Game

The game displays on the terminal in the following order from top to bottom. - First, the computer's hand with 4 cards hidden. - The table shows the two decks (main and discard decks) with the option for each one below it along with a card counter, in the middle of the decks is the score counter and at the end on the right are revealed even more 4 cards besides the revealed deck. - The player's hand with the 4 visible cards to decide the plays, with the selection options for each one below. - And finally, the text describes the player's or computer's current move.

  • Player Actions

    • The player has two screens for his moves, the first is the selection for the discard, where the player must choose which of the 4 cards he wishes to discard. The discarded card will be placed in the revealed deck, where the next player can pick it up if it is useful.
    • The options for the selection are given in ordered numbers, being [1], [2], [3] or [4]. By selecting the option the card will be removed from the hand and will not appear on the next screen of the terminal.
  • After the discard action, the player must choose which card to buy. You have two options to select from, the main deck identified as [H] for hidden and the discard deck that is face-up, identified as [R] for revealed.
  • Each action takes the last available card at the top of each deck. The card discarded by the player in the previous action is described separately from the discard deck, until the end of the player's purchase action
  • During the card purchase step the player can choose the option [B] that ends the current game and displays the question of whether the player wants to continue playing or return to the menu.
  • The options are [Y] to continue (where the cards will be dealt again) or [N] which will return to the main menu and reset the points.
  • Computer

  • After the player's two choices, the computer will run the code and decide what action to take. It first separates the cards in the hand into potential winning and discarding options. Then it compares the cards in the hand to discard and then draws the card with the most potential to win.

  • I used the time library to add a delay to the computer's play so that the game would have better dynamics.

  • Win / Loss

  • At each hand played the function to check the winner checks both hands and returns whether the player was the winner or the loser of this game.

  • A message is printed on the terminal and the computer's hand is revealed, in both cases (victory or defeat). The point counter adds one point for each game. The score is reset to zero when the player goes back to the main menu and starts the game again.

  • A question is printed asking whether the player would like to continue playing, or whether he or she wants to return to the main menu. The options are [Y] for yes, continue playing, and [N] for no and return to the menu.

Features Left to Implement

  • To be implemented in the future, I am thinking about the possibility of adding a ranking that receives the player's name and the player's victory and defeat points. This ranking would be accessed from the menu to encourage players to try to beat the records.

Testing

During these tests, the size of the displays was adjusted, when to clean the terminal to keep the game fixed. In the end, I found what I believe to be the most pleasing and intuitive look for the scope of a terminal-based game.

Funcionality

  • Once the game was finished, I played it several times to find possible flaws or errors that could compromise the gameplay or interrupt the game. All commands are responding as they should, when some wrong selection is sent to the terminal, the answers are appearing to the user. So far, when I finished and made the final deployment, the game is responding with no apparent errors.

Navegation and Devices

  • With the project finished, I performed several tests on different browsers and different computers to check the playability and possible faults. No errors were presented during these tests

  • Desktop

    • Sony Vaio (Laptop)
    • Dell XPS (Laptop)
    • Asus Chromebook (Laptop)
    • Macbook Air (Laptop)
    • HP (CPU)
  • Browsers

    • Chrome
    • Firefox
    • Safari
    • Edge

Validator Testing

  • Pyhton
  • I tested the code through PEP8 and no significant errors were presented.

User Story Testing

  • User Story 01: As a user, I want to understand the purpose of the website, so I can know if it's of interest to me.

  • Outcome: When the user visits the application can access the rules to understand the game. Passed.

  • User Story 02: As a user, I want to easily navigate the site/game, so I don't get lost trying to navigate/play.

  • Outcome: When the user visits the application he can read the options for each action, and the actions are subjective. Passed.

  • User Story 03: As a user, I want to be able to check my points and those of my opponent, to know my performance.

  • Outcome: When the application/game is executed, it is possible to visualize the score in the middle of the terminal. Passed.

  • User Story 04: As a user, I want to be able to restart/quit the game, if it is in my interest to start again for some reason.

  • Outcome: When the user executes the application/game he can go back and forth to the game as many times as you want. Passed.

Fixed Bugs

  • When executing the start_game function there was an error when passing the card information from the main deck to the revealed deck. It was directly adding the card without using a third variable, transforming the reveal_deck list into a string. To do this I added a new variable that took the value from the deck and passed it to reveal_deck through append. Commit

  • The function for the computation action was faulty due to the wrong variable name, I added if/else to check if the card displayed in the discard deck would be bought to win the game. Commit

  • When the player performs the pick a new card function, if he chooses the revealed deck, he picks the card he has just discarded. I changed the revealed deck index from [-1] to [-2] to solve the problem. Commit

  • The win check function was considered a win when there were 2 pairs in the hand, to fix the problem I used the same function (Counter) used for the computer action. It creates a dictionary where the key is the card and the value is the number of times it repeats in a list. So when it equals 3 it will be a win. Commit

  • The players' points were not being counted while the variable for the points was set to an integer, the solution I found was to change to a list and append the points, using the length to count the total points for each. Commit

  • I added two ifs at the end of the function in case of error, where it guarantees that the computer has 4 cards in its hand at the end of its turn. And I deleted one for loop that ended up running unnecessarily and added two breaks to the other for loop, which sometimes caused the computer to buy more than one card. Commit

Unfixed Bugs

  • Up to the present moment when this project has been finalized, I have not identified any unfixed errors.

Deployment

  • To create this project I used GitHub and GitPod.
  • I used the Code Institute Python Essentials Template, clicking on the "Use this template" button. From there I created the repository on Github with my username.
  • These commands were used for version control during project:
    • git status - to check the status of the files to be commited.
    • git add filename - to add files before committing.
    • git commit -m "message" - to commit changes to the local repository.
    • git push - to push all committed changes to the GitHub repository.

Deployment

  • After finishing developing the program I deployed it on Heroku following these steps:
  1. Create an account if you don't have one and login into Heroku website
  2. After logged in, you should click on "New -> Create new app" button
  3. Insert your app's Name (need to be unique), then you need to Choose your region, at the end click on the "Create App" button
  4. Navigate into the Settings tab, and go to "Config vars" section, then go to "Reveal Config Vars"
  5. Enter the PORT in the KEY section and 8000 for its value, then click "Add"
  6. Next you need to go to "Buildpacks" section and click "Add buildpack"
  7. Firstly add the Python buildpack then NodeJs, need to be in that order
  8. Navigate to the "Deploy" tab, and select Github as the deployment method
  9. You need to look for your repository name and select the option Connect
  10. You can choose between two deployment options for your app to Heroku (Automatic or Manual).
    • With automatic deploys enabled, your app will be updated each time a change has been pushed to the repository
    • With manual deploys, your app will be updated only when you manually click to deploy it
  11. After these steps the deploying is finished, a link will be provided to you for accessing your app

Fork

  • Forks let you make changes to a project without affecting the original repository. Follow this steps:
  1. Go to the repository page, can be accessed here.
  2. On top right, you select the Fork option and proceed.
  3. A duplicate will be created inside your repository.

Clone

  • Clone let you create an identical repository to the original. Follow this steps:
  1. Go to the repository page, can be accessed here.
  2. Click on code drop down menu.
  3. Choose if you want to clone using HTTPS, SSH or GitHub CLI. Then select de copy button.
  4. Open your Git Bash in your IDE.
  5. Type git clone and then paste the URL you copied before.
  6. Press Enter to create your clone.

Technologies and tools

  • Programming languages used: Python 3.6
  • Python libraries used: random / os / time
  • Gitpod - Used to create/edit the code of the project.
  • Github - Used to create repository, hosting files and deployment of the website.
  • Heroku - Used to deploy the project
  • Ludichart - Used to create the flowchart.
  • PEP8 - Used to test/validate Python code.
  • Python Tutor - Used to run tests during project development.

Credits

Media

  • The image used for README.md responsive mockup was taken from Am I Responsive.

Inspiration

  • I used the content on this webpage to help implement the colors in the terminal (It is in Portuguese). Website
  • I used the content on this Stack Overflow question, to implement at my project to clear the terminal. Website

Acknowledgements

  • Code Institute for all the support and the team always ready to help.
  • My mentor Ben Kavanagh for all the instructions, advice and knowledge that helped me to improve the project.
  • My parents, my wife and my friends for motivating me to achieve my best.
  • Everyone in the Slack community for tips and opinions.

third-project-ci-2's People

Contributors

guisgrande avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.