Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
improvement(Artifact): max_level property
Browse files Browse the repository at this point in the history
  • Loading branch information
trumully committed Apr 16, 2024
1 parent 8edaa65 commit efd100d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/artipy/artifacts/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from typing import Optional

from artipy import UPGRADE_STEP
from artipy.stats import MainStat, StatType, SubStat

from .upgrade_strategy import AddStatStrategy, UpgradeStatStrategy, UpgradeStrategy
Expand Down Expand Up @@ -150,13 +151,21 @@ def get_strategy(self) -> UpgradeStrategy:
:return: The upgrade strategy for the artifact.
:rtype: UpgradeStrategy
"""
if self.get_rarity() == 1:
return UpgradeStrategy()
if len(self.get_substats()) < self.get_rarity() - 1:
return AddStatStrategy()
return UpgradeStatStrategy()

@property
def max_level(self) -> int:
rarity = self.get_rarity()
return rarity * UPGRADE_STEP if rarity > 2 else UPGRADE_STEP

def upgrade(self) -> None:
"""Upgrade the artifact."""
self.get_strategy().upgrade(self)
if self.get_level() < self.max_level:
self.get_strategy().upgrade(self)

def __str__(self) -> str:
# Black can't format f-strings with double quotes in them
Expand Down

0 comments on commit efd100d

Please sign in to comment.