]>
iEval git - www-backpacktf.git/blob - Item.pm
7c5d57f5c3683600c34033dd393f47420a190ed0
1 package WWW
:: BackpackTF
:: Item
;
6 our $VERSION = '0.001' ;
9 my ( $class , $name , $content ) = @_ ;
10 $content ->{ name
} = $name ;
11 bless $content , $class
14 sub name
{ shift ->{ name
} }
15 sub defindex
{ wantarray ? @
{ shift ->{ defindex
}} : shift ->{ defindex
}->[ 0 ] }
17 my ( $self , $quality , $tradable , $craftable , $priceindex ) = ( @_ , 6 , 1 , 1 );
18 $tradable = $tradable ?
'Tradable' : 'Non-Tradable' ;
19 $craftable = $craftable ?
'Craftable' : 'Non-Craftable' ;
20 my $price = shift ->{ prices
}->{ $quality }->{ $tradable }->{ $craftable };
21 defined $priceindex ?
$price ->{ $priceindex } : $price ->[ 0 ]
31 WWW::BackpackTF::Item - Class representing item information
35 use WWW::BackpackTF qw/VINTAGE GENUINE UNUSUAL/;
36 use Data::Dumper qw/Dumper/;
38 my @items = $bp->get_prices;
40 say 'Name: ', $item->name;
41 say 'Linked defindexes: ', join ' ', $item->defindex;
42 say 'Price of Unique, Tradable, Craftable version: ', $item->price;
43 say 'Price of Vintage, Tradable, Craftable version: ', Dumper $item->price(VINTAGE);
44 say 'Price of Vintage, Non-Tradable, Craftable version: ', Dumper $item->price(VINTAGE, 0);
45 say 'Price of Genuine, Non-Tradable, Non-Craftable version: ', Dumper $item->price(GENUINE, 0, 0);
46 say 'Price of Unusual, Tradable, Craftable version with effect 10: ', Dumper $item->price(UNUSUAL, 1, 1, 10);
50 WWW::BackpackTF::Item is a class representing price information about an item.
62 In list context, a list of defindexes linked to the item. In scalar context, the first such defindex.
64 =item B<price>([I<$quality>, [I<$tradable>, [I<$craftable>, [I<$priceindex>]]]])
66 The price of an item. Takes four optional arguments: the quality (defaults to 6, which is Unique), the tradability of the item (defaults to true), the craftability of an item (defaults to true), and the priceindex (crate series/unusual effect, defaults to none).
68 Returns an hashref with the following keys/values:
74 The currency the item's price is in.
82 If present, the upper range of the price range.
86 The price in the lowest currency, without rounding. Only present if get_prices was called with a true value for $raw.
90 Timestamp of last price update.
94 The difference bitween the former price and the current price. 0 if the current price is new.
102 L<http://backpack.tf/api/prices>
106 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
108 =head1 COPYRIGHT AND LICENSE
110 Copyright (C) 2014, 2015 by Marius Gavrilescu
112 This library is free software; you can redistribute it and/or modify
113 it under the same terms as Perl itself, either Perl version 5.18.2 or,
114 at your option, any later version of Perl 5 you may have available.
This page took 0.055722 seconds and 3 git commands to generate.