Giter VIP home page Giter VIP logo

project1-blackjack's Introduction

Project #1 - Blackjack

Description

A blackjack game where the user can play against the AI dealer. Betting is built into the game as a way to track wins and losses across multiple games.

https://karlmorand.github.io/project1-blackjack/

Game Rules

The dealer deals two cards to himself and the player, starting with the player. Only one of the dealer's cards is visible to the player. If the player's cards total 21 on the initial deal the player wins.

The player then has the option to receive an additional card ('Hit') or end their turn. They can take as many additional cards as they'd like, with the goal being to have the sum of their cards equal 21. If the player goes over 21 he busts and the dealer wins.

The player starts with $500 to bet with, and can make a bet before each game. All ties go to the player. Aces can be used as a 1 or 11.

Technologies

Javascript, jQuery, HTML5, CSS3.

Resources

Playing card images are from http://wheels-cards.wc.lt/bo.html This site is also cited in index.html line 9.

Unsolved Issues

I'd like to grow the multiplayer aspect of the game so that a user could play at a table with multiple AI players. The visual design of the game could also be improved. I would also add some timers throughout the game so certain gameplay events happen less instantaneously, which would feel more realistic.

project1-blackjack's People

Contributors

karlmorand avatar

Watchers

James Cloos avatar  avatar

project1-blackjack's Issues

Game flow

Need to diagram out the game flow and which functions call which other functions.

winner function

Removes the game UI and puts up text indicating who has won.

Next player function

When a player's (or dealer's) turn is finished this function is called. Based on conditions it decides who's turn is next and calls the appropriate function for their turn.

Intoxication factor for AI players

As the number of games increases the AI players get more intoxicated, as if they were sitting at a casino table getting free drinks. The more intoxicated they are the more likely they are to make choices that aren't the optimal blackjack moves.

Check cards function

This function must be called after everything that affects the cards on the table...initial deal, a player taking an additional card, etc.

This function checks to see if the cards === 21, if they bust, or if neither of those then return their score.

  • gets an array of the player's/dealer's cards as input
  • converts the string values into a format that can be added together
  • adds the cards and checks against several conditions (switch?)...
  • do they have blackjack (only two cards totaling 21)
  • are they below 21 (return the number so other action can be performed as necessary, such as dealer having to hit)
  • are they over 21 and bust
  • do they have non-blackjack 21

Separate the checkHand function

Need to have at least two functions:

  • One that just adds the cards of the array of cards sent to it
  • One that checks to see if that array of cards busts, is blackjack

User can click the 'hit' button to receive another card

  • gets array of currently available cards
  • chooses a random number based on the length of that array
  • get the card that's at that index and add it to the players hand array
  • remove the card from the deck
  • send the players updated array to the checkHand function to see if they won, bust, etc
    the checkHand function will handle the logic of what to do next, such as end the game because of bust, or tell dealer to take turn, etc.

Create basic card table layout

Don't worry about fancy colors, transitions, animation, etc. Just have spaces for the player's cards, the Hit and Hold buttons, and the dealer's cards. This screen will be visually improved and iterated once MVP is complete.

  • divs created to hold player's two cards
  • buttons created for Hit and Hold
  • divs created to hold dealer's cards

User can click 'start game' button to shuffle and deal

This button and its function shuffle a fresh deck of cards, gets how many players are playing, and deals the cards to them.

  • start button appears on screen and has a click event
  • create an array of cards
  • get one random number and assign the card at that index to the player
  • get one random number and assign the card at that index to the dealer
  • get one random number and assign the card at that index to the player
  • get one random number and assign the card at that index to the player
  • make sure that each card is removed from the array of cards when it is dealt, before any more cards are dealt
  • start button is removed from the screen after it is clicked

whoWins function

This function is called at the end of the game if nobody busts or gets blackjack. It will compare the scores and decide the winner.

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.