Skip to content

Commit

Permalink
Unify the rarity data classes for consistency
Browse files Browse the repository at this point in the history
Signed-off-by: Akashdeep Dhar <[email protected]>
  • Loading branch information
gridhead committed Aug 27, 2024
1 parent 0957055 commit 555de71
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 35 deletions.
4 changes: 2 additions & 2 deletions gi_loadouts/face/wind/fclt.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def arti_load(self, part: str) -> None:
droptype = getattr(self, f"arti_{part}_type")
droptype.setCurrentText(arti.type.value.name)
droprare = getattr(self, f"arti_{part}_rare")
droprare.setCurrentText(f"Star {arti.rare.value}")
droprare.setCurrentText(f"Star {arti.rare.value.name}")
droplevl = getattr(self, f"arti_{part}_levl")
droplevl.setCurrentText(arti.levl.value.name)

Expand Down Expand Up @@ -234,7 +234,7 @@ def team_load(self) -> None:
droptype = getattr(self, f"arti_{part}_type")
droptype.setCurrentText(arti.type.value.name)
droprare = getattr(self, f"arti_{part}_rare")
droprare.setCurrentText(f"Star {arti.rare.value}")
droprare.setCurrentText(f"Star {arti.rare.value.name}")
droplevl = getattr(self, f"arti_{part}_levl")
droplevl.setCurrentText(arti.levl.value.name)

Expand Down
17 changes: 8 additions & 9 deletions gi_loadouts/face/wind/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from gi_loadouts.type.char import CharName
from gi_loadouts.type.char.cons import Cons
from gi_loadouts.type.levl import Level
from gi_loadouts.type.rare import Rare, __rarecolour__
from gi_loadouts.type.rare import Rare
from gi_loadouts.type.vson import Vision, __visioncolour__
from gi_loadouts.type.weap import WeaponStatType, WeaponType

Expand Down Expand Up @@ -96,7 +96,7 @@ def handle_char_data(self, _: int) -> None:
self.head_char_icon_subs.setToolTip(f"{char.seco.stat_name.value}")
self.head_char_data_subs.setText(f"{round(char.seco.stat_data, 1)}")
self.head_area_line_prim.setText(f"<b>{char.head}</b> - {char.cons_name}" + f" ({char.afln})" if char.afln != "" else f"<b>{char.head}</b> - {char.cons_name}")
self.head_area_line_seco.setText(f"<i>{char.name} is a {char.weapon.value.lower()}-wielding {char.vision.value if char.vision != Vision.none else ""} character of {char.rare.value}-star quality.</i>")
self.head_area_line_seco.setText(f"<i>{char.name} is a {char.weapon.value.lower()}-wielding {char.vision.value if char.vision != Vision.none else ""} character of {char.rare.value.qant}-star quality.</i>")
self.manage_changing_appearance(__visioncolour__[char.vision])

def format_weapon_by_char_change(self, _: int) -> None:
Expand Down Expand Up @@ -141,7 +141,7 @@ def convey_weapon_name_change(self, _: int) -> None:
weap = Family[kind][name]
self.weap_area_levl.addItems([item.value.name for item in weap.levl_bind])
self.weap_area_refn.addItems(item for item in weap.refinement.keys())
self.weap_port_area.setPixmap(QPixmap(__rarecolour__[weap.rare]))
self.weap_port_area.setPixmap(QPixmap(weap.rare.value.back))

def convey_weapon_levl_change(self, _: int) -> None:
"""
Expand Down Expand Up @@ -191,7 +191,7 @@ def change_rarity_backdrop_by_changing_type(self, droptype: QComboBox, droprare:
if droptype.currentText().strip() != "":
kind = getattr(ArtiList, droptype.currentText().replace(" ", "_").replace("'", "").replace("-", "_"))
droprare.clear()
droprare.addItems([f"Star {indx.value}" for indx in kind.value.rare])
droprare.addItems([indx.value.name for indx in kind.value.rare])
artiname.setText(truncate_text(getattr(kind.value, part).__name__, 30))
headicon.setPixmap(QPixmap(f":arti/imgs/arti/{kind.value.file}/{part}.webp"))
if droptype.currentText().strip() == "None":
Expand Down Expand Up @@ -219,7 +219,7 @@ def change_data_by_changing_level_or_stat(self, droplevl: QComboBox, droptype: Q
rare = getattr(Rare, droprare.currentText().replace(" ", "_"))
stat = getattr(arti, f"revmap_{part}")[dropstat.currentText()]
item = getattr(team.value, part)
item.levl, item.rare, item.stat_name = levl.value.levl, rare.value, stat
item.levl, item.rare, item.stat_name = levl.value.levl, rare.value.qant, stat
statdata.setText(f"{round(item.stat_data, 1)}")

def change_artifact_team_by_changing_type(self, droptype: QComboBox, part: str) -> None:
Expand Down Expand Up @@ -305,10 +305,10 @@ def change_artifact_substats_by_changing_rarity_or_mainstat(self, droprare: QCom
if droprare.currentText().strip() != "" and dropstat.currentText().strip() != "":
rare = getattr(Rare, droprare.currentText().replace(" ", "_"))
stat = dropstat.currentText().strip()
for indx in __artistat__[rare.value]["active"]:
for indx in __artistat__[rare.value.qant]["active"]:
getattr(self, f"arti_{part}_name_{indx}").clear()
getattr(self, f"arti_{part}_name_{indx}").addItems([item.value.value for item in SecoStatType if item.value.value != stat])
for alfa in __artistat__[rare.value]["inactive"]:
for alfa in __artistat__[rare.value.qant]["inactive"]:
getattr(self, f"arti_{part}_name_{alfa}").clear()
getattr(self, f"arti_{part}_name_{alfa}").addItems(["None"])

Expand All @@ -325,8 +325,7 @@ def change_levels_backdrop_by_changing_rarity(self, droplevl: QComboBox, backdro
rare = getattr(Rare, droprare.currentText().replace(" ", "_"))
droplevl.clear()
droplevl.addItems([item.value.name for item in ArtiLevl if rare in item.value.rare])
rare = getattr(Rare, droprare.currentText().replace(" ", "_"))
backdrop.setPixmap(QPixmap(__rarecolour__[rare]))
backdrop.setPixmap(QPixmap(rare.value.back))

def render_lineedit_readonly_when_none(self, dropstat: QComboBox, lineedit: QLineEdit) -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion gi_loadouts/type/file/arti.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def easydict(self) -> dict:
"name": self.name,
"type": self.type.value.name,
"area": self.area.value,
"rare": self.rare.value,
"rare": self.rare.value.qant,
"levl": self.levl.value.name,
"stat": {
"main": {
Expand Down
34 changes: 12 additions & 22 deletions gi_loadouts/type/rare/__init__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
from enum import Enum

__rare__ = {
"Star 0": 0,
"Star 1": 1,
"Star 2": 2,
"Star 3": 3,
"Star 4": 4,
"Star 5": 5,
}
from pydantic import BaseModel


Rare = Enum(
"Rare",
{
item.replace(" ", "_"): data for item, data in __rare__.items()
}
)
class RareType(BaseModel):
name: str = ""
qant: int = 0
back: str = ""


__rarecolour__ = {
Rare.Star_0: ":rare/imgs/rare/star_1.webp",
Rare.Star_1: ":rare/imgs/rare/star_1.webp",
Rare.Star_2: ":rare/imgs/rare/star_2.webp",
Rare.Star_3: ":rare/imgs/rare/star_3.webp",
Rare.Star_4: ":rare/imgs/rare/star_4.webp",
Rare.Star_5: ":rare/imgs/rare/star_5.webp",
}
class Rare(Enum):
Star_0 = RareType(name="Star 0", qant=0, back=":rare/imgs/rare/star_1.webp")
Star_1 = RareType(name="Star 1", qant=1, back=":rare/imgs/rare/star_1.webp")
Star_2 = RareType(name="Star 2", qant=2, back=":rare/imgs/rare/star_2.webp")
Star_3 = RareType(name="Star 3", qant=3, back=":rare/imgs/rare/star_3.webp")
Star_4 = RareType(name="Star 4", qant=4, back=":rare/imgs/rare/star_4.webp")
Star_5 = RareType(name="Star 5", qant=5, back=":rare/imgs/rare/star_5.webp")
2 changes: 1 addition & 1 deletion gi_loadouts/type/weap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def main_stat(self) -> WeaponStat:
:return: Statistics associated with the weapon
"""
base = self.tier.value["rare"][self.rare.value]
base = self.tier.value["rare"][self.rare.value.qant]

if self.rare in [Rare.Star_1, Rare.Star_2]:
mult = Mult[Rare.Star_3][self.levl.value.qant].data[self.tier]
Expand Down

0 comments on commit 555de71

Please sign in to comment.