Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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
Replies are listed 'Best First'.
Re: Place your bets
by sth (Priest) on Oct 15, 2008 at 17:45 UTC

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2015-07-30 15:10 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (271 votes), past polls