diff --git a/Service/Application.Domain/Services/Interface/Business/IGameMagicService.cs b/Service/Application.Domain/Services/Interface/Business/IGameMagicService.cs index 138800c..99b389d 100644 --- a/Service/Application.Domain/Services/Interface/Business/IGameMagicService.cs +++ b/Service/Application.Domain/Services/Interface/Business/IGameMagicService.cs @@ -4,6 +4,7 @@ public interface IGameMagicService { Task UpdateUserMagicTime(string userId,int areaId); Task UpdateUserMagicEndTime(string userId, bool isWin); + Task IsHaveWin(int areaId, string time); Task CheckInMagic(string userId); Task HandleMagicData(); } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Business/GameMagicService.cs b/Service/Application.Domain/Services/Service/Business/GameMagicService.cs index b5e7200..9b226b6 100644 --- a/Service/Application.Domain/Services/Service/Business/GameMagicService.cs +++ b/Service/Application.Domain/Services/Service/Business/GameMagicService.cs @@ -35,6 +35,13 @@ public class GameMagicService(ISqlSugarClient DbClient, IRedisCache redis) : IGa .ExecuteCommandAsync(); } + public async Task IsHaveWin(int areaId, string time) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(it => it.areaId == areaId && it.time == time && it.isWin == 1) + .AnyAsync(); + } + public async Task CheckInMagic(string userId) { var db = DbClient.AsTenant().GetConnectionWithAttr(); @@ -83,11 +90,12 @@ public class GameMagicService(ISqlSugarClient DbClient, IRedisCache redis) : IGa var users = await mapService.GetMapUserByAll(GameConfig.GameMagicMapId, area.areaId, 1, []); if (users.Count > 0) { + bool isHaveWin = await IsHaveWin(area.areaId, time); for (int i = 1; i <= users.Count; i++) { string userId = users[i - 1].userId; bool isWin = false; - if (i == users.Count) + if (i == users.Count && isHaveWin == false) { isWin = true; } diff --git a/Service/Application.Web/Controllers/Map/MapController.cs b/Service/Application.Web/Controllers/Map/MapController.cs index 91801f2..5a4ae15 100644 --- a/Service/Application.Web/Controllers/Map/MapController.cs +++ b/Service/Application.Web/Controllers/Map/MapController.cs @@ -715,20 +715,23 @@ public class MapController : ControllerBase if (code == nameof(MapEnum.NpcEventCode.Magic_Event)) //魔城 { + var magicService = App.GetService(); bool isWin = false; if (TimeAssist.GetHourNum > 221000) { var onMapUser = await _mapService.GetMapUser(GameConfig.GameMagicMapId, areaId, 1, [userId], 1); if (onMapUser.Count == 0) { - isWin = true; + string time = TimeAssist.GetDateTimeYMDString(0); + if (await magicService.IsHaveWin(areaId, time)==false) + { + isWin = true; + } } } - - var magicService = App.GetService(); await magicService.UpdateUserMagicEndTime(userId, isWin); - await _mapService.UpdateUserOnMap(onMap, GameConfig.GameMagicInMapId);//设置地图 + await _mapService.UpdateUserOnMap(onMap, GameConfig.GameMagicInMapId); //设置地图 return PoAction.Ok(0, "魔城成功退出!"); }