121212
This commit is contained in:
@@ -19,6 +19,9 @@
|
||||
<Content Update="applicationsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="applicationsettings.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -117,5 +117,11 @@ public class GameAutoJobService(ISqlSugarClient DbClient, IRedisCache redis, ITi
|
||||
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleMessageData,
|
||||
data));
|
||||
}
|
||||
else if (data.code == nameof(GameEnum.JobCode.UpdateMagicData)) //处理魔城数据
|
||||
{
|
||||
var _eventPublisher = App.GetService<IEventPublisher>();
|
||||
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleMagicData,
|
||||
data));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,8 +52,8 @@ namespace Application.Web.Controllers.Login
|
||||
[HttpGet]
|
||||
public async Task<string> HandleError()
|
||||
{
|
||||
var attrService = App.GetService<IUnitUserAttrService>();
|
||||
var model = await attrService.GetUserAttrModel("32cd4777-e523-4cf9-b8f1-de13235f6170");
|
||||
var magicService = App.GetService<IGameMagicService>();
|
||||
await magicService.HandleMagicData();
|
||||
|
||||
|
||||
return "1";
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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 采集相关
|
||||
|
||||
88
Service/Application.Web/Controllers/Pub/CdkController.cs
Normal file
88
Service/Application.Web/Controllers/Pub/CdkController.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Application.Web.Controllers.Pub;
|
||||
|
||||
/// <summary>
|
||||
/// Cdk接口
|
||||
/// </summary>
|
||||
[Route("[controller]/[action]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class CdkController : ControllerBase
|
||||
{
|
||||
private readonly IGameCdkService _cdkService;
|
||||
public CdkController(IGameCdkService cdkService)
|
||||
{
|
||||
_cdkService = cdkService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 兑换CDK
|
||||
/// </summary>
|
||||
/// <param name="cdk"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> Exchange(string cdk)
|
||||
{
|
||||
if (string.IsNullOrEmpty(cdk))
|
||||
{
|
||||
return PoAction.Message("CDK不能为空!");
|
||||
}
|
||||
var cdkItem = await _cdkService.GetCdkItemInfo(cdk);
|
||||
if (cdkItem == null)
|
||||
{
|
||||
return PoAction.Message("CDK无效!");
|
||||
}
|
||||
if (cdkItem.userId != "0")
|
||||
{
|
||||
return PoAction.Message("CDK已被使用!");
|
||||
}
|
||||
var cdkInfo = await _cdkService.GetCdkInfo((int)cdkItem.cdkId);
|
||||
if (cdkInfo == null)
|
||||
{
|
||||
return PoAction.Message("CDK无效!");
|
||||
}
|
||||
if (cdkInfo.endTime < DateTime.Now)
|
||||
{
|
||||
return PoAction.Message("CDK已过期!");
|
||||
}
|
||||
if (cdkInfo.area != 0)
|
||||
{
|
||||
if (cdkInfo.area != StateHelper.areaId)
|
||||
{
|
||||
return PoAction.Message($"该CDK仅可在{cdkInfo.area}区使用!");
|
||||
}
|
||||
}
|
||||
|
||||
string userId = StateHelper.userId;
|
||||
if (cdkInfo.limit > 0)
|
||||
{
|
||||
int onCount = await _cdkService.GetUserCdkCount(cdkInfo.cdkId, userId);
|
||||
if (onCount >= cdkInfo.limit)
|
||||
{
|
||||
return PoAction.Message($"该类型CDK限制兑换{cdkInfo.limit}个!");
|
||||
}
|
||||
}
|
||||
if (await _cdkService.UpdateCdkUser(cdk, userId))
|
||||
{
|
||||
if (await GameBus.UpdateBag(userId, 1, cdkInfo.award, "CDK获得"))
|
||||
{
|
||||
string message = "兑换成功,获得:";
|
||||
foreach (var item in cdkInfo.award)
|
||||
{
|
||||
message += $"{item.name}+{item.count},";
|
||||
}
|
||||
message = message.TrimEnd(',');
|
||||
return PoAction.Ok(true,message);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("兑换失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("兑换失败,请稍后尝试!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,6 +250,7 @@ public class RecoverController : ControllerBase
|
||||
var needData = data.FindAll(it =>
|
||||
it.isAppr == 1 && it.durability < it.maxdurability && it.useEndTime > TimeExtend.GetTimeStampSeconds);
|
||||
need = needData.Sum(it => (int)it.maxdurability - (int)it.durability);
|
||||
need = need * 500;
|
||||
return PoAction.Ok(new { data, need });
|
||||
}
|
||||
|
||||
|
||||
43
Service/Application.Web/applicationsettings.txt
Normal file
43
Service/Application.Web/applicationsettings.txt
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"AutoProgram": 0,
|
||||
"Redis": {
|
||||
"connection": "127.0.0.1:6379,password=,defaultdatabase=5"
|
||||
},
|
||||
"SqlData": [
|
||||
{
|
||||
"type": 0,
|
||||
"name": "Kg.SeaTime.Game",
|
||||
"connect": "data source=81.70.212.61;database=kg.seatime.game;user id=root;password=1f5ozxRGE3Y;pooling=true;port=3306;sslmode=Required;charset=utf8mb4;"
|
||||
},
|
||||
{
|
||||
"type": 0,
|
||||
"name": "Kg.SeaTime.Resource",
|
||||
"connect": "data source=81.70.212.61;database=kg.seatime.resource;user id=root;password=1f5ozxRGE3Y;pooling=true;port=3306;sslmode=Required;charset=utf8mb4;"
|
||||
},
|
||||
{
|
||||
"type": 0,
|
||||
"name": "Kg.SeaTime.Log",
|
||||
"connect": "data source=81.70.212.61;database=kg.seatime.log;user id=root;password=1f5ozxRGE3Y;pooling=true;port=3306;sslmode=Required;charset=utf8mb4;"
|
||||
}
|
||||
],
|
||||
"JwtTokenOptions": {
|
||||
"Issuer": "kx.seatime",
|
||||
"Audience": "kx.seatime",
|
||||
"SecurityKey": "46055HR0n7FeNHhDKAYD2i9ZsdsYn4jn"
|
||||
},
|
||||
"ResUrl": {
|
||||
"local": "http://192.168.0.142:5298",
|
||||
"resUrl": "http://localhost:12206",
|
||||
"imgCDN": "/",
|
||||
"videoCDN": "/"
|
||||
},
|
||||
"Sms": {
|
||||
"SmsType": 1,
|
||||
"AccessKey": "AKIDVptgCRP5UcT4PTGm1yf5E6pKYVBajeKn",
|
||||
"Secret": "FG2atxlKflcEclgKhnc9XeU3LM6YjdGf",
|
||||
"signName": "探玩驿站",
|
||||
"TemplateCode": "963929",
|
||||
"SmsSdkAppId": "1400523979",
|
||||
"SmsOnTime": 300
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user