This commit is contained in:
Putoo
2026-06-05 18:06:38 +08:00
parent 5195407266
commit 1927e3f960
17 changed files with 575 additions and 27 deletions

View File

@@ -18,10 +18,11 @@ public class MapController : ControllerBase
private readonly IMessageService _messageService;
private readonly IUnitUserWeight _weightService;
private readonly IUnitUserAccService _accService;
private readonly IGameSkillService _skillService;
private readonly IGameGoodsService _goodsService;
public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService,
IUnitUserAttrService attrService, IMessageService messageService, IUnitUserWeight weightService,
IUnitUserAccService accService)
IUnitUserAccService accService, IGameSkillService skillService,IGameGoodsService goodsService)
{
_userService = userService;
_mapService = mapService;
@@ -30,6 +31,8 @@ public class MapController : ControllerBase
_messageService = messageService;
_weightService = weightService;
_accService = accService;
_skillService = skillService;
_goodsService = goodsService;
}
#region
@@ -118,10 +121,10 @@ public class MapController : ControllerBase
}
//地图资源
List<game_city_map_res> mapRes = new List<game_city_map_res>();
List<MapResModel> mapRes = new List<MapResModel>();
if (mapInfo.isRes == 1)
{
mapRes = await _mapService.GetMapRes(mapInfo.mapId);
mapRes = await _mapService.GetMapResData(mapInfo.mapId, area);
}
#endregion
@@ -635,4 +638,78 @@ public class MapController : ControllerBase
}
#endregion
#region
/// <summary>
/// 采集接口
/// </summary>
/// <param name="resId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> CollectMapRes(string resId)
{
var resInfo = await _mapService.GetMapResInfo(resId);
if (resInfo == null)
{
return PoAction.Message("特产不存在!");
}
var userId = StateHelper.userId;
int area = StateHelper.areaId;
var onMap = await _mapService.GetUserOnMap(userId);
if (onMap.mapId != resInfo.mapId)
{
return PoAction.Message("特产不存在!");
}
long lockTime = await _mapService.GetMapResLockTime(resId, area);
if (lockTime > 0)
{
return PoAction.Message($"{lockTime}秒后可采集!");
}
var skillInfo = await _skillService.GetUserSkillInfo(userId, nameof(SkillEnum.code.Collect));
if (skillInfo == null)
{
return PoAction.Message("未学习采集术!");
}
if (skillInfo.lev < resInfo.lev)
{
return PoAction.Message($"需要{resInfo.lev}级采集术才可以采集哦!");
}
var myVigour = await _attrService.GetUserVigourInfo(userId);
Console.WriteLine($"{myVigour.vitality }-{resInfo.needVigour}");
if (myVigour.vitality < resInfo.needVigour)
{
return PoAction.Message("活力不足!");
}
if (await _attrService.UpdateUserVigour(userId, 0, (int)resInfo.needVigour))
{
await _mapService.SetMapResLockTime(resId, area, (int)resInfo.gatherTime);
if (RandomAssist.CheakRandom((int)resInfo.okRadio))
{
//采集成功
string[] counts = resInfo.count.Split('-');
int onCount =
RandomAssist.GetFormatedNumeric(Convert.ToInt32(counts[0]), Convert.ToInt32(counts[1]) + 1);
await _goodsService.UpdateUserGoods(userId, 1, (int)resInfo.goodsId, onCount, "采集获得");
return PoAction.Ok(resInfo.gatherTime, $"成功采集{resInfo.resName}×{onCount}!");
}
else
{
await _mapService.SetMapResLockTime(resId, area, (int)resInfo.gatherTime);
return PoAction.Ok(resInfo.gatherTime, "抱歉,采集失败!提升技能会提高成功率哦!");
}
}
else
{
return PoAction.Message("采集失败,请稍后尝试!");
}
}
#endregion
}