121212
This commit is contained in:
@@ -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