1 | <?php |
||
17 | class Player |
||
18 | { |
||
19 | /** |
||
20 | * @var \Burthorpe\Runescape\Common |
||
21 | */ |
||
22 | protected $common; |
||
23 | |||
24 | /** |
||
25 | * @var \Burthorpe\Runescape\RS3\API |
||
26 | */ |
||
27 | protected $api; |
||
28 | |||
29 | /** |
||
30 | * Players display name |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $displayName; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $stats; |
||
40 | |||
41 | /** |
||
42 | * @param $displayName string Runescape display name |
||
43 | * @throws InvalidArgumentException |
||
44 | */ |
||
45 | 6 | public function __construct($displayName) |
|
56 | |||
57 | /** |
||
58 | * Return the players stats |
||
59 | * |
||
60 | * @return \Burthorpe\Runescape\RS3\Stats\Repository |
||
61 | */ |
||
62 | 2 | public function getStats() |
|
63 | { |
||
64 | 2 | if ($this->stats) { |
|
65 | 1 | return $this->stats; |
|
66 | } |
||
67 | |||
68 | 2 | return $this->stats = $this->api->stats($this->getDisplayName()); |
|
69 | } |
||
70 | |||
71 | /** |
||
72 | * Return the calculated combat level of this player |
||
73 | * |
||
74 | * @param bool $float |
||
75 | * @return int |
||
76 | */ |
||
77 | 1 | public function getCombatLevel($float = false) |
|
78 | { |
||
79 | 1 | $stats = $this->getStats(); |
|
80 | |||
81 | 1 | return $this->api->calculateCombatLevel( |
|
82 | 1 | $stats->findByClass(Attack::class)->getLevel(), |
|
83 | 1 | $stats->findByClass(Strength::class)->getLevel(), |
|
84 | 1 | $stats->findByClass(Magic::class)->getLevel(), |
|
85 | 1 | $stats->findByClass(Ranged::class)->getLevel(), |
|
86 | 1 | $stats->findByClass(Defence::class)->getLevel(), |
|
87 | 1 | $stats->findByClass(Constitution::class)->getLevel(), |
|
88 | 1 | $stats->findByClass(Prayer::class)->getLevel(), |
|
89 | 1 | $stats->findByClass(Summoning::class)->getLevel(), |
|
90 | $float |
||
91 | 1 | ); |
|
92 | } |
||
93 | |||
94 | 3 | public function getDisplayName() |
|
98 | } |
||
99 |