Game/MeasureScore.ps1
param( [PSObject[]] $Cards ) $hardTotal = 0 $softTotal = 0 foreach ($card in $cards) { $hardTotal += [Math]::Min(10,$card.Number) if ($card.Number -eq 1) { if (($softTotal + 11) -le 21) { $softTotal+=11 } else { $softTotal+=1 } } else { $softTotal += [Math]::Min(10,$card.Number) } } [PSCustomObject]@{ HardTotal = $hardTotal SoftTotal = $softTotal RealTotal = if ($softTotal -gt $hardTotal -and $softTotal -le 21) { $softTotal } else { $hardTotal } } |