|
1
|
|
|
<?php |
|
2
|
|
|
class CommonBadgeActivator extends BadgeActivator |
|
3
|
|
|
{ |
|
4
|
|
|
public function triggerTravel($id) |
|
5
|
|
|
{ |
|
6
|
|
|
if ($id == 3) { |
|
7
|
|
|
$this->activate('travel_loc3'); |
|
8
|
|
|
} |
|
9
|
|
|
|
|
10
|
|
|
if ($id == 5) { |
|
11
|
|
|
$this->activate('travel_county2'); |
|
12
|
|
|
} |
|
13
|
|
|
|
|
14
|
|
|
if ($id == 33) { |
|
15
|
|
|
$this->activate('travel_county9'); |
|
16
|
|
|
} |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function triggerLocationRoutine($id, $routine) |
|
20
|
|
|
{ |
|
21
|
|
|
$map = [ |
|
22
|
|
|
'4b' => [4, 1], |
|
23
|
|
|
'13s' => [13, 3], |
|
24
|
|
|
'28s' => [28, 3], |
|
25
|
|
|
'37g' => [37, 9], |
|
26
|
|
|
'52b' => [52, 1], |
|
27
|
|
|
'61s' => [61, 3], |
|
28
|
|
|
'71g' => [71, 9], |
|
29
|
|
|
'72e' => [72, 27], |
|
30
|
|
|
'46d' => [46, 81] |
|
31
|
|
|
]; |
|
32
|
|
|
foreach ($map as $key => $params) { |
|
33
|
|
|
if ($id == $params[0] && $routine >= $params[1]) { |
|
34
|
|
|
$this->activate('loc_routine_' . $key); |
|
35
|
|
|
} |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function triggerSimple($id) |
|
40
|
|
|
{ |
|
41
|
|
|
$activate = false; |
|
42
|
|
|
switch ($id) { |
|
43
|
|
|
case 'energy_drink': |
|
44
|
|
|
$activate = true; |
|
45
|
|
|
break; |
|
46
|
|
|
case 'win_contest': |
|
47
|
|
|
$activate = true; |
|
48
|
|
|
break; |
|
49
|
|
|
case 'club_join': |
|
50
|
|
|
$activate = true; |
|
51
|
|
|
break; |
|
52
|
|
|
case 'club_create': |
|
53
|
|
|
$activate = true; |
|
54
|
|
|
break; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
if ($activate) { |
|
58
|
|
|
$this->activate($id); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function triggerRoutine($routine) |
|
63
|
|
|
{ |
|
64
|
|
|
if ($routine >= 100) { |
|
65
|
|
|
$this->activate('routine_100'); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function triggerSetPart($part) |
|
70
|
|
|
{ |
|
71
|
|
|
foreach ([3, 10, 30] as $cnt) { |
|
72
|
|
|
if ($part >= $cnt) { |
|
73
|
|
|
$this->activate('setpart_' . $cnt); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function triggerItems($cnt) |
|
79
|
|
|
{ |
|
80
|
|
|
if ($cnt >= 10) { |
|
81
|
|
|
$this->activate('shop_item10'); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function triggerBaits($cnt) |
|
86
|
|
|
{ |
|
87
|
|
|
if ($cnt >= 20) { |
|
88
|
|
|
$this->activate('shop_bait20'); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function triggerSet($id, $sold = false) |
|
93
|
|
|
{ |
|
94
|
|
|
$key = $sold ? 'set_sell_': 'set_'; |
|
95
|
|
|
|
|
96
|
|
|
foreach ([1 => 'b', 2 => 's', 3 => 'g'] as $search => $type) { |
|
97
|
|
|
if ($id == $search) { |
|
98
|
|
|
$this->activate($key . $type); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
public function triggerClubMembers($cnt) |
|
104
|
|
|
{ |
|
105
|
|
|
if ($cnt >= 8) { |
|
106
|
|
|
$this->activate('club_members_8'); |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function triggerLoginDays() |
|
111
|
|
|
{ |
|
112
|
|
|
$cnt = $this->getLoginDays(); |
|
113
|
|
|
foreach ([7, 30, 60] as $limit) { |
|
114
|
|
|
if ($cnt >= $limit) { |
|
115
|
|
|
$this->activate('login_days_' . $limit); |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
private function getLoginDays() |
|
121
|
|
|
{ |
|
122
|
|
|
$redis = Yii::app()->redis->getClient(); |
|
123
|
|
|
$key = "counter:login:days:".$this->uid; |
|
|
|
|
|
|
124
|
|
|
return (int)$redis->hGet($key, 'cnt'); |
|
125
|
|
|
} |
|
126
|
|
|
} |
|
|
|
|
|
|
127
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.