inventory working :D

This commit is contained in:
2025-02-05 19:38:25 -03:00
parent 7a2c3d2f67
commit 5289910270
15 changed files with 174 additions and 468 deletions

View File

@@ -14,16 +14,16 @@ namespace PetCompanion.Services
_petRepository = petRepository;
}
public async Task<IEnumerable<PetSkill>> GetPetSkills(string petId, string userId)
public IEnumerable<PetSkill> GetPetSkills(string petId, string userId)
{
var pet = _petRepository.GetPetById(petId, userId);
if (pet == null)
throw new Exception("Pet not found");
return await _petSkillRepository.GetPetSkills(petId);
return _petSkillRepository.GetPetSkills(petId);
}
public async Task<PetSkill> AllocateSkillPoint(string petId, string userId, int skillId)
public PetSkill AllocateSkillPoint(string petId, string userId, int skillId)
{
var pet = _petRepository.GetPetById(petId, userId);
if (pet == null)
@@ -32,7 +32,7 @@ namespace PetCompanion.Services
if (pet.SkillPoints <= 0)
throw new Exception("No skill points available");
var skills = await _petSkillRepository.GetPetSkills(petId);
var skills = _petSkillRepository.GetPetSkills(petId);
var existingSkill = skills.FirstOrDefault(s => s.SkillId == skillId);
if (existingSkill != null)
@@ -41,7 +41,7 @@ namespace PetCompanion.Services
throw new Exception("Skill already at maximum tier");
existingSkill.CurrentTier++;
await _petSkillRepository.SavePetSkill(existingSkill);
_petSkillRepository.SavePetSkill(existingSkill);
}
else
{
@@ -51,7 +51,7 @@ namespace PetCompanion.Services
SkillId = skillId,
CurrentTier = SkillTier.I
};
await _petSkillRepository.SavePetSkill(existingSkill);
_petSkillRepository.SavePetSkill(existingSkill);
}
pet.SkillPoints--;