12121
This commit is contained in:
@@ -19,7 +19,7 @@ namespace Application.Domain.Entity
|
|||||||
public string? userId { get; set; }
|
public string? userId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// areaCode
|
/// 作用区域
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(Length = 255, IsNullable = true)]
|
[SugarColumn(Length = 255, IsNullable = true)]
|
||||||
public string? areaCode { get; set; }
|
public string? areaCode { get; set; }
|
||||||
@@ -43,17 +43,23 @@ namespace Application.Domain.Entity
|
|||||||
public string? monsterName { get; set; }
|
public string? monsterName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// code
|
/// 场景
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(Length = 50, IsNullable = true)]
|
[SugarColumn(Length = 50, IsNullable = true)]
|
||||||
public string? code { get; set; }
|
public string? code { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// par
|
/// 相关参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(Length = 255, IsNullable = true)]
|
[SugarColumn(Length = 255, IsNullable = true)]
|
||||||
public string? par { get; set; }
|
public string? par { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// state
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? state { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// addTime
|
/// addTime
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Application.Domain.Entity
|
||||||
|
{
|
||||||
|
[Tenant("Kg.SeaTime.Game")]
|
||||||
|
public class unit_user_task
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// utId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsPrimaryKey = true, Length = 50)]
|
||||||
|
public string utId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// userId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 50, IsNullable = true)]
|
||||||
|
public string? userId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// taskId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? taskId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// itemId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? itemId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// name
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 255, IsNullable = true)]
|
||||||
|
public string? name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// code
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 50, IsNullable = true)]
|
||||||
|
public string? code { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// endTime
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public long? endTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Application.Domain.Entity
|
||||||
|
{
|
||||||
|
[Tenant("Kg.SeaTime.Game")]
|
||||||
|
public class unit_user_task_log
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// utId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsPrimaryKey = true, Length = 50)]
|
||||||
|
public string utId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// userId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 50, IsNullable = true)]
|
||||||
|
public string? userId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// taskId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? taskId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// addTime
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public DateTime? addTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// endTime
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public long? endTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
9
Service/Application.Domain.Entity/model/GameNpcModel.cs
Normal file
9
Service/Application.Domain.Entity/model/GameNpcModel.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Application.Domain.Entity;
|
||||||
|
|
||||||
|
public class GameNpcModel
|
||||||
|
{
|
||||||
|
public int npcId { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string tips { get; set; }
|
||||||
|
public int state { get; set; }
|
||||||
|
}
|
||||||
8
Service/Application.Domain.Entity/model/TaskNeedData.cs
Normal file
8
Service/Application.Domain.Entity/model/TaskNeedData.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Application.Domain.Entity;
|
||||||
|
|
||||||
|
public class TaskNeedData:TowerNeed
|
||||||
|
{
|
||||||
|
public string areaCode { get; set; }
|
||||||
|
public string mapId { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
11
Service/Application.Domain.Entity/model/UserTaskModel.cs
Normal file
11
Service/Application.Domain.Entity/model/UserTaskModel.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace Application.Domain.Entity;
|
||||||
|
|
||||||
|
public class UserTaskModel
|
||||||
|
{
|
||||||
|
public string code { get; set; }
|
||||||
|
public int taskId { get; set; }
|
||||||
|
public int itemId { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public int state { get; set; }
|
||||||
|
public CheckTowerNeed result { get; set; }
|
||||||
|
}
|
||||||
81
Service/Application.Domain.Entity/resource/game/game_task.cs
Normal file
81
Service/Application.Domain.Entity/resource/game/game_task.cs
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Application.Domain.Entity
|
||||||
|
{
|
||||||
|
[Tenant("Kg.SeaTime.Resource")]
|
||||||
|
public class game_task
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// taskId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public int taskId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// code
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 255, IsNullable = true)]
|
||||||
|
public string? code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// name
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 50, IsNullable = true)]
|
||||||
|
public string? name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// itemCount
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? itemCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// count
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? count { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// timeSpan
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 50, IsNullable = true)]
|
||||||
|
public string? timeSpan { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// sTime
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? sTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// eTime
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? eTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// lev
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? lev { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// remark
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 255, IsNullable = true)]
|
||||||
|
public string? remark { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任务完成时间分钟 0不限制
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// status
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? status { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Application.Domain.Entity
|
||||||
|
{
|
||||||
|
[Tenant("Kg.SeaTime.Resource")]
|
||||||
|
public class game_task_item
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// tiId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public int tiId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// taskId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? taskId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// name
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 255, IsNullable = true)]
|
||||||
|
public string? name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 主线、支线
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 255, IsNullable = true)]
|
||||||
|
public string? code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// inType
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 50, IsNullable = true)]
|
||||||
|
public string? inType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 普通,答题
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(Length = 255, IsNullable = true)]
|
||||||
|
public string? itemCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 0起始环 1任务环 2结束环
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? itemType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// npcId
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? npcId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// needData
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true,IsJson = true)]
|
||||||
|
public List<TaskNeedData> needData { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 环说明
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public string? taskTips { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// nextTips
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public string? nextTips { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 按钮提示
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public string? btnTips { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// award
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public string? award { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任务时长
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 等级
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int? lev { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,4 +18,6 @@ public static class GameConfig
|
|||||||
public const int GameToMapNeedCopper = 5;//传送每海里费用
|
public const int GameToMapNeedCopper = 5;//传送每海里费用
|
||||||
public const int TeamCacheTime = 300;//队伍缓存时间
|
public const int TeamCacheTime = 300;//队伍缓存时间
|
||||||
public const int GameEquApprGoods = 10019;//鉴定装备道具
|
public const int GameEquApprGoods = 10019;//鉴定装备道具
|
||||||
|
public const int GameGetTaskGoods =10034 ;//引路蜂
|
||||||
|
public const int GameRetTaskGoods =10033 ;//领路蝶
|
||||||
}
|
}
|
||||||
@@ -16,4 +16,12 @@ public class MapEnum
|
|||||||
DEF_MAP,
|
DEF_MAP,
|
||||||
Dup_Map
|
Dup_Map
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum NpcCode
|
||||||
|
{
|
||||||
|
Default,
|
||||||
|
Task,
|
||||||
|
Dup_In,
|
||||||
|
Dup_Exit
|
||||||
|
}
|
||||||
}
|
}
|
||||||
16
Service/Application.Domain/Enum/TaskEnum.cs
Normal file
16
Service/Application.Domain/Enum/TaskEnum.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
namespace Application.Domain;
|
||||||
|
|
||||||
|
public static class TaskEnum
|
||||||
|
{
|
||||||
|
public enum TaskCode
|
||||||
|
{
|
||||||
|
主线,
|
||||||
|
支线,
|
||||||
|
日常
|
||||||
|
}
|
||||||
|
public enum ItemCode
|
||||||
|
{
|
||||||
|
普通,
|
||||||
|
答题
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ public interface IGameMapService
|
|||||||
Task<game_city_map> GetMapInfo(string mapId);
|
Task<game_city_map> GetMapInfo(string mapId);
|
||||||
Task<int> GetMapCityByMapId(string mapId);
|
Task<int> GetMapCityByMapId(string mapId);
|
||||||
Task<List<game_city_npc>> GetMapNpc(string mapId);
|
Task<List<game_city_npc>> GetMapNpc(string mapId);
|
||||||
|
Task<List<GameNpcModel>> GetMapNpcModel(string userId, string mapId, int areaId);
|
||||||
Task<game_city_npc> GetNpcInfo(int npcId);
|
Task<game_city_npc> GetNpcInfo(int npcId);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
namespace Application.Domain;
|
||||||
|
|
||||||
|
public interface IGameTaskService
|
||||||
|
{
|
||||||
|
#region 任务基础
|
||||||
|
|
||||||
|
Task<game_task> GetTaskInfo(int taskId);
|
||||||
|
Task<List<UserTaskModel>> GetTaskDataByNpc(string userId, int npcId);
|
||||||
|
Task<game_task_item> GetTaskItemInfo(int itemId);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 个人任务
|
||||||
|
|
||||||
|
Task<unit_user_task> GetUserTaskInfo(string userId, int taskId);
|
||||||
|
Task<bool> UpdateUserTaskInfo(string userId, int itemId);
|
||||||
|
Task<int> GetUserTaskCount(string userId, int taskId);
|
||||||
|
Task<UserTaskModel> GetUserTaskModel(string userId, game_task_item task);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -187,6 +187,12 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
|||||||
result = await db.SaveQueuesAsync() > 0;
|
result = await db.SaveQueuesAsync() > 0;
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
|
if (fightData.keyId != fightData.fightId)
|
||||||
|
{
|
||||||
|
var monsterService = App.GetService<IGameMonsterService>();
|
||||||
|
await monsterService.RemoveCreateMonster(fightData.keyId);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var item in data)
|
foreach (var item in data)
|
||||||
{
|
{
|
||||||
await ClearFightInfoCache(item.fightId, item.keyId, true);
|
await ClearFightInfoCache(item.fightId, item.keyId, true);
|
||||||
|
|||||||
@@ -119,6 +119,40 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<GameNpcModel>> GetMapNpcModel(string userId, string mapId, int areaId)
|
||||||
|
{
|
||||||
|
var taskService = App.GetService<IGameTaskService>();
|
||||||
|
List<GameNpcModel> result = new List<GameNpcModel>();
|
||||||
|
var data = await GetMapNpc(mapId);
|
||||||
|
foreach (var item in data)
|
||||||
|
{
|
||||||
|
if (GameTool.AreaVerify(areaId, item.areaId) == false)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameNpcModel temp = new GameNpcModel()
|
||||||
|
{
|
||||||
|
npcId = item.npcId,
|
||||||
|
name = item.npcName,
|
||||||
|
tips = item.tips,
|
||||||
|
state = 0
|
||||||
|
};
|
||||||
|
if (item.code == nameof(MapEnum.NpcCode.Task))
|
||||||
|
{
|
||||||
|
var task = await taskService.GetTaskDataByNpc(userId,item.npcId);
|
||||||
|
if (task.Count > 0)
|
||||||
|
{
|
||||||
|
temp.state = task.Any(it => it.state == 0) ? 1 : 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Add(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<game_city_npc> GetNpcInfo(int npcId)
|
public async Task<game_city_npc> GetNpcInfo(int npcId)
|
||||||
{
|
{
|
||||||
string key = string.Format(BaseCache.BaseCacheKeys, "CityData", "NpcInfo");
|
string key = string.Format(BaseCache.BaseCacheKeys, "CityData", "NpcInfo");
|
||||||
@@ -183,6 +217,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
|||||||
isOnline = isOnline
|
isOnline = isOnline
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateUserOnMap(string userId)
|
public async Task UpdateUserOnMap(string userId)
|
||||||
{
|
{
|
||||||
unit_user_online onLine = await GetUserOnMap(userId);
|
unit_user_online onLine = await GetUserOnMap(userId);
|
||||||
@@ -194,6 +229,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
|||||||
await db.Updateable<unit_user_online>(onLine).ExecuteCommandAsync();
|
await db.Updateable<unit_user_online>(onLine).ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateUserOnMap(string userId, string ip, string mapId)
|
public async Task UpdateUserOnMap(string userId, string ip, string mapId)
|
||||||
{
|
{
|
||||||
unit_user_online onLine = new unit_user_online();
|
unit_user_online onLine = new unit_user_online();
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public class GameMonsterService(ISqlSugarClient DbClient, IRedisCache redis) : I
|
|||||||
monsterName = monsterInfo.name,
|
monsterName = monsterInfo.name,
|
||||||
code = monsterInfo.code,
|
code = monsterInfo.code,
|
||||||
par = par,
|
par = par,
|
||||||
|
state = 0,
|
||||||
addTime = onTime,
|
addTime = onTime,
|
||||||
endTime = endTime
|
endTime = endTime
|
||||||
});
|
});
|
||||||
@@ -106,7 +107,8 @@ public class GameMonsterService(ISqlSugarClient DbClient, IRedisCache redis) : I
|
|||||||
}
|
}
|
||||||
|
|
||||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_monster>();
|
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_monster>();
|
||||||
var data = await db.Queryable<unit_user_monster>().Where(it => it.mapId == mapId).ToListAsync();
|
var data = await db.Queryable<unit_user_monster>().Where(it => it.mapId == mapId && it.state == 0)
|
||||||
|
.ToListAsync();
|
||||||
await redis.AddHashAsync(key, mapId, data);
|
await redis.AddHashAsync(key, mapId, data);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -130,7 +132,7 @@ public class GameMonsterService(ISqlSugarClient DbClient, IRedisCache redis) : I
|
|||||||
var data = await GetCreateMonsterInfo(umId);
|
var data = await GetCreateMonsterInfo(umId);
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
result = await RemoveCreateMonster(data);
|
result = await RemoveCreateMonster(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -139,7 +141,9 @@ public class GameMonsterService(ISqlSugarClient DbClient, IRedisCache redis) : I
|
|||||||
public async Task<bool> RemoveCreateMonster(unit_user_monster data)
|
public async Task<bool> RemoveCreateMonster(unit_user_monster data)
|
||||||
{
|
{
|
||||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_monster>();
|
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_monster>();
|
||||||
bool result = await db.Deleteable<unit_user_monster>().Where(it => it.umId == data.umId).ExecuteCommandAsync()>0;
|
bool result = await db.Updateable<unit_user_monster>()
|
||||||
|
.SetColumns(it => it.state == 1)
|
||||||
|
.Where(it => it.umId == data.umId).ExecuteCommandAsync() > 0;
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
await ClearCreateMonster(data.mapId);
|
await ClearCreateMonster(data.mapId);
|
||||||
@@ -174,7 +178,6 @@ public class GameMonsterService(ISqlSugarClient DbClient, IRedisCache redis) : I
|
|||||||
await redis.DelHashAsync(key, mapIds.ToArray());
|
await redis.DelHashAsync(key, mapIds.ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<MapMonsterModel>> GetMapMonster(string userId, string mapId, string teamId)
|
public async Task<List<MapMonsterModel>> GetMapMonster(string userId, string mapId, string teamId)
|
||||||
@@ -258,9 +261,9 @@ public class GameMonsterService(ISqlSugarClient DbClient, IRedisCache redis) : I
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 怪物模型
|
#region 怪物模型
|
||||||
|
|
||||||
public async Task<UserAttrModel> GetMonsterAttrModel(string keyId,string monsterId)
|
public async Task<UserAttrModel> GetMonsterAttrModel(string keyId, string monsterId)
|
||||||
{
|
{
|
||||||
UserAttrModel temp = new UserAttrModel();
|
UserAttrModel temp = new UserAttrModel();
|
||||||
var monsterInfo = await GetMonsterInfo(monsterId);
|
var monsterInfo = await GetMonsterInfo(monsterId);
|
||||||
@@ -293,6 +296,7 @@ public class GameMonsterService(ISqlSugarClient DbClient, IRedisCache redis) : I
|
|||||||
|
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<int> GetMonsterBlood(string keyId, int maxBlood)
|
private async Task<int> GetMonsterBlood(string keyId, int maxBlood)
|
||||||
{
|
{
|
||||||
int blood = maxBlood;
|
int blood = maxBlood;
|
||||||
|
|||||||
@@ -0,0 +1,318 @@
|
|||||||
|
namespace Application.Domain;
|
||||||
|
|
||||||
|
public class GameTaskService(ISqlSugarClient DbClient, IRedisCache redis) : IGameTaskService, ITransient
|
||||||
|
{
|
||||||
|
#region 任务基础
|
||||||
|
|
||||||
|
public async Task<game_task> GetTaskInfo(int taskId)
|
||||||
|
{
|
||||||
|
string key = string.Format(BaseCache.BaseCacheKeys, "TaskCache", "TaskInfo");
|
||||||
|
if (await redis.HExistsHashAsync(key, taskId.ToString()))
|
||||||
|
{
|
||||||
|
return await redis.GetHashAsync<game_task>(key, taskId.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
var db = DbClient.AsTenant().GetConnectionWithAttr<game_task>();
|
||||||
|
var data = await db.Queryable<game_task>().Where(it => it.taskId == taskId).SingleAsync();
|
||||||
|
await redis.AddHashAsync(key, taskId.ToString(), data);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<UserTaskModel>> GetTaskDataByNpc(string userId, int npcId)
|
||||||
|
{
|
||||||
|
List<game_task_item> data = new List<game_task_item>();
|
||||||
|
List<UserTaskModel> result = new List<UserTaskModel>();
|
||||||
|
string key = string.Format(BaseCache.BaseCacheKeys, "TaskCache", "NpcTask");
|
||||||
|
if (await redis.HExistsHashAsync(key, npcId.ToString()))
|
||||||
|
{
|
||||||
|
data = await redis.GetHashAsync<List<game_task_item>>(key, npcId.ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var db = DbClient.AsTenant().GetConnectionWithAttr<game_task_item>();
|
||||||
|
data = await db.Queryable<game_task_item>().Where(it => it.npcId == npcId).ToListAsync();
|
||||||
|
await redis.AddHashAsync(key, npcId.ToString(), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in data)
|
||||||
|
{
|
||||||
|
var temp = await GetUserTaskModel(userId, item);
|
||||||
|
if (temp.state != -1)
|
||||||
|
{
|
||||||
|
result.Add(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<game_task_item> GetTaskItemInfo(int itemId)
|
||||||
|
{
|
||||||
|
string key = string.Format(BaseCache.BaseCacheKeys, "TaskCache", "TaskItemInfo");
|
||||||
|
if (await redis.HExistsHashAsync(key, itemId.ToString()))
|
||||||
|
{
|
||||||
|
return await redis.GetHashAsync<game_task_item>(key, itemId.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
var db = DbClient.AsTenant().GetConnectionWithAttr<game_task_item>();
|
||||||
|
var data = await db.Queryable<game_task_item>().Where(it => it.tiId == itemId).SingleAsync();
|
||||||
|
await redis.AddHashAsync(key, itemId.ToString(), data);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 个人任务
|
||||||
|
|
||||||
|
public async Task<unit_user_task> GetUserTaskInfo(string userId, int taskId)
|
||||||
|
{
|
||||||
|
string utId = $"{userId}_{taskId}";
|
||||||
|
string key = string.Format(UserCache.BaseCacheKeys, "TaskCache", "UserTaskInfo");
|
||||||
|
if (await redis.HExistsHashAsync(key, utId.ToString()))
|
||||||
|
{
|
||||||
|
return await redis.GetHashAsync<unit_user_task>(key, utId);
|
||||||
|
}
|
||||||
|
|
||||||
|
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_task>();
|
||||||
|
var data = await db.Queryable<unit_user_task>().Where(it => it.utId == utId).SingleAsync();
|
||||||
|
await redis.AddHashAsync(key, utId, data);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> UpdateUserTaskInfo(string userId, int itemId)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
var taskInfo = await GetTaskItemInfo(itemId);
|
||||||
|
if (taskInfo != null)
|
||||||
|
{
|
||||||
|
string utId = $"{userId}_{taskInfo.taskId}";
|
||||||
|
if (taskInfo.itemType == 2)
|
||||||
|
{
|
||||||
|
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_task>();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var onTask = await GetUserTaskInfo(userId, (int)taskInfo.taskId);
|
||||||
|
if (onTask == null)
|
||||||
|
{
|
||||||
|
onTask = new unit_user_task();
|
||||||
|
onTask.utId = utId;
|
||||||
|
onTask.userId = userId;
|
||||||
|
onTask.taskId = taskInfo.taskId;
|
||||||
|
onTask.itemId = taskInfo.tiId;
|
||||||
|
onTask.name = taskInfo.name;
|
||||||
|
onTask.code = taskInfo.code;
|
||||||
|
onTask.endTime = await GetItemEndTime((int)taskInfo.taskId, (int)taskInfo.time);
|
||||||
|
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_task>();
|
||||||
|
result = await db.Insertable(onTask).ExecuteCommandAsync() > 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
onTask.itemId = taskInfo.tiId;
|
||||||
|
onTask.name = taskInfo.name;
|
||||||
|
onTask.code = taskInfo.code;
|
||||||
|
onTask.endTime = await GetItemEndTime((int)taskInfo.taskId, (int)taskInfo.time);
|
||||||
|
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_task>();
|
||||||
|
result = await db.Updateable(onTask).ExecuteCommandAsync() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
string key = string.Format(UserCache.BaseCacheKeys, "TaskCache", "UserTaskInfo");
|
||||||
|
await redis.AddHashAsync(key, utId, onTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
if (taskInfo.itemType == 0)
|
||||||
|
{
|
||||||
|
await AddUserTaskLog(userId, (int)taskInfo.taskId);
|
||||||
|
}
|
||||||
|
else if (taskInfo.itemType == 1)
|
||||||
|
{
|
||||||
|
//初始化下一环任务
|
||||||
|
await ResetNextTask(userId, taskInfo.tiId + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> GetUserTaskCount(string userId, int taskId)
|
||||||
|
{
|
||||||
|
string utId = $"{userId}_{taskId}";
|
||||||
|
string key = string.Format(UserCache.BaseCacheKeys, "TaskCache", "UserTaskCount");
|
||||||
|
if (await redis.HExistsHashAsync(key, taskId.ToString()))
|
||||||
|
{
|
||||||
|
return await redis.GetHashAsync<int>(key, utId);
|
||||||
|
}
|
||||||
|
|
||||||
|
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_task_log>();
|
||||||
|
var data = await db.Queryable<unit_user_task_log>().Where(it => it.userId == userId && it.taskId == taskId)
|
||||||
|
.CountAsync();
|
||||||
|
await redis.AddHashAsync(key, utId, data);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task AddUserTaskLog(string userId, int taskId)
|
||||||
|
{
|
||||||
|
string utId = $"{userId}_{taskId}";
|
||||||
|
long endTime = await GetEndTime(taskId);
|
||||||
|
unit_user_task_log log = new unit_user_task_log()
|
||||||
|
{
|
||||||
|
utId = utId,
|
||||||
|
userId = userId,
|
||||||
|
taskId = taskId,
|
||||||
|
addTime = DateTime.Now,
|
||||||
|
endTime = endTime
|
||||||
|
};
|
||||||
|
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_task_log>();
|
||||||
|
bool result = await db.Insertable(log).ExecuteCommandAsync() > 0;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
string key = string.Format(UserCache.BaseCacheKeys, "TaskCache", "UserTaskCount");
|
||||||
|
await redis.DelHashAsync(key, utId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ResetNextTask(string userId, int nextId)
|
||||||
|
{
|
||||||
|
await Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<UserTaskModel> GetUserTaskModel(string userId, game_task_item task)
|
||||||
|
{
|
||||||
|
UserTaskModel model = new UserTaskModel()
|
||||||
|
{
|
||||||
|
code = task.code,
|
||||||
|
taskId = (int)task.taskId,
|
||||||
|
itemId = task.tiId,
|
||||||
|
name = task.name,
|
||||||
|
state = -1
|
||||||
|
};
|
||||||
|
var attrService = App.GetService<IUnitUserAttrService>();
|
||||||
|
int myLev = await attrService.GetUserLev(userId);
|
||||||
|
if (myLev < task.lev)
|
||||||
|
{
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (task.itemType == 0) //判断是否可接
|
||||||
|
{
|
||||||
|
var taskInfo = await GetTaskInfo((int)task.taskId);
|
||||||
|
if (taskInfo == null)
|
||||||
|
{
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taskInfo.status == 0)
|
||||||
|
{
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
int time = TimeAssist.GetHourNum;
|
||||||
|
if (time < taskInfo.sTime || time > taskInfo.eTime)
|
||||||
|
{
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
var userTask = await GetUserTaskInfo(userId, (int)task.taskId);
|
||||||
|
if (userTask != null) //判断是否接取
|
||||||
|
{
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
var onCount = await GetUserTaskCount(userId, (int)task.taskId);
|
||||||
|
if (onCount >= taskInfo.count)
|
||||||
|
{
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
model.result = await GameBus.CheckNeed(userId, task.needData);
|
||||||
|
model.state = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var userTask = await GetUserTaskInfo(userId, (int)task.taskId);
|
||||||
|
if (userTask == null) //判断是否接取
|
||||||
|
{
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (task.tiId != (userTask.itemId + 1))
|
||||||
|
{
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await GameBus.CheckNeed(userId, task.needData);
|
||||||
|
model.result = result;
|
||||||
|
if (result.result)
|
||||||
|
{
|
||||||
|
model.state = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model.state = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 辅助
|
||||||
|
|
||||||
|
private async Task<long> GetItemEndTime(int taskId, int time)
|
||||||
|
{
|
||||||
|
long result = TimeExtend.GetTimeStampSeconds;
|
||||||
|
if (time == 0)
|
||||||
|
{
|
||||||
|
var taskInfo = await GetTaskInfo(taskId);
|
||||||
|
if (taskInfo.time == 0)
|
||||||
|
{
|
||||||
|
result += 3650 * 24 * 60 * 60;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result += (int)taskInfo.time * 60;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result += time * 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<long> GetEndTime(int taskId)
|
||||||
|
{
|
||||||
|
long result = TimeExtend.GetTimeStampSeconds;
|
||||||
|
var taskInfo = await GetTaskInfo(taskId);
|
||||||
|
if (taskInfo != null)
|
||||||
|
{
|
||||||
|
if (taskInfo.time == 0)
|
||||||
|
{
|
||||||
|
result += 3650 * 24 * 60 * 60;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result += (int)taskInfo.time * 60;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -101,6 +101,24 @@ public static class GameBus
|
|||||||
|
|
||||||
#region 验证
|
#region 验证
|
||||||
|
|
||||||
|
public static async Task<CheckTowerNeed> CheckNeed(string userId, dynamic data, int count = 1)
|
||||||
|
{
|
||||||
|
List<TowerNeed> needs = new List<TowerNeed>();
|
||||||
|
foreach (var item in data)
|
||||||
|
{
|
||||||
|
needs.Add(new TowerNeed()
|
||||||
|
{
|
||||||
|
code = Convert.ToString(item.code),
|
||||||
|
name = Convert.ToString(item.name),
|
||||||
|
parameter = Convert.ToString(item.parameter),
|
||||||
|
count = Convert.ToInt64(item.count),
|
||||||
|
retCount = Convert.ToInt64(item.retCount)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return await CheckNeed(userId, needs, count);
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<CheckTowerNeed> CheckNeed(string userId, TowerNeed item, int count = 1)
|
public static async Task<CheckTowerNeed> CheckNeed(string userId, TowerNeed item, int count = 1)
|
||||||
{
|
{
|
||||||
CheckTowerNeed result = new CheckTowerNeed();
|
CheckTowerNeed result = new CheckTowerNeed();
|
||||||
@@ -219,23 +237,23 @@ public static class GameBus
|
|||||||
int isGive = 1;
|
int isGive = 1;
|
||||||
foreach (var item in needs)
|
foreach (var item in needs)
|
||||||
{
|
{
|
||||||
var cheakResult = await CheckNeed(userId, item, count);
|
var checkResult = await CheckNeed(userId, item, count);
|
||||||
if (isok)
|
if (isok)
|
||||||
{
|
{
|
||||||
isok = cheakResult.result;
|
isok = checkResult.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cheakResult.isDeal == 0)
|
if (checkResult.isDeal == 0)
|
||||||
{
|
{
|
||||||
isDeal = 0;
|
isDeal = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cheakResult.isGive == 0)
|
if (checkResult.isGive == 0)
|
||||||
{
|
{
|
||||||
isGive = 0;
|
isGive = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Needs.AddRange(cheakResult.Needs);
|
result.Needs.AddRange(checkResult.Needs);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.result = isok;
|
result.result = isok;
|
||||||
|
|||||||
@@ -10,10 +10,11 @@ namespace Application.Web.Controllers.Map;
|
|||||||
public class MapBusController : ControllerBase
|
public class MapBusController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IGameMapService _mapService;
|
private readonly IGameMapService _mapService;
|
||||||
|
private readonly IMessageService _messageService;
|
||||||
public MapBusController(IGameMapService mapService)
|
public MapBusController(IGameMapService mapService,IMessageService messageService)
|
||||||
{
|
{
|
||||||
_mapService = mapService;
|
_mapService = mapService;
|
||||||
|
_messageService = messageService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -102,4 +103,66 @@ public class MapBusController : ControllerBase
|
|||||||
return PoAction.Message("操作失败,请稍后尝试!");
|
return PoAction.Message("操作失败,请稍后尝试!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 打开宝箱
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IPoAction> MapBusBox(int id)
|
||||||
|
{
|
||||||
|
string userId = StateHelper.userId;
|
||||||
|
var busData = await _mapService.GetMapBusInfo(id);
|
||||||
|
if (busData == null)
|
||||||
|
{
|
||||||
|
return PoAction.Message("业务不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (busData.busType != "Box")
|
||||||
|
{
|
||||||
|
return PoAction.Message("业务不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var onMap = await _mapService.GetUserOnMapId(userId);
|
||||||
|
if (busData.busCode != onMap)
|
||||||
|
{
|
||||||
|
return PoAction.Message("业务不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkResult = await GameBus.CheckNeed(userId, busData.busNeed, 1);
|
||||||
|
if (checkResult.result==false)
|
||||||
|
{
|
||||||
|
return PoAction.Message("不满足开启要求!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await GameBus.UpdateBag(userId, 0, busData.busNeed, "业务传送"))
|
||||||
|
{
|
||||||
|
string message = "";
|
||||||
|
var park = JsonConvert.DeserializeObject<RandomModel>(busData.busContent);
|
||||||
|
var award = GameBus.GetRandomGoods(park);
|
||||||
|
if (award.Count > 0)
|
||||||
|
{
|
||||||
|
message = $"开启了[{park.name}],获得:";
|
||||||
|
foreach (var item in award)
|
||||||
|
{
|
||||||
|
message += $"{item.name}+{item.count},";
|
||||||
|
}
|
||||||
|
|
||||||
|
message = message.TrimEnd(',');
|
||||||
|
await GameBus.UpdateBag(userId, 1, award, $"开启:{park.name}获得");
|
||||||
|
|
||||||
|
await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Award), message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = "空空如也,什么也没有得到!";
|
||||||
|
}
|
||||||
|
return PoAction.Ok(true,message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("操作失败,请稍后尝试!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace Application.Web.Controllers.Map;
|
namespace Application.Web.Controllers.Map;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -24,12 +23,13 @@ public class MapController : ControllerBase
|
|||||||
private readonly IGameMonsterService _monsterService;
|
private readonly IGameMonsterService _monsterService;
|
||||||
private readonly IGameFightService _fightService;
|
private readonly IGameFightService _fightService;
|
||||||
private readonly IOnHookService _hookService;
|
private readonly IOnHookService _hookService;
|
||||||
|
private readonly IGameTaskService _taskService;
|
||||||
|
|
||||||
public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService,
|
public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService,
|
||||||
IUnitUserAttrService attrService, IMessageService messageService, IUnitUserWeight weightService,
|
IUnitUserAttrService attrService, IMessageService messageService, IUnitUserWeight weightService,
|
||||||
IUnitUserAccService accService, IGameSkillService skillService, IGameGoodsService goodsService,
|
IUnitUserAccService accService, IGameSkillService skillService, IGameGoodsService goodsService,
|
||||||
IGameTeamService teamService, IGameMonsterService monsterService, IGameFightService fightService,
|
IGameTeamService teamService, IGameMonsterService monsterService, IGameFightService fightService,
|
||||||
IOnHookService hookService)
|
IOnHookService hookService, IGameTaskService taskService)
|
||||||
{
|
{
|
||||||
_userService = userService;
|
_userService = userService;
|
||||||
_mapService = mapService;
|
_mapService = mapService;
|
||||||
@@ -44,6 +44,7 @@ public class MapController : ControllerBase
|
|||||||
_monsterService = monsterService;
|
_monsterService = monsterService;
|
||||||
_fightService = fightService;
|
_fightService = fightService;
|
||||||
_hookService = hookService;
|
_hookService = hookService;
|
||||||
|
_taskService = taskService;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 地图相关
|
#region 地图相关
|
||||||
@@ -106,8 +107,7 @@ public class MapController : ControllerBase
|
|||||||
var chatData = await _chatService.GetChatTop(userId, area, 2, teamId, groupId);
|
var chatData = await _chatService.GetChatTop(userId, area, 2, teamId, groupId);
|
||||||
|
|
||||||
|
|
||||||
var npcData = await _mapService.GetMapNpc(mapInfo.mapId); //NPC信息
|
var npcData = await _mapService.GetMapNpcModel(userId, mapInfo.mapId, area); //NPC信息
|
||||||
npcData = npcData.FindAll(it => GameTool.AreaVerify(StateHelper.areaId, it.areaId));
|
|
||||||
|
|
||||||
//获取怪物
|
//获取怪物
|
||||||
var monsterData = await _monsterService.GetMapMonster(userId, mapInfo.mapId, teamId);
|
var monsterData = await _monsterService.GetMapMonster(userId, mapInfo.mapId, teamId);
|
||||||
@@ -668,7 +668,13 @@ public class MapController : ControllerBase
|
|||||||
return PoAction.Message("Npc不存在!");
|
return PoAction.Message("Npc不存在!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return PoAction.Ok(data);
|
List<UserTaskModel> task = new List<UserTaskModel>();
|
||||||
|
if (data.code == nameof(MapEnum.NpcCode.Task))
|
||||||
|
{
|
||||||
|
task = await _taskService.GetTaskDataByNpc(userId, npcId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PoAction.Ok(new { data, task });
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
298
Service/Application.Web/Controllers/Map/TaskController.cs
Normal file
298
Service/Application.Web/Controllers/Map/TaskController.cs
Normal file
@@ -0,0 +1,298 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Application.Web.Controllers.Map;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任务接口
|
||||||
|
/// </summary>
|
||||||
|
[ApiExplorerSettings(GroupName = "Map")]
|
||||||
|
[Route("Map/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class TaskController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IGameMapService _mapService;
|
||||||
|
private readonly IGameTaskService _taskService;
|
||||||
|
private readonly IGameGoodsService _goodsService;
|
||||||
|
|
||||||
|
public TaskController(IGameMapService mapService, IGameTaskService taskService, IGameGoodsService goodsService)
|
||||||
|
{
|
||||||
|
_mapService = mapService;
|
||||||
|
_taskService = taskService;
|
||||||
|
_goodsService = goodsService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取NPC任务
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="npcId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IPoAction> GetTaskByNpc(int npcId, int taskId)
|
||||||
|
{
|
||||||
|
string userId = StateHelper.userId;
|
||||||
|
int areaId = StateHelper.areaId;
|
||||||
|
var npcInfo = await _mapService.GetNpcInfo(npcId);
|
||||||
|
if (npcInfo == null)
|
||||||
|
{
|
||||||
|
return PoAction.Message("Npc不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (npcInfo.status != 1)
|
||||||
|
{
|
||||||
|
return PoAction.Message("Npc不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (npcInfo.code != nameof(MapEnum.NpcCode.Task))
|
||||||
|
{
|
||||||
|
return PoAction.Message("Npc错误!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameTool.AreaVerify(areaId, npcInfo.areaId) == false)
|
||||||
|
{
|
||||||
|
return PoAction.Message("Npc不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var onMap = await _mapService.GetUserOnMapId(userId);
|
||||||
|
if (npcInfo.mapId != onMap)
|
||||||
|
{
|
||||||
|
return PoAction.Message("Npc不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var taskInfo = await _taskService.GetTaskItemInfo(taskId);
|
||||||
|
if (taskInfo == null)
|
||||||
|
{
|
||||||
|
return PoAction.Message("任务不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taskInfo.npcId != npcId)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
taskState = taskInfo.npcId == npcId ? 1 : 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = await _taskService.GetUserTaskModel(userId, taskInfo);
|
||||||
|
if (data.state == -1)
|
||||||
|
{
|
||||||
|
return PoAction.Message("任务不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
int toGoods = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameGetTaskGoods);
|
||||||
|
int retGoods = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameRetTaskGoods);
|
||||||
|
return PoAction.Ok(new
|
||||||
|
{ npc = npcInfo, data = data, talkMsg, taskState, btnTips = taskInfo.btnTips, toGoods, retGoods });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 完成任务
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="npcId"></param>
|
||||||
|
/// <param name="taskId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IPoAction> OverTask(int npcId, int taskId)
|
||||||
|
{
|
||||||
|
string userId = StateHelper.userId;
|
||||||
|
int areaId = StateHelper.areaId;
|
||||||
|
var npcInfo = await _mapService.GetNpcInfo(npcId);
|
||||||
|
if (npcInfo == null)
|
||||||
|
{
|
||||||
|
return PoAction.Message("Npc不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (npcInfo.status != 1)
|
||||||
|
{
|
||||||
|
return PoAction.Message("Npc不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (npcInfo.code != nameof(MapEnum.NpcCode.Task))
|
||||||
|
{
|
||||||
|
return PoAction.Message("Npc错误!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameTool.AreaVerify(areaId, npcInfo.areaId) == false)
|
||||||
|
{
|
||||||
|
return PoAction.Message("Npc不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var onMap = await _mapService.GetUserOnMapId(userId);
|
||||||
|
if (npcInfo.mapId != onMap)
|
||||||
|
{
|
||||||
|
return PoAction.Message("Npc不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var taskInfo = await _taskService.GetTaskItemInfo(taskId);
|
||||||
|
if (taskInfo == null)
|
||||||
|
{
|
||||||
|
return PoAction.Message("任务不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taskInfo.npcId != npcId)
|
||||||
|
{
|
||||||
|
return PoAction.Message("任务不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkTask = await _taskService.GetUserTaskModel(userId, taskInfo);
|
||||||
|
if (checkTask.state == -1)
|
||||||
|
{
|
||||||
|
return PoAction.Message("任务不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkTask.result.result)
|
||||||
|
{
|
||||||
|
if (await GameBus.UpdateBag(userId, 0, taskInfo.needData, "完成任务"))
|
||||||
|
{
|
||||||
|
if (await _taskService.UpdateUserTaskInfo(userId, taskId))
|
||||||
|
{
|
||||||
|
string message = string.Empty;
|
||||||
|
if (!string.IsNullOrEmpty(taskInfo.award))
|
||||||
|
{
|
||||||
|
message = "任务完成,获得:";
|
||||||
|
List<TowerGet> award = JsonConvert.DeserializeObject<List<TowerGet>>(taskInfo.award);
|
||||||
|
foreach (var item in award)
|
||||||
|
{
|
||||||
|
message += $"{item.name}+{item.count},";
|
||||||
|
}
|
||||||
|
|
||||||
|
message = message.TrimEnd(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
return PoAction.Ok(true, message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("任务操作失败,请稍后尝试!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("任务完成失败,请稍后尝试!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("不满足任务条件!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物品道具点传送
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="task"></param>
|
||||||
|
/// <param name="num"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IPoAction> NeedMapTo(int task, int num)
|
||||||
|
{
|
||||||
|
string userId = StateHelper.userId;
|
||||||
|
var taskInfo = await _taskService.GetTaskItemInfo(task);
|
||||||
|
|
||||||
|
var checkTask = await _taskService.GetUserTaskModel(userId, taskInfo);
|
||||||
|
if (checkTask.state == -1)
|
||||||
|
{
|
||||||
|
return PoAction.Message("无法传送!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var toData = taskInfo.needData[num];
|
||||||
|
if (string.IsNullOrEmpty(toData.mapId))
|
||||||
|
{
|
||||||
|
return PoAction.Message("该任务要求不提供传送!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var goodsCount = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameGetTaskGoods);
|
||||||
|
if (goodsCount < 1)
|
||||||
|
{
|
||||||
|
return PoAction.Message("暂无引路蜂!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await _goodsService.UpdateUserGoods(userId, 0, GameConfig.GameGetTaskGoods, 1, "传送"))
|
||||||
|
{
|
||||||
|
var ResultMap = await _mapService.GetToMapInfo(userId, toData.mapId, true, true);
|
||||||
|
if (ResultMap != null)
|
||||||
|
{
|
||||||
|
return PoAction.Ok(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("传送失败,请稍后尝试!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("传送失败,请稍后尝试!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 任务提交传送
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="task"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IPoAction> ReturnTask(int task)
|
||||||
|
{
|
||||||
|
string userId = StateHelper.userId;
|
||||||
|
var taskInfo = await _taskService.GetTaskItemInfo(task);
|
||||||
|
|
||||||
|
var checkTask = await _taskService.GetUserTaskModel(userId, taskInfo);
|
||||||
|
if (checkTask.state == -1)
|
||||||
|
{
|
||||||
|
return PoAction.Message("无法传送!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkTask.result.result == false)
|
||||||
|
{
|
||||||
|
return PoAction.Message("任务未完成,无法传送!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var npcInfo = await _mapService.GetNpcInfo((int)taskInfo.npcId);
|
||||||
|
if (npcInfo == null)
|
||||||
|
{
|
||||||
|
return PoAction.Message("任务地点不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var goodsCount = await _goodsService.GetUserGoodsCount(userId, GameConfig.GameRetTaskGoods);
|
||||||
|
if (goodsCount < 1)
|
||||||
|
{
|
||||||
|
return PoAction.Message("暂无领路蝶!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await _goodsService.UpdateUserGoods(userId, 0, GameConfig.GameRetTaskGoods, 1, "传送"))
|
||||||
|
{
|
||||||
|
var ResultMap = await _mapService.GetToMapInfo(userId, npcInfo.mapId, true, true);
|
||||||
|
if (ResultMap != null)
|
||||||
|
{
|
||||||
|
return PoAction.Ok(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("传送失败,请稍后尝试!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("传送失败,请稍后尝试!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,8 +44,6 @@ namespace Application.Web.Controllers.Pub
|
|||||||
account.pwd = "";
|
account.pwd = "";
|
||||||
account.npwd = "";
|
account.npwd = "";
|
||||||
account.token = "";
|
account.token = "";
|
||||||
account.openId = "";
|
|
||||||
|
|
||||||
isOnline = true;
|
isOnline = true;
|
||||||
userData = await _userService.GetUserDataByAccId(account.accId);
|
userData = await _userService.GetUserDataByAccId(account.accId);
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Web/public/images/site/tg.gif
Normal file
BIN
Web/public/images/site/tg.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 90 B |
BIN
Web/public/images/site/tr.gif
Normal file
BIN
Web/public/images/site/tr.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 86 B |
@@ -42,6 +42,7 @@ const visible = ref(props.isShow)
|
|||||||
position: relative;
|
position: relative;
|
||||||
padding: 18px 20px;
|
padding: 18px 20px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
min-width: 150px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 标题文字 */
|
/* 标题文字 */
|
||||||
|
|||||||
32
Web/src/components/Business/GameTaskPropVerify.vue
Normal file
32
Web/src/components/Business/GameTaskPropVerify.vue
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<template>
|
||||||
|
<div class="common" v-for="(item, index) in data" :key="index">
|
||||||
|
<div v-if="item.code == 'Goods'">
|
||||||
|
▸<Abar :href='"/prop/goods?id=" + item.parameter'>{{ item.name }}</Abar>:({{ item.onCount }}/{{ item.count
|
||||||
|
}})
|
||||||
|
<span style="color: red;" v-if="item.isAsk == 0">(不满足)</span>
|
||||||
|
<span v-if="item.isAsk == 0">
|
||||||
|
[<Abutton @click="MapTo(index)">传送</Abutton>]
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
▸{{ item.name }}:({{ item.onCount }}/{{ item.count }})
|
||||||
|
<span style="color: red;" v-if="item.isAsk == 0">(不满足)</span>
|
||||||
|
<span v-if="item.isAsk == 0">
|
||||||
|
[<Abutton @click="MapTo(index)">传送</Abutton>]
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
const props = defineProps({
|
||||||
|
// 字段名、类型、默认值
|
||||||
|
data: Array<any>
|
||||||
|
})
|
||||||
|
const emit = defineEmits(['mapTo'])
|
||||||
|
|
||||||
|
const MapTo = async (num: Number) => {
|
||||||
|
emit('mapTo', { num: num });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -14,7 +14,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content" v-if="data.busType == 'Box'">
|
<div class="content" v-if="data.busType == 'Box'">
|
||||||
222
|
<div class="common" v-if="needs.length > 0">
|
||||||
|
开启要求:<br>
|
||||||
|
<GamePropVerify :data="verifyData.needs"></GamePropVerify>
|
||||||
|
</div>
|
||||||
|
<div class="common" v-if="verifyData.result">
|
||||||
|
<Abutton @click="OpenBox">立即开启</Abutton>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -67,4 +73,17 @@ const MapTo = async (index: number) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const OpenBox = async () => {
|
||||||
|
MessageExtend.LoadingToast("开启中...");
|
||||||
|
let result = await MapBusService.MapBusBox(Number(busId));
|
||||||
|
MessageExtend.LoadingClose();
|
||||||
|
if (result.code == 0) {
|
||||||
|
await BindData();
|
||||||
|
MessageExtend.Notify(result.msg,"success");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageExtend.ShowToast(result.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<GameBroadcast :data="broadcast"></GameBroadcast>
|
<GameBroadcast :data="broadcast"></GameBroadcast>
|
||||||
<div class="content" v-if="isHook==1">
|
<div class="content" v-if="isHook == 1">
|
||||||
<div class="item" style="font-size:15px;font-weight:bold;color:green">
|
<div class="item" style="font-size:15px;font-weight:bold;color:green">
|
||||||
<i class="dup"></i>
|
<i class="dup"></i>
|
||||||
<Abar href="/user/onhook" style="color:green">小宝贝,正在挂机中...</Abar>
|
<Abar href="/user/onhook" style="color:green">小宝贝,正在挂机中...</Abar>
|
||||||
@@ -31,7 +31,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="item" v-for="item in npcData">
|
<div class="item" v-for="item in npcData">
|
||||||
<Abar :href='"/map/npc?npc=" + item.npcId'>{{ item.npcName }}{{ item.tips }}</Abar>
|
<img src="/images/site/tg.gif" v-if="item.state == 1" />
|
||||||
|
<img src="/images/site/tr.gif" v-if="item.state == 2" />
|
||||||
|
<Abar :href='"/map/npc?npc=" + item.npcId'>{{ item.name }}{{ item.tips }}</Abar>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content" v-if="business.length > 0">
|
<div class="content" v-if="business.length > 0">
|
||||||
@@ -340,15 +342,15 @@ const AddFight = async (type: number, monsterId: string, sign: string) => {
|
|||||||
|
|
||||||
/**拾取物品 */
|
/**拾取物品 */
|
||||||
const GetMapGoods = async (mgId: string) => {
|
const GetMapGoods = async (mgId: string) => {
|
||||||
MessageExtend.LoadingToast("拾取中...");
|
MessageExtend.LoadingToast("拾取中...");
|
||||||
let result = await MapService.GetMapGoods(mgId);
|
let result = await MapService.GetMapGoods(mgId);
|
||||||
MessageExtend.LoadingClose();
|
MessageExtend.LoadingClose();
|
||||||
if (result.code == 0) {
|
if (result.code == 0) {
|
||||||
await BindData("");
|
await BindData("");
|
||||||
MessageExtend.Notify(result.msg,"success");
|
MessageExtend.Notify(result.msg, "success");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MessageExtend.Notify(result.msg,"danger");
|
MessageExtend.Notify(result.msg, "danger");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,21 @@
|
|||||||
{{ data.story }}
|
{{ data.story }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content" v-if="data.code == 'Default'">
|
||||||
<div class="item" v-for="item in data.bus">
|
<div class="item" v-for="item in data.bus">
|
||||||
◈<Abar :href="item.url">{{ item.name }}</Abar>
|
◈<Abar :href="item.url">{{ item.name }}</Abar>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="content" v-if="data.code == 'Task'">
|
||||||
|
<div class="common" v-if="task.length > 0">
|
||||||
|
当前任务:<br>
|
||||||
|
<div class="item" v-for="item in task">
|
||||||
|
<img src="/images/site/tg.gif" v-if="item.state==0" />
|
||||||
|
<img src="/images/site/tr.gif" v-if="item.state==1" />
|
||||||
|
<Abar :href='"/task/info?task=" + item.itemId'>[{{ item.code }}]{{ item.name }}</Abar>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
||||||
@@ -20,7 +30,7 @@ definePageMeta({
|
|||||||
middleware: 'page-loading'
|
middleware: 'page-loading'
|
||||||
})
|
})
|
||||||
const data = ref<any>({});
|
const data = ref<any>({});
|
||||||
|
const task = ref<Array<any>>([]);
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
await BindData();
|
await BindData();
|
||||||
@@ -36,7 +46,8 @@ const BindData = async (): Promise<void> => {
|
|||||||
let npc = PageExtend.QueryString("npc");
|
let npc = PageExtend.QueryString("npc");
|
||||||
let result = await MapService.GetNpcInfo(Number(npc));
|
let result = await MapService.GetNpcInfo(Number(npc));
|
||||||
if (result.code == 0) {
|
if (result.code == 0) {
|
||||||
data.value = result.data;
|
data.value = result.data.data;
|
||||||
|
task.value = result.data.task;
|
||||||
LocalStorageHelper.SetOnNpc(npc);//存储当前进的npc信息
|
LocalStorageHelper.SetOnNpc(npc);//存储当前进的npc信息
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
110
Web/src/pages/task/info.vue
Normal file
110
Web/src/pages/task/info.vue
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
<template>
|
||||||
|
<div class="content">
|
||||||
|
<strong>{{ npcData.npcName }}</strong>:{{ talkMsg }}
|
||||||
|
</div>
|
||||||
|
<div class="content" v-if="taskState == 100">
|
||||||
|
等待开放下一环任务!
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<div v-if="data.state != -1">
|
||||||
|
<div class="content" v-if="needs.length > 0">
|
||||||
|
任务要求:<br>
|
||||||
|
<GameTaskPropVerify :data="verifyData.needs" @mapTo="mapTo"></GameTaskPropVerify>
|
||||||
|
</div>
|
||||||
|
<div class="content" v-if="verifyData.result">
|
||||||
|
<div v-if="taskState == 1">
|
||||||
|
我:<Abutton @click="ReturnTask">{{ btnTips }}</Abutton>
|
||||||
|
</div>
|
||||||
|
<div v-if="taskState == 2">
|
||||||
|
➢<Abutton @click="retTask">我要传送</Abutton>(领路蝶:{{ retGoods }})
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
definePageMeta({
|
||||||
|
layout: layout.default,
|
||||||
|
middleware: 'page-loading'
|
||||||
|
})
|
||||||
|
const data = ref<any>({});
|
||||||
|
const npcData = ref<any>({});
|
||||||
|
const verifyData = ref<any>({});
|
||||||
|
const needs = ref<Array<any>>([]);
|
||||||
|
const talkMsg = ref('');
|
||||||
|
const btnTips = ref('');
|
||||||
|
const taskState = ref(-1);
|
||||||
|
const toGoods = ref(0);
|
||||||
|
const retGoods = ref(0);
|
||||||
|
let taskId = PageExtend.QueryString("task");
|
||||||
|
let npcId = LocalStorageHelper.GetOnNpc();
|
||||||
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
await BindData();
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
PageLoading.Close();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const BindData = async (): Promise<void> => {
|
||||||
|
let result = await TaskService.GetTaskByNpc(Number(npcId), Number(taskId));
|
||||||
|
if (result.code == 0) {
|
||||||
|
data.value = result.data.data;
|
||||||
|
npcData.value = result.data.npc;
|
||||||
|
talkMsg.value = result.data.talkMsg;
|
||||||
|
btnTips.value = result.data.btnTips;
|
||||||
|
taskState.value = result.data.taskState;
|
||||||
|
toGoods.value = result.data.toGoods;
|
||||||
|
retGoods.value = result.data.retGoods;
|
||||||
|
verifyData.value = data.value.result;
|
||||||
|
needs.value = verifyData.value.needs;
|
||||||
|
taskId = data.value.itemId;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PageExtend.RedirectTo("/map/npc?npc=" + npcId)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const ReturnTask = async () => {
|
||||||
|
MessageExtend.LoadingToast("提交任务中...");
|
||||||
|
let result = await TaskService.OverTask(Number(npcId), Number(data.value.itemId));
|
||||||
|
MessageExtend.LoadingClose();
|
||||||
|
if (result.code == 0) {
|
||||||
|
await BindData();
|
||||||
|
if (result.msg != '') {
|
||||||
|
MessageExtend.Notify(result.msg, "success");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageExtend.Notify(result.msg, "danger");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapTo = async (btnData: any) => {
|
||||||
|
MessageExtend.LoadingToast("传送中...");
|
||||||
|
let result = await TaskService.NeedMapTo( Number(data.value.itemId), btnData.num);
|
||||||
|
MessageExtend.LoadingClose();
|
||||||
|
if (result.code == 0) {
|
||||||
|
PageExtend.RedirectTo("/map");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageExtend.Notify(result.msg, "danger");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const retTask = async (btnData: any) => {
|
||||||
|
MessageExtend.LoadingToast("传送中...");
|
||||||
|
let result = await TaskService.ReturnTask( Number(data.value.itemId));
|
||||||
|
MessageExtend.LoadingClose();
|
||||||
|
if (result.code == 0) {
|
||||||
|
PageExtend.RedirectTo("/map");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageExtend.Notify(result.msg, "danger");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -14,4 +14,12 @@ export class MapBusService {
|
|||||||
static async MapBusTo(id: number, num: number) {
|
static async MapBusTo(id: number, num: number) {
|
||||||
return await ApiService.Request("get", "/Map/MapBus/MapBusTo", { id, num });
|
return await ApiService.Request("get", "/Map/MapBus/MapBusTo", { id, num });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开宝箱
|
||||||
|
* GET /Map/MapBus/MapBusBox
|
||||||
|
*/
|
||||||
|
static async MapBusBox(id: number) {
|
||||||
|
return await ApiService.Request("get", "/Map/MapBus/MapBusBox", { id });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
33
Web/src/services/map/TaskService.ts
Normal file
33
Web/src/services/map/TaskService.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
export class TaskService {
|
||||||
|
/**
|
||||||
|
* 获取NPC任务
|
||||||
|
* GET /Map/Task/GetTaskByNpc
|
||||||
|
*/
|
||||||
|
static async GetTaskByNpc(npcId: number, taskId: number) {
|
||||||
|
return await ApiService.Request("get", "/Map/Task/GetTaskByNpc", { npcId, taskId });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 完成任务
|
||||||
|
* GET /Map/Task/OverTask
|
||||||
|
*/
|
||||||
|
static async OverTask(npcId: number, taskId: number) {
|
||||||
|
return await ApiService.Request("get", "/Map/Task/OverTask", { npcId, taskId });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物品道具点传送
|
||||||
|
* GET /Map/Task/NeedMapTo
|
||||||
|
*/
|
||||||
|
static async NeedMapTo(task: number, num: number) {
|
||||||
|
return await ApiService.Request("get", "/Map/Task/NeedMapTo", { task, num });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务提交传送
|
||||||
|
* GET /Map/Task/ReturnTask
|
||||||
|
*/
|
||||||
|
static async ReturnTask(task: number) {
|
||||||
|
return await ApiService.Request("get", "/Map/Task/ReturnTask", { task });
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user