mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-12 22:24:34 +01:00
avatar skill impl...
i hate mongo C#
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Common.Resources.Proto;
|
||||
using Common.Utils.ExcelReader;
|
||||
using Newtonsoft.Json;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Driver;
|
||||
|
||||
@@ -11,7 +12,7 @@ namespace Common.Database
|
||||
|
||||
public static AvatarScheme[] AvatarsFromUid(uint uid)
|
||||
{
|
||||
return collection.AsQueryable().Where(collection=> collection.OwnerUid == uid).ToArray();
|
||||
return collection.AsQueryable().Where(collection => collection.OwnerUid == uid).ToArray();
|
||||
}
|
||||
|
||||
public static AvatarScheme Create(int avatarId, uint uid, EquipmentScheme equipment)
|
||||
@@ -40,7 +41,8 @@ namespace Common.Database
|
||||
SubStar = 0,
|
||||
TouchGoodfeel = 0,
|
||||
TodayHasAddGoodfeel = 0,
|
||||
WeaponUniqueId = weapon.UniqueId
|
||||
WeaponUniqueId = weapon.UniqueId,
|
||||
SkillLists = new()
|
||||
};
|
||||
|
||||
if(avatarData.AvatarId == 101)
|
||||
@@ -54,18 +56,25 @@ namespace Common.Database
|
||||
avatar.StigmataUniqueId3 = defaultStigmata3.UniqueId;
|
||||
}
|
||||
|
||||
avatar.SkillLists.AddRange(avatarData.SkillList.Select(skillId => new AvatarSkill { SkillId = (uint)skillId }));
|
||||
avatar.SkillLists.AddRange(avatarData.SkillList.Select(skillId => new AvatarScheme.AvatarSkill { SkillId = (uint)skillId }));
|
||||
|
||||
collection.InsertOne(avatar);
|
||||
|
||||
return avatar;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class AvatarScheme : Resources.Proto.Avatar
|
||||
{
|
||||
public class AvatarSkill : Resources.Proto.AvatarSkill
|
||||
{
|
||||
public new List<AvatarSubSkill> SubSkillLists { get; set; } = new();
|
||||
}
|
||||
|
||||
public ObjectId Id { get; set; }
|
||||
public uint OwnerUid { get; set; }
|
||||
public new List<AvatarSkill> SkillLists { get; set; } = new();
|
||||
|
||||
|
||||
public void Save()
|
||||
{
|
||||
@@ -80,5 +89,39 @@ namespace Common.Database
|
||||
|
||||
return levelData;
|
||||
}
|
||||
|
||||
public void LevelUpSkill(uint subSkillId, bool isLevelUpAll = false)
|
||||
{
|
||||
AvatarSubSkillDataExcel? subSkillData = AvatarSubSkillData.GetInstance().FromId((int)subSkillId);
|
||||
if (subSkillData is null)
|
||||
return;
|
||||
|
||||
AvatarSkill? avatarSkill = SkillLists.Where(skill => skill.SkillId == subSkillData.SkillId).FirstOrDefault();
|
||||
if(avatarSkill is not null)
|
||||
{
|
||||
AvatarSubSkill? avatarSubSkill = avatarSkill.SubSkillLists.FirstOrDefault(skill => skill.SubSkillId == subSkillData.AvatarSubSkillId);
|
||||
if (avatarSubSkill is not null)
|
||||
{
|
||||
if (isLevelUpAll)
|
||||
{
|
||||
avatarSubSkill.Level = (uint)subSkillData.MaxLv;
|
||||
}
|
||||
else
|
||||
{
|
||||
avatarSubSkill.Level++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
avatarSkill.SubSkillLists.Add(new() { SubSkillId = (uint)subSkillData.AvatarSubSkillId, Level = 1, IsMask = false });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AvatarSkill newAvatarSkill = new() { SkillId = (uint)subSkillData.SkillId };
|
||||
newAvatarSkill.SubSkillLists.Add(new() { SubSkillId = (uint)subSkillData.AvatarSubSkillId, Level = 1, IsMask = false });
|
||||
SkillLists.Add(newAvatarSkill);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
141
Common/Utils/ExcelReader/AvatarSubSkillData.cs
Normal file
141
Common/Utils/ExcelReader/AvatarSubSkillData.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Common.Utils.ExcelReader
|
||||
{
|
||||
public class AvatarSubSkillData : BaseExcelReader<AvatarSubSkillData, AvatarSubSkillDataExcel>
|
||||
{
|
||||
public override string FileName { get { return "AvatarSubSkillData.json"; } }
|
||||
|
||||
public AvatarSubSkillDataExcel? FromId(int id)
|
||||
{
|
||||
return All.Where(subSkill => subSkill.AvatarSubSkillId == id).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
public partial class AvatarSubSkillDataExcel
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public HashName Name { get; set; }
|
||||
|
||||
[JsonProperty("info")]
|
||||
public HashName Info { get; set; }
|
||||
|
||||
[JsonProperty("brief")]
|
||||
public HashName Brief { get; set; }
|
||||
|
||||
[JsonProperty("showOrder")]
|
||||
public int ShowOrder { get; set; }
|
||||
|
||||
[JsonProperty("skillId")]
|
||||
public int SkillId { get; set; }
|
||||
|
||||
[JsonProperty("ignoreLeader")]
|
||||
public bool IgnoreLeader { get; set; }
|
||||
|
||||
[JsonProperty("iconPath")]
|
||||
public string IconPath { get; set; }
|
||||
|
||||
[JsonProperty("unlockStar")]
|
||||
public int UnlockStar { get; set; }
|
||||
|
||||
[JsonProperty("unlockSubStar")]
|
||||
public int UnlockSubStar { get; set; }
|
||||
|
||||
[JsonProperty("unlockLv")]
|
||||
public int UnlockLv { get; set; }
|
||||
|
||||
[JsonProperty("unlockLvAdd")]
|
||||
public int UnlockLvAdd { get; set; }
|
||||
|
||||
[JsonProperty("maxLv")]
|
||||
public int MaxLv { get; set; }
|
||||
|
||||
[JsonProperty("upLevelSubStarNeedList")]
|
||||
public UpLevelSubStarNeedList[] UpLevelSubStarNeedList { get; set; }
|
||||
|
||||
[JsonProperty("scoinCalc")]
|
||||
public bool ScoinCalc { get; set; }
|
||||
|
||||
[JsonProperty("unlockScoin")]
|
||||
public int UnlockScoin { get; set; }
|
||||
|
||||
[JsonProperty("scoinLvAdd")]
|
||||
public int ScoinLvAdd { get; set; }
|
||||
|
||||
[JsonProperty("itemType")]
|
||||
public int ItemType { get; set; }
|
||||
|
||||
[JsonProperty("skillToggle")]
|
||||
public bool SkillToggle { get; set; }
|
||||
|
||||
[JsonProperty("paramBase_1")]
|
||||
public double ParamBase1 { get; set; }
|
||||
|
||||
[JsonProperty("paramAdd_1")]
|
||||
public double ParamAdd1 { get; set; }
|
||||
|
||||
[JsonProperty("paramBase_2")]
|
||||
public double ParamBase2 { get; set; }
|
||||
|
||||
[JsonProperty("paramAdd_2")]
|
||||
public double ParamAdd2 { get; set; }
|
||||
|
||||
[JsonProperty("paramBase_3")]
|
||||
public double ParamBase3 { get; set; }
|
||||
|
||||
[JsonProperty("paramAdd_3")]
|
||||
public double ParamAdd3 { get; set; }
|
||||
|
||||
[JsonProperty("canTry")]
|
||||
public bool CanTry { get; set; }
|
||||
|
||||
[JsonProperty("ArtifactSkillID")]
|
||||
public int ArtifactSkillId { get; set; }
|
||||
|
||||
[JsonProperty("UpLevelArtifactNeedList")]
|
||||
public UpLevelArtifactNeedList[] UpLevelArtifactNeedList { get; set; }
|
||||
|
||||
[JsonProperty("TagList")]
|
||||
public TagList[] TagList { get; set; }
|
||||
|
||||
[JsonProperty("DataImpl")]
|
||||
public object DataImpl { get; set; }
|
||||
|
||||
[JsonProperty("avatarSubSkillId")]
|
||||
public int AvatarSubSkillId { get; set; }
|
||||
}
|
||||
|
||||
public partial class TagList
|
||||
{
|
||||
[JsonProperty("Strength")]
|
||||
public int Strength { get; set; }
|
||||
|
||||
[JsonProperty("TagID")]
|
||||
public int TagId { get; set; }
|
||||
|
||||
[JsonProperty("TagComment")]
|
||||
public HashName TagComment { get; set; }
|
||||
}
|
||||
|
||||
public partial class UpLevelArtifactNeedList
|
||||
{
|
||||
[JsonProperty("ArtifactLevel")]
|
||||
public int ArtifactLevel { get; set; }
|
||||
|
||||
[JsonProperty("SubSkillLevel")]
|
||||
public int SubSkillLevel { get; set; }
|
||||
}
|
||||
|
||||
public partial class UpLevelSubStarNeedList
|
||||
{
|
||||
[JsonProperty("level")]
|
||||
public int Level { get; set; }
|
||||
|
||||
[JsonProperty("starNeed")]
|
||||
public int StarNeed { get; set; }
|
||||
|
||||
[JsonProperty("subStarNeed")]
|
||||
public int SubStarNeed { get; set; }
|
||||
}
|
||||
}
|
||||
39
Common/Utils/ExcelReader/AvatarSubSkillLevelData.cs
Normal file
39
Common/Utils/ExcelReader/AvatarSubSkillLevelData.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Common.Utils.ExcelReader
|
||||
{
|
||||
internal class AvatarSubSkillLevelData : BaseExcelReader<AvatarSubSkillLevelData, AvatarSubSkillLevelDataExcel>
|
||||
{
|
||||
public override string FileName { get { return "AvatarSubSkillLevelDataV2.json"; } }
|
||||
|
||||
public List<AvatarSubSkillLevelDataExcel> FromType(int type)
|
||||
{
|
||||
return All.Where(d => d.ItemType == type).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
public partial class AvatarSubSkillLevelDataExcel
|
||||
{
|
||||
[JsonProperty("ItemList_1")]
|
||||
public AvatarSubSkillLevelItemList[] ItemList1 { get; set; }
|
||||
|
||||
[JsonProperty("DataImpl")]
|
||||
public object DataImpl { get; set; }
|
||||
|
||||
[JsonProperty("ItemType")]
|
||||
public int ItemType { get; set; }
|
||||
|
||||
[JsonProperty("SkillLevel")]
|
||||
public int SkillLevel { get; set; }
|
||||
}
|
||||
|
||||
public partial class AvatarSubSkillLevelItemList
|
||||
{
|
||||
[JsonProperty("itemMetaID")]
|
||||
public int ItemMetaId { get; set; }
|
||||
|
||||
[JsonProperty("itemNum")]
|
||||
public int ItemNum { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user