1111
This commit is contained in:
@@ -14,12 +14,15 @@ public class MapController : ControllerBase
|
||||
private readonly IUnitUserService _userService;
|
||||
private readonly IGameMapService _mapService;
|
||||
private readonly IGameChatService _chatService;
|
||||
private readonly IUnitUserAttrService _attrService;
|
||||
|
||||
public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService)
|
||||
public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService,
|
||||
IUnitUserAttrService attrService)
|
||||
{
|
||||
_userService = userService;
|
||||
_mapService = mapService;
|
||||
_chatService = chatService;
|
||||
_attrService = attrService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -32,17 +35,35 @@ public class MapController : ControllerBase
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
int area = StateHelper.areaId;
|
||||
var onMap = await _mapService.GetUserOnMap(userId);
|
||||
game_city_map mapInfo = new game_city_map();
|
||||
if (string.IsNullOrEmpty(map))
|
||||
|
||||
#region 地图导向处理
|
||||
|
||||
bool isSelfMap = false;
|
||||
if (!isSelfMap)
|
||||
{
|
||||
//血量为0得时候地图点为本身
|
||||
var myBlood = await _attrService.GetUserBlood(userId);
|
||||
if (myBlood.blood < 1)
|
||||
{
|
||||
//设置默认地图点
|
||||
await _mapService.SetUserMapDefult(userId);
|
||||
isSelfMap = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isSelfMap)
|
||||
{
|
||||
var onMap = await _mapService.GetUserOnMap(userId);
|
||||
mapInfo = await _mapService.GetMapInfo(onMap.mapId);
|
||||
}
|
||||
else
|
||||
{
|
||||
mapInfo = await _mapService.GetMapInfo(map);
|
||||
mapInfo = await _mapService.GetToMapInfo(userId, map, false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
//公聊信息
|
||||
string teamId = "";
|
||||
string groupId = "";
|
||||
@@ -56,7 +77,7 @@ public class MapController : ControllerBase
|
||||
3); //获取附近的人
|
||||
|
||||
var cityInfo = await _mapService.GetCityInfo((int)mapInfo.cityId); //城市信息
|
||||
var cityShow = await _mapService.GetMapCity(cityInfo.cityId); //城内地图
|
||||
var cityShow = await _mapService.GetCityShowMap(cityInfo.cityId); //城内地图
|
||||
|
||||
#region 更新在线
|
||||
|
||||
@@ -83,16 +104,62 @@ public class MapController : ControllerBase
|
||||
string userId = StateHelper.userId;
|
||||
int areaId = StateHelper.areaId;
|
||||
var onMap = await _mapService.GetUserOnMap(userId);
|
||||
|
||||
|
||||
var mapInfo = await _mapService.GetMapInfo(onMap.mapId);
|
||||
if (mapInfo == null)
|
||||
{
|
||||
return PoAction.Message("地图不存在!");
|
||||
}
|
||||
|
||||
var data = await _mapService.GetMapUser(onMap.mapId, areaId, (int)mapInfo.lookArea, new List<string> { userId }, page,
|
||||
var data = await _mapService.GetMapUser(onMap.mapId, areaId, (int)mapInfo.lookArea, new List<string> { userId },
|
||||
page,
|
||||
10, Total);
|
||||
|
||||
return PoAction.Ok(new { data, total = Total.Value});
|
||||
|
||||
return PoAction.Ok(new { data, total = Total.Value });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前城市所有地图
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserOnCityMap(string? search)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var onMap = await _mapService.GetUserOnMap(userId);
|
||||
var mapInfo = await _mapService.GetMapInfo(onMap.mapId);
|
||||
var data = await _mapService.GetCityMap((int)mapInfo.cityId);
|
||||
if (!string.IsNullOrEmpty(search))
|
||||
{
|
||||
data = data.FindAll(it => it.mapName.Contains(search));
|
||||
}
|
||||
|
||||
return PoAction.Ok(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取自动寻路路径
|
||||
/// </summary>
|
||||
/// <param name="toMap"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetAutoMapPath(string? toMap)
|
||||
{
|
||||
if (string.IsNullOrEmpty(toMap))
|
||||
{
|
||||
return PoAction.Message("目标地点不能为空!");
|
||||
}
|
||||
|
||||
string userId = StateHelper.userId;
|
||||
var onMap = await _mapService.GetUserOnMap(userId);
|
||||
var result = await _mapService.CreateAutoMap(onMap.mapId, toMap);
|
||||
if (result.Count > 0)
|
||||
{
|
||||
return PoAction.Ok(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("无法自动寻路!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,14 @@
|
||||
public class BagController : ControllerBase
|
||||
{
|
||||
private readonly IUnitUserWeight _weightService;
|
||||
private readonly IGameGoodsService _goodsService;
|
||||
private readonly IGameEquService _equService;
|
||||
|
||||
public BagController(IUnitUserWeight weightService)
|
||||
public BagController(IUnitUserWeight weightService, IGameGoodsService goodsService, IGameEquService equService)
|
||||
{
|
||||
_weightService = weightService;
|
||||
_goodsService = goodsService;
|
||||
_equService = equService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -32,7 +36,89 @@ public class BagController : ControllerBase
|
||||
var userWeight = await _weightService.GetUserWeightInfo(userId);
|
||||
onWeight = (int)userWeight.onWeight;
|
||||
maxWeight = (int)userWeight.maxWeight;
|
||||
|
||||
return PoAction.Ok(new { onWeight, maxWeight,cowry, gold, copper });
|
||||
|
||||
return PoAction.Ok(new { onWeight, maxWeight, cowry, gold, copper });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户道具数据
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="ch"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserBagProp(int type, int ch, string? query, int page)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
string userId = StateHelper.userId;
|
||||
if (type == 0)
|
||||
{
|
||||
int _t = 0;
|
||||
switch (ch)
|
||||
{
|
||||
case 1:
|
||||
_t = 1;
|
||||
break;
|
||||
case 2:
|
||||
_t = 2;
|
||||
break;
|
||||
case 3:
|
||||
_t = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
var data = await _equService.GetUserEquData(userId, _t, query, page, 10, total);
|
||||
return PoAction.Ok(new { data, total.Value });
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
List<string> code = new List<string>() { nameof(GoodsEnum.Code.Drug) };
|
||||
var data = await _goodsService.GetUserGoodsData(userId, code, new List<string>(), query, page, 10, total);
|
||||
return PoAction.Ok(new { data, total.Value });
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
List<string> code = new List<string>();
|
||||
List<string> noCode = new List<string>() { nameof(GoodsEnum.Code.Drug) };
|
||||
switch (ch)
|
||||
{
|
||||
case 1:
|
||||
code.Add(nameof(GoodsEnum.Code.Gem));
|
||||
break;
|
||||
case 2:
|
||||
code.Add(nameof(GoodsEnum.Code.Palace));
|
||||
break;
|
||||
case 3:
|
||||
code.Add(nameof(GoodsEnum.Code.Mark));
|
||||
break;
|
||||
case 4:
|
||||
code.Add(nameof(GoodsEnum.Code.Pack));
|
||||
break;
|
||||
case 5:
|
||||
code.Add(nameof(GoodsEnum.Code.Mak));
|
||||
break;
|
||||
case 6:
|
||||
code.Add(nameof(GoodsEnum.Code.Paper));
|
||||
break;
|
||||
case 7:
|
||||
code.Add(nameof(GoodsEnum.Code.Card));
|
||||
break;
|
||||
case 8:
|
||||
code.Add(nameof(GoodsEnum.Code.Cargo));
|
||||
break;
|
||||
case 9:
|
||||
code.Add(nameof(GoodsEnum.Code.Prop));
|
||||
break;
|
||||
}
|
||||
|
||||
var data = await _goodsService.GetUserGoodsData(userId, code, noCode, query, page, 10, total);
|
||||
return PoAction.Ok(new { data, total.Value });
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Ok(new { data = new List<string>(), total.Value });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user