Compare commits

...

4 Commits

Author SHA1 Message Date
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
9 changed files with 149 additions and 3 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

@@ -11,7 +11,9 @@ 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; } = [];
public uint MaxLevel => LevelLimitId switch public uint MaxLevel => LevelLimitId switch
{ {
@@ -21,6 +23,12 @@ public class SupportCardExcel : ExcelResource
_ => 10 _ => 10
}; };
// Number of affixes granted initially
public int InitialAffixCount => Color >= 5 ? 2 : 1;
// Total maximum affixes (including ones unlocked at max level)
public int TotalAffixCount => Color >= 5 ? 3 : 2;
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;

View File

@@ -23,6 +23,8 @@ 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<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

@@ -106,6 +106,8 @@ public class GameSkinInfo : BaseGameItemInfo
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 +122,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,18 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
ItemType = genre, ItemType = genre,
ItemCount = 1, ItemCount = 1,
Level = cardLevel, Level = cardLevel,
AffixId = 1,
}; };
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;
info.Affixs.Add(affixId);
info.Affixs.Add(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,40 @@
using MikuSB.Data;
namespace MikuSB.GameServer.Game.Support;
public static class SupportAffixService
{
// Returns (affixId, tier) - both 1-based. Returns (0,0) if pool not found.
public static (uint AffixId, uint Tier) GenerateRandomAffix(int poolId)
{
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 affixId = selectedAffixs[Random.Shared.Next(selectedAffixs.Count)];
var tierCount = GameData.SupportAffixData.GetValueOrDefault(affixId)?.TierCount ?? 5;
var tier = (uint)(Random.Shared.Next(tierCount) + 1);
return ((uint)affixId, tier);
}
}

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,23 @@ 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 = supportCard.Affixs.Count / 2;
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)
{
supportCard.Affixs.Add(affixId);
supportCard.Affixs.Add(tier);
}
}
}
} }
syncItems.Add(supportCard.ToProto()); syncItems.Add(supportCard.ToProto());

View File

@@ -1 +1 @@
v=3.0 v=3.1