Skip to content

Commit

Permalink
calculate unique item cdr and haste items cdr
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeIsJustLikeMagic committed Jul 5, 2020
1 parent 2b60d20 commit 5ca9b00
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 46 deletions.
80 changes: 43 additions & 37 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 37 additions & 9 deletions Bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def eventFilter(self, spellbutton, event):
if not spellbutton.set:
id = (spellbutton.id)
spell = dataholder.getSpell(id)
cd = calculateCD(spell)
cd = float("{:.2f}".format(calculateCD(spell)))
if spellbutton.spellName != 'ult':
cd = int(cd)
spellbutton.setText(str(cd))
Expand Down Expand Up @@ -751,7 +751,6 @@ def calculateCD(spellObject):
if gtcdr == spellDatabase.get("ARAM"):
cd = cd * (1.0 - (spellObject.runecdr / 100.0))
cdr = gtcdr + getItemScdr(spellObject)
return
cd = cd * (1.0 - ((gtcdr + getItemScdr(spellObject)) / 100.0))
else:
cd = cd * (1.0 - ((getItemScdr(spellObject) + spellObject.runecdr) / 100.0))
Expand Down Expand Up @@ -973,11 +972,30 @@ def getItemScdr(summonerspell):
def getItemUcdr(ultspell):
items = dataholder.getItem(ultspell.champion)
ucdr = 0.0
#basecdr
s = []
for item in items:
id = item.get('itemID')
cd = dataholder.getItemCD(id)
if cd is not None:
s.append(id)
cd = cd.get('base')
if cd is not None:
ucdr = ucdr + cd
#qunique
itemset = set(s)
for id in itemset:
cd = dataholder.getItemCD(id)
cd = cd.get('unique')
if cd is not None:
ucdr = ucdr + cd
for id in itemset:
cd = dataholder.getItemCD(id)
cd = cd.get('haste')
if cd is not None:
ucdr = ucdr + cd
break

return ucdr

def loadLevelsAndItems():
Expand Down Expand Up @@ -1500,17 +1518,27 @@ def updateItems():
j = json.loads(r.content)
p = re.compile('([0-9]*)% Cooldown Reduction')
dict = {}
i = {}
for item in j:
itemid = item.get('id')
for c in item.get('categories'):
if c == 'CooldownReduction':
desc = item.get('description')
cdlist = p.findall(desc)
if len(cdlist) > 0:
cd = 0
for c in cdlist:
cd = cd + int(c)
dict[itemid] = cd
l = re.split('UNIQUE', desc, maxsplit=1)
i = {}
for desc in l:
cdlist = p.findall(desc)
if len(cdlist) > 0:
cd = 0
for c in cdlist:
cd = cd + int(c)
if re.search('Haste', desc) is not None:
i['haste'] = cd
elif re.search('UNIQUE', desc) is not None:
i['unique'] = cd
else:
i['base'] = cd
dict[itemid] = i
filepath = os.path.join(appdatadir.jsondir, "items.json")
with open(filepath, 'w') as outfile:
json.dump(dict, outfile)
Expand Down Expand Up @@ -1565,7 +1593,7 @@ def loadItems():
logging.StreamHandler()
]
)
updateSummonSpellJson()
updateItems()
initCDragon()

logging.debug('m0 overlay started! (0/4 startup, 0/5 entire run)')
Expand Down

0 comments on commit 5ca9b00

Please sign in to comment.