mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 15:23:58 +00:00
Compare commits
5 Commits
v3.7
...
1051de8dcf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1051de8dcf | ||
|
|
72126da9a5 | ||
|
|
331d2dbcaa | ||
|
|
85df98c0ae | ||
|
|
a585232045 |
39
Common/Data/Excel/SpecialBreakExcel.cs
Normal file
39
Common/Data/Excel/SpecialBreakExcel.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("item/cardbreak/breaknew.json")]
|
||||||
|
public class SpecialBreakExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public int Id { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("1Items1")] public List<List<int>> Items1 { get; set; } = [];
|
||||||
|
[JsonProperty("2Items1")] public List<List<int>> Items2 { get; set; } = [];
|
||||||
|
[JsonProperty("3Items1")] public List<List<int>> Items3 { get; set; } = [];
|
||||||
|
[JsonProperty("4Items1")] public List<List<int>> Items4 { get; set; } = [];
|
||||||
|
|
||||||
|
public List<List<int>> GetItems(uint breakLevel) => breakLevel switch
|
||||||
|
{
|
||||||
|
1 => Items1,
|
||||||
|
2 => Items2,
|
||||||
|
3 => Items3,
|
||||||
|
4 => Items4,
|
||||||
|
_ => []
|
||||||
|
};
|
||||||
|
|
||||||
|
public bool HasBreakLevel(uint breakLevel) => breakLevel switch
|
||||||
|
{
|
||||||
|
1 => Items1.Count > 0,
|
||||||
|
2 => Items2.Count > 0,
|
||||||
|
3 => Items3.Count > 0,
|
||||||
|
4 => Items4.Count > 0,
|
||||||
|
_ => false
|
||||||
|
};
|
||||||
|
|
||||||
|
public override uint GetId() => (uint)Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.SpecialBreakData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ public static class GameData
|
|||||||
public static Dictionary<uint, Rogue3DTalentExcel> Rogue3DTalentData { get; private set; } = [];
|
public static Dictionary<uint, Rogue3DTalentExcel> Rogue3DTalentData { get; private set; } = [];
|
||||||
public static Dictionary<uint, Rogue3DDailyBuffExcel> Rogue3DDailyBuffData { get; private set; } = [];
|
public static Dictionary<uint, Rogue3DDailyBuffExcel> Rogue3DDailyBuffData { get; private set; } = [];
|
||||||
public static Dictionary<int, BreakExcel> BreakData { get; private set; } = [];
|
public static Dictionary<int, BreakExcel> BreakData { get; private set; } = [];
|
||||||
|
public static Dictionary<int, SpecialBreakExcel> SpecialBreakData { get; private set; } = [];
|
||||||
public static Dictionary<uint, SpineExcel> SpineData { get; private set; } = [];
|
public static Dictionary<uint, SpineExcel> SpineData { get; private set; } = [];
|
||||||
public static Dictionary<uint, NodeConditionExcel> NodeConditionData { get; private set; } = [];
|
public static Dictionary<uint, NodeConditionExcel> NodeConditionData { get; private set; } = [];
|
||||||
public static List<SupportCardExcel> SupportCardData { get; private set; } = [];
|
public static List<SupportCardExcel> SupportCardData { get; private set; } = [];
|
||||||
|
|||||||
@@ -2,16 +2,15 @@ using MikuSB.Data;
|
|||||||
using MikuSB.Data.Excel;
|
using MikuSB.Data.Excel;
|
||||||
using MikuSB.Database.Inventory;
|
using MikuSB.Database.Inventory;
|
||||||
using MikuSB.GameServer.Game.Player;
|
using MikuSB.GameServer.Game.Player;
|
||||||
using MikuSB.GameServer.Server.CallGS;
|
|
||||||
using MikuSB.Proto;
|
using MikuSB.Proto;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
namespace MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
internal static class BossPvpShared
|
internal static class BossPvpService
|
||||||
{
|
{
|
||||||
private const uint GroupId = 51;
|
private const uint GroupId = 51;
|
||||||
private const uint ActivitySubId = 0;
|
private const uint ActivitySubId = 0;
|
||||||
@@ -27,9 +26,8 @@ internal static class BossPvpShared
|
|||||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
|
||||||
};
|
};
|
||||||
|
|
||||||
public static async ValueTask<(object Response, NtfSyncPlayer Sync)> HandleGetOpenIdAsync(Connection connection)
|
public static async ValueTask<(object Response, NtfSyncPlayer Sync)> HandleGetOpenIdAsync(PlayerInstance player)
|
||||||
{
|
{
|
||||||
var player = connection.Player!;
|
|
||||||
await EnsureBossLineupsAsync(player);
|
await EnsureBossLineupsAsync(player);
|
||||||
|
|
||||||
var sync = new NtfSyncPlayer();
|
var sync = new NtfSyncPlayer();
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
[CallGSApi("BossPvpLogic_EnterLevel")]
|
[CallGSApi("BossPvpLogic_EnterLevel")]
|
||||||
@@ -5,7 +7,7 @@ public class BossPvpLogic_EnterLevel : ICallGSHandler
|
|||||||
{
|
{
|
||||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
{
|
{
|
||||||
var response = BossPvpShared.HandleEnterLevel(param);
|
var response = BossPvpService.HandleEnterLevel(param);
|
||||||
await CallGSRouter.SendScript(connection, "BossPvpLogic_EnterLevel", System.Text.Json.JsonSerializer.Serialize(response));
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_EnterLevel", System.Text.Json.JsonSerializer.Serialize(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
[CallGSApi("BossPvpLogic_GetOpenID")]
|
[CallGSApi("BossPvpLogic_GetOpenID")]
|
||||||
@@ -5,7 +7,7 @@ public class BossPvpLogic_GetOpenID : ICallGSHandler
|
|||||||
{
|
{
|
||||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
{
|
{
|
||||||
var (response, sync) = await BossPvpShared.HandleGetOpenIdAsync(connection);
|
var (response, sync) = await BossPvpService.HandleGetOpenIdAsync(connection.Player!);
|
||||||
await CallGSRouter.SendScript(connection, "BossPvpLogic_GetOpenID", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_GetOpenID", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
[CallGSApi("BossPvpLogic_GetReward")]
|
[CallGSApi("BossPvpLogic_GetReward")]
|
||||||
@@ -5,7 +7,7 @@ public class BossPvpLogic_GetReward : ICallGSHandler
|
|||||||
{
|
{
|
||||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
{
|
{
|
||||||
var response = BossPvpShared.HandleGetReward(param);
|
var response = BossPvpService.HandleGetReward(param);
|
||||||
await CallGSRouter.SendScript(connection, "BossPvpLogic_GetReward", System.Text.Json.JsonSerializer.Serialize(response));
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_GetReward", System.Text.Json.JsonSerializer.Serialize(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
[CallGSApi("BossPvpLogic_LevelFail")]
|
[CallGSApi("BossPvpLogic_LevelFail")]
|
||||||
@@ -6,7 +8,7 @@ public class BossPvpLogic_LevelFail : ICallGSHandler
|
|||||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
{
|
{
|
||||||
var node = System.Text.Json.Nodes.JsonNode.Parse(param);
|
var node = System.Text.Json.Nodes.JsonNode.Parse(param);
|
||||||
var (response, sync) = BossPvpShared.HandleFail(connection.Player!, node);
|
var (response, sync) = BossPvpService.HandleFail(connection.Player!, node);
|
||||||
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelFail", response.ToJsonString(), sync);
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelFail", response.ToJsonString(), sync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
[CallGSApi("BossPvpLogic_LevelMopup")]
|
[CallGSApi("BossPvpLogic_LevelMopup")]
|
||||||
@@ -5,7 +7,7 @@ public class BossPvpLogic_LevelMopup : ICallGSHandler
|
|||||||
{
|
{
|
||||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
{
|
{
|
||||||
var (response, sync) = BossPvpShared.HandleMopup(connection.Player!, param);
|
var (response, sync) = BossPvpService.HandleMopup(connection.Player!, param);
|
||||||
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelMopup", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelMopup", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
[CallGSApi("BossPvpLogic_LevelSettlement")]
|
[CallGSApi("BossPvpLogic_LevelSettlement")]
|
||||||
@@ -6,7 +8,7 @@ public class BossPvpLogic_LevelSettlement : ICallGSHandler
|
|||||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
{
|
{
|
||||||
var node = System.Text.Json.Nodes.JsonNode.Parse(param);
|
var node = System.Text.Json.Nodes.JsonNode.Parse(param);
|
||||||
var (response, sync) = BossPvpShared.HandleSettlement(connection.Player!, node);
|
var (response, sync) = BossPvpService.HandleSettlement(connection.Player!, node);
|
||||||
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelSettlement", response.ToJsonString(), sync);
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelSettlement", response.ToJsonString(), sync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
[CallGSApi("BossPvpLogic_Record")]
|
[CallGSApi("BossPvpLogic_Record")]
|
||||||
@@ -5,7 +7,7 @@ public class BossPvpLogic_Record : ICallGSHandler
|
|||||||
{
|
{
|
||||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
{
|
{
|
||||||
var (response, sync) = BossPvpShared.HandleRecord(connection.Player!, param);
|
var (response, sync) = BossPvpService.HandleRecord(connection.Player!, param);
|
||||||
await CallGSRouter.SendScript(connection, "BossPvpLogic_Record", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_Record", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
using MikuSB.Proto;
|
using MikuSB.Proto;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.Chapter;
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.Chapter;
|
||||||
@@ -44,14 +44,14 @@ public class Chapter_DealLevelSettlement : ICallGSHandler
|
|||||||
|
|
||||||
if (string.Equals(sCmd, "BossPvpLogic_LevelSettlement", StringComparison.Ordinal))
|
if (string.Equals(sCmd, "BossPvpLogic_LevelSettlement", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
var (response, sync) = BossPvpShared.HandleSettlement(connection.Player!, tbParam);
|
var (response, sync) = BossPvpService.HandleSettlement(connection.Player!, tbParam);
|
||||||
extraSync = sync;
|
extraSync = sync;
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.Equals(sCmd, "BossPvpLogic_LevelFail", StringComparison.Ordinal))
|
if (string.Equals(sCmd, "BossPvpLogic_LevelFail", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
var (response, sync) = BossPvpShared.HandleFail(connection.Player!, tbParam);
|
var (response, sync) = BossPvpService.HandleFail(connection.Player!, tbParam);
|
||||||
extraSync = sync;
|
extraSync = sync;
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,127 @@
|
|||||||
|
using MikuSB.Data;
|
||||||
|
using MikuSB.Database;
|
||||||
|
using MikuSB.Database.Inventory;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.Girl;
|
||||||
|
|
||||||
|
[CallGSApi("GirlCard_UpBySpecialBreak")]
|
||||||
|
public class GirlCard_UpBySpecialBreak : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var player = connection.Player!;
|
||||||
|
var req = JsonSerializer.Deserialize<GirlCardUpBySpecialBreakParam>(param);
|
||||||
|
if (req == null || req.CardId == 0)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlCard_UpBySpecialBreak", "{\"sErr\":\"error.BadParam\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var card = player.CharacterManager.GetCharacterByGUID((uint)req.CardId);
|
||||||
|
if (card == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlCard_UpBySpecialBreak", "{\"sErr\":\"error.BadParam\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var cardTemplate = GameData.CardData.Values.FirstOrDefault(x =>
|
||||||
|
GameResourceTemplateId.FromGdpl(x.Genre, x.Detail, x.Particular, x.Level) == card.TemplateId);
|
||||||
|
if (cardTemplate == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlCard_UpBySpecialBreak", "{\"sErr\":\"error.BadParam\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cardTemplate.BreakMatID <= 10000 ||
|
||||||
|
!GameData.SpecialBreakData.TryGetValue(cardTemplate.BreakMatID, out var specialBreakExcel))
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlCard_UpBySpecialBreak", "{\"sErr\":\"error.BadParam\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var nextBreak = card.Break + 1;
|
||||||
|
if (!specialBreakExcel.HasBreakLevel(nextBreak))
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlCard_UpBySpecialBreak", "{\"sErr\":\"tip.already_max_break\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var requestedMaterials = new Dictionary<ulong, uint>();
|
||||||
|
foreach (var row in specialBreakExcel.GetItems(nextBreak))
|
||||||
|
{
|
||||||
|
if (row.Count < 5)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var templateId = GameResourceTemplateId.FromGdpl(
|
||||||
|
(uint)Math.Max(0, row[0]),
|
||||||
|
(uint)Math.Max(0, row[1]),
|
||||||
|
(uint)Math.Max(0, row[2]),
|
||||||
|
(uint)Math.Max(0, row[3]));
|
||||||
|
var count = (uint)Math.Max(0, row[4]);
|
||||||
|
if (templateId == 0 || count == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
requestedMaterials[templateId] = requestedMaterials.GetValueOrDefault(templateId) + count;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestedMaterials.Count == 0)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlCard_UpBySpecialBreak", "{\"sErr\":\"tip.not_material_for_break\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var (templateId, count) in requestedMaterials)
|
||||||
|
{
|
||||||
|
var item = player.InventoryManager.InventoryData.Items.Values.FirstOrDefault(x => x.TemplateId == templateId);
|
||||||
|
if (item == null || item.ItemCount < count)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlCard_UpBySpecialBreak", "{\"sErr\":\"tip.not_material_for_break\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var syncItems = new List<Item>();
|
||||||
|
foreach (var (templateId, count) in requestedMaterials)
|
||||||
|
{
|
||||||
|
var item = player.InventoryManager.InventoryData.Items.Values.First(x => x.TemplateId == templateId);
|
||||||
|
item.ItemCount -= count;
|
||||||
|
|
||||||
|
if (item.ItemCount == 0)
|
||||||
|
{
|
||||||
|
player.InventoryManager.InventoryData.Items.Remove(item.UniqueId);
|
||||||
|
syncItems.Add(BuildRemovedProto(item));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
syncItems.Add(item.ToProto());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
card.Break = nextBreak;
|
||||||
|
syncItems.Add(card.ToProto());
|
||||||
|
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.CharacterManager.CharacterData);
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
sync.Items.AddRange(syncItems);
|
||||||
|
|
||||||
|
await CallGSRouter.SendScript(connection, "GirlCard_UpBySpecialBreak", "{}", sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Item BuildRemovedProto(BaseGameItemInfo item)
|
||||||
|
{
|
||||||
|
var proto = item.ToProto();
|
||||||
|
proto.Count = 0;
|
||||||
|
return proto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class GirlCardUpBySpecialBreakParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nCardId")]
|
||||||
|
public int CardId { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
using MikuSB.Data;
|
||||||
|
using MikuSB.Database.Player;
|
||||||
|
using MikuSB.GameServer.Game.Player;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.Rogue3D;
|
||||||
|
|
||||||
|
// Enters the Rogue3D season level. Returns a random seed used by the client for map generation.
|
||||||
|
// Persists SeasonGameplayId (sid=1006) and SeasonEnterFlag (sid=1008) as player attributes (GroupId=124).
|
||||||
|
// param: {"nDiffId", "nTeamID", "tbTeam", "tbBuffList", "tbLog"}
|
||||||
|
// Response: {"nSeed": int} on success, {"sErr": "key"} on failure
|
||||||
|
[CallGSApi("Rogue3D_EnterSeasonLevel")]
|
||||||
|
public class Rogue3D_EnterSeasonLevel : ICallGSHandler
|
||||||
|
{
|
||||||
|
private const uint GroupId = 124;
|
||||||
|
private const uint SeasonGameplayIdSid = 1006;
|
||||||
|
private const uint SeasonEnterFlagSid = 1008;
|
||||||
|
private static readonly Random Random = new();
|
||||||
|
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var req = JsonSerializer.Deserialize<EnterSeasonLevelParam>(param);
|
||||||
|
if (req == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Rogue3D_EnterSeasonLevel", "{\"nSeed\":0}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GameData.Rogue3DDifficultData.TryGetValue(req.DiffId, out var cfg) || cfg.GameplayGroup.Count == 0)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Rogue3D_EnterSeasonLevel", "{\"sErr\":\"rogue3.massage_gameProcessError\"}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var player = connection.Player!;
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
|
||||||
|
SetAttr(player, SeasonGameplayIdSid, cfg.GameplayGroup[0], sync);
|
||||||
|
SetAttr(player, SeasonEnterFlagSid, 1, sync);
|
||||||
|
|
||||||
|
var seed = Random.Next(1, 1_000_000_000);
|
||||||
|
await CallGSRouter.SendScript(connection, "Rogue3D_EnterSeasonLevel", $"{{\"nSeed\":{seed}}}", sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetAttr(PlayerInstance player, uint sid, uint val, NtfSyncPlayer sync)
|
||||||
|
{
|
||||||
|
var attr = player.Data.Attrs.FirstOrDefault(x => x.Gid == GroupId && x.Sid == sid);
|
||||||
|
if (attr == null)
|
||||||
|
{
|
||||||
|
attr = new PlayerAttr { Gid = GroupId, Sid = sid };
|
||||||
|
player.Data.Attrs.Add(attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attr.Val == val)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
attr.Val = val;
|
||||||
|
sync.Custom[player.ToPackedAttrKey(GroupId, sid)] = val;
|
||||||
|
sync.Custom[player.ToShiftedAttrKey(GroupId, sid)] = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class EnterSeasonLevelParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nDiffId")]
|
||||||
|
public uint DiffId { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using MikuSB.Database.Player;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.Rogue3D;
|
||||||
|
|
||||||
|
// Selects the Rogue3D season talent and persists it as player attribute (GroupId=124, TalentId=1007).
|
||||||
|
// param: {"nTalentId": int}
|
||||||
|
// Response: {} on success, {"sErr": "key"} on failure
|
||||||
|
[CallGSApi("Rogue3D_SelectSeasonTalent")]
|
||||||
|
public class Rogue3D_SelectSeasonTalent : ICallGSHandler
|
||||||
|
{
|
||||||
|
private const uint GroupId = 124;
|
||||||
|
private const uint SeasonTalentIdSid = 1007;
|
||||||
|
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var req = JsonSerializer.Deserialize<SelectSeasonTalentParam>(param);
|
||||||
|
if (req == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "Rogue3D_SelectSeasonTalent", "{}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var player = connection.Player!;
|
||||||
|
var attr = player.Data.Attrs.FirstOrDefault(x => x.Gid == GroupId && x.Sid == SeasonTalentIdSid);
|
||||||
|
if (attr == null)
|
||||||
|
{
|
||||||
|
attr = new PlayerAttr { Gid = GroupId, Sid = SeasonTalentIdSid };
|
||||||
|
player.Data.Attrs.Add(attr);
|
||||||
|
}
|
||||||
|
attr.Val = req.TalentId;
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
sync.Custom[player.ToPackedAttrKey(GroupId, SeasonTalentIdSid)] = attr.Val;
|
||||||
|
sync.Custom[player.ToShiftedAttrKey(GroupId, SeasonTalentIdSid)] = attr.Val;
|
||||||
|
|
||||||
|
await CallGSRouter.SendScript(connection, "Rogue3D_SelectSeasonTalent", "{}", sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class SelectSeasonTalentParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nTalentId")]
|
||||||
|
public uint TalentId { get; set; }
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
v=3.7
|
v=3.9
|
||||||
Reference in New Issue
Block a user