Skip Menu |

This queue is for tickets about the Acme-Mahjong CPAN distribution.

Report information
The Basics
Id: 55176
Status: new
Priority: 0/
Queue: Acme-Mahjong

People
Owner: Nobody in particular
Requestors: ainoneko [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.00001
Fixed in: (no value)



Subject: Acme-Mahjong: using 'suit' instead of 'label'
Distribution name and version: "Acme-Mahjong-0.00001" Perl version: "v5.10.1" (Strawberry Perl) Operating System vendor and version: Microsoft Windows XP [Build 5.1.2600] In Acme::Mahjong::Hand.pm, the sub sort() incorrectly uses 'suit' property for Dragon and Winds (instead of the 'label' property). Exact cut and pasted error or warning messages: " Can't locate object method "suit" via package "Acme::Mahjong::Tile::Dragon" at D:/strawberry/perl/site/lib/Acme/ Mahjong/Hand.pm line 61. " The shortest, clearest code you can manage to write which reproduces the bug described: -- BEGIN FILE mj_3.pl -- #!perl use strict; #use lib '.'; use Acme::Mahjong; use Acme::Mahjong::Rule::JP; use Data::Dumper; # Add the missing next() method package Acme::Mahjong::Deck; sub next { my $self = shift; my @tiles = @{ $self->tiles }; my $next = shift @tiles; if ($next) { $self->tiles( [ @tiles ]); return $next; } else { warn "No tiles left!"; return undef; } } package main; my $m = Acme::Mahjong->new( rule => Acme::Mahjong::Rule::JP->new(), ); my $hand = $m->hand_create(); my $deck = $m->deck_create(); # Add line missing in synopsis $deck->populate; for( 1..13 ) { my $tile = $deck->next(); $hand->add( tile => $tile ); } my @res = $hand->sort; print "\nsorted: " . Dumper(\@res); -- END FILE mj_3.pl -- A patch against the latest released version of this distribution which fixes this bug: diff -r 37a209356950 Hand.pm --- a/Hand.pm Wed Mar 03 17:59:56 2010 +0600 +++ b/Hand.pm Wed Mar 03 18:01:10 2010 +0600 @@ -58,10 +58,10 @@ $suit{ $tile->suit } ||= []; push @{ $suit{ $tile->suit } }, $tile; } elsif ( $tile->isa('Acme::Mahjong::Tile::Dragon')) { - $dragon{ $tile->suit } ||= []; + $dragon{ $tile->label } ||= []; push @{ $dragon{ $tile->label } }, $tile; } elsif ( $tile->isa('Acme::Mahjong::Tile::Wind')) { - $wind{ $tile->suit } ||= []; + $wind{ $tile->label } ||= []; push @{ $wind{ $tile->label } }, $tile; } else { confess "Don't know what to do with $tile"; @@ -75,4 +75,4 @@ ); }