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

@@ -11,10 +11,13 @@ public class MapBusController : ControllerBase
{
private readonly IGameMapService _mapService;
private readonly IMessageService _messageService;
public MapBusController(IGameMapService mapService,IMessageService messageService)
private readonly IGameMagicService _magicService;
public MapBusController(IGameMapService mapService, IMessageService messageService, IGameMagicService magicService)
{
_mapService = mapService;
_messageService = messageService;
_magicService = magicService;
}
/// <summary>
@@ -52,6 +55,7 @@ public class MapBusController : ControllerBase
public async Task<IPoAction> MapBusTo(int id, int num)
{
string userId = StateHelper.userId;
int areaId = StateHelper.areaId;
var busData = await _mapService.GetMapBusInfo(id);
if (busData == null)
{
@@ -63,39 +67,59 @@ public class MapBusController : ControllerBase
return PoAction.Message("业务不存在!");
}
var toData = JsonConvert.DeserializeObject<List<MapBusTo> >(busData.busContent);
var toData = JsonConvert.DeserializeObject<List<MapBusTo>>(busData.busContent);
if (num > (toData.Count - 1))
{
return PoAction.Message("业务不存在!");
}
var onMap = await _mapService.GetUserOnMapId(userId);
if (busData.busCode != onMap)
{
return PoAction.Message("业务不存在!");
}
var mapToData = toData[num];
if (TimeAssist.GetHourNum < mapToData.sTime || TimeAssist.GetHourNum > mapToData.eTime)
{
return PoAction.Message($"当前时间不允许进入");
}
#region
if (mapToData.code == nameof(MapEnum.MapCode.Magic_Map)) //魔城场景,验证否否进入过
{
if (await _magicService.CheckInMagic(userId) == false)
{
return PoAction.Message($"您的魔城记录冷却中,冷却时间为7天!");
}
}
#endregion
var checkResult = await GameBus.CheckNeed(userId, busData.busNeed, 1);
if (checkResult.result==false)
if (checkResult.result == false)
{
return PoAction.Message("不满足传送要求!");
}
if (await GameBus.UpdateBag(userId, 0, busData.busNeed, "业务传送"))
{
var ResultMap = await _mapService.GetToMapInfo(userId, mapToData.mapId, true, true);
if (ResultMap != null)
{
if (mapToData.code == nameof(MapEnum.MapCode.Magic_Map)) //魔城场景
{
await _magicService.UpdateUserMagicTime(userId,areaId);
}
return PoAction.Ok(true);
}
else
{
return PoAction.Message("操作失败,请稍后尝试!");
return PoAction.Message("操作失败,请稍后尝试!");
}
}
else
@@ -103,7 +127,7 @@ public class MapBusController : ControllerBase
return PoAction.Message("操作失败,请稍后尝试!");
}
}
/// <summary>
/// 打开宝箱
/// </summary>
@@ -129,13 +153,13 @@ public class MapBusController : ControllerBase
{
return PoAction.Message("业务不存在!");
}
var checkResult = await GameBus.CheckNeed(userId, busData.busNeed, 1);
if (checkResult.result==false)
if (checkResult.result == false)
{
return PoAction.Message("不满足开启要求!");
}
if (await GameBus.UpdateBag(userId, 0, busData.busNeed, "业务传送"))
{
string message = "";
@@ -158,7 +182,8 @@ public class MapBusController : ControllerBase
{
message = "空空如也,什么也没有得到!";
}
return PoAction.Ok(true,message);
return PoAction.Ok(true, message);
}
else
{

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