|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Item\Service; |
|
4
|
|
|
|
|
5
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Item\Model\ArtifactTraitValueObject; |
|
6
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Item\Model\DamageValueObject; |
|
7
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Item\Model\ItemAppearanceValueObject; |
|
8
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Item\Model\ItemStatValueObject; |
|
9
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Item\Model\ItemValueObject; |
|
10
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Item\Model\RelicValueObject; |
|
11
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Item\Model\StandardItemValueObject; |
|
12
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Item\Model\TooltipParamsValueObject; |
|
13
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Item\Model\WeaponInfoValueObject; |
|
14
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Item\Model\WeaponItemValueObject; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @author Willy Reiche |
|
18
|
|
|
* @since 2017-08-23 |
|
19
|
|
|
* @version 1.0 |
|
20
|
|
|
*/ |
|
21
|
|
|
class ItemService |
|
22
|
|
|
{ |
|
23
|
|
|
public function prepareItemValueObject($items) |
|
24
|
|
|
{ |
|
25
|
|
|
return new ItemValueObject( |
|
26
|
|
|
$items->averageItemLevel, |
|
27
|
|
|
$items->averageItemLevelEquipped, |
|
28
|
|
|
$this->getStandardItemValueObject($items->head), |
|
29
|
|
|
$this->getStandardItemValueObject($items->neck), |
|
30
|
|
|
$this->getStandardItemValueObject($items->shoulder), |
|
31
|
|
|
$this->getStandardItemValueObject($items->back), |
|
32
|
|
|
$this->getStandardItemValueObject($items->chest), |
|
33
|
|
|
$this->getStandardItemValueObject($items->shirt), |
|
34
|
|
|
$this->getStandardItemValueObject($items->wrist), |
|
35
|
|
|
$this->getStandardItemValueObject($items->hands), |
|
36
|
|
|
$this->getStandardItemValueObject($items->waist), |
|
37
|
|
|
$this->getStandardItemValueObject($items->legs), |
|
38
|
|
|
$this->getStandardItemValueObject($items->feet), |
|
39
|
|
|
$this->getStandardItemValueObject($items->finger1), |
|
40
|
|
|
$this->getStandardItemValueObject($items->finger2), |
|
41
|
|
|
$this->getStandardItemValueObject($items->trinket1), |
|
42
|
|
|
$this->getStandardItemValueObject($items->trinket2), |
|
43
|
|
|
$this->getWeaponItemValueObject($items->mainHand), |
|
44
|
|
|
$this->getWeaponItemValueObject($items->offHand) |
|
45
|
|
|
); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param \StdClass $item |
|
50
|
|
|
* @return StandardItemValueObject |
|
51
|
|
|
*/ |
|
52
|
|
|
private function getStandardItemValueObject($item) |
|
53
|
|
|
{ |
|
54
|
|
|
$tooltipParams = $this->getTooltipParamsValueObject($item); |
|
55
|
|
|
$stats = $this->getItemStatValueObjects($item); |
|
56
|
|
|
$appearance = $this->getItemAppearanceValueObject($item); |
|
57
|
|
|
|
|
58
|
|
|
$armorItemValueObject = new StandardItemValueObject( |
|
59
|
|
|
$item->id, |
|
60
|
|
|
$item->name, |
|
61
|
|
|
$item->icon, |
|
62
|
|
|
$item->quality, |
|
63
|
|
|
$item->itemLevel, |
|
64
|
|
|
$tooltipParams, |
|
65
|
|
|
$stats, |
|
66
|
|
|
$item->armor, |
|
67
|
|
|
$item->context, |
|
68
|
|
|
$item->bonusLists, |
|
69
|
|
|
$item->displayInfoId, |
|
70
|
|
|
$appearance |
|
71
|
|
|
); |
|
72
|
|
|
|
|
73
|
|
|
return $armorItemValueObject; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @param \StdClass $item |
|
78
|
|
|
* @return WeaponItemValueObject |
|
79
|
|
|
*/ |
|
80
|
|
|
private function getWeaponItemValueObject($item) |
|
81
|
|
|
{ |
|
82
|
|
|
$weaponInfo = $this->getWeaponInfoValueObject($item->weaponInfo); |
|
83
|
|
|
$artifactTraits = $this->getArtifactTraitValueObjects($item->artifactTraits); |
|
84
|
|
|
$relics = $this->getRelicValueObjects($item->relics); |
|
85
|
|
|
|
|
86
|
|
|
$armorItemValueObject = new WeaponItemValueObject( |
|
87
|
|
|
$this->getStandardItemValueObject($item), |
|
88
|
|
|
$weaponInfo, |
|
89
|
|
|
$item->artifactId, |
|
90
|
|
|
$item->artifactAppearanceId, |
|
91
|
|
|
$artifactTraits, |
|
92
|
|
|
$relics |
|
93
|
|
|
); |
|
94
|
|
|
|
|
95
|
|
|
return $armorItemValueObject; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @param \StdClass $item |
|
100
|
|
|
* @return TooltipParamsValueObject |
|
101
|
|
|
*/ |
|
102
|
|
|
private function getTooltipParamsValueObject($item) |
|
103
|
|
|
{ |
|
104
|
|
|
$tooltipParams = new TooltipParamsValueObject( |
|
105
|
|
|
$item->tooltipParams->timewalkerLevel, |
|
106
|
|
|
$item->tooltipParams->transmogItem |
|
107
|
|
|
); |
|
108
|
|
|
|
|
109
|
|
|
return $tooltipParams; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @param \StdClass $item |
|
114
|
|
|
* @return array |
|
115
|
|
|
*/ |
|
116
|
|
|
private function getItemStatValueObjects($item) |
|
117
|
|
|
{ |
|
118
|
|
|
$stats = []; |
|
119
|
|
|
|
|
120
|
|
|
foreach ($item->stats as $stat) { |
|
121
|
|
|
$stats[] = new ItemStatValueObject( |
|
122
|
|
|
$stat->stat, |
|
123
|
|
|
$stat->amount |
|
124
|
|
|
); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
return $stats; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @param \StdClass $item |
|
132
|
|
|
* @return ItemAppearanceValueObject |
|
133
|
|
|
*/ |
|
134
|
|
|
private function getItemAppearanceValueObject($item) |
|
135
|
|
|
{ |
|
136
|
|
|
$appearance = new ItemAppearanceValueObject( |
|
137
|
|
|
$item->appearance->itemId, |
|
138
|
|
|
$item->appearance->itemAppearanceModId |
|
139
|
|
|
); |
|
140
|
|
|
|
|
141
|
|
|
return $appearance; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* @param \StdClass $info |
|
146
|
|
|
* @return WeaponInfoValueObject |
|
147
|
|
|
*/ |
|
148
|
|
|
private function getWeaponInfoValueObject($info) |
|
149
|
|
|
{ |
|
150
|
|
|
$damageValueObject = new DamageValueObject( |
|
151
|
|
|
$info->damage->min, |
|
152
|
|
|
$info->damage->max, |
|
153
|
|
|
$info->damage->exactMin, |
|
154
|
|
|
$info->damage->exactMax |
|
155
|
|
|
); |
|
156
|
|
|
|
|
157
|
|
|
$weaponInfo = new WeaponInfoValueObject( |
|
158
|
|
|
$damageValueObject, |
|
159
|
|
|
$info->weaponSpeed, |
|
160
|
|
|
$info->dps |
|
161
|
|
|
); |
|
162
|
|
|
|
|
163
|
|
|
return $weaponInfo; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* @param \StdClass $item |
|
168
|
|
|
* @return ArtifactTraitValueObject[] |
|
169
|
|
|
*/ |
|
170
|
|
|
private function getArtifactTraitValueObjects($item) |
|
171
|
|
|
{ |
|
172
|
|
|
$itemArtifactTraits = []; |
|
173
|
|
|
|
|
174
|
|
|
foreach ($item->artifactTraits as $artifactTrait) { |
|
175
|
|
|
$itemArtifactTraits[] = new ArtifactTraitValueObject( |
|
176
|
|
|
$artifactTrait->id, |
|
177
|
|
|
$artifactTrait->rank |
|
178
|
|
|
); |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
return $itemArtifactTraits; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* @param \StdClass $item |
|
186
|
|
|
* @return RelicValueObject[] |
|
187
|
|
|
*/ |
|
188
|
|
|
private function getRelicValueObjects($item) |
|
189
|
|
|
{ |
|
190
|
|
|
$itemRelics = []; |
|
191
|
|
|
|
|
192
|
|
|
foreach ($item->relics as $relic) { |
|
193
|
|
|
$itemRelics[] = new RelicValueObject( |
|
194
|
|
|
$relic->socket, |
|
195
|
|
|
$relic->itemId, |
|
196
|
|
|
$relic->context, |
|
197
|
|
|
$relic->bonusLists |
|
198
|
|
|
); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
return $itemRelics; |
|
202
|
|
|
} |
|
203
|
|
|
} |
|
204
|
|
|
|