Repository navigation
Expand file tree
/
Copy path_modDiscordPacker.php
More file actions
104 lines (94 loc) · 3.01 KB
/
Copy path_modDiscordPacker.php
File metadata and controls
104 lines (94 loc) · 3.01 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
class DiscordPacker{
public $rabbitChan;
function preInit($pch,...$data){
$this->rabbitChan=$pch->callPlugin("RabbitMQ::connChan");
$this->rabbitChan->queue_declare("bot_".SRV_ID,false,true,false,false);
}
function genpayload($type,$obj){
return json_encode(array("type"=>$type,"data"=>$obj));
}
function onPlayerActivate($pch,$id,$uname,$emailFWD){
$pch->callPlugin("RabbitMQ::publishText",$this->rabbitChan,$this->genpayload("newuser",$uname));
}
function onPlayerNew(...$data){
$this->onPlayerActivate(...$data);
}
function onLevelUpload($pch, $id, $name, $builder, $desc){
$pch->callPlugin("RabbitMQ::publishText",$this->rabbitChan,$this->genpayload("newlevel",array(
"id"=>$id,
"name"=>$name,
"builder"=>$builder,
"desc"=>$desc
)));
}
function onLevelUpdate(...$data){
$this->onLevelUpload(...$data); //I'm legally blind
}
function onLevelRate($pch, $id, $name, $builder, $stars, $likes, $downloads, $length, $demonDiff, $isEpic, $isFeatured, $ratedBy){
$pch->callPlugin("RabbitMQ::publishText",$this->rabbitChan,$this->genpayload("rate",array(
"id"=>$id,
"name"=>$name,
"builder"=>$builder,
"diff"=>$this->diffToText($stars,$demonDiff,$isEpic,$isFeatured),
"stars"=>$stars,
"likes"=>$likes,
"downloads"=>$downloads,
"len"=>$length,
"rateuser"=>$ratedBy[1]
)));
}
function unload($pch){
$pch->callPlugin("RabbitMQ::close",$this->rabbitChan);
}
function diffToText($stars,$demonDiff,$isEpic,$isFeatured){
switch($stars){
case 1:
$diff="auto";
break;
case 2:
$diff="easy";
break;
case 3:
$diff="normal";
break;
case 4:
case 5:
$diff="hard";
break;
case 6:
case 7:
$diff="harder";
break;
case 8:
case 9:
$diff="insane";
break;
case 10:
$diff="demon";
switch($demonDiff){
case 3:
$diff.="-easy";
break;
case 4:
$diff.="-medium";
break;
case 5:
$diff.="-insane";
break;
case 6:
$diff.="-extreme";
break;
case 0:
default:
$diff.="-hard";
}
break;
default:
$diff="unrated";
}
if($isEpic) return $diff."-epic";
if($isFeatured) return $diff."-featured";
return $diff;
}
}