mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 13:03:57 +00:00
Compare commits
11 Commits
49f4fdfda5
...
v2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7507d10072 | ||
|
|
8a7a919d04 | ||
|
|
2d1079a80d | ||
|
|
677e4027b9 | ||
|
|
4dc28ae423 | ||
|
|
1fce4ca2e6 | ||
|
|
93c59e5730 | ||
|
|
f7814b0537 | ||
|
|
2fdda3157f | ||
|
|
f07c5f77fd | ||
|
|
2883ac3d41 |
@@ -1,6 +1,6 @@
|
||||
namespace MikuSB.Data.Excel;
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("ar_item.json")]
|
||||
[ResourceEntity("item/templates/ar_item.json")]
|
||||
public class ArItemExcel : ExcelResource
|
||||
{
|
||||
public uint Genre { get; set; }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("break.json")]
|
||||
[ResourceEntity("item/break.json")]
|
||||
public class BreakExcel : ExcelResource
|
||||
{
|
||||
[JsonProperty("ID")] public int Id { get; set; }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace MikuSB.Data.Excel;
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("break_level_limit.json")]
|
||||
[ResourceEntity("item/break_level_limit.json")]
|
||||
public class BreakLevelLimitExcel : ExcelResource
|
||||
{
|
||||
public int ID { get; set; }
|
||||
|
||||
@@ -3,7 +3,7 @@ using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("call_item.json")]
|
||||
[ResourceEntity("item/templates/call_item.json")]
|
||||
public class CallItemExcel : ExcelResource
|
||||
{
|
||||
public uint Genre { get; set; }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("card.json")]
|
||||
[ResourceEntity("item/templates/card.json")]
|
||||
public class CardExcel : ExcelResource
|
||||
{
|
||||
public uint Genre { get; set; }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("card_skin.json")]
|
||||
[ResourceEntity("item/templates/card_skin.json")]
|
||||
public class CardSkinExcel : ExcelResource
|
||||
{
|
||||
public uint Genre { get; set; }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("card_skin_parts.json")]
|
||||
[ResourceEntity("item/templates/card_skin_parts.json")]
|
||||
public class CardSkinPartsExcel : ExcelResource
|
||||
{
|
||||
public uint Genre { get; set; }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("level.json")]
|
||||
[ResourceEntity("chapter/level.json")]
|
||||
public class ChapterLevelExcel : ExcelResource
|
||||
{
|
||||
public uint ID { get; set; }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("daily_level.json")]
|
||||
[ResourceEntity("daily/level.json")]
|
||||
public class DailyLevelExcel : ExcelResource
|
||||
{
|
||||
public uint ID { get; set; }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("manifestation.json")]
|
||||
[ResourceEntity("item/templates/manifestation.json")]
|
||||
public class ManifestationExcel : ExcelResource
|
||||
{
|
||||
public uint Genre { get; set; }
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
// nodecondition.json: NodeConditionId → NodeXCost per sub-node (1-9)
|
||||
[ResourceEntity("nodecondition.json")]
|
||||
[ResourceEntity("item/skill/nodecondition.json")]
|
||||
public class NodeConditionExcel : ExcelResource
|
||||
{
|
||||
[JsonProperty("ID")] public uint Id { get; set; }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("profile.json")]
|
||||
[ResourceEntity("item/templates/profile.json")]
|
||||
public class ProfileExcel : ExcelResource
|
||||
{
|
||||
public uint Genre { get; set; }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("recycle.json")]
|
||||
[ResourceEntity("item/recycle.json")]
|
||||
public class RecycleExcel : ExcelResource
|
||||
{
|
||||
public int ID { get; set; }
|
||||
|
||||
18
Common/Data/Excel/Rogue3DDailyBuffExcel.cs
Normal file
18
Common/Data/Excel/Rogue3DDailyBuffExcel.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("dlc/rogue3d/dailybuff.json")]
|
||||
public class Rogue3DDailyBuffExcel : ExcelResource
|
||||
{
|
||||
[JsonProperty("ID")] public uint Id { get; set; }
|
||||
[JsonProperty("GroupID")] public uint GroupId { get; set; }
|
||||
[JsonProperty("ScoreBuffID")] public uint ScoreBuffId { get; set; }
|
||||
|
||||
public override uint GetId() => Id;
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.Rogue3DDailyBuffData[Id] = this;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("server_01_difficult.json")]
|
||||
[ResourceEntity("dlc/rogue3d/server_01_difficult.json")]
|
||||
public class Rogue3DDifficultExcel : ExcelResource
|
||||
{
|
||||
[JsonProperty("DifficultID")] public uint DifficultId { get; set; }
|
||||
|
||||
19
Common/Data/Excel/Rogue3DSeasonExcel.cs
Normal file
19
Common/Data/Excel/Rogue3DSeasonExcel.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("dlc/rogue3d/server_10_season.json")]
|
||||
public class Rogue3DSeasonExcel : ExcelResource
|
||||
{
|
||||
[JsonProperty("SeasonID")] public uint SeasonId { get; set; }
|
||||
[JsonProperty("Type")] public int Type { get; set; }
|
||||
[JsonProperty("OpenTime")] public string OpenTime { get; set; } = "";
|
||||
[JsonProperty("CloseTime")] public string CloseTime { get; set; } = "";
|
||||
|
||||
public override uint GetId() => SeasonId;
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.Rogue3DSeasonData[SeasonId] = this;
|
||||
}
|
||||
}
|
||||
31
Common/Data/Excel/Rogue3DTalentExcel.cs
Normal file
31
Common/Data/Excel/Rogue3DTalentExcel.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("dlc/rogue3d/server_03_talent.json")]
|
||||
public class Rogue3DTalentExcel : ExcelResource
|
||||
{
|
||||
[JsonProperty("TalentID")] public uint TalentId { get; set; }
|
||||
[JsonProperty("UnlockCondition")] private object? UnlockConditionRaw { get; set; }
|
||||
[JsonIgnore] public uint UnlockCondition { get; private set; }
|
||||
|
||||
public override uint GetId() => TalentId;
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
UnlockCondition = ParseUnlockCondition(UnlockConditionRaw);
|
||||
GameData.Rogue3DTalentData[TalentId] = this;
|
||||
}
|
||||
|
||||
private static uint ParseUnlockCondition(object? raw)
|
||||
{
|
||||
return raw switch
|
||||
{
|
||||
null => 0,
|
||||
long value when value > 0 => (uint)value,
|
||||
int value when value > 0 => (uint)value,
|
||||
string text when uint.TryParse(text, out var value) => value,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
// spine.json: SpineId → Node{i}Req (nodecondition ID per master node index)
|
||||
[ResourceEntity("spine.json")]
|
||||
[ResourceEntity("item/skill/spine.json")]
|
||||
public class SpineExcel : ExcelResource
|
||||
{
|
||||
[JsonProperty("ID")] public uint Id { get; set; }
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("suplies.json")]
|
||||
[ResourceEntity("item/templates/suplies.json")]
|
||||
public class SuppliesExcel : ExcelResource
|
||||
{
|
||||
public uint Genre { get; set; }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("support_card.json")]
|
||||
[ResourceEntity("item/templates/support_card.json")]
|
||||
public class SupportCardExcel : ExcelResource
|
||||
{
|
||||
public uint Genre { get; set; }
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("upgrade_exp.json")]
|
||||
[ResourceEntity("item/upgrade_exp.json")]
|
||||
public class UpgradeExpExcel : ExcelResource
|
||||
{
|
||||
public int Lv { get; set; }
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("weapon.json")]
|
||||
[ResourceEntity("item/templates/weapon.json")]
|
||||
public class WeaponExcel : ExcelResource
|
||||
{
|
||||
public uint Genre { get; set; }
|
||||
|
||||
24
Common/Data/Excel/WeaponPartsExcel.cs
Normal file
24
Common/Data/Excel/WeaponPartsExcel.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("item/templates/weapon_parts.json")]
|
||||
public class WeaponPartsExcel : 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 int AppearID { get; set; }
|
||||
public string I18n { get; set; } = "";
|
||||
public override uint GetId()
|
||||
{
|
||||
return (uint)I18n.GetHashCode();
|
||||
}
|
||||
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.WeaponPartsData.Add(GetId(), this);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MikuSB.Data.Excel;
|
||||
|
||||
[ResourceEntity("weapon_skin.json")]
|
||||
[ResourceEntity("item/templates/weapon_skin.json")]
|
||||
public class WeaponSkinExcel : ExcelResource
|
||||
{
|
||||
public uint Genre { get; set; }
|
||||
|
||||
@@ -16,6 +16,9 @@ public static class GameData
|
||||
public static Dictionary<uint, ArItemExcel> ArItemData { 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, Rogue3DSeasonExcel> Rogue3DSeasonData { get; private set; } = [];
|
||||
public static Dictionary<uint, Rogue3DTalentExcel> Rogue3DTalentData { get; private set; } = [];
|
||||
public static Dictionary<uint, Rogue3DDailyBuffExcel> Rogue3DDailyBuffData { 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; } = [];
|
||||
@@ -25,6 +28,7 @@ public static class GameData
|
||||
public static Dictionary<uint, ProfileExcel> ProfileData { 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, WeaponPartsExcel> WeaponPartsData { get; private set; } = [];
|
||||
}
|
||||
|
||||
public static class GameResourceTemplateId
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ResourceManager
|
||||
foreach (var fileName in attribute.FileName)
|
||||
try
|
||||
{
|
||||
var path = ConfigManager.Config.Path.ResourcePath + "/ExcelOutput/" + fileName;
|
||||
var path = ConfigManager.Config.Path.ResourcePath + "/" + fileName;
|
||||
var file = new FileInfo(path);
|
||||
if (!file.Exists)
|
||||
{
|
||||
|
||||
@@ -62,6 +62,7 @@ public abstract class GrowableItemInfo : BaseGameItemInfo
|
||||
|
||||
public class GameWeaponInfo : GrowableItemInfo
|
||||
{
|
||||
[SugarColumn(IsJson = true)] public Dictionary<uint, ulong> PartSlots { get; set; } = [];
|
||||
public override Item ToProto()
|
||||
{
|
||||
var proto = new Item
|
||||
@@ -78,6 +79,7 @@ public class GameWeaponInfo : GrowableItemInfo
|
||||
Evolue = Evolue
|
||||
}
|
||||
};
|
||||
foreach (var (slot, uid) in PartSlots) proto.Slots[slot] = uid;
|
||||
return proto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public class ServerTextCHS
|
||||
/// </summary>
|
||||
public class WordTextCHS
|
||||
{
|
||||
public string WeaponPart => "武器部件";
|
||||
public string CallItem => "召唤道具";
|
||||
public string SkinPart => "皮肤部件";
|
||||
public string Profile => "个人资料";
|
||||
@@ -246,6 +247,7 @@ public class GiveAllTextCHS
|
||||
"用法:/giveall card <detail/-1> -p<特定> -l<等級>" +
|
||||
"用法:/giveall profile <detail/-1> -g<类型> -p<特定> -l<等级>" +
|
||||
"用法:/giveall skinpart <detail/-1> -g<類型> -p<特定> -l<等級>" +
|
||||
"用法:/giveall weaponpart <detail/-1> -g<類型> -p<特定> -l<等級>" +
|
||||
"用法:/giveall call <detail/-1> -g<類型> -p<特定> -l<等級>";
|
||||
public string NotFound => "未找到 {0}!";
|
||||
public string GiveAllItems => "已向玩家添加 {0} 个 {1}!";
|
||||
|
||||
@@ -35,6 +35,7 @@ public class ServerTextCHT
|
||||
/// </summary>
|
||||
public class WordTextCHT
|
||||
{
|
||||
public string WeaponPart => "武器部件";
|
||||
public string CallItem => "召喚道具";
|
||||
public string SkinPart => "外觀部件";
|
||||
public string Profile => "個人資料";
|
||||
@@ -246,6 +247,7 @@ public class GiveAllTextCHT
|
||||
"用法:/giveall card <detail/-1> -p<特定> -l<等級>" +
|
||||
"用法:/giveall profile <detail/-1> -g<類型> -p<特定> -l<等級>" +
|
||||
"用法:/giveall skinpart <detail/-1> -g<類型> -p<特定> -l<等級>" +
|
||||
"用法:/giveall weaponpart <detail/-1> -g<類型> -p<特定> -l<等級>" +
|
||||
"用法:/giveall call <detail/-1> -g<類型> -p<特定> -l<等級>";
|
||||
public string NotFound => "未找到 {0}!";
|
||||
public string GiveAllItems => "已向玩家添加 {0} 個 {1}!";
|
||||
|
||||
@@ -35,6 +35,7 @@ public class ServerTextEN
|
||||
/// </summary>
|
||||
public class WordTextEN
|
||||
{
|
||||
public string WeaponPart => "Weapon Part";
|
||||
public string CallItem => "Call Item";
|
||||
public string SkinPart => "Skin Part";
|
||||
public string Profile => "Profile";
|
||||
@@ -212,6 +213,7 @@ public class GiveAllTextEN
|
||||
"Usage: /giveall card <detail/-1> -p<particular> -l<level>" +
|
||||
"Usage: /giveall profile <detail/-1> -g<genre> -p<particular> -l<level>" +
|
||||
"Usage: /giveall skinpart <detail/-1> -g<genre> -p<particular> -l<level>" +
|
||||
"Usage: /giveall weaponpart <detail/-1> -g<genre> -p<particular> -l<level>" +
|
||||
"Usage: /giveall call <detail/-1> -g<genre> -p<particular> -l<level>";
|
||||
public string NotFound => "{0} not found!";
|
||||
public string GiveAllItems => "Added {0} {1} to player!";
|
||||
|
||||
@@ -222,4 +222,40 @@ public class CommandGiveAll : ICommands
|
||||
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
||||
I18NManager.Translate("Word.CallItem"), callItems.Count.ToString()));
|
||||
}
|
||||
|
||||
[CommandMethod("weaponpart")]
|
||||
public async ValueTask GiveAllWeaponPart(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;
|
||||
if (await arg.GetOption('g') is not int genre) return;
|
||||
|
||||
var detail = arg.GetInt(0);
|
||||
var player = arg.Target!.Player!;
|
||||
List<BaseGameItemInfo> weaponPartItems = [];
|
||||
if (detail == -1)
|
||||
{
|
||||
// add all
|
||||
foreach (var config in GameData.WeaponPartsData.Values)
|
||||
{
|
||||
var weaponPart = await player.InventoryManager!
|
||||
.AddWeaponPartItem((ItemTypeEnum)config.Genre, config.Detail, config.Particular, config.Level, false);
|
||||
if (weaponPart != null) weaponPartItems.Add(weaponPart);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var weaponPart = await player.InventoryManager!.AddWeaponPartItem((ItemTypeEnum)genre, (uint)detail, (uint)particular, (uint)level, false);
|
||||
if (weaponPart == null)
|
||||
{
|
||||
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.NotFound", I18NManager.Translate("Word.WeaponPart")));
|
||||
return;
|
||||
}
|
||||
weaponPartItems.Add(weaponPart);
|
||||
}
|
||||
if (weaponPartItems.Count > 0) await player.SendPacket(new PacketNtfCallScript(weaponPartItems));
|
||||
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
||||
I18NManager.Translate("Word.WeaponPart"), weaponPartItems.Count.ToString()));
|
||||
}
|
||||
}
|
||||
@@ -312,4 +312,25 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
||||
|
||||
return callInfo;
|
||||
}
|
||||
|
||||
public async ValueTask<BaseGameItemInfo?> AddWeaponPartItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
||||
{
|
||||
if (genre != ItemTypeEnum.TYPE_WEAPON_PART) return null;
|
||||
var weaponPartData = GameData.WeaponPartsData.Values.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level);
|
||||
if (weaponPartData == null) return null;
|
||||
var templateId = GameResourceTemplateId.FromGdpl((uint)genre, detail, particular, level);
|
||||
if (InventoryData.Items.Values.Any(x => x.TemplateId == templateId)) return null;
|
||||
var weaponPartInfo = new BaseGameItemInfo
|
||||
{
|
||||
TemplateId = templateId,
|
||||
UniqueId = InventoryData.NextUniqueUid++,
|
||||
ItemType = genre,
|
||||
ItemCount = 1
|
||||
};
|
||||
InventoryData.Items[weaponPartInfo.UniqueId] = weaponPartInfo;
|
||||
|
||||
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([weaponPartInfo]));
|
||||
|
||||
return weaponPartInfo;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,7 @@
|
||||
using Azure;
|
||||
using MikuSB.Data;
|
||||
using MikuSB.Database;
|
||||
using MikuSB.Data;
|
||||
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.Serialization;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.Girl;
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
using MikuSB.Proto;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.House;
|
||||
|
||||
[HouseFunc("ArcadeGameEnterMainUI")]
|
||||
public class ArcadeGameEnterMainUI : IHouseFuncHandler
|
||||
{
|
||||
private static readonly int[] ArcadeUnlockedGirlList = [1, 5, 13, 23, 10];
|
||||
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var unlockGirls = new JsonArray();
|
||||
foreach (var girlId in ArcadeUnlockedGirlList)
|
||||
unlockGirls.Add(girlId);
|
||||
|
||||
var rsp = new JsonObject
|
||||
{
|
||||
["tbUnlockGirlList"] = unlockGirls,
|
||||
["FuncName"] = "ArcadeGameEnterMainUI"
|
||||
};
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Success(rsp));
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("ArcadeGameEnter")]
|
||||
public class ArcadeGameEnter : IHouseFuncHandler
|
||||
{
|
||||
private static readonly Random Random = new();
|
||||
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var rsp = new JsonObject
|
||||
{
|
||||
["FuncName"] = "ArcadeGameEnter",
|
||||
["nSeed"] = Random.Next(1, 1_000_000_000)
|
||||
};
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Success(rsp));
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("ArcadeGameSettlement")]
|
||||
public class ArcadeGameSettlement : IHouseFuncHandler
|
||||
{
|
||||
private const uint HouseArcadeInfoStart = 18000;
|
||||
private const uint ArcadeAttrExpOffset = 2;
|
||||
private const uint ArcadeAttrEndlessScoreOffset = 4;
|
||||
private const uint ArcadeAttrGirlEndlessModeStateOffset = 5;
|
||||
private const uint ArcadeAttrGirlNormalModeStateOffset = 10;
|
||||
private const uint ArcadeAttrGirlNormalModeStateEndOffset = 35;
|
||||
private const uint ArcadeAttrConditionValStartOffset = 36;
|
||||
private const uint ArcadeAttrConditionValEndOffset = 55;
|
||||
private const uint ArcadeAttrPropUseStartOffset = 56;
|
||||
private const uint ArcadeAttrPropUseEndOffset = 250;
|
||||
private const int ArcadeGameModeNormal = 1;
|
||||
private const int ArcadeGameModeEndless = 2;
|
||||
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var player = connection.Player!;
|
||||
var sync = new NtfSyncPlayer();
|
||||
var modeType = HouseJson.NumField(root, "nModeType");
|
||||
var finishRound = Math.Max(0, HouseJson.NumField(root, "nFinishRound"));
|
||||
var maxScore = Math.Max(0, HouseJson.NumField(root, "nMaxScore"));
|
||||
|
||||
if (root["tbConditionVal"] is JsonArray conditions)
|
||||
{
|
||||
foreach (var conditionNode in conditions)
|
||||
{
|
||||
if (conditionNode is not JsonArray condition || condition.Count < 2) continue;
|
||||
var id = HouseJson.ToInt(condition[0]);
|
||||
var value = Math.Max(0, HouseJson.ToInt(condition[1]));
|
||||
if (id < 0) continue;
|
||||
var sid = HouseArcadeInfoStart + ArcadeAttrConditionValStartOffset + (uint)id;
|
||||
if (sid > HouseArcadeInfoStart + ArcadeAttrConditionValEndOffset) continue;
|
||||
var prev = HouseAttr.Read(player, sid);
|
||||
if ((uint)value > prev)
|
||||
await HouseAttr.SetAsync(connection, sid, (uint)value, sync);
|
||||
}
|
||||
}
|
||||
|
||||
if (root["tbPropUse"] is JsonArray propUses)
|
||||
{
|
||||
var slotStart = HouseArcadeInfoStart + ArcadeAttrPropUseStartOffset;
|
||||
var slotEnd = HouseArcadeInfoStart + ArcadeAttrPropUseEndOffset;
|
||||
var slotState = new Dictionary<uint, ArcadePropUseSlot>();
|
||||
var emptySlots = new Queue<uint>();
|
||||
for (uint sid = slotStart; sid <= slotEnd; sid++)
|
||||
{
|
||||
var value = HouseAttr.Read(player, sid);
|
||||
if (value == 0)
|
||||
{
|
||||
emptySlots.Enqueue(sid);
|
||||
continue;
|
||||
}
|
||||
|
||||
slotState[sid] = new ArcadePropUseSlot
|
||||
{
|
||||
Type = (byte)(value & 0xff),
|
||||
Id = (byte)((value >> 8) & 0xff),
|
||||
Count = (ushort)((value >> 16) & 0xffff)
|
||||
};
|
||||
}
|
||||
|
||||
foreach (var propUseNode in propUses)
|
||||
{
|
||||
if (propUseNode is not JsonArray propUse || propUse.Count < 3) continue;
|
||||
var type = HouseJson.ToInt(propUse[0]) & 0xff;
|
||||
var id = HouseJson.ToInt(propUse[1]) & 0xff;
|
||||
var count = HouseJson.ToInt(propUse[2]);
|
||||
if (count <= 0) continue;
|
||||
|
||||
uint? foundSid = null;
|
||||
foreach (var (sid, slot) in slotState)
|
||||
{
|
||||
if (slot.Type == type && slot.Id == id)
|
||||
{
|
||||
foundSid = sid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundSid != null)
|
||||
{
|
||||
var slot = slotState[foundSid.Value];
|
||||
slot.Count = (ushort)Math.Min(0xffff, slot.Count + count);
|
||||
slotState[foundSid.Value] = slot;
|
||||
await HouseAttr.SetAsync(connection, foundSid.Value, HouseAttr.PackArcadePropUse(slot.Type, slot.Id, slot.Count), sync);
|
||||
}
|
||||
else if (emptySlots.Count > 0)
|
||||
{
|
||||
var sid = emptySlots.Dequeue();
|
||||
var packedCount = (ushort)Math.Min(0xffff, count);
|
||||
slotState[sid] = new ArcadePropUseSlot { Type = type, Id = id, Count = packedCount };
|
||||
await HouseAttr.SetAsync(connection, sid, HouseAttr.PackArcadePropUse(type, id, packedCount), sync);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var girlList = root["tbGirlDataList"] as JsonArray;
|
||||
var nAddExp = 0;
|
||||
if (modeType == ArcadeGameModeNormal)
|
||||
{
|
||||
if (girlList != null)
|
||||
{
|
||||
foreach (var girlNode in girlList)
|
||||
{
|
||||
var girlId = HouseJson.ToInt(girlNode);
|
||||
if (girlId <= 0) continue;
|
||||
var sid = HouseArcadeInfoStart + ArcadeAttrGirlNormalModeStateOffset + (uint)girlId;
|
||||
if (sid > HouseArcadeInfoStart + ArcadeAttrGirlNormalModeStateEndOffset) continue;
|
||||
var prev = HouseAttr.Read(player, sid);
|
||||
await HouseAttr.SetAsync(connection, sid, prev + (uint)finishRound, sync);
|
||||
}
|
||||
}
|
||||
nAddExp = finishRound * 10;
|
||||
}
|
||||
else if (modeType == ArcadeGameModeEndless)
|
||||
{
|
||||
var scoreSid = HouseArcadeInfoStart + ArcadeAttrEndlessScoreOffset;
|
||||
var prevScore = HouseAttr.Read(player, scoreSid);
|
||||
if ((uint)maxScore > prevScore)
|
||||
await HouseAttr.SetAsync(connection, scoreSid, (uint)maxScore, sync);
|
||||
|
||||
var bitsSid = HouseArcadeInfoStart + ArcadeAttrGirlEndlessModeStateOffset;
|
||||
var bits = HouseAttr.Read(player, bitsSid);
|
||||
var originalBits = bits;
|
||||
if (girlList != null)
|
||||
{
|
||||
foreach (var girlNode in girlList)
|
||||
{
|
||||
var girlId = HouseJson.ToInt(girlNode);
|
||||
if (girlId is > 0 and < 31)
|
||||
bits |= 1u << girlId;
|
||||
}
|
||||
}
|
||||
if (bits != originalBits)
|
||||
await HouseAttr.SetAsync(connection, bitsSid, bits, sync);
|
||||
|
||||
nAddExp = maxScore / 10;
|
||||
}
|
||||
|
||||
if (nAddExp > 0)
|
||||
{
|
||||
var expSid = HouseArcadeInfoStart + ArcadeAttrExpOffset;
|
||||
var prevExp = HouseAttr.Read(player, expSid);
|
||||
await HouseAttr.SetAsync(connection, expSid, prevExp + (uint)nAddExp, sync);
|
||||
}
|
||||
|
||||
var rsp = new JsonObject
|
||||
{
|
||||
["nAddExp"] = nAddExp,
|
||||
["FuncName"] = "ArcadeGameSettlement"
|
||||
};
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Success(rsp), sync);
|
||||
}
|
||||
|
||||
private struct ArcadePropUseSlot
|
||||
{
|
||||
public int Type { get; set; }
|
||||
public int Id { get; set; }
|
||||
public ushort Count { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("ArcadeGameLogSettlement")]
|
||||
public class ArcadeGameLogSettlement : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var rsp = new JsonObject { ["FuncName"] = "ArcadeGameLogSettlement" };
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Success(rsp));
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("ArcadeGameGetLevelReward")]
|
||||
public class ArcadeGameGetLevelReward : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var rsp = new JsonObject { ["FuncName"] = "ArcadeGameGetLevelReward" };
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Success(rsp));
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("ArcadeGameGetAchReward")]
|
||||
public class ArcadeGameGetAchReward : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var rsp = new JsonObject { ["FuncName"] = "ArcadeGameGetAchReward" };
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Success(rsp));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using MikuSB.Proto;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.House;
|
||||
|
||||
[HouseFunc("GirlRegister")]
|
||||
public class GirlRegister : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var girlId = HouseJson.NumField(root, "GirlId");
|
||||
var sync = new NtfSyncPlayer();
|
||||
if (girlId > 0)
|
||||
await HouseAttr.SetAsync(connection, HouseAttr.GirlRoomNumSid(girlId), HouseAttr.BedroomRegisteredNoRoom, sync);
|
||||
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Synthesize(root), sync);
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("SetBedroomGirlId")]
|
||||
public class SetBedroomGirlId : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var bedroomId = HouseJson.NumField(root, "BedroomId");
|
||||
var girlId = HouseJson.NumField(root, "GirlId");
|
||||
var sync = new NtfSyncPlayer();
|
||||
if (bedroomId > 0 && girlId > 0)
|
||||
await HouseAttr.MoveGirlIntoRoomAsync(connection, girlId, bedroomId, sync);
|
||||
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Synthesize(root), sync);
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("GirlRoomChange")]
|
||||
public class GirlRoomChange : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var girlId = HouseJson.NumField(root, "GirlId");
|
||||
var roomId = HouseJson.NumField(root, "RoomId");
|
||||
var oldRoomId = girlId > 0 ? (int)HouseAttr.Read(connection.Player!, HouseAttr.GirlRoomNumSid(girlId)) : 0;
|
||||
var sync = new NtfSyncPlayer();
|
||||
if (girlId > 0 && roomId > 0)
|
||||
await HouseAttr.MoveGirlIntoRoomAsync(connection, girlId, roomId, sync);
|
||||
|
||||
var rsp = new JsonObject
|
||||
{
|
||||
["FuncName"] = "GirlRoomChangeSuccess",
|
||||
["GirlId"] = girlId,
|
||||
["OldRoomId"] = oldRoomId,
|
||||
["NewRoomId"] = roomId
|
||||
};
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Success(rsp), sync);
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("GirlLeaveRoom")]
|
||||
public class GirlLeaveRoom : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var bedroomId = HouseJson.NumField(root, "BedroomId");
|
||||
var girlId = HouseJson.NumField(root, "GirlId");
|
||||
var sync = new NtfSyncPlayer();
|
||||
if (bedroomId > 0 && girlId > 0)
|
||||
{
|
||||
await HouseAttr.SetAsync(connection, HouseAttr.BedroomSlotSid(bedroomId), 0, sync);
|
||||
await HouseAttr.SetAsync(connection, HouseAttr.GirlRoomNumSid(girlId), HouseAttr.BedroomRegisteredNoRoom, sync);
|
||||
}
|
||||
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Synthesize(root), sync);
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("ExchangeRoomGirl")]
|
||||
public class ExchangeRoomGirl : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var roomId1 = HouseJson.NumField(root, "RoomId1");
|
||||
var roomId2 = HouseJson.NumField(root, "RoomId2");
|
||||
var sync = new NtfSyncPlayer();
|
||||
if (roomId1 > 0 && roomId2 > 0 && roomId1 != roomId2)
|
||||
{
|
||||
var slot1 = HouseAttr.BedroomSlotSid(roomId1);
|
||||
var slot2 = HouseAttr.BedroomSlotSid(roomId2);
|
||||
var girl1 = HouseAttr.Read(connection.Player!, slot1);
|
||||
var girl2 = HouseAttr.Read(connection.Player!, slot2);
|
||||
await HouseAttr.SetAsync(connection, slot1, girl2, sync);
|
||||
await HouseAttr.SetAsync(connection, slot2, girl1, sync);
|
||||
if (girl1 > 0) await HouseAttr.SetAsync(connection, HouseAttr.GirlRoomNumSid((int)girl1), (uint)roomId2, sync);
|
||||
if (girl2 > 0) await HouseAttr.SetAsync(connection, HouseAttr.GirlRoomNumSid((int)girl2), (uint)roomId1, sync);
|
||||
}
|
||||
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Synthesize(root), sync);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using MikuSB.Proto;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.House;
|
||||
|
||||
[HouseFunc("SetGroupFurIndex")]
|
||||
public class SetGroupFurIndex : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var areaId = HouseJson.NumField(root, "AreaId");
|
||||
var groupId = HouseJson.NumField(root, "GroupId");
|
||||
var index = HouseJson.NumField(root, "Index");
|
||||
var sync = new NtfSyncPlayer();
|
||||
if (areaId > 0 && groupId is >= 1 and <= 10)
|
||||
{
|
||||
var sid = (uint)(areaId * 50 + 20);
|
||||
var prev = HouseAttr.Read(connection.Player!, sid);
|
||||
var shift = (groupId - 1) * 3;
|
||||
var mask = ~(0b111u << shift);
|
||||
var next = (prev & mask) | (((uint)index & 0b111u) << shift);
|
||||
await HouseAttr.SetAsync(connection, sid, next, sync, sendImmediate: true);
|
||||
}
|
||||
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Synthesize(root), sync);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using MikuSB.Proto;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.House;
|
||||
|
||||
[HouseFunc("SetPlayerRingInfo")]
|
||||
public class SetPlayerRingInfo : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var ringId = HouseJson.NumField(root, "RingId");
|
||||
var ringPos = HouseJson.NumField(root, "RingPos");
|
||||
var ringOffset = HouseJson.NumField(root, "RingOffset");
|
||||
var sync = new NtfSyncPlayer();
|
||||
if (ringPos is >= 1 and <= 10 && ringOffset is >= 0 and <= 2)
|
||||
{
|
||||
var sid = HouseAttr.PlayerRingInfoSidBase + (uint)ringPos;
|
||||
var prev = HouseAttr.Read(connection.Player!, sid);
|
||||
var shift = ringOffset * 10;
|
||||
var mask = ~(0x3ffu << shift);
|
||||
var next = (prev & mask) | (((uint)ringId & 0x3ffu) << shift);
|
||||
await HouseAttr.SetAsync(connection, sid, next, sync, deleteIfZero: true, sendImmediate: true);
|
||||
}
|
||||
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Synthesize(root), sync);
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("ReadGirlLoveStory")]
|
||||
public class ReadGirlLoveStory : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var girlId = HouseJson.NumField(root, "GirlId");
|
||||
var index = HouseJson.NumField(root, "Index");
|
||||
var sync = new NtfSyncPlayer();
|
||||
if (girlId > 0 && index is >= 0 and <= 30)
|
||||
{
|
||||
var sid = (uint)(girlId * 50 + 2);
|
||||
var prev = HouseAttr.Read(connection.Player!, sid);
|
||||
var next = prev | (1u << index);
|
||||
await HouseAttr.SetAsync(connection, sid, next, sync, sendImmediate: true);
|
||||
}
|
||||
|
||||
var rsp = new JsonObject
|
||||
{
|
||||
["GirlId"] = girlId,
|
||||
["Index"] = index,
|
||||
["tbReward"] = new JsonArray(),
|
||||
["FuncName"] = "ReadGirlLoveStorySuccess"
|
||||
};
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Success(rsp), sync);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
using MikuSB.Proto;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.House;
|
||||
|
||||
[HouseFunc("UnLockWaterGunGameItem")]
|
||||
public class UnLockWaterGunGameItem : IHouseFuncHandler
|
||||
{
|
||||
private const uint HouseHotSpringInfoStart = 15000;
|
||||
private const uint WaterGunItemCollectBegin = 17;
|
||||
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var sync = new NtfSyncPlayer();
|
||||
if (root["tbItem"] is JsonArray items)
|
||||
{
|
||||
var touched = new Dictionary<uint, uint>();
|
||||
foreach (var node in items)
|
||||
{
|
||||
var itemId = HouseJson.ToInt(node);
|
||||
if (itemId is < 0 or > 60) continue;
|
||||
var offset = itemId / 30;
|
||||
var bit = itemId % 30;
|
||||
var sid = HouseHotSpringInfoStart + WaterGunItemCollectBegin + (uint)offset;
|
||||
var cur = touched.TryGetValue(sid, out var existing)
|
||||
? existing
|
||||
: HouseAttr.Read(connection.Player!, sid);
|
||||
touched[sid] = cur | (1u << bit);
|
||||
}
|
||||
|
||||
foreach (var (sid, value) in touched)
|
||||
await HouseAttr.SetAsync(connection, sid, value, sync);
|
||||
}
|
||||
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Synthesize(root), sync);
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("RouletteEnd")]
|
||||
public class RouletteEnd : IHouseFuncHandler
|
||||
{
|
||||
private const uint HouseHotSpringInfoStart = 15000;
|
||||
private const uint MaxRoundsInWaterGun = 16;
|
||||
private const uint HasCompleteGameGuide = 19;
|
||||
private const uint HotSpringGirlInfoStart = 15100;
|
||||
private const uint HotSpringGirlAttrCount = 10;
|
||||
private const uint HotSpringGirlHasCompleteStory = 1;
|
||||
private const int RoulettePlayModePlot = 1;
|
||||
private const int RoulettePlayModeEndless = 2;
|
||||
private const int RouletteEndReasonSuccess = 0;
|
||||
private const int RouletteTutorialGirlId = 5;
|
||||
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var modeType = HouseJson.NumField(root, "ModeType");
|
||||
var girlId = HouseJson.NumField(root, "GirlId");
|
||||
var isSuccess = HouseJson.NumField(root, "IsSuccess");
|
||||
var rounds = HouseJson.NumField(root, "Rounds");
|
||||
var sync = new NtfSyncPlayer();
|
||||
|
||||
if (isSuccess == RouletteEndReasonSuccess)
|
||||
{
|
||||
if (modeType == RoulettePlayModePlot && girlId > 0)
|
||||
{
|
||||
await HouseAttr.SetAsync(
|
||||
connection,
|
||||
HotSpringGirlInfoStart + (uint)(girlId * (int)HotSpringGirlAttrCount) + HotSpringGirlHasCompleteStory,
|
||||
1,
|
||||
sync);
|
||||
if (girlId == RouletteTutorialGirlId)
|
||||
await HouseAttr.SetAsync(connection, HouseHotSpringInfoStart + HasCompleteGameGuide, 1, sync);
|
||||
}
|
||||
else if (modeType == RoulettePlayModeEndless && rounds > 0)
|
||||
{
|
||||
var sid = HouseHotSpringInfoStart + MaxRoundsInWaterGun;
|
||||
var prev = HouseAttr.Read(connection.Player!, sid);
|
||||
if ((uint)rounds > prev)
|
||||
await HouseAttr.SetAsync(connection, sid, (uint)rounds, sync);
|
||||
}
|
||||
}
|
||||
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Synthesize(root), sync);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using MikuSB.Proto;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.House;
|
||||
|
||||
[HouseFunc("ChangeNpcSuit")]
|
||||
public class ChangeNpcSuit : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var npcId = HouseJson.NumField(root, "NpcId");
|
||||
var suitId = HouseJson.NumField(root, "SuitId");
|
||||
var sync = new NtfSyncPlayer();
|
||||
await HouseAttr.SetAsync(connection, (uint)(npcId * 50 + 7), (uint)Math.Max(0, suitId), sync, sendImmediate: true);
|
||||
|
||||
var rsp = new JsonObject
|
||||
{
|
||||
["NpcId"] = npcId,
|
||||
["SuitId"] = suitId,
|
||||
["npcSuit"] = new JsonObject
|
||||
{
|
||||
["NpcId"] = npcId,
|
||||
["SuitId"] = suitId
|
||||
},
|
||||
["FuncName"] = "ChangeNpcSuitSuccess"
|
||||
};
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Success(rsp), sync);
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("ChangeNpcSuitByAreaId")]
|
||||
public class ChangeNpcSuitByAreaId : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var npcId = HouseJson.NumField(root, "NpcId");
|
||||
var areaId = HouseJson.NumField(root, "AreaId");
|
||||
var suitId = HouseJson.NumField(root, "SuitId");
|
||||
var sync = new NtfSyncPlayer();
|
||||
|
||||
if (npcId > 0 && areaId > 0)
|
||||
{
|
||||
uint[] slotSids = Enumerable.Range(24, 6).Select(i => (uint)(npcId * 50 + i)).ToArray();
|
||||
uint? chosenSid = null;
|
||||
foreach (var sid in slotSids)
|
||||
{
|
||||
if ((HouseAttr.Read(connection.Player!, sid) & 0xffffu) == (uint)areaId)
|
||||
{
|
||||
chosenSid = sid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (chosenSid == null)
|
||||
{
|
||||
foreach (var sid in slotSids)
|
||||
{
|
||||
if (HouseAttr.Read(connection.Player!, sid) == 0)
|
||||
{
|
||||
chosenSid = sid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chosenSid ??= slotSids[0];
|
||||
var packed = (((uint)suitId & 0xffffu) << 16) | ((uint)areaId & 0xffffu);
|
||||
await HouseAttr.SetAsync(connection, chosenSid.Value, packed, sync, sendImmediate: true);
|
||||
}
|
||||
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Synthesize(root), sync);
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("ChangeGirlBeachSuitId")]
|
||||
public class ChangeGirlBeachSuitId : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var npcId = HouseJson.NumField(root, "NpcId");
|
||||
var suitId = HouseJson.NumField(root, "SuitId");
|
||||
var sync = new NtfSyncPlayer();
|
||||
if (npcId > 0)
|
||||
await HouseAttr.SetAsync(connection, (uint)(npcId * 50 + 8), (uint)Math.Max(0, suitId), sync, sendImmediate: true);
|
||||
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Synthesize(root), sync);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.House;
|
||||
|
||||
// PubGameEnter — returns nSeed for client-side game initialization.
|
||||
[HouseFunc("PubGameEnter")]
|
||||
public class PubGameEnter : IHouseFuncHandler
|
||||
{
|
||||
private static readonly Random Random = new();
|
||||
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var rsp = new JsonObject
|
||||
{
|
||||
["FuncName"] = "PubGameEnter",
|
||||
["nSeed"] = Random.Next(1, 1_000_000_000),
|
||||
["nModeType"] = 1,
|
||||
["bIsGuide"] = false,
|
||||
["bHasTry"] = false
|
||||
};
|
||||
await CallGSRouter.SendScript(connection, "House_Request", rsp.ToJsonString());
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("PubGameMulExit")]
|
||||
public class PubGameMulExit : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var rsp = new JsonObject { ["FuncName"] = "PubGameMulExit" };
|
||||
await CallGSRouter.SendScript(connection, "House_Request", rsp.ToJsonString());
|
||||
}
|
||||
}
|
||||
|
||||
// PubGameSettlement — nAddExp=0 on private server.
|
||||
[HouseFunc("PubGameSettlement")]
|
||||
public class PubGameSettlement : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var rsp = new JsonObject { ["FuncName"] = "PubGameSettlement", ["nAddExp"] = 0 };
|
||||
await CallGSRouter.SendScript(connection, "House_Request", rsp.ToJsonString());
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("PubGameGetReward")]
|
||||
public class PubGameGetReward : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var rsp = new JsonObject { ["FuncName"] = "PubGameGetReward" };
|
||||
await CallGSRouter.SendScript(connection, "House_Request", rsp.ToJsonString());
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("PubGameGetAchReward")]
|
||||
public class PubGameGetAchReward : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var rsp = new JsonObject { ["FuncName"] = "PubGameGetAchReward" };
|
||||
await CallGSRouter.SendScript(connection, "House_Request", rsp.ToJsonString());
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("PubGameAchievementFinish")]
|
||||
public class PubGameAchievementFinish : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var rsp = new JsonObject { ["FuncName"] = "PubGameAchievementFinish" };
|
||||
await CallGSRouter.SendScript(connection, "House_Request", rsp.ToJsonString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
using MikuSB.Database.Player;
|
||||
using MikuSB.GameServer.Game.Player;
|
||||
using MikuSB.Proto;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.House;
|
||||
|
||||
internal static class HouseRequestScript
|
||||
{
|
||||
internal static readonly Dictionary<string, string> FuncNameMap = new()
|
||||
{
|
||||
["ChangeGirlBeachSuitId"] = "ChangeGirlBeachSuitIdSuccess",
|
||||
["ChangeNpcSuitByAreaId"] = "ChangeNpcSuitByAreaIdRsp",
|
||||
["SetGroupFurIndex"] = "SetGroupFurSuccess",
|
||||
["RouletteEnd"] = "RouletteEndRsp",
|
||||
["UnLockWaterGunGameItem"] = "UnLockWaterGunGameItemRsp",
|
||||
["ChangeNpcSuit"] = "ChangeNpcSuitSuccess",
|
||||
["GiveGiftToArea"] = "GiveGiftToAreaSuccess",
|
||||
["BuyRefreshMapTimes"] = "BuyRefreshMapTimesSuccess",
|
||||
["CompleteHousePuzzleTask"] = "CompleteHousePuzzleTaskSuccess",
|
||||
["CompleteStarWishTask"] = "CompleteStarWishTaskSuccess",
|
||||
["SetPlayerRingInfo"] = "SetPlayerRingInfoSuccess",
|
||||
["ReadGirlLoveStory"] = "ReadGirlLoveStorySuccess",
|
||||
["GirlRoomChange"] = "GirlRoomChangeSuccess",
|
||||
["GirlRegister"] = "GirlRegisterSuccess"
|
||||
};
|
||||
|
||||
internal static string Synthesize(JsonObject request)
|
||||
{
|
||||
var funcName = request["FuncName"]?.GetValue<string>();
|
||||
var response = CreateSuccessObject();
|
||||
foreach (var (key, value) in request)
|
||||
{
|
||||
if (key is "FuncName" or "tblog")
|
||||
continue;
|
||||
|
||||
response[key] = value?.DeepClone();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(funcName))
|
||||
response["FuncName"] = FuncNameMap.TryGetValue(funcName, out var renamed) ? renamed : funcName;
|
||||
|
||||
return response.ToJsonString();
|
||||
}
|
||||
|
||||
internal static string Success(JsonObject? extra = null) => CreateSuccessObject(extra).ToJsonString();
|
||||
|
||||
internal static JsonObject CreateSuccessObject(JsonObject? extra = null)
|
||||
{
|
||||
var response = new JsonObject
|
||||
{
|
||||
["bSuccess"] = true,
|
||||
["nResult"] = 0
|
||||
};
|
||||
|
||||
if (extra != null)
|
||||
{
|
||||
foreach (var (key, value) in extra)
|
||||
response[key] = value?.DeepClone();
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
internal static class HouseJson
|
||||
{
|
||||
internal static JsonObject? ParseObject(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonNode.Parse(json) as JsonObject;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
internal static int NumField(JsonObject? obj, string name) => ToInt(obj?[name]);
|
||||
|
||||
internal static int ToInt(JsonNode? node)
|
||||
{
|
||||
if (node == null) return 0;
|
||||
try
|
||||
{
|
||||
if (node is JsonValue value)
|
||||
{
|
||||
if (value.TryGetValue<int>(out var i)) return i;
|
||||
if (value.TryGetValue<uint>(out var u)) return unchecked((int)u);
|
||||
if (value.TryGetValue<long>(out var l)) return unchecked((int)l);
|
||||
if (value.TryGetValue<string>(out var s) && int.TryParse(s, out var parsed)) return parsed;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
internal static class HouseAttr
|
||||
{
|
||||
internal const uint Gid = 101;
|
||||
internal const uint BedroomStartSid = 2550;
|
||||
internal const uint BedroomRegisteredNoRoom = 100;
|
||||
internal const uint PlayerRingInfoSidBase = 3174;
|
||||
|
||||
internal static uint Read(PlayerInstance player, uint sid)
|
||||
{
|
||||
var attr = player.Data.Attrs.FirstOrDefault(x => x.Gid == Gid && x.Sid == sid);
|
||||
return attr?.Val ?? 0;
|
||||
}
|
||||
|
||||
internal static async Task SetAsync(
|
||||
Connection connection,
|
||||
uint sid,
|
||||
uint value,
|
||||
NtfSyncPlayer sync,
|
||||
bool deleteIfZero = false,
|
||||
bool sendImmediate = false)
|
||||
{
|
||||
var player = connection.Player!;
|
||||
var attr = player.Data.Attrs.FirstOrDefault(x => x.Gid == Gid && x.Sid == sid);
|
||||
if (value == 0 && deleteIfZero)
|
||||
{
|
||||
if (attr != null)
|
||||
player.Data.Attrs.Remove(attr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (attr == null)
|
||||
{
|
||||
attr = new PlayerAttr { Gid = Gid, Sid = sid };
|
||||
player.Data.Attrs.Add(attr);
|
||||
}
|
||||
attr.Val = value;
|
||||
}
|
||||
|
||||
sync.Custom[player.ToPackedAttrKey(Gid, sid)] = value;
|
||||
sync.Custom[player.ToShiftedAttrKey(Gid, sid)] = value;
|
||||
if (sendImmediate)
|
||||
await player.SendPacket(CmdIds.NtfSetAttr, new NtfSetAttr { Gid = Gid, Sid = sid, Val = value });
|
||||
}
|
||||
|
||||
internal static uint BedroomSlotSid(int roomId) => BedroomStartSid + (uint)roomId;
|
||||
|
||||
internal static uint GirlRoomNumSid(int girlId) => (uint)(girlId * 50 + 1);
|
||||
|
||||
internal static async Task MoveGirlIntoRoomAsync(Connection connection, int girlId, int roomId, NtfSyncPlayer sync)
|
||||
{
|
||||
var player = connection.Player!;
|
||||
var oldRoom = (int)Read(player, GirlRoomNumSid(girlId));
|
||||
var targetSlotSid = BedroomSlotSid(roomId);
|
||||
var oldSlotSid = oldRoom is >= 1 and < 100 ? BedroomSlotSid(oldRoom) : 0;
|
||||
var occupant = Read(player, targetSlotSid);
|
||||
|
||||
await SetAsync(connection, targetSlotSid, (uint)girlId, sync);
|
||||
await SetAsync(connection, GirlRoomNumSid(girlId), (uint)roomId, sync);
|
||||
|
||||
if (oldRoom is >= 1 and < 100 && oldRoom != roomId)
|
||||
await SetAsync(connection, oldSlotSid, 0, sync);
|
||||
|
||||
if (occupant > 0 && occupant != (uint)girlId)
|
||||
{
|
||||
if (oldRoom is >= 1 and < 100 && oldRoom != roomId)
|
||||
{
|
||||
await SetAsync(connection, oldSlotSid, occupant, sync);
|
||||
await SetAsync(connection, GirlRoomNumSid((int)occupant), (uint)oldRoom, sync);
|
||||
}
|
||||
else
|
||||
{
|
||||
await SetAsync(connection, GirlRoomNumSid((int)occupant), BedroomRegisteredNoRoom, sync);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static uint PackArcadePropUse(int type, int id, ushort count) =>
|
||||
(((uint)count & 0xffffu) << 16) | (((uint)id & 0xffu) << 8) | ((uint)type & 0xffu);
|
||||
}
|
||||
117
GameServer/Server/CallGS/Handlers/House/House_Func/HouseThrow.cs
Normal file
117
GameServer/Server/CallGS/Handlers/House/House_Func/HouseThrow.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using MikuSB.Proto;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.House;
|
||||
|
||||
[HouseFunc("GameEnterMainUI")]
|
||||
public class ThrowGameEnterMainUI : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var rsp = new JsonObject
|
||||
{
|
||||
["FuncName"] = "GameEnterMainUI",
|
||||
["tblockGirlList"] = new JsonArray()
|
||||
};
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Success(rsp));
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("ThrowGameTutorialFinish")]
|
||||
public class ThrowGameTutorialFinish : IHouseFuncHandler
|
||||
{
|
||||
private const uint HouseBeachInfoStart = 17000;
|
||||
private const uint ThrowGameTutorialOffset = 10;
|
||||
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var index = Math.Max(0, HouseJson.NumField(root, "Index"));
|
||||
var sync = new NtfSyncPlayer();
|
||||
await HouseAttr.SetAsync(connection, HouseBeachInfoStart + ThrowGameTutorialOffset + (uint)index, 1, sync);
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Synthesize(root), sync);
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("ThrowGameEnter")]
|
||||
public class ThrowGameEnter : IHouseFuncHandler
|
||||
{
|
||||
private static readonly Random Random = new();
|
||||
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var rsp = new JsonObject
|
||||
{
|
||||
["FuncName"] = "ThrowGameEnter",
|
||||
["nSeed"] = Random.Next(1, 1_000_000_000)
|
||||
};
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Success(rsp));
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("ThrowGameSettlement")]
|
||||
public class ThrowGameSettlement : IHouseFuncHandler
|
||||
{
|
||||
private const uint HouseBeachInfoStart = 17000;
|
||||
private const uint ThrowGameChallengePointsOffset = 2;
|
||||
private const uint ThrowGameUnlockDrinkStartOffset = 50;
|
||||
private const int ThrowGameModeChallenge = 2;
|
||||
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
|
||||
var modeType = HouseJson.NumField(root, "nModeType");
|
||||
var score = Math.Max(0, HouseJson.NumField(root, "nScore"));
|
||||
var sync = new NtfSyncPlayer();
|
||||
if (root["tbUnlockDrink"] is JsonObject unlockDrink && unlockDrink["nDrinkIDs"] is JsonArray drinks)
|
||||
{
|
||||
foreach (var drinkNode in drinks)
|
||||
{
|
||||
var drinkId = HouseJson.ToInt(drinkNode);
|
||||
if (drinkId <= 0) continue;
|
||||
var sid = HouseBeachInfoStart + ThrowGameUnlockDrinkStartOffset + (uint)drinkId;
|
||||
var prev = HouseAttr.Read(connection.Player!, sid);
|
||||
await HouseAttr.SetAsync(connection, sid, prev + 1, sync);
|
||||
}
|
||||
}
|
||||
|
||||
if (modeType == ThrowGameModeChallenge && score > 0)
|
||||
{
|
||||
var sid = HouseBeachInfoStart + ThrowGameChallengePointsOffset;
|
||||
var prev = HouseAttr.Read(connection.Player!, sid);
|
||||
if ((uint)score > prev)
|
||||
await HouseAttr.SetAsync(connection, sid, (uint)score, sync);
|
||||
}
|
||||
|
||||
var rsp = new JsonObject
|
||||
{
|
||||
["nAddExp"] = score,
|
||||
["FuncName"] = "ThrowGameSettlement"
|
||||
};
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Success(rsp), sync);
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("ThrowGameGetLevelReward")]
|
||||
public class ThrowGameGetLevelReward : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var rsp = new JsonObject { ["FuncName"] = "ThrowGameGetLevelReward" };
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Success(rsp));
|
||||
}
|
||||
}
|
||||
|
||||
[HouseFunc("ThrowGameGetAchReward")]
|
||||
public class ThrowGameGetAchReward : IHouseFuncHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param)
|
||||
{
|
||||
var rsp = new JsonObject { ["FuncName"] = "ThrowGameGetAchReward" };
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Success(rsp));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.House;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
public class HouseFuncAttribute(string funcName) : Attribute
|
||||
{
|
||||
public string FuncName { get; } = funcName;
|
||||
}
|
||||
|
||||
public interface IHouseFuncHandler
|
||||
{
|
||||
Task Handle(Connection connection, string param);
|
||||
}
|
||||
42
GameServer/Server/CallGS/Handlers/House/House_Request.cs
Normal file
42
GameServer/Server/CallGS/Handlers/House/House_Request.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.House;
|
||||
|
||||
[CallGSApi("House_Request")]
|
||||
public class House_Request : ICallGSHandler
|
||||
{
|
||||
private static readonly Dictionary<string, IHouseFuncHandler> Handlers = [];
|
||||
|
||||
static House_Request()
|
||||
{
|
||||
foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
|
||||
{
|
||||
foreach (var attr in type.GetCustomAttributes<HouseFuncAttribute>())
|
||||
Handlers[attr.FuncName] = (IHouseFuncHandler)Activator.CreateInstance(type)!;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
var req = JsonSerializer.Deserialize<HouseRequestParam>(param);
|
||||
if (req?.FuncName == null) return;
|
||||
|
||||
if (Handlers.TryGetValue(req.FuncName, out var handler))
|
||||
{
|
||||
await handler.Handle(connection, param);
|
||||
return;
|
||||
}
|
||||
|
||||
var root = HouseJson.ParseObject(param);
|
||||
if (root == null) return;
|
||||
await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Synthesize(root));
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class HouseRequestParam
|
||||
{
|
||||
[JsonPropertyName("FuncName")]
|
||||
public string? FuncName { get; set; }
|
||||
}
|
||||
178
GameServer/Server/CallGS/Handlers/Rogue3D/Rogue3DStateHelper.cs
Normal file
178
GameServer/Server/CallGS/Handlers/Rogue3D/Rogue3DStateHelper.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
using MikuSB.Data;
|
||||
using MikuSB.Database.Player;
|
||||
using MikuSB.GameServer.Game.Player;
|
||||
using MikuSB.Proto;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.Rogue3D;
|
||||
|
||||
internal static class Rogue3DStateHelper
|
||||
{
|
||||
private const uint GroupId = 124;
|
||||
private const uint LevelPassStart = 20;
|
||||
private const uint DailyBuffStart = 51;
|
||||
private const uint DailyBuffEnd = 65;
|
||||
private const int DailyBuffBitCount = 10;
|
||||
private const int DailyBuffBitsPerValue = DailyBuffBitCount + 1;
|
||||
private const uint DailyBuffMask = (1u << DailyBuffBitCount) - 1;
|
||||
private const uint UnlockDiff1Sid = LevelPassStart + 1;
|
||||
private const uint UnlockDiff2Sid = LevelPassStart + 2;
|
||||
private const uint UnlockDiff3Sid = LevelPassStart + 3;
|
||||
private const uint UnlockDiff4Sid = LevelPassStart + 4;
|
||||
private static uint[]? ShuffledDailyBuffIds;
|
||||
|
||||
public static NtfSyncPlayer EnsureUnlockState(PlayerInstance player)
|
||||
{
|
||||
var sync = new NtfSyncPlayer();
|
||||
|
||||
EnsureMinAttr(player, UnlockDiff1Sid, 1, sync);
|
||||
EnsureMinAttr(player, UnlockDiff2Sid, 1, sync);
|
||||
EnsureMinAttr(player, UnlockDiff3Sid, 1, sync);
|
||||
EnsureMinAttr(player, UnlockDiff4Sid, 1, sync);
|
||||
|
||||
foreach (var scienceSid in GetUnlockTalentScienceSids())
|
||||
{
|
||||
EnsureMinAttr(player, scienceSid, 1, sync);
|
||||
}
|
||||
|
||||
EnsureDailyBuffAttrs(player, sync);
|
||||
|
||||
return sync;
|
||||
}
|
||||
|
||||
private static IEnumerable<uint> GetUnlockTalentScienceSids()
|
||||
{
|
||||
return GameData.Rogue3DTalentData.Values
|
||||
.Select(x => x.UnlockCondition)
|
||||
.Where(x => x > 0)
|
||||
.Distinct()
|
||||
.OrderBy(x => x);
|
||||
}
|
||||
|
||||
private static void EnsureDailyBuffAttrs(PlayerInstance player, NtfSyncPlayer sync)
|
||||
{
|
||||
var buffIds = GetOrCreateDailyBuffIds()
|
||||
.Take((int)(DailyBuffEnd - DailyBuffStart + 1) * 3)
|
||||
.ToArray();
|
||||
|
||||
var index = 0;
|
||||
for (var sid = DailyBuffStart; sid <= DailyBuffEnd; sid++)
|
||||
{
|
||||
uint packed = 0;
|
||||
for (var slot = 0; slot < 3 && index < buffIds.Length; slot++, index++)
|
||||
{
|
||||
packed |= (buffIds[index] & DailyBuffMask) << (slot * DailyBuffBitsPerValue);
|
||||
}
|
||||
|
||||
SetAttr(player, sid, packed, sync);
|
||||
}
|
||||
}
|
||||
|
||||
private static uint[] GetOrCreateDailyBuffIds()
|
||||
{
|
||||
if (ShuffledDailyBuffIds != null)
|
||||
{
|
||||
return ShuffledDailyBuffIds;
|
||||
}
|
||||
|
||||
var groupedBuffIds = GameData.Rogue3DDailyBuffData.Values
|
||||
.Where(x => x.ScoreBuffId > 0 && x.ScoreBuffId <= DailyBuffMask)
|
||||
.GroupBy(x => x.GroupId)
|
||||
.OrderBy(x => x.Key)
|
||||
.Select(x => x
|
||||
.OrderBy(y => y.Id)
|
||||
.Select(y => y.ScoreBuffId)
|
||||
.Distinct()
|
||||
.ToList())
|
||||
.ToList();
|
||||
|
||||
var random = new Random();
|
||||
foreach (var group in groupedBuffIds)
|
||||
{
|
||||
Shuffle(group, random);
|
||||
}
|
||||
Shuffle(groupedBuffIds, random);
|
||||
|
||||
var buffIds = new List<uint>();
|
||||
var indexByGroup = new int[groupedBuffIds.Count];
|
||||
var hasRemaining = true;
|
||||
|
||||
while (hasRemaining)
|
||||
{
|
||||
hasRemaining = false;
|
||||
for (var i = 0; i < groupedBuffIds.Count; i++)
|
||||
{
|
||||
var group = groupedBuffIds[i];
|
||||
var index = indexByGroup[i];
|
||||
if (index >= group.Count)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
buffIds.Add(group[index]);
|
||||
indexByGroup[i] = index + 1;
|
||||
hasRemaining = true;
|
||||
}
|
||||
}
|
||||
|
||||
ShuffledDailyBuffIds = buffIds.ToArray();
|
||||
return ShuffledDailyBuffIds;
|
||||
}
|
||||
|
||||
private static IEnumerable<uint> GetDailyBuffIds()
|
||||
{
|
||||
return GetOrCreateDailyBuffIds();
|
||||
}
|
||||
|
||||
private static void Shuffle<T>(IList<T> list, Random random)
|
||||
{
|
||||
for (var i = list.Count - 1; i > 0; i--)
|
||||
{
|
||||
var swapIndex = random.Next(i + 1);
|
||||
(list[i], list[swapIndex]) = (list[swapIndex], list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void EnsureMinAttr(PlayerInstance player, uint sid, uint value, NtfSyncPlayer sync, bool overwrite = false)
|
||||
{
|
||||
var attr = player.Data.Attrs.FirstOrDefault(x => x.Gid == GroupId && x.Sid == sid);
|
||||
if (attr == null)
|
||||
{
|
||||
attr = new PlayerAttr { Gid = GroupId, Sid = sid, Val = value };
|
||||
player.Data.Attrs.Add(attr);
|
||||
AddSync(player, sync, sid, value);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((!overwrite && attr.Val >= value) || (overwrite && attr.Val == value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
attr.Val = value;
|
||||
AddSync(player, sync, sid, value);
|
||||
}
|
||||
|
||||
private static void SetAttr(PlayerInstance player, uint sid, uint value, 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 == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
attr.Val = value;
|
||||
AddSync(player, sync, sid, value);
|
||||
}
|
||||
|
||||
private static void AddSync(PlayerInstance player, NtfSyncPlayer sync, uint sid, uint value)
|
||||
{
|
||||
sync.Custom[player.ToPackedAttrKey(GroupId, sid)] = value;
|
||||
sync.Custom[player.ToShiftedAttrKey(GroupId, sid)] = value;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ public class Rogue3D_CheckOpenAct : ICallGSHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
await CallGSRouter.SendScript(connection, "Rogue3D_CheckOpenAct", "{\"bOpen\":true}");
|
||||
var sync = Rogue3DStateHelper.EnsureUnlockState(connection.Player!);
|
||||
await CallGSRouter.SendScript(connection, "Rogue3D_CheckOpenAct", "{\"bOpen\":true}", sync);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ public class Rogue3D_SelectMode : ICallGSHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
await CallGSRouter.SendScript(connection, "Rogue3D_SelectMode", "{}");
|
||||
var sync = Rogue3DStateHelper.EnsureUnlockState(connection.Player!);
|
||||
await CallGSRouter.SendScript(connection, "Rogue3D_SelectMode", "{}", sync);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using MikuSB.Proto;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.Girl;
|
||||
|
||||
[CallGSApi("Weapon_ReplacePart")]
|
||||
public class Weapon_ReplacePart : ICallGSHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
var req = JsonSerializer.Deserialize<WeaponPartReplaceParam>(param);
|
||||
if (req == null)
|
||||
{
|
||||
await CallGSRouter.SendScript(connection, "Weapon_ReplacePart", "{\"sErr\":\"error.BadParam\"}");
|
||||
return;
|
||||
}
|
||||
|
||||
var player = connection.Player!;
|
||||
var weaponData = player.InventoryManager.GetWeaponItem(req.Id);
|
||||
if (weaponData == null)
|
||||
{
|
||||
await CallGSRouter.SendScript(connection, "Weapon_ReplacePart", "{}");
|
||||
return;
|
||||
}
|
||||
|
||||
uint partId = 0;
|
||||
if (req.PartId != -1)
|
||||
{
|
||||
var partData = player.InventoryManager.GetNormalItem((uint)req.PartId);
|
||||
if (partData != null) partId = partData.UniqueId;
|
||||
}
|
||||
|
||||
weaponData.PartSlots[req.Type] = partId;
|
||||
var sync = new NtfSyncPlayer
|
||||
{
|
||||
Items = { weaponData.ToProto() }
|
||||
};
|
||||
await CallGSRouter.SendScript(connection, "Weapon_ReplacePart", "null", sync);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class WeaponPartReplaceParam
|
||||
{
|
||||
public int PartId { get; set; }
|
||||
public uint Type { get; set; }
|
||||
public uint Id { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using MikuSB.Enums.Item;
|
||||
using MikuSB.Proto;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.Girl;
|
||||
|
||||
[CallGSApi("Weapon_ShowDefaultPart")]
|
||||
public class Weapon_ShowDefaultPart : ICallGSHandler
|
||||
{
|
||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||
{
|
||||
var req = JsonSerializer.Deserialize<WeaponShowDefaultPartParam>(param);
|
||||
if (req == null)
|
||||
{
|
||||
await CallGSRouter.SendScript(connection, "Weapon_ShowDefaultPart", "{\"sErr\":\"error.BadParam\"}");
|
||||
return;
|
||||
}
|
||||
|
||||
var player = connection.Player!;
|
||||
var weaponData = player.InventoryManager.GetWeaponItem(req.Id);
|
||||
if (weaponData == null)
|
||||
{
|
||||
await CallGSRouter.SendScript(connection, "Weapon_ShowDefaultPart", "{}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.Flag == 1) weaponData.Flag = ItemFlagEnum.FLAG_WEAPON_DEFAULT;
|
||||
else weaponData.Flag = ItemFlagEnum.FLAG_READED;
|
||||
|
||||
var sync = new NtfSyncPlayer
|
||||
{
|
||||
Items = { weaponData.ToProto() }
|
||||
};
|
||||
await CallGSRouter.SendScript(connection, "Weapon_ShowDefaultPart", "null", sync);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class WeaponShowDefaultPartParam
|
||||
{
|
||||
[JsonPropertyName("nFlag")] public int Flag { get; set; }
|
||||
public uint Id { get; set; }
|
||||
}
|
||||
@@ -102,11 +102,6 @@ static void UpdateResources(string resourcePackagePath, string resourceTargetDir
|
||||
ZipFile.ExtractToDirectory(resourcePackagePath, resourceStagingDirectory, overwriteFiles: true);
|
||||
|
||||
var extractedRoot = Directory.GetDirectories(resourceStagingDirectory).FirstOrDefault() ?? resourceStagingDirectory;
|
||||
var excelOutputSource = Path.Combine(extractedRoot, "ExcelOutput");
|
||||
if (!Directory.Exists(excelOutputSource))
|
||||
throw new DirectoryNotFoundException($"ExcelOutput directory was not found in resource package: {excelOutputSource}");
|
||||
|
||||
var excelOutputTarget = Path.Combine(resourceTargetDirectory, "ExcelOutput");
|
||||
Directory.CreateDirectory(excelOutputTarget);
|
||||
CopyDirectory(excelOutputSource, excelOutputTarget);
|
||||
Directory.CreateDirectory(resourceTargetDirectory);
|
||||
CopyDirectory(extractedRoot, resourceTargetDirectory);
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ public static class UpdateService
|
||||
"https://github.com/Kei-Luna/MikuSB-Resource/archive/refs/heads/main.zip";
|
||||
private static readonly string[] RequiredResourceFiles =
|
||||
[
|
||||
"card.json",
|
||||
"weapon.json"
|
||||
"item/templates/card.json",
|
||||
"item/templates/weapon.json"
|
||||
];
|
||||
|
||||
public static async Task<bool> TryStartSelfUpdateAsync()
|
||||
@@ -160,11 +160,11 @@ public static class UpdateService
|
||||
|
||||
private static bool AreRequiredResourcesPresent()
|
||||
{
|
||||
var excelOutputPath = Path.Combine(AppContext.BaseDirectory, ConfigManager.Config.Path.ResourcePath, "ExcelOutput");
|
||||
if (!Directory.Exists(excelOutputPath))
|
||||
var resourcePath = Path.Combine(AppContext.BaseDirectory, ConfigManager.Config.Path.ResourcePath);
|
||||
if (!Directory.Exists(resourcePath))
|
||||
return false;
|
||||
|
||||
return RequiredResourceFiles.All(fileName => File.Exists(Path.Combine(excelOutputPath, fileName)));
|
||||
return RequiredResourceFiles.All(fileName => File.Exists(Path.Combine(resourcePath, fileName)));
|
||||
}
|
||||
|
||||
private static async Task DownloadAndInstallResourcesAsync()
|
||||
@@ -187,13 +187,8 @@ public static class UpdateService
|
||||
ZipFile.ExtractToDirectory(resourcePackagePath, resourceStagingDirectory, overwriteFiles: true);
|
||||
|
||||
var extractedRoot = Directory.GetDirectories(resourceStagingDirectory).FirstOrDefault() ?? resourceStagingDirectory;
|
||||
var excelOutputSource = Path.Combine(extractedRoot, "ExcelOutput");
|
||||
if (!Directory.Exists(excelOutputSource))
|
||||
throw new DirectoryNotFoundException($"ExcelOutput directory was not found in resource package: {excelOutputSource}");
|
||||
|
||||
var excelOutputTarget = Path.Combine(resourceTargetDirectory, "ExcelOutput");
|
||||
Directory.CreateDirectory(excelOutputTarget);
|
||||
CopyDirectory(excelOutputSource, excelOutputTarget);
|
||||
Directory.CreateDirectory(resourceTargetDirectory);
|
||||
CopyDirectory(extractedRoot, resourceTargetDirectory);
|
||||
}
|
||||
|
||||
private static bool ConfirmUpdate(string latestVersion)
|
||||
|
||||
@@ -198,7 +198,7 @@ public sealed class ProxyServer(
|
||||
{
|
||||
var pathAndQuery = request.GetPathAndQuery();
|
||||
var uri = new Uri($"http://{ServerHost}:{_options.ServerHttpPort}{pathAndQuery}");
|
||||
logger.Info($"Redirect: {request.Method} {request.HostOverride ?? request.Host}{pathAndQuery} -> {uri}");
|
||||
if (ConfigManager.Config.HttpServer.EnableLog) logger.Info($"Redirect: {request.Method} {request.HostOverride ?? request.Host}{pathAndQuery} -> {uri}");
|
||||
await SendHttpRequestAsync(clientStream, request, uri, true, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
v=1.6
|
||||
v=2.0
|
||||
Reference in New Issue
Block a user