|
4 | 4 |
|
5 | 5 | class Item extends BaseContainer |
6 | 6 | { |
7 | | - public $appId; |
| 7 | + public $id; |
8 | 8 |
|
9 | | - public $name; |
| 9 | + public $originalId; |
10 | 10 |
|
11 | | - public $playtimeTwoWeeks; |
| 11 | + public $defIndex; |
12 | 12 |
|
13 | | - public $playtimeTwoWeeksReadable; |
| 13 | + public $level; |
14 | 14 |
|
15 | | - public $playtimeForever; |
| 15 | + public $quality; |
16 | 16 |
|
17 | | - public $playtimeForeverReadable; |
| 17 | + public $quantity; |
18 | 18 |
|
19 | | - public $icon; |
| 19 | + public $inventory; |
20 | 20 |
|
21 | | - public $logo; |
| 21 | + public $origin; |
22 | 22 |
|
23 | | - public $header; |
| 23 | + public $flags; |
24 | 24 |
|
25 | | - public $hasCommunityVisibleStats; |
| 25 | + public $containedItem; |
26 | 26 |
|
27 | | - public function __construct($app) |
28 | | - { |
29 | | - $this->appId = $app->appid; |
30 | | - $this->name = $this->checkIssetField($app, 'name'); |
31 | | - $this->playtimeTwoWeeks = $this->checkIssetField($app, 'playtime_2weeks', 0); |
32 | | - $this->playtimeTwoWeeksReadable = $this->convertFromMinutes($this->playtimeTwoWeeks); |
33 | | - $this->playtimeForever = $this->checkIssetField($app, 'playtime_forever', 0); |
34 | | - $this->playtimeForeverReadable = $this->convertFromMinutes($this->playtimeForever); |
35 | | - $this->icon = $this->checkIssetImage($app, 'img_icon_url'); |
36 | | - $this->logo = $this->checkIssetImage($app, 'img_logo_url'); |
37 | | - $this->header = 'http://cdn.steampowered.com/v/gfx/apps/' . $this->appId . '/header.jpg'; |
38 | | - $this->hasCommunityVisibleStats = $this->checkIssetField($app, 'has_community_visible_stats', 0); |
39 | | - } |
| 27 | + public $style; |
40 | 28 |
|
41 | | - /** |
42 | | - * @param $app |
43 | | - * @param string $field |
44 | | - * @param string $value |
45 | | - * |
46 | | - * @return null|string |
47 | | - */ |
48 | | - protected function checkIssetImage($app, $field, $value = null) |
49 | | - { |
50 | | - return isset($app->$field) ? $this->getImageForGame($app->appid, $app->$field) : $value; |
51 | | - } |
| 29 | + public $attributes; |
52 | 30 |
|
53 | | - protected function getImageForGame($appId, $hash) |
54 | | - { |
55 | | - if ($hash != null) { |
56 | | - return 'http://media.steampowered.com/steamcommunity/public/images/apps/' . $appId . '/' . $hash . '.jpg'; |
57 | | - } |
| 31 | + public $custom; |
58 | 32 |
|
59 | | - return null; |
| 33 | + public function __construct($item) |
| 34 | + { |
| 35 | + $this->id = $item->id; |
| 36 | + $this->originalId = $item->original_id; |
| 37 | + $this->defIndex = $item->defindex; |
| 38 | + $this->level = $item->level; |
| 39 | + $this->quality = $item->quality; |
| 40 | + $this->quantity = $item->quantity; |
| 41 | + $this->inventory = $item->inventory; |
| 42 | + $this->origin = $this->checkIssetField($item, 'origin'); |
| 43 | + $this->containedItem = $this->checkIssetField($item, 'contained_item'); |
| 44 | + $this->style = $this->checkIssetField($item, 'style'); |
| 45 | + $this->attributes = $this->checkIssetField($item, 'attributes'); |
| 46 | + |
| 47 | + $this->flags = [ |
| 48 | + 'trade' => (boolean)! $this->checkIssetField($item, 'flag_cannot_trade', false), |
| 49 | + 'craft' => (boolean)! $this->checkIssetField($item, 'flag_cannot_craft', false), |
| 50 | + ]; |
| 51 | + $this->custom = [ |
| 52 | + 'name' => $this->checkIssetField($item, 'custom_name'), |
| 53 | + 'description' => $this->checkIssetField($item, 'custom_desc'), |
| 54 | + ]; |
60 | 55 | } |
61 | 56 | } |
0 commit comments