mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 18:03:58 +00:00
Compare commits
6 Commits
v3.5
...
331d2dbcaa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
331d2dbcaa | ||
|
|
85df98c0ae | ||
|
|
a585232045 | ||
|
|
125dadd224 | ||
|
|
cfca2f970c | ||
|
|
9a9ae13da0 |
32
Common/Data/Excel/BossPvpBossChallengeExcel.cs
Normal file
32
Common/Data/Excel/BossPvpBossChallengeExcel.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("challenge/bosspvp/boss_challenge.json")]
|
||||||
|
public class BossPvpBossChallengeExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint ID { get; set; }
|
||||||
|
public string StartTime { get; set; } = "";
|
||||||
|
public string EndTime { get; set; } = "";
|
||||||
|
public List<uint> tbTaskID { get; set; } = [];
|
||||||
|
|
||||||
|
[JsonExtensionData] public IDictionary<string, JToken> ExtraData { get; set; } = new Dictionary<string, JToken>();
|
||||||
|
|
||||||
|
[JsonIgnore] public List<uint> BossIds { get; private set; } = [];
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
BossIds = ExtraData
|
||||||
|
.Where(x => x.Key.StartsWith("Boss", StringComparison.Ordinal) && int.TryParse(x.Key[4..], out _))
|
||||||
|
.OrderBy(x => int.Parse(x.Key[4..], CultureInfo.InvariantCulture))
|
||||||
|
.Select(x => x.Value.Type == JTokenType.Integer ? x.Value.Value<uint>() : 0u)
|
||||||
|
.Where(x => x > 0)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
GameData.BossPvpBossChallengeData[ID] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Common/Data/Excel/BossPvpBossExcel.cs
Normal file
17
Common/Data/Excel/BossPvpBossExcel.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("challenge/bosspvp/boss.json")]
|
||||||
|
public class BossPvpBossExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint ID { get; set; }
|
||||||
|
public uint LevelID { get; set; }
|
||||||
|
public uint BossID { get; set; }
|
||||||
|
public List<List<int>> BossLevel { get; set; } = [];
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.BossPvpBossData[ID] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
15
Common/Data/Excel/BossPvpNumExcel.cs
Normal file
15
Common/Data/Excel/BossPvpNumExcel.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("challenge/bosspvp/num.json")]
|
||||||
|
public class BossPvpNumExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint Week { get; set; }
|
||||||
|
public uint Num { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId() => Week;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.BossPvpNumData[Week] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Common/Data/Excel/RoleLevelExcel.cs
Normal file
14
Common/Data/Excel/RoleLevelExcel.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("challenge/role/level.json")]
|
||||||
|
public class RoleLevelExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint ID { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.RoleLevelData[ID] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ public static class GameData
|
|||||||
public static Dictionary<int, BreakLevelLimitExcel> BreakLevelLimitData { get; private set; } = [];
|
public static Dictionary<int, BreakLevelLimitExcel> BreakLevelLimitData { get; private set; } = [];
|
||||||
public static Dictionary<int, RecycleExcel> RecycleData { get; private set; } = [];
|
public static Dictionary<int, RecycleExcel> RecycleData { get; private set; } = [];
|
||||||
public static Dictionary<uint, ChapterLevelExcel> ChapterLevelData { get; private set; } = [];
|
public static Dictionary<uint, ChapterLevelExcel> ChapterLevelData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, RoleLevelExcel> RoleLevelData { get; private set; } = [];
|
||||||
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; } = [];
|
||||||
@@ -28,6 +29,9 @@ public static class GameData
|
|||||||
public static Dictionary<int, SupportFixedExcel> SupportFixedData { get; private set; } = [];
|
public static Dictionary<int, SupportFixedExcel> SupportFixedData { get; private set; } = [];
|
||||||
public static Dictionary<uint, WeaponSkinExcel> WeaponSkinData { get; private set; } = [];
|
public static Dictionary<uint, WeaponSkinExcel> WeaponSkinData { get; private set; } = [];
|
||||||
public static Dictionary<uint, DailyLevelExcel> DailyLevelData { get; private set; } = [];
|
public static Dictionary<uint, DailyLevelExcel> DailyLevelData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, BossPvpBossChallengeExcel> BossPvpBossChallengeData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, BossPvpBossExcel> BossPvpBossData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, BossPvpNumExcel> BossPvpNumData { get; private set; } = [];
|
||||||
public static Dictionary<uint, ProfileExcel> ProfileData { get; private set; } = [];
|
public static Dictionary<uint, ProfileExcel> ProfileData { get; private set; } = [];
|
||||||
public static Dictionary<uint, CardSkinPartsExcel> CardSkinPartsData { get; private set; } = [];
|
public static Dictionary<uint, CardSkinPartsExcel> CardSkinPartsData { get; private set; } = [];
|
||||||
public static Dictionary<uint, CallItemExcel> CallItemData { get; private set; } = [];
|
public static Dictionary<uint, CallItemExcel> CallItemData { get; private set; } = [];
|
||||||
|
|||||||
498
GameServer/Game/BossPvp/BossPvpService.cs
Normal file
498
GameServer/Game/BossPvp/BossPvpService.cs
Normal file
@@ -0,0 +1,498 @@
|
|||||||
|
using MikuSB.Data;
|
||||||
|
using MikuSB.Data.Excel;
|
||||||
|
using MikuSB.Database.Inventory;
|
||||||
|
using MikuSB.GameServer.Game.Player;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
internal static class BossPvpService
|
||||||
|
{
|
||||||
|
private const uint GroupId = 51;
|
||||||
|
private const uint ActivitySubId = 0;
|
||||||
|
private const uint ChallengeNumSid = 1;
|
||||||
|
private const uint DiffStartId = 10;
|
||||||
|
private const uint LevelStartSid = 100;
|
||||||
|
private const uint LevelStride = 10;
|
||||||
|
private const uint BossLineup1 = 15;
|
||||||
|
private const uint BossLineup2 = 16;
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions JsonOptions = new()
|
||||||
|
{
|
||||||
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
|
||||||
|
};
|
||||||
|
|
||||||
|
public static async ValueTask<(object Response, NtfSyncPlayer Sync)> HandleGetOpenIdAsync(PlayerInstance player)
|
||||||
|
{
|
||||||
|
await EnsureBossLineupsAsync(player);
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
var season = GetOpenSeason();
|
||||||
|
var seasonId = season?.ID ?? 1u;
|
||||||
|
|
||||||
|
SetStr(player, ActivitySubId, seasonId.ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
SetStr(player, ChallengeNumSid, GetDailyChallengeNum().ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
|
||||||
|
if (season != null)
|
||||||
|
{
|
||||||
|
for (var index = 0; index < season.BossIds.Count; index++)
|
||||||
|
{
|
||||||
|
var bossLevelId = season.BossIds[index];
|
||||||
|
EnsureStr(player, DiffStartId + (uint)(index + 1), "0", sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 1), EmptySnapshotJson(), sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 2), EmptySnapshotJson(), sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 3), EmptySnapshotJson(), sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 4), "0", sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 5), "0", sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 6), "0", sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 7), "0", sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 8), "0", sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = new
|
||||||
|
{
|
||||||
|
nID = seasonId,
|
||||||
|
tbTimeCfg = new[]
|
||||||
|
{
|
||||||
|
new
|
||||||
|
{
|
||||||
|
nStartTime = -1,
|
||||||
|
nEndTime = -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (response, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static object HandleEnterLevel(string? param)
|
||||||
|
{
|
||||||
|
var req = Deserialize<EnterLevelParam>(param);
|
||||||
|
return new
|
||||||
|
{
|
||||||
|
nSeed = Random.Shared.Next(1, int.MaxValue),
|
||||||
|
nID = req?.NId ?? 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static (object Response, NtfSyncPlayer Sync) HandleRecord(PlayerInstance player, string? param)
|
||||||
|
{
|
||||||
|
var req = Deserialize<RecordParam>(param);
|
||||||
|
if (req == null)
|
||||||
|
{
|
||||||
|
return (new { bRecord = false }, new NtfSyncPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
if (req.BRecord)
|
||||||
|
{
|
||||||
|
var historyScore = ReadInt(player, GetBossSid(req.NId, 4));
|
||||||
|
var currentScore = ComputeIntegral(req.NId, req.NDiff, req.ResidueTime);
|
||||||
|
if (currentScore >= historyScore)
|
||||||
|
{
|
||||||
|
WriteBestRun(player, req.NId, req.NTeamId, req.NTime, currentScore, sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (new { bRecord = req.BRecord }, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static (JsonNode Response, NtfSyncPlayer Sync) HandleSettlement(PlayerInstance player, JsonNode? param)
|
||||||
|
{
|
||||||
|
var req = param?.Deserialize<SettlementParam>(JsonOptions);
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
if (req == null)
|
||||||
|
{
|
||||||
|
return (new JsonObject(), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
var totalSid = GetBossSid(req.NId, 7);
|
||||||
|
var successSid = GetBossSid(req.NId, 6);
|
||||||
|
var diffSid = GetBossSid(req.NId, 8);
|
||||||
|
|
||||||
|
SetStr(player, totalSid, (ReadInt(player, totalSid) + 1).ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
SetStr(player, successSid, (ReadInt(player, successSid) + 1).ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
|
||||||
|
var clearedDiff = Math.Max(ReadInt(player, diffSid), req.NDiff);
|
||||||
|
SetStr(player, diffSid, clearedDiff.ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
|
||||||
|
var positionSid = TryGetPositionDiffSid(req.NId);
|
||||||
|
if (positionSid != null)
|
||||||
|
{
|
||||||
|
var newPositionDiff = Math.Max(ReadInt(player, positionSid.Value), req.NDiff);
|
||||||
|
SetStr(player, positionSid.Value, newPositionDiff.ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
var score = ComputeIntegral(req.NId, req.NDiff, req.ResidueTime);
|
||||||
|
if (score > ReadInt(player, GetBossSid(req.NId, 4)))
|
||||||
|
{
|
||||||
|
WriteBestRun(player, req.NId, req.NTeamId, req.NTime, score, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (new JsonObject(), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static (JsonNode Response, NtfSyncPlayer Sync) HandleFail(PlayerInstance player, JsonNode? param)
|
||||||
|
{
|
||||||
|
var req = param?.Deserialize<FailParam>(JsonOptions);
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
if (req == null)
|
||||||
|
{
|
||||||
|
return (new JsonObject(), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
var totalSid = GetBossSid(req.NId, 7);
|
||||||
|
SetStr(player, totalSid, (ReadInt(player, totalSid) + 1).ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
|
||||||
|
return (new JsonObject(), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static (object Response, NtfSyncPlayer Sync) HandleMopup(PlayerInstance player, string? param)
|
||||||
|
{
|
||||||
|
var req = Deserialize<MopupParam>(param);
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
if (req == null)
|
||||||
|
{
|
||||||
|
return (new { }, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
var totalSid = GetBossSid(req.NId, 7);
|
||||||
|
var successSid = GetBossSid(req.NId, 6);
|
||||||
|
var diffSid = GetBossSid(req.NId, 8);
|
||||||
|
|
||||||
|
SetStr(player, totalSid, (ReadInt(player, totalSid) + 1).ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
SetStr(player, successSid, (ReadInt(player, successSid) + 1).ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
|
||||||
|
var clearedDiff = Math.Max(ReadInt(player, diffSid), req.NDiff);
|
||||||
|
SetStr(player, diffSid, clearedDiff.ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
|
||||||
|
var positionSid = TryGetPositionDiffSid(req.NId);
|
||||||
|
if (positionSid != null)
|
||||||
|
{
|
||||||
|
var newPositionDiff = Math.Max(ReadInt(player, positionSid.Value), req.NDiff + 1);
|
||||||
|
SetStr(player, positionSid.Value, newPositionDiff.ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
var score = ComputeIntegral(req.NId, req.NDiff, 0);
|
||||||
|
if (score > ReadInt(player, GetBossSid(req.NId, 4)))
|
||||||
|
{
|
||||||
|
WriteBestRun(player, req.NId, 0, 0, score, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (new { }, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static object HandleGetReward(string? param)
|
||||||
|
{
|
||||||
|
_ = Deserialize<RewardParam>(param);
|
||||||
|
return new { tbAward = Array.Empty<object>() };
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async ValueTask EnsureBossLineupsAsync(PlayerInstance player)
|
||||||
|
{
|
||||||
|
var lineups = player.LineupManager.LineupData.LineupInfo;
|
||||||
|
var baseLineup = lineups.GetValueOrDefault(1) ?? lineups.Values.FirstOrDefault();
|
||||||
|
if (baseLineup == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lineups.ContainsKey((int)BossLineup1))
|
||||||
|
{
|
||||||
|
await player.LineupManager.UpdateLineup((int)BossLineup1, baseLineup.Member1, baseLineup.Member2, baseLineup.Member3, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lineups.ContainsKey((int)BossLineup2))
|
||||||
|
{
|
||||||
|
await player.LineupManager.UpdateLineup((int)BossLineup2, baseLineup.Member1, baseLineup.Member2, baseLineup.Member3, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteBestRun(PlayerInstance player, uint bossLevelId, uint lineupId, double finishTime, int score, NtfSyncPlayer sync)
|
||||||
|
{
|
||||||
|
var snapshots = CaptureLineupSnapshots(player, lineupId);
|
||||||
|
SetStr(player, GetBossSid(bossLevelId, 1), System.Text.Json.JsonSerializer.Serialize(snapshots[0], JsonOptions), sync);
|
||||||
|
SetStr(player, GetBossSid(bossLevelId, 2), System.Text.Json.JsonSerializer.Serialize(snapshots[1], JsonOptions), sync);
|
||||||
|
SetStr(player, GetBossSid(bossLevelId, 3), System.Text.Json.JsonSerializer.Serialize(snapshots[2], JsonOptions), sync);
|
||||||
|
SetStr(player, GetBossSid(bossLevelId, 4), score.ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
SetStr(player, GetBossSid(bossLevelId, 5), Math.Max(0, (int)Math.Floor(finishTime)).ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BossPvpRoleSnapshot[] CaptureLineupSnapshots(PlayerInstance player, uint lineupId)
|
||||||
|
{
|
||||||
|
var lineups = player.LineupManager.LineupData.LineupInfo;
|
||||||
|
var lineup = lineups.GetValueOrDefault((int)lineupId)
|
||||||
|
?? lineups.GetValueOrDefault((int)BossLineup1)
|
||||||
|
?? lineups.GetValueOrDefault(1)
|
||||||
|
?? lineups.Values.FirstOrDefault();
|
||||||
|
|
||||||
|
if (lineup == null)
|
||||||
|
{
|
||||||
|
return [new(), new(), new()];
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
[
|
||||||
|
CaptureRoleSnapshot(player, lineup.Member1),
|
||||||
|
CaptureRoleSnapshot(player, lineup.Member2),
|
||||||
|
CaptureRoleSnapshot(player, lineup.Member3)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BossPvpRoleSnapshot CaptureRoleSnapshot(PlayerInstance player, uint characterGuid)
|
||||||
|
{
|
||||||
|
if (characterGuid == 0)
|
||||||
|
{
|
||||||
|
return new BossPvpRoleSnapshot();
|
||||||
|
}
|
||||||
|
|
||||||
|
var character = player.CharacterManager.GetCharacterByGUID(characterGuid);
|
||||||
|
if (character == null)
|
||||||
|
{
|
||||||
|
return new BossPvpRoleSnapshot();
|
||||||
|
}
|
||||||
|
|
||||||
|
var snapshot = new BossPvpRoleSnapshot
|
||||||
|
{
|
||||||
|
Role = character.Guid,
|
||||||
|
Weapon = character.WeaponUniqueId
|
||||||
|
};
|
||||||
|
|
||||||
|
var weapon = player.InventoryManager.GetWeaponItem(character.WeaponUniqueId);
|
||||||
|
if (weapon != null)
|
||||||
|
{
|
||||||
|
snapshot.Wgdpl = BuildWeaponGdpl(weapon);
|
||||||
|
snapshot.Wslot = weapon.PartSlots;
|
||||||
|
}
|
||||||
|
|
||||||
|
var supports = character.SupportSlots
|
||||||
|
.OrderBy(x => x.Key)
|
||||||
|
.Select(x => x.Value)
|
||||||
|
.Where(x => x != 0)
|
||||||
|
.Take(3)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
if (supports.Length > 0)
|
||||||
|
{
|
||||||
|
snapshot.S1 = supports[0];
|
||||||
|
snapshot.Sgdpl1 = BuildSupportGdpl(player.InventoryManager.GetSupportCardItem(supports[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (supports.Length > 1)
|
||||||
|
{
|
||||||
|
snapshot.S2 = supports[1];
|
||||||
|
snapshot.Sgdpl2 = BuildSupportGdpl(player.InventoryManager.GetSupportCardItem(supports[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (supports.Length > 2)
|
||||||
|
{
|
||||||
|
snapshot.S3 = supports[2];
|
||||||
|
snapshot.Sgdpl3 = BuildSupportGdpl(player.InventoryManager.GetSupportCardItem(supports[2]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return snapshot;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<uint> BuildWeaponGdpl(GameWeaponInfo weapon)
|
||||||
|
{
|
||||||
|
var gdpl = DecodeGdpl(weapon.TemplateId);
|
||||||
|
gdpl.Add(weapon.Level);
|
||||||
|
gdpl.Add(weapon.Evolue);
|
||||||
|
return gdpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<uint> BuildSupportGdpl(GameSupportCardInfo? support)
|
||||||
|
{
|
||||||
|
if (support == null)
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
var gdpl = DecodeGdpl(support.TemplateId);
|
||||||
|
gdpl.Add(support.Level);
|
||||||
|
gdpl.Add(0);
|
||||||
|
return gdpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<uint> DecodeGdpl(ulong templateId)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
[
|
||||||
|
(uint)(templateId & 0xFFFF),
|
||||||
|
(uint)((templateId >> 16) & 0xFFFF),
|
||||||
|
(uint)((templateId >> 32) & 0xFFFF),
|
||||||
|
(uint)((templateId >> 48) & 0xFFFF)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int ComputeIntegral(uint bossLevelId, int diff, int residueTime)
|
||||||
|
{
|
||||||
|
if (!GameData.BossPvpBossData.TryGetValue(bossLevelId, out var boss) || diff <= 0 || diff > boss.BossLevel.Count)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var info = boss.BossLevel[diff - 1];
|
||||||
|
if (info.Count == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var multiplier = info.Count > 2 ? info[2] : 0;
|
||||||
|
var baseScore = info.Count > 3 ? info[3] : 0;
|
||||||
|
var residueScore = info.Count > 4 ? info[4] : 0;
|
||||||
|
var total = (baseScore + residueScore * Math.Max(0, residueTime)) * multiplier;
|
||||||
|
return (int)Math.Floor(total + 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static uint? TryGetPositionDiffSid(uint bossLevelId)
|
||||||
|
{
|
||||||
|
var season = GetOpenSeason();
|
||||||
|
if (season == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var index = season.BossIds.FindIndex(x => x == bossLevelId);
|
||||||
|
return index >= 0 ? DiffStartId + (uint)(index + 1) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BossPvpBossChallengeExcel? GetOpenSeason()
|
||||||
|
{
|
||||||
|
var now = DateTimeOffset.Now;
|
||||||
|
var current = GameData.BossPvpBossChallengeData.Values
|
||||||
|
.OrderBy(x => x.ID)
|
||||||
|
.FirstOrDefault(x =>
|
||||||
|
{
|
||||||
|
var startAt = ParseBossTime(x.StartTime);
|
||||||
|
var endAt = ParseBossTime(x.EndTime);
|
||||||
|
return startAt != null && endAt != null && now >= startAt && now <= endAt;
|
||||||
|
});
|
||||||
|
|
||||||
|
return current ?? GameData.BossPvpBossChallengeData.Values.OrderBy(x => x.ID).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static uint GetDailyChallengeNum()
|
||||||
|
{
|
||||||
|
var now = DateTime.Now;
|
||||||
|
if (now.Hour < 4)
|
||||||
|
{
|
||||||
|
now = now.AddHours(-4);
|
||||||
|
}
|
||||||
|
|
||||||
|
var week = now.DayOfWeek == DayOfWeek.Sunday ? 7 : (int)now.DayOfWeek;
|
||||||
|
return GameData.BossPvpNumData.TryGetValue((uint)week, out var count) ? count.Num : 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int ReadInt(PlayerInstance player, uint sid)
|
||||||
|
{
|
||||||
|
var attr = player.Data.StrAttrs.FirstOrDefault(x => x.Gid == GroupId && x.Sid == sid)?.Val;
|
||||||
|
return int.TryParse(attr, NumberStyles.Integer, CultureInfo.InvariantCulture, out var value) ? value : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void EnsureStr(PlayerInstance player, uint sid, string value, NtfSyncPlayer sync)
|
||||||
|
{
|
||||||
|
var attr = player.Data.StrAttrs.FirstOrDefault(x => x.Gid == GroupId && x.Sid == sid);
|
||||||
|
if (attr != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetStr(player, sid, value, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetStr(PlayerInstance player, uint sid, string value, NtfSyncPlayer sync)
|
||||||
|
{
|
||||||
|
player.SetStrAttr(GroupId, sid, value);
|
||||||
|
sync.CustomStr[player.ToShiftedAttrKey(GroupId, sid)] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static uint GetBossSid(uint bossLevelId, uint offset) => (LevelStride * bossLevelId) + LevelStartSid + offset;
|
||||||
|
|
||||||
|
private static string EmptySnapshotJson() => System.Text.Json.JsonSerializer.Serialize(new BossPvpRoleSnapshot(), JsonOptions);
|
||||||
|
|
||||||
|
private static T? Deserialize<T>(string? param)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(param))
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
return System.Text.Json.JsonSerializer.Deserialize<T>(param, JsonOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DateTimeOffset? ParseBossTime(string? value)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var raw = value.Trim().Trim('[', ']');
|
||||||
|
if (!DateTime.TryParseExact(raw, "yyyyMMddHHmm", CultureInfo.InvariantCulture, DateTimeStyles.None, out var localTime))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new DateTimeOffset(localTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class EnterLevelParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nID")] public uint NId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class RecordParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nID")] public uint NId { get; set; }
|
||||||
|
[JsonPropertyName("nDiff")] public int NDiff { get; set; }
|
||||||
|
[JsonPropertyName("nTime")] public double NTime { get; set; }
|
||||||
|
[JsonPropertyName("ResidueTime")] public int ResidueTime { get; set; }
|
||||||
|
[JsonPropertyName("bRecord")] public bool BRecord { get; set; }
|
||||||
|
[JsonPropertyName("nTeamID")] public uint NTeamId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class SettlementParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nID")] public uint NId { get; set; }
|
||||||
|
[JsonPropertyName("nDiff")] public int NDiff { get; set; }
|
||||||
|
[JsonPropertyName("nTime")] public double NTime { get; set; }
|
||||||
|
[JsonPropertyName("ResidueTime")] public int ResidueTime { get; set; }
|
||||||
|
[JsonPropertyName("nTeamID")] public uint NTeamId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class FailParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nID")] public uint NId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class MopupParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nID")] public uint NId { get; set; }
|
||||||
|
[JsonPropertyName("nDiff")] public int NDiff { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class RewardParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("tbTaskID")] public List<uint> TaskIds { get; set; } = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class BossPvpRoleSnapshot
|
||||||
|
{
|
||||||
|
[JsonPropertyName("role")] public uint Role { get; set; }
|
||||||
|
[JsonPropertyName("weapon")] public uint Weapon { get; set; }
|
||||||
|
[JsonPropertyName("s1")] public uint S1 { get; set; }
|
||||||
|
[JsonPropertyName("s2")] public uint S2 { get; set; }
|
||||||
|
[JsonPropertyName("s3")] public uint S3 { get; set; }
|
||||||
|
[JsonPropertyName("wgdpl")] public List<uint> Wgdpl { get; set; } = [];
|
||||||
|
[JsonPropertyName("wslot")] public Dictionary<uint, ulong> Wslot { get; set; } = [];
|
||||||
|
[JsonPropertyName("sgdpl1")] public List<uint> Sgdpl1 { get; set; } = [];
|
||||||
|
[JsonPropertyName("sgdpl2")] public List<uint> Sgdpl2 { get; set; } = [];
|
||||||
|
[JsonPropertyName("sgdpl3")] public List<uint> Sgdpl3 { get; set; } = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -425,6 +425,14 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
yield return (22, levelId, 1_700_000_000);
|
yield return (22, levelId, 1_700_000_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Role fragment chapters use Condition.PRE_LEVEL against Launch.GPASSID as well.
|
||||||
|
// Mark every role level as cleared so character-specific stages beyond the first one unlock.
|
||||||
|
foreach (var levelId in GameData.RoleLevelData.Keys)
|
||||||
|
{
|
||||||
|
yield return (21, levelId, 7);
|
||||||
|
yield return (22, levelId, 1_700_000_000);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var guide in GameData.GuideData.Values)
|
foreach (var guide in GameData.GuideData.Values)
|
||||||
{
|
{
|
||||||
yield return (4, guide.ID, 999);
|
yield return (4, guide.ID, 999);
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
|
[CallGSApi("BossPvpLogic_EnterLevel")]
|
||||||
|
public class BossPvpLogic_EnterLevel : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var response = BossPvpService.HandleEnterLevel(param);
|
||||||
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_EnterLevel", System.Text.Json.JsonSerializer.Serialize(response));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
|
[CallGSApi("BossPvpLogic_GetOpenID")]
|
||||||
|
public class BossPvpLogic_GetOpenID : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var (response, sync) = await BossPvpService.HandleGetOpenIdAsync(connection.Player!);
|
||||||
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_GetOpenID", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
|
[CallGSApi("BossPvpLogic_GetReward")]
|
||||||
|
public class BossPvpLogic_GetReward : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var response = BossPvpService.HandleGetReward(param);
|
||||||
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_GetReward", System.Text.Json.JsonSerializer.Serialize(response));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
|
[CallGSApi("BossPvpLogic_LevelFail")]
|
||||||
|
public class BossPvpLogic_LevelFail : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var node = System.Text.Json.Nodes.JsonNode.Parse(param);
|
||||||
|
var (response, sync) = BossPvpService.HandleFail(connection.Player!, node);
|
||||||
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelFail", response.ToJsonString(), sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
|
[CallGSApi("BossPvpLogic_LevelMopup")]
|
||||||
|
public class BossPvpLogic_LevelMopup : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var (response, sync) = BossPvpService.HandleMopup(connection.Player!, param);
|
||||||
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelMopup", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
|
[CallGSApi("BossPvpLogic_LevelSettlement")]
|
||||||
|
public class BossPvpLogic_LevelSettlement : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var node = System.Text.Json.Nodes.JsonNode.Parse(param);
|
||||||
|
var (response, sync) = BossPvpService.HandleSettlement(connection.Player!, node);
|
||||||
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelSettlement", response.ToJsonString(), sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
|
[CallGSApi("BossPvpLogic_Record")]
|
||||||
|
public class BossPvpLogic_Record : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var (response, sync) = BossPvpService.HandleRecord(connection.Player!, param);
|
||||||
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_Record", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
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.Game.BossPvp;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.Chapter;
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.Chapter;
|
||||||
|
|
||||||
@@ -10,17 +12,20 @@ public class Chapter_DealLevelSettlement : 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<DealLevelSettlementParam>(param);
|
var req = JsonSerializer.Deserialize<DealLevelSettlementParam>(param);
|
||||||
|
NtfSyncPlayer? extraSync = null;
|
||||||
var response = new JsonObject
|
var response = new JsonObject
|
||||||
{
|
{
|
||||||
["sCmd"] = req?.SCmd ?? "Chapter_LevelSettlement",
|
["sCmd"] = req?.SCmd ?? "Chapter_LevelSettlement",
|
||||||
["tbParam"] = BuildSettlementPayload(req?.SCmd, req?.TbParam)
|
["tbParam"] = BuildSettlementPayload(connection, req?.SCmd, req?.TbParam, out extraSync)
|
||||||
};
|
};
|
||||||
|
|
||||||
await CallGSRouter.SendScript(connection, "Chapter_DealLevelSettlement", response.ToJsonString());
|
await CallGSRouter.SendScript(connection, "Chapter_DealLevelSettlement", response.ToJsonString(), extraSync!);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JsonNode BuildSettlementPayload(string? sCmd, JsonNode? tbParam)
|
private static JsonNode BuildSettlementPayload(Connection connection, string? sCmd, JsonNode? tbParam, out NtfSyncPlayer? extraSync)
|
||||||
{
|
{
|
||||||
|
extraSync = null;
|
||||||
|
|
||||||
if (string.Equals(sCmd, "Chapter_LevelSettlement", StringComparison.Ordinal))
|
if (string.Equals(sCmd, "Chapter_LevelSettlement", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
return new JsonArray();
|
return new JsonArray();
|
||||||
@@ -37,6 +42,20 @@ public class Chapter_DealLevelSettlement : ICallGSHandler
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (string.Equals(sCmd, "BossPvpLogic_LevelSettlement", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
var (response, sync) = BossPvpService.HandleSettlement(connection.Player!, tbParam);
|
||||||
|
extraSync = sync;
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Equals(sCmd, "BossPvpLogic_LevelFail", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
var (response, sync) = BossPvpService.HandleFail(connection.Player!, tbParam);
|
||||||
|
extraSync = sync;
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
return tbParam?.DeepClone() ?? new JsonObject();
|
return tbParam?.DeepClone() ?? new JsonObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.5
|
v=3.8
|
||||||
Reference in New Issue
Block a user