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

Commit

Permalink
Merge pull request #2 from HenryQuan/Comment
Browse files Browse the repository at this point in the history
Comment merges to master
  • Loading branch information
HenryQuan authored Feb 12, 2017
2 parents 8540c99 + 0540857 commit 3e59d5a
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

*.pyc
65 changes: 65 additions & 0 deletions WoWs Personal Rating.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import json

def getRatingComment(rating):
# There are eight comment in total
if rating >= 0 and rating <= 750:
print('Keep it up')
elif rating <= 1100:
print('Below Average')
elif rating <= 1350:
print('Average')
elif rating <= 1550:
print('Good')
elif rating <= 1750:
print('Very Good')
elif rating <= 2100:
print('Great')
elif rating <= 2450:
print('Unicum')
elif rating <= 9999:
print('Super Unicum')
else:
print('Error')

print('\nWorld of Warship Personal Rating\n(http://wows-numbers.com/personal/rating)')

# load json file locally
with open('expected.json') as json_data:
data = json.load(json_data)

# Get total number of data
shipCount = len(data['data'])

damage = 0
frag = 0
winRate = 0

# Accumulating averageDamage, averageFrags and average winRate
for key in data['data'].keys():
damage += data['data'][key]['average_damage_dealt']
frag += data['data'][key]['average_frags']
winRate += data['data'][key]['win_rate']

expectedDamage = damage / shipCount
expectedFrags = frag / shipCount
expectedWinRate = winRate / shipCount

print('\n' + str(expectedDamage) + '\n' + str(expectedFrags) + '\n' + str(expectedWinRate) + '\n')

# Calculate with your data
# Change your data here... This is not accurate but only a estimated value. Please visit wows-number for more information
actualDmg = 99999
actualWins = 99.9
actualFrags = 99.9

rDmg = actualDmg/expectedDamage
rWins = actualWins/expectedWinRate
rFrags = actualFrags/expectedFrags

nDmg = max(0, (rDmg - 0.4) / (1 - 0.4))
nFrags = max(0, (rFrags - 0.1) / (1 - 0.1))
nWins = max(0, (rWins - 0.7) / (1 - 0.7))

PR = 700 * nDmg + 300 * nFrags + 150 * nWins
print('Your personal rate is ' + str(PR))
getRatingComment(PR)
13 changes: 6 additions & 7 deletions WoWsClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ def getServerDomain(self, name):
def setAPI(self):
self.playerAPI = 'https://api.worldofwarships.' + str(self.server) + \
'/wows/account/list/?application_id=' + str(self.application_id)
self.playerDataAPI = 'https://api.worldofwarships.' + str(self.server) + \
'/wows/account/info/?application_id=' + str(self.application_id)
self.playerDataAPI = a' + str(self.application_id)
self.playerDataByDateAPI = 'https://api.worldofwarships.' + str(self.server) + \
'/wows/account/statsbydate/?application_id=' + str(self.application_id)

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

dataToday = self.getDataForDate(todayData, yesterdayData)
dataYesterday = self.getDataForDate(yesterdayData, daybeforeData)
TYData = dataToday + dataYesterday
dataToday = self.getDataForDate(todayData, yesterdayData)
dataYesterday = self.getDataForDate(yesterdayData, daybeforeData)
TYData = dataToday + dataYesterday

# Today and Yesterday data
return TYData
# Today and Yesterday data
return TYData

# print out useful for this player
def printInformation(self, data, account_id, todayData):
Expand Down
Loading

0 comments on commit 3e59d5a

Please sign in to comment.