inventory working :D
This commit is contained in:
@@ -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--;
|
||||
|
||||
Reference in New Issue
Block a user