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


class BackstagePassesItem(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 self.get_sell_in() > 10 and self.is_quality_valid_after_addition(1):
            self._quality += 1 
        elif self.get_sell_in() > 5 and self.is_quality_valid_after_addition(2):
            self._quality += 2
        elif self.get_sell_in() > 0 and self.is_quality_valid_after_addition(3):
            self._quality += 3
        elif self.is_item_sale_date_passed():
            self._quality = 0
        else:
            self._quality = MAX_QUALITY_DEFAULT_VALUE

        self._sell_in -= INCREMENTER_SELL_IN_VALUE
