Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Wynncraft DPS calculator
- import requests, json
- print('\n:: ------------------- WYNNCRAFT DPS CALCULATOR ------------------- ::\n:: DPS values for super fast and super slow weapons are approximate ::\n')
- # Get item name as string
- item_name = str(input('Item name : '))
- payload = {'action': 'itemDB', 'search': item_name}
- # Fetch JSON with parameters itemDB and item name
- r = requests.get('https://api.wynncraft.com/public_api.php', params = payload)
- # Get JSON data
- json_data = r.json()
- # Get specific values
- official_name = json_data['items'][0]['name']
- lore = str(json_data['items'][0]['addedLore'])
- attack_speed = json_data['items'][0]['attackSpeed']
- damage = json_data['items'][0]['damage']
- # Map weapon attack speed strings to int values
- weapon_time_dict = {
- 'SUPER_FAST': 4,
- 'VERY_FAST': 2.5,
- 'FAST': 1.9,
- 'NORMAL': 1.7,
- 'SLOW': 1.3,
- 'VERY_SLOW': 0.8,
- 'SUPER_SLOW': 0.4
- }
- # Map uppercase attack speed strings to more readable strings
- weapon_lower_dict = {
- 'SUPER_FAST': 'Super fast',
- 'VERY_FAST': 'Very fast',
- 'FAST': 'Fast',
- 'NORMAL': 'Normal',
- 'SLOW': 'Slow',
- 'VERY_SLOW': 'Very slow',
- 'SUPER_SLOW': 'Super slow'
- }
- # Get average weapon damage
- weapon_damages = damage.split('-')
- weapon_approx_damage = (int(weapon_damages[1]) + int(weapon_damages[0])) / 2
- # Calculate dps
- dps = weapon_approx_damage * weapon_time_dict.get(attack_speed)
- # Print everything
- print('Lore : ' + lore)
- print('Attack speed: ' + weapon_lower_dict.get(attack_speed))
- print('Damage : ' + damage)
- print('Avg damage : ' + '%.2f' % weapon_approx_damage)
- print('\n:: -------------- ::')
- print(':: DPS : ' + '%.2f' % dps + ' ::')
- print(':: -------------- ::')
Advertisement
Add Comment
Please, Sign In to add comment