Compare commits

..

5 Commits

Author SHA1 Message Date
Kei-Luna
7507d10072 Updater fixes due to changes in resource folders 2026-05-09 17:39:17 +09:00
Kei-Luna
8a7a919d04 Changed the Resources folder structure to match the official one. 2026-05-09 17:30:25 +09:00
Kei-Luna
2d1079a80d I rewrote House_Request based on the code provided by undownding. 2026-05-05 07:35:34 +09:00
Kei-Luna
677e4027b9 Update version.txt 2026-05-03 13:50:50 +09:00
Kei-Luna
4dc28ae423 more House_Func 2026-05-03 13:42:09 +09:00
39 changed files with 1074 additions and 138 deletions

View File

@@ -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 class ArItemExcel : ExcelResource
{ {
public uint Genre { get; set; } public uint Genre { get; set; }

View File

@@ -1,8 +1,8 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("break.json")] [ResourceEntity("item/break.json")]
public class BreakExcel : ExcelResource public class BreakExcel : ExcelResource
{ {
[JsonProperty("ID")] public int Id { get; set; } [JsonProperty("ID")] public int Id { get; set; }

View File

@@ -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 class BreakLevelLimitExcel : ExcelResource
{ {
public int ID { get; set; } public int ID { get; set; }

View File

@@ -3,7 +3,7 @@ using Newtonsoft.Json.Linq;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("call_item.json")] [ResourceEntity("item/templates/call_item.json")]
public class CallItemExcel : ExcelResource public class CallItemExcel : ExcelResource
{ {
public uint Genre { get; set; } public uint Genre { get; set; }

View File

@@ -2,7 +2,7 @@
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("card.json")] [ResourceEntity("item/templates/card.json")]
public class CardExcel : ExcelResource public class CardExcel : ExcelResource
{ {
public uint Genre { get; set; } public uint Genre { get; set; }

View File

@@ -2,7 +2,7 @@
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("card_skin.json")] [ResourceEntity("item/templates/card_skin.json")]
public class CardSkinExcel : ExcelResource public class CardSkinExcel : ExcelResource
{ {
public uint Genre { get; set; } public uint Genre { get; set; }

View File

@@ -2,7 +2,7 @@
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("card_skin_parts.json")] [ResourceEntity("item/templates/card_skin_parts.json")]
public class CardSkinPartsExcel : ExcelResource public class CardSkinPartsExcel : ExcelResource
{ {
public uint Genre { get; set; } public uint Genre { get; set; }

View File

@@ -1,6 +1,6 @@
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("level.json")] [ResourceEntity("chapter/level.json")]
public class ChapterLevelExcel : ExcelResource public class ChapterLevelExcel : ExcelResource
{ {
public uint ID { get; set; } public uint ID { get; set; }

View File

@@ -1,6 +1,6 @@
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("daily_level.json")] [ResourceEntity("daily/level.json")]
public class DailyLevelExcel : ExcelResource public class DailyLevelExcel : ExcelResource
{ {
public uint ID { get; set; } public uint ID { get; set; }

View File

@@ -2,7 +2,7 @@
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("manifestation.json")] [ResourceEntity("item/templates/manifestation.json")]
public class ManifestationExcel : ExcelResource public class ManifestationExcel : ExcelResource
{ {
public uint Genre { get; set; } public uint Genre { get; set; }

View File

@@ -1,9 +1,9 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
// nodecondition.json: NodeConditionId → NodeXCost per sub-node (1-9) // nodecondition.json: NodeConditionId → NodeXCost per sub-node (1-9)
[ResourceEntity("nodecondition.json")] [ResourceEntity("item/skill/nodecondition.json")]
public class NodeConditionExcel : ExcelResource public class NodeConditionExcel : ExcelResource
{ {
[JsonProperty("ID")] public uint Id { get; set; } [JsonProperty("ID")] public uint Id { get; set; }

View File

@@ -1,6 +1,6 @@
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("profile.json")] [ResourceEntity("item/templates/profile.json")]
public class ProfileExcel : ExcelResource public class ProfileExcel : ExcelResource
{ {
public uint Genre { get; set; } public uint Genre { get; set; }

View File

@@ -1,8 +1,8 @@
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("recycle.json")] [ResourceEntity("item/recycle.json")]
public class RecycleExcel : ExcelResource public class RecycleExcel : ExcelResource
{ {
public int ID { get; set; } public int ID { get; set; }

View File

@@ -1,8 +1,8 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("dailybuff.json")] [ResourceEntity("dlc/rogue3d/dailybuff.json")]
public class Rogue3DDailyBuffExcel : ExcelResource public class Rogue3DDailyBuffExcel : ExcelResource
{ {
[JsonProperty("ID")] public uint Id { get; set; } [JsonProperty("ID")] public uint Id { get; set; }

View File

@@ -1,8 +1,8 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("server_01_difficult.json")] [ResourceEntity("dlc/rogue3d/server_01_difficult.json")]
public class Rogue3DDifficultExcel : ExcelResource public class Rogue3DDifficultExcel : ExcelResource
{ {
[JsonProperty("DifficultID")] public uint DifficultId { get; set; } [JsonProperty("DifficultID")] public uint DifficultId { get; set; }

View File

@@ -1,8 +1,8 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("server_10_season.json")] [ResourceEntity("dlc/rogue3d/server_10_season.json")]
public class Rogue3DSeasonExcel : ExcelResource public class Rogue3DSeasonExcel : ExcelResource
{ {
[JsonProperty("SeasonID")] public uint SeasonId { get; set; } [JsonProperty("SeasonID")] public uint SeasonId { get; set; }

View File

@@ -1,8 +1,8 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("server_03_talent.json")] [ResourceEntity("dlc/rogue3d/server_03_talent.json")]
public class Rogue3DTalentExcel : ExcelResource public class Rogue3DTalentExcel : ExcelResource
{ {
[JsonProperty("TalentID")] public uint TalentId { get; set; } [JsonProperty("TalentID")] public uint TalentId { get; set; }

View File

@@ -1,9 +1,9 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
// spine.json: SpineId → Node{i}Req (nodecondition ID per master node index) // spine.json: SpineId → Node{i}Req (nodecondition ID per master node index)
[ResourceEntity("spine.json")] [ResourceEntity("item/skill/spine.json")]
public class SpineExcel : ExcelResource public class SpineExcel : ExcelResource
{ {
[JsonProperty("ID")] public uint Id { get; set; } [JsonProperty("ID")] public uint Id { get; set; }

View File

@@ -1,9 +1,9 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("suplies.json")] [ResourceEntity("item/templates/suplies.json")]
public class SuppliesExcel : ExcelResource public class SuppliesExcel : ExcelResource
{ {
public uint Genre { get; set; } public uint Genre { get; set; }

View File

@@ -1,8 +1,8 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("support_card.json")] [ResourceEntity("item/templates/support_card.json")]
public class SupportCardExcel : ExcelResource public class SupportCardExcel : ExcelResource
{ {
public uint Genre { get; set; } public uint Genre { get; set; }

View File

@@ -1,9 +1,9 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("upgrade_exp.json")] [ResourceEntity("item/upgrade_exp.json")]
public class UpgradeExpExcel : ExcelResource public class UpgradeExpExcel : ExcelResource
{ {
public int Lv { get; set; } public int Lv { get; set; }

View File

@@ -1,9 +1,9 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("weapon.json")] [ResourceEntity("item/templates/weapon.json")]
public class WeaponExcel : ExcelResource public class WeaponExcel : ExcelResource
{ {
public uint Genre { get; set; } public uint Genre { get; set; }

View File

@@ -2,7 +2,7 @@
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("weapon_parts.json")] [ResourceEntity("item/templates/weapon_parts.json")]
public class WeaponPartsExcel : ExcelResource public class WeaponPartsExcel : ExcelResource
{ {
public uint Genre { get; set; } public uint Genre { get; set; }

View File

@@ -3,7 +3,7 @@ using Newtonsoft.Json.Linq;
namespace MikuSB.Data.Excel; namespace MikuSB.Data.Excel;
[ResourceEntity("weapon_skin.json")] [ResourceEntity("item/templates/weapon_skin.json")]
public class WeaponSkinExcel : ExcelResource public class WeaponSkinExcel : ExcelResource
{ {
public uint Genre { get; set; } public uint Genre { get; set; }

View File

@@ -46,7 +46,7 @@ public class ResourceManager
foreach (var fileName in attribute.FileName) foreach (var fileName in attribute.FileName)
try try
{ {
var path = ConfigManager.Config.Path.ResourcePath + "/ExcelOutput/" + fileName; var path = ConfigManager.Config.Path.ResourcePath + "/" + fileName;
var file = new FileInfo(path); var file = new FileInfo(path);
if (!file.Exists) if (!file.Exists)
{ {

View File

@@ -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));
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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());
}
}

View File

@@ -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);
}

View 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));
}
}

View File

@@ -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);
}

View File

@@ -1,6 +1,5 @@
using MikuSB.Proto; using System.Reflection;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace MikuSB.GameServer.Server.CallGS.Handlers.House; namespace MikuSB.GameServer.Server.CallGS.Handlers.House;
@@ -8,93 +7,31 @@ namespace MikuSB.GameServer.Server.CallGS.Handlers.House;
[CallGSApi("House_Request")] [CallGSApi("House_Request")]
public class House_Request : ICallGSHandler public class House_Request : ICallGSHandler
{ {
private static readonly Random Random = new(); private static readonly Dictionary<string, IHouseFuncHandler> Handlers = [];
// GID for all house/arcade attributes static House_Request()
private const uint ArcadeGid = 101; {
// HouseStorage.HouseArcadeStart = 18000 foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
// Attr_GirlEndlessModeState = 5 → SID 18005 {
// ConditionType.TeachMode = 8, Attr_ConditionValStart = 36 → SID 18000+36+8 = 18044 foreach (var attr in type.GetCustomAttributes<HouseFuncAttribute>())
private const uint EndlessModeStateSid = 18000 + 5; Handlers[attr.FuncName] = (IHouseFuncHandler)Activator.CreateInstance(type)!;
private const uint TeachModeConditionSid = 18000 + 36 + 8; // = 18044 }
}
public async Task Handle(Connection connection, string param, ushort seqNo) public async Task Handle(Connection connection, string param, ushort seqNo)
{ {
var req = JsonSerializer.Deserialize<HouseRequestParam>(param); var req = JsonSerializer.Deserialize<HouseRequestParam>(param);
if (req?.FuncName == null) return; if (req?.FuncName == null) return;
switch (req.FuncName) if (Handlers.TryGetValue(req.FuncName, out var handler))
{ {
case "ArcadeGameEnterMainUI": await handler.Handle(connection, param);
await HandleArcadeGameEnterMainUI(connection); return;
break;
case "ArcadeGameEnter":
await HandleArcadeGameEnter(connection);
break;
case "ArcadeGameSettlement":
await HandleArcadeGameSettlement(connection);
break;
case "ArcadeGameLogSettlement":
await HandleArcadeGameLogSettlement(connection);
break;
default:
var err = new JsonObject { ["FuncName"] = req.FuncName, ["sErr"] = "error.NotImplemented" };
await CallGSRouter.SendScript(connection, "House_Request", err.ToJsonString());
break;
} }
}
private static async Task HandleArcadeGameEnterMainUI(Connection connection) var root = HouseJson.ParseObject(param);
{ if (root == null) return;
var girlList = new JsonArray(); await CallGSRouter.SendScript(connection, "House_Request", HouseRequestScript.Synthesize(root));
for (int i = 1; i <= 25; i++)
girlList.Add(i);
var rsp = new JsonObject
{
["FuncName"] = "ArcadeGameEnterMainUI",
["tbUnlockGirlList"] = girlList
};
var player = connection.Player!;
var sync = new NtfSyncPlayer();
sync.Custom[player.ToPackedAttrKey(ArcadeGid, TeachModeConditionSid)] = 1;
sync.Custom[player.ToShiftedAttrKey(ArcadeGid, TeachModeConditionSid)] = 1;
// Bits 1-25 set → all girls have endless mode unlocked
const uint endlessAllUnlocked = 0x3FFFFFE; // bits 1-25
sync.Custom[player.ToPackedAttrKey(ArcadeGid, EndlessModeStateSid)] = endlessAllUnlocked;
sync.Custom[player.ToShiftedAttrKey(ArcadeGid, EndlessModeStateSid)] = endlessAllUnlocked;
await CallGSRouter.SendScript(connection, "House_Request", rsp.ToJsonString(), sync);
}
private static async Task HandleArcadeGameEnter(Connection connection)
{
var seed = Random.Next(1, 1_000_000_000);
var rsp = new JsonObject
{
["FuncName"] = "ArcadeGameEnter",
["nSeed"] = seed
};
await CallGSRouter.SendScript(connection, "House_Request", rsp.ToJsonString());
}
private static async Task HandleArcadeGameSettlement(Connection connection)
{
var rsp = new JsonObject
{
["FuncName"] = "ArcadeGameSettlement",
["nAddExp"] = 0
};
await CallGSRouter.SendScript(connection, "House_Request", rsp.ToJsonString());
}
private static async Task HandleArcadeGameLogSettlement(Connection connection)
{
var rsp = new JsonObject { ["FuncName"] = "ArcadeGameLogSettlement" };
await CallGSRouter.SendScript(connection, "House_Request", rsp.ToJsonString());
} }
} }

View File

@@ -102,11 +102,6 @@ static void UpdateResources(string resourcePackagePath, string resourceTargetDir
ZipFile.ExtractToDirectory(resourcePackagePath, resourceStagingDirectory, overwriteFiles: true); ZipFile.ExtractToDirectory(resourcePackagePath, resourceStagingDirectory, overwriteFiles: true);
var extractedRoot = Directory.GetDirectories(resourceStagingDirectory).FirstOrDefault() ?? resourceStagingDirectory; var extractedRoot = Directory.GetDirectories(resourceStagingDirectory).FirstOrDefault() ?? resourceStagingDirectory;
var excelOutputSource = Path.Combine(extractedRoot, "ExcelOutput"); Directory.CreateDirectory(resourceTargetDirectory);
if (!Directory.Exists(excelOutputSource)) CopyDirectory(extractedRoot, resourceTargetDirectory);
throw new DirectoryNotFoundException($"ExcelOutput directory was not found in resource package: {excelOutputSource}");
var excelOutputTarget = Path.Combine(resourceTargetDirectory, "ExcelOutput");
Directory.CreateDirectory(excelOutputTarget);
CopyDirectory(excelOutputSource, excelOutputTarget);
} }

View File

@@ -24,8 +24,8 @@ public static class UpdateService
"https://github.com/Kei-Luna/MikuSB-Resource/archive/refs/heads/main.zip"; "https://github.com/Kei-Luna/MikuSB-Resource/archive/refs/heads/main.zip";
private static readonly string[] RequiredResourceFiles = private static readonly string[] RequiredResourceFiles =
[ [
"card.json", "item/templates/card.json",
"weapon.json" "item/templates/weapon.json"
]; ];
public static async Task<bool> TryStartSelfUpdateAsync() public static async Task<bool> TryStartSelfUpdateAsync()
@@ -160,11 +160,11 @@ public static class UpdateService
private static bool AreRequiredResourcesPresent() private static bool AreRequiredResourcesPresent()
{ {
var excelOutputPath = Path.Combine(AppContext.BaseDirectory, ConfigManager.Config.Path.ResourcePath, "ExcelOutput"); var resourcePath = Path.Combine(AppContext.BaseDirectory, ConfigManager.Config.Path.ResourcePath);
if (!Directory.Exists(excelOutputPath)) if (!Directory.Exists(resourcePath))
return false; 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() private static async Task DownloadAndInstallResourcesAsync()
@@ -187,13 +187,8 @@ public static class UpdateService
ZipFile.ExtractToDirectory(resourcePackagePath, resourceStagingDirectory, overwriteFiles: true); ZipFile.ExtractToDirectory(resourcePackagePath, resourceStagingDirectory, overwriteFiles: true);
var extractedRoot = Directory.GetDirectories(resourceStagingDirectory).FirstOrDefault() ?? resourceStagingDirectory; var extractedRoot = Directory.GetDirectories(resourceStagingDirectory).FirstOrDefault() ?? resourceStagingDirectory;
var excelOutputSource = Path.Combine(extractedRoot, "ExcelOutput"); Directory.CreateDirectory(resourceTargetDirectory);
if (!Directory.Exists(excelOutputSource)) CopyDirectory(extractedRoot, resourceTargetDirectory);
throw new DirectoryNotFoundException($"ExcelOutput directory was not found in resource package: {excelOutputSource}");
var excelOutputTarget = Path.Combine(resourceTargetDirectory, "ExcelOutput");
Directory.CreateDirectory(excelOutputTarget);
CopyDirectory(excelOutputSource, excelOutputTarget);
} }
private static bool ConfirmUpdate(string latestVersion) private static bool ConfirmUpdate(string latestVersion)

View File

@@ -1 +1 @@
v=1.8 v=2.0