Skip to content

Commit

Permalink
Fixes. Fixes everywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pathal authored and Pathal committed Oct 15, 2012
1 parent e60c6c5 commit 4c25cd8
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 31 deletions.
25 changes: 20 additions & 5 deletions scripts/import_character.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,28 @@ class CharacterData:
4419 : [{'stat':'agi', 'value':80}, {'stat':'str', 'value':80}],
4421 : [{'stat':'hit', 'value':180}],
4428 : [{'stat':'agi', 'value':140}], #Speed Boost
4430 : [{'stat':'haste', 'value':170}],
4431 : [{'stat':'exp', 'value':170}],
4804 : [{'stat':'agi', 'value':200}, {'stat':'crit', 'value':100}],
4875 : [{'stat':'agi', 'value':500}], #Leatherworking Perk
4880 : [{'stat':'agi', 'value':285}, {'stat':'crit', 'value':165}],
4411 : [{'stat':'mastery', 'value':170}],
4871 : [{'stat':'agi', 'value':170}, {'stat':'crit', 'value':100}]
}

gemsMap = {76666: [{'stat':'agi', 'value':80}, {'stat':'haste', 'value':160}],
76884: [{'stat':'agi', 'value':216}, 'chaotic_metagem'],
76643: [{'stat':'hit', 'value':160}, {'stat':'mastery', 'value':160}],
76576: [{'stat':'hit', 'value':160}, {'stat':'haste', 'value':160}],
76636: [{'stat':'hit', 'value':320}],
gemsMap = {76884: [{'stat':'agi', 'value':216}, 'chaotic_metagem'],
83151: [{'stat':'agi', 'value':320}], #agi JC gem
76626: [{'stat':'agi', 'value':160}],
76680: [{'stat':'agi', 'value':80}, {'stat':'hit', 'value':160}],
76614: [{'stat':'agi', 'value':80}, {'stat':'hit', 'value':160}],
76666: [{'stat':'agi', 'value':80}, {'stat':'haste', 'value':160}],
76600: [{'stat':'agi', 'value':80}, {'stat':'haste', 'value':160}],
76604: [{'stat':'agi', 'value':80}, {'stat':'mastery', 'value':160}],
76670: [{'stat':'agi', 'value':80}, {'stat':'mastery', 'value':160}],
76636: [{'stat':'hit', 'value':320}],
76576: [{'stat':'hit', 'value':160}, {'stat':'haste', 'value':160}],
76643: [{'stat':'hit', 'value':160}, {'stat':'mastery', 'value':160}],
76699: [{'stat':'haste', 'value':320}],
76667: [{'stat':'exp', 'value':160}, {'stat':'haste', 'value':160}],
}

Expand Down Expand Up @@ -263,6 +273,9 @@ def get_oh(self):
item_data = self.raw_data['data'][u'items'][u'offHand']
weapon_data = get_item_cached(self.region, item_data[u'id'])
return self.get_weapon(weapon_data, item_data)

def get_mh_type(self):
return self.get_mh()[2]

def get_trinket_proc(self, item_data):
id = item_data[u'id']
Expand Down Expand Up @@ -319,6 +332,7 @@ def get_gear_stats(self):
#
lst = {'agi': 0, 'str':0, 'stam':0, 'crit':0, 'hit':0, 'exp':0, 'haste':0, 'mastery':0, 'ap':0, 'pvp_power':0, 'pvp_resil':0}
reforge = ('none', 'none')
reforgeID = None
gemList = {u'gem0':None, u'gem1':None, u'gem2':None}
#Loops over every item
for p in self.raw_data['data'][u'items']:
Expand Down Expand Up @@ -357,6 +371,7 @@ def get_gear_stats(self):
#add stats from enchants
if u'enchant' in params.keys():
if not type( CharacterData.enchants[ params[u'enchant'] ] ) == type(''):
#print CharacterData.enchants[ params[u'enchant'] ]
for key in CharacterData.enchants[ params[u'enchant'] ]:
lst[ key['stat'] ] += key['value']
except Exception as inst:
Expand Down
Binary file modified scripts/item_db.db
Binary file not shown.
30 changes: 22 additions & 8 deletions scripts/mop_assassination_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@
test_language = 'local'
i18n.set_language(test_language)

character_data = CharacterData('us', 'Doomhammer', 'Pins')
charInfo = {'region':'us', 'realm':'Doomhammer', 'name':'Pins', 'talents':None, 'stormlash':False}
key = 1
while key < len(sys.argv):
terms = sys.argv[key].split(':')
charInfo[ terms[0] ] = terms[1]
key += 1

print "Loading " + charInfo['name'] + " of " + charInfo['region'] + "-" + charInfo['realm'] + "\n"
character_data = CharacterData(charInfo['region'], charInfo['realm'], charInfo['name'])
character_data.do_import()


Expand Down Expand Up @@ -73,6 +81,8 @@
test_stats = stats.Stats(*(character_stats + [test_mh, test_oh, test_procs, test_gear_buffs]), pvp_power=0, pvp_resil=0, pvp_target_armor=None)

# Initialize talents..
if charInfo['talents'] == None:
charInfo['talents'] = character_data.get_talents()
test_talents = talents.Talents(character_data.get_talents(), test_class, test_level)

# Set up glyphs.
Expand All @@ -82,10 +92,11 @@
# Set up settings.
test_cycle = settings.AssassinationCycle(min_envenom_size_non_execute=4, min_envenom_size_execute=5,
prioritize_rupture_uptime_non_execute=True, prioritize_rupture_uptime_execute=True)
test_settings = settings.Settings(test_cycle, response_time=.5, duration=360, dmg_poison='dp', utl_poison='lp', is_pvp=False)
test_settings = settings.Settings(test_cycle, response_time=.5, duration=360, dmg_poison='dp', utl_poison='lp', is_pvp=False,
stormlash=charInfo['stormlash'])

# Build a DPS object.
calculator = AldrianasRogueDamageCalculator(test_stats, test_talents, test_glyphs, test_buffs, test_race, test_settings, test_level)
calculator = AldrianasRogueDamageCalculator(test_stats, test_talents, test_glyphs, test_buffs, test_race, test_settings, test_level, char_class=test_class)

# Compute EP values.
ep_values = calculator.get_ep()
Expand All @@ -95,6 +106,7 @@
non_execute_breakdown = calculator.assassination_dps_breakdown_non_execute()
total_dps = sum(entry[1] for entry in dps_breakdown.items())
non_execute_total = sum(entry[1] for entry in non_execute_breakdown.items())
talent_ranks = calculator.get_talents_ranking()

def max_length(dict_list):
max_len = 0
Expand All @@ -105,26 +117,28 @@ def max_length(dict_list):

return max_len

def pretty_print(dict_list):
def pretty_print(dict_list, total_sum = 1.):
max_len = max_length(dict_list)

for i in dict_list:
dict_values = i.items()
dict_values.sort(key=lambda entry: entry[1], reverse=True)
for value in dict_values:
if ("{0:.2f}".format(float(value[1])/total_dps)) != '0.00':
print value[0] + ':' + ' ' * (max_len - len(value[0])), str(value[1]) + ' ('+str( "{0:.2f}".format(100*float(value[1])/total_dps) )+'%)'
#print value[0] + ':' + ' ' * (max_len - len(value[0])), str(value[1])
if ("{0:.2f}".format(10*float(value[1])/total_dps)) != '0.00':
print value[0] + ':' + ' ' * (max_len - len(value[0])), str(value[1]) + ' ('+str( "{0:.2f}".format(100*float(value[1])/total_sum) )+'%)'
else:
print value[0] + ':' + ' ' * (max_len - len(value[0])), str(value[1])
print '-' * (max_len + 15)

dicts_for_pretty_print = [
ep_values,
talent_ranks,
dps_breakdown
]
pretty_print(dicts_for_pretty_print)
pretty_print(dicts_for_pretty_print, total_sum=total_dps)
print ' ' * (max_length(dicts_for_pretty_print) + 1), total_dps, _("total damage per second.")
print ''
print 'non-execute breakdown: '
pretty_print([non_execute_breakdown])
pretty_print([non_execute_breakdown], total_sum=non_execute_total)
print ' ' * (max_length([non_execute_breakdown]) + 1), non_execute_total, _("total damage per second.")
12 changes: 7 additions & 5 deletions scripts/mop_combat_import.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Simple test program to debug + play with assassination models.
# Simple test program to debug + play with combat models.
from os import path
import sys
from import_character import CharacterData
Expand All @@ -22,7 +22,7 @@
test_language = 'local'
i18n.set_language(test_language)

character_data = CharacterData('eu', 'Silvermoon', 'Aylje')
character_data = CharacterData('us', 'Doomhammer', 'Pins')
character_data.do_import()


Expand Down Expand Up @@ -66,7 +66,7 @@

# Set up a calcs object..
# str, agi, ap, crit, hit, exp, haste, mast, mh, oh, procs, gear_buffs
character_stats = character_data.get_stats()
character_stats = character_data.get_gear_stats()
test_stats = stats.Stats(*(character_stats + [test_mh, test_oh, test_procs, test_gear_buffs]), pvp_power=0, pvp_resil=0, pvp_target_armor=None)


Expand All @@ -78,8 +78,8 @@
test_glyphs = glyphs.Glyphs(test_class, *glyph_list)

# Set up settings.
test_cycle = settings.CombatCycle()
test_settings = settings.Settings(test_cycle, response_time=1)
test_cycle = settings.CombatCycle(use_rupture=True, ksp_immediately=True, revealing_strike_pooling=True, blade_flurry=False)
test_settings = settings.Settings(test_cycle, response_time=.5, duration=360, dmg_poison='dp', utl_poison='lp', is_pvp=False)

# Build a DPS object.
calculator = AldrianasRogueDamageCalculator(test_stats, test_talents, test_glyphs, test_buffs, test_race, test_settings, test_level)
Expand All @@ -90,6 +90,7 @@
# Compute DPS Breakdown.
dps_breakdown = calculator.get_dps_breakdown()
total_dps = sum(entry[1] for entry in dps_breakdown.items())
talent_ranks = calculator.get_talents_ranking()

# Compute weapon type modifier.
weapon_type_mod = calculator.get_oh_weapon_modifier()
Expand Down Expand Up @@ -118,6 +119,7 @@ def pretty_print(dict_list):

dicts_for_pretty_print = [
weapon_type_mod,
talent_ranks,
ep_values,
dps_breakdown
]
Expand Down
4 changes: 2 additions & 2 deletions scripts/mop_subtlety.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
test_stats = stats.Stats(80, 19000, 250, 4800, 2550, 2550, 3000, 5000, test_mh, test_oh, test_procs, test_gear_buffs, pvp_power=3000, pvp_resil=0, pvp_target_armor=None)

# Initialize talents..
test_talents = talents.Talents('022210', test_class, test_level)
test_talents = talents.Talents('022211', test_class, test_level)

# Set up glyphs.
glyph_list = []
Expand All @@ -69,11 +69,11 @@

# Compute EP values.
ep_values = calculator.get_ep()
talent_ranks = calculator.get_talents_ranking()

# Compute DPS Breakdown.
dps_breakdown = calculator.get_dps_breakdown()
total_dps = sum(entry[1] for entry in dps_breakdown.items())
talent_ranks = calculator.get_talents_ranking()

def max_length(dict_list):
max_len = 0
Expand Down
141 changes: 141 additions & 0 deletions scripts/mop_subtlety_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Simple test program to debug + play with subtlety models.
from os import path
import sys
from import_character import CharacterData

#sys.path.append(path.abspath(path.join(path.dirname(__file__), '..')))

from shadowcraft.calcs.rogue.Aldriana import AldrianasRogueDamageCalculator
from shadowcraft.calcs.rogue.Aldriana import settings

from shadowcraft.objects import buffs
from shadowcraft.objects import race
from shadowcraft.objects import stats
from shadowcraft.objects import procs
from shadowcraft.objects import proc_data
from shadowcraft.objects import talents
from shadowcraft.objects import glyphs

from shadowcraft.core import i18n

# Set up language. Use 'en_US', 'es_ES', 'fr' for specific languages.
test_language = 'local'
i18n.set_language(test_language)

charInfo = {'region':'us', 'realm':'Doomhammer', 'name':'Pins', 'talents':None}
key = 1
while key < len(sys.argv):
terms = sys.argv[key].split(':')
charInfo[ terms[0] ] = terms[1]
key += 1

print "Loading " + charInfo['name'] + " of " + charInfo['region'] + "-" + charInfo['realm'] + "\n"
character_data = CharacterData(charInfo['region'], charInfo['realm'], charInfo['name'])
character_data.do_import()


# Set up level/class/race
test_level = 90
test_race = race.Race(character_data.get_race())
test_class = 'rogue'

# Set up buffs.
test_buffs = buffs.Buffs(
'short_term_haste_buff',
'stat_multiplier_buff',
'crit_chance_buff',
'mastery_buff',
'melee_haste_buff',
'attack_power_buff',
'armor_debuff',
'physical_vulnerability_debuff',
'spell_damage_debuff',
'agi_flask_mop',
'food_300_agi'
)

# Set up weapons.

test_mh = stats.Weapon(*character_data.get_mh())
test_oh = stats.Weapon(*character_data.get_oh())

# Set up procs.
character_procs = character_data.get_procs()
character_procs_allowed = filter(lambda p: p in proc_data.allowed_procs, character_procs)

#not_allowed_procs = set(character_procs) - set(character_procs_allowed)
#print not_allowed_procs

test_procs = procs.ProcsList(*character_procs_allowed)

# Set up gear buffs.
character_gear_buffs = character_data.get_gear_buffs() + ['leather_specialization', 'virmens_bite', 'virmens_bite_prepot', 'chaotic_metagem']
test_gear_buffs = stats.GearBuffs(*character_gear_buffs)

# Set up a calcs object..
# str, agi, ap, crit, hit, exp, haste, mast, mh, oh, procs, gear_buffs
#test_stats = stats.Stats(80, 19000, 250, 4800, 2550, 2550, 3000, 5000, test_mh, test_oh, test_procs, test_gear_buffs, pvp_power=0, pvp_resil=0, pvp_target_armor=None)
#[215, 12136, 365, 2486, 2584, 1582, 2423, 4039]
#character_stats = character_data.get_stats()
character_stats = character_data.get_gear_stats()
test_stats = stats.Stats(*(character_stats + [test_mh, test_oh, test_procs, test_gear_buffs]), pvp_power=0, pvp_resil=0, pvp_target_armor=None)

# Initialize talents..
if charInfo['talents'] == None:
charInfo['talents'] = character_data.get_talents()
test_talents = talents.Talents(charInfo['talents'], test_class, test_level)

# Set up glyphs.
glyph_list = character_data.get_glyphs()
test_glyphs = glyphs.Glyphs(test_class, *glyph_list)

# Set up settings.
raid_crits_per_second = 5
hemo_interval = 24 #'always', 'never', 24, 25, 26...
if not character_data.get_mh_type() == 'dagger':
if not hemo_interval == 'always':
print "\nALERT: Dagger not found, forced rotation to strictly Hemo \n"
hemo_interval = 'always'
test_cycle = settings.SubtletyCycle(raid_crits_per_second, use_hemorrhage=hemo_interval)
test_settings = settings.Settings(test_cycle, response_time=.5, duration=360, dmg_poison='dp', utl_poison='lp', is_pvp=False)

# Build a DPS object.
calculator = AldrianasRogueDamageCalculator(test_stats, test_talents, test_glyphs, test_buffs, test_race, test_settings, test_level)

# Compute EP values.
ep_values = calculator.get_ep()

# Compute DPS Breakdown.
dps_breakdown = calculator.get_dps_breakdown()
total_dps = sum(entry[1] for entry in dps_breakdown.items())
talent_ranks = calculator.get_talents_ranking()

def max_length(dict_list):
max_len = 0
for i in dict_list:
dict_values = i.items()
if max_len < max(len(entry[0]) for entry in dict_values):
max_len = max(len(entry[0]) for entry in dict_values)

return max_len

def pretty_print(dict_list):
max_len = max_length(dict_list)

for i in dict_list:
dict_values = i.items()
dict_values.sort(key=lambda entry: entry[1], reverse=True)
for value in dict_values:
if ("{0:.2f}".format(float(value[1])/total_dps)) != '0.00':
print value[0] + ':' + ' ' * (max_len - len(value[0])), str(value[1]) + ' ('+str( "{0:.2f}".format(100*float(value[1])/total_dps) )+'%)'
else:
print value[0] + ':' + ' ' * (max_len - len(value[0])), str(value[1])
print '-' * (max_len + 15)

dicts_for_pretty_print = [
ep_values,
talent_ranks,
dps_breakdown
]
pretty_print(dicts_for_pretty_print)
print ' ' * (max_length(dicts_for_pretty_print) + 1), total_dps, _("total damage per second.")
7 changes: 5 additions & 2 deletions shadowcraft/calcs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from shadowcraft.core import exceptions
from shadowcraft.calcs import armor_mitigation
from shadowcraft.objects import class_data
from shadowcraft.objects import talents
from shadowcraft.objects.procs import InvalidProcException

class DamageCalculator(object):
Expand All @@ -29,13 +30,14 @@ class DamageCalculator(object):
# normalize_ep_stat is the stat with value 1 EP, override in your subclass
normalize_ep_stat = None

def __init__(self, stats, talents, glyphs, buffs, race, settings=None, level=85, target_level=None):
def __init__(self, stats, talents, glyphs, buffs, race, settings=None, level=85, target_level=None, char_class='rogue'):
self.tools = class_data.Util()
self.stats = stats
self.talents = talents
self.glyphs = glyphs
self.buffs = buffs
self.race = race
self.char_class = char_class
self.settings = settings
self.target_level = [target_level, level + 3][target_level is None]
self.level_difference = max(self.target_level - level, 0)
Expand Down Expand Up @@ -313,6 +315,7 @@ def get_glyphs_ranking(self, list=None):

def get_talents_ranking(self, list=None):
talents_ranking = {}
self.talents = talents.Talents('000000', self.char_class, self.level)
baseline_dps = self.get_dps()
talent_list = []

Expand All @@ -326,7 +329,7 @@ def get_talents_ranking(self, list=None):
try:
new_dps = self.get_dps()
if new_dps != baseline_dps:
talents_ranking[talent] = abs(new_dps - baseline_dps)
talents_ranking[talent] = new_dps - baseline_dps
except:
talents_ranking[talent] = _('not implemented')
setattr(self.talents, talent, not getattr(self.talents, talent))
Expand Down
Loading

0 comments on commit 4c25cd8

Please sign in to comment.