121212
This commit is contained in:
@@ -29,6 +29,9 @@ namespace Application.Domain.Entity
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? itemId { get; set; }
|
||||
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int? lev { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// name
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace Application.Domain
|
||||
HandleCreateMonster,//处理创建的怪物
|
||||
HandleFightData,//处理战斗日志数据
|
||||
HandleExchangeData,//处理兑换数据
|
||||
HandleTaskLog,//处理任务日志
|
||||
HandelTaskUser,//处理角色任务
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,5 +85,25 @@
|
||||
var exchangeService = App.GetService<IExchangeService>();
|
||||
await exchangeService.HandleExchangeLogData();
|
||||
}
|
||||
/// <summary>
|
||||
/// 处理任务日志
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
[EventSubscribe(BusEventsEnum.BusEventsName.HandleTaskLog, NumRetries = 0,RetryTimeout = 999999999)]
|
||||
public async Task HandleTaskLog(EventHandlerExecutingContext context)
|
||||
{
|
||||
var taskService = App.GetService<IGameTaskService>();
|
||||
await taskService.HandleUserTaskLog();
|
||||
}
|
||||
/// <summary>
|
||||
/// 处理角色任务
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
[EventSubscribe(BusEventsEnum.BusEventsName.HandelTaskUser, NumRetries = 0,RetryTimeout = 999999999)]
|
||||
public async Task HandelTaskUser(EventHandlerExecutingContext context)
|
||||
{
|
||||
var taskService = App.GetService<IGameTaskService>();
|
||||
await taskService.HandleUserTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ public static class GameEnum
|
||||
UpdateCreateMonster,//更新创建得怪物
|
||||
UpdateFightData,//更新战斗信息
|
||||
UpdateExchangeData,//更新兑换的记录
|
||||
UpdateTaskLog,//更新任务日志
|
||||
UpdateTaskUser,//更新角色任务
|
||||
}
|
||||
public enum PropCode//游戏资源编码
|
||||
{
|
||||
|
||||
@@ -7,5 +7,10 @@ public static class MonsterEnum
|
||||
Default,
|
||||
|
||||
}
|
||||
|
||||
public enum MonsterCode
|
||||
{
|
||||
Default,
|
||||
Dup,
|
||||
Task
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@ public interface IGameMonsterService
|
||||
Task<unit_user_monster> GetCreateMonsterInfo(string umId);
|
||||
Task<bool> RemoveCreateMonster(string umId);
|
||||
Task<bool> RemoveCreateMonster(unit_user_monster data);
|
||||
Task ClearCreateMonster(string userId,string code, string par, string monsterId, string mapId);
|
||||
Task<int> GetUserMonsterCount(string userId, string monsterId, int state);
|
||||
Task HandleCreateMonster();
|
||||
Task<List<MapMonsterModel>> GetMapMonster(string userId, string mapId, string teamId);
|
||||
|
||||
|
||||
@@ -12,10 +12,14 @@ public interface IGameTaskService
|
||||
|
||||
#region 个人任务
|
||||
|
||||
Task<List<unit_user_task>> GetUserTaskData(string userId);
|
||||
Task<unit_user_task> GetUserTaskInfo(string userId, int taskId);
|
||||
Task<bool> UpdateUserTaskInfo(string userId, int itemId);
|
||||
Task<int> GetUserTaskCount(string userId, int taskId);
|
||||
Task ResetNextTask(string userId, int nextId);
|
||||
Task<UserTaskModel> GetUserTaskModel(string userId, game_task_item task);
|
||||
Task HandleUserTaskLog();
|
||||
Task HandleUserTask();
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -91,5 +91,17 @@ public class GameAutoJobService(ISqlSugarClient DbClient, IRedisCache redis, ITi
|
||||
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleExchangeData,
|
||||
data));
|
||||
}
|
||||
else if (data.code == nameof(GameEnum.JobCode.UpdateTaskLog)) //更新任务日志
|
||||
{
|
||||
var _eventPublisher = App.GetService<IEventPublisher>();
|
||||
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleTaskLog,
|
||||
data));
|
||||
}
|
||||
else if (data.code == nameof(GameEnum.JobCode.UpdateTaskUser)) //更新角色任务
|
||||
{
|
||||
var _eventPublisher = App.GetService<IEventPublisher>();
|
||||
await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandelTaskUser,
|
||||
data));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,6 +152,26 @@ public class GameMonsterService(ISqlSugarClient DbClient, IRedisCache redis) : I
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task ClearCreateMonster(string userId, string code, string par, string monsterId, string mapId)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_monster>();
|
||||
bool result = await db.Deleteable<unit_user_monster>()
|
||||
.Where(it => it.userId == userId && it.code == code && it.par == par && it.monsterId == monsterId)
|
||||
.ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
await ClearCreateMonster(mapId);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<int> GetUserMonsterCount(string userId, string monsterId, int state)
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_monster>();
|
||||
return await db.Queryable<unit_user_monster>()
|
||||
.Where(it => it.userId == userId && it.monsterId == monsterId && it.state == state).CountAsync();
|
||||
}
|
||||
|
||||
|
||||
public async Task HandleCreateMonster()
|
||||
{
|
||||
var endTime = TimeExtend.GetTimeStampSeconds;
|
||||
|
||||
@@ -64,6 +64,20 @@ public class GameTaskService(ISqlSugarClient DbClient, IRedisCache redis) : IGam
|
||||
|
||||
#region 个人任务
|
||||
|
||||
public async Task<List<unit_user_task>> GetUserTaskData(string userId)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "TaskCache", "UserTaskData");
|
||||
if (await redis.HExistsHashAsync(key, userId))
|
||||
{
|
||||
return await redis.GetHashAsync<List<unit_user_task>>(key, userId);
|
||||
}
|
||||
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_task>();
|
||||
var data = await db.Queryable<unit_user_task>().Where(it => it.userId == userId).ToListAsync();
|
||||
await redis.AddHashAsync(key, userId, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<unit_user_task> GetUserTaskInfo(string userId, int taskId)
|
||||
{
|
||||
string utId = $"{userId}_{taskId}";
|
||||
@@ -80,6 +94,17 @@ public class GameTaskService(ISqlSugarClient DbClient, IRedisCache redis) : IGam
|
||||
return data;
|
||||
}
|
||||
|
||||
private async Task ClearUserTaskCache(string userId, string utId = "")
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "TaskCache", "UserTaskData");
|
||||
await redis.DelHashAsync(key, userId);
|
||||
if (!string.IsNullOrEmpty(utId))
|
||||
{
|
||||
key = string.Format(UserCache.BaseCacheKeys, "TaskCache", "UserTaskInfo");
|
||||
await redis.DelHashAsync(key, utId);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateUserTaskInfo(string userId, int itemId)
|
||||
{
|
||||
bool result = false;
|
||||
@@ -93,8 +118,7 @@ public class GameTaskService(ISqlSugarClient DbClient, IRedisCache redis) : IGam
|
||||
result = await db.Deleteable<unit_user_task>().Where(it => it.utId == utId).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "TaskCache", "UserTaskInfo");
|
||||
await redis.DelHashAsync(key, utId);
|
||||
await ClearUserTaskCache(userId, utId);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -107,6 +131,7 @@ public class GameTaskService(ISqlSugarClient DbClient, IRedisCache redis) : IGam
|
||||
onTask.userId = userId;
|
||||
onTask.taskId = taskInfo.taskId;
|
||||
onTask.itemId = taskInfo.tiId;
|
||||
onTask.lev = taskInfo.lev;
|
||||
onTask.name = taskInfo.name;
|
||||
onTask.code = taskInfo.code;
|
||||
onTask.endTime = await GetItemEndTime((int)taskInfo.taskId, (int)taskInfo.time);
|
||||
@@ -117,6 +142,7 @@ public class GameTaskService(ISqlSugarClient DbClient, IRedisCache redis) : IGam
|
||||
{
|
||||
onTask.itemId = taskInfo.tiId;
|
||||
onTask.name = taskInfo.name;
|
||||
onTask.lev = taskInfo.lev;
|
||||
onTask.code = taskInfo.code;
|
||||
onTask.endTime = await GetItemEndTime((int)taskInfo.taskId, (int)taskInfo.time);
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_task>();
|
||||
@@ -127,17 +153,36 @@ public class GameTaskService(ISqlSugarClient DbClient, IRedisCache redis) : IGam
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "TaskCache", "UserTaskInfo");
|
||||
await redis.AddHashAsync(key, utId, onTask);
|
||||
await ClearUserTaskCache(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
//清理遗留数据,如怪物
|
||||
if (taskInfo.needData.Count > 0)
|
||||
{
|
||||
var monsterService = App.GetService<IGameMonsterService>();
|
||||
foreach (var item in taskInfo.needData)
|
||||
{
|
||||
if (item.code == nameof(GameEnum.PropCode.Monster))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.mapId))
|
||||
{
|
||||
await monsterService.ClearCreateMonster(userId, nameof(MonsterEnum.MonsterCode.Task),
|
||||
taskInfo.tiId.ToString(), item.parameter, item.mapId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (taskInfo.itemType == 0)
|
||||
{
|
||||
await AddUserTaskLog(userId, (int)taskInfo.taskId);
|
||||
}
|
||||
else if (taskInfo.itemType == 1)
|
||||
|
||||
if (taskInfo.itemType != 2)
|
||||
{
|
||||
//初始化下一环任务
|
||||
await ResetNextTask(userId, taskInfo.tiId + 1);
|
||||
@@ -169,7 +214,7 @@ public class GameTaskService(ISqlSugarClient DbClient, IRedisCache redis) : IGam
|
||||
long endTime = await GetEndTime(taskId);
|
||||
unit_user_task_log log = new unit_user_task_log()
|
||||
{
|
||||
utId = utId,
|
||||
utId = StringAssist.NewGuid,
|
||||
userId = userId,
|
||||
taskId = taskId,
|
||||
addTime = DateTime.Now,
|
||||
@@ -184,9 +229,35 @@ public class GameTaskService(ISqlSugarClient DbClient, IRedisCache redis) : IGam
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ResetNextTask(string userId, int nextId)
|
||||
public async Task ResetNextTask(string userId, int nextId)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
var taskInfo = await GetTaskItemInfo(nextId);
|
||||
if (taskInfo != null)
|
||||
{
|
||||
if (taskInfo.needData.Count > 0)
|
||||
{
|
||||
var monsterService = App.GetService<IGameMonsterService>();
|
||||
var monster = taskInfo.needData.FindAll(it => it.code == nameof(GameEnum.PropCode.Monster));
|
||||
if (monster.Count > 0)
|
||||
{
|
||||
foreach (var item in monster)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.mapId) && !string.IsNullOrEmpty(item.parameter))
|
||||
{
|
||||
int opCount = 0;
|
||||
int count = await monsterService.GetUserMonsterCount(userId, item.parameter, 0);
|
||||
if (count < item.count)
|
||||
{
|
||||
opCount = (int)item.count - count;
|
||||
await monsterService.CreateMonsterToMap(userId, item.mapId, item.areaCode,
|
||||
item.parameter,
|
||||
opCount, (int)taskInfo.time, nextId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<UserTaskModel> GetUserTaskModel(string userId, game_task_item task)
|
||||
@@ -268,6 +339,68 @@ public class GameTaskService(ISqlSugarClient DbClient, IRedisCache redis) : IGam
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
public async Task HandleUserTaskLog()
|
||||
{
|
||||
//处理任务日志
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_task_log>();
|
||||
List<string> uts = new List<string>();
|
||||
long endTime = TimeExtend.GetTimeStampSeconds;
|
||||
var data = await db.Queryable<unit_user_task_log>().Where(it => it.endTime < endTime).ToListAsync();
|
||||
foreach (var item in data)
|
||||
{
|
||||
string utId = $"{item.userId}_{item.taskId}";
|
||||
if (uts.Any(it => it == utId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
uts.Add(utId);
|
||||
}
|
||||
|
||||
if (uts.Count > 0)
|
||||
{
|
||||
bool result =
|
||||
await db.Deleteable<unit_user_task_log>().Where(it => it.endTime < endTime).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "TaskCache", "UserTaskCount");
|
||||
await redis.DelHashAsync(key, uts.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task HandleUserTask()
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_task>();
|
||||
List<string> users = new List<string>();
|
||||
List<string> uts = new List<string>();
|
||||
long endTime = TimeExtend.GetTimeStampSeconds;
|
||||
var data = await db.Queryable<unit_user_task>().Where(it => it.endTime < endTime).ToListAsync();
|
||||
foreach (var item in data)
|
||||
{
|
||||
if (users.Any(it => it == item.userId) == false)
|
||||
{
|
||||
users.Add(item.userId);
|
||||
}
|
||||
|
||||
uts.Add($"{item.userId}_{item.taskId}");
|
||||
}
|
||||
|
||||
if (users.Count > 0)
|
||||
{
|
||||
bool result =
|
||||
await db.Deleteable<unit_user_task>().Where(it => it.endTime < endTime).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "TaskCache", "UserTaskData");
|
||||
await redis.DelHashAsync(key, users.ToArray());
|
||||
key = string.Format(UserCache.BaseCacheKeys, "TaskCache", "UserTaskInfo");
|
||||
await redis.DelHashAsync(key, uts.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 辅助
|
||||
|
||||
@@ -220,6 +220,18 @@ public static class GameBus
|
||||
isok = false;
|
||||
}
|
||||
}
|
||||
else if (item.code == nameof(GameEnum.PropCode.Monster))
|
||||
{
|
||||
var monsterService = App.GetService<IGameMonsterService>();
|
||||
var onCount = await monsterService.GetUserMonsterCount(userId,item.parameter,1);
|
||||
item.count = item.count;
|
||||
item.onCount = onCount;
|
||||
if (onCount < item.count)
|
||||
{
|
||||
item.isAsk = 0;
|
||||
isok = false;
|
||||
}
|
||||
}
|
||||
|
||||
result.result = isok;
|
||||
result.isDeal = isDeal;
|
||||
|
||||
@@ -28,17 +28,37 @@ namespace Application.Web.Controllers.Login
|
||||
_attrService = attrService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string GetExp()
|
||||
{
|
||||
string html = string.Empty;
|
||||
decimal sum = 0M;
|
||||
decimal addsum = 0;
|
||||
for (int i = 1; i < 121; i++)
|
||||
{
|
||||
Decimal exp = GameTool.GetUserUpExp(i);
|
||||
if (i > 160 && i < 221)
|
||||
{
|
||||
addsum += exp;
|
||||
}
|
||||
sum += exp;
|
||||
html += string.Format("当前等级:{0},升级经验:{1};总经验:{2}\n\r", i, exp, sum);
|
||||
}
|
||||
html += String.Format("总经验:{0}", sum);
|
||||
html += String.Format("升级经验:{0}", addsum);
|
||||
return html;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录接口
|
||||
/// </summary>
|
||||
/// <param name="parms"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IPoAction> Login([FromBody] LoginParms parms)
|
||||
{
|
||||
return PoAction.Ok(parms.code);
|
||||
}
|
||||
// [HttpPost]
|
||||
// public async Task<IPoAction> Login([FromBody] LoginParms parms)
|
||||
// {
|
||||
// return PoAction.Ok(parms.code);
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// 探玩自动登录
|
||||
|
||||
@@ -152,7 +152,7 @@ public class MapController : ControllerBase
|
||||
string fightId = userFight.Count > 0 ? userFight[0] : "";
|
||||
var mapGoods = await _fightService.GetMapFightGoods(mapInfo.mapId);
|
||||
mapGoods = mapGoods.FindAll(it => it.userId == "0" || it.userId == userId).Take(3).ToList();
|
||||
|
||||
var taskData = await _taskService.GetUserTaskData(userId);
|
||||
int isHook = 0; //挂机处理
|
||||
var onHook = await _hookService.GetUserOnHook(userId);
|
||||
isHook = (int)onHook.status;
|
||||
@@ -173,7 +173,8 @@ public class MapController : ControllerBase
|
||||
monster = monsterData,
|
||||
fightId,
|
||||
gameTips,
|
||||
isHook
|
||||
isHook,
|
||||
taskCount = taskData.Count
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -103,6 +103,94 @@ public class TaskController : ControllerBase
|
||||
{ npc = npcInfo, data = data, talkMsg, taskState, btnTips = taskInfo.btnTips, toGoods, retGoods });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取个人任务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserTask()
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var data = await _taskService.GetUserTaskData(userId);
|
||||
return PoAction.Ok(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置任务
|
||||
/// </summary>
|
||||
/// <param name="task"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> RestTask(int task)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
var onTaskInfo = await _taskService.GetUserTaskInfo(userId,task);
|
||||
if (onTaskInfo == null)
|
||||
{
|
||||
return PoAction.Message("暂无任务!");
|
||||
}
|
||||
|
||||
int nextId = (int)onTaskInfo.itemId + 1;
|
||||
var nextTask = await _taskService.GetTaskItemInfo(nextId);
|
||||
if (nextTask == null)
|
||||
{
|
||||
return PoAction.Message("当前任务已结束,无需重置!");
|
||||
}
|
||||
|
||||
var result = await _taskService.GetUserTaskModel(userId, nextTask);
|
||||
if (result.result.result)
|
||||
{
|
||||
return PoAction.Message("任务可完成,无需重置!");
|
||||
}
|
||||
|
||||
await _taskService.ResetNextTask(userId, nextId);
|
||||
return PoAction.Ok(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取个人任务详情
|
||||
/// </summary>
|
||||
/// <param name="taskId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserTaskInfo(int taskId)
|
||||
{
|
||||
string userId = StateHelper.userId;
|
||||
|
||||
var taskInfo = await _taskService.GetTaskItemInfo(taskId);
|
||||
if (taskInfo == null)
|
||||
{
|
||||
return PoAction.Message("任务不存在!");
|
||||
}
|
||||
|
||||
string talkMsg = taskInfo.taskTips;
|
||||
int taskState = 1;
|
||||
var userOnTask = await _taskService.GetUserTaskInfo(userId, (int)taskInfo.taskId);
|
||||
if (userOnTask != null)
|
||||
{
|
||||
if (userOnTask.itemId == taskId)
|
||||
{
|
||||
var nextInfo = await _taskService.GetTaskItemInfo(taskId + 1);
|
||||
if (taskInfo == null)
|
||||
{
|
||||
taskState = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
talkMsg = taskInfo.nextTips;
|
||||
taskInfo = nextInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var data = await _taskService.GetUserTaskModel(userId, taskInfo);
|
||||
|
||||
int toGoods = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameGetTaskGoods);
|
||||
int retGoods = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameRetTaskGoods);
|
||||
return PoAction.Ok(new
|
||||
{ data = data, talkMsg, taskState, toGoods, retGoods });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 完成任务
|
||||
/// </summary>
|
||||
@@ -175,6 +263,7 @@ public class TaskController : ControllerBase
|
||||
}
|
||||
|
||||
message = message.TrimEnd(',');
|
||||
await GameBus.UpdateBag(userId, 1, award, "完成任务");//发放奖励
|
||||
}
|
||||
|
||||
return PoAction.Ok(true, message);
|
||||
|
||||
@@ -20,11 +20,12 @@ public class FightController : ControllerBase
|
||||
private readonly IUnitUserService _userService;
|
||||
private readonly IOnHookService _hookService;
|
||||
private readonly IUnitUserRelationService _relationService;
|
||||
private readonly IGameTaskService _taskService;
|
||||
|
||||
public FightController(IGameFightService fightService, IGameMonsterService monsterService,
|
||||
IUnitUserAttrService attrService, IGameMapService mapService, IUnitUserAccService accService,
|
||||
IGameGoodsService goodsService, IUnitUserService userService, IOnHookService hookService,
|
||||
IUnitUserRelationService relationService)
|
||||
IUnitUserRelationService relationService, IGameTaskService taskService)
|
||||
{
|
||||
_fightService = fightService;
|
||||
_monsterService = monsterService;
|
||||
@@ -35,6 +36,7 @@ public class FightController : ControllerBase
|
||||
_userService = userService;
|
||||
_hookService = hookService;
|
||||
_relationService = relationService;
|
||||
_taskService = taskService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -162,16 +164,18 @@ public class FightController : ControllerBase
|
||||
return PoAction.Message("该地图不允许跨服战斗!");
|
||||
}
|
||||
}
|
||||
|
||||
string fightId = StringAssist.NewGuid;
|
||||
string areaCode = nameof(GameEnum.AreaCode.Own);
|
||||
string code = nameof(GameEnum.FightCode.PVP);
|
||||
string keyId = StringAssist.GetSortKey(userId,otUser.userId);
|
||||
string keyId = StringAssist.GetSortKey(userId, otUser.userId);
|
||||
long exp = 0;
|
||||
long copper = 0;
|
||||
long petExp = 0;
|
||||
string award = string.Empty;
|
||||
string pars = "";
|
||||
bool result = await _fightService.AddFight(fightId, areaCode, keyId, otUser.userId, code, onMapInfo.code, onMapInfo.mapId, userId, exp,
|
||||
bool result = await _fightService.AddFight(fightId, areaCode, keyId, otUser.userId, code, onMapInfo.code,
|
||||
onMapInfo.mapId, userId, exp,
|
||||
copper, petExp, award, pars);
|
||||
if (result)
|
||||
{
|
||||
@@ -229,17 +233,6 @@ public class FightController : ControllerBase
|
||||
#endregion
|
||||
|
||||
//更新攻击
|
||||
if (fightResult.result == 0)
|
||||
{
|
||||
myHarm = fightResult.myHarm;
|
||||
myHarm += await _fightService.GetUserFightHarm(userId);
|
||||
otHarm = fightResult.otHarm;
|
||||
await _attrService.UpdateUserBlood(userId, 1, fightResult.myHarm);
|
||||
await _attrService.AddUserLoadState(userId, fightResult.myStateData);
|
||||
await _fightService.HandelFightEnd(userId, fightResult.myRemData);
|
||||
}
|
||||
|
||||
var myAttr = await _attrService.GetUserAttrModel(userId, fight.scene);
|
||||
UserAttrModel otAttr = new UserAttrModel();
|
||||
if (fight.code == nameof(GameEnum.FightCode.PVE))
|
||||
{
|
||||
@@ -264,6 +257,20 @@ public class FightController : ControllerBase
|
||||
|
||||
otAttr = await _attrService.GetUserAttrModel(fight.mainId, fight.scene);
|
||||
}
|
||||
if (fightResult.result == 0)
|
||||
{
|
||||
if (otAttr.blood >0)
|
||||
{
|
||||
myHarm = fightResult.myHarm;
|
||||
myHarm += await _fightService.GetUserFightHarm(userId);
|
||||
otHarm = fightResult.otHarm;
|
||||
await _attrService.UpdateUserBlood(userId, 1, fightResult.myHarm);
|
||||
await _attrService.AddUserLoadState(userId, fightResult.myStateData);
|
||||
await _fightService.HandelFightEnd(userId, fightResult.myRemData);
|
||||
}
|
||||
}
|
||||
|
||||
var myAttr = await _attrService.GetUserAttrModel(userId, fight.scene);
|
||||
|
||||
//结束战斗都此处直接返回
|
||||
if (otAttr.blood < 1 || myAttr.blood < 1)
|
||||
@@ -545,10 +552,26 @@ public class FightController : ControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
string figArea = nameof(MonsterEnum.MonsterCode.Default);
|
||||
var myAttr = await _attrService.GetUserAttrModel(userId, fight.scene);
|
||||
var parsData = JsonConvert.DeserializeObject<dynamic>(fight.pars);
|
||||
object figResult = new object();
|
||||
if (Convert.ToString(parsData.type) == "Create")
|
||||
{
|
||||
if (Convert.ToString(parsData.code) == nameof(MonsterEnum.MonsterCode.Task))
|
||||
{
|
||||
int itemId = Convert.ToInt32(parsData.par);
|
||||
var taskInfo = await _taskService.GetTaskItemInfo(itemId);
|
||||
if (taskInfo != null)
|
||||
{
|
||||
figArea = nameof(MonsterEnum.MonsterCode.Task);
|
||||
figResult = await _taskService.GetUserTaskModel(userId, taskInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return PoAction.Ok(new { isWin, otName, blood = myAttr.blood, upBlood = myAttr.upBlood, fight, isCopy });
|
||||
return PoAction.Ok(new
|
||||
{ isWin, otName, blood = myAttr.blood, upBlood = myAttr.upBlood, fight, isCopy, figArea, figResult });
|
||||
}
|
||||
|
||||
#region 挂机相关
|
||||
|
||||
Reference in New Issue
Block a user