Skip to content
This repository was archived by the owner on Sep 16, 2022. It is now read-only.

Commit 3e59d5a

Browse files
authored
Merge pull request #2 from HenryQuan/Comment
Comment merges to master
2 parents 8540c99 + 0540857 commit 3e59d5a

File tree

4 files changed

+74
-7
lines changed

4 files changed

+74
-7
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
*.pyc

WoWs Personal Rating.py

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import json
2+
3+
def getRatingComment(rating):
4+
# There are eight comment in total
5+
if rating >= 0 and rating <= 750:
6+
print('Keep it up')
7+
elif rating <= 1100:
8+
print('Below Average')
9+
elif rating <= 1350:
10+
print('Average')
11+
elif rating <= 1550:
12+
print('Good')
13+
elif rating <= 1750:
14+
print('Very Good')
15+
elif rating <= 2100:
16+
print('Great')
17+
elif rating <= 2450:
18+
print('Unicum')
19+
elif rating <= 9999:
20+
print('Super Unicum')
21+
else:
22+
print('Error')
23+
24+
print('\nWorld of Warship Personal Rating\n(http://wows-numbers.com/personal/rating)')
25+
26+
# load json file locally
27+
with open('expected.json') as json_data:
28+
data = json.load(json_data)
29+
30+
# Get total number of data
31+
shipCount = len(data['data'])
32+
33+
damage = 0
34+
frag = 0
35+
winRate = 0
36+
37+
# Accumulating averageDamage, averageFrags and average winRate
38+
for key in data['data'].keys():
39+
damage += data['data'][key]['average_damage_dealt']
40+
frag += data['data'][key]['average_frags']
41+
winRate += data['data'][key]['win_rate']
42+
43+
expectedDamage = damage / shipCount
44+
expectedFrags = frag / shipCount
45+
expectedWinRate = winRate / shipCount
46+
47+
print('\n' + str(expectedDamage) + '\n' + str(expectedFrags) + '\n' + str(expectedWinRate) + '\n')
48+
49+
# Calculate with your data
50+
# Change your data here... This is not accurate but only a estimated value. Please visit wows-number for more information
51+
actualDmg = 99999
52+
actualWins = 99.9
53+
actualFrags = 99.9
54+
55+
rDmg = actualDmg/expectedDamage
56+
rWins = actualWins/expectedWinRate
57+
rFrags = actualFrags/expectedFrags
58+
59+
nDmg = max(0, (rDmg - 0.4) / (1 - 0.4))
60+
nFrags = max(0, (rFrags - 0.1) / (1 - 0.1))
61+
nWins = max(0, (rWins - 0.7) / (1 - 0.7))
62+
63+
PR = 700 * nDmg + 300 * nFrags + 150 * nWins
64+
print('Your personal rate is ' + str(PR))
65+
getRatingComment(PR)

WoWsClass.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ def getServerDomain(self, name):
3333
def setAPI(self):
3434
self.playerAPI = 'https://api.worldofwarships.' + str(self.server) + \
3535
'/wows/account/list/?application_id=' + str(self.application_id)
36-
self.playerDataAPI = 'https://api.worldofwarships.' + str(self.server) + \
37-
'/wows/account/info/?application_id=' + str(self.application_id)
36+
self.playerDataAPI = a' + str(self.application_id)
3837
self.playerDataByDateAPI = 'https://api.worldofwarships.' + str(self.server) + \
3938
'/wows/account/statsbydate/?application_id=' + str(self.application_id)
4039

@@ -186,12 +185,12 @@ def getinformationForTodayAndYesterday(self, account_id):
186185
if str(daybefore) in playerDataJson['data'][str(account_id)]['pvp']:
187186
daybeforeData = playerDataJson['data'][str(account_id)]['pvp'][str(daybefore)]
188187

189-
dataToday = self.getDataForDate(todayData, yesterdayData)
190-
dataYesterday = self.getDataForDate(yesterdayData, daybeforeData)
191-
TYData = dataToday + dataYesterday
188+
dataToday = self.getDataForDate(todayData, yesterdayData)
189+
dataYesterday = self.getDataForDate(yesterdayData, daybeforeData)
190+
TYData = dataToday + dataYesterday
192191

193-
# Today and Yesterday data
194-
return TYData
192+
# Today and Yesterday data
193+
return TYData
195194

196195
# print out useful for this player
197196
def printInformation(self, data, account_id, todayData):

0 commit comments

Comments
 (0)