Skip to content

Commit

Permalink
Fixed gitignore and added Black config file for standardization
Browse files Browse the repository at this point in the history
  • Loading branch information
dryancd committed Nov 18, 2020
1 parent f905ac2 commit 4848b11
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 17 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/files/
/files/model2.py
/items/
/champions/
__pycache__/
__cache__/
champions/
champions.json
items/
items.json
13 changes: 11 additions & 2 deletions lolstaticdata/champions/pull_champions_dragons.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,24 @@ def build_guess(


def perform_guess(
champion_name, ability_name, ability_key, ability_index, filenames, use_underscores=True,
champion_name,
ability_name,
ability_key,
ability_index,
filenames,
use_underscores=True,
):
best_score = -float("inf")
for include_champion_name in (True, False):
for include_ability_name in (True, False):
for include_ability_index in (True, False):
for include_ability_key in (True, False):
if include_champion_name is True and not any(
[include_ability_name, include_ability_index, include_ability_key,]
[
include_ability_name,
include_ability_index,
include_ability_key,
]
):
continue
guess = build_guess(
Expand Down
43 changes: 34 additions & 9 deletions lolstaticdata/champions/pull_champions_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ def get_champions(self) -> Iterator[Champion]:
d["skill_q"] = {1: d["skills"][3], 2: d["skills"][4]}
d["skill_e"] = {1: d["skills"][6], 2: d["skills"][7]}
d["skill_r"] = {1: d["skills"][8], 2: d["skills"][9]}
if d["id"] == 9999 or d["date"] == "Upcoming" or datetime.strptime(d["date"], "%Y-%m-%d") > datetime.today(): # Champion not released yet
if (
d["id"] == 9999
or d["date"] == "Upcoming"
or datetime.strptime(d["date"], "%Y-%m-%d") > datetime.today()
): # Champion not released yet
continue
champion = self._render_champion_data(name, d)
yield champion
Expand Down Expand Up @@ -230,7 +234,9 @@ def _render_champion_data(self, name: str, data: Dict) -> Champion:
per_level=data["stats"]["as_lvl"],
),
attack_speed_ratio=Stat(flat=data["stats"]["as_ratio"]),
attack_cast_time=Stat(flat=data["stats"].get("attack_cast_time", 0.3)), # I don't know if this default is correct, but going off the values the wiki provides, it seems reasonable.
attack_cast_time=Stat(
flat=data["stats"].get("attack_cast_time", 0.3)
), # I don't know if this default is correct, but going off the values the wiki provides, it seems reasonable.
attack_total_time=Stat(flat=data["stats"].get("attack_total_time", 1.6)), # ibid
attack_delay_offset=Stat(flat=data["stats"].get("attack_delay_offset", 0)),
attack_range=AttackRange(
Expand Down Expand Up @@ -285,39 +291,54 @@ def _render_champion_data(self, name: str, data: Dict) -> Champion:
abilities=[
self._pull_champion_ability(champion_name=name, ability_name=ability_name)
for ability_name in data["skill_i"].values()
if not (name in LolWikiDataHandler.MISSING_SKILLS and ability_name in LolWikiDataHandler.MISSING_SKILLS[name])
if not (
name in LolWikiDataHandler.MISSING_SKILLS
and ability_name in LolWikiDataHandler.MISSING_SKILLS[name]
)
],
),
self._render_abilities(
champion_name=name,
abilities=[
self._pull_champion_ability(champion_name=name, ability_name=ability_name)
for ability_name in data["skill_q"].values()
if not (name in LolWikiDataHandler.MISSING_SKILLS and ability_name in LolWikiDataHandler.MISSING_SKILLS[name])
if not (
name in LolWikiDataHandler.MISSING_SKILLS
and ability_name in LolWikiDataHandler.MISSING_SKILLS[name]
)
],
),
self._render_abilities(
champion_name=name,
abilities=[
self._pull_champion_ability(champion_name=name, ability_name=ability_name)
for ability_name in data["skill_w"].values()
if not (name in LolWikiDataHandler.MISSING_SKILLS and ability_name in LolWikiDataHandler.MISSING_SKILLS[name])
if not (
name in LolWikiDataHandler.MISSING_SKILLS
and ability_name in LolWikiDataHandler.MISSING_SKILLS[name]
)
],
),
self._render_abilities(
champion_name=name,
abilities=[
self._pull_champion_ability(champion_name=name, ability_name=ability_name)
for ability_name in data["skill_e"].values()
if not (name in LolWikiDataHandler.MISSING_SKILLS and ability_name in LolWikiDataHandler.MISSING_SKILLS[name])
if not (
name in LolWikiDataHandler.MISSING_SKILLS
and ability_name in LolWikiDataHandler.MISSING_SKILLS[name]
)
],
),
self._render_abilities(
champion_name=name,
abilities=[
self._pull_champion_ability(champion_name=name, ability_name=ability_name)
for ability_name in data["skill_r"].values()
if not (name in LolWikiDataHandler.MISSING_SKILLS and ability_name in LolWikiDataHandler.MISSING_SKILLS[name])
if not (
name in LolWikiDataHandler.MISSING_SKILLS
and ability_name in LolWikiDataHandler.MISSING_SKILLS[name]
)
],
),
]
Expand Down Expand Up @@ -365,7 +386,9 @@ def _render_abilities(self, champion_name, abilities: List[HTMLAbilityWrapper])
assert _skill_key == skill_key

if champion_name == "Pyke" and _skill_key == "I":
del data["Cost"] # This is a weird one... There's an embedded table that doesn't get parsed right. It overwrites 'cost', but luckily that isn't an issue because 'cost' is empty.
del data[
"Cost"
] # This is a weird one... There's an embedded table that doesn't get parsed right. It overwrites 'cost', but luckily that isn't an issue because 'cost' is empty.
if data.get("Cost") is not None:
raise ValueError(data)

Expand Down Expand Up @@ -703,7 +726,9 @@ def _get_champ_skin(self, name):
skins = []
champ_id = self.skin_data[name]["id"]

cdragon = "http://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/v1/champions/{0}.json".format(champ_id)
cdragon = "http://raw.communitydragon.org/pbe/plugins/rcp-be-lol-game-data/global/default/v1/champions/{0}.json".format(
champ_id
)
cdrag_json = download_json(cdragon, False)

for s in champ_data:
Expand Down
4 changes: 3 additions & 1 deletion lolstaticdata/common/modelcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ class MagicPenetration(Stat):
class ArmorPenetration(Stat):
pass


class AbilityHaste(Stat):
pass


class OmniVamp(Stat):
pass
pass
2 changes: 1 addition & 1 deletion lolstaticdata/items/pull_items_dragon.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ def get_ddragon(cls, ddragon: int, p: dict):
active=[],
stats=[],
shop=shop,
rank=""
rank="",
)
return item
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool.black]
line-length = 120
target-version = ['py37']
include = '\.pyi?$'
exclude = ''

0 comments on commit 4848b11

Please sign in to comment.