222
This commit is contained in:
@@ -11,10 +11,11 @@ namespace Application.Web.Controllers.Chat;
|
||||
public class ChatController : ControllerBase
|
||||
{
|
||||
private readonly IGameChatService _chatService;
|
||||
|
||||
public ChatController(IGameChatService chatService)
|
||||
private readonly IGameGoodsService _goodsService;
|
||||
public ChatController(IGameChatService chatService,IGameGoodsService goodsService)
|
||||
{
|
||||
_chatService = chatService;
|
||||
_goodsService = goodsService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -26,6 +27,7 @@ public class ChatController : ControllerBase
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetChatData(int type, int page)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
int areaId = StateHelper.areaId;
|
||||
string teamId = "";
|
||||
string groupId = "";
|
||||
@@ -37,15 +39,15 @@ public class ChatController : ControllerBase
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
sendGoodsCount = 199;
|
||||
sendGoodsCount = await _goodsService.GetUserGoodsCount(userId,GameConfig.SendChatGoodsBase);
|
||||
sendGoodsName = "小海螺";
|
||||
break;
|
||||
case 3:
|
||||
sendGoodsCount = 15;
|
||||
sendGoodsCount = await _goodsService.GetUserGoodsCount(userId,GameConfig.SendChatGoodsArea);
|
||||
sendGoodsName = "大海螺";
|
||||
break;
|
||||
case 4:
|
||||
sendGoodsCount = 9;
|
||||
sendGoodsCount = await _goodsService.GetUserGoodsCount(userId,GameConfig.SendChatGoodsService);
|
||||
sendGoodsName = "金海螺";
|
||||
break;
|
||||
}
|
||||
@@ -71,12 +73,14 @@ public class ChatController : ControllerBase
|
||||
int areaId = StateHelper.areaId;
|
||||
string par = string.Empty;
|
||||
string code = GameChatEnum.Code.Public.ToString();
|
||||
int goodsId = 0;
|
||||
bool isSend = false;
|
||||
switch (pars.type)
|
||||
{
|
||||
case 0:
|
||||
isSend = true;
|
||||
code =nameof(GameChatEnum.Code.Public);
|
||||
goodsId = GameConfig.SendChatGoodsBase;
|
||||
break;
|
||||
case 1:
|
||||
isSend = true;
|
||||
@@ -90,23 +94,39 @@ public class ChatController : ControllerBase
|
||||
break;
|
||||
case 3:
|
||||
isSend = true;
|
||||
goodsId = GameConfig.SendChatGoodsArea;
|
||||
code = nameof(GameChatEnum.Code.Region);
|
||||
break;
|
||||
case 4:
|
||||
isSend = true;
|
||||
goodsId = GameConfig.SendChatGoodsService;
|
||||
code = nameof(GameChatEnum.Code.Dress);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (isSend == false)
|
||||
{
|
||||
return PoAction.Message("无法发言!");
|
||||
}
|
||||
|
||||
if (goodsId != 0)
|
||||
{
|
||||
var myCount = await _goodsService.GetUserGoodsCount(userId, goodsId);
|
||||
if (myCount < 1)
|
||||
{
|
||||
return PoAction.Message("暂无发言道具,去商城购买海螺才可以发言哦!");
|
||||
}
|
||||
}
|
||||
|
||||
string sign = StringAssist.NoHTML(pars.sign);
|
||||
bool result = await _chatService.SendChat(userId, areaId, code, sign, par);
|
||||
if (result)
|
||||
{
|
||||
if (goodsId != 0)//扣除道具
|
||||
{
|
||||
await _goodsService.UpdateUserGoods(userId, 0, goodsId, 1, "发言");
|
||||
}
|
||||
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -47,13 +47,17 @@ public class MapController : ControllerBase
|
||||
string teamId = "";
|
||||
string groupId = "";
|
||||
var chatData = await _chatService.GetChatTop(area, 2, teamId, groupId);
|
||||
//NPC信息
|
||||
|
||||
var npcData = await _mapService.GetMapNpc(mapInfo.mapId);
|
||||
|
||||
var npcData = await _mapService.GetMapNpc(mapInfo.mapId); //NPC信息
|
||||
npcData = npcData.FindAll(it => GameTool.AreaVerify(StateHelper.areaId, it.areaId));
|
||||
//城市信息
|
||||
var cityInfo = await _mapService.GetCityInfo((int)mapInfo.cityId);
|
||||
var cityShow = await _mapService.GetMapCity(cityInfo.cityId);
|
||||
var nearUser =
|
||||
await _mapService.GetMapUser(mapInfo.mapId, area, (int)mapInfo.lookArea, new List<string> { userId },
|
||||
3); //获取附近的人
|
||||
|
||||
var cityInfo = await _mapService.GetCityInfo((int)mapInfo.cityId); //城市信息
|
||||
var cityShow = await _mapService.GetMapCity(cityInfo.cityId); //城内地图
|
||||
|
||||
#region 更新在线
|
||||
|
||||
string ip = ComHelper.GetClientUserIp(HttpContext);
|
||||
@@ -61,8 +65,34 @@ public class MapController : ControllerBase
|
||||
|
||||
#endregion
|
||||
|
||||
object ret = new { mapInfo, cityInfo, npcData, chatData,cityShow };
|
||||
object ret = new { mapInfo, cityInfo, npcData, chatData, cityShow, nearUser };
|
||||
|
||||
return PoAction.Ok(ret);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取地图在线玩家
|
||||
/// </summary>
|
||||
/// <param name="map"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetMapUser(int page)
|
||||
{
|
||||
RefAsync<int> Total = 0;
|
||||
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,
|
||||
10, Total);
|
||||
|
||||
return PoAction.Ok(new { data, total = Total.Value});
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace Application.Web.Controllers.Pub
|
||||
|
||||
var notice = await _noticeService.GetNoticeDataByTake(5);
|
||||
|
||||
int OnCount = 100;
|
||||
int OnCount = await _userService.GetOnlineCount();
|
||||
return PoAction.Ok(new { area = areaData, notice, isOnline, onCount = OnCount, account,userData });
|
||||
}
|
||||
|
||||
|
||||
38
Service/Application.Web/Controllers/User/BagController.cs
Normal file
38
Service/Application.Web/Controllers/User/BagController.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
namespace Application.Web.Controllers.User;
|
||||
|
||||
/// <summary>
|
||||
/// 用户背包信息
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "User")]
|
||||
[Route("User/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class BagController : ControllerBase
|
||||
{
|
||||
private readonly IUnitUserWeight _weightService;
|
||||
|
||||
public BagController(IUnitUserWeight weightService)
|
||||
{
|
||||
_weightService = weightService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取背包信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserBagData()
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
int onWeight = 0;
|
||||
int maxWeight = 0;
|
||||
int gold = 0;
|
||||
int cowry = 0;
|
||||
long copper = 0;
|
||||
var userWeight = await _weightService.GetUserWeightInfo(userId);
|
||||
onWeight = (int)userWeight.onWeight;
|
||||
maxWeight = (int)userWeight.maxWeight;
|
||||
|
||||
return PoAction.Ok(new { onWeight, maxWeight,cowry, gold, copper });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user