Welcome to the ninth entry in the Intermediate ColdFusion Contest. The earlier entries may be found at the end of this post. Today's entry is from Lior Gonda. Before reading on, please check his application here. You can download his code from the download link at the bottom. Please respect the copyright of the creator. As with the last contest, it is taking a while to go through the entries, but I hope people are finding this worthwhile. We only have 3 left, so I'm hoping to have a winner Friday night.
So - I have to say that I really don't like the design. Well - not the design per se - but the colors. I found it very hard to read. Maybe it's just my eyes - but the text of the buttons was very hard to make out. I'd probably consider a backgroud color for the play area while keeping the wood background. This isn't a design contest of course - but still, it bugged me. While playing, I noticed that there didn't seem to be a way to end the game. I ended up with 5 bucks left, and was stuck. I couldn't bet less then 10, and every button I hit simply told me I didn't have enough(t) money. (Typo there too.) Let's take a look at his code. The first thing I saw that bugged me was this from Application.cfm:2 session.com.deck = createObject('component','models.deck').init(1);
Comment 1 written by Scott Slone on 7 December 2005, at 4:24 PM
Comment 2 written by Jason on 7 December 2005, at 4:58 PM
This is something that I have seen with many of the entries, not just isolated to this one. If you refresh the page the current hand is wiped away, while it is not a huge deal. If I do not like the cards I am delt, I can simply refresh the page and get a re-deal. Of course this is not going to be used on a actual gambling site, but in my opinion a big problem.
Some additional little things:
- I also did not see the point of having to hit "New Hand" each time. Once the game is over placing a new bet should be the new hand indicator.
- I had A,K for a natural Black Jack but the game still made me choose stay. It would be nice if it forced then to stay so they do not make a mistake and hit on a BJ.
Other than that, I think it operated well. I liked the win/loss tracking.
Jason
Comment 3 written by Dan G. Switzer, II on 7 December 2005, at 6:09 PM
* If you click the "HIT" button in rapid succession, you'll keep getting new cards. I was able to get 70 on one hand.
* You can also "HIT" before actually being dealt cards.
* Along the lines of the same bug, if hitting the "HIT" button in rapid succession causes mysterious loses of funds. Somehow after 1 single $10 bet, I ended up with -$2730.
Comment 4 written by tony of the weeg clan on 7 December 2005, at 7:27 PM
:) i think im #10, please be nice.
remember, im a 100% self taught and
no framework person. not to mention
there were some last minute code changes
that i just didnt have time for. also
if the player and the dealer both get cards
and the player has over 17 and the dealer has
at least 17 and the player wins, i make
the player an automatic winner without letting
them mess up... kinda let them win at that point.
small bug in my winner decision code.
/hiding until mine is judged and nervous :)
tony
Comment 5 written by Justice on 8 December 2005, at 7:03 AM
In the deck.cfc file:
for ( deck_idx = 1; deck_idx lte variables.instance.numberOfDecks; deck_idx = deck_idx + 1 ) {
for ( figure_idx = 1; figure_idx lte 13; figure_idx = figure_idx + 1 ) {
for ( suit_idx = 1; suit_idx lte 4; suit_idx = suit_idx + 1 ) {
card = structNew();
card.number = figure_idx;
card.suit = suit_idx;
cardImg = '';
switch(suit_idx){
case "1":{
cardImg = 'c';
break;
}
case "2":{
cardImg = 'd';
break;
}
case "3":{
cardImg = 'h';
break;
}
case "4":{
cardImg = 's';
break;
}
}
if ( figure_idx lte 10 ){
cardImg = cardImg & figure_idx;
}
else if( figure_idx eq 11 ){
cardImg = cardImg & 'j';
}
else if( figure_idx eq 12 ){
cardImg = cardImg & 'q';
}
else if( figure_idx eq 13 ){
cardImg = cardImg & 'k';
}
cardImg = cardImg & '.gif';
card.Img = cardImg;
arrayAppend(variables.instance.deck, card);
}
}
}
Comment 6 written by Dan G. Switzer, II on 8 December 2005, at 9:50 AM
In a nutshell, here's what the code does:
1) Determine how many "decks" you're playing with. My casinos will play with multiple decks of cards, so that's what the first outer loop does.
2) Next, create a card. This is sets up the 2-10, Jack, Queen, King and Ace (13 cards total.) That's what the next loop does.
3) Next, create a Heart, Diamond, Club and Spade for each card. In each deck there are 4 suits of 13 cards. That's what the inner loop does.
4) The switch statement is simply assigning the suit type based on a number. Personally, I would have either used a suit list in step #3 or used an integer to represent the suit instead of remapping to a single charater.
5) The if/else statements simply set up what image to display to represent the card.
6) The arrayAppend() statement adds the card to your array of available cards. The variables.instance.deck is what actually holds a reference to all the cards that are available until it reshuffles.
[Add Comment] [Subscribe to Comments]