|
| 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) |
0 commit comments