| 1 | package Game::Mahjong::Shanten; | ||||||||||
| 2 | |||||||||||
| 3 | 34 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 34 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 34 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 34 | ▶ | use Game::Mahjong::Tiles; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 34 | our $VERSION = '0.03'; | |||||||||
| 10 | |||||||||||
| 11 | 34 | our @FORMS = qw(standard seven_pairs thirteen_orphans honours_knitted); | |||||||||
| 12 | |||||||||||
| 13 | 4448 | ▶ | sub shanten { | ||||||||
|
Subroutine
shanten: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 14 | 4448 | my ($hand) = @_; | |||||||||
| 15 | 4448 | return _shanten($hand->counts, $hand->meld_count); | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | 2 | ▶ | sub forms { | ||||||||
|
Subroutine
forms: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 19 | 2 | my ($hand) = @_; | |||||||||
| 20 | 2 | my $f = _forms($hand->counts, $hand->meld_count); | |||||||||
| 21 | 2 | return { map { $FORMS[$_] => $f->[$_] } 0 .. $#FORMS }; | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 22583 | ▶ | sub ukeire { | ||||||||
|
Subroutine
ukeire: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 25 | 22583 | my ($hand) = @_; | |||||||||
| 26 | 22583 | return @{ _ukeire($hand->counts, $hand->meld_count) }; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 67256 | ▶ | sub after_discard { | ||||||||
|
Subroutine
after_discard: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 30 | 67256 | my ($hand, $kind) = @_; | |||||||||
| 31 | 67256 | my $counts = [ @{ $hand->counts } ]; | |||||||||
| 32 | 67256 | ▶ | die 'Game::Mahjong::Shanten: the hand does not hold ' . Game::Mahjong::Tiles::code_of($kind) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | unless $counts->[$kind]; | ||||||||||
| 34 | 67255 | $counts->[$kind]--; | |||||||||
| 35 | 67255 | return _shanten($counts, $hand->meld_count); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 34 | 1; | |||||||||
| 39 | |||||||||||
| 40 | __END__ | ||||||||||