check.js
5.91 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
var Pubg = require('./pubg');
var p = new Pubg();
var check={};
check.checkdata = function(id,region,mode,callback){
p.recivedata(id,region,mode,function(data){
var temp = -1;
var result = {
'flag': 1,
'id': id,
'per' : 0,
'head' : 0,
'kda' : 0,
'deal' : 0,
'kill' : 0
};
if(data['error']){
callback(result);
}else{
var flag = false;
for(var i=0; i<data['stats'].length;i++){
if(data['stats'][i]['region']==region&&data['stats'][i]['mode']==mode&&data['stats'][i]['season']=='2017-pre5'){
flag = true;
temp = i;
}
}
if(flag){
result['flag'] =2;
for(var i =0; i<data['stats'][temp]['stats'].length; i++){
if(data['stats'][temp]['stats'][i]['label']=='Avg Dmg per Match'){
result['deal'] = data['stats'][temp]['stats'][i]['value'];
}else if(data['stats'][temp]['stats'][i]['label']=='Kills Pg'){
result['kill'] = data['stats'][temp]['stats'][i]['value'];
}else if(data['stats'][temp]['stats'][i]['label']=='Headshot Kill Ratio'){
result['head'] = data['stats'][temp]['stats'][i]['value'];
}else if(data['stats'][temp]['stats'][i]['label']=='K/D Ratio'){
result['kda'] = data['stats'][temp]['stats'][i]['value'];
}
}
var dealscore = result['deal'];
if(dealscore<300){
dealscore =0;
}else if(dealscore>=700){
dealscore = 400;
dealscore = dealscore/400*40+5;
}else{
dealscore -= 300;
dealscore = dealscore/400*40+5;
}
var headscore = result['head']*100;
if(headscore<35){
headscore =0;
}else if(headscore>60){
headscore = 35;
headscore = headscore/35*20+5;
}else{
headscore -=35;
headscore = headscore/35*20+5;
}
var killscore = result['kill'];
if(killscore < 4){
killscore =0;
}else if(killscore >=10){
killscore =6;
killscore = killscore/6*10+5;
}else{
killscore -=4;
killscore = killscore/6*10+5;
}
var kdascore = result['kda'];
if(kdascore <5){
kdascore = 0;
}else if(kdascore > 10){
kdascore = 5;
}else {
kdascore -=5;
}
kdascore = kdascore/5*10;
result['per'] = dealscore+headscore+killscore+kdascore;
result['per']=result['per'].toFixed(2);
callback(result);
}else{
callback(result);
}
}
});
}
check.detaildata = function(id,region,mode,callback){
p.recivedata(id,region,mode,function(data){
var temp = -1;
var result = {
'round' : "", // Rounds Played
'wins' : "", // Wins
'top10' : "", // Top 10s
'lose' : "", // Losses
'rating' :"", // Rating
'bestrate' : "", // Best Rating
'dmg' : "", // Avg Dmg per Match
'head' : "", //Headshot Kill Ratio
'heal' : "", // Heals Pg
'kill' : "", // Kills Pg
'distance' : "", // Move Distance Pg
'revive' : "", // Revives Pg
'road' : "", // Road Kills Pg
'team' : "", // Team Kills Pg
'survive' : "", // Time Survived Pg
'long':"" // Longest Kill
};
for(var i=0; i<data['stats'].length;i++){
if(data['stats'][i]['region']==region&&data['stats'][i]['mode']==mode&&data['stats'][i]['season']=='2017-pre5'){
temp=i;
break;
}
}
for(var i =0; i<data['stats'][temp]['stats'].length; i++){
if(data['stats'][temp]['stats'][i]['label']=='Rounds Played'){
result['round'] = data['stats'][temp]['stats'][i]['displayValue'];
}else if(data['stats'][temp]['stats'][i]['label']=='Wins'){
result['wins'] = data['stats'][temp]['stats'][i]['displayValue'];
}else if(data['stats'][temp]['stats'][i]['label']=='Top 10s'){
result['top10'] = data['stats'][temp]['stats'][i]['value'];
}else if(data['stats'][temp]['stats'][i]['label']=='Losses'){
result['lose'] = data['stats'][temp]['stats'][i]['displayValue'];
}else if(data['stats'][temp]['stats'][i]['label']=='Rating'){
result['rating'] = data['stats'][temp]['stats'][i]['displayValue'];
}else if(data['stats'][temp]['stats'][i]['label']=='Best Rating'){
result['bestrate'] = data['stats'][temp]['stats'][i]['displayValue'];
}else if(data['stats'][temp]['stats'][i]['label']=='Avg Dmg per Match'){
result['dmg'] = data['stats'][temp]['stats'][i]['displayValue'];
}else if(data['stats'][temp]['stats'][i]['label']=='Headshot Kill Ratio'){
result['head'] = data['stats'][temp]['stats'][i]['displayValue'];
}else if(data['stats'][temp]['stats'][i]['label']=='Heals Pg'){
result['heal'] = data['stats'][temp]['stats'][i]['displayValue'];
}else if(data['stats'][temp]['stats'][i]['label']=='Kills Pg'){
result['kill'] = data['stats'][temp]['stats'][i]['displayValue'];
}else if(data['stats'][temp]['stats'][i]['label']=='Move Distance Pg'){
result['distance'] = data['stats'][temp]['stats'][i]['displayValue'];
}else if(data['stats'][temp]['stats'][i]['label']=='Revives Pg'){
result['revive'] = data['stats'][temp]['stats'][i]['displayValue'];
}else if(data['stats'][temp]['stats'][i]['label']=='Road Kills Pg'){
result['road'] = data['stats'][temp]['stats'][i]['displayValue'];
}else if(data['stats'][temp]['stats'][i]['label']=='Team Kills Pg'){
result['team'] = data['stats'][temp]['stats'][i]['displayValue'];
}else if(data['stats'][temp]['stats'][i]['label']=='Time Survived Pg'){
result['survive'] = data['stats'][temp]['stats'][i]['displayValue'];
}else if(data['stats'][temp]['stats'][i]['label']=='Longest Kill'){
result['long'] = data['stats'][temp]['stats'][i]['displayValue'];
}
}
callback(result);
});
}
module.exports = check;