Welcome to the tenth entry in the Intermediate ColdFusion Contest. The earlier entries may be found at the end of this post. Today's entry is from Charlie Griefer. 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.
Wow. What a design. I mean - look at that dealer. He looks like a young Tom Cruise. I think this entry will win just for that. ;) Ok, so it's me. Still though, even if it wasn't me, I'd find it pretty darn funny, and cool. It really gives the entry some personality and makes it feel like you are playing with someone, and not just against the computer. I like both the rules box and the Hands Won box. However, the rules box isn't exactly true. The minimum bet is actually 0.1 (10 cents) and you can bet more than 500 dollars (up to 999). There is also no automatic end gate. I got down to 0 dollars (or lower, see below) and the game didn't automatically end. At least though there was a nice and obvious 'start over' button so I wasn't stuck, as I was in some entries.
Outside of this - I didn't see much to complain about. I did find one un-VARed method variable in the init method ("deck"), but I believe that was the only variable he forgot to correctly scope.
I noticed this in his getRaySays method:
<!--- i know this whole method sucks. by the time I realized it, was too late to turn back (deadlines and all, y'know). should have set this variable throughout the CFC so as not to have to re-do all of this logic. look for improvement in version 2.0! --->
Rest easy, Charlie. I've done the same thing. One nice thing about CFC development is you can write 'bad' methods and come back to them later. You can also (and this may be obvious) write completely fake methods. I.e., imagine the game loaded your bank from a database, and the database wasn't written. You could easily just make a method that returned 100, a hard coded value, and return to the method later once the database is set up. Again - this may be obvious - but it is something to keep in mind. Another example - imagine one method needed some complex math, like it needed to return the distance between two zip codes. You can always make the method return some number and then return to the method once you have the math ready.
One last question. I notice he pays 1.5 times your bet on Blackjack. If I bet 3 dollars, this would mean I'd win 4.50. Do casinos do that normally, or do they round down (or up)?