Refactor pet action management: rename PetAction to PetBasicAction, update related properties and methods, and enhance pet stats with maximum values.
This commit is contained in:
@@ -14,7 +14,28 @@ namespace pet_companion_api.Models
|
||||
public string UserId { get; set; }
|
||||
public bool IsDead { get; set; }
|
||||
|
||||
public PetActionGather PetAction { get; set; }
|
||||
public DateTime ActionSince { get; set; }
|
||||
public PetActionGather PetGatherAction { get; set; }
|
||||
public DateTime GatherActionSince { get; set; }
|
||||
|
||||
public PetBasicAction PetBasicAction { get; set; }
|
||||
public DateTime BasicActionCooldown { get; set; }
|
||||
|
||||
public void IncrementIntelligence(int amount)
|
||||
{
|
||||
var newValue = Stats.Intelligence + amount;
|
||||
Stats.Intelligence = Math.Min(newValue, Stats.MaxIntelligence);
|
||||
}
|
||||
|
||||
public void IncrementStrength(int amount)
|
||||
{
|
||||
var newValue = Stats.Strength + amount;
|
||||
Stats.Strength = Math.Min(newValue, Stats.MaxStrength);
|
||||
}
|
||||
|
||||
public void IncrementCharisma(int amount)
|
||||
{
|
||||
var newValue = Stats.Charisma + amount;
|
||||
Stats.Charisma = Math.Min(newValue, Stats.MaxCharisma);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
namespace pet_companion_api.Models
|
||||
{
|
||||
public enum PetAction
|
||||
public enum PetBasicAction
|
||||
{
|
||||
UNKNOWN,
|
||||
FEED,
|
||||
|
@@ -11,6 +11,10 @@ namespace pet_companion_api.Models
|
||||
public int Strength { get; set; }
|
||||
public int Charisma { get; set; }
|
||||
|
||||
public int MaxIntelligence { get; set; }
|
||||
public int MaxStrength { get; set; }
|
||||
public int MaxCharisma { get; set; }
|
||||
|
||||
public static PetStats BuildFromClass(PetClass petClass)
|
||||
{
|
||||
var stats = new PetStats();
|
||||
@@ -59,6 +63,10 @@ namespace pet_companion_api.Models
|
||||
break;
|
||||
}
|
||||
|
||||
stats.MaxIntelligence = stats.Intelligence;
|
||||
stats.MaxStrength = stats.Strength;
|
||||
stats.MaxCharisma = stats.Charisma;
|
||||
|
||||
return stats;
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ namespace pet_companion_api.Models
|
||||
{
|
||||
public class PetUpdateActionRequest
|
||||
{
|
||||
public PetAction? Action { get; set; }
|
||||
public PetActionGather? PetActionGather { get; set; }
|
||||
public PetBasicAction? BasicAction { get; set; }
|
||||
public PetActionGather? GatherAction { get; set; }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user