mirror of
https://git.lewd.wtf/PGR/ascnet
synced 2025-12-13 17:44:38 +01:00
upgrade skill (not throughly tested because the lack of other implementation)
This commit is contained in:
@@ -4,6 +4,7 @@ using MongoDB.Driver;
|
||||
using AscNet.Table.share.character;
|
||||
using AscNet.Table.share.character.skill;
|
||||
using AscNet.Common.MsgPack;
|
||||
using AscNet.Common.Util;
|
||||
|
||||
namespace AscNet.Common.Database
|
||||
{
|
||||
@@ -83,6 +84,41 @@ namespace AscNet.Common.Database
|
||||
Characters.Add(characterData);
|
||||
}
|
||||
|
||||
public UpgradeCharacterResult UpgradeCharacterSkillGroup(uint skillGroupId, int count)
|
||||
{
|
||||
List<uint> affectedCharacters = new();
|
||||
int totalCoinCost = 0;
|
||||
int totalSkillPointCost = 0;
|
||||
IEnumerable<int> affectedSkills = CharacterSkillGroupTableReader.Instance.All.Where(x => x.Id == skillGroupId).SelectMany(x => x.SkillId);
|
||||
|
||||
foreach (var skillId in affectedSkills)
|
||||
{
|
||||
foreach (var character in Characters.Where(x => x.SkillList.Any(x => x.Id == skillId)))
|
||||
{
|
||||
var characterSkill = character.SkillList.First(x => x.Id == skillId);
|
||||
int targetLevel = characterSkill.Level + count;
|
||||
|
||||
while (characterSkill.Level < targetLevel)
|
||||
{
|
||||
var skillUpgrade = CharacterSkillUpgradeTableReader.Instance.All.FirstOrDefault(x => x.SkillId == skillId && Miscs.ParseIntOr(x.Level) == characterSkill.Level);
|
||||
|
||||
totalCoinCost += Miscs.ParseIntOr(skillUpgrade?.UseCoin);
|
||||
totalSkillPointCost += Miscs.ParseIntOr(skillUpgrade?.UseSkillPoint);
|
||||
|
||||
characterSkill.Level++;
|
||||
}
|
||||
affectedCharacters.Add(character.Id);
|
||||
}
|
||||
}
|
||||
|
||||
return new UpgradeCharacterResult()
|
||||
{
|
||||
AffectedCharacters = affectedCharacters,
|
||||
CoinCost = totalCoinCost,
|
||||
SkillPointCost = totalSkillPointCost
|
||||
};
|
||||
}
|
||||
|
||||
public void AddEquip(uint equipId, int characterId = 0)
|
||||
{
|
||||
NotifyEquipDataList.NotifyEquipDataListEquipData equipData = new()
|
||||
@@ -128,4 +164,11 @@ namespace AscNet.Common.Database
|
||||
[BsonRequired]
|
||||
public List<FashionList> Fashions { get; set; }
|
||||
}
|
||||
|
||||
public struct UpgradeCharacterResult
|
||||
{
|
||||
public int CoinCost { get; init; }
|
||||
public int SkillPointCost { get; init; }
|
||||
public List<uint> AffectedCharacters { get; init; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,34 @@ namespace AscNet.Common.Database
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
public class Inventory
|
||||
{
|
||||
#region CommonItems
|
||||
public const int Coin = 1;
|
||||
public const int PaidGem = 2;
|
||||
public const int FreeGem = 3;
|
||||
public const int ActionPoint = 4;
|
||||
public const int HongKa = 5;
|
||||
public const int TeamExp = 7;
|
||||
public const int AndroidHongKa = 8;
|
||||
public const int IosHongKa = 10;
|
||||
public const int SkillPoint = 12;
|
||||
public const int DailyActiveness = 13;
|
||||
public const int WeeklyActiveness = 14;
|
||||
public const int HostelElectric = 15;
|
||||
public const int HostelMat = 16;
|
||||
public const int OnlineBossTicket = 17;
|
||||
public const int BountyTaskExp = 18;
|
||||
public const int DormCoin = 30;
|
||||
public const int FurnitureCoin = 31;
|
||||
public const int DormEnterIcon = 36;
|
||||
public const int BaseEquipCoin = 300;
|
||||
public const int InfestorActionPoint = 50;
|
||||
public const int InfestorMoney = 51;
|
||||
public const int PokemonLevelUpItem = 56;
|
||||
public const int PokemonStarUpItem = 57;
|
||||
public const int PokemonLowStarUpItem = 58;
|
||||
public const int PassportExp = 60;
|
||||
#endregion
|
||||
|
||||
public static readonly IMongoCollection<Inventory> collection = Common.db.GetCollection<Inventory>("inventory");
|
||||
|
||||
public static Inventory FromUid(long uid)
|
||||
@@ -41,6 +69,26 @@ namespace AscNet.Common.Database
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public void Do(int itemId, int amount)
|
||||
{
|
||||
Item? item = Items.FirstOrDefault(x => x.Id == itemId);
|
||||
if (item is not null)
|
||||
{
|
||||
item.Count += amount;
|
||||
item.RefreshTime = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
}
|
||||
else
|
||||
{
|
||||
Items.Add(new Item()
|
||||
{
|
||||
Id = itemId,
|
||||
Count = amount,
|
||||
RefreshTime = DateTimeOffset.Now.ToUnixTimeSeconds(),
|
||||
CreateTime = DateTimeOffset.Now.ToUnixTimeSeconds()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
collection.ReplaceOne(Builders<Inventory>.Filter.Eq(x => x.Id, Id), this);
|
||||
|
||||
Reference in New Issue
Block a user