This commit is contained in:
Putoo
2026-07-16 17:52:33 +08:00
parent 2cd2ed02f8
commit 00c2758df2
43 changed files with 897 additions and 72 deletions

View File

@@ -1,4 +1,6 @@
namespace Application.Web.Controllers.Map;
using Newtonsoft.Json;
namespace Application.Web.Controllers.Map;
/// <summary>
/// 地图接口
@@ -29,7 +31,7 @@ public class MapController : ControllerBase
IUnitUserAttrService attrService, IMessageService messageService, IUnitUserWeight weightService,
IUnitUserAccService accService, IGameSkillService skillService, IGameGoodsService goodsService,
IGameTeamService teamService, IGameMonsterService monsterService, IGameFightService fightService,
IOnHookService hookService, IGameTaskService taskService,INoticeService noticeService)
IOnHookService hookService, IGameTaskService taskService, INoticeService noticeService)
{
_userService = userService;
_mapService = mapService;
@@ -128,8 +130,8 @@ public class MapController : ControllerBase
#endregion
var busData = await _mapService.GetMapBus(mapInfo.mapId, 0, 0);//地图业务
var busData = await _mapService.GetMapBus(mapInfo.mapId, 0, 0); //地图业务
IEnumerable<object> business = busData.Select(it => new
{
busId = it.busId,
@@ -214,6 +216,7 @@ public class MapController : ControllerBase
var onMap = await _mapService.GetUserOnMap(userId);
var mapInfo = await _mapService.GetMapInfo(onMap.mapId);
var data = await _mapService.GetCityMap((int)mapInfo.cityId);
data = data.FindAll(it => it.code == nameof(MapEnum.MapCode.DEF_MAP));
if (!string.IsNullOrEmpty(search))
{
data = data.FindAll(it => it.mapName.Contains(search));
@@ -672,6 +675,66 @@ public class MapController : ControllerBase
return PoAction.Ok(new { data, task });
}
/// <summary>
/// 处理Npc事务
/// </summary>
/// <param name="npcId"></param>
/// <param name="code"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> HandleNpcEvent(int npcId, string code, string? parms)
{
string userId = StateHelper.userId;
int areaId = StateHelper.areaId;
var data = await _mapService.GetNpcInfo(npcId);
if (data == null)
{
return PoAction.Message("Npc不存在!");
}
if (data.status != 1)
{
return PoAction.Message("Npc不存在!");
}
if (data.code != nameof(MapEnum.NpcCode.Event))
{
return PoAction.Message("无法处理该业务!");
}
if (data.bus.Any(it => it.code == code) == false)
{
return PoAction.Message("无法处理该业务!");
}
var onMap = await _mapService.GetUserOnMap(userId);
if (data.mapId != onMap.mapId)
{
return PoAction.Message("Npc不存在!");
}
if (code == nameof(MapEnum.NpcEventCode.Magic_Event)) //魔城
{
bool isWin = false;
if (TimeAssist.GetHourNum > 221000)
{
var onMapUser = await _mapService.GetMapUser(GameConfig.GameMagicMapId, areaId, 1, [userId], 1);
if (onMapUser.Count == 0)
{
isWin = true;
}
}
var magicService = App.GetService<IGameMagicService>();
await magicService.UpdateUserMagicEndTime(userId, isWin);
await _mapService.UpdateUserOnMap(onMap, GameConfig.GameMagicInMapId);//设置地图
return PoAction.Ok(0, "魔城成功退出!");
}
return PoAction.Message("非处理的游戏项!");
}
#endregion
#region