Lab 10
For this lab, you will be creating a "functional and illogical" blackjack
game. The game will not have gambiling or card values, but it will have
the functionality of blackjack actions: deal, hit, stand, and surrender.
Setting Up The Page
Create divisions for the dealerArea and the playerArea. Within the
dealerArea there will be a div for the two images (dealer's cards). Within
the playerArea there will be five images (palyer's cards). Create a
seperate division controlArea, which will include the divs/buttons with
onclick calls for DEAL, HIT, STAND, and SURRENDER.
Functions
Use the example
given in class to initialize your deck images array.
When the page loads, call the initDeck function immediately. topCard
will be our iterator that will traverse the deck. Each time a
card is "dealt", topCard will be incremented.
- deal() - shuffle the deck, and then deal two cards to the playerArea's
first two images, deal one card to the dealerArea's img, and set the dealer's
second image to a facedown image (ex. face down or partial face down).
Using this function to invoke a 'new game' we will have to reset our hits
counter variable to 0, access the playerArea's cards and change the opacity
back to default 1 (invoked by surrender), and reset topCard back to 0.
- hit() - deal another card to the playerArea and increment a counter variable
that will count the number of hits. If the user has already hit 3 times,
disallow the following action.
- stand() - access the dealerArea's second image (the face down image) and
change the source of the image to a newly dealt card.
- surrender() - access the playerArea's cards and change the opacity to
0.5 for each card. Call function stand() to reveal the dealer's second
image.
- initDeck() / shuffle() / swap() - given cardObject.js contains the following functions.