69 lines
2.3 KiB
C#
69 lines
2.3 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace PetCompanion.Models
|
|
{
|
|
public class Pet
|
|
{
|
|
[Key]
|
|
public string Id { get; set; }
|
|
public string Name { get; set; }
|
|
public PetClass Class { get; set; }
|
|
public PetStats Stats { get; set; }
|
|
public Resources Resources { get; set; }
|
|
public int Level { get; set; }
|
|
public int Experience { get; set; }
|
|
public int Health { get; set; }
|
|
public int MaxHealth { get; set; }
|
|
public string UserId { get; set; }
|
|
public bool IsDead { get; set; }
|
|
|
|
public PetActionGather PetGatherAction { get; set; }
|
|
public DateTime GatherActionSince { get; set; }
|
|
|
|
public PetBasicAction PetBasicAction { get; set; }
|
|
public DateTime BasicActionCooldown { get; set; }
|
|
|
|
public int SkillPoints { get; set; } = 2;
|
|
|
|
public virtual ICollection<PetSkill> Skills { get; set; } = new List<PetSkill>();
|
|
public virtual Inventory Inventory { get; set; }
|
|
public virtual ICollection<EquippedItem> EquippedItemsList { get; set; } = new List<EquippedItem>();
|
|
|
|
[NotMapped]
|
|
public Dictionary<ItemEquipTarget, int> EquippedItems
|
|
{
|
|
get => EquippedItemsList?.ToDictionary(e => e.EquipTarget, e => e.GameItemId) ?? new Dictionary<ItemEquipTarget, int>();
|
|
set
|
|
{
|
|
EquippedItemsList = value.Select(kvp => new EquippedItem
|
|
{
|
|
PetId = Id,
|
|
EquipTarget = kvp.Key,
|
|
GameItemId = kvp.Value
|
|
}).ToList();
|
|
}
|
|
}
|
|
|
|
public Pet() { }
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|