Implement base controller for shared functionality; update existing controllers to inherit from BaseController and adjust user ID handling. Add JWT authentication support and modify item retrieval methods in GameDataController.

This commit is contained in:
2025-02-15 21:57:59 -03:00
parent 6d81ff1564
commit b84599b370
10 changed files with 72 additions and 31 deletions

View File

@@ -64,11 +64,11 @@ namespace PetCompanion.Services
var gathered = new List<ActionGathered>();
var baseRate = timeElapsed + pet.Level * 10; // Base rate per hour
var baseRate = (timeElapsed + pet.Level) / 10; // Base rate per hour
gathered.Add(new ActionGathered
{
Resource = "Junk",
Amount = (int)(baseRate * 2)
Amount = (int)(baseRate * 0.2)
});
var random = new Random();
@@ -79,28 +79,28 @@ namespace PetCompanion.Services
gathered.Add(new ActionGathered
{
Resource = "Wisdom",
Amount = (int)(baseRate * (pet.Stats.Intelligence * 2))
Amount = (int)(baseRate * (pet.Stats.Intelligence * 0.5))
});
break;
case PetActionGather.GATHERING_GOLD:
gathered.Add(new ActionGathered
{
Resource = "Gold",
Amount = (int)(baseRate * (pet.Stats.Charisma * 2))
Amount = (int)(baseRate * (pet.Stats.Charisma * 0.5))
});
break;
case PetActionGather.GATHERING_FOOD:
gathered.Add(new ActionGathered
{
Resource = "Food",
Amount = (int)(baseRate * (pet.Stats.Strength * 1.5))
Amount = (int)(baseRate * (pet.Stats.Strength * 0.5))
});
break;
case PetActionGather.EXPLORE:
gathered.Add(new ActionGathered
{
Resource = "Wisdom",
Amount = (int)(baseRate * (pet.Stats.Strength * 3))
Amount = (int)(baseRate * (pet.Stats.Strength * 0.25))
});
if (random.Next(0, 100) < 5)
@@ -122,7 +122,7 @@ namespace PetCompanion.Services
gathered.Add(new ActionGathered
{
Resource = "Gold",
Amount = (int)(baseRate * (pet.Stats.Strength * 3))
Amount = (int)(baseRate * (pet.Stats.Strength * 0.25))
});
if (random.Next(0, 100) < 10)
@@ -130,7 +130,7 @@ namespace PetCompanion.Services
pet.Health -= random.Next(5, 10);
}
if (random.Next(0, 100) < 500)
if (random.Next(0, 100) < 10)
{
gathered.Add(new ActionGathered
{

View File

@@ -29,18 +29,18 @@ namespace PetCompanion.Services
this.petActionService = petActionService;
}
public IEnumerable<Pet> GetAllPets(Guid userId)
public IEnumerable<Pet> GetAllPets(string userId)
{
return petRepository.GetPetsByUserId(userId.ToString());
return petRepository.GetPetsByUserId(userId);
}
public Pet CreatePet(Guid userId, PetCreationRequest petRequest)
public Pet CreatePet(string userId, PetCreationRequest petRequest)
{
var petId = Guid.NewGuid().ToString();
var pet = new Pet
{
Id = petId,
UserId = userId.ToString(),
UserId = userId,
Name = petRequest.Name,
Class = petRequest.Class,
Health = 100,