mirror of
https://git.lewd.wtf/PGR/ascnet
synced 2025-12-13 06:34:38 +01:00
DB for starting tutorial
This commit is contained in:
@@ -12,6 +12,8 @@ namespace AscNet.Common.Database
|
||||
{
|
||||
public static readonly IMongoCollection<Character> collection = Common.db.GetCollection<Character>("characters");
|
||||
|
||||
private uint NextEquipId => Equips.MaxBy(x => x.Id)?.Id + 1 ?? 1;
|
||||
|
||||
public static Character FromUid(long uid)
|
||||
{
|
||||
return collection.AsQueryable().FirstOrDefault(x => x.Uid == uid) ?? Create(uid);
|
||||
@@ -22,7 +24,9 @@ namespace AscNet.Common.Database
|
||||
Character character = new()
|
||||
{
|
||||
Uid = uid,
|
||||
Characters = new()
|
||||
Characters = new(),
|
||||
Equips = new(),
|
||||
Fashions = new()
|
||||
};
|
||||
// Lucia havers by default
|
||||
character.AddCharacter(1021001);
|
||||
@@ -36,8 +40,12 @@ namespace AscNet.Common.Database
|
||||
{
|
||||
CharacterTable? character = CharacterTableReader.Instance.FromId((int)id);
|
||||
CharacterSkillTable? characterSkill = CharacterSkillTableReader.Instance.FromCharacterId((int)id);
|
||||
|
||||
if (character is null || characterSkill is null)
|
||||
throw new ArgumentException("Invlid character id!", nameof(id));
|
||||
throw new ArgumentException("Invalid character id!", nameof(id));
|
||||
if (Characters.FirstOrDefault(x => x.Id == character.Id) is not null)
|
||||
throw new ArgumentException("Character already obtained!", nameof(id));
|
||||
|
||||
NotifyCharacterDataList.NotifyCharacterDataListCharacterData characterData = new()
|
||||
{
|
||||
Id = (uint)character.Id,
|
||||
@@ -64,10 +72,38 @@ namespace AscNet.Common.Database
|
||||
Id = uint.Parse(x.ToString().Take(6).ToArray()),
|
||||
Level = 1
|
||||
}));
|
||||
Fashions.Add(new()
|
||||
{
|
||||
Id = character.DefaultNpcFashtionId,
|
||||
IsLock = false
|
||||
});
|
||||
if (character.EquipId > 0)
|
||||
AddEquip((uint)character.EquipId, character.Id);
|
||||
|
||||
Characters.Add(characterData);
|
||||
}
|
||||
|
||||
public void AddEquip(uint equipId, int characterId = 0)
|
||||
{
|
||||
NotifyEquipDataList.NotifyEquipDataListEquipData equipData = new()
|
||||
{
|
||||
Id = NextEquipId,
|
||||
TemplateId = equipId,
|
||||
CharacterId = characterId,
|
||||
Level = 1,
|
||||
Exp = 0,
|
||||
Breakthrough = 0,
|
||||
ResonanceInfo = new(),
|
||||
UnconfirmedResonanceInfo = new(),
|
||||
AwakeSlotList = new(),
|
||||
IsLock = false,
|
||||
CreateTime = (uint)DateTimeOffset.Now.ToUnixTimeSeconds(),
|
||||
IsRecycle = false
|
||||
};
|
||||
|
||||
Equips.Add(equipData);
|
||||
}
|
||||
|
||||
[BsonId]
|
||||
public ObjectId Id { get; set; }
|
||||
|
||||
@@ -75,8 +111,16 @@ namespace AscNet.Common.Database
|
||||
[BsonRequired]
|
||||
public long Uid { get; set; }
|
||||
|
||||
[BsonElement("uid")]
|
||||
[BsonElement("characters")]
|
||||
[BsonRequired]
|
||||
public List<NotifyCharacterDataList.NotifyCharacterDataListCharacterData> Characters { get; set; }
|
||||
|
||||
[BsonElement("equips")]
|
||||
[BsonRequired]
|
||||
public List<NotifyEquipDataList.NotifyEquipDataListEquipData> Equips { get; set; }
|
||||
|
||||
[BsonElement("fashions")]
|
||||
[BsonRequired]
|
||||
public List<FashionList> Fashions { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user