rendered paste bodyon *:INPUT:#:{ pokercommand $1- }
on *:TEXT:*:#:{ pokercommand $1- }
alias -l pokercommand {
if ($1 == !vp) { deal-vp }
if ($1 == !draw) { draw-vp $2- }
if ($1 == !cash) { pnotice $msg.vp.cash }
if ($1 == !best) { pnotice $msg.vp.recordhand }
}
alias -l deal-vp {
if ($isdeck($vp)) { return }
if (!$pvar(Money, $nick)) { pset Money $nick 100 }
getdeck $vp
var %i = 1) %deal.temp
while (%i <= 5) {
setcard $vp $vp %i
inc %i
}
pnotice $msg.vp.hand
pset Money $nick $calc($pvar(Money, $nick) - $vp-bet)
}
alias -l draw-vp {
if (!$isdeck($vp)) { return }
if (1 isin $1-) { setcard $vp $vp 1 }
if (2 isin $1-) { setcard $vp $vp 2 }
if (3 isin $1-) { setcard $vp $vp 3 }
if (4 isin $1-) { setcard $vp $vp 4 }
if (5 isin $1-) { setcard $vp $vp 5 }
%index = $pkconvert($pvar($vp,1), $pvar($vp,2), $pvar($vp,3), $pvar($vp,4), $pvar($vp,5))
if (%index > $pvar(Record,Index)) || ($pvar(Record,Index) == $null) {
pset Record Index %index
pset Record Hand %last-hand
pset Record Nick $nick
}
pset Money $nick $calc($pvar(Money, $nick) + $vp-score)
psay $msg.vp.finalhand($vp)
pset $vp
trashdeck $vp
}
alias -l vp { return vp- $+ $nick }
alias -l vp-bet { return 5 }
alias -l vp-score {
var %mult = %d0
if ((%d0 == 8) && (%d1 == 14)) { var %mult = 400 }
elseif (%d0 == 8) { var %mult = 50 }
elseif (%d0 == 7) { var %mult = 25 }
elseif (%d0 == 6) { var %mult = 8 }
elseif (%d0 == 1) { var %mult = $iif(%d1 >= 11, 1,0) }
return $calc($vp-bet * %mult)
}
alias -l pc1 { return 12 }
alias -l pc2 { return 03 }
alias -l msg.vp.cash { return $pc2 $+ $nick $+ $pc1 $+ , you currently have $pc2 $+ $pvar(Money,$nick) $+ $pc1 video poker bet of $pc2 $+ $vp-bet $+ $pc1 $+ . }
alias -l msg.vp.finalhand { return $pc2 $+ $nick $+ $pc1 $+ , $+ $pc2 %index $+ $pc1 $+ , your hand, $msg.vp.thehand $+ , is a $pc2 $+ %last-hand $+ $pc1 you win $+ $pc2 $vp-score $+ $pc1 for that hand. Current total: $+ $pc2 $pvar(Money,$nick) }
alias -l msg.vp.hand { return $pc2 $+ $nick $+ $pc1 $+ , you have $pc2 $+ $pvar(Money,$nick) $+ $pc1 you bet $pc2 $+ $vp-bet $+ $pc1 $+ . Hand: $msg.vp.thehand }
alias -l msg.vp.thehand { return $convert.shortcard(1) $convert.shortcard(2) $convert.shortcard(3) $convert.shortcard(4) $convert.shortcard(5) }
alias -l msg.vp.recordhand { return $pc1 $+ The best hand so far was $+ $pc2 $pvar(Record,Nick) $+ 's $+ $pc1 hand $+ $pc2 $pvar(Record,Hand) $pc1 $+ with an index of $+ $pc2 $pvar(Record,Index) $+ $pc1 $+ . }
alias -l pvar { return $readini(cards.ini, $1, $2) }
alias pset { $iif($3, writeini, remini) cards.ini $1- }
alias -l psay { $iif($nick == $me, .timer 1 0) msg $chan $1- }
alias -l pnotice { $iif($nick != $me, .notice $nick, .timer 1 0 echo $chan) $1- }
alias -l setcard { pset $2 $3 $getcard($1) }
;deck standards
alias -l getcard {
if (!$hget($1)) { return }
var %temp = $hget($1,$cardsleft($1))
hdel $1 $cardsleft($1)
return %temp
}
alias -l getdeck {
trashdeck $1
hmake $1
var %c = 1
while (%c <= 52) {
hadd $1 %c %c
inc %c
}
shuffledeck $1
}
alias -l shuffledeck {
var %i = 1
while ($cardsleft($1) >= %i) {
var %temp = $rand(1,$cardsleft($1))
var %temp.card = $hget($1,%temp)
hadd $1 %temp $hget($1,%i)
hadd $1 %i %temp.card
inc %i
}
}
alias -l trashdeck { if ($hget($1)) { hfree $1 } }
alias -l isdeck { if ($hget($1) != $null) { return $true } }
alias -l cardsleft { return $$hget($1,0).item }
;card standards
alias -l convert.shortcard { return $pc2 $+ $left($convert.rank($pvar($vp,$1)),1) $+ $convert.suit($pvar($vp,$1)) $+ $pc1 }
alias -l convert.card { return $pc2 $+ $convert.rank($1) $+ $pc1 of $convert.suit($1) }
alias -l convert.rank { return $convert.face($convert.ranknum($1)) }
alias -l convert.suit { return $gettok(02 of clubs.04 of diamonds.04 of hearts.02 of spades, $calc($convert.suitnum($1) + 1), $asc(.)) }
alias -l convert.face { return $gettok(Ace.2.3.4.5.6.7.8.9.Ten.Jack.Queen.King.Ace, $1, $asc(.)) }
alias -l convert.ranknum { return $calc($mod($calc($1 - 1),13) + 2) }
alias -l convert.suitnum { return $int($calc(($1 - 1) / 13)) }
alias -l mod { return $calc($1 - ($int($calc($1 / $2)) * $2)) }
;hand standards
alias -l cardrank { return $calc(( %d0 * (16 ^ 5) ) + ( %d1 * (16 ^ 4) ) + ( %d2 * (16 ^ 3) ) + ( %d3 * (16 ^ 2) ) + ( %d4 * (16 ^ 1)) + ( %d5 * (16 ^ 0))) }
alias -l pkconvert {
setcards 0 0 0 0 0 0
handconvert $1 $2 $3 $4 $5
return $cardrank
}
alias -l handconvert {
if (($convert.suitnum($1) == $convert.suitnum($2)) && ($convert.suitnum($2) == $convert.suitnum($3)) && ($convert.suitnum($3) == $convert.suitnum($4)) && ($convert.suitnum($4) == $convert.suitnum($5))) { var %flush = $true }
tokenize 46 $sorttok($convert.ranknum($1) $+ . $+ $convert.ranknum($2) $+ . $+ $convert.ranknum($3) $+ . $+ $convert.ranknum($4) $+ . $+ $convert.ranknum($5), 46, nr)
if (%flush) { setcards 5 $1 $2 $3 $4 $5 }
if ((($1 == $calc($2 + 1)) || (($1 == 14) && ($2 == 5))) && ($2 == $calc($3 + 1)) && ($3 == $calc($4 + 1)) && ($4 == $calc($5 + 1))) {
setcards $iif(%d0 == 5,8,4) $iif((($1 == 14) && ($2 == 5)),5,$1) 0 0 0 0
}
if (($1 == $2) && ($2 == $3) && ($3 == $4) && ($4 == $5)) { setcards 9 $1 0 0 0 0 }
if (($1 == $2) && ($2 == $3) && ($3 == $4) && ($4 != $5)) { setcards 7 $1 $5 0 0 0 }
if (($1 == $2) && ($2 == $3) && ($3 != $4) && ($4 == $5)) { setcards 6 $1 $5 0 0 0 }
if (($1 == $2) && ($2 == $3) && ($3 != $4) && ($4 != $5)) { setcards 3 $1 $4 $5 0 0 }
if (($1 == $2) && ($2 != $3) && ($3 == $4) && ($4 == $5)) { setcards 6 $5 $1 0 0 0 }
if (($1 == $2) && ($2 != $3) && ($3 == $4) && ($4 != $5)) { setcards 2 $1 $3 $5 0 0 }
if (($1 == $2) && ($2 != $3) && ($3 != $4) && ($4 == $5)) { setcards 2 $1 $5 $3 0 0 }
if (($1 == $2) && ($2 != $3) && ($3 != $4) && ($4 != $5)) { setcards 1 $1 $3 $4 $5 0 }
if (($1 != $2) && ($2 == $3) && ($3 == $4) && ($4 != $5)) { setcards 3 $4 $1 $5 0 0 }
if (($1 != $2) && ($2 == $3) && ($3 != $4) && ($4 == $5)) { setcards 2 $3 $5 $1 0 0 }
if (($1 != $2) && ($2 == $3) && ($3 == $4) && ($4 == $5)) { setcards 7 $5 $1 0 0 0 }
if (($1 != $2) && ($2 == $3) && ($3 != $4) && ($4 != $5)) { setcards 1 $2 $1 $4 $5 0 }
if (($1 != $2) && ($2 != $3) && ($3 == $4) && ($4 != $5)) { setcards 1 $3 $1 $2 $5 0 }
if (($1 != $2) && ($2 != $3) && ($3 != $4) && ($4 == $5)) { setcards 1 $4 $1 $2 $3 0 }
if (($1 != $2) && ($2 != $3) && ($3 == $4) && ($4 == $5)) { setcards 3 $5 $1 $2 0 0 }
if (%d0 = 0) { setcards 0 $1 $2 $3 $4 $5 }
convert.lasthand
}
alias convert.lasthand {
if (%d0 == 0) { set %last-hand HighCard, $convert.face(%d1) $convert.face(%d2) $convert.face(%d3) $convert.face(%d4) $convert.face(%d5) }
if (%d0 == 1) { set %last-hand Pair, $convert.face(%d1) $+ 's with $convert.face(%d2) $convert.face(%d3) $convert.face(%d4) odd }
if (%d0 == 2) { set %last-hand Two Pair, $convert.face(%d1) $+ 's and $convert.face(%d2) $+ 's with a $convert.face(%d3) kicker }
if (%d0 == 3) { set %last-hand Three of a Kind, $convert.face(%d1) $+ 's with $convert.face(%d2) and $convert.face(%d3) odd }
if (%d0 == 4) { set %last-hand Straight, $convert.face(%d1) to $convert.face($calc(%d1 - 4)) }
if (%d0 == 5) { set %last-hand Flush, $convert.face(%d1) $convert.face(%d2) $convert.face(%d3) $convert.face(%d4) $convert.face(%d5) }
if (%d0 == 6) { set %last-hand Fullhouse, $convert.face(%d1) $+ 's over $convert.face(%d2) $+ 's }
if (%d0 == 7) { set %last-hand Four of a Kind, $convert.face(%d1) $+ 's with $convert.face(%d2) kicker }
if (%d0 == 8) { set %last-hand Straight Flush, $convert.face(%d1) to $convert.face($calc(%d1 - 4)) }
if (%d0 == 9) { set %last-hand Five of a Kind, $convert.face(%d1) $+ 's }
}
alias -l setcards { %d0 = $1 | %d1 = $2 | %d2 = $3 | %d3 = $4 | %d4 = $5 | %d5 = $6 }