Video Poker

By FordLawnmower on Feb 10, 2010

Image
This is Video Poker in a mIRC Dialog. All of the controls in the game should be self explanatory.
To use:
Load in Remotes.
From any menu Click - Initialize Video Poker Deck. This will take 13 seconds.
After the Deck is done, click Video Poker from any menu.
Note If you load this script with the load command, it will initialize the deck on load.

;Video Poker by Ford_Lawnmower irc.Geekshed.net #Script-Help
menu * { 
  $iif($isdir(Poker),Video Poker,Initialize Video Poker Deck): {
    if (!$isdir(Poker)) GetPokerDeck
    else dialog $iif($dialog(VideoPoker),-v,-md) VideoPoker VideoPoker
  }
}
dialog VideoPoker {
  title "Video Poker"
  size -1 -1 151 189
  option dbu
  icon 1, 7 116 22 31
  icon 2, 35 116 22 31
  icon 3, 63 116 22 31
  icon 4, 91 116 22 31
  icon 5, 120 116 22 31
  text "", 6, 8 106 22 8, center
  text "", 7, 36 106 22 8, center
  text "", 8, 64 106 22 8, center
  text "", 9, 92 106 22 8, center
  text "", 10, 121 106 22 8, center
  button "Deal", 11, 103 173 37 12
  button "Bet+", 12, 10 173 17 12
  button "Bet-", 13, 29 173 17 12
  text "Current Bet $", 14, 51 175 35 8, right
  text "1", 15, 86 175 15 8
  text "Royal Flush  250 to 1", 16, 23 9 108 8, center
  text "Straight Flush 100 to 1", 17, 23 19 108 8, center
  text "Four of a Kind 75 to 1", 18, 23 29 108 8, center
  text "Full House 50 to 1", 19, 23 39 108 8, center
  text "Flush 30 to 1", 20, 23 49 109 8, center
  text "Straight 20 to 1", 21, 23 59 109 8, center
  text "Three of a Kind 10 to 1", 22, 23 69 108 8, center
  text "Two Pair 5 to 1", 23, 22 79 110 8, center
  box "Payouts", 24, 12 2 129 91
  text "Your Cash $", 25, 11 153 31 8
  edit "500", 26, 42 152 50 10, read autohs
  text "", 27, 12 163 128 8, center
  text "Click Deal to Begin.", 28, 8 96 136 8, center
}
On *:Dialog:VideoPoker:init:*: { did -g $dname 1-5 Poker\0.png }
On *:Dialog:VideoPoker:Sclick:*: {
  if ($did) && ($did < 6) && ($did($dname,11) == Draw) {
    var %hold $calc($did + 5)
    if ($did($dname,%hold)) { did -a $dname %hold }
    else { did -a $dname %hold Hold }
  }
  elseif ($did == 11) { $did($dname,$did) }
  elseif ($did == 12) && ($did($dname,11) == Deal) {
    if ($did($dname,15) < 10) { did -a $dname 15 $calc($did($dname,15) + 1) }
    else { 
      did -a $dname 27 Max Bet Has Been Reached.
      .timer 1 3 did -a $dname 27 
    } 
  }
  elseif ($did == 13) && ($did($dname,11) == Deal) {
    if ($did($dname,15) > 1) { did -a $dname 15 $calc($did($dname,15) - 1) }
    else { 
      did -a $dname 27 You Must Bet At Least One Dollar.
      .timer 1 3 did -a $dname 27 
    }   
  }
}
alias -l SuitMatch {
  if ($wildtok($1-,$1,0,32) == 5) { return 1 } 
}
alias OrderMatch {
  tokenize 32 $sorttok($1-,32,n)
  tokenize 32 $sorttok($iif($1 == 1 && $2 != 2,14,$1) $2-,32,n)
  if ($Plus1($1,$2)) && ($Plus1($2,$3)) && ($Plus1($3,$4)) && ($Plus1($4,$5)) { return 1 }
}  
alias -l Plus1 if ($calc($1 + 1) == $2) return 1
alias -l Matches {
  var %Matches $calc($wildtok($1-,$1,0,32) + $wildtok($1-,$2,0,32) + $wildtok($1-,$3,0,32) + $wildtok($1-,$4,0,32) + $wildtok($1-,$5,0,32))
  if (%Matches < 9) { return 0 }
  elseif (%Matches == 9) { return 2 }
  elseif (%Matches == 11) { return 3 }
  elseif (%Matches == 13) { return 5 }
  elseif (%Matches == 17) { return 4 }
}
alias -l Checkhand {
  tokenize 32 $mid($1,2-) $left($1,1) $mid($2,2-) $left($2,1) $mid($3,2-) $left($3,1) $mid($4,2-) $left($4,1) $mid($5,2-) $left($5,1)
  if ($SuitMatch($2,$4,$6,$8,$10)) {
    if ($OrderMatch($1,$3,$5,$7,$9)) {
      if ($istok($1 $3 $5 $7 $9,1,32)) { return Royal Flush }
      else { return Straight Flush }
    }
    else { return Flush }
  }
  elseif ($OrderMatch($1,$3,$5,$7,$9)) { return Straight }
  elseif ($Matches($1,$3,$5,$7,$9)) {
    var %Match $v1
    if (%Match == 2) { return 2 Pair }
    elseif (%Match == 3) { return 3 of A Kind }
    elseif (%Match == 5) { return Full House }
    elseif (%Match == 4) { return 4 of A Kind }
  }
}
alias -l MakeDeck {
  if (!$hget(PokerDeck)) { hmake PokerDeck 5 }
  var %count 1
  while (%count <= 13) {
    hadd PokerDeck %count R H %count
    hadd PokerDeck $calc(%count + 13) B C %count
    hadd PokerDeck $calc(%count + 26) B S %count
    hadd PokerDeck $calc(%count + 39) R D %count
    inc %count
  }
}
alias -l swap {
  var %a $r(1,52), %b $r(1,52), %adata $hget(PokerDeck,%a), %bdata $hget(PokerDeck,%b)
  hadd PokerDeck %a %bdata
  hadd PokerDeck %b %adata
}
alias -l shuffle {
  var %count 1
  while (%count <= 100) {
    swap
    inc %count
  }
}
alias -l Draw {
  if ($dialog(VideoPoker)) {
    var %card, %count 1
    while (%count <= 5) {
      if (!$did(VideoPoker,$calc(%count + 5))) { %card = $+(%card,$chr(32),%count) }
      inc %count
    }
    tokenize 32 %card
    %count = 1 
    var %counter $gettok(%card,0,32)
    while (%count <= %counter) {
      did -g VideoPoker $gettok(%card,%count,32) $+(Poker\,$remove($hget(PokerDeck,$calc(%count + 5)),$chr(32)),.png)
      inc %count
    }
    Score VideoPoker
    did -a VideoPoker 11 Deal
  }
}
alias -l Deal {
  did -a VideoPoker 6-10
  if ($dialog(VideoPoker)) {
    if (!$did(VideoPoker,26)) { did -a VideoPoker 28 Game Over!! Out of Cash!! }
    elseif ($did(VideoPoker,26) < $did(VideoPoker,15)) { 
      did -a VideoPoker 27 You don't have that much cash!! Lower your bet!! 
      .timer 1 3 did -a VideoPoker 27
    }
    else {
      MakeDeck
      Shuffle
      did -a VideoPoker 11 Draw
      var %card 1
      while (%card <= 5) {
        did -g VideoPoker %card $+(Poker\,$remove($hget(PokerDeck,%card),$chr(32)),.png)
        inc %card
      }
      did -a VideoPoker 28 Click the cards you want to keep then Click Draw.
    }
  }
}
alias -l Score {
  tokenize 32 $remove($mid($nopath($did($1,1)),2-) $mid($nopath($did($1,2)),2-) $mid($nopath($did($1,3)),2-) $mid($nopath($did($1,4)),2-) $mid($nopath($did($1,5)),2-),.png)
  var %cash $did(VideoPoker,26), %bet $did(VideoPoker,15)
  if ($checkhand($1,$2,$3,$4,$5)) {
    var %Winner $v1, %Prize
    if (%Winner == 2 Pair) { %Prize = 5 }
    elseif (%Winner == 3 of A Kind) { %Prize = 10 }
    elseif (%Winner == Straight) { %Prize = 20 }
    elseif (%Winner == Flush) { %Prize = 30 }
    elseif (%Winner == Full House) { %Prize = 50 }
    elseif (%Winner == 4 of A Kind) { %Prize = 75 }
    elseif (%Winner == Straight Flush) { %Prize = 100 }
    elseif (%Winner == Royal Flush) { %Prize = 250 }
    did -a VideoPoker 28 Winner!! %Winner - Prize $+($chr(36),$calc(%Prize * %bet)) - Click Deal to Play Again.
    did -ra VideoPoker 26 $calc(%cash + [ %bet * %Prize ] )
  }
  else { 
    did -a VideoPoker 28 You Lose :( Click Deal to Play Again
    did -ra VideoPoker 26 $calc(%cash - %bet)
  }
}
alias GetPokerDeck {
  echo -a Initializing Video Poker Deck. This will take about 13 Seconds. Please Wait......
  var %count 1
  while (%count <= 13) {
    .timer 1 %count GetCard s0.staticworldofsolitaire.com $+(/decks/anglo/9/,%count,h.png) Poker $+(RH,%count,.png)
    .timer 1 %count GetCard s0.staticworldofsolitaire.com $+(/decks/anglo/9/,%count,c.png) Poker $+(BC,%count,.png)
    .timer 1 %count GetCard s0.staticworldofsolitaire.com $+(/decks/anglo/9/,%count,s.png) Poker $+(BS,%count,.png)
    .timer 1 %count GetCard s0.staticworldofsolitaire.com $+(/decks/anglo/9/,%count,d.png) Poker $+(RD,%count,.png)
    inc %count
  }
  GetCard s0.staticworldofsolitaire.com /decks/anglo/9/base_foundation.png Poker 0.png
  GetCard s0.staticworldofsolitaire.com /decks/anglo/9/back.png Poker back.png
  .timer 1 %count echo -a Video Poker Deck is complete. Enjoy the Game.
}
alias -l GetCard {
  if ($isfile($qt($+($3,\,$4)))) { .remove $qt($+($3,\,$4)) }
  var %sockname $+(GetCard,$ticks,$r(1,$ticks))
  if (!$isdir($qt($3))) { mkdir $qt($3) }
  sockopen %sockname $1 80
  sockmark %sockname $1-
}
On *:sockopen:GetCard*:{
  sockwrite -nt $sockname GET $gettok($sock($sockname).mark,2,32) HTTP/1.0
  sockwrite -n $sockname Host: $gettok($sock($sockname).mark,1,32) $+ $crlf $+ $crlf
}
On *:sockread:GetCard*:{
  if (!$gettok($sock($sockname).mark,5,32)) {
    var %GetCard | sockread %GetCard
    if (!%GetCard) { sockmark $sockname $addtok($sock($sockname).mark,1,32) }
  }
  else {
    sockread &GetCard
    bwrite -s $qt($+($gettok($sock($sockname).mark,3,32),\,$gettok($sock($sockname).mark,4,32))) -1 -1 &GetCard
  }
}
On *:Load: { if (!$isdir(Poker)) GetPokerDeck }

Comments

Sign in to comment.
beeper   -  Nov 19, 2011

Is there anyway you can convert this into a channle bot? Like this below.

<%bot> -> user -> Bank for user: 6,421,745 Coins
<&user> !poker 500
<%bot> -> user -> Your cards are: Qd 10s 8c 7s 9h | Options: !deal & !howtopoker
<&user> !deal 1
<%bot> -> user -> Sorry, you didn't win. You Lost 500 VCoins. Your Cards: Kc 10s 8c 7s 9h
<&user> !bank
<%bot> -> user -> Bank for user: 6,421,245 Coins
<&user> !poker 1000
<%bot> -> user -> Your cards are: Ac As 6s Qs 6c | Options: !deal & !howtopoker
<&user> !deal 345
<%bot> -> user -> You got one pair, Jacks or better. You received your bet (1,000 Coins) back. Your cards: Ac As 5h 9c Qh

 Respond  
FordLawnmower   -  Jun 12, 2011

:)

 Respond  
blackvenomm666   -  Jun 11, 2011

fyi i love this thing

 Respond  
blackvenomm666   -  Apr 29, 2011

ahh that worked. ty. would be cool if you could make vid poker that could be played multi player with the dialog haha

 Respond  
FordLawnmower   -  Apr 29, 2011

It's fixed now blackvenomm666 . Just load the updated code and type : /GetPokerDeck

 Respond  
blackvenomm666   -  Apr 29, 2011

it downloaded them but they wouldnt show up in the dialog. nor did they show up if i tried to open them via other programs

 Respond  
FordLawnmower   -  Apr 29, 2011

I'll check into it blackvenomm666 and see if I can find the problem. I have the cards , so if nothing else I can upload them somewhere else and make a small edit to the script.

 Respond  
blackvenomm666   -  Apr 29, 2011

i like the idea but it wouldnt load the cards

 Respond  
FordLawnmower   -  Apr 23, 2010

NP :)

 Respond  
SglCdnMade   -  Apr 23, 2010

That works. Thanks!!

Very nice!

 Respond  
FordLawnmower   -  Apr 23, 2010

@SglCdnMade I just noticed the 6.2 version comment.
Change that line to this:

var %a $r(1,52), %b $r(1,52), %adata $hget(PokerDeck, [ %a ] ), %bdata $hget(PokerDeck, [ %b ] )

Should work fine then :)

 Respond  
SglCdnMade   -  Apr 23, 2010

I changed that line of code to what you have shown. I also did a check for any alias r. There is none in any of the scripts I have loaded.

Still getting the same error.

 Respond  
FordLawnmower   -  Apr 23, 2010

The only way that line can generate that error is if you have an alias r {} That is interfering with the mIRC identifier $r.
Try changing that line to this:

var %a $rand(1,52), %b $rand(1,52), %adata $hget(PokerDeck,%a), %bdata $hget(PokerDeck,%b)

If this works then you have a script loaded with an alias named r. It should probably be changed to something else.

 Respond  
SglCdnMade   -  Apr 23, 2010

Yeah, line 111 is the same as what you have posted.

it's the 2nd line in the alias -l swap.

var %a $r(1,52), %b $r(1,52), %adata $hget(PokerDeck,%a), %bdata $hget(PokerDeck,%b)

Not sure if this makes a difference... but I am using mIRC version 6.2

 Respond  
FordLawnmower   -  Apr 23, 2010

@SglCdnMade Hmmm, Is this what you have for line 111:

  var %a $r(1,52), %b $r(1,52), %adata $hget(PokerDeck,%a), %bdata $hget(PokerDeck,%b)
 Respond  
SglCdnMade   -  Apr 23, 2010

I have loaded this script.. After it has initialized & I press the deal button. I get the following error in my Status window... * Invalid format: $hget (line 111, Poker.txt)

Here is the info.

Initializing Video Poker Deck. This will take about 13 Seconds. Please Wait......
Video Poker Deck is complete. Enjoy the Game.

  • Invalid format: $hget (line 111, Poker.txt)
 Respond  
FordLawnmower   -  Apr 23, 2010

Thanks PunkTuReD :)

 Respond  
PuNkTuReD   -  Apr 23, 2010

absolutely brilliant.
+10 and a like

 Respond  
FordLawnmower   -  Mar 18, 2010

Thanks slub77 :)

 Respond  
slub77   -  Mar 18, 2010

Awesome script :D good dialog :D

 Respond  
FordLawnmower   -  Feb 16, 2010

Thank you eNkIL :)

 Respond  
eNkIL   -  Feb 16, 2010

Really good man congratz!!

 Respond  
FordLawnmower   -  Feb 13, 2010

Thanks Quick :)

 Respond  
Quick   -  Feb 13, 2010

Very nice.

 Respond  
sunslayer   -  Feb 11, 2010

cheaters = winners :)

 Respond  
FordLawnmower   -  Feb 11, 2010

Haha, well you do have 250 Zillion Dollars.

 Respond  
sunslayer   -  Feb 11, 2010

are you callin me cheater ford? :'(

 Respond  
FordLawnmower   -  Feb 11, 2010

@Kirby that's my biggest problem with these sockets scripts, they just keep changing the sites ;/ It's amazing how hard it can be to read your own code after only a few months have passed.
@sunslayer Did you really hit that or have some help from /did?

 Respond  
sunslayer   -  Feb 10, 2010

bow down to my leet poker skillz :p
Image
nice job

 Respond  
Kirby   -  Feb 10, 2010

Thank you. It seems like some of the websites that I had used for sockets have changed their layout/source, so a lot of them are broken. I've received many complaints about this, so I have to remake many of them, one by one.

Seems like you've made a much better Youtube downloader than I did.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.