line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Mahjong::Rule::CC; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
17054
|
use 5.008008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
35
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
818
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
13
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
14
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# This allows declaration use Acme::Mahjong::Rule::CC ':all'; |
17
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
18
|
|
|
|
|
|
|
# will save memory. |
19
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
20
|
|
|
|
|
|
|
'all' => [ qw( |
21
|
|
|
|
|
|
|
mahjong_table |
22
|
|
|
|
|
|
|
dealer |
23
|
|
|
|
|
|
|
nondealer |
24
|
|
|
|
|
|
|
draw |
25
|
|
|
|
|
|
|
) ], |
26
|
|
|
|
|
|
|
'tables' =>[qw( |
27
|
|
|
|
|
|
|
dealer |
28
|
|
|
|
|
|
|
nondealer |
29
|
|
|
|
|
|
|
draw |
30
|
|
|
|
|
|
|
)] ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
our @EXPORT = qw( |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
our $VERSION = '0.22'; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub mahjong_table{ |
42
|
0
|
|
|
0
|
1
|
0
|
my $ans = 7; |
43
|
0
|
|
0
|
|
|
0
|
while($ans!=0 && $ans!=1 && $ans!=2){ |
|
|
|
0
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
print("0.Nondealer , 1.Dealer, or 2.Draw : "); |
45
|
0
|
|
|
|
|
0
|
$ans=; |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
0
|
my @subs = (\&nondealer, \&dealer, \&draw); |
48
|
0
|
|
|
|
|
0
|
my @players = (qw/dealer player2 player3 player4/); |
49
|
0
|
0
|
|
|
|
0
|
$players[0]='winner' if ($ans != 2); |
50
|
0
|
0
|
|
|
|
0
|
$players[1]='dealer' if ($ans == 0); |
51
|
0
|
|
|
|
|
0
|
my @points; |
52
|
0
|
|
|
|
|
0
|
foreach $a(@players){ |
53
|
0
|
|
|
|
|
0
|
print("$a : "); |
54
|
0
|
|
|
|
|
0
|
my $pts =; |
55
|
0
|
|
|
|
|
0
|
push @points,$pts; |
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
|
|
0
|
print "===========================\n"; |
58
|
0
|
|
|
|
|
0
|
foreach (&{$subs[$ans]}(@points)){ |
|
0
|
|
|
|
|
0
|
|
59
|
0
|
|
|
|
|
0
|
my $p = shift @players; |
60
|
0
|
|
|
|
|
0
|
print "$p : $_\n"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
sub nondealer{ |
64
|
1
|
50
|
|
1
|
1
|
10
|
croak "Wrong number of arguments, needs 4.\n" unless (@_==4); |
65
|
1
|
|
|
|
|
2
|
my @score; |
66
|
1
|
|
|
|
|
2
|
my($w, $deal, $l2 , $l3)=@_; |
67
|
1
|
|
|
|
|
3
|
$score[0]=$w*4; |
68
|
1
|
|
|
|
|
2
|
$score[1]=4*$deal-(2*$w+2*$l2+2*$l3); |
69
|
1
|
|
|
|
|
3
|
$score[2]=3*$l2-($w+2*$deal+$l3); |
70
|
1
|
|
|
|
|
2
|
$score[3]=3*$l3-($w+2*$deal+$l2); |
71
|
1
|
|
|
|
|
4
|
@score; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
sub dealer{ |
74
|
1
|
50
|
|
1
|
1
|
7
|
croak "Wrong number of arguments, needs 4.\n" unless (@_==4); |
75
|
1
|
|
|
|
|
1
|
my @score; |
76
|
1
|
|
|
|
|
1
|
my($w, $l2 ,$l3 ,$l4)=@_; |
77
|
1
|
|
|
|
|
3
|
$score[0]=$w*6; |
78
|
1
|
|
|
|
|
2
|
$score[1]=2*$l2-($w*2+$l3+$l4); |
79
|
1
|
|
|
|
|
3
|
$score[2]=2*$l3-($w*2+$l2+$l4); |
80
|
1
|
|
|
|
|
1
|
$score[3]=2*$l4-($w*2+$l3+$l2); |
81
|
1
|
|
|
|
|
4
|
@score; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
sub draw{ |
84
|
1
|
50
|
|
1
|
1
|
5
|
croak "Wrong number of arguments, needs 4.\n" unless (@_==4); |
85
|
1
|
|
|
|
|
2
|
my @score; |
86
|
1
|
|
|
|
|
1
|
my($l1, $l2 ,$l3 ,$l4)=@_; |
87
|
1
|
|
|
|
|
3
|
$score[0]=$l1*6-2*($l2+$l3+$l4); |
88
|
1
|
|
|
|
|
3
|
$score[1]=$l2*4-($l1*2+$l3+$l4); |
89
|
1
|
|
|
|
|
2
|
$score[2]=$l3*4-($l1*2+$l2+$l4); |
90
|
1
|
|
|
|
|
2
|
$score[3]=$l4*4-($l1*2+$l3+$l2); |
91
|
1
|
|
|
|
|
3
|
@score; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
__END__ |