Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: 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.


In reply to Place your bets by olus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-19 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found