| 1 | <!-- -*-html-*- |
| 2 | - |
| 3 | - Deal a hand for study or discussion |
| 4 | - |
| 5 | - (c) 2013 Mark Wooding |
| 6 | --> |
| 7 | |
| 8 | <table class=table> |
| 9 | <tr> |
| 10 | <td><td> |
| 11 | <& .hand, seat => "N", hand => $deal->{N} &>\ |
| 12 | <td> |
| 13 | <tr> |
| 14 | <td> |
| 15 | <& .hand, seat => "W", hand => $deal->{W} &>\ |
| 16 | <td><td> |
| 17 | <& .hand, seat => "E", hand => $deal->{E} &>\ |
| 18 | <tr> |
| 19 | <td><td> |
| 20 | <& .hand, seat => "S", hand => $deal->{S} &>\ |
| 21 | <td> |
| 22 | <tr> |
| 23 | <td class=info colspan=3> |
| 24 | <% $Deal::SEAT[$deal->{dealer}] %> dealer <br> |
| 25 | <% $Deal::VULN[$deal->{vuln}] %> vulnerable <br> |
| 26 | Hand <a href="<% $ENV{SCRIPT_NAME} %>/hand?\ |
| 27 | seed=<% $deal->{seed} |u %>;\ |
| 28 | dealer=<% $deal->{dealer} |u %>;\ |
| 29 | vuln=<% $deal->{vuln} |u %>">\ |
| 30 | <% $deal->{seed} |h %></a> |
| 31 | </table> |
| 32 | %# |
| 33 | <%args> |
| 34 | $dealer => undef |
| 35 | $vuln => undef |
| 36 | $seed => undef |
| 37 | </%args> |
| 38 | %# |
| 39 | <%method title>Full deal</%method> |
| 40 | %# |
| 41 | <%def .hand>\ |
| 42 | <table class=hand title="HCP = <% $hand{hcp} %>; LTC = <% $hand{ltc} %>"> |
| 43 | <& .suit, suit => "S", cards => $hand{S} &>\ |
| 44 | <& .suit, suit => "H", cards => $hand{H} &>\ |
| 45 | <& .suit, suit => "D", cards => $hand{D} &>\ |
| 46 | <& .suit, suit => "C", cards => $hand{C} &>\ |
| 47 | </table> |
| 48 | <%args> |
| 49 | $seat |
| 50 | %hand |
| 51 | </%args> |
| 52 | </%def> |
| 53 | %# |
| 54 | <%def .suit>\ |
| 55 | <tr><th><% $SUIT{$suit} %><td><% @cards ? join " ", @cards : "—" %> |
| 56 | <%args> |
| 57 | $suit |
| 58 | @cards |
| 59 | </%args> |
| 60 | </%def> |
| 61 | %# |
| 62 | <%once> |
| 63 | use Deal; |
| 64 | |
| 65 | our %SUIT= ( |
| 66 | C => "<span class=club-suit>♣</span>", |
| 67 | D => "<span class=diamond-suit>♦</span>", |
| 68 | H => "<span class=heart-suit>♥</span>", |
| 69 | S => "<span class=spade-suit>♠</span>"); |
| 70 | </%once> |
| 71 | %# |
| 72 | <%init> |
| 73 | my $deal = Deal::deal(%ARGS); |
| 74 | </%init> |