Compare commits

..

6 Commits

Author SHA1 Message Date
Kei-Luna
3bc30812aa Added a warning against scam. Die, scammers! 2026-05-18 07:32:25 +09:00
Kei-Luna
f8f7311997 SupporterCard Affix can now be changed. 2026-05-16 16:20:17 +09:00
Kei-Luna
e628a010be Update version.txt 2026-05-15 16:45:00 +09:00
Kei-Luna
738a7d4e14 Improved the system so that affixes are correctly applied when obtaining support cards using the give command. 2026-05-15 16:17:36 +09:00
Kei-Luna
0058ba0db6 Support Card Affix 2026-05-15 16:07:36 +09:00
Kei-Luna
46d945f3ce Fix SupporterCard_Upgrade 2026-05-15 15:11:53 +09:00
22 changed files with 708 additions and 20 deletions

View File

@@ -0,0 +1,27 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace MikuSB.Data.Excel;
[ResourceEntity("item/support/affix.json")]
public class SupportAffixExcel : ExcelResource
{
[JsonProperty("ID")] public int Id { get; set; }
[JsonExtensionData] public IDictionary<string, JToken> ExtraData { get; set; } = new Dictionary<string, JToken>();
public int TierCount =>
ExtraData
.Where(x => x.Key != "ID" && x.Key != "Sift" && x.Key != "Comment")
.Select(x => x.Value)
.OfType<JObject>()
.Select(x => x.Count)
.DefaultIfEmpty(0)
.Max();
public override uint GetId() => (uint)Id;
public override void Loaded()
{
GameData.SupportAffixData[Id] = this;
}
}

View File

@@ -0,0 +1,35 @@
using Newtonsoft.Json;
namespace MikuSB.Data.Excel;
[ResourceEntity("item/support/affix_pool.json")]
public class SupportAffixPoolExcel : ExcelResource
{
[JsonProperty("ID")] public int Id { get; set; }
public List<int> AffixGroup1 { get; set; } = [];
public int Weight1 { get; set; }
public List<int> AffixGroup2 { get; set; } = [];
public int Weight2 { get; set; }
public List<int> AffixGroup3 { get; set; } = [];
public int Weight3 { get; set; }
public List<int> AffixGroup4 { get; set; } = [];
public int Weight4 { get; set; }
public IEnumerable<(IReadOnlyList<int> Affixs, int Weight)> Groups
{
get
{
if (AffixGroup1.Count > 0 && Weight1 > 0) yield return (AffixGroup1, Weight1);
if (AffixGroup2.Count > 0 && Weight2 > 0) yield return (AffixGroup2, Weight2);
if (AffixGroup3.Count > 0 && Weight3 > 0) yield return (AffixGroup3, Weight3);
if (AffixGroup4.Count > 0 && Weight4 > 0) yield return (AffixGroup4, Weight4);
}
}
public override uint GetId() => (uint)Id;
public override void Loaded()
{
GameData.SupportAffixPoolData[Id] = this;
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
@@ -11,7 +12,12 @@ public class SupportCardExcel : ExcelResource
public uint Level { get; set; } public uint Level { get; set; }
public uint Icon { get; set; } public uint Icon { get; set; }
public uint ProvideExp { get; set; } public uint ProvideExp { get; set; }
public uint Color { get; set; }
[JsonProperty("LevelLimitID")] public int LevelLimitId { get; set; } [JsonProperty("LevelLimitID")] public int LevelLimitId { get; set; }
[JsonProperty("AffixPool")] public List<int> AffixPool { get; set; } = [];
[JsonProperty("AffixCost")] public JToken? AffixCostRaw { get; set; }
[JsonProperty("InitialAffixCost")] public JToken? InitialAffixCostRaw { get; set; }
[JsonProperty("FixedAffixCost")] public JToken? FixedAffixCostRaw { get; set; }
public uint MaxLevel => LevelLimitId switch public uint MaxLevel => LevelLimitId switch
{ {
@@ -21,6 +27,19 @@ public class SupportCardExcel : ExcelResource
_ => 10 _ => 10
}; };
public int InitialAffixCount => Color >= 5 ? 2 : 1;
public int TotalAffixCount => Color >= 5 ? 3 : 2;
[JsonIgnore]
public IReadOnlyList<uint> AffixCost => ParseFlatCost(AffixCostRaw);
[JsonIgnore]
public IReadOnlyList<IReadOnlyList<uint>> InitialAffixCost => ParseNestedCost(InitialAffixCostRaw);
[JsonIgnore]
public IReadOnlyList<uint> FixedAffixCost => ParseFlatCost(FixedAffixCostRaw);
public ulong TemplateId => GameResourceTemplateId.FromGdpl(Genre, Detail, Particular, Level); public ulong TemplateId => GameResourceTemplateId.FromGdpl(Genre, Detail, Particular, Level);
public override uint GetId() => Icon; public override uint GetId() => Icon;
@@ -29,4 +48,23 @@ public class SupportCardExcel : ExcelResource
{ {
GameData.SupportCardData.Add(this); GameData.SupportCardData.Add(this);
} }
private static IReadOnlyList<uint> ParseFlatCost(JToken? token)
{
if (token is not JArray array)
return [];
return array.Select(x => x.Value<uint>()).ToArray();
}
private static IReadOnlyList<IReadOnlyList<uint>> ParseNestedCost(JToken? token)
{
if (token is not JArray outer)
return [];
var result = new List<IReadOnlyList<uint>>();
foreach (var entry in outer.OfType<JArray>())
result.Add(entry.Select(x => x.Value<uint>()).ToArray());
return result;
}
} }

View File

@@ -0,0 +1,18 @@
using Newtonsoft.Json;
namespace MikuSB.Data.Excel;
[ResourceEntity("item/support/fixed.json")]
public class SupportFixedExcel : ExcelResource
{
[JsonProperty("ID")] public int Id { get; set; }
public int Num { get; set; }
public List<uint> Item { get; set; } = [];
public override uint GetId() => (uint)Id;
public override void Loaded()
{
GameData.SupportFixedData[Id] = this;
}
}

View File

@@ -23,6 +23,9 @@ public static class GameData
public static Dictionary<uint, SpineExcel> SpineData { get; private set; } = []; public static Dictionary<uint, SpineExcel> SpineData { get; private set; } = [];
public static Dictionary<uint, NodeConditionExcel> NodeConditionData { get; private set; } = []; public static Dictionary<uint, NodeConditionExcel> NodeConditionData { get; private set; } = [];
public static List<SupportCardExcel> SupportCardData { get; private set; } = []; public static List<SupportCardExcel> SupportCardData { get; private set; } = [];
public static Dictionary<int, SupportAffixExcel> SupportAffixData { get; private set; } = [];
public static Dictionary<int, SupportAffixPoolExcel> SupportAffixPoolData { get; private set; } = [];
public static Dictionary<int, SupportFixedExcel> SupportFixedData { get; private set; } = [];
public static Dictionary<uint, WeaponSkinExcel> WeaponSkinData { get; private set; } = []; public static Dictionary<uint, WeaponSkinExcel> WeaponSkinData { get; private set; } = [];
public static Dictionary<uint, DailyLevelExcel> DailyLevelData { get; private set; } = []; public static Dictionary<uint, DailyLevelExcel> DailyLevelData { get; private set; } = [];
public static Dictionary<uint, ProfileExcel> ProfileData { get; private set; } = []; public static Dictionary<uint, ProfileExcel> ProfileData { get; private set; } = [];

View File

@@ -1,4 +1,4 @@
using MikuSB.Enums.Item; using MikuSB.Enums.Item;
using MikuSB.Proto; using MikuSB.Proto;
using SqlSugar; using SqlSugar;
@@ -10,19 +10,19 @@ public class InventoryData : BaseDatabaseDataHelper
public uint NextUniqueUid { get; set; } = 100000; public uint NextUniqueUid { get; set; } = 100000;
[SugarColumn(IsJson = true)] [SugarColumn(IsJson = true)]
public Dictionary<uint, BaseGameItemInfo> Items { get; set; } = []; // Key: UniqueId public Dictionary<uint, BaseGameItemInfo> Items { get; set; } = [];
[SugarColumn(IsJson = true)] [SugarColumn(IsJson = true)]
public Dictionary<uint, GameWeaponInfo> Weapons { get; set; } = []; // Key: UniqueId public Dictionary<uint, GameWeaponInfo> Weapons { get; set; } = [];
[SugarColumn(IsJson = true)] [SugarColumn(IsJson = true)]
public Dictionary<uint, GameSkinInfo> Skins { get; set; } = []; // Key: UniqueId public Dictionary<uint, GameSkinInfo> Skins { get; set; } = [];
[SugarColumn(IsJson = true)] [SugarColumn(IsJson = true)]
public Dictionary<uint, GameSupportCardInfo> SupportCards { get; set; } = []; // Key: UniqueId public Dictionary<uint, GameSupportCardInfo> SupportCards { get; set; } = [];
[SugarColumn(IsJson = true)] [SugarColumn(IsJson = true)]
public Dictionary<uint, uint> SkinTypesBySkinId { get; set; } = []; // Key: nSkinId, Value: client nType public Dictionary<uint, uint> SkinTypesBySkinId { get; set; } = [];
} }
public class BaseGameItemInfo public class BaseGameItemInfo
@@ -63,6 +63,7 @@ public abstract class GrowableItemInfo : BaseGameItemInfo
public class GameWeaponInfo : GrowableItemInfo public class GameWeaponInfo : GrowableItemInfo
{ {
[SugarColumn(IsJson = true)] public Dictionary<uint, ulong> PartSlots { get; set; } = []; [SugarColumn(IsJson = true)] public Dictionary<uint, ulong> PartSlots { get; set; } = [];
public override Item ToProto() public override Item ToProto()
{ {
var proto = new Item var proto = new Item
@@ -79,14 +80,17 @@ public class GameWeaponInfo : GrowableItemInfo
Evolue = Evolue Evolue = Evolue
} }
}; };
foreach (var (slot, uid) in PartSlots) proto.Slots[slot] = uid; foreach (var (slot, uid) in PartSlots)
proto.Slots[slot] = uid;
return proto; return proto;
} }
} }
public class GameSkinInfo : BaseGameItemInfo public class GameSkinInfo : BaseGameItemInfo
{ {
[SugarColumn(IsJson = true)] public Dictionary<uint, ulong> PartSlots { get; set; } = []; [SugarColumn(IsJson = true)] public Dictionary<uint, ulong> PartSlots { get; set; } = [];
public uint SkinType { get; set; } public uint SkinType { get; set; }
public override Item ToProto() public override Item ToProto()
{ {
var proto = new Item var proto = new Item
@@ -97,15 +101,17 @@ public class GameSkinInfo : BaseGameItemInfo
Flag = (uint)Flag, Flag = (uint)Flag,
}; };
proto.Slots[(uint)ItemSkinSlotTypeEnum.SLOT_CARD_SKIL_TYPE] = Math.Min(SkinType, 1); proto.Slots[(uint)ItemSkinSlotTypeEnum.SLOT_CARD_SKIL_TYPE] = Math.Min(SkinType, 1);
foreach (var (slot, uid) in PartSlots) proto.Slots[slot] = uid; foreach (var (slot, uid) in PartSlots)
proto.Slots[slot] = uid;
return proto; return proto;
} }
} }
public class GameSupportCardInfo : BaseGameItemInfo public class GameSupportCardInfo : BaseGameItemInfo
{ {
public uint AffixId { get; set; } public uint AffixId { get; set; }
[SugarColumn(IsJson = true)] public List<uint> Affixs { get; set; } = [];
public override Item ToProto() public override Item ToProto()
{ {
var proto = new Item var proto = new Item
@@ -120,6 +126,7 @@ public class GameSupportCardInfo : BaseGameItemInfo
Exp = Exp Exp = Exp
} }
}; };
proto.Enhance.Affixs.AddRange(Affixs);
proto.Slots[(uint)ItemSupportCardSlotTypeEnum.SLOT_AFFIXINDEX] = AffixId; proto.Slots[(uint)ItemSupportCardSlotTypeEnum.SLOT_AFFIXINDEX] = AffixId;
return proto; return proto;
} }

View File

@@ -4,6 +4,7 @@ using MikuSB.Database;
using MikuSB.Database.Inventory; using MikuSB.Database.Inventory;
using MikuSB.Enums.Item; using MikuSB.Enums.Item;
using MikuSB.GameServer.Game.Player; using MikuSB.GameServer.Game.Player;
using MikuSB.GameServer.Game.Support;
using MikuSB.GameServer.Server.Packet.Send.Misc; using MikuSB.GameServer.Server.Packet.Send.Misc;
namespace MikuSB.GameServer.Game.Inventory; namespace MikuSB.GameServer.Game.Inventory;
@@ -135,7 +136,17 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
ItemType = genre, ItemType = genre,
ItemCount = 1, ItemCount = 1,
Level = cardLevel, Level = cardLevel,
AffixId = 0,
}; };
var affixCount = cardLevel >= spCard.MaxLevel ? spCard.TotalAffixCount : spCard.InitialAffixCount;
for (int i = 0; i < affixCount && i < spCard.AffixPool.Count; i++)
{
var (affixId, tier) = SupportAffixService.GenerateRandomAffix(spCard.AffixPool[i]);
if (affixId == 0) continue;
SupportAffixStateService.SetAffix(info, i + 1, affixId, tier);
}
InventoryData.SupportCards[info.UniqueId] = info; InventoryData.SupportCards[info.UniqueId] = info;
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([info])); if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([info]));

View File

@@ -0,0 +1,50 @@
using MikuSB.Data;
namespace MikuSB.GameServer.Game.Support;
public static class SupportAffixService
{
public static (uint AffixId, uint Tier) GenerateRandomAffix(int poolId, IEnumerable<uint>? excludedAffixIds = null)
{
if (!GameData.SupportAffixPoolData.TryGetValue(poolId, out var pool))
return (0, 0);
var groups = pool.Groups.ToList();
if (groups.Count == 0)
return (0, 0);
var totalWeight = groups.Sum(x => x.Weight);
var roll = Random.Shared.Next(totalWeight);
var cumulative = 0;
var selectedAffixs = groups[0].Affixs;
foreach (var (affixIds, weight) in groups)
{
cumulative += weight;
if (roll < cumulative)
{
selectedAffixs = affixIds;
break;
}
}
if (selectedAffixs.Count == 0)
return (0, 0);
var excluded = excludedAffixIds?.ToHashSet() ?? [];
var candidates = selectedAffixs.Where(x => !excluded.Contains((uint)x)).ToList();
if (candidates.Count == 0)
candidates = selectedAffixs.ToList();
var affixId = candidates[Random.Shared.Next(candidates.Count)];
var tierCount = GameData.SupportAffixData.GetValueOrDefault(affixId)?.TierCount ?? 5;
var tier = (uint)(Random.Shared.Next(tierCount) + 1);
return ((uint)affixId, tier);
}
public static uint GenerateTier(uint affixId)
{
var tierCount = GameData.SupportAffixData.GetValueOrDefault((int)affixId)?.TierCount ?? 5;
return (uint)(Random.Shared.Next(tierCount) + 1);
}
}

View File

@@ -0,0 +1,70 @@
using MikuSB.Database.Inventory;
namespace MikuSB.GameServer.Game.Support;
public static class SupportAffixStateService
{
public const int PairSize = 2;
public const int MaxLogicalSlots = 5;
public const int ActiveThirdAffixSlot = 3;
public const int PendingMaxAffixSlot = 4;
public const int PendingInitialAffixSlot = 5;
public static void EnsureCapacity(GameSupportCardInfo card, int logicalSlot = MaxLogicalSlots)
{
var minCount = Math.Clamp(logicalSlot, 1, MaxLogicalSlots) * PairSize;
while (card.Affixs.Count < minCount)
card.Affixs.Add(0);
}
public static (uint AffixId, uint Tier) GetAffix(GameSupportCardInfo card, int logicalSlot)
{
if (logicalSlot < 1 || logicalSlot > MaxLogicalSlots)
return (0, 0);
var index = (logicalSlot - 1) * PairSize;
if (card.Affixs.Count <= index + 1)
return (0, 0);
return (card.Affixs[index], card.Affixs[index + 1]);
}
public static bool HasAffix(GameSupportCardInfo card, int logicalSlot)
{
var (affixId, tier) = GetAffix(card, logicalSlot);
return affixId > 0 && tier > 0;
}
public static void SetAffix(GameSupportCardInfo card, int logicalSlot, uint affixId, uint tier)
{
if (logicalSlot < 1 || logicalSlot > MaxLogicalSlots)
return;
EnsureCapacity(card, logicalSlot);
var index = (logicalSlot - 1) * PairSize;
card.Affixs[index] = affixId;
card.Affixs[index + 1] = tier;
}
public static void ClearAffix(GameSupportCardInfo card, int logicalSlot)
{
SetAffix(card, logicalSlot, 0, 0);
}
public static void CopyAffix(GameSupportCardInfo card, int fromSlot, int toSlot)
{
var (affixId, tier) = GetAffix(card, fromSlot);
SetAffix(card, toSlot, affixId, tier);
}
public static uint GetVisibleInitialAffixIndex(GameSupportCardInfo card)
{
return HasAffix(card, PendingInitialAffixSlot) ? card.AffixId : 0;
}
public static void NormalizePendingState(GameSupportCardInfo card)
{
if (!HasAffix(card, PendingInitialAffixSlot))
card.AffixId = 0;
}
}

View File

@@ -0,0 +1,153 @@
using MikuSB.Data;
using MikuSB.Data.Excel;
using MikuSB.Database;
using MikuSB.Database.Inventory;
using MikuSB.Database.Player;
using MikuSB.GameServer.Game.Support;
using MikuSB.Proto;
using System.Text.Json.Serialization;
namespace MikuSB.GameServer.Server.CallGS.Handlers.SupporterCard;
internal static class SupporterCardAffixShared
{
public const uint BaseGid = 150;
public const uint FixedResetSid = 1;
public static SupportCardExcel? GetExcel(GameSupportCardInfo card)
{
return GameData.SupportCardData.FirstOrDefault(x => x.TemplateId == card.TemplateId);
}
public static async Task SendResetResponse(Connection connection, NtfSyncPlayer? sync = null)
{
await CallGSRouter.SendScript(connection, "SupporterCard_ResetAffix", "null", sync!);
}
public static async Task SendSelectResponse(Connection connection, NtfSyncPlayer? sync = null)
{
await CallGSRouter.SendScript(connection, "SupporterCard_SelectAffix", "null", sync!);
}
public static List<Item> ConsumeCostItems(Connection connection, IEnumerable<IReadOnlyList<uint>> costs)
{
var player = connection.Player!;
var syncItems = new List<Item>();
foreach (var cost in costs)
{
if (cost.Count < 5)
continue;
var templateId = GameResourceTemplateId.FromGdpl(cost);
var item = player.InventoryManager.InventoryData.Items.Values.FirstOrDefault(x => x.TemplateId == templateId);
if (item == null || item.ItemCount < cost[4])
throw new InvalidOperationException("support affix material not enough");
item.ItemCount -= cost[4];
var proto = item.ToProto();
if (item.ItemCount == 0)
{
player.InventoryManager.InventoryData.Items.Remove(item.UniqueId);
proto.Count = 0;
}
syncItems.Add(proto);
}
return syncItems;
}
public static bool HasEnoughItems(Connection connection, IEnumerable<IReadOnlyList<uint>> costs)
{
var items = connection.Player!.InventoryManager.InventoryData.Items.Values;
return costs.All(cost =>
{
if (cost.Count < 5)
return false;
var templateId = GameResourceTemplateId.FromGdpl(cost);
var item = items.FirstOrDefault(x => x.TemplateId == templateId);
return item != null && item.ItemCount >= cost[4];
});
}
public static PlayerAttr GetOrCreateAttr(PlayerGameData data, uint gid, uint sid)
{
var attr = data.Attrs.FirstOrDefault(x => x.Gid == gid && x.Sid == sid);
if (attr != null)
return attr;
attr = new PlayerAttr { Gid = gid, Sid = sid, Val = 0 };
data.Attrs.Add(attr);
return attr;
}
public static void SetAttr(Connection connection, NtfSyncPlayer sync, uint gid, uint sid, uint value)
{
var player = connection.Player!;
var attr = GetOrCreateAttr(player.Data, gid, sid);
attr.Val = value;
sync.Custom[player.ToPackedAttrKey(gid, sid)] = value;
sync.Custom[player.ToShiftedAttrKey(gid, sid)] = value;
}
public static IEnumerable<uint> GetActiveAffixIds(GameSupportCardInfo card, params int[] ignoreSlots)
{
var ignored = ignoreSlots.ToHashSet();
for (var slot = 1; slot <= SupportAffixStateService.ActiveThirdAffixSlot; slot++)
{
if (ignored.Contains(slot))
continue;
var (affixId, _) = SupportAffixStateService.GetAffix(card, slot);
if (affixId > 0)
yield return affixId;
}
}
public static void Save(Connection connection)
{
var player = connection.Player!;
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
DatabaseHelper.SaveDatabaseType(player.Data);
}
}
internal sealed class SupporterCardIdParam
{
[JsonPropertyName("Id")]
public int SupportCardUid { get; set; }
}
internal sealed class SupporterCardSelectParam
{
[JsonPropertyName("Id")]
public int SupportCardUid { get; set; }
[JsonPropertyName("SelectNew")]
public bool SelectNew { get; set; }
}
internal sealed class SupporterCardResetInitialParam
{
[JsonPropertyName("Id")]
public int SupportCardUid { get; set; }
[JsonPropertyName("Index")]
public int Index { get; set; }
[JsonPropertyName("FixedId")]
public uint FixedId { get; set; }
}
internal sealed class SupporterCardSelectInitialParam
{
[JsonPropertyName("Id")]
public int SupportCardUid { get; set; }
[JsonPropertyName("Index")]
public int Index { get; set; }
[JsonPropertyName("SelectNew")]
public bool SelectNew { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace MikuSB.GameServer.Server.CallGS.Handlers.SupporterCard;
[CallGSApi("SupporterCard_FixedResetInitialAffix")]
public class SupporterCard_FixedResetInitialAffix : ICallGSHandler
{
public async Task Handle(Connection connection, string param, ushort seqNo)
{
await SupporterCard_ResetInitialAffix.Reset(connection, param, fixedMode: true);
}
}

View File

@@ -0,0 +1,57 @@
using MikuSB.Data;
using MikuSB.Proto;
using System.Text.Json.Nodes;
namespace MikuSB.GameServer.Server.CallGS.Handlers.SupporterCard;
[CallGSApi("SupporterCard_ReceiveFixedItem")]
public class SupporterCard_ReceiveFixedItem : ICallGSHandler
{
public async Task Handle(Connection connection, string param, ushort seqNo)
{
var player = connection.Player!;
if (!GameData.SupportFixedData.TryGetValue(1, out var fixedCfg) || fixedCfg.Item.Count < 5 || fixedCfg.Num <= 0)
{
await CallGSRouter.SendScript(connection, "SupporterCard_ReceiveFixedItem", "{}");
return;
}
var attr = SupporterCardAffixShared.GetOrCreateAttr(player.Data, SupporterCardAffixShared.BaseGid, SupporterCardAffixShared.FixedResetSid);
var claimCount = attr.Val / (uint)fixedCfg.Num;
if (claimCount == 0)
{
await CallGSRouter.SendScript(connection, "SupporterCard_ReceiveFixedItem", "{}");
return;
}
attr.Val %= (uint)fixedCfg.Num;
var rewardTemplateId = (uint)GameResourceTemplateId.FromGdpl(fixedCfg.Item);
var rewardItem = GameData.SuppliesData.GetValueOrDefault(rewardTemplateId);
if (rewardItem == null)
{
await CallGSRouter.SendScript(connection, "SupporterCard_ReceiveFixedItem", "{}");
return;
}
var granted = await player.InventoryManager.AddSuppliesItem(rewardItem, claimCount * fixedCfg.Item[4], sendPacket: false);
var sync = new NtfSyncPlayer();
if (granted != null)
sync.Items.Add(granted.ToProto());
SupporterCardAffixShared.SetAttr(connection, sync, SupporterCardAffixShared.BaseGid, SupporterCardAffixShared.FixedResetSid, attr.Val);
SupporterCardAffixShared.Save(connection);
var arg = new JsonObject
{
["tbRewards"] = new JsonArray(
(int)fixedCfg.Item[0],
(int)fixedCfg.Item[1],
(int)fixedCfg.Item[2],
(int)fixedCfg.Item[3],
(int)(claimCount * fixedCfg.Item[4]))
}.ToJsonString();
await CallGSRouter.SendScript(connection, "SupporterCard_ReceiveFixedItem", arg, sync);
}
}

View File

@@ -0,0 +1,38 @@
using MikuSB.GameServer.Game.Support;
using MikuSB.Proto;
using System.Text.Json;
namespace MikuSB.GameServer.Server.CallGS.Handlers.SupporterCard;
[CallGSApi("SupporterCard_ResetAffix")]
public class SupporterCard_ResetAffix : ICallGSHandler
{
public async Task Handle(Connection connection, string param, ushort seqNo)
{
var req = JsonSerializer.Deserialize<SupporterCardIdParam>(param);
var card = req == null ? null : connection.Player!.InventoryManager.GetSupportCardItem((uint)req.SupportCardUid);
var excel = card == null ? null : SupporterCardAffixShared.GetExcel(card);
if (card == null || excel == null || excel.AffixCost.Count < 5 || !SupportAffixStateService.HasAffix(card, SupportAffixStateService.ActiveThirdAffixSlot))
{
await SupporterCardAffixShared.SendResetResponse(connection);
return;
}
var costs = new[] { excel.AffixCost };
if (!SupporterCardAffixShared.HasEnoughItems(connection, costs))
{
await SupporterCardAffixShared.SendResetResponse(connection);
return;
}
var sync = new NtfSyncPlayer();
sync.Items.AddRange(SupporterCardAffixShared.ConsumeCostItems(connection, costs));
var excluded = SupporterCardAffixShared.GetActiveAffixIds(card, SupportAffixStateService.ActiveThirdAffixSlot);
var (affixId, tier) = SupportAffixService.GenerateRandomAffix(excel.AffixPool[SupportAffixStateService.ActiveThirdAffixSlot - 1], excluded);
SupportAffixStateService.SetAffix(card, SupportAffixStateService.PendingMaxAffixSlot, affixId, tier);
sync.Items.Add(card.ToProto());
SupporterCardAffixShared.Save(connection);
await SupporterCardAffixShared.SendResetResponse(connection, sync);
}
}

View File

@@ -0,0 +1,60 @@
using MikuSB.GameServer.Game.Support;
using MikuSB.Proto;
using System.Text.Json;
namespace MikuSB.GameServer.Server.CallGS.Handlers.SupporterCard;
[CallGSApi("SupporterCard_ResetInitialAffix")]
public class SupporterCard_ResetInitialAffix : ICallGSHandler
{
public async Task Handle(Connection connection, string param, ushort seqNo)
{
await Reset(connection, param, fixedMode: false);
}
internal static async Task Reset(Connection connection, string param, bool fixedMode)
{
var req = JsonSerializer.Deserialize<SupporterCardResetInitialParam>(param);
var card = req == null ? null : connection.Player!.InventoryManager.GetSupportCardItem((uint)req.SupportCardUid);
var excel = card == null ? null : SupporterCardAffixShared.GetExcel(card);
if (req == null || card == null || excel == null || req.Index is < 1 or > 2 || excel.AffixPool.Count < req.Index)
{
await SupporterCardAffixShared.SendResetResponse(connection);
return;
}
var costs = fixedMode ? new[] { excel.FixedAffixCost } : excel.InitialAffixCost;
if (!costs.Any() || !SupporterCardAffixShared.HasEnoughItems(connection, costs))
{
await SupporterCardAffixShared.SendResetResponse(connection);
return;
}
var sync = new NtfSyncPlayer();
sync.Items.AddRange(SupporterCardAffixShared.ConsumeCostItems(connection, costs));
uint affixId;
uint tier;
if (fixedMode && req.FixedId > 0)
{
affixId = req.FixedId;
tier = SupportAffixService.GenerateTier(affixId);
}
else
{
var excluded = SupporterCardAffixShared.GetActiveAffixIds(card, req.Index);
(affixId, tier) = SupportAffixService.GenerateRandomAffix(excel.AffixPool[req.Index - 1], excluded);
}
SupportAffixStateService.SetAffix(card, SupportAffixStateService.PendingInitialAffixSlot, affixId, tier);
card.AffixId = (uint)req.Index;
var attr = SupporterCardAffixShared.GetOrCreateAttr(connection.Player!.Data, SupporterCardAffixShared.BaseGid, SupporterCardAffixShared.FixedResetSid);
attr.Val += 1;
SupporterCardAffixShared.SetAttr(connection, sync, SupporterCardAffixShared.BaseGid, SupporterCardAffixShared.FixedResetSid, attr.Val);
sync.Items.Add(card.ToProto());
SupporterCardAffixShared.Save(connection);
await SupporterCardAffixShared.SendResetResponse(connection, sync);
}
}

View File

@@ -0,0 +1,30 @@
using MikuSB.GameServer.Game.Support;
using MikuSB.Proto;
using System.Text.Json;
namespace MikuSB.GameServer.Server.CallGS.Handlers.SupporterCard;
[CallGSApi("SupporterCard_SelectAffix")]
public class SupporterCard_SelectAffix : ICallGSHandler
{
public async Task Handle(Connection connection, string param, ushort seqNo)
{
var req = JsonSerializer.Deserialize<SupporterCardSelectParam>(param);
var card = req == null ? null : connection.Player!.InventoryManager.GetSupportCardItem((uint)req.SupportCardUid);
if (card == null || !SupportAffixStateService.HasAffix(card, SupportAffixStateService.PendingMaxAffixSlot))
{
await SupporterCardAffixShared.SendSelectResponse(connection);
return;
}
if (req!.SelectNew)
SupportAffixStateService.CopyAffix(card, SupportAffixStateService.PendingMaxAffixSlot, SupportAffixStateService.ActiveThirdAffixSlot);
SupportAffixStateService.ClearAffix(card, SupportAffixStateService.PendingMaxAffixSlot);
var sync = new NtfSyncPlayer();
sync.Items.Add(card.ToProto());
SupporterCardAffixShared.Save(connection);
await SupporterCardAffixShared.SendSelectResponse(connection, sync);
}
}

View File

@@ -0,0 +1,31 @@
using MikuSB.GameServer.Game.Support;
using MikuSB.Proto;
using System.Text.Json;
namespace MikuSB.GameServer.Server.CallGS.Handlers.SupporterCard;
[CallGSApi("SupporterCard_SelectInitialAffix")]
public class SupporterCard_SelectInitialAffix : ICallGSHandler
{
public async Task Handle(Connection connection, string param, ushort seqNo)
{
var req = JsonSerializer.Deserialize<SupporterCardSelectInitialParam>(param);
var card = req == null ? null : connection.Player!.InventoryManager.GetSupportCardItem((uint)req.SupportCardUid);
if (req == null || card == null || req.Index is < 1 or > 2 || card.AffixId != req.Index || !SupportAffixStateService.HasAffix(card, SupportAffixStateService.PendingInitialAffixSlot))
{
await SupporterCardAffixShared.SendSelectResponse(connection);
return;
}
if (req.SelectNew)
SupportAffixStateService.CopyAffix(card, SupportAffixStateService.PendingInitialAffixSlot, req.Index);
SupportAffixStateService.ClearAffix(card, SupportAffixStateService.PendingInitialAffixSlot);
card.AffixId = 0;
var sync = new NtfSyncPlayer();
sync.Items.Add(card.ToProto());
SupporterCardAffixShared.Save(connection);
await SupporterCardAffixShared.SendSelectResponse(connection, sync);
}
}

View File

@@ -1,5 +1,6 @@
using MikuSB.Data; using MikuSB.Data;
using MikuSB.Database; using MikuSB.Database;
using MikuSB.GameServer.Game.Support;
using MikuSB.Proto; using MikuSB.Proto;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@@ -19,7 +20,7 @@ public class SupporterCard_Upgrade : ICallGSHandler
return; return;
} }
var supportCard = player.InventoryManager.InventoryData.Items.GetValueOrDefault((uint)req.SupportCardUid); var supportCard = player.InventoryManager.GetSupportCardItem((uint)req.SupportCardUid);
if (supportCard == null) if (supportCard == null)
{ {
await CallGSRouter.SendScript(connection, "Logistics_Upgrade", "{}"); await CallGSRouter.SendScript(connection, "Logistics_Upgrade", "{}");
@@ -68,10 +69,11 @@ public class SupporterCard_Upgrade : ICallGSHandler
} }
// Apply exp and level up // Apply exp and level up
if (supportCard.Level == 0) supportCard.Level = 1;
supportCard.Exp += gainedExp; supportCard.Exp += gainedExp;
while (supportCard.Level < maxLevel) while (supportCard.Level < maxLevel)
{ {
var expNeeded = GetExpNeeded(supportCard.Level + 1); var expNeeded = GetExpNeeded(supportCard.Level);
if (expNeeded == 0 || supportCard.Exp < expNeeded) break; if (expNeeded == 0 || supportCard.Exp < expNeeded) break;
supportCard.Exp -= expNeeded; supportCard.Exp -= expNeeded;
supportCard.Level++; supportCard.Level++;
@@ -80,6 +82,21 @@ public class SupporterCard_Upgrade : ICallGSHandler
{ {
supportCard.Exp = 0; supportCard.Exp = 0;
supportCard.Level = maxLevel; supportCard.Level = maxLevel;
// Unlock next affix slot when reaching max level for the first time
if (supportCardExcel != null)
{
var currentSlots = Enumerable.Range(1, SupportAffixStateService.ActiveThirdAffixSlot)
.Count(slot => SupportAffixStateService.HasAffix(supportCard, slot));
var totalSlots = supportCardExcel.TotalAffixCount;
if (currentSlots < totalSlots && currentSlots < supportCardExcel.AffixPool.Count)
{
var poolId = supportCardExcel.AffixPool[currentSlots];
var (affixId, tier) = SupportAffixService.GenerateRandomAffix(poolId);
if (affixId > 0)
SupportAffixStateService.SetAffix(supportCard, currentSlots + 1, affixId, tier);
}
}
} }
syncItems.Add(supportCard.ToProto()); syncItems.Add(supportCard.ToProto());

View File

@@ -1,6 +1,8 @@
using MikuSB.Database.Character; using MikuSB.Database.Character;
using MikuSB.Database.Inventory; using MikuSB.Database.Inventory;
using MikuSB.Enums.Item;
using MikuSB.GameServer.Game.Player; using MikuSB.GameServer.Game.Player;
using MikuSB.GameServer.Game.Support;
using MikuSB.Proto; using MikuSB.Proto;
using MikuSB.TcpSharp; using MikuSB.TcpSharp;
@@ -10,14 +12,14 @@ public class PacketNtfCallScript : BasePacket
{ {
public PacketNtfCallScript(List<CharacterInfo> characters) : base(CmdIds.NtfScript) public PacketNtfCallScript(List<CharacterInfo> characters) : base(CmdIds.NtfScript)
{ {
var proto = new NtfCallScript var proto = new NtfCallScript
{ {
Api = "", Api = "",
Arg = "{}", Arg = "{}",
ExtraSync = new NtfSyncPlayer ExtraSync = new NtfSyncPlayer
{ {
Items = { characters.Select(x => x.ToProto()) } Items = { characters.Select(x => x.ToProto()) }
} }
}; };
SetData(proto); SetData(proto);
@@ -61,7 +63,7 @@ public class PacketNtfCallScript : BasePacket
Arg = "{}", Arg = "{}",
ExtraSync = new NtfSyncPlayer ExtraSync = new NtfSyncPlayer
{ {
Items = { cards.Select(x => x.ToProto()) } Items = { cards.Select(ToSupportCardProto) }
} }
}; };
@@ -95,7 +97,7 @@ public class PacketNtfCallScript : BasePacket
foreach (var item in inventory.Items.Values) extraSync.Items.Add(item.ToProto()); foreach (var item in inventory.Items.Values) extraSync.Items.Add(item.ToProto());
foreach (var skin in inventory.Skins.Values) extraSync.Items.Add(skin.ToProto()); foreach (var skin in inventory.Skins.Values) extraSync.Items.Add(skin.ToProto());
foreach (var weapon in inventory.Weapons.Values) extraSync.Items.Add(weapon.ToProto()); foreach (var weapon in inventory.Weapons.Values) extraSync.Items.Add(weapon.ToProto());
foreach (var supportCard in inventory.SupportCards.Values) extraSync.Items.Add(supportCard.ToProto()); foreach (var supportCard in inventory.SupportCards.Values) extraSync.Items.Add(ToSupportCardProto(supportCard));
proto.ExtraSync = extraSync; proto.ExtraSync = extraSync;
SetData(proto); SetData(proto);
} }
@@ -128,4 +130,12 @@ public class PacketNtfCallScript : BasePacket
SetData(proto); SetData(proto);
} }
private static Item ToSupportCardProto(GameSupportCardInfo card)
{
SupportAffixStateService.NormalizePendingState(card);
var proto = card.ToProto();
proto.Slots[(uint)ItemSupportCardSlotTypeEnum.SLOT_AFFIXINDEX] = SupportAffixStateService.GetVisibleInitialAffixIndex(card);
return proto;
}
} }

View File

@@ -27,6 +27,7 @@ public class MikuSB
var time = DateTime.Now; var time = DateTime.Now;
IConsole.InitConsole(); IConsole.InitConsole();
LoaderManager.InitConfig(); LoaderManager.InitConfig();
ShowAntiScamWarning();
if (await UpdateService.TryStartSelfUpdateAsync()) if (await UpdateService.TryStartSelfUpdateAsync())
return; return;
@@ -65,6 +66,16 @@ public class MikuSB
await ProcessExit(Volatile.Read(ref _exitCode)); await ProcessExit(Volatile.Read(ref _exitCode));
} }
private static void ShowAntiScamWarning()
{
Logger.Warn("============================================================");
Logger.Warn("MikuSB is completely free and open source.");
Logger.Warn("If you paid anyone for this server, you were scammed.");
Logger.Warn("Request a refund immediately and report the seller to us.");
Logger.Warn("Discord: https://discord.gg/aMwCu9JyUR");
Logger.Warn("============================================================");
}
#region Exit #region Exit
private static void RegisterExitEvent() private static void RegisterExitEvent()
@@ -109,4 +120,4 @@ public class MikuSB
} }
# endregion # endregion
} }

View File

@@ -7,6 +7,12 @@
日本語のドキュメントは [README_jp.md](README_jp.md) にあります。 日本語のドキュメントは [README_jp.md](README_jp.md) にあります。
## Scam Warning
MikuSB is completely free and open source.
If anyone sold you this server or charged money to provide it, that was a scam.
Request a refund immediately and report the seller to us on Discord with any relevant proof or purchase details.
## Overview ## Overview
- `SdkServer` - `SdkServer`

View File

@@ -7,6 +7,12 @@
English documentation is available in [README.md](README.md). English documentation is available in [README.md](README.md).
## 詐欺に関する警告
MikuSB は完全無料のオープンソースです。
このサーバーを誰かから有料で販売された場合、それは詐欺です。
すぐに返金を申請し、購入記録や証拠とあわせて Discord で私たちに通報してください。
## 概要 ## 概要
- `SdkServer` - `SdkServer`

View File

@@ -1 +1 @@
v=3.0 v=3.3