Break on ; KIXPOKER.KIX ; KIXTART POKET POKER ; ; KIXTART 4.0 ; KIXFORMS 2.0.0 ; ; This is a variation on a public domain ; poker game written in VB. Actually, it ; was written for the Pocket PC - a fact ; that will seem obvious when you run ; this script for the first time. Bells ; and whistles added by your truely ; ; Game play: ; ; Press Bet 1 to bet one token ; Press Bet Max to bet the max no. of tokens (5) ; Press Draw to draw a hand full hand of cards ; Press 1-5 to discard your unwanted cards. Press again to bring back. ; Press Draw (again) to draw more cards. ; Press Spin button for a quick larf ; ; GAME SETTINGS ; $BACKCOLOR = &005500 ; Dark Green $FORECOLOR = &00ffff ; Yellow $CR = Chr(13) $form = CreateObject("kixtart.form") $form.caption = "KiXPoker" $form.scaleheight = 235 $form.scalewidth = 3480/15 $form.center $form.backcolor = $BACKCOLOR $form.forecolor = $FORECOLOR $form.fontsize = 8 $form.fontbold = 1 $Form.Icon = "shell32.dll;24" $label1 = $form.label("Current Bet",8,4,45,25) $label1.backcolor = $form.backcolor $label1.forecolor = $form.forecolor $label1.alignment = 2 $label2 = $form.label("Current Score",184,4,45,25) $label2.alignment = 2 $label2.backcolor = $form.backcolor $label2.forecolor = $form.forecolor $bet = $form.label("0",8,35,45,25) $bet.alignment = 2 $bet.forecolor = $form.forecolor $bet.backcolor = $form.backcolor $score = $form.label("0",184,35,45,25) $score.alignment = 2 $score.forecolor = $form.forecolor $score.backcolor = $form.backcolor $message1 = $form.label("Welcome",52,4,125,25) $message1.alignment = 2 ; center $message1.fontsize = 11 $message1.backcolor = $form.backcolor $message1.forecolor = $form.forecolor $message2 = $form.label("@userid",52,30,125,25) $message2.alignment = 2 ; center $message2.fontsize = 11 $message2.backcolor = $form.backcolor $message2.forecolor = $form.forecolor $betone = $form.commandbutton("Bet 1",8,160,65,31) $betone.onclick = "betone_click" $BetOne.MousePointer = 16 $BetOne.ToolTip = "Ah come one - live dangerously !" $betmax = $form.commandbutton("Bet Max",8,194,65,31) $betmax.onclick = "betmax_click" $BetMax.MousePointer = 16 $BetMax.ToolTip = "Goin' for the Gusto !!!" $Draw = $form.commandbutton("Draw",81,160,68,65) ;$Draw.fontsize = "12" $Draw.onclick = "draw_click" $Draw.MousePointer = 16 $Draw.Icon = "shell32.dll;22" $Draw.ToolTip = "Draw!" $Spin = $form.commandbutton("Spin!",155,160,65,31) $Spin.onclick = "spin_click" $Spin.MousePointer = 16 $Spin.ToolTip = "Don't like Poker ... how about Slots ?" $Exit = $form.commandbutton("Exit",155,194,65,31) $Exit.onclick = "exit_click" $Exit.MousePointer = 16 $Exit.ToolTip = "I'm outta here!" Global $hold[4] $hold[0] = $form.commandbutton("1",8,132,37,21) $hold[1] = $form.commandbutton("2",52,132,37,21) $hold[2] = $form.commandbutton("3",96,132,37,21) $hold[3] = $form.commandbutton("4",140,132,37,21) $hold[4] = $form.commandbutton("5",184,132,37,21) For $i=0 to Ubound($hold) $Hold[$i].Enabled=0 $Hold[$i].OnClick = "hold_click($i)" $Hold[$i].MousePointer = 16 Next Global $values[4] $values[0] = $form.label("P",8,68,37,28) $values[1] = $form.label("O",52,68,37,28) $values[2] = $form.label("K",96,68,37,28) $values[3] = $form.label("E",140,68,37,28) $values[4] = $form.label("R",184,68,37,28) For Each $label in $values $label.alignment = 2 $label.forecolor = &0 $label.fontsize = 18 $label.backcolor = &0ffffff Next Global $suites[4] $suites[0] = $form.label("",8,93,37,28) $suites[1] = $form.label("",52,93,37,28) $suites[2] = $form.label("",96,93,37,28) $suites[3] = $form.label("",140,93,37,28) $suites[4] = $form.label("",184,93,37,28) For Each $label in $suites $label.alignment = 2 $label.forecolor = &0FF $label.backcolor = &0FFFFFF $label.fontname = "symbol" $label.fontsize = 18 $label.caption = Chr(169) Next Global $madeck[10] Global $minextcard Global $firstdraw Global $mybet Global $myscore Global $masuite[13] SRND(@ticks) $myscore = 100 $firstdraw = 1 $draw.enabled = 0 $score.caption = $myscore $minextcard = 1 $Form.Show $BetMax.SetFocus While $Form.Visible $=Execute($Form.DoEvents) Loop Exit 1 Function betone_click() If $mybet < 5 $mybet = $mybet + 1 $draw.enabled = 1 EndIf $bet.caption = $mybet If $myscore - $mybet = 0 $betone.enabled = 0 EndIf EndFunction Function betmax_click() $mybet = 5 $bet.caption = $mybet $draw.enabled = 1 $draw.SetFocus() $draw.default = 1 draw_click() EndFunction Function hold_click($button) If $values[$button].visible = 0 $values[$button].visible = 1 $suites[$button].visible = 1 Else $values[$button].visible = 0 $suites[$button].visible = 0 EndIf $draw.SetFocus() EndFunction Function draw_click() Dim $icounter If $firstdraw $message1.caption = "" $message2.caption = "" $betone.enabled = 0 $betmax.enabled = 0 $spin.enabled = 0 $myscore = $myscore - $mybet $score.caption = $myscore shufflecards() For $i=0 to Ubound($values) $values[$i].tag = getnextcard() $values[$i].caption = getcardvalue(Val($values[$i].tag)) $values[$i].forecolor = getcardcolor(Val($values[$i].tag)) $suites[$i].caption = getsuitimage(Val($values[$i].tag)) $suites[$i].forecolor = $values[$i].forecolor Next $firstdraw = 0 For Each $button in $hold $button.enabled = 1 Next $message2.caption = "Discard ..." Else $draw.enabled = 0 For $i = 0 to Ubound($values) If $values[$i].visible = 0 $values[$i].tag = getnextcard() $values[$i].caption = getcardvalue(Val($values[$i].tag)) $values[$i].forecolor = getcardcolor(Val($values[$i].tag)) $suites[$i].caption = getsuitimage(Val($values[$i].tag)) $suites[$i].forecolor = $values[$i].forecolor $values[$i].visible = 1 $suites[$i].visible = 1 EndIf Next checkforwinninghand() $mybet = 0 $bet.caption = $mybet If $myscore > 0 $betone.enabled = 1 EndIf If $myscore > 4 $betmax.enabled = 1 EndIf For Each $button in $hold $button.enabled = 0 Next $spin.enabled = 1 $firstdraw = 1 EndIf EndFunction Function checkforwinninghand() Dim $x For $x = 1 to Ubound($masuite) $masuite[$x] = 0 Next For $i = 0 to Ubound($values) $number = getcardnumber(Val($values[$i].tag)) $masuite[$number] = $masuite[$number] + 1 Next Select $message2.caption = "" Case isroyalflush() $myscore = $myscore + ($mybet * 1000) $message2.caption = "Royal Flush!" Case isstraightflush() $myscore = $myscore + ( $mybet * 50 ) $message2.caption = "Straight Flush" Case isfourofakind() $myscore = $myscore + ( $mybet * 25 ) $message2.caption = "Four of a Kind" Case isfullhouse() $myscore = $myscore + ( $mybet * 8 ) $message2.caption = "Full House" Case isflush() $myscore = $myscore + ( $mybet * 5 ) $message2.caption = "Flush" Case isstraight() $myscore = $myscore + ( $mybet * 4 ) $message2.caption = "Straight" Case isthreeofakind() $myscore = $myscore + ( $mybet * 3 ) $message2.caption = "Three of a Kind" Case istwopair() $myscore = $myscore + ( $mybet * 2 ) $message2.caption = "Two Pair" Case istwoofakind() $myscore = $myscore + $mybet $message2.caption = "One Pair" Case 1 $message2.caption = "" EndSelect If $message2.caption $message1.caption = "WINNER!!!" Else $message1.caption = "Sorry" $message2.caption = "Place your bet" EndIf $score.caption = $myscore EndFunction Function istwoofakind() Dim $i $istwoofakind = 0 For $i = 1 to Ubound($masuite) If $masuite[$i] = 2 $istwoofakind = 1 ; if $jacks_or_better and ($i < 11 and $i > 1) ; $handisapair = 0 ; endif EndIf Next EndFunction Function istwopair() Dim $found Dim $i $istwopair = 0 $found = 0 For $i = 1 to Ubound($masuite) If $masuite[$i] = 2 If $found $istwopair = 1 Else $found = 1 EndIf EndIf Next EndFunction Function isthreeofakind() Dim $i $isthreeofakind = 0 For $i = 1 to Ubound($masuite) If $masuite[$i] = 3 $isthreeofakind = 1 EndIf Next EndFunction Function isstraight() $isstraight = 0 $n = 0 $ace = 0 For $x = 1 to Ubound($masuite) If $masuite[$x] = 1 $n = $n + 1 If $n = 1 AND $x = 10 AND $ace $n = $n + 1 EndIf If $n = 5 $x = Ubound($masuite)+1 EndIf Else If $n > 0 AND $n < 5 If $n = 1 AND $x = 2 $n = 0 $ace = 1 Else $x = Ubound($masuite)+1 EndIf EndIf EndIf Next If $n = 5 $isstraight = 1 EndIf EndFunction Function isflush() $isflush = 0 $suite1 = $suites[0].caption $suite2 = $suites[1].caption $suite3 = $suites[2].caption $suite4 = $suites[3].caption $suite5 = $suites[4].caption If $suite2 = $suite1 AND $suite3 = $suite1 AND $suite4 = $suite1 AND $suite5 = $suite1 $isflush = 1 EndIf EndFunction Function isfullhouse() $isfullhouse = 0 If isthreeofakind() For $i = 1 to Ubound($masuite) If $masuite[$i] = 2 $isfullhouse = 1 EndIf Next EndIf EndFunction Function isfourofakind() $isfourofakind = 0 For $i = 1 to Ubound($masuite) If $masuite[$i] = 4 $isfourofakind = 1 EndIf Next EndFunction Function isstraightflush() $isstraightflush = 0 If isstraight() If isflush() $isstraightflush = 1 EndIf EndIf EndFunction Function isroyalflush() $isroyalflush = 0 If isstraightflush() If $masuite[10] = 1 AND $masuite[1] = 1 $isroyalflush = 1 EndIf EndIf EndFunction Function testshuffle() $madeck[1] = 1 $madeck[2] = 10 $madeck[3] = 11 $madeck[4] = 12 $madeck[5] = 13 $manextcard = 1 EndFunction Function shufflecards() Dim $i,$found,$value,$exists For $i = 1 to Ubound($madeck) $madeck[$i] = 0 $found = 0 Do $value = Rnd(51)+1 $exists = 0 For $j = 1 to $i If $madeck[$j] = $value $exists = 1 EndIf Next Until $exists = 0 $madeck[$i] = $value Next $minextcard = 1 EndFunction Function getnextcard() $getnextcard = $madeck[$minextcard] $minextcard = $minextcard + 1 EndFunction Function getcardvalue($icard) If $icard > 39 $icard = $icard - 39 Else If $icard > 26 $icard = $icard - 26 Else If $icard > 13 $icard = $icard - 13 EndIf EndIf EndIf If $icard < 11 AND $icard > 1 $getcardvalue = "$icard" Else Select Case $icard = 1 $getcardvalue = "A" Case $icard = 11 $getcardvalue = "J" Case $icard = 12 $getcardvalue = "Q" Case $icard = 13 $getcardvalue = "K" EndSelect EndIf EndFunction Function getsuitimage($icard) Select Case $icard > 39 $getsuitimage = Chr(167) Case $icard > 26 $getsuitimage = Chr(168) Case $icard > 13 $getsuitimage = Chr(169) Case 1 $getsuitimage = Chr(170) EndSelect EndFunction Function getcardcolor($icard) Select Case $icard > 39 $getcardcolor = &0 Case $icard > 26 $getcardcolor = &0FF Case $icard > 13 $getcardcolor = &0FF Case 1 $getcardcolor = &0 EndSelect EndFunction Function getcardnumber($icard) If $icard > 39 $getcardnumber = $icard - 39 Else If $icard > 26 $getcardnumber = $icard - 26 Else If $icard > 13 $getcardnumber = $icard - 13 Else $getcardnumber = $icard EndIf EndIf EndIf EndFunction Function spin_click ; this function is just for fun. ; it is possible to get duplicate ; cards with this button but thats ; just part of the fun. $mybet = 1 $myscore = $myscore - $mybet $score.caption = $myscore For $j = 0 to 4 For $i = 1 to 50 For $k = $j to 4 $card = Rnd(51)+1 $values[$k].tag = $card $values[$k].caption = getcardvalue($card) $suites[$k].caption = getsuitimage($card) $suites[$k].forecolor = getcardcolor($card) $values[$k].forecolor = $suites[$k].forecolor Next Next Next checkforwinninghand() EndFunction Function exit_click Dim $prev If $form.visible $prev = 0 While $form.scaleheight <> $prev $prev = $form.scaleheight $form.scaleheight = $form.scaleheight - 3 Loop While $form.scalewidth <> $prev $prev = $form.scalewidth $form.scalewidth = $form.scalewidth - 3 Loop EndIf Quit() EndFunction