from src.items.helpers.constants import INCREMENTER_SELL_IN_VALUE
from src.items.base import Item


class ConjuredItem(Item):

    def __init__(self, name: str, sell_in: int, quality: int):
        super().__init__(name, sell_in, quality)
        self.is_valid_quality(self.get_quality())

    def update_quality(self):
        if not self.is_item_sale_date_passed() and self.is_quality_valid_after_subtraction(2):
            self._quality -= 2
        elif self.is_item_sale_date_passed() and self.is_quality_valid_after_subtraction(4):
            self._quality -= 4
        else:
            self._quality = 0
        self._sell_in -= INCREMENTER_SELL_IN_VALUE
