Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Place your bets

by olus (Curate)
on Sep 26, 2008 at 15:18 UTC ( #713890=obfuscated: print w/ replies, xml ) Need Help??

For use when bored or the bamboo sways.

  • 1 to 5 and enter to select cards
  • 1 to 5 and enter to unselect cards
  • d to refresh hand after selecting cards
  • d for a new hand
  • q to quit

Unfortunately you'll have to hit the 'download' link to see the art, and it is not guaranteed to work on all terminals. Nothing hidden, it's just pure char arrangement.

@n =(2,3,4,5, 6, 7, 8, 9, 10 ,'J','Q', 'K', 'A');$C =50; $R =''; $e= 0;@c = map{ "\e[31m".$_. " h"} @n; @p = map{ "\e[32m".$_." c"}@n;@o=map{"\e[31m". $_." d"}@n;@e=map {"\e[32m".$_." s"} @n;@D;(%p,@H,@h);%seen;sub cls{print "\e[1J\e[H";}d();$/=\1;$i;while( $i= <STDIN> ) {last if($i eq 'q');if(($i>=1)&&($i<=5)) {$h[$i-1] =( $h [ $i -1] == 0) ?1:0;p(); }if($i eq 'd'){ if ( $e ){ d () if($C>0);$e= +0;} else{$e=1;f();}}}sub b{my @d= (@c,@p,@o,@ +e);@D= ();while(@d){push@D,splice (@d, rand (@d), 1);}@H= +();push@H , shift@D for 0..4 ; } sub p { cls( ); print "\n\t\t\tCr +edit:$C\n"; for(0..4) { if($h[$_] == 1){print " H ";}else{print " +";}}print"\n" ; print" ".$H[$_]." " for 0..4; print "\e[0m\n\n\t\t\t$R\n\n\n"; i +f( $e==0){print "Cards to hold ([d]eal):";} else{if($C>0){print"[d]eal again or [q]uit +?:";}else{print "No more credits. You must [q]uit:";} }}sub f(){ for(0..4){if($h[$_]== +0){$H[$_]=shift @D;}} P(); p();}sub d{ %p= ('p' => 0 ,'t'=>0,'k'=>0,'f'=>0,'s' +=>0,);@h=(0,0 ,0,0,0); $R=''; $e= 0; $C-- ; b() ;p() ; } sub P{ @v = + map{ $_=~ /m(.*) /; $1}@H;for( 0.. $#v){ if($v[$_]eq'J') {$ +v[$_]= 11 ;}elsif($v[$_]eq'Q') {$v [$_]= 12;}elsif($v[$_] +eq'K'){ $v[$_] = 13 ;} elsif($v[ $_]eq'A'){$v[ +$_]= 14;}}@v= sort@v;if (($v[4]-$v +[ 0])==4){for(1 ..4){ if($v[$_] ==$v[$_-1]+1 ){ $p{ 's'}=1;}else{$p{'s' }=0;last;}}}%seen=();map{ $seen{$_}++} @v; foreach$k(keys %seen){if($seen{$k}==2){$p{'p'}++;}if($seen {$k}==3){$p{'t'}=1;}if($seen{$k}==4){$p{'k'}=1;}}if($p{' +t'} &&$p{'p'}) {$p{'f'}=1;}if($p{'s'}){$R='Sequence!';$C+=6;}elsif( +$p{'f'} ){$R='Fullhouse!'; $C+=4; } elsif( $p{'k'} ){ $R= 'Poker!'; $C += 10; +} elsif ($p{'t'} ){$R='trio';$C+=2;}elsif($p{'p'}){$R="$p{'p'}pair"; $C++;}@h =(0,0,0, +0,0);}print"\n";

Have fun.

Comment on Place your bets
Select or Download Code
Re: Place your bets
by sth (Priest) on Oct 15, 2008 at 17:45 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://713890]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2014-09-23 00:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (210 votes), past polls