Acme-Mahjong-Rule-CC

 view release on metacpan or  search on metacpan

META.yml  view on Meta::CPAN

--- #YAML:1.0
name:               Acme-Mahjong-Rule-CC
version:            0.22
abstract:           Exchange Tables for a Classic Chinese Version of Mahjong.
author:
    - Caleb Veenstra <cjveenst@mtu.edu>
license:            unknown
distribution_type:  module
configure_requires:
    ExtUtils::MakeMaker:  0
build_requires:
    ExtUtils::MakeMaker:  0
requires:  {}
no_index:

lib/Acme/Mahjong/Rule/CC.pm  view on Meta::CPAN

   $score[3]=$l4*4-($l1*2+$l3+$l2);
   @score;
}

1;
__END__


=head1 NAME

Acme::Mahjong::Rule::CC - Exchange Tables for a Classic Chinese Version of Mahjong.

=head1 SYNOPSIS

this returns the exchanges of the given scores
when the winner is a non-dealer. 
The equivalent chart form of this exchange would be:

      |win 200  | deal 100 | pl3 50 | pl4 20 |
=============================================|
 win  |    X    |   -400   | -200   | -200   |
 deal |   400   |     X    | -100   | -160   |
 pl3  |   200   |    100   |   X    | -30    |
 pl4  |   200   |    160   |  30    |  X     |
=============================================|
 total|   800   |   -140   | -270   | -390   |

lib/Acme/Mahjong/Rule/CC.pm  view on Meta::CPAN

}

=head2 Note:

You can find the rest of the source code for mj_series with your distrobution.  
#!There must be exactly four arguments in dealer(), nondealer(),
and draw() otherwise, the function will throw an exception.

=head1 DESCRIPTION

This module provides functions that table the exchanges of a round of mahjong
based off of the given scores.  This module mainly applies to the Classic 
Chinese version of the game, where every hand is scored, not just the winners.
Players pay each other the value of the other's hand, dealer pays and recieves
double, and winner pays no one.

=over

=item mahjong_table()

mahjong_table() provides an example of how to use the 

lib/Acme/Mahjong/Rule/CC.pm  view on Meta::CPAN

and the other players collect normally, while still paying/recieving 
double from the dealer and paying, but not collecting from the winner.

=cut

nondealer($winner_pts, $dealer_pts, $player3_pts, $player4_pts);
#nondealer(200,100,50,20) returns (800,-140,-270,-390)

=item dealer()

The dealer() function returns the exchanges of the given 
scores when the dealer is the winner. meaning that the 
winnner both collects double and pays no one.

=cut

dealer(winner, player2, player3, player4);
#dealer(200,100,50,20) returns (1200,-200,-500,-500)

=item draw()

returns the exchanges of the given scores when there
is no winner in the form of an array.

=cut        

draw(dealer, player2, player3, player4);
#draw(200,100,0,0) returns (1000,-200,-400,-400)

=back

=head2 EXPORT

t/Acme-Mahjong-Rule-CC.t  view on Meta::CPAN

# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Acme-Mahjong-Rule-CC.t'

#########################

# change 'tests => 1' to 'tests => last_test_to_print';

use Test::Simple tests => 6;
use Acme::Mahjong::Rule::CC qw/:all/;

#########################

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
my @non = nondealer(200,100,50,20);
my @deal = dealer(200,100,50,20);



( run in 0.406 second using v1.01-cache-2.11-cpan-5dc5da66d9d )