Scripting Games 2008 Advanced Windows PowerShell Event 10
My Windows PowerShell solution for event 10 is posted on the scriptcenter.
By accident ( I did send a "preview" version to confuse the scripting guys check if format was right), it was not the latest version that got posted, I made some small changes after :
*update* the article on the scriptcenter is now also updated to include the changes mentioned below,
* BugFix * only the first ace was checked for 1 or 11
Function get-Value ($cards){
$aces = $val = 0
$cards |% {
if ($_.card[1] -match '[0JQK]') {$val += 10}
if ($_.card[1] -match '\d') {$val += [int]$_.card[1].toString()}
if ($_.card[1] -match '[A]') {$val += 11;$aces += 1}
}
while ($aces -gt 0 ) {if ( $val -gt 21) {$val -= 10};$aces--}
$val
}
* Addition * and I added the drawing of a facedown card :
Function PaintFaceDownCard ($x,$y){
($y)..($y + 6) |% {ColorLine $x $_ 6 'Blue'}
WriteLine $x ($y + 2) " /\/\ " 'white' 'Blue'
WriteLine $x ($y + 3) " () " 'white' 'Blue'
WriteLine $x ($y + 4) " \/\/ " 'white' 'Blue'
}
As you could see in the teaser here : The Scripting Games have started and some teasers
The complete version of the blackJack function, including these changes, I will attach to this post.
Enjoy,
Greetings /\/\o\/\/