mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-10-18 20:05:04 +00:00
Add Perl 5 implementation
This commit is contained in:
1 parent
4967a5606d
commit
0a772512de
3 files changed
+108
No files matched your search
@@ -0,0 +1,74 @@
|
||||
package GildedRose;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ( $class, %attrs ) = @_;
|
||||
return bless \%attrs, $class;
|
||||
}
|
||||
|
||||
sub update_quality {
|
||||
my $self = shift;
|
||||
for my $item ( @{ $self->{items} } ) {
|
||||
if ( $item->{name} ne 'Aged Brie'
|
||||
&& $item->{name} ne 'Backstage passes to a TAFKAL80ETC concert' )
|
||||
{
|
||||
if ( $item->{quality} > 0 ) {
|
||||
if ( $item->{name} ne 'Sulfuras, Hand of Ragnaros' ) {
|
||||
$item->{quality} = $item->{quality} - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( $item->{quality} < 50 ) {
|
||||
$item->{quality} = $item->{quality} + 1;
|
||||
|
||||
if ( $item->{name} eq
|
||||
'Backstage passes to a TAFKAL80ETC concert' )
|
||||
{
|
||||
if ( $item->{sell_in} < 11 ) {
|
||||
if ( $item->{quality} < 50 ) {
|
||||
$item->{quality} = $item->{quality} + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $item->{sell_in} < 6 ) {
|
||||
if ( $item->{quality} < 50 ) {
|
||||
$item->{quality} = $item->{quality} + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $item->{name} ne 'Sulfuras, Hand of Ragnaros' ) {
|
||||
$item->{sell_in} = $item->{sell_in} - 1;
|
||||
}
|
||||
|
||||
if ( $item->{sell_in} < 0 ) {
|
||||
if ( $item->{name} ne 'Aged Brie' ) {
|
||||
if ( $item->{name} ne
|
||||
'Backstage passes to a TAFKAL80ETC concert' )
|
||||
{
|
||||
if ( $item->{quality} > 0 ) {
|
||||
if ( $item->{name} ne 'Sulfuras, Hand of Ragnaros' ) {
|
||||
$item->{quality} = $item->{quality} - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$item->{quality} = $item->{quality} - $item->{quality};
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( $item->{quality} < 50 ) {
|
||||
$item->{quality} = $item->{quality} + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
1;
|
||||
Reference in new issue
Block a user