axheron / ffxiv-dps-calc

A Final Fantasy XIV DPS simulator for comparing gear sets
https://dpscalc.xivresources.com
GNU Affero General Public License v3.0
2 stars 4 forks source link

stop abusing enums #55

Open ackao opened 3 years ago

ackao commented 3 years ago
    # Class variable to convert stats
    crit_convert: ClassVar[dict[Stats, tuple[int, int]]] = {
        Stats.CRIT: (200, 50),
        Stats.DH: (550, 0),
    }

replace with:

WhateverType = tuple[int, int]
StatWhateverMapping = dict[Stats, WhateverType]
# later

crit_convert: ClassVar[StatWhateverMapping] = {

and similar

also consider typing.IntEnum (example: https://github.com/xivlogs/nari/blob/9f3169a7112654a8ab25ae390374983a0750f32d/nari/types/event/directorupdate.py#L14)

ackao commented 3 years ago

also maybe actually write __repr__() for enums lmao

ackao commented 3 years ago

suggestion:

PercentageBuff = float
DurationSecs = int
Cooldown = int
AppropriateName = Tuple[PercentageBuff, DurationSecs, Cooldown]

...
class Buffs(Enum):
  # aoe
  Chain: AppropriateName = (0.1, 15, 120)
joooooooooe-star commented 3 years ago

i used

    # Class variable to convert stats
    P_scalars = tuple[int, int]  # for less ugly

    CRIT_CONVERT: ClassVar[dict[Stats, P_scalars]] = {
        Stats.CRIT: (200, 50),
        Stats.DH: (550, 0),
    }

but i dunno

redshadowhero commented 3 years ago

It might be nice to do a util/types.py to locate types into if they're generally useful (like things like PScalars). Might also help to document what the types represent there just because it would be useful for those that are not math- or statistics-inclined but want to help.