mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-27 07:59:03 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json;
|
||||
using RadicadeServer.Extensions;
|
||||
using RadicadeServer.RecNet.Avatar;
|
||||
|
||||
namespace RadicadeServer.RecNet.Accounts
|
||||
{
|
||||
public class PlayerUnlocks
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public long AccountId { get; set; }
|
||||
|
||||
public string AvatarItems { get; set; } = DBConfig.DefaultAvatarUnlocks;
|
||||
public string Consumables { get; set; } = DBConfig.DefaultConsumableUnlocks;
|
||||
public string Equipment { get; set; } = DBConfig.DefaultEquipmentUnlocks;
|
||||
|
||||
public string Inventions { get; set; } = "[]";
|
||||
public string RoomKeys { get; set; } = "[]";
|
||||
|
||||
public List<AvatarItem> GetAvatarItems()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(this.AvatarItems) || this.AvatarItems == "null")
|
||||
return new List<AvatarItem>();
|
||||
return JsonSerializer.Deserialize<List<AvatarItem>>(this.AvatarItems) ?? new List<AvatarItem>();
|
||||
}
|
||||
public void AddAvatarItem(AvatarItem avatarItem)
|
||||
{
|
||||
var items = GetAvatarItems();
|
||||
items.Add(avatarItem);
|
||||
this.AvatarItems = items.ToJson();
|
||||
}
|
||||
|
||||
public List<Equipment> GetEquipment()
|
||||
{
|
||||
return JsonSerializer.Deserialize<List<Equipment>>(this.Equipment) ?? new List<Equipment>();
|
||||
}
|
||||
public void AddEquipment(Equipment equipment)
|
||||
{
|
||||
var items = GetEquipment();
|
||||
items.Add(equipment);
|
||||
this.Equipment = items.ToJson();
|
||||
}
|
||||
|
||||
public List<Consumable> GetConsumables()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(this.Consumables) || this.Consumables == "null")
|
||||
return new List<Consumable>();
|
||||
return JsonSerializer.Deserialize<List<Consumable>>(this.Consumables) ?? new List<Consumable>();
|
||||
}
|
||||
public void AddConsumable(Consumable consumable)
|
||||
{
|
||||
var consumables = GetConsumables();
|
||||
consumables.Add(consumable);
|
||||
this.Consumables = JsonSerializer.Serialize(consumables);
|
||||
}
|
||||
public void SetConsumables(List<Consumable> consumables)
|
||||
{
|
||||
this.Consumables = JsonSerializer.Serialize(consumables ?? new List<Consumable>());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user