-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAchievements.php
executable file
·67 lines (56 loc) · 1.72 KB
/
Achievements.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/* Achievement
* -----------
*/
class Loadestone_Achievements
{
private $Category;
private $TotalPoints;
private $Points;
private $List;
// CATEGORIES
public function setCategory($ID)
{
$this->Category = $ID;
}
public function getCategory() { return $this->Category; }
// POINTS
public function setPoints($String)
{
$this->TotalPoints = trim($String[0]);
}
public function getPoints() { return $this->TotalPoints; }
// ACHIEVEMENTS
public function set($Array)
{
// New list of achievements
$NewList = array();
// Loop through achievement blocks
foreach($Array as $A)
{
// Temp data array
$Temp = array();
// Loop through block data
$i = 0;
foreach($A as $Line)
{
// Get achievement Data
if (stripos($Line, 'achievement_name') !== false) { $Data = trim(strip_tags(html_entity_decode($Line))); $Temp['name'] = $Data; }
if (stripos($Line, 'achievement_point') !== false) { $Data = trim(strip_tags(html_entity_decode($Line))); $Temp['points'] = $Data; }
if (stripos($Line, 'getElementById') !== false) { $Temp['date'] = trim(filter_var(explode("(", strip_tags(html_entity_decode($Line)))[2], FILTER_SANITIZE_NUMBER_INT)); }
// Increment
$i++;
}
// Obtained or not
if ($Temp['date']) { $Temp['obtained'] = true; } else { $Temp['obtained'] = false; }
// Increment Points
if ($Temp['obtained']) { $this->Points['current'] += $Temp['points']; }
$this->Points['max'] += $Temp['points'];
// Append temp data
$NewList[] = $Temp;
}
// Set Achievement List
$this->List = $NewList;
}
public function get() { return $this->List; }
}