September 4, 200619 yr Anyhow, I decided I would remake my Black Jack game since I was so sad I lost my first one. My computer died and I lost it. :( Click HERE to play my Black Jack game I made using JavaScript. Click HERE to view blackjack.js. *Links removed until I can find a host that Tip.It does allow. Problems... -Occasionally, the script needs to be stop by the user -Two or more of the same card may appear -Cards do not always display immediatly -Heavily relies on prompts, alerts, and confirms Future Additions... -Determine winner, loser, or tied -Money! -More graphics + animations -Score board -Music :) var cardNum = 0; var cardDraw = 0; var cardValue = 0; var cardTotal = 0; var user; var comp; document.write(" "); cardNum = Math.floor(Math.random() * 52 + 1); document.write(""); if(cardNum >= 1) { if(cardNum <= 13) { cardValue = cardNum; } } if(cardNum >= 14) { if(cardNum <= 26) { cardValue = cardNum - 13; } } if(cardNum >= 27) { if(cardNum <= 39) { cardValue = cardNum - 26; } } if(cardNum >= 40) { if(cardNum <= 52) { cardValue = cardNum - 39; } } if(cardValue >= 11) { if(cardValue <= 13) { cardValue = 10; } } if(cardValue == 1) { cardValue = window.prompt("You have an ace! Would you like the value of your ace to be 1 or 11?"); if(cardValue == 1) { cardValue = 1; } if(cardValue == 11) { cardValue = 11; } else { cardValue = 1; } } if(cardTotal == 21) { alert("Black Jack!"); } if(cardTotal > 21) { alert("Busted!"); } cardTotal = cardValue; cardNum = Math.floor(Math.random() * 52 + 1); document.write(""); if(cardNum >= 1) { if(cardNum <= 13) { cardValue = cardNum; } } if(cardNum >= 14) { if(cardNum <= 26) { cardValue = cardNum - 13; } } if(cardNum >= 27) { if(cardNum <= 39) { cardValue = cardNum - 26; } } if(cardNum >= 40) { if(cardNum <= 52) { cardValue = cardNum - 39; } } if(cardValue >= 11) { if(cardValue <= 13) { cardValue = 10; } } if(cardValue == 1) { cardValue = window.prompt("You have an ace! Would you like the value of your ace to be 1 or 11?"); if(cardValue == 1) { cardValue = 1; } if(cardValue == 11) { cardValue = 11; } else { cardValue = 1; } } cardTotal = cardTotal + cardValue; user = cardTotal; alert("The user card total is " + cardTotal + "."); if(cardTotal == 21) { alert("Black Jack!"); } if(cardTotal > 21) { alert("Busted!"); } while(cardDraw == 0) { cardDraw = confirm("Would you like to be hit?"); if(cardDraw == true) { cardDraw = 0; cardNum = Math.floor(Math.random() * 52 + 1); document.write(""); if(cardNum >= 1) { if(cardNum <= 13) { cardValue = cardNum; } } if(cardNum >= 14) { if(cardNum <= 26) { cardValue = cardNum - 13; } } if(cardNum >= 27) { if(cardNum <= 39) { cardValue = cardNum - 26; } } if(cardNum >= 40) { if(cardNum <= 52) { cardValue = cardNum - 39; } } if(cardValue >= 11) { if(cardValue <= 13) { cardValue = 10; } } if(cardValue == 1) { cardValue = window.prompt("You have an ace! Would you like the value of your ace to be 1 or 11?"); if(cardValue == 1) { cardValue = 1; } if(cardValue == 11) { cardValue = 11; } else { cardValue = 1; } } cardTotal = cardTotal + cardValue; user = cardTotal; alert("The user total points is " + cardTotal + "."); if(cardTotal == 21) { alert("Black Jack!"); cardDraw = 1; } if(cardTotal > 21) { alert("Busted!"); cardDraw = 1; } } else { cardDraw = 1; } } document.write(" "); cardTotal = 0; cardNum = Math.floor(Math.random() * 52 + 1); document.write(""); if(cardNum >= 1) { if(cardNum <= 13) { cardValue = cardNum; } } if(cardNum >= 14) { if(cardNum <= 26) { cardValue = cardNum - 13; } } if(cardNum >= 27) { if(cardNum <= 39) { cardValue = cardNum - 26; } } if(cardNum >= 40) { if(cardNum <= 52) { cardValue = cardNum - 39; } } if(cardValue >= 11) { if(cardValue <= 13) { cardValue = 10; } } if(cardValue == 1) { if(cardTotal > 10) { cardValue = 1; } if(cardTotal <= 10) { cardValue = 11; } else { cardValue = 1; } } if(cardTotal == 21) { alert("Black Jack!"); } if(cardTotal > 21) { alert("Busted!"); } cardTotal = cardValue; cardNum = Math.floor(Math.random() * 52 + 1); document.write(""); if(cardNum >= 1) { if(cardNum <= 13) { cardValue = cardNum; } } if(cardNum >= 14) { if(cardNum <= 26) { cardValue = cardNum - 13; } } if(cardNum >= 27) { if(cardNum <= 39) { cardValue = cardNum - 26; } } if(cardNum >= 40) { if(cardNum <= 52) { cardValue = cardNum - 39; } } if(cardValue >= 11) { if(cardValue <= 13) { cardValue = 10; } } if(cardValue == 1) { if(cardTotal > 10) { cardValue = 1; } if(cardTotal <= 10) { cardValue = 11; } else { cardValue = 1; } } if(cardTotal == 21) { alert("Black Jack!"); } if(cardTotal > 21) { alert("Busted!"); } cardTotal = cardTotal + cardValue; comp = cardTotal; alert("The computer total points is " + cardTotal + "."); while(cardTotal < 17) { cardNum = Math.floor(Math.random() * 52 + 1); document.write(""); if(cardNum >= 1) { if(cardNum <= 13) { cardValue = cardNum; } } if(cardNum >= 14) { if(cardNum <= 26) { cardValue = cardNum - 13; } } if(cardNum >= 27) { if(cardNum <= 39) { cardValue = cardNum - 26; } } if(cardNum >= 40) { if(cardNum <= 52) { cardValue = cardNum - 39; } } if(cardValue >= 11) { if(cardValue <= 13) { cardValue = 10; } } if(cardValue == 1) { if(cardTotal > 10) { cardValue = 1; } if(cardTotal <= 10) { cardValue = 11; } else { cardValue = 1; } } if(cardTotal == 21) { alert("Black Jack!"); } if(cardTotal > 21) { alert("Busted!"); } cardTotal = cardTotal + cardValue; comp = cardTotal; alert("The computer total points is " + cardTotal + "."); } if(user <= 21) { while(user > comp) { cardNum = Math.floor(Math.random() * 52 + 1); document.write(""); if(cardNum >= 1) { if(cardNum <= 13) { cardValue = cardNum; } } if(cardNum >= 14) { if(cardNum <= 26) { cardValue = cardNum - 13; } } if(cardNum >= 27) { if(cardNum <= 39) { cardValue = cardNum - 26; } } if(cardNum >= 40) { if(cardNum <= 52) { cardValue = cardNum - 39; } } if(cardValue >= 11) { if(cardValue <= 13) { cardValue = 10; } } if(cardValue == 1) { if(cardTotal > 10) { cardValue = 1; } if(cardTotal <= 10) { cardValue = 11; } else { cardValue = 1; } } if(cardTotal == 21) { alert("Black Jack!"); } if(cardTotal > 21) { alert("Busted!"); } cardTotal = cardTotal + cardValue; comp = cardTotal; alert("The computer total points is " + cardTotal + "."); } } document.write(""); document.write(""); Please leave behind comments and/or suggestions.
September 4, 200619 yr Unfortunately your link is not going to work as we no longer allow links to that specific host. Just a tip though , 21 is not a blackjack , BlackJacK is ONLY if 21 is achieved in your first 2 cards :) The best bet would probably be to add another variable of how many cards the user or dealer have and if cardTotal = 21 AND variable = 2 , BlackJack :) Just besure to increment the variable by 1 with each card dealt and reset it at the begining of the script :) I like to fart silently but deadly in movie theatersArd Choille says (11:41 PM):I wouldn't dare tell you what to do m'dear
September 4, 200619 yr Not bad, all thought albosky is right, it is not a hard problem to fix. ill look forward to seeing some further progress with this :) Current Goals80/80 Fletching60/75 Woodcutting97/100 Combat
September 4, 200619 yr Author Aw, that's a shame. What host do you guys accept so people would be able to view and play the game? Bleh, I forgot about that. One of my family told me to make a black jack game and it has been awhile since I have played it so I don't remember so much of it. Somebody told me that if you have 5 cards, you automatically win which I am not sure if that is true. I'll fix that, but please tell me another free host I can use to share stuff I have made. :) EDIT: I guess for now, I will just display blackjack.js which is the important part. :)
September 4, 200619 yr Do you want me to upload it to yourmysin.info ? Current Goals80/80 Fletching60/75 Woodcutting97/100 Combat
September 5, 200619 yr Author At least 21 is more fun then blackjack...^_^ At least 21? Is that another game? Mysin, if that is your own site, make sure to give credit to me :lmfao:. Sure. Just post up the link here. :)
September 7, 200619 yr At least 21 is more fun then blackjack...^_^ At least 21? Is that another game? Mysin, if that is your own site, make sure to give credit to me :lmao:. Sure. Just post up the link here. :) was only planning on it if you wanted to demonstrate it, but i would need the card images :P Current Goals80/80 Fletching60/75 Woodcutting97/100 Combat
Create an account or sign in to comment