mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 21:13:59 +00:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
846139347a | ||
|
|
d1102b444c | ||
|
|
3611624073 | ||
|
|
c61ac08dd3 | ||
|
|
720f56c708 | ||
|
|
5fa42bdb23 | ||
|
|
5af23a8113 | ||
|
|
ee79486748 | ||
|
|
0cf0e3beb4 | ||
|
|
8d6e0d7638 | ||
|
|
5f0de1a9f0 | ||
|
|
069ee6aa2a | ||
|
|
64f977173f | ||
|
|
0e62fcc9b2 | ||
|
|
f4ad74e00d | ||
|
|
ccdfbee828 | ||
|
|
5d0f587fb9 | ||
|
|
94f972ff82 | ||
|
|
2f8d0c6afc | ||
|
|
1b4f3531d1 | ||
|
|
1cac82d10d | ||
|
|
1e4d93bab1 | ||
|
|
f6204134a9 | ||
|
|
57ce0e183b | ||
|
|
5f92f2c116 |
@@ -16,7 +16,7 @@ public class HttpServerConfig
|
|||||||
public string BindAddress { get; set; } = "0.0.0.0";
|
public string BindAddress { get; set; } = "0.0.0.0";
|
||||||
public string PublicAddress { get; set; } = "127.0.0.1";
|
public string PublicAddress { get; set; } = "127.0.0.1";
|
||||||
public int Port { get; set; } = 21500;
|
public int Port { get; set; } = 21500;
|
||||||
public bool EnableLog { get; set; } = true;
|
public bool EnableLog { get; set; } = false;
|
||||||
|
|
||||||
public string GetDisplayAddress()
|
public string GetDisplayAddress()
|
||||||
{
|
{
|
||||||
|
|||||||
34
Common/Data/Excel/BreakExcel.cs
Normal file
34
Common/Data/Excel/BreakExcel.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("break.json")]
|
||||||
|
public class BreakExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public int Id { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("Items1")] public List<List<int>> Items1 { get; set; } = [];
|
||||||
|
[JsonProperty("Items2")] public List<List<int>> Items2 { get; set; } = [];
|
||||||
|
[JsonProperty("Items3")] public List<List<int>> Items3 { get; set; } = [];
|
||||||
|
[JsonProperty("Items4")] public List<List<int>> Items4 { get; set; } = [];
|
||||||
|
[JsonProperty("Items5")] public List<List<int>> Items5 { get; set; } = [];
|
||||||
|
[JsonProperty("Items6")] public List<List<int>> Items6 { get; set; } = [];
|
||||||
|
|
||||||
|
public List<List<int>> GetItems(uint breakLevel) => breakLevel switch
|
||||||
|
{
|
||||||
|
1 => Items1,
|
||||||
|
2 => Items2,
|
||||||
|
3 => Items3,
|
||||||
|
4 => Items4,
|
||||||
|
5 => Items5,
|
||||||
|
6 => Items6,
|
||||||
|
_ => []
|
||||||
|
};
|
||||||
|
|
||||||
|
public override uint GetId() => (uint)Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.BreakData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ public class CardExcel : ExcelResource
|
|||||||
[JsonProperty("profile")] public List<List<int>> Profile { get; set; } = [];
|
[JsonProperty("profile")] public List<List<int>> Profile { get; set; } = [];
|
||||||
public List<List<int>> Pieces { get; set; } = [];
|
public List<List<int>> Pieces { get; set; } = [];
|
||||||
public List<int> Attribute { get; set; } = [];
|
public List<int> Attribute { get; set; } = [];
|
||||||
|
[JsonProperty("SpineID")] public uint SpineId { get; set; }
|
||||||
public override uint GetId()
|
public override uint GetId()
|
||||||
{
|
{
|
||||||
return Icon;
|
return Icon;
|
||||||
|
|||||||
14
Common/Data/Excel/DailyLevelExcel.cs
Normal file
14
Common/Data/Excel/DailyLevelExcel.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("daily_level.json")]
|
||||||
|
public class DailyLevelExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint ID { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.DailyLevelData.Add(ID, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
41
Common/Data/Excel/NodeConditionExcel.cs
Normal file
41
Common/Data/Excel/NodeConditionExcel.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
// nodecondition.json: NodeConditionId → NodeXCost per sub-node (1-9)
|
||||||
|
[ResourceEntity("nodecondition.json")]
|
||||||
|
public class NodeConditionExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public uint Id { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("Node1Cost")] public List<List<int>> Node1Cost { get; set; } = [];
|
||||||
|
[JsonProperty("Node2Cost")] public List<List<int>> Node2Cost { get; set; } = [];
|
||||||
|
[JsonProperty("Node3Cost")] public List<List<int>> Node3Cost { get; set; } = [];
|
||||||
|
[JsonProperty("Node4Cost")] public List<List<int>> Node4Cost { get; set; } = [];
|
||||||
|
[JsonProperty("Node5Cost")] public List<List<int>> Node5Cost { get; set; } = [];
|
||||||
|
[JsonProperty("Node6Cost")] public List<List<int>> Node6Cost { get; set; } = [];
|
||||||
|
[JsonProperty("Node7Cost")] public List<List<int>> Node7Cost { get; set; } = [];
|
||||||
|
[JsonProperty("Node8Cost")] public List<List<int>> Node8Cost { get; set; } = [];
|
||||||
|
[JsonProperty("Node9Cost")] public List<List<int>> Node9Cost { get; set; } = [];
|
||||||
|
|
||||||
|
public List<List<int>> GetNodeCost(int subIdx) => subIdx switch
|
||||||
|
{
|
||||||
|
1 => Node1Cost,
|
||||||
|
2 => Node2Cost,
|
||||||
|
3 => Node3Cost,
|
||||||
|
4 => Node4Cost,
|
||||||
|
5 => Node5Cost,
|
||||||
|
6 => Node6Cost,
|
||||||
|
7 => Node7Cost,
|
||||||
|
8 => Node8Cost,
|
||||||
|
9 => Node9Cost,
|
||||||
|
_ => []
|
||||||
|
};
|
||||||
|
|
||||||
|
public override uint GetId() => Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.NodeConditionData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
35
Common/Data/Excel/SpineExcel.cs
Normal file
35
Common/Data/Excel/SpineExcel.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
// spine.json: SpineId → Node{i}Req (nodecondition ID per master node index)
|
||||||
|
[ResourceEntity("spine.json")]
|
||||||
|
public class SpineExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public uint Id { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("Node1Req")] public uint Node1Req { get; set; }
|
||||||
|
[JsonProperty("Node2Req")] public uint Node2Req { get; set; }
|
||||||
|
[JsonProperty("Node3Req")] public uint Node3Req { get; set; }
|
||||||
|
[JsonProperty("Node4Req")] public uint Node4Req { get; set; }
|
||||||
|
[JsonProperty("Node5Req")] public uint Node5Req { get; set; }
|
||||||
|
[JsonProperty("Node6Req")] public uint Node6Req { get; set; }
|
||||||
|
|
||||||
|
public uint GetNodeReq(int mastIdx) => mastIdx switch
|
||||||
|
{
|
||||||
|
1 => Node1Req,
|
||||||
|
2 => Node2Req,
|
||||||
|
3 => Node3Req,
|
||||||
|
4 => Node4Req,
|
||||||
|
5 => Node5Req,
|
||||||
|
6 => Node6Req,
|
||||||
|
_ => 0
|
||||||
|
};
|
||||||
|
|
||||||
|
public override uint GetId() => Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.SpineData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
32
Common/Data/Excel/SupportCardExcel.cs
Normal file
32
Common/Data/Excel/SupportCardExcel.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("support_card.json")]
|
||||||
|
public class SupportCardExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint Genre { get; set; }
|
||||||
|
public uint Detail { get; set; }
|
||||||
|
public uint Particular { get; set; }
|
||||||
|
public uint Level { get; set; }
|
||||||
|
public uint Icon { get; set; }
|
||||||
|
public uint ProvideExp { get; set; }
|
||||||
|
[JsonProperty("LevelLimitID")] public int LevelLimitId { get; set; }
|
||||||
|
|
||||||
|
public uint MaxLevel => LevelLimitId switch
|
||||||
|
{
|
||||||
|
1007 => 10,
|
||||||
|
1008 => 13,
|
||||||
|
1009 => 16,
|
||||||
|
_ => 10
|
||||||
|
};
|
||||||
|
|
||||||
|
public ulong TemplateId => GameResourceTemplateId.FromGdpl(Genre, Detail, Particular, Level);
|
||||||
|
|
||||||
|
public override uint GetId() => Icon;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.SupportCardData.Add(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
Common/Data/Excel/WeaponSkinExcel.cs
Normal file
24
Common/Data/Excel/WeaponSkinExcel.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("weapon_skin.json")]
|
||||||
|
public class WeaponSkinExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint Genre { get; set; }
|
||||||
|
public uint Detail { get; set; }
|
||||||
|
public uint Particular { get; set; }
|
||||||
|
public uint Level { get; set; }
|
||||||
|
public string I18n { get; set; } = "";
|
||||||
|
|
||||||
|
public override uint GetId()
|
||||||
|
{
|
||||||
|
return (uint)I18n.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.WeaponSkinData.Add(GetId(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,13 @@ public static class GameData
|
|||||||
public static Dictionary<uint, ArItemExcel> ArItemData { get; private set; } = [];
|
public static Dictionary<uint, ArItemExcel> ArItemData { get; private set; } = [];
|
||||||
public static Dictionary<uint, ManifestationExcel> ManifestationData { get; private set; } = [];
|
public static Dictionary<uint, ManifestationExcel> ManifestationData { get; private set; } = [];
|
||||||
public static Dictionary<uint, Rogue3DDifficultExcel> Rogue3DDifficultData { get; private set; } = [];
|
public static Dictionary<uint, Rogue3DDifficultExcel> Rogue3DDifficultData { get; private set; } = [];
|
||||||
|
public static Dictionary<int, BreakExcel> BreakData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, SpineExcel> SpineData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, NodeConditionExcel> NodeConditionData { get; private set; } = [];
|
||||||
|
public static List<SupportCardExcel> SupportCardData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, WeaponSkinExcel> WeaponSkinData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, DailyLevelExcel> DailyLevelData { get; private set; } = [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GameResourceTemplateId
|
public static class GameResourceTemplateId
|
||||||
|
|||||||
@@ -19,14 +19,18 @@ public class CharacterInfo
|
|||||||
public int Exp { get; set; }
|
public int Exp { get; set; }
|
||||||
public uint Break { get; set; }
|
public uint Break { get; set; }
|
||||||
public int Evolue { get; set; }
|
public int Evolue { get; set; }
|
||||||
|
public uint ProLevel { get; set; }
|
||||||
public int Trust { get; set; }
|
public int Trust { get; set; }
|
||||||
public uint WeaponUniqueId { get; set; }
|
public uint WeaponUniqueId { get; set; }
|
||||||
public uint SkinId { get; set; }
|
public uint SkinId { get; set; }
|
||||||
|
public uint WeaponSkinId { get; set; }
|
||||||
public ItemFlagEnum Flag { get; set; } = ItemFlagEnum.FLAG_READED;
|
public ItemFlagEnum Flag { get; set; } = ItemFlagEnum.FLAG_READED;
|
||||||
public uint Expiration { get; set; }
|
public uint Expiration { get; set; }
|
||||||
[SugarColumn(IsJson = true)] public List<uint> UnlockedSkin { get; set; } = [];
|
[SugarColumn(IsJson = true)] public List<uint> UnlockedSkin { get; set; } = [];
|
||||||
[SugarColumn(IsJson = true)] public List<uint> Spines { get; set; } = [];
|
[SugarColumn(IsJson = true)] public List<uint> Spines { get; set; } = [];
|
||||||
[SugarColumn(IsJson = true)] public List<uint> Affixs { get; set; } = [];
|
[SugarColumn(IsJson = true)] public List<uint> Affixs { get; set; } = [];
|
||||||
|
// Key = EqSlot (= support card Detail), Value = support card UniqueId
|
||||||
|
[SugarColumn(IsJson = true)] public Dictionary<uint, uint> SupportSlots { get; set; } = [];
|
||||||
public long Timestamp { get; set; }
|
public long Timestamp { get; set; }
|
||||||
public uint Count { get; set; } = 1;
|
public uint Count { get; set; } = 1;
|
||||||
|
|
||||||
@@ -45,6 +49,7 @@ public class CharacterInfo
|
|||||||
Exp = ToUInt32(Exp),
|
Exp = ToUInt32(Exp),
|
||||||
Break = Break,
|
Break = Break,
|
||||||
Evolue = ToUInt32(Evolue),
|
Evolue = ToUInt32(Evolue),
|
||||||
|
ProLevel = ProLevel,
|
||||||
Trust = ToUInt32(Trust)
|
Trust = ToUInt32(Trust)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -53,6 +58,9 @@ public class CharacterInfo
|
|||||||
|
|
||||||
proto.Slots[4] = WeaponUniqueId;
|
proto.Slots[4] = WeaponUniqueId;
|
||||||
proto.Slots[5] = SkinId;
|
proto.Slots[5] = SkinId;
|
||||||
|
proto.Slots[6] = WeaponSkinId;
|
||||||
|
foreach (var (slot, uid) in SupportSlots)
|
||||||
|
proto.Slots[slot] = uid;
|
||||||
|
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ public class InventoryData : BaseDatabaseDataHelper
|
|||||||
|
|
||||||
[SugarColumn(IsJson = true)]
|
[SugarColumn(IsJson = true)]
|
||||||
public Dictionary<uint, GameSkinInfo> Skins { get; set; } = []; // Key: UniqueId
|
public Dictionary<uint, GameSkinInfo> Skins { get; set; } = []; // Key: UniqueId
|
||||||
|
|
||||||
|
[SugarColumn(IsJson = true)]
|
||||||
|
public Dictionary<uint, GameSupportCardInfo> SupportCards { get; set; } = []; // Key: UniqueId
|
||||||
|
|
||||||
|
[SugarColumn(IsJson = true)]
|
||||||
|
public Dictionary<uint, uint> SkinTypesBySkinId { get; set; } = []; // Key: nSkinId, Value: client nType
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BaseGameItemInfo
|
public class BaseGameItemInfo
|
||||||
@@ -26,25 +32,31 @@ public class BaseGameItemInfo
|
|||||||
public uint ItemCount { get; set; }
|
public uint ItemCount { get; set; }
|
||||||
public ItemTypeEnum ItemType { get; set; }
|
public ItemTypeEnum ItemType { get; set; }
|
||||||
public ItemFlagEnum Flag { get; set; } = ItemFlagEnum.FLAG_READED;
|
public ItemFlagEnum Flag { get; set; } = ItemFlagEnum.FLAG_READED;
|
||||||
|
public uint Level { get; set; }
|
||||||
|
public uint Exp { get; set; }
|
||||||
|
|
||||||
public virtual Item ToProto()
|
public virtual Item ToProto()
|
||||||
{
|
{
|
||||||
return new Item
|
var proto = new Item
|
||||||
{
|
{
|
||||||
Id = UniqueId,
|
Id = UniqueId,
|
||||||
Template = TemplateId,
|
Template = TemplateId,
|
||||||
Count = ItemCount,
|
Count = ItemCount,
|
||||||
Flag = (uint)Flag
|
Flag = (uint)Flag
|
||||||
};
|
};
|
||||||
|
if (Level > 0 || Exp > 0)
|
||||||
|
proto.Enhance = new Enhance { Level = Level, Exp = Exp };
|
||||||
|
return proto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class GrowableItemInfo : BaseGameItemInfo
|
public abstract class GrowableItemInfo : BaseGameItemInfo
|
||||||
{
|
{
|
||||||
public bool IsLocked { get; set; }
|
public bool IsLocked { get; set; }
|
||||||
public uint Level { get; set; }
|
public new uint Level { get; set; }
|
||||||
public uint Exp { get; set; }
|
public new uint Exp { get; set; }
|
||||||
public uint Break { get; set; }
|
public uint Break { get; set; }
|
||||||
|
public uint Evolue { get; set; }
|
||||||
public uint EquipAvatarId { get; set; }
|
public uint EquipAvatarId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,14 +74,16 @@ public class GameWeaponInfo : GrowableItemInfo
|
|||||||
{
|
{
|
||||||
Level = Level,
|
Level = Level,
|
||||||
Exp = Exp,
|
Exp = Exp,
|
||||||
Break = Break
|
Break = Break,
|
||||||
|
Evolue = Evolue
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
}public class GameSkinInfo : BaseGameItemInfo
|
}
|
||||||
|
public class GameSkinInfo : BaseGameItemInfo
|
||||||
{
|
{
|
||||||
public uint Level { get; set; }
|
public uint SkinType { get; set; }
|
||||||
public override Item ToProto()
|
public override Item ToProto()
|
||||||
{
|
{
|
||||||
var proto = new Item
|
var proto = new Item
|
||||||
@@ -79,6 +93,30 @@ public class GameWeaponInfo : GrowableItemInfo
|
|||||||
Count = ItemCount,
|
Count = ItemCount,
|
||||||
Flag = (uint)Flag,
|
Flag = (uint)Flag,
|
||||||
};
|
};
|
||||||
|
proto.Slots[11] = Math.Min(SkinType, 1);
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class GameSupportCardInfo : BaseGameItemInfo
|
||||||
|
{
|
||||||
|
public uint AffixId { get; set; }
|
||||||
|
public override Item ToProto()
|
||||||
|
{
|
||||||
|
var proto = new Item
|
||||||
|
{
|
||||||
|
Id = UniqueId,
|
||||||
|
Template = TemplateId,
|
||||||
|
Count = ItemCount,
|
||||||
|
Flag = (uint)Flag,
|
||||||
|
Enhance = new Enhance
|
||||||
|
{
|
||||||
|
Level = Level,
|
||||||
|
Exp = Exp
|
||||||
|
}
|
||||||
|
};
|
||||||
|
proto.Slots[1] = AffixId;
|
||||||
|
return proto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ namespace MikuSB.Database.Player;
|
|||||||
[SugarTable("Player")]
|
[SugarTable("Player")]
|
||||||
public class PlayerGameData : BaseDatabaseDataHelper
|
public class PlayerGameData : BaseDatabaseDataHelper
|
||||||
{
|
{
|
||||||
|
public const string DefaultDisplayName = "Miku";
|
||||||
|
|
||||||
public string? Name { get; set; } = "";
|
public string? Name { get; set; } = "";
|
||||||
public string? Signature { get; set; } = "MikuPS";
|
public string? Signature { get; set; } = "MikuPS";
|
||||||
public uint Level { get; set; } = 100;
|
public uint Level { get; set; } = 100;
|
||||||
@@ -16,6 +18,7 @@ public class PlayerGameData : BaseDatabaseDataHelper
|
|||||||
public Sex Gender { get; set; } = Sex.Female;
|
public Sex Gender { get; set; } = Sex.Female;
|
||||||
public uint Vigor { get; set; } = 240;
|
public uint Vigor { get; set; } = 240;
|
||||||
[SugarColumn(IsJson = true)] public List<PlayerAttr> Attrs { get; set; } = [];
|
[SugarColumn(IsJson = true)] public List<PlayerAttr> Attrs { get; set; } = [];
|
||||||
|
[SugarColumn(IsJson = true)] public List<PlayerStrAttr> StrAttrs { get; set; } = [];
|
||||||
[SugarColumn(IsJson = true)] public List<ulong> ShowItems { get; set; } = [];
|
[SugarColumn(IsJson = true)] public List<ulong> ShowItems { get; set; } = [];
|
||||||
|
|
||||||
public static PlayerGameData? GetPlayerByUid(long uid)
|
public static PlayerGameData? GetPlayerByUid(long uid)
|
||||||
@@ -24,13 +27,30 @@ public class PlayerGameData : BaseDatabaseDataHelper
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string NormalizeDisplayName(string? name)
|
||||||
|
{
|
||||||
|
var normalized = name?.Trim();
|
||||||
|
return string.IsNullOrWhiteSpace(normalized) ? DefaultDisplayName : normalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool EnsureDisplayName()
|
||||||
|
{
|
||||||
|
var normalized = NormalizeDisplayName(Name);
|
||||||
|
if (string.Equals(Name, normalized, StringComparison.Ordinal))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Name = normalized;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public PlayerProfile ToProfileProto()
|
public PlayerProfile ToProfileProto()
|
||||||
{
|
{
|
||||||
|
var displayName = NormalizeDisplayName(Name);
|
||||||
var proto = new PlayerProfile
|
var proto = new PlayerProfile
|
||||||
{
|
{
|
||||||
Pid = (uint)Uid,
|
Pid = (uint)Uid,
|
||||||
Account = Name,
|
Account = displayName,
|
||||||
Name = Name,
|
Name = displayName,
|
||||||
Level = Level,
|
Level = Level,
|
||||||
Sex = Gender,
|
Sex = Gender,
|
||||||
Sign = Signature,
|
Sign = Signature,
|
||||||
@@ -45,4 +65,11 @@ public class PlayerAttr
|
|||||||
public uint Gid { get; set; }
|
public uint Gid { get; set; }
|
||||||
public uint Sid { get; set; }
|
public uint Sid { get; set; }
|
||||||
public uint Val { get; set; }
|
public uint Val { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PlayerStrAttr
|
||||||
|
{
|
||||||
|
public uint Gid { get; set; }
|
||||||
|
public uint Sid { get; set; }
|
||||||
|
public string Val { get; set; } = "";
|
||||||
}
|
}
|
||||||
@@ -35,6 +35,9 @@ public class ServerTextCHS
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class WordTextCHS
|
public class WordTextCHS
|
||||||
{
|
{
|
||||||
|
public string WeaponSkin => "武器皮肤";
|
||||||
|
public string SupportCard => "支援卡";
|
||||||
|
public string Weapon => "武器";
|
||||||
public string Rank => "星魂";
|
public string Rank => "星魂";
|
||||||
public string Avatar => "角色";
|
public string Avatar => "角色";
|
||||||
public string Material => "材料";
|
public string Material => "材料";
|
||||||
@@ -121,6 +124,7 @@ public class CommandTextCHS
|
|||||||
public HelpTextCHS Help { get; } = new();
|
public HelpTextCHS Help { get; } = new();
|
||||||
public GirlTextCHS Girl { get; } = new();
|
public GirlTextCHS Girl { get; } = new();
|
||||||
public GiveAllTextCHS GiveAll { get; } = new();
|
public GiveAllTextCHS GiveAll { get; } = new();
|
||||||
|
public DebugTextCHS Debug { get; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -218,11 +222,13 @@ public class GirlTextCHS
|
|||||||
|
|
||||||
public string Usage =>
|
public string Usage =>
|
||||||
"用法: /girl add <detail/-1> -p<particular> -l<level> -s<star>\n" +
|
"用法: /girl add <detail/-1> -p<particular> -l<level> -s<star>\n" +
|
||||||
"用法: /girl level <guid/-1> <level>";
|
"用法: /girl level <guid/-1> <level>\n" +
|
||||||
|
"用法: /girl neuronic <guid/-1> <level>";
|
||||||
|
|
||||||
public string NotFound => "角色不存在!";
|
public string NotFound => "角色不存在!";
|
||||||
public string Added => "已为玩家添加 {0} 个角色!";
|
public string Added => "已为玩家添加 {0} 个角色!";
|
||||||
public string UpdateLevel => "已将 {1} 个角色等级设置为 {0}!";
|
public string UpdateLevel => "已将 {1} 个角色等级设置为 {0}!";
|
||||||
|
public string UpdateNeuronicLevel => "已将 {1} 个角色的神经元等级设置为 {0}!";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -230,11 +236,28 @@ public class GirlTextCHS
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class GiveAllTextCHS
|
public class GiveAllTextCHS
|
||||||
{
|
{
|
||||||
public string Desc => "给玩家所有物品\n" +
|
public string Desc => "给予玩家所有物品\n" +
|
||||||
"备注: -1 代表全部";
|
"注意:-1 表示全部";
|
||||||
public string Usage => "用法: /giveall weapon <detail/-1> -p<particular> -l<level>";
|
public string Usage => "用法:/giveall weapon <detail/-1> -p<特定> -l<等級>\n" +
|
||||||
public string WeaponNotFound => "找不到武器!";
|
"用法:/giveall weaponskin <detail/-1> -p<特定>\n" +
|
||||||
public string WeaponAdded => "已添加 {0} 把武器给玩家!";
|
"用法:/giveall card <detail/-1> -p<特定> -l<等級>";
|
||||||
|
public string NotFound => "未找到 {0}!";
|
||||||
|
public string GiveAllItems => "已向玩家添加 {0} 个 {1}!";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// path: Game.Command.Debug
|
||||||
|
/// </summary>
|
||||||
|
public class DebugTextCHS
|
||||||
|
{
|
||||||
|
public string Desc => "调试包输出开关";
|
||||||
|
public string Usage => "用法: /debug [on|off|simple|detail|file]";
|
||||||
|
public string Enabled => "已启用调试包输出。";
|
||||||
|
public string Disabled => "已禁用调试包输出。";
|
||||||
|
public string SimpleEnabled => "已启用简单调试包输出。";
|
||||||
|
public string DetailEnabled => "已启用详细调试包输出。";
|
||||||
|
public string FileEnabled => "个人调试文件输出已启用。";
|
||||||
|
public string FileDisabled => "个人调试文件输出已禁用。";
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ public class ServerTextCHT
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class WordTextCHT
|
public class WordTextCHT
|
||||||
{
|
{
|
||||||
|
public string WeaponSkin => "武器外觀";
|
||||||
|
public string SupportCard => "支援卡";
|
||||||
|
public string Weapon => "武器";
|
||||||
public string Rank => "星魂";
|
public string Rank => "星魂";
|
||||||
public string Avatar => "角色";
|
public string Avatar => "角色";
|
||||||
public string Material => "材料";
|
public string Material => "材料";
|
||||||
@@ -121,6 +124,7 @@ public class CommandTextCHT
|
|||||||
public HelpTextCHT Help { get; } = new();
|
public HelpTextCHT Help { get; } = new();
|
||||||
public GirlTextCHT Girl { get; } = new();
|
public GirlTextCHT Girl { get; } = new();
|
||||||
public GiveAllTextCHT GiveAll { get; } = new();
|
public GiveAllTextCHT GiveAll { get; } = new();
|
||||||
|
public DebugTextCHT Debug { get; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -218,11 +222,13 @@ public class GirlTextCHT
|
|||||||
|
|
||||||
public string Usage =>
|
public string Usage =>
|
||||||
"用法: /girl add <detail/-1> -p<particular> -l<level> -s<star>\n" +
|
"用法: /girl add <detail/-1> -p<particular> -l<level> -s<star>\n" +
|
||||||
"用法: /girl level <guid/-1> <level>";
|
"用法: /girl level <guid/-1> <level>\n" +
|
||||||
|
"用法: /girl neuronic <guid/-1> <level>";
|
||||||
|
|
||||||
public string NotFound => "角色不存在!";
|
public string NotFound => "角色不存在!";
|
||||||
public string Added => "已為玩家新增 {0} 個角色!";
|
public string Added => "已為玩家新增 {0} 個角色!";
|
||||||
public string UpdateLevel => "已將 {1} 個角色等級設為 {0}!";
|
public string UpdateLevel => "已將 {1} 個角色等級設為 {0}!";
|
||||||
|
public string UpdateNeuronicLevel => "已將 {1} 個角色的神經元等級設置為 {0}!";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -230,11 +236,28 @@ public class GirlTextCHT
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class GiveAllTextCHT
|
public class GiveAllTextCHT
|
||||||
{
|
{
|
||||||
public string Desc => "給玩家所有物品\n" +
|
public string Desc => "給予玩家所有物品\n" +
|
||||||
"備註: -1 代表全部";
|
"注意:-1 表示全部";
|
||||||
public string Usage => "用法: /giveall weapon <detail/-1> -p<particular> -l<level>";
|
public string Usage => "用法:/giveall weapon <detail/-1> -p<特定> -l<等級>\n" +
|
||||||
public string WeaponNotFound => "找不到武器!";
|
"用法:/giveall weaponskin <detail/-1> -p<特定>\n" +
|
||||||
public string WeaponAdded => "已添加 {0} 把武器給玩家!";
|
"用法:/giveall card <detail/-1> -p<特定> -l<等級>";
|
||||||
|
public string NotFound => "未找到 {0}!";
|
||||||
|
public string GiveAllItems => "已向玩家添加 {0} 個 {1}!";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// path: Game.Command.Debug
|
||||||
|
/// </summary>
|
||||||
|
public class DebugTextCHT
|
||||||
|
{
|
||||||
|
public string Desc => "切換調試封包輸出";
|
||||||
|
public string Usage => "用法: /debug [on|off|simple|detail|file]";
|
||||||
|
public string Enabled => "已啟用調試封包輸出。";
|
||||||
|
public string Disabled => "已停用調試封包輸出。";
|
||||||
|
public string SimpleEnabled => "已啟用簡易調試封包輸出。";
|
||||||
|
public string DetailEnabled => "已啟用詳細調試封包輸出。";
|
||||||
|
public string FileEnabled => "個人調試檔案輸出已啟用。";
|
||||||
|
public string FileDisabled => "個人調試檔案輸出已停用。";
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ public class ServerTextEN
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class WordTextEN
|
public class WordTextEN
|
||||||
{
|
{
|
||||||
public string Star => "Star";
|
public string WeaponSkin => "Weapon Skin";
|
||||||
public string Valk => "Valkyrie";
|
public string Valk => "Valkyrie";
|
||||||
public string Material => "Material";
|
public string Material => "Material";
|
||||||
public string Stigmata => "Stigmata";
|
public string SupportCard => "Support Card";
|
||||||
public string Weapon => "Weapon";
|
public string Weapon => "Weapon";
|
||||||
public string Banner => "Gacha";
|
public string Banner => "Gacha";
|
||||||
public string Activity => "Activity";
|
public string Activity => "Activity";
|
||||||
@@ -83,6 +83,7 @@ public class CommandTextEN
|
|||||||
public HelpTextEN Help { get; } = new();
|
public HelpTextEN Help { get; } = new();
|
||||||
public GirlTextEN Girl { get; } = new();
|
public GirlTextEN Girl { get; } = new();
|
||||||
public GiveAllTextEN GiveAll { get; } = new();
|
public GiveAllTextEN GiveAll { get; } = new();
|
||||||
|
public DebugTextEN Debug { get; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -187,11 +188,13 @@ public class GirlTextEN
|
|||||||
|
|
||||||
public string Usage =>
|
public string Usage =>
|
||||||
"Usage: /girl add <detail/-1> -p<particular> -l<level> -s<star>\n" +
|
"Usage: /girl add <detail/-1> -p<particular> -l<level> -s<star>\n" +
|
||||||
"Usage: /girl level <guid/-1> <level>";
|
"Usage: /girl level <guid/-1> <level>\n" +
|
||||||
|
"Usage: /girl neuronic <guid/-1> <level>";
|
||||||
|
|
||||||
public string NotFound => "Character not found!";
|
public string NotFound => "Character not found!";
|
||||||
public string Added => "Granted {0} character(s) to player!";
|
public string Added => "Granted {0} character(s) to player!";
|
||||||
public string UpdateLevel => "Set {1} character(s) to level {0}!";
|
public string UpdateLevel => "Set {1} character(s) to level {0}!";
|
||||||
|
public string UpdateNeuronicLevel => "Set {1} character(s) Neuronic to level {0}!";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -201,9 +204,26 @@ public class GiveAllTextEN
|
|||||||
{
|
{
|
||||||
public string Desc => "Give all items to player\n"+
|
public string Desc => "Give all items to player\n"+
|
||||||
"Note: -1 means all";
|
"Note: -1 means all";
|
||||||
public string Usage => "Usage: /giveall weapon <detail/-1> -p<particular> -l<level>";
|
public string Usage => "Usage: /giveall weapon <detail/-1> -p<particular> -l<level>\n" +
|
||||||
public string WeaponNotFound => "Weapon not found!";
|
"Usage: /giveall weaponskin <detail/-1> -p<particular>\n" +
|
||||||
public string WeaponAdded => "Added {0} weapon(s) to player!";
|
"Usage: /giveall card <detail/-1> -p<particular> -l<level>";
|
||||||
|
public string NotFound => "{0} not found!";
|
||||||
|
public string GiveAllItems => "Added {0} {1} to player!";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// path: Game.Command.Debug
|
||||||
|
/// </summary>
|
||||||
|
public class DebugTextEN
|
||||||
|
{
|
||||||
|
public string Desc => "Toggle debug packet output";
|
||||||
|
public string Usage => "Usage: /debug [on|off|simple|detail|file]";
|
||||||
|
public string Enabled => "Debug packet output enabled.";
|
||||||
|
public string Disabled => "Debug packet output disabled.";
|
||||||
|
public string SimpleEnabled => "Simple debug packet output enabled.";
|
||||||
|
public string DetailEnabled => "Detailed debug packet output enabled.";
|
||||||
|
public string FileEnabled => "Personal debug file output enabled.";
|
||||||
|
public string FileDisabled => "Personal debug file output disabled.";
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ public class PlayerCommandSender(PlayerInstance player) : ICommandSender
|
|||||||
Type = ChatType.Friend,
|
Type = ChatType.Friend,
|
||||||
Sender = (uint)ConfigManager.Config.ServerOption.ServerProfile.Uid,
|
Sender = (uint)ConfigManager.Config.ServerOption.ServerProfile.Uid,
|
||||||
Recver = (uint)Player.Uid,
|
Recver = (uint)Player.Uid,
|
||||||
Text = msg,
|
Text = ChatMessageHelper.NormalizeForClient(msg),
|
||||||
Profile = Player.ToServerFriendProto(),
|
Profile = Player.ToServerFriendProto(),
|
||||||
TimeStamp = (uint)Extensions.GetUnixMs()
|
TimeStamp = ChatMessageHelper.BuildClientTimestamp()
|
||||||
};
|
};
|
||||||
await Player.SendPacket(CmdIds.NtfFriendChat, data);
|
await Player.SendPacket(CmdIds.NtfFriendChat, data);
|
||||||
}
|
}
|
||||||
|
|||||||
69
GameServer/Command/Commands/CommandDebug.cs
Normal file
69
GameServer/Command/Commands/CommandDebug.cs
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
using MikuSB.Configuration;
|
||||||
|
using MikuSB.Enums.Player;
|
||||||
|
using MikuSB.Util;
|
||||||
|
using MikuSB.Internationalization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Command.Commands;
|
||||||
|
|
||||||
|
[CommandInfo("debug", "Game.Command.Debug.Desc", "Game.Command.Debug.Usage", ["dbg"], [PermEnum.Admin, PermEnum.Support])]
|
||||||
|
public class CommandDebug : ICommands
|
||||||
|
{
|
||||||
|
private static readonly Logger Logger = new("CommandManager");
|
||||||
|
|
||||||
|
[CommandDefault]
|
||||||
|
public async ValueTask ToggleDebug(CommandArg arg)
|
||||||
|
{
|
||||||
|
var option = arg.Args.FirstOrDefault()?.ToLowerInvariant() ?? "on";
|
||||||
|
var serverOption = ConfigManager.Config.ServerOption;
|
||||||
|
var message = option switch
|
||||||
|
{
|
||||||
|
"on" => EnableDebug(serverOption),
|
||||||
|
"off" => DisableDebug(serverOption),
|
||||||
|
"simple" => EnableSimpleDebug(serverOption),
|
||||||
|
"detail" => EnableDetailDebug(serverOption),
|
||||||
|
"file" => ToggleDebugFile(serverOption),
|
||||||
|
_ => I18NManager.Translate("Game.Command.Debug.Usage")
|
||||||
|
};
|
||||||
|
|
||||||
|
Logger.Info(message);
|
||||||
|
await arg.SendMsg(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string EnableDebug(ServerOption serverOption)
|
||||||
|
{
|
||||||
|
serverOption.EnableDebug = true;
|
||||||
|
serverOption.DebugMessage = true;
|
||||||
|
serverOption.DebugDetailMessage = true;
|
||||||
|
return I18NManager.Translate("Game.Command.Debug.Enabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string DisableDebug(ServerOption serverOption)
|
||||||
|
{
|
||||||
|
serverOption.EnableDebug = false;
|
||||||
|
return I18NManager.Translate("Game.Command.Debug.Disabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string EnableSimpleDebug(ServerOption serverOption)
|
||||||
|
{
|
||||||
|
serverOption.EnableDebug = true;
|
||||||
|
serverOption.DebugMessage = true;
|
||||||
|
serverOption.DebugDetailMessage = false;
|
||||||
|
return I18NManager.Translate("Game.Command.Debug.SimpleEnabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string EnableDetailDebug(ServerOption serverOption)
|
||||||
|
{
|
||||||
|
serverOption.EnableDebug = true;
|
||||||
|
serverOption.DebugMessage = true;
|
||||||
|
serverOption.DebugDetailMessage = true;
|
||||||
|
return I18NManager.Translate("Game.Command.Debug.DetailEnabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ToggleDebugFile(ServerOption serverOption)
|
||||||
|
{
|
||||||
|
serverOption.SavePersonalDebugFile = !serverOption.SavePersonalDebugFile;
|
||||||
|
return serverOption.SavePersonalDebugFile
|
||||||
|
? I18NManager.Translate("Game.Command.Debug.FileEnabled")
|
||||||
|
: I18NManager.Translate("Game.Command.Debug.FileDisabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -84,4 +84,49 @@ public class CommandGirl : ICommands
|
|||||||
level.ToString(),
|
level.ToString(),
|
||||||
girls.Count.ToString()));
|
girls.Count.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CommandMethod("neuronic")]
|
||||||
|
public async ValueTask UpdateNeuronicLevel(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckOnlineTarget()) return;
|
||||||
|
if (!await arg.CheckArgCnt(2)) return;
|
||||||
|
|
||||||
|
var guid = arg.GetInt(0);
|
||||||
|
var level = Math.Clamp(arg.GetInt(1), 0, 6);
|
||||||
|
var player = arg.Target!.Player!;
|
||||||
|
List<CharacterInfo> girls = [];
|
||||||
|
|
||||||
|
List<uint> spines = new List<uint>();
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
spines.Add(i < level ? 511u : 0u);
|
||||||
|
|
||||||
|
uint proLevel = (uint)(spines.Count(x => x == 511) / 2);
|
||||||
|
|
||||||
|
if (guid == -1)
|
||||||
|
{
|
||||||
|
foreach (var girl in player.CharacterManager.CharacterData.Characters)
|
||||||
|
{
|
||||||
|
girl.Spines = spines;
|
||||||
|
girl.ProLevel = proLevel;
|
||||||
|
girls.Add(girl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var girl = player.CharacterManager.GetCharacterByGUID((uint)guid);
|
||||||
|
if (girl == null)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Girl.NotFound"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
girl.Spines = spines;
|
||||||
|
girl.ProLevel = proLevel;
|
||||||
|
girls.Add(girl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (girls.Count > 0) await player.SendPacket(new PacketNtfCallScript(girls));
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Girl.UpdateNeuronicLevel",
|
||||||
|
level.ToString(),
|
||||||
|
girls.Count.ToString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ public class CommandGiveAll : ICommands
|
|||||||
if (await arg.GetOption('l') is not int level) return;
|
if (await arg.GetOption('l') is not int level) return;
|
||||||
|
|
||||||
var detail = arg.GetInt(0);
|
var detail = arg.GetInt(0);
|
||||||
level = Math.Clamp(level, 1, 80);
|
level = Math.Clamp(level, 1, 90);
|
||||||
var player = arg.Target!.Player!;
|
var player = arg.Target!.Player!;
|
||||||
List<GameWeaponInfo> weapons = [];
|
List<GameWeaponInfo> weapons = [];
|
||||||
if (detail == -1)
|
if (detail == -1)
|
||||||
@@ -36,12 +36,82 @@ public class CommandGiveAll : ICommands
|
|||||||
var weapon = await player.InventoryManager!.AddWeaponItem(ItemTypeEnum.TYPE_WEAPON, (uint)detail,(uint)particular,1,(uint)level,false);
|
var weapon = await player.InventoryManager!.AddWeaponItem(ItemTypeEnum.TYPE_WEAPON, (uint)detail,(uint)particular,1,(uint)level,false);
|
||||||
if (weapon == null)
|
if (weapon == null)
|
||||||
{
|
{
|
||||||
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.WeaponNotFound"));
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.NotFound", I18NManager.Translate("Word.Weapon")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
weapons.Add(weapon);
|
weapons.Add(weapon);
|
||||||
}
|
}
|
||||||
if (weapons.Count > 0) await player.SendPacket(new PacketNtfCallScript(weapons));
|
if (weapons.Count > 0) await player.SendPacket(new PacketNtfCallScript(weapons));
|
||||||
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.WeaponAdded", weapons.Count.ToString()));
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
||||||
|
I18NManager.Translate("Word.Weapon"), weapons.Count.ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandMethod("card")]
|
||||||
|
public async ValueTask GiveAllSupportCard(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckOnlineTarget()) return;
|
||||||
|
if (await arg.GetOption('p') is not int particular) return;
|
||||||
|
if (await arg.GetOption('l') is not int level) return;
|
||||||
|
|
||||||
|
var detail = arg.GetInt(0);
|
||||||
|
var player = arg.Target!.Player!;
|
||||||
|
List<GameSupportCardInfo> supportCards = [];
|
||||||
|
if (detail == -1)
|
||||||
|
{
|
||||||
|
// add all
|
||||||
|
foreach (var config in GameData.SupportCardData)
|
||||||
|
{
|
||||||
|
var supportCard = await player.InventoryManager!
|
||||||
|
.AddSupportCardItem(config.Detail, config.Particular, config.Level, (uint)level, false);
|
||||||
|
if (supportCard != null) supportCards.Add(supportCard);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var supportCard = await player.InventoryManager!.AddSupportCardItem((uint)detail, (uint)particular, 1, (uint)level, false);
|
||||||
|
if (supportCard == null)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.NotFound", I18NManager.Translate("Word.SupportCard")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
supportCards.Add(supportCard);
|
||||||
|
}
|
||||||
|
if (supportCards.Count > 0) await player.SendPacket(new PacketNtfCallScript(supportCards));
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
||||||
|
I18NManager.Translate("Word.SupportCard"), supportCards.Count.ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandMethod("weaponskin")]
|
||||||
|
public async ValueTask GiveAllWeaponSkin(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckOnlineTarget()) return;
|
||||||
|
if (await arg.GetOption('p') is not int particular) return;
|
||||||
|
|
||||||
|
var detail = arg.GetInt(0);
|
||||||
|
var player = arg.Target!.Player!;
|
||||||
|
List<BaseGameItemInfo> weaponSkins = [];
|
||||||
|
if (detail == -1)
|
||||||
|
{
|
||||||
|
// add all
|
||||||
|
foreach (var config in GameData.WeaponSkinData.Values)
|
||||||
|
{
|
||||||
|
var weaponSkin = await player.InventoryManager!
|
||||||
|
.AddWeaponSkinItem((ItemTypeEnum)config.Genre, config.Detail, config.Particular, 1, false);
|
||||||
|
if (weaponSkin != null) weaponSkins.Add(weaponSkin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var weaponSkin = await player.InventoryManager!.AddWeaponSkinItem(ItemTypeEnum.TYPE_WEAPON, (uint)detail, (uint)particular, 1, false);
|
||||||
|
if (weaponSkin == null)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.NotFound", I18NManager.Translate("Word.WeaponSkin")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
weaponSkins.Add(weaponSkin);
|
||||||
|
}
|
||||||
|
if (weaponSkins.Count > 0) await player.SendPacket(new PacketNtfCallScript(weaponSkins));
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
||||||
|
I18NManager.Translate("Word.WeaponSkin"), weaponSkins.Count.ToString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ public class CharacterManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
var weaponInfo = await Player.InventoryManager!.AddWeaponItem((ItemTypeEnum)CharacterExcel.DefaultWeaponGPDL[0], CharacterExcel.DefaultWeaponGPDL[1], CharacterExcel.DefaultWeaponGPDL[2], CharacterExcel.DefaultWeaponGPDL[3],sendPacket:false);
|
var weaponInfo = await Player.InventoryManager!.AddWeaponItem((ItemTypeEnum)CharacterExcel.DefaultWeaponGPDL[0], CharacterExcel.DefaultWeaponGPDL[1], CharacterExcel.DefaultWeaponGPDL[2], CharacterExcel.DefaultWeaponGPDL[3],sendPacket:false);
|
||||||
if (weaponInfo != null) character.WeaponUniqueId = weaponInfo.UniqueId;
|
if (weaponInfo != null) character.WeaponUniqueId = weaponInfo.UniqueId;
|
||||||
|
|
||||||
var skinInfo = Player.InventoryManager!.GetNormalItemGDPL(ItemTypeEnum.TYPE_CARD_SKIN, detail, particular, level)
|
var skinInfo = Player.InventoryManager!.GetSkinItemGDPL(ItemTypeEnum.TYPE_CARD_SKIN, detail, particular, level)
|
||||||
?? await Player.InventoryManager!.AddSkinItem(ItemTypeEnum.TYPE_CARD_SKIN, detail, particular, level, false);
|
?? await Player.InventoryManager!.AddSkinItem(ItemTypeEnum.TYPE_CARD_SKIN, detail, particular, level, false);
|
||||||
if (skinInfo != null) character.SkinId = skinInfo.UniqueId;
|
if (skinInfo != null) character.SkinId = skinInfo.UniqueId;
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
TemplateId = templateId,
|
TemplateId = templateId,
|
||||||
UniqueId = InventoryData.NextUniqueUid++,
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
Level = weaponLevel,
|
Level = weaponLevel,
|
||||||
Break = weaponData.InitBreak,
|
Break = GetWeaponBreak(weaponLevel),
|
||||||
ItemType = ItemTypeEnum.TYPE_WEAPON,
|
ItemType = ItemTypeEnum.TYPE_WEAPON,
|
||||||
ItemCount = 1
|
ItemCount = 1
|
||||||
};
|
};
|
||||||
@@ -35,6 +35,17 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
return weaponInfo;
|
return weaponInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static uint GetWeaponBreak(uint level)
|
||||||
|
{
|
||||||
|
if (level <= 20) return 1;
|
||||||
|
if (level <= 40) return 2;
|
||||||
|
if (level <= 60) return 3;
|
||||||
|
if (level <= 70) return 4;
|
||||||
|
if (level <= 80) return 5;
|
||||||
|
if (level <= 90) return 6;
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
|
||||||
public GameWeaponInfo? GetWeaponItem(uint uniqueId)
|
public GameWeaponInfo? GetWeaponItem(uint uniqueId)
|
||||||
{
|
{
|
||||||
return InventoryData.Weapons.GetValueOrDefault(uniqueId);
|
return InventoryData.Weapons.GetValueOrDefault(uniqueId);
|
||||||
@@ -51,27 +62,43 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
return InventoryData.Weapons.Values.FirstOrDefault(x => x.TemplateId == templateId);
|
return InventoryData.Weapons.Values.FirstOrDefault(x => x.TemplateId == templateId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async ValueTask<BaseGameItemInfo?> AddSkinItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
public async ValueTask<GameSkinInfo?> AddSkinItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
||||||
{
|
{
|
||||||
if (genre != ItemTypeEnum.TYPE_CARD_SKIN) return null;
|
if (genre != ItemTypeEnum.TYPE_CARD_SKIN) return null;
|
||||||
var skinData = GameData.CardSkinData.Values.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level);
|
var skinData = GameData.CardSkinData.Values.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level);
|
||||||
if (skinData == null) return null;
|
if (skinData == null) return null;
|
||||||
|
|
||||||
var templateId = GameResourceTemplateId.FromGdpl((uint)genre,detail,particular,level);
|
var templateId = GameResourceTemplateId.FromGdpl((uint)genre,detail,particular,level);
|
||||||
var skinInfo = new BaseGameItemInfo
|
var skinInfo = new GameSkinInfo
|
||||||
{
|
{
|
||||||
TemplateId = templateId,
|
TemplateId = templateId,
|
||||||
UniqueId = InventoryData.NextUniqueUid++,
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
ItemType = ItemTypeEnum.TYPE_CARD_SKIN,
|
ItemType = ItemTypeEnum.TYPE_CARD_SKIN,
|
||||||
ItemCount = 1
|
ItemCount = 1
|
||||||
};
|
};
|
||||||
InventoryData.Items[skinInfo.UniqueId] = skinInfo;
|
InventoryData.Skins[skinInfo.UniqueId] = skinInfo;
|
||||||
|
|
||||||
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([skinInfo]));
|
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([skinInfo]));
|
||||||
|
|
||||||
return skinInfo;
|
return skinInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameSkinInfo? GetSkinItem(uint uniqueId)
|
||||||
|
{
|
||||||
|
return InventoryData.Skins.GetValueOrDefault(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameSkinInfo? GetSkinItemByTemplateId(ulong templateId)
|
||||||
|
{
|
||||||
|
return InventoryData.Skins.Values.FirstOrDefault(x => x.TemplateId == templateId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameSkinInfo? GetSkinItemGDPL(ItemTypeEnum genre, uint detail, uint particular, uint level)
|
||||||
|
{
|
||||||
|
var templateId = GameResourceTemplateId.FromGdpl((uint)genre, detail, particular, level);
|
||||||
|
return InventoryData.Skins.Values.FirstOrDefault(x => x.TemplateId == templateId);
|
||||||
|
}
|
||||||
|
|
||||||
public async ValueTask<BaseGameItemInfo?> AddArItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
public async ValueTask<BaseGameItemInfo?> AddArItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
||||||
{
|
{
|
||||||
if (genre != ItemTypeEnum.TYPE_AR) return null;
|
if (genre != ItemTypeEnum.TYPE_AR) return null;
|
||||||
@@ -94,6 +121,44 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
return arInfo;
|
return arInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async ValueTask<GameSupportCardInfo?> AddSupportCardItem(uint detail, uint particular, uint level = 1, uint cardLevel = 1, bool sendPacket = true)
|
||||||
|
{
|
||||||
|
const ItemTypeEnum genre = ItemTypeEnum.TYPE_SUPPORT;
|
||||||
|
var spCard = GameData.SupportCardData.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level);
|
||||||
|
if (spCard == null) return null;
|
||||||
|
var templateId = GameResourceTemplateId.FromGdpl((uint)genre, detail, particular, level);
|
||||||
|
cardLevel = Math.Clamp(cardLevel, 1, spCard.MaxLevel);
|
||||||
|
var info = new GameSupportCardInfo
|
||||||
|
{
|
||||||
|
TemplateId = templateId,
|
||||||
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
|
ItemType = genre,
|
||||||
|
ItemCount = 1,
|
||||||
|
Level = cardLevel,
|
||||||
|
};
|
||||||
|
InventoryData.SupportCards[info.UniqueId] = info;
|
||||||
|
|
||||||
|
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([info]));
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameSupportCardInfo? GetSupportCardItem(uint uniqueId)
|
||||||
|
{
|
||||||
|
return InventoryData.SupportCards.GetValueOrDefault(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameSupportCardInfo? GetSupportCardByTemplateId(ulong templateId)
|
||||||
|
{
|
||||||
|
return InventoryData.SupportCards.Values.FirstOrDefault(x => x.TemplateId == templateId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameSupportCardInfo? GetSupportCardItemGDPL(ItemTypeEnum genre, uint detail, uint particular, uint level)
|
||||||
|
{
|
||||||
|
var templateId = GameResourceTemplateId.FromGdpl((uint)genre, detail, particular, level);
|
||||||
|
return InventoryData.SupportCards.Values.FirstOrDefault(x => x.TemplateId == templateId);
|
||||||
|
}
|
||||||
|
|
||||||
public async ValueTask<BaseGameItemInfo?> AddManifestationItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
public async ValueTask<BaseGameItemInfo?> AddManifestationItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
||||||
{
|
{
|
||||||
if (genre != ItemTypeEnum.TYPE_MANIFESTATION) return null;
|
if (genre != ItemTypeEnum.TYPE_MANIFESTATION) return null;
|
||||||
@@ -162,4 +227,26 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
|
|
||||||
return itemInfo;
|
return itemInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async ValueTask<BaseGameItemInfo?> AddWeaponSkinItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
||||||
|
{
|
||||||
|
if (genre != ItemTypeEnum.TYPE_WEAPON_SKIN) return null;
|
||||||
|
var skinData = GameData.WeaponSkinData.Values.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level);
|
||||||
|
if (skinData == null) return null;
|
||||||
|
|
||||||
|
var templateId = GameResourceTemplateId.FromGdpl((uint)genre, detail, particular, level);
|
||||||
|
if (InventoryData.Items.Values.Any(x => x.TemplateId == templateId)) return null;
|
||||||
|
var skinInfo = new BaseGameItemInfo
|
||||||
|
{
|
||||||
|
TemplateId = templateId,
|
||||||
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
|
ItemType = ItemTypeEnum.TYPE_WEAPON_SKIN,
|
||||||
|
ItemCount = 1
|
||||||
|
};
|
||||||
|
InventoryData.Items[skinInfo.UniqueId] = skinInfo;
|
||||||
|
|
||||||
|
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([skinInfo]));
|
||||||
|
|
||||||
|
return skinInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
27
GameServer/Game/Player/ChatMessageHelper.cs
Normal file
27
GameServer/Game/Player/ChatMessageHelper.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Game.Player;
|
||||||
|
|
||||||
|
public static partial class ChatMessageHelper
|
||||||
|
{
|
||||||
|
[GeneratedRegex(@"\s+")]
|
||||||
|
private static partial Regex MultiWhitespaceRegex();
|
||||||
|
|
||||||
|
public static uint BuildClientTimestamp()
|
||||||
|
{
|
||||||
|
return (uint)MikuSB.Util.Extensions.Extensions.GetUnixSec();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string NormalizeForClient(string? text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
var normalized = text
|
||||||
|
.Replace("\r\n", " ")
|
||||||
|
.Replace('\r', ' ')
|
||||||
|
.Replace('\n', ' ');
|
||||||
|
|
||||||
|
return MultiWhitespaceRegex().Replace(normalized, " ").Trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,7 +43,7 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
{
|
{
|
||||||
// new player
|
// new player
|
||||||
IsNewPlayer = true;
|
IsNewPlayer = true;
|
||||||
Data.Name = AccountData.GetAccountByUid(uid)?.Username;
|
Data.Name = PlayerGameData.NormalizeDisplayName(AccountData.GetAccountByUid(uid)?.Username);
|
||||||
|
|
||||||
DatabaseHelper.CreateInstance(Data);
|
DatabaseHelper.CreateInstance(Data);
|
||||||
|
|
||||||
@@ -79,34 +79,6 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
|
|
||||||
await LineupManager.UpdateLineup(1, selected[0], selected[1], selected[2],false);
|
await LineupManager.UpdateLineup(1, selected[0], selected[1], selected[2],false);
|
||||||
|
|
||||||
var bootstrapAttrs = BuildLobbyBootstrapAttrs();
|
|
||||||
var existingAttrs = Data.Attrs
|
|
||||||
.ToDictionary(x => (x.Gid, x.Sid));
|
|
||||||
var seenAttrs = new HashSet<(uint Gid, uint Sid)>();
|
|
||||||
|
|
||||||
foreach (var (gid, sid, value) in bootstrapAttrs)
|
|
||||||
{
|
|
||||||
if (!seenAttrs.Add((gid, sid)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (existingAttrs.TryGetValue((gid, sid), out var attr))
|
|
||||||
{
|
|
||||||
if (attr.Val < value)
|
|
||||||
attr.Val = value;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var newAttr = new PlayerAttr
|
|
||||||
{
|
|
||||||
Gid = gid,
|
|
||||||
Sid = sid,
|
|
||||||
Val = value
|
|
||||||
};
|
|
||||||
|
|
||||||
Data.Attrs.Add(newAttr);
|
|
||||||
existingAttrs[(gid, sid)] = newAttr;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
t.Wait();
|
t.Wait();
|
||||||
|
|
||||||
@@ -134,6 +106,7 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
public async ValueTask OnEnterGame()
|
public async ValueTask OnEnterGame()
|
||||||
{
|
{
|
||||||
if (!Initialized) await InitialPlayerManager();
|
if (!Initialized) await InitialPlayerManager();
|
||||||
|
Data.EnsureDisplayName();
|
||||||
await CharacterManager.RepairCharacterWeapons();
|
await CharacterManager.RepairCharacterWeapons();
|
||||||
await EnsureSupplies();
|
await EnsureSupplies();
|
||||||
}
|
}
|
||||||
@@ -187,9 +160,9 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
Sender = sendUid,
|
Sender = sendUid,
|
||||||
Recver = recvUid,
|
Recver = recvUid,
|
||||||
Emoji = emojiId ?? 0,
|
Emoji = emojiId ?? 0,
|
||||||
Text = message ?? "",
|
Text = ChatMessageHelper.NormalizeForClient(message),
|
||||||
Profile = Data.ToProfileProto(),
|
Profile = Data.ToProfileProto(),
|
||||||
TimeStamp = (uint)Extensions.GetUnixMs()
|
TimeStamp = ChatMessageHelper.BuildClientTimestamp()
|
||||||
};
|
};
|
||||||
|
|
||||||
await SendPacket(CmdIds.NtfFriendChat, data);
|
await SendPacket(CmdIds.NtfFriendChat, data);
|
||||||
@@ -225,12 +198,14 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
|
|
||||||
public Proto.Player ToPlayerProto()
|
public Proto.Player ToPlayerProto()
|
||||||
{
|
{
|
||||||
|
BuildPlayerAttr();
|
||||||
|
var displayName = PlayerGameData.NormalizeDisplayName(Data.Name);
|
||||||
var proto = new Proto.Player
|
var proto = new Proto.Player
|
||||||
{
|
{
|
||||||
Pid = (ulong)Data.Uid,
|
Pid = (ulong)Data.Uid,
|
||||||
Account = Data.Name,
|
Account = displayName,
|
||||||
Provider = Data.Name,
|
Provider = displayName,
|
||||||
Name = Data.Name,
|
Name = displayName,
|
||||||
Level = Data.Level,
|
Level = Data.Level,
|
||||||
Sex = Data.Gender,
|
Sex = Data.Gender,
|
||||||
Vigor = Data.Vigor,
|
Vigor = Data.Vigor,
|
||||||
@@ -259,6 +234,11 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetDisplayName(string? name)
|
||||||
|
{
|
||||||
|
Data.Name = PlayerGameData.NormalizeDisplayName(name);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetShowItem(int index, ulong itemId)
|
public void SetShowItem(int index, ulong itemId)
|
||||||
{
|
{
|
||||||
if (index <= 0)
|
if (index <= 0)
|
||||||
@@ -286,6 +266,38 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
return (gid << 16) | sid;
|
return (gid << 16) | sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void BuildPlayerAttr()
|
||||||
|
{
|
||||||
|
var bootstrapAttrs = BuildLobbyBootstrapAttrs();
|
||||||
|
var existingAttrs = Data.Attrs
|
||||||
|
.ToDictionary(x => (x.Gid, x.Sid));
|
||||||
|
var seenAttrs = new HashSet<(uint Gid, uint Sid)>();
|
||||||
|
|
||||||
|
foreach (var (gid, sid, value) in bootstrapAttrs)
|
||||||
|
{
|
||||||
|
if (!seenAttrs.Add((gid, sid)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (existingAttrs.TryGetValue((gid, sid), out var attr))
|
||||||
|
{
|
||||||
|
if (attr.Val < value)
|
||||||
|
attr.Val = value;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var newAttr = new PlayerAttr
|
||||||
|
{
|
||||||
|
Gid = gid,
|
||||||
|
Sid = sid,
|
||||||
|
Val = value
|
||||||
|
};
|
||||||
|
|
||||||
|
Data.Attrs.Add(newAttr);
|
||||||
|
existingAttrs[(gid, sid)] = newAttr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static IEnumerable<(uint Gid, uint Sid, uint Value)> BuildLobbyBootstrapAttrs()
|
private static IEnumerable<(uint Gid, uint Sid, uint Value)> BuildLobbyBootstrapAttrs()
|
||||||
{
|
{
|
||||||
// GuideLogic uses group 4. Value 999 is safely above every configured step count,
|
// GuideLogic uses group 4. Value 999 is safely above every configured step count,
|
||||||
@@ -330,6 +342,12 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
yield return (22, levelId, 1_700_000_000);
|
yield return (22, levelId, 1_700_000_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var levelId in GameData.DailyLevelData.Keys)
|
||||||
|
{
|
||||||
|
yield return (21, levelId, 7);
|
||||||
|
yield return (22, levelId, 1_700_000_000);
|
||||||
|
}
|
||||||
|
|
||||||
// Main Scene 0 mean default scene
|
// Main Scene 0 mean default scene
|
||||||
yield return (132, 1, 0);
|
yield return (132, 1, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.Daily;
|
||||||
|
|
||||||
|
[CallGSApi("Daily_SetSelectSuit")]
|
||||||
|
public class Daily_SetSelectSuit : ICallGSHandler
|
||||||
|
{
|
||||||
|
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var req = JsonSerializer.Deserialize<GirlWeaponSkinParam>(param);
|
||||||
|
if (req == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlWeaponSkin_Change", "{}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var rsp = $"{{\"SuitId\":{req.Suit}}}";
|
||||||
|
await CallGSRouter.SendScript(connection, "Daily_SetSelectSuit", rsp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class GirlWeaponSkinParam
|
||||||
|
{
|
||||||
|
public uint Type { get; set; }
|
||||||
|
public uint Suit { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
using MikuSB.Database;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.Girl;
|
||||||
|
|
||||||
|
[CallGSApi("GirlCard_ProLevelPromote")]
|
||||||
|
public class GirlCard_ProLevelPromote : ICallGSHandler
|
||||||
|
{
|
||||||
|
private const uint MaxProLevel = 3;
|
||||||
|
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var player = connection.Player!;
|
||||||
|
var req = JsonSerializer.Deserialize<ProLevelPromoteParam>(param);
|
||||||
|
if (req == null || req.CardId == 0)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlCard_ProLevelPromote", "{\"sErr\":\"error.BadParam\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var card = player.CharacterManager.GetCharacterByGUID((uint)req.CardId);
|
||||||
|
if (card == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlCard_ProLevelPromote", "{\"sErr\":\"error.BadParam\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (card.ProLevel >= MaxProLevel)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlCard_ProLevelPromote", "{\"sErr\":\"error.BadParam\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
card.ProLevel++;
|
||||||
|
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.CharacterManager.CharacterData);
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
sync.Items.Add(card.ToProto());
|
||||||
|
|
||||||
|
// s2c callback takes no params — return empty arg
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlCard_ProLevelPromote", "{}", sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class ProLevelPromoteParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nID")]
|
||||||
|
public int CardId { get; set; }
|
||||||
|
}
|
||||||
@@ -1,4 +1,10 @@
|
|||||||
using System.Text.Json;
|
using MikuSB.Data;
|
||||||
|
using MikuSB.Database;
|
||||||
|
using MikuSB.Database.Inventory;
|
||||||
|
using MikuSB.Enums.Item;
|
||||||
|
using MikuSB.GameServer.Game.Player;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Text.Json;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
@@ -10,21 +16,83 @@ public class GirlSkin_ChangeSkinType : ICallGSHandler
|
|||||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
{
|
{
|
||||||
var req = JsonSerializer.Deserialize<ChangeSkinTypeParam>(param);
|
var req = JsonSerializer.Deserialize<ChangeSkinTypeParam>(param);
|
||||||
|
var skinType = ClampClientSkinType(req?.Type ?? 0);
|
||||||
var response = new JsonObject
|
var response = new JsonObject
|
||||||
{
|
{
|
||||||
["nType"] = req?.Type ?? 1,
|
["nType"] = skinType,
|
||||||
["nSkinId"] = req?.SkinId
|
["nSkinId"] = req?.SkinId
|
||||||
};
|
};
|
||||||
// TODO change type in proto Item ??
|
if (req == null)
|
||||||
await CallGSRouter.SendScript(connection, "GirlSkin_ChangeSkinType", response.ToJsonString());
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSkin_ChangeSkinType", response.ToJsonString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var player = connection.Player!;
|
||||||
|
var skinData = GetOrCreateSkinItem(player, req.SkinId);
|
||||||
|
if (skinData != null)
|
||||||
|
skinData.SkinType = skinType;
|
||||||
|
|
||||||
|
player.InventoryManager.InventoryData.SkinTypesBySkinId ??= [];
|
||||||
|
player.InventoryManager.InventoryData.SkinTypesBySkinId[req.SkinId] = skinType;
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
|
|
||||||
|
if (skinData == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSkin_ChangeSkinType", response.ToJsonString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer
|
||||||
|
{
|
||||||
|
Items = { skinData.ToProto() }
|
||||||
|
};
|
||||||
|
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSkin_ChangeSkinType", response.ToJsonString(), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static uint ClampClientSkinType(uint skinType)
|
||||||
|
{
|
||||||
|
return Math.Min(skinType, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static GameSkinInfo? GetOrCreateSkinItem(PlayerInstance player, uint skinId)
|
||||||
|
{
|
||||||
|
var inventoryData = player.InventoryManager.InventoryData;
|
||||||
|
if (inventoryData.Skins.TryGetValue(skinId, out var skinInfo))
|
||||||
|
return skinInfo;
|
||||||
|
|
||||||
|
if (!GameData.CardSkinData.TryGetValue(skinId, out var skinData))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var templateId = GameResourceTemplateId.FromGdpl(skinData.Genre, skinData.Detail, skinData.Particular, skinData.Level);
|
||||||
|
skinInfo = player.InventoryManager.GetSkinItemByTemplateId(templateId);
|
||||||
|
if (skinInfo != null)
|
||||||
|
{
|
||||||
|
inventoryData.Skins.Remove(skinInfo.UniqueId);
|
||||||
|
skinInfo.UniqueId = skinId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
skinInfo = new GameSkinInfo
|
||||||
|
{
|
||||||
|
UniqueId = skinId,
|
||||||
|
TemplateId = templateId,
|
||||||
|
ItemType = ItemTypeEnum.TYPE_CARD_SKIN,
|
||||||
|
ItemCount = 1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
inventoryData.Skins[skinId] = skinInfo;
|
||||||
|
return skinInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal sealed class ChangeSkinTypeParam
|
internal sealed class ChangeSkinTypeParam
|
||||||
{
|
{
|
||||||
[JsonPropertyName("nType")]
|
[JsonPropertyName("nType")]
|
||||||
public int? Type { get; set; }
|
public uint Type { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("nSkinId")]
|
[JsonPropertyName("nSkinId")]
|
||||||
public uint? SkinId { get; set; }
|
public uint SkinId { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
182
GameServer/Server/CallGS/Handlers/Girl/GirlSpine_ChildUnLock.cs
Normal file
182
GameServer/Server/CallGS/Handlers/Girl/GirlSpine_ChildUnLock.cs
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
using MikuSB.Data;
|
||||||
|
using MikuSB.Database;
|
||||||
|
using MikuSB.Database.Player;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.Girl;
|
||||||
|
|
||||||
|
// Spine node encoding: (MastIdx << 8) | SubIdx stored as uint in CharacterInfo.Spines
|
||||||
|
// GetStrAttribute(Gid=30, Sid=Detail) stores JSON: { "<Particular>": { "ns": <MastIdx>, "tbn": [0,0], "tbr": [] } }
|
||||||
|
[CallGSApi("GirlSpine_ChildUnLock")]
|
||||||
|
public class GirlSpine_ChildUnLock : ICallGSHandler
|
||||||
|
{
|
||||||
|
private const uint SpineStrAttrGid = 30;
|
||||||
|
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var player = connection.Player!;
|
||||||
|
var req = JsonSerializer.Deserialize<ChildUnLockParam>(param);
|
||||||
|
if (req == null || req.CardId == 0 || req.Info == null || req.Materials == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSpine_ChildUnLock", "{\"sErr\":\"error.BadParam\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var card = player.CharacterManager.GetCharacterByGUID((uint)req.CardId);
|
||||||
|
if (card == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSpine_ChildUnLock", "{\"sErr\":\"error.BadParam\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var mastIdx = req.Info.Indx;
|
||||||
|
var subIdx = req.Info.InSubIdx;
|
||||||
|
if (mastIdx <= 0 || subIdx <= 0)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSpine_ChildUnLock", "{\"sErr\":\"error.BadParam\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spines[MastIdx-1] is a bitmask; bit (SubIdx-1) = 1 means that sub-node is unlocked.
|
||||||
|
// GetSpine(MastIdx, SubIdx) checks (Spines[MastIdx-1] & (1 << (SubIdx-1))) != 0
|
||||||
|
int spineListIdx = mastIdx - 1;
|
||||||
|
uint spineBit = 1u << (subIdx - 1);
|
||||||
|
|
||||||
|
while (card.Spines.Count <= spineListIdx)
|
||||||
|
card.Spines.Add(0);
|
||||||
|
|
||||||
|
if ((card.Spines[spineListIdx] & spineBit) != 0)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSpine_ChildUnLock", "{\"sErr\":\"tip.girlcard_alread_break\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Consume materials
|
||||||
|
var requestedMaterials = new Dictionary<ulong, uint>();
|
||||||
|
foreach (var row in req.Materials)
|
||||||
|
{
|
||||||
|
if (row == null || row.Count < 5) continue;
|
||||||
|
var genre = (uint)Math.Max(0, row[0]);
|
||||||
|
var detail = (uint)Math.Max(0, row[1]);
|
||||||
|
var particular = (uint)Math.Max(0, row[2]);
|
||||||
|
var level = (uint)Math.Max(0, row[3]);
|
||||||
|
var count = (uint)Math.Max(0, row[4]);
|
||||||
|
if (genre == 0 || detail == 0 || particular == 0 || level == 0 || count == 0) continue;
|
||||||
|
var tid = GameResourceTemplateId.FromGdpl(genre, detail, particular, level);
|
||||||
|
requestedMaterials[tid] = requestedMaterials.GetValueOrDefault(tid) + count;
|
||||||
|
}
|
||||||
|
|
||||||
|
var syncItems = new List<Item>();
|
||||||
|
foreach (var (tid, count) in requestedMaterials)
|
||||||
|
{
|
||||||
|
var item = player.InventoryManager.InventoryData.Items.Values.FirstOrDefault(x => x.TemplateId == tid);
|
||||||
|
if (item == null || item.ItemCount < count)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSpine_ChildUnLock", "{\"sErr\":\"tip.not_material\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var (tid, count) in requestedMaterials)
|
||||||
|
{
|
||||||
|
var item = player.InventoryManager.InventoryData.Items.Values.First(x => x.TemplateId == tid);
|
||||||
|
item.ItemCount -= count;
|
||||||
|
var proto = item.ToProto();
|
||||||
|
if (item.ItemCount == 0)
|
||||||
|
{
|
||||||
|
player.InventoryManager.InventoryData.Items.Remove(item.UniqueId);
|
||||||
|
proto.Count = 0;
|
||||||
|
}
|
||||||
|
syncItems.Add(proto);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unlock the spine node by setting the corresponding bit
|
||||||
|
card.Spines[spineListIdx] |= spineBit;
|
||||||
|
syncItems.Add(card.ToProto());
|
||||||
|
|
||||||
|
// Extract Detail and Particular from TemplateId for StrAttr
|
||||||
|
var cardDetail = (uint)((card.TemplateId >> 16) & 0xFFFF);
|
||||||
|
var cardParticular = (uint)((card.TemplateId >> 32) & 0xFFFF);
|
||||||
|
|
||||||
|
// Build and persist StrAttr JSON: { "<particular>": { "ns": mastIdx, "tbn": [0,0], "tbr": [] } }
|
||||||
|
UpdateSpineStrAttr(player.Data, cardDetail, cardParticular, mastIdx);
|
||||||
|
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.CharacterManager.CharacterData);
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.Data);
|
||||||
|
|
||||||
|
// Send NtfSetStrAttr so client's GetStrAttribute(30, Detail) returns fresh data
|
||||||
|
var strAttrData = GetSpineStrAttrJson(player.Data, cardDetail);
|
||||||
|
var ntfStrAttr = new NtfSetStrAttr { Gid = SpineStrAttrGid, Sid = cardDetail, Val = strAttrData };
|
||||||
|
await connection.Player!.SendPacket(CmdIds.NtfSetStrAttr, ntfStrAttr);
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
sync.Items.AddRange(syncItems);
|
||||||
|
|
||||||
|
var rsp = $"{{\"tb\":{{\"D\":{cardDetail},\"pId\":{req.CardId},\"MastIdx\":{mastIdx},\"SubIdx\":{subIdx}}}}}";
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSpine_ChildUnLock", rsp, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void UpdateSpineStrAttr(PlayerGameData data, uint detail, uint particular, int mastIdx)
|
||||||
|
{
|
||||||
|
var existing = data.StrAttrs.FirstOrDefault(x => x.Gid == SpineStrAttrGid && x.Sid == detail);
|
||||||
|
if (existing == null)
|
||||||
|
{
|
||||||
|
existing = new PlayerStrAttr { Gid = SpineStrAttrGid, Sid = detail, Val = "{}" };
|
||||||
|
data.StrAttrs.Add(existing);
|
||||||
|
}
|
||||||
|
|
||||||
|
var root = JsonSerializer.Deserialize<Dictionary<string, SpineStrData>>(existing.Val)
|
||||||
|
?? new Dictionary<string, SpineStrData>();
|
||||||
|
|
||||||
|
var key = particular.ToString();
|
||||||
|
if (!root.TryGetValue(key, out var entry))
|
||||||
|
entry = new SpineStrData();
|
||||||
|
|
||||||
|
entry.Ns = mastIdx;
|
||||||
|
root[key] = entry;
|
||||||
|
|
||||||
|
existing.Val = JsonSerializer.Serialize(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetSpineStrAttrJson(PlayerGameData data, uint detail)
|
||||||
|
{
|
||||||
|
var existing = data.StrAttrs.FirstOrDefault(x => x.Gid == SpineStrAttrGid && x.Sid == detail);
|
||||||
|
return existing?.Val ?? "{}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class ChildUnLockParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("pId")]
|
||||||
|
public int CardId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("tbInfo")]
|
||||||
|
public NodeInfo? Info { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("tbMat")]
|
||||||
|
public List<List<int>> Materials { get; set; } = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class NodeInfo
|
||||||
|
{
|
||||||
|
[JsonPropertyName("Indx")]
|
||||||
|
public int Indx { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("InSubIdx")]
|
||||||
|
public int InSubIdx { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class SpineStrData
|
||||||
|
{
|
||||||
|
[JsonPropertyName("ns")]
|
||||||
|
public int Ns { get; set; } = 0;
|
||||||
|
|
||||||
|
[JsonPropertyName("tbn")]
|
||||||
|
public List<int> Tbn { get; set; } = [0, 0];
|
||||||
|
|
||||||
|
[JsonPropertyName("tbr")]
|
||||||
|
public List<int> Tbr { get; set; } = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
using MikuSB.Data;
|
||||||
|
using MikuSB.Database;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.Girl;
|
||||||
|
|
||||||
|
[CallGSApi("GirlSpine_UnlockNodeOneKey")]
|
||||||
|
public class GirlSpine_UnlockNodeOneKey : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var player = connection.Player!;
|
||||||
|
var req = JsonSerializer.Deserialize<OneKeyUnlockParam>(param);
|
||||||
|
if (req == null || req.CardId == 0 || req.MastIdx <= 0 || req.SubIdxList == null || req.SubIdxList.Count == 0)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSpine_ChildUnLock", "{\"sErr\":\"error.BadParam\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var card = player.CharacterManager.GetCharacterByGUID((uint)req.CardId);
|
||||||
|
if (card == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSpine_ChildUnLock", "{\"sErr\":\"error.BadParam\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look up costs from config: CardExcel → SpineId → SpineExcel → NodeConditionId → NodeConditionExcel
|
||||||
|
var cardTemplateId = card.TemplateId;
|
||||||
|
var cardDetail = (uint)((cardTemplateId >> 16) & 0xFFFF);
|
||||||
|
var cardParticular = (uint)((cardTemplateId >> 32) & 0xFFFF);
|
||||||
|
|
||||||
|
var cardExcel = GameData.CardData.Values.FirstOrDefault(
|
||||||
|
x => x.Detail == cardDetail && x.Particular == cardParticular);
|
||||||
|
|
||||||
|
var requestedMaterials = new Dictionary<ulong, uint>();
|
||||||
|
|
||||||
|
if (cardExcel != null && GameData.SpineData.TryGetValue(cardExcel.SpineId, out var spineExcel))
|
||||||
|
{
|
||||||
|
var nodeCondId = spineExcel.GetNodeReq(req.MastIdx);
|
||||||
|
if (nodeCondId != 0 && GameData.NodeConditionData.TryGetValue(nodeCondId, out var nodeCond))
|
||||||
|
{
|
||||||
|
int spineListIdx = req.MastIdx - 1;
|
||||||
|
while (card.Spines.Count <= spineListIdx) card.Spines.Add(0);
|
||||||
|
var currentMask = card.Spines[spineListIdx];
|
||||||
|
|
||||||
|
foreach (var subIdx in req.SubIdxList)
|
||||||
|
{
|
||||||
|
if (subIdx <= 0) continue;
|
||||||
|
uint bit = 1u << (subIdx - 1);
|
||||||
|
if ((currentMask & bit) != 0) continue; // already unlocked, skip cost
|
||||||
|
|
||||||
|
foreach (var row in nodeCond.GetNodeCost(subIdx))
|
||||||
|
{
|
||||||
|
if (row.Count < 5) continue;
|
||||||
|
var tid = GameResourceTemplateId.FromGdpl(
|
||||||
|
(uint)row[0], (uint)row[1], (uint)row[2], (uint)row[3]);
|
||||||
|
requestedMaterials[tid] = requestedMaterials.GetValueOrDefault(tid) + (uint)row[4];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate materials
|
||||||
|
foreach (var (tid, count) in requestedMaterials)
|
||||||
|
{
|
||||||
|
var item = player.InventoryManager.InventoryData.Items.Values.FirstOrDefault(x => x.TemplateId == tid);
|
||||||
|
if (item == null || item.ItemCount < count)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSpine_ChildUnLock", "{\"sErr\":\"tip.not_material\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Consume materials
|
||||||
|
var syncItems = new List<Item>();
|
||||||
|
foreach (var (tid, count) in requestedMaterials)
|
||||||
|
{
|
||||||
|
var item = player.InventoryManager.InventoryData.Items.Values.First(x => x.TemplateId == tid);
|
||||||
|
item.ItemCount -= count;
|
||||||
|
var proto = item.ToProto();
|
||||||
|
if (item.ItemCount == 0)
|
||||||
|
{
|
||||||
|
player.InventoryManager.InventoryData.Items.Remove(item.UniqueId);
|
||||||
|
proto.Count = 0;
|
||||||
|
}
|
||||||
|
syncItems.Add(proto);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unlock all specified sub-nodes
|
||||||
|
int mastSpineIdx = req.MastIdx - 1;
|
||||||
|
while (card.Spines.Count <= mastSpineIdx) card.Spines.Add(0);
|
||||||
|
foreach (var subIdx in req.SubIdxList)
|
||||||
|
{
|
||||||
|
if (subIdx <= 0) continue;
|
||||||
|
card.Spines[mastSpineIdx] |= 1u << (subIdx - 1);
|
||||||
|
}
|
||||||
|
syncItems.Add(card.ToProto());
|
||||||
|
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.CharacterManager.CharacterData);
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
sync.Items.AddRange(syncItems);
|
||||||
|
|
||||||
|
// No s2c handler exists for GirlSpine_UnlockNodeOneKey — reuse GirlSpine_ChildUnLock
|
||||||
|
// which calls UI.CloseConnection() and triggers OnNerveNodeUp to refresh the UI.
|
||||||
|
var lastSubIdx = req.SubIdxList.Count > 0 ? req.SubIdxList[^1] : 9;
|
||||||
|
var rsp = $"{{\"tb\":{{\"D\":{cardDetail},\"pId\":{req.CardId},\"MastIdx\":{req.MastIdx},\"SubIdx\":{lastSubIdx}}}}}";
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSpine_ChildUnLock", rsp, sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class OneKeyUnlockParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("pId")]
|
||||||
|
public int CardId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("nIdx")]
|
||||||
|
public int MastIdx { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("tbOneKey")]
|
||||||
|
public List<int> SubIdxList { get; set; } = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.Girl;
|
||||||
|
|
||||||
|
[CallGSApi("GirlWeaponSkin_Change")]
|
||||||
|
public class GirlWeaponSkin_Change : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var req = JsonSerializer.Deserialize<GirlWeaponSkinParam>(param);
|
||||||
|
if (req == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlWeaponSkin_Change", "{}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var player = connection.Player!;
|
||||||
|
var cardData = player.CharacterManager.GetCharacterByGUID(req.CardId);
|
||||||
|
if (cardData == null) return;
|
||||||
|
var skinData = player.InventoryManager.GetNormalItem(req.SkinId);
|
||||||
|
if (skinData == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlWeaponSkin_Change", "{\"err\":\"error.BadParam\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cardData.WeaponSkinId = req.SkinId;
|
||||||
|
var sync = new NtfSyncPlayer
|
||||||
|
{
|
||||||
|
Items = { cardData.ToProto() }
|
||||||
|
};
|
||||||
|
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlWeaponSkin_Change", "{}", sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class GirlWeaponSkinParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nCardId")]
|
||||||
|
public uint CardId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("nSkinId")]
|
||||||
|
public uint SkinId { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
using MikuSB.Database;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.SupporterCard;
|
||||||
|
|
||||||
|
[CallGSApi("SupporterCard_Equip")]
|
||||||
|
public class SupporterCard_Equip : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var player = connection.Player!;
|
||||||
|
var req = JsonSerializer.Deserialize<SupporterCardEquipParam>(param);
|
||||||
|
if (req == null || req.CardId == 0 || req.SupportCardUid == 0)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Logistics_Equip", "{}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var card = player.CharacterManager.GetCharacterByGUID((uint)req.CardId);
|
||||||
|
if (card == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Logistics_Equip", "{}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var slot = (uint)req.EqSlot;
|
||||||
|
|
||||||
|
// If an existing card is equipped in this slot and bForce is false, ask for confirmation
|
||||||
|
if (!req.Force && req.CurrentEquippedUid != 0 && card.SupportSlots.TryGetValue(slot, out var existing) && existing != 0)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Logistics_Confirm", "{}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform equip
|
||||||
|
card.SupportSlots[slot] = (uint)req.SupportCardUid;
|
||||||
|
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.CharacterManager.CharacterData);
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
sync.Items.Add(card.ToProto());
|
||||||
|
|
||||||
|
// Req_EquipChange (no Model) → Logistics_Change; Req_Equip (has Model) → Logistics_Equip
|
||||||
|
var responseApi = string.IsNullOrEmpty(req.Model) ? "Logistics_Change" : "Logistics_Equip";
|
||||||
|
await CallGSRouter.SendScript(connection, responseApi, "{}", sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class SupporterCardEquipParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("EqId")]
|
||||||
|
public int CardId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("beEqId")]
|
||||||
|
public int SupportCardUid { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("EqSlot")]
|
||||||
|
public int EqSlot { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("BEqId")]
|
||||||
|
public int CurrentEquippedUid { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("bForce")]
|
||||||
|
public bool Force { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("Model")]
|
||||||
|
public string? Model { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
using MikuSB.Data;
|
||||||
|
using MikuSB.Database;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.SupporterCard;
|
||||||
|
|
||||||
|
[CallGSApi("SupporterCard_Upgrade")]
|
||||||
|
public class SupporterCard_Upgrade : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var player = connection.Player!;
|
||||||
|
var req = JsonSerializer.Deserialize<SupporterCardUpgradeParam>(param);
|
||||||
|
if (req == null || req.SupportCardUid == 0 || req.Materials == null || req.Materials.Count == 0)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Logistics_Upgrade", "{}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var supportCard = player.InventoryManager.InventoryData.Items.GetValueOrDefault((uint)req.SupportCardUid);
|
||||||
|
if (supportCard == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Logistics_Upgrade", "{}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var supportCardExcel = GameData.SupportCardData.FirstOrDefault(x => x.TemplateId == supportCard.TemplateId);
|
||||||
|
var maxLevel = supportCardExcel?.MaxLevel ?? 10;
|
||||||
|
|
||||||
|
// Validate all materials exist with sufficient count
|
||||||
|
foreach (var mat in req.Materials)
|
||||||
|
{
|
||||||
|
var item = player.InventoryManager.InventoryData.Items.GetValueOrDefault((uint)mat.Id);
|
||||||
|
if (item == null || item.ItemCount < mat.Num)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Logistics_Upgrade", "{}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Consume materials and accumulate exp
|
||||||
|
var syncItems = new List<Item>();
|
||||||
|
uint gainedExp = 0;
|
||||||
|
|
||||||
|
foreach (var mat in req.Materials)
|
||||||
|
{
|
||||||
|
var item = player.InventoryManager.InventoryData.Items[(uint)mat.Id];
|
||||||
|
|
||||||
|
// Look up ProvideExp: check SupportCardData first, then SuppliesData
|
||||||
|
uint provideExp = 0;
|
||||||
|
var scExcel = GameData.SupportCardData.FirstOrDefault(x => x.TemplateId == item.TemplateId);
|
||||||
|
if (scExcel != null)
|
||||||
|
provideExp = scExcel.ProvideExp;
|
||||||
|
else if (GameData.SuppliesData.TryGetValue((uint)item.TemplateId, out var supExcel))
|
||||||
|
provideExp = supExcel.ProvideExp;
|
||||||
|
gainedExp += provideExp * (uint)mat.Num;
|
||||||
|
|
||||||
|
item.ItemCount -= (uint)mat.Num;
|
||||||
|
var proto = item.ToProto();
|
||||||
|
if (item.ItemCount == 0)
|
||||||
|
{
|
||||||
|
player.InventoryManager.InventoryData.Items.Remove(item.UniqueId);
|
||||||
|
proto.Count = 0;
|
||||||
|
}
|
||||||
|
syncItems.Add(proto);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply exp and level up
|
||||||
|
supportCard.Exp += gainedExp;
|
||||||
|
while (supportCard.Level < maxLevel)
|
||||||
|
{
|
||||||
|
var expNeeded = GetExpNeeded(supportCard.Level + 1);
|
||||||
|
if (expNeeded == 0 || supportCard.Exp < expNeeded) break;
|
||||||
|
supportCard.Exp -= expNeeded;
|
||||||
|
supportCard.Level++;
|
||||||
|
}
|
||||||
|
if (supportCard.Level >= maxLevel)
|
||||||
|
{
|
||||||
|
supportCard.Exp = 0;
|
||||||
|
supportCard.Level = maxLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
syncItems.Add(supportCard.ToProto());
|
||||||
|
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
sync.Items.AddRange(syncItems);
|
||||||
|
|
||||||
|
await CallGSRouter.SendScript(connection, "Logistics_Upgrade", "{}", sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static uint GetExpNeeded(uint level)
|
||||||
|
{
|
||||||
|
if (GameData.UpgradeExpData.TryGetValue((int)level, out var row))
|
||||||
|
return row.SusNeedExp;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class SupporterCardUpgradeParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("Id")]
|
||||||
|
public int SupportCardUid { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("tbMaterials")]
|
||||||
|
public List<UpgradeMaterial> Materials { get; set; } = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class UpgradeMaterial
|
||||||
|
{
|
||||||
|
[JsonPropertyName("Id")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("Num")]
|
||||||
|
public uint Num { get; set; }
|
||||||
|
}
|
||||||
98
GameServer/Server/CallGS/Handlers/Weapon/Weapon_Break.cs
Normal file
98
GameServer/Server/CallGS/Handlers/Weapon/Weapon_Break.cs
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
using MikuSB.Data;
|
||||||
|
using MikuSB.Database;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.Weapon;
|
||||||
|
|
||||||
|
// s2c: function(sErr) — send "null" on success (json.decode("null") = nil = falsy in Lua)
|
||||||
|
[CallGSApi("Weapon_Break")]
|
||||||
|
public class Weapon_Break : ICallGSHandler
|
||||||
|
{
|
||||||
|
private const uint MaxBreak = 6;
|
||||||
|
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var player = connection.Player!;
|
||||||
|
var req = JsonSerializer.Deserialize<WeaponBreakParam>(param);
|
||||||
|
if (req == null || req.WeaponId == 0)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Weapon_Break", "\"error.BadParam\"");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var weapon = player.InventoryManager.InventoryData.Weapons.GetValueOrDefault((uint)req.WeaponId);
|
||||||
|
if (weapon == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Weapon_Break", "\"error.BadParam\"");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (weapon.Break >= MaxBreak)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Weapon_Break", "\"tip.already_max_break\"");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var nextBreak = weapon.Break + 1;
|
||||||
|
|
||||||
|
// Look up break cost from WeaponExcel → BreakExcel
|
||||||
|
var weaponExcel = GameData.WeaponData.Values.FirstOrDefault(x =>
|
||||||
|
GameResourceTemplateId.FromGdpl(x.Genre, x.Detail, x.Particular, x.Level) == weapon.TemplateId);
|
||||||
|
|
||||||
|
var requestedMaterials = new Dictionary<ulong, uint>();
|
||||||
|
if (weaponExcel != null && GameData.BreakData.TryGetValue(weaponExcel.BreakMatID, out var breakExcel))
|
||||||
|
{
|
||||||
|
foreach (var row in breakExcel.GetItems(nextBreak))
|
||||||
|
{
|
||||||
|
if (row.Count < 5) continue;
|
||||||
|
var tid = GameResourceTemplateId.FromGdpl(
|
||||||
|
(uint)row[0], (uint)row[1], (uint)row[2], (uint)row[3]);
|
||||||
|
requestedMaterials[tid] = requestedMaterials.GetValueOrDefault(tid) + (uint)row[4];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate materials
|
||||||
|
foreach (var (tid, count) in requestedMaterials)
|
||||||
|
{
|
||||||
|
var item = player.InventoryManager.InventoryData.Items.Values.FirstOrDefault(x => x.TemplateId == tid);
|
||||||
|
if (item == null || item.ItemCount < count)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Weapon_Break", "\"tip.not_material_for_break\"");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Consume materials
|
||||||
|
var syncItems = new List<Item>();
|
||||||
|
foreach (var (tid, count) in requestedMaterials)
|
||||||
|
{
|
||||||
|
var item = player.InventoryManager.InventoryData.Items.Values.First(x => x.TemplateId == tid);
|
||||||
|
item.ItemCount -= count;
|
||||||
|
var proto = item.ToProto();
|
||||||
|
if (item.ItemCount == 0)
|
||||||
|
{
|
||||||
|
player.InventoryManager.InventoryData.Items.Remove(item.UniqueId);
|
||||||
|
proto.Count = 0;
|
||||||
|
}
|
||||||
|
syncItems.Add(proto);
|
||||||
|
}
|
||||||
|
|
||||||
|
weapon.Break = nextBreak;
|
||||||
|
syncItems.Add(weapon.ToProto());
|
||||||
|
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
sync.Items.AddRange(syncItems);
|
||||||
|
|
||||||
|
await CallGSRouter.SendScript(connection, "Weapon_Break", "null", sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class WeaponBreakParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("Id")]
|
||||||
|
public int WeaponId { get; set; }
|
||||||
|
}
|
||||||
77
GameServer/Server/CallGS/Handlers/Weapon/Weapon_Evolution.cs
Normal file
77
GameServer/Server/CallGS/Handlers/Weapon/Weapon_Evolution.cs
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
using MikuSB.Database;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.Weapon;
|
||||||
|
|
||||||
|
// s2c: function(sErr) — send "null" on success
|
||||||
|
// Id = target weapon UniqueId
|
||||||
|
// nItemId = material item UniqueId (weapon or supply item to consume)
|
||||||
|
[CallGSApi("Weapon_Evolution")]
|
||||||
|
public class Weapon_Evolution : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var player = connection.Player!;
|
||||||
|
var req = JsonSerializer.Deserialize<WeaponEvolutionParam>(param);
|
||||||
|
if (req == null || req.WeaponId == 0 || req.MaterialId == 0)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Weapon_Evolution", "\"error.BadParam\"");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var weapon = player.InventoryManager.InventoryData.Weapons.GetValueOrDefault((uint)req.WeaponId);
|
||||||
|
if (weapon == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Weapon_Evolution", "\"error.BadParam\"");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var syncItems = new List<Item>();
|
||||||
|
|
||||||
|
// Material can be a weapon or a regular item
|
||||||
|
if (player.InventoryManager.InventoryData.Weapons.TryGetValue((uint)req.MaterialId, out var matWeapon))
|
||||||
|
{
|
||||||
|
player.InventoryManager.InventoryData.Weapons.Remove((uint)req.MaterialId);
|
||||||
|
var removed = matWeapon.ToProto();
|
||||||
|
removed.Count = 0;
|
||||||
|
syncItems.Add(removed);
|
||||||
|
}
|
||||||
|
else if (player.InventoryManager.InventoryData.Items.TryGetValue((uint)req.MaterialId, out var matItem))
|
||||||
|
{
|
||||||
|
matItem.ItemCount--;
|
||||||
|
var proto = matItem.ToProto();
|
||||||
|
if (matItem.ItemCount == 0)
|
||||||
|
{
|
||||||
|
player.InventoryManager.InventoryData.Items.Remove(matItem.UniqueId);
|
||||||
|
proto.Count = 0;
|
||||||
|
}
|
||||||
|
syncItems.Add(proto);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Weapon_Evolution", "\"tip.not_material\"");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
weapon.Evolue++;
|
||||||
|
syncItems.Add(weapon.ToProto());
|
||||||
|
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
sync.Items.AddRange(syncItems);
|
||||||
|
|
||||||
|
await CallGSRouter.SendScript(connection, "Weapon_Evolution", "null", sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class WeaponEvolutionParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("Id")]
|
||||||
|
public int WeaponId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("nItemId")]
|
||||||
|
public int MaterialId { get; set; }
|
||||||
|
}
|
||||||
@@ -4,12 +4,14 @@ using MikuSB.Database.Account;
|
|||||||
using MikuSB.Database.Player;
|
using MikuSB.Database.Player;
|
||||||
using MikuSB.GameServer.Game.Player;
|
using MikuSB.GameServer.Game.Player;
|
||||||
using MikuSB.GameServer.Server.CallGS;
|
using MikuSB.GameServer.Server.CallGS;
|
||||||
|
using MikuSB.GameServer.Server.CallGS.Handlers.Girl;
|
||||||
using MikuSB.GameServer.Server.Packet.Send.Friend;
|
using MikuSB.GameServer.Server.Packet.Send.Friend;
|
||||||
using MikuSB.GameServer.Server.Packet.Send.Login;
|
using MikuSB.GameServer.Server.Packet.Send.Login;
|
||||||
using MikuSB.GameServer.Server.Packet.Send.Misc;
|
using MikuSB.GameServer.Server.Packet.Send.Misc;
|
||||||
using MikuSB.Proto;
|
using MikuSB.Proto;
|
||||||
using MikuSB.TcpSharp;
|
using MikuSB.TcpSharp;
|
||||||
using MikuSB.Util;
|
using MikuSB.Util;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Server.Packet.Recv.Login;
|
namespace MikuSB.GameServer.Server.Packet.Recv.Login;
|
||||||
|
|
||||||
@@ -43,6 +45,8 @@ public class HandlerReqLogin : Handler
|
|||||||
connection.State = SessionStateEnum.WAITING_FOR_LOGIN;
|
connection.State = SessionStateEnum.WAITING_FOR_LOGIN;
|
||||||
var pd = DatabaseHelper.GetInstance<PlayerGameData>(account.Uid);
|
var pd = DatabaseHelper.GetInstance<PlayerGameData>(account.Uid);
|
||||||
connection.Player = pd == null ? new PlayerInstance(account.Uid) : new PlayerInstance(pd);
|
connection.Player = pd == null ? new PlayerInstance(account.Uid) : new PlayerInstance(pd);
|
||||||
|
if (connection.Player.Data.EnsureDisplayName())
|
||||||
|
DatabaseHelper.UpdateInstance(connection.Player.Data);
|
||||||
|
|
||||||
connection.DebugFile = Path.Combine(ConfigManager.Config.Path.LogPath, "Debug/", $"{account.Uid}/",
|
connection.DebugFile = Path.Combine(ConfigManager.Config.Path.LogPath, "Debug/", $"{account.Uid}/",
|
||||||
$"Debug-{DateTime.Now:yyyy-MM-dd HH-mm-ss}.log");
|
$"Debug-{DateTime.Now:yyyy-MM-dd HH-mm-ss}.log");
|
||||||
@@ -52,6 +56,66 @@ public class HandlerReqLogin : Handler
|
|||||||
|
|
||||||
await connection.Player.OnHeartBeat();
|
await connection.Player.OnHeartBeat();
|
||||||
await connection.SendPacket(new PacketNtfUpdateFriend(connection.Player!));
|
await connection.SendPacket(new PacketNtfUpdateFriend(connection.Player!));
|
||||||
|
ApplySavedGirlSkinTypes(connection.Player!);
|
||||||
await connection.SendPacket(new PacketNtfCallScript(connection.Player!.InventoryManager.InventoryData));
|
await connection.SendPacket(new PacketNtfCallScript(connection.Player!.InventoryManager.InventoryData));
|
||||||
|
await SendGirlSkinTypeOnLogin(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ApplySavedGirlSkinTypes(PlayerInstance player)
|
||||||
|
{
|
||||||
|
var inventoryData = player.InventoryManager.InventoryData;
|
||||||
|
inventoryData.SkinTypesBySkinId ??= [];
|
||||||
|
var changed = false;
|
||||||
|
|
||||||
|
foreach (var (skinId, skinType) in inventoryData.SkinTypesBySkinId.ToArray())
|
||||||
|
{
|
||||||
|
var clamped = GirlSkin_ChangeSkinType.ClampClientSkinType(skinType);
|
||||||
|
if (clamped != skinType)
|
||||||
|
{
|
||||||
|
inventoryData.SkinTypesBySkinId[skinId] = clamped;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var skinData = GirlSkin_ChangeSkinType.GetOrCreateSkinItem(player, skinId);
|
||||||
|
if (skinData != null && skinData.SkinType != clamped)
|
||||||
|
{
|
||||||
|
skinData.SkinType = clamped;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
DatabaseHelper.SaveDatabaseType(inventoryData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task SendGirlSkinTypeOnLogin(Connection connection)
|
||||||
|
{
|
||||||
|
var player = connection.Player;
|
||||||
|
if (player == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var inventoryData = player.InventoryManager.InventoryData;
|
||||||
|
inventoryData.SkinTypesBySkinId ??= [];
|
||||||
|
foreach (var (skinId, skinType) in inventoryData.SkinTypesBySkinId)
|
||||||
|
{
|
||||||
|
var clamped = GirlSkin_ChangeSkinType.ClampClientSkinType(skinType);
|
||||||
|
var skinData = GirlSkin_ChangeSkinType.GetOrCreateSkinItem(player, skinId);
|
||||||
|
var response = new JsonObject
|
||||||
|
{
|
||||||
|
["nType"] = clamped,
|
||||||
|
["nSkinId"] = skinId
|
||||||
|
};
|
||||||
|
|
||||||
|
if (skinData == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSkin_ChangeSkinType", response.ToJsonString());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlSkin_ChangeSkinType", response.ToJsonString(), new NtfSyncPlayer
|
||||||
|
{
|
||||||
|
Items = { skinData.ToProto() }
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using MikuSB.Proto;
|
using Google.Protobuf;
|
||||||
|
using MikuSB.Database;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Server.Packet.Recv.Login;
|
namespace MikuSB.GameServer.Server.Packet.Recv.Login;
|
||||||
|
|
||||||
@@ -7,6 +9,57 @@ public class HandlerReqRename : Handler
|
|||||||
{
|
{
|
||||||
public override async Task OnHandle(Connection connection, byte[] data, ushort seqNo)
|
public override async Task OnHandle(Connection connection, byte[] data, ushort seqNo)
|
||||||
{
|
{
|
||||||
|
var player = connection.Player;
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
var requestedName = ParseDisplayName(data);
|
||||||
|
player.SetDisplayName(requestedName);
|
||||||
|
DatabaseHelper.UpdateInstance(player.Data);
|
||||||
|
await player.OnHeartBeat();
|
||||||
|
}
|
||||||
|
|
||||||
await connection.SendPacket(CmdIds.RspRename);
|
await connection.SendPacket(CmdIds.RspRename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string? ParseDisplayName(byte[] data)
|
||||||
|
{
|
||||||
|
if (data.Length == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var input = new CodedInputStream(data);
|
||||||
|
while (!input.IsAtEnd)
|
||||||
|
{
|
||||||
|
var tag = input.ReadTag();
|
||||||
|
if (tag == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited)
|
||||||
|
{
|
||||||
|
var value = input.ReadString();
|
||||||
|
if (!string.IsNullOrWhiteSpace(value))
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
input.SkipLastField();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Fall back to raw UTF-8 payload handling below.
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var rawText = System.Text.Encoding.UTF8.GetString(data).Trim('\0', ' ', '\r', '\n', '\t');
|
||||||
|
return string.IsNullOrWhiteSpace(rawText) ? null : rawText;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using MikuSB.Database.Character;
|
using MikuSB.Database.Character;
|
||||||
using MikuSB.Database.Inventory;
|
using MikuSB.Database.Inventory;
|
||||||
using MikuSB.GameServer.Game.Inventory;
|
using MikuSB.GameServer.Game.Player;
|
||||||
using MikuSB.Proto;
|
using MikuSB.Proto;
|
||||||
using MikuSB.TcpSharp;
|
using MikuSB.TcpSharp;
|
||||||
|
|
||||||
@@ -53,6 +53,21 @@ public class PacketNtfCallScript : BasePacket
|
|||||||
SetData(proto);
|
SetData(proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketNtfCallScript(List<GameSupportCardInfo> cards) : base(CmdIds.NtfScript)
|
||||||
|
{
|
||||||
|
var proto = new NtfCallScript
|
||||||
|
{
|
||||||
|
Api = "",
|
||||||
|
Arg = "{}",
|
||||||
|
ExtraSync = new NtfSyncPlayer
|
||||||
|
{
|
||||||
|
Items = { cards.Select(x => x.ToProto()) }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SetData(proto);
|
||||||
|
}
|
||||||
|
|
||||||
public PacketNtfCallScript(InventoryData inventory) : base(CmdIds.NtfScript)
|
public PacketNtfCallScript(InventoryData inventory) : base(CmdIds.NtfScript)
|
||||||
{
|
{
|
||||||
var proto = new NtfCallScript
|
var proto = new NtfCallScript
|
||||||
@@ -63,8 +78,39 @@ public class PacketNtfCallScript : BasePacket
|
|||||||
|
|
||||||
var extraSync = new NtfSyncPlayer();
|
var extraSync = new NtfSyncPlayer();
|
||||||
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 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());
|
||||||
proto.ExtraSync = extraSync;
|
proto.ExtraSync = extraSync;
|
||||||
SetData(proto);
|
SetData(proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketNtfCallScript(PlayerInstance Player) : base(CmdIds.NtfScript)
|
||||||
|
{
|
||||||
|
Player.BuildPlayerAttr();
|
||||||
|
var proto = new NtfCallScript
|
||||||
|
{
|
||||||
|
Api = "",
|
||||||
|
Arg = "{}"
|
||||||
|
};
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
foreach (var x in Player.Data.Attrs)
|
||||||
|
{
|
||||||
|
uint gid = x.Gid;
|
||||||
|
uint sid = x.Sid;
|
||||||
|
uint val = x.Val;
|
||||||
|
|
||||||
|
if (gid == 0)
|
||||||
|
{
|
||||||
|
sync.Custom[sid] = val;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
sync.Custom[Player.ToPackedAttrKey(gid, sid)] = val;
|
||||||
|
sync.Custom[Player.ToShiftedAttrKey(gid, sid)] = val;
|
||||||
|
}
|
||||||
|
proto.ExtraSync = sync;
|
||||||
|
|
||||||
|
SetData(proto);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
Projects="..\MikuSB.Updater\MikuSB.Updater.csproj"
|
Projects="..\MikuSB.Updater\MikuSB.Updater.csproj"
|
||||||
Targets="Restore;Publish"
|
Targets="Restore;Publish"
|
||||||
RemoveProperties="PublishProfile"
|
RemoveProperties="PublishProfile"
|
||||||
Properties="Configuration=$(Configuration);RuntimeIdentifier=$(RuntimeIdentifier);SelfContained=true;PublishSingleFile=true;PublishDir=$(_UpdaterPublishDir)" />
|
Properties="Configuration=$(Configuration);RuntimeIdentifier=$(RuntimeIdentifier);SelfContained=false;PublishSingleFile=true;PublishDir=$(_UpdaterPublishDir)" />
|
||||||
|
|
||||||
<Copy
|
<Copy
|
||||||
SourceFiles="$(_UpdaterPublishDir)MikuSB.Updater.exe"
|
SourceFiles="$(_UpdaterPublishDir)MikuSB.Updater.exe"
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- [.NET SDK 9.0](https://dotnet.microsoft.com/ja-jp/download/dotnet/9.0)
|
- [.NET SDK 9.0](https://dotnet.microsoft.com/en-us/download/dotnet/9.0)
|
||||||
|
|
||||||
## Running
|
## Running
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v=0.9
|
v=1.4
|
||||||
Reference in New Issue
Block a user