public function updateAchievementCriterias($owner, string $type, $data = null): int
    {
        $criterias = $this->storage->getOwnerCriteriasByType($owner, $type, $data);

        if (!count($criterias)) {
            return 0;
        }

        $this->achievementsToCheck = [];

        $achievements = $this->storage->getAchievementsByCriterias($criterias);
        $updatedCriteriasCount = 0;

        foreach ($criterias as $criteria) {
            /** @var AchievementCriteria $criteria*/

            if ($criteria->completed()) {
                continue;
            }

            $achievement = $this->storage->getAchievementForCriteria($criteria, $achievements);

            if (is_null($achievement)) {
                continue;
            }

            $change = $this->getCriteriaChange($owner, $criteria, $achievement, $data);

            if (is_null($change)) {
                continue;
            }

            $this->setCriteriaProgress($owner, $criteria, $achievement, $change);
            $updatedCriteriasCount++;
        }

        if (count($this->achievementsToCheck) > 0) {
            $this->checkCompletedAchievements($owner);
        }

        return $updatedCriteriasCount;
    }