diff --git a/Service/Application.Domain.Entity/game/user/unit_user_config.cs b/Service/Application.Domain.Entity/game/user/unit_user_config.cs index 6dc352e..6a0ecbe 100644 --- a/Service/Application.Domain.Entity/game/user/unit_user_config.cs +++ b/Service/Application.Domain.Entity/game/user/unit_user_config.cs @@ -41,5 +41,10 @@ namespace Application.Domain.Entity /// [SugarColumn(IsNullable = true)] public int? giveRole { get; set; } + /// + /// 消息权限:0封禁 1正常 + /// + [SugarColumn(IsNullable = true)] + public int? msgRole { get; set; } } } \ No newline at end of file diff --git a/Service/Application.Domain.Entity/log/db/game_mall_log.cs b/Service/Application.Domain.Entity/logdb/db/game_mall_log.cs similarity index 100% rename from Service/Application.Domain.Entity/log/db/game_mall_log.cs rename to Service/Application.Domain.Entity/logdb/db/game_mall_log.cs diff --git a/Service/Application.Domain.Entity/log/db/unit_user_acc_log.cs b/Service/Application.Domain.Entity/logdb/db/unit_user_acc_log.cs similarity index 100% rename from Service/Application.Domain.Entity/log/db/unit_user_acc_log.cs rename to Service/Application.Domain.Entity/logdb/db/unit_user_acc_log.cs diff --git a/Service/Application.Domain.Entity/log/db/unit_user_equ_log.cs b/Service/Application.Domain.Entity/logdb/db/unit_user_equ_log.cs similarity index 100% rename from Service/Application.Domain.Entity/log/db/unit_user_equ_log.cs rename to Service/Application.Domain.Entity/logdb/db/unit_user_equ_log.cs diff --git a/Service/Application.Domain.Entity/log/db/unit_user_goods_log.cs b/Service/Application.Domain.Entity/logdb/db/unit_user_goods_log.cs similarity index 100% rename from Service/Application.Domain.Entity/log/db/unit_user_goods_log.cs rename to Service/Application.Domain.Entity/logdb/db/unit_user_goods_log.cs diff --git a/Service/Application.Domain.Entity/log/db/unit_user_weight_log.cs b/Service/Application.Domain.Entity/logdb/db/unit_user_weight_log.cs similarity index 100% rename from Service/Application.Domain.Entity/log/db/unit_user_weight_log.cs rename to Service/Application.Domain.Entity/logdb/db/unit_user_weight_log.cs diff --git a/Service/Application.Domain.Entity/model/EquSuitAttr.cs b/Service/Application.Domain.Entity/model/EquSuitAttr.cs new file mode 100644 index 0000000..309daf7 --- /dev/null +++ b/Service/Application.Domain.Entity/model/EquSuitAttr.cs @@ -0,0 +1,33 @@ +namespace Application.Domain.Entity; + +public class EquSuitAttr +{ + private System.String _NeedType; + + /// + /// + /// + public System.String NeedType + { get { return this._NeedType; } set { this._NeedType = value; } } + + public String[] _NeedData; + + public System.String[] NeedData + { get { return this._NeedData; } set { this._NeedData = value; } } + + private System.Int32 _Type; + + /// + /// 0特殊属性 1隐藏属性 + /// + public System.Int32 Type + { get { return this._Type; } set { this._Type = value; } } + + private List _AttrItem; + + /// + /// + /// + public List AttrItem + { get { return this._AttrItem; } set { this._AttrItem = value; } } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/EquSuitList.cs b/Service/Application.Domain.Entity/model/EquSuitList.cs new file mode 100644 index 0000000..400413c --- /dev/null +++ b/Service/Application.Domain.Entity/model/EquSuitList.cs @@ -0,0 +1,20 @@ +namespace Application.Domain.Entity; + +public class EquSuitList +{ + private System.Int32 _equId; + + /// + /// 装备表Id--goods表 + /// + public System.Int32 equId + { get { return this._equId; } set { this._equId = value; } } + + private System.String _equName; + + /// + /// + /// + public System.String equName + { get { return this._equName; } set { this._equName = value; } } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/NpcBus.cs b/Service/Application.Domain.Entity/model/NpcBus.cs index 80eaf2c..c832149 100644 --- a/Service/Application.Domain.Entity/model/NpcBus.cs +++ b/Service/Application.Domain.Entity/model/NpcBus.cs @@ -2,6 +2,7 @@ public class NpcBus { + public string code { get; set; } public string name { get; set; } public string url { get; set; } } \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/UserAttrModel.cs b/Service/Application.Domain.Entity/model/UserAttrModel.cs index bcd638e..a0fae81 100644 --- a/Service/Application.Domain.Entity/model/UserAttrModel.cs +++ b/Service/Application.Domain.Entity/model/UserAttrModel.cs @@ -14,14 +14,14 @@ public string remark { get; set; } public string TmImg { get; set; } public int lev { get; set; }//等级 - public decimal minAtk { get; set; }//最小攻击 - public decimal maxAtk { get; set; }//最大攻击 - public decimal defense { get; set; }//防御 - public decimal agility { get; set; }//敏捷 - public decimal blood { get; set; }//血量 - public decimal upBlood { get; set; }//最大血量 - public decimal morale { get; set; }//士气 - public decimal upMorale { get; set; }//最大士气 + public int minAtk { get; set; }//最小攻击 + public int maxAtk { get; set; }//最大攻击 + public int defense { get; set; }//防御 + public int agility { get; set; }//敏捷 + public int blood { get; set; }//血量 + public int upBlood { get; set; }//最大血量 + public int morale { get; set; }//士气 + public int upMorale { get; set; }//最大士气 public decimal score { get; set; }//评分 public decimal InBlood { get; set; }//吸血 public decimal Crit { get; set; }//暴击 diff --git a/Service/Application.Domain.Entity/resource/game/game_equ_suit.cs b/Service/Application.Domain.Entity/resource/game/game_equ_suit.cs new file mode 100644 index 0000000..8858da8 --- /dev/null +++ b/Service/Application.Domain.Entity/resource/game/game_equ_suit.cs @@ -0,0 +1,45 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Resource")] + public class game_equ_suit + { + /// + /// 套装编码 + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string suitCode { get; set; } + + /// + /// 套装名称 + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? suitName { get; set; } + + /// + /// 套装介绍 + /// + [SugarColumn(Length = 500, IsNullable = true)] + public string? sign { get; set; } + + /// + /// 属性 + /// + [SugarColumn(IsNullable = true,IsJson = true)] + public List? attr { get; set; } + + /// + /// 套装组成装备 + /// + [SugarColumn(IsNullable = true,IsJson = true)] + public List onEqu { get; set; } + + /// + /// 套装特权 + /// + [SugarColumn(IsNullable = true)] + public string? role { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain/Enum/GameEnum.cs b/Service/Application.Domain/Enum/GameEnum.cs index c171c69..c11bcbf 100644 --- a/Service/Application.Domain/Enum/GameEnum.cs +++ b/Service/Application.Domain/Enum/GameEnum.cs @@ -44,4 +44,11 @@ public static class GameEnum 减少, 增加 } + + public enum NpcBusCode + { + RetBlood, + RetMorale, + RetVigour, + } } \ No newline at end of file diff --git a/Service/Application.Domain/Enum/UserEnum.cs b/Service/Application.Domain/Enum/UserEnum.cs index 8bc9c51..cedb51a 100644 --- a/Service/Application.Domain/Enum/UserEnum.cs +++ b/Service/Application.Domain/Enum/UserEnum.cs @@ -14,5 +14,6 @@ public static class UserEnum AutoBag, AutoDrug, GiveRole, + MsgRole, } } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs index 9bdbf52..7c93181 100644 --- a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs +++ b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs @@ -5,7 +5,7 @@ public interface IGameEquService #region 装备资源 Task GetEquInfo(int equId); - + Task GetEuqSuitInfo(string suitCode); #endregion #region 用户装备 @@ -29,4 +29,10 @@ public interface IGameEquService #endregion + #region 辅助 + + Task GetUserEquWeightSum(string userId); + + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs b/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs index 3684165..0fb307e 100644 --- a/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs +++ b/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs @@ -20,5 +20,12 @@ public interface IGameGoodsService Task UpdateUserGoods(string userId, int op, int goodsId, int count, string remark = ""); + #endregion + + #region 辅助 + + Task GetUserGoodWeightSum(string userId, int type); + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs index 3469aa3..d509cdf 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs @@ -27,13 +27,14 @@ public interface IUnitUserAttrService Task GetUserMorale(string userId); Task UpdateUserMorale(string userId, int op, int count); - + Task CheackRecoverMorale(string userId); + Task LockRecoverMorale(string userId); #endregion #region 活力 Task GetUserVigourInfo(string userId); - Task UpdateUserVigour(string userId, int op, decimal count, string UpTime = ""); + Task UpdateUserVigour(string userId, int op, long count, string UpTime = ""); Task UpdateUserUpVigour(string userId, decimal count); #endregion diff --git a/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs b/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs index fe277bd..ae01546 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs @@ -3,10 +3,14 @@ public interface IUnitUserWeight { Task GetUserWeightInfo(string userId); + Task UpdateUserWeight(unit_user_weight data); Task UpdateUserWeight(string userId, int op, int weight); - Task UpdateUserMaxWeight(string userId, int op, int weight); - Task AddUserWeightLog(string userId, int goodsId, string goodsName, int weight, int count); - Task CheakUserWeight(string userId, int useWeight); + + Task UpdateUserMaxWeight(string userId, int op, int weight, int count = 1, int goodsId = 0, + string goodsName = ""); + + Task> GetUserWeightLog(string userId); + Task CheckUserWeight(string userId, int useWeight); #region 船只相关 diff --git a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs index 05f04b7..5ed7550 100644 --- a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs +++ b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs @@ -17,6 +17,18 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return data; } + public async Task GetEuqSuitInfo(string suitCode) + { + string key = string.Format(BaseCache.BaseCacheKeys, "EquData", "SuitInfo"); + var data = await redis.GetHashAsync(key, suitCode); + if (data == null) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(it => it.suitCode == suitCode).SingleAsync(); + await redis.AddHashAsync(key, suitCode, data); + } + return data; + } #endregion @@ -292,5 +304,16 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame await db.Insertable(logs).SplitTable().ExecuteCommandAsync(); } + #endregion + + #region 辅助方法 + public async Task GetUserEquWeightSum(string userId) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.userId == userId).ToListAsync(); + return data.Sum(it => (int)it.weight); + } + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs b/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs index a67d739..b7e6d00 100644 --- a/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs +++ b/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs @@ -55,7 +55,8 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa return info == null ? 0 : (int)info.count; } - public async Task> GetUserGoodsData(string userId, List code, List noCode, string search, int page, + public async Task> GetUserGoodsData(string userId, List code, List noCode, + string search, int page, int limit, RefAsync total) { var db = DbClient.AsTenant().GetConnectionWithAttr(); @@ -125,13 +126,13 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa if (weightCount > 0) { var weightService = App.GetService(); - if (UserGoods.code == nameof(GoodsEnum.Code.Cargo))//跑商物品处理 + if (UserGoods.code == nameof(GoodsEnum.Code.Cargo)) //跑商物品处理 { await weightService.UpdateUserShipOnWeight(userId, op, weightCount); } else { - await weightService.UpdateUserWeight(userId, op, weightCount); + await weightService.UpdateUserWeight(userId, op, weightCount); } } @@ -164,5 +165,16 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa return $"{userId}_{goodsId}"; } + public async Task GetUserGoodWeightSum(string userId, int type) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + string code = nameof(GoodsEnum.Code.Cargo); + var data = await db.Queryable().Where(it => it.userId == userId) + .WhereIF(type == 0, it => it.code != code) + .WhereIF(type == 1, it => it.code == code) + .ToListAsync(); + return data.Sum(it => (int)it.count * (int)it.weight); + } + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs index 2a753a7..ecd01a1 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs @@ -18,14 +18,16 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : result.code = nameof(UserEnum.AttrCode.Person); var unitAttr = await GetUserAttr(userId); result.lev = (int)unitAttr.lev; - result.minAtk = (decimal)unitAttr.minAtk; - result.maxAtk = (decimal)unitAttr.maxAtk; - result.defense = (decimal)unitAttr.defense; - result.agility = (decimal)unitAttr.agility; - result.upBlood = (decimal)unitAttr.upBlood; - result.upMorale = (decimal)unitAttr.upMorale; - result.blood = 1; - result.morale = 1; + result.minAtk = (int)unitAttr.minAtk; + result.maxAtk = (int)unitAttr.maxAtk; + result.defense = (int)unitAttr.defense; + result.agility = (int)unitAttr.agility; + result.upBlood = (int)unitAttr.upBlood; + result.upMorale = (int)unitAttr.upMorale; + var bloodInfo = await GetUserBlood(userId); + result.blood = (int)bloodInfo.blood; + var moraleInfo = await GetUserMorale(userId); + result.morale = (int)moraleInfo.morale; return result; } @@ -172,6 +174,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : .ExecuteCommandAsync() > 0; int upVigour = GameConfig.GameBaseVigour + (OnLev * 10); await UpdateUserUpVigour(userId, upVigour); + IsUpUserAttr = result; } } @@ -199,7 +202,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : { //增加负重 var wightService = App.GetService(); - await wightService.UpdateUserMaxWeight(userId, 1, GameConfig.UpLevAddWeight); + await wightService.UpdateUserMaxWeight(userId, 1, GameConfig.UpLevAddWeight, 1, 0, "升级增加负重"); await ClearUserAttrCache(userId); } @@ -252,6 +255,17 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : return result; } + public async Task CheackRecoverMorale(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "Recover:Morale", userId); + return await redis.ExistsAsync(key); + } + public async Task LockRecoverMorale(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "Recover:Morale", userId); + await redis.SetAsync(key, DateTime.Now,TimeAssist.GetDateTimeYMD(1)); + } + #endregion 士气 #region 活力 @@ -279,7 +293,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : await redis.DelHashAsync(key, userId); } - public async Task UpdateUserVigour(string userId, int op, decimal count, string UpTime = "") + public async Task UpdateUserVigour(string userId, int op, long count, string UpTime = "") { bool result = false; try diff --git a/Service/Application.Domain/Services/Service/User/UnitUserService.cs b/Service/Application.Domain/Services/Service/User/UnitUserService.cs index 4094445..4d70dd7 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserService.cs @@ -207,6 +207,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni config.autoBag = -1; config.autoDrug = -1; config.giveRole = 0; + config.msgRole = 1; db.Insertable(config).AddQueue(); //注册个人血量 @@ -231,14 +232,14 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni unit_user_weight weight = new unit_user_weight(); weight.userId = userId; weight.onWeight = 0; - weight.maxWeight = 100; + weight.maxWeight = 0; db.Insertable(weight).AddQueue(); //注册活力 unit_user_vigour vitality = new unit_user_vigour(); vitality.userId = userId; vitality.vitality = GameConfig.GameBaseVigour; vitality.upVitality = GameConfig.GameBaseVigour; - vitality.upTime = TimeAssist.GetDateTimeYMDString(0); + vitality.upTime = TimeAssist.GetDateTimeYMDString(-1); db.Insertable(vitality).AddQueue(); //注册在线 @@ -252,6 +253,13 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni await db.SaveQueuesAsync(false); } + if (result)//注册各项后处理 + { + //赠送初始负重 + var weightService = App.GetService(); + await weightService.UpdateUserMaxWeight(userId, 1, 100, 1, 0, "初始负重"); + } + return result; } @@ -337,6 +345,9 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni case "AutoDrug": result = (int)config.autoDrug; break; + case "MsgRole": + result = (int)config.msgRole; + break; } return result; @@ -357,6 +368,7 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni .SetColumnsIF(code == "AutoBag", it => it.autoBag == state) .SetColumnsIF(code == "AutoDrug", it => it.autoDrug == state) .SetColumnsIF(code == "GiveRole", it => it.giveRole == state) + .SetColumnsIF(code == "MsgRole", it => it.msgRole == state) .Where(it => it.userId == userId).ExecuteCommandAsync() > 0; if (result) { diff --git a/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs b/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs index cfde171..48b59b2 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs @@ -30,6 +30,18 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit await redis.DelHashAsync(key, userId); } + public async Task UpdateUserWeight(unit_user_weight data) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + bool result = await db.Updateable(data).ExecuteCommandAsync() > 0; + if (result) + { + await ClearUserWeightInfo(data.userId); + } + + return result; + } + public async Task UpdateUserWeight(string userId, int op, int weight) { var db = DbClient.AsTenant().GetConnectionWithAttr(); @@ -46,22 +58,33 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit return result; } - public async Task UpdateUserMaxWeight(string userId, int op, int weight) + public async Task UpdateUserMaxWeight(string userId, int op, int weight, int count = 1, int goodsId = 0, + string goodsName = "") { + int sumWeight = weight * count; var db = DbClient.AsTenant().GetConnectionWithAttr(); bool result = await db.Updateable() - .SetColumnsIF(op == 0, it => it.maxWeight == it.maxWeight - weight) - .SetColumnsIF(op == 1, it => it.maxWeight == it.maxWeight + weight) + .SetColumnsIF(op == 0, it => it.maxWeight == it.maxWeight - sumWeight) + .SetColumnsIF(op == 1, it => it.maxWeight == it.maxWeight + sumWeight) .Where(it => it.userId == userId).ExecuteCommandAsync() > 0; if (result) { + if (op == 1) + { + await AddUserWeightLog(userId, goodsId, goodsName, weight, count); + } + else + { + await AddUserWeightLog(userId, goodsId, goodsName, (0 - weight), count); + } + await ClearUserWeightInfo(userId); } return result; } - public async Task AddUserWeightLog(string userId, int goodsId, string goodsName, int weight, int count) + private async Task AddUserWeightLog(string userId, int goodsId, string goodsName, int weight, int count) { var db = DbClient.AsTenant().GetConnectionWithAttr(); unit_user_weight_log log = new unit_user_weight_log(); @@ -76,7 +99,14 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit return await db.Insertable(log).ExecuteCommandAsync() > 0; } - public async Task CheakUserWeight(string userId, int useWeight) + public async Task> GetUserWeightLog(string userId) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(it => it.userId == userId) + .ToListAsync(); + } + + public async Task CheckUserWeight(string userId, int useWeight) { bool result = false; var weightInfo = await GetUserWeightInfo(userId); @@ -103,11 +133,13 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit return data; } + public async Task GetUserShipMaxWeight(string userId) { var data = await GetUserShip(userId); return data.Sum(it => (int)it.weight); } + private async Task ClearUserShipData(string userId) { string key = string.Format(UserCache.BaseCacheKeys, "WeightData", "Ship"); @@ -142,7 +174,7 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit return result; } - public async Task DeleteUserShip(string usId,string userId) + public async Task DeleteUserShip(string usId, string userId) { var db = DbClient.AsTenant().GetConnectionWithAttr(); bool result = await db.Deleteable().Where(it => it.usId == usId).ExecuteCommandAsync() > 0; @@ -154,7 +186,7 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit return result; } - public async Task AddUserShip(string userId,string name,int goodsId,int speed,int weight) + public async Task AddUserShip(string userId, string name, int goodsId, int speed, int weight) { unit_user_ship ship = new unit_user_ship(); ship.usId = StringAssist.NewGuid; diff --git a/Service/Application.Web/Controllers/Chat/ChatController.cs b/Service/Application.Web/Controllers/Chat/ChatController.cs index cbf80e6..c13ff71 100644 --- a/Service/Application.Web/Controllers/Chat/ChatController.cs +++ b/Service/Application.Web/Controllers/Chat/ChatController.cs @@ -214,4 +214,72 @@ public class ChatController : ControllerBase return PoAction.Message("操作失败,请稍后尝试!"); } } + + /// + /// 封禁ID + /// + /// + /// + [HttpGet] + public async Task BlackUser(string chatId) + { + var chatInfo = await _chatService.GetChatInfo(chatId); + if (chatInfo == null) + { + return PoAction.Message("发言不存在!"); + } + + if (chatInfo.state != 1) + { + return PoAction.Message("发言不存在!"); + } + + if (chatInfo.areaId != StateHelper.areaId) + { + return PoAction.Message("发言不存在!"); + } + + if (chatInfo.userId == StateHelper.userId) + { + return PoAction.Message("不能封禁自己!"); + } + + bool IsOp = false; + string userId = StateHelper.userId; + int chatRole = await _userService.GetUserConfigInfo(userId, nameof(UserEnum.ConfigCode.ChatRole)); + if ((chatInfo.code == nameof(GameChatEnum.Code.Public) || chatInfo.code == nameof(GameChatEnum.Code.Region)) && + chatRole > 0) + { + IsOp = true; + } + else if (chatRole > 1 && chatInfo.code == nameof(GameChatEnum.Code.Dress)) + { + IsOp = true; + } + + if (IsOp == false) + { + return PoAction.Message("无权限!"); + } + + var otConfig = await _userService.GetUserConfigInfo(chatInfo.userId); + if (otConfig.chatRole < 0) + { + return PoAction.Message("Ta已被禁言,无需封禁!"); + } + + if (otConfig.chatRole != 0) + { + return PoAction.Message("您无权封禁!"); + } + + if (await _userService.UpdateUserConfigInfo(chatInfo.userId, nameof(UserEnum.ConfigCode.ChatRole), -1)) + { + return PoAction.Ok(true); + } + else + { + return PoAction.Message("操作失败,请稍后尝试!"); + } + } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Map/StoreController.cs b/Service/Application.Web/Controllers/Map/StoreController.cs index 88879dd..b9ddabe 100644 --- a/Service/Application.Web/Controllers/Map/StoreController.cs +++ b/Service/Application.Web/Controllers/Map/StoreController.cs @@ -110,7 +110,7 @@ public class StoreController : ControllerBase //此处需要计算负重 var needWeight = await GameTool.GetPropWeight(storeInfo.type, storeInfo.parameter); needWeight = needWeight * parms.count; - if (await _weightService.CheakUserWeight(userId, needWeight) == false) + if (await _weightService.CheckUserWeight(userId, needWeight) == false) { return PoAction.Message("负重不足!"); } diff --git a/Service/Application.Web/Controllers/Pub/EquController.cs b/Service/Application.Web/Controllers/Pub/EquController.cs new file mode 100644 index 0000000..b9ef3fd --- /dev/null +++ b/Service/Application.Web/Controllers/Pub/EquController.cs @@ -0,0 +1,71 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Application.Web.Controllers.Pub; + +/// +/// 装备接口 +/// +[Route("[controller]/[action]")] +[ApiController] +[Authorize] +public class EquController : ControllerBase +{ + private readonly IGameEquService _equService; + + public EquController(IGameEquService equService) + { + _equService = equService; + } + + /// + /// 获取装备信息 + /// + /// + /// + /// + [HttpGet] + public async Task GetEquInfo(int? equId, string? ueId) + { + game_equ equInfo = new game_equ(); + game_equ_suit suit = new game_equ_suit(); + unit_user_equ ueInfo = new unit_user_equ(); + UserModel user = new UserModel(); + if (equId != 0) + { + equInfo = await _equService.GetEquInfo((int)equId); + if (equInfo == null) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.suitCode != "0" && !string.IsNullOrEmpty(equInfo.suitCode)) + { + suit = await _equService.GetEuqSuitInfo(equInfo.suitCode); + } + } + else + { + ueInfo = await _equService.GetUserEquInfo(ueId); + if (ueInfo == null) + { + return PoAction.Message("装备不存在!"); + } + + equInfo = await _equService.GetEquInfo((int)ueInfo.equId); + if (equInfo == null) + { + return PoAction.Message("装备不存在!"); + } + + if (equInfo.suitCode != "0" && !string.IsNullOrEmpty(equInfo.suitCode)) + { + suit = await _equService.GetEuqSuitInfo(equInfo.suitCode); + } + + user = await UserModelTool.GetUserView(ueInfo.owerId); + } + + return PoAction.Ok(new { equ = equInfo, suit, equData = ueInfo,user }); + } + +} \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Pub/GoodsController.cs b/Service/Application.Web/Controllers/Pub/GoodsController.cs new file mode 100644 index 0000000..5b0a2ab --- /dev/null +++ b/Service/Application.Web/Controllers/Pub/GoodsController.cs @@ -0,0 +1,39 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Application.Web.Controllers.Pub; + +/// +/// 物品接口 +/// +[Route("[controller]/[action]")] +[ApiController] +[Authorize] +public class GoodsController : ControllerBase +{ + private readonly IGameGoodsService _goodsService; + + public GoodsController(IGameGoodsService goodsService) + { + _goodsService = goodsService; + } + + /// + /// 获取物品信息 + /// + /// 物品ID + /// + [HttpGet] + public async Task GetGoodsInfo(int goodsId) + { + var goodsInfo = await _goodsService.GetGoodsInfo(goodsId); + if (goodsInfo == null) + { + return PoAction.Message("物品不存在!"); + } + + string userId = StateHelper.userId; + int count = await _goodsService.GetUserGoodsCount(userId, goodsId); + + return PoAction.Ok(new { goods = goodsInfo, count }); + } +} \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Pub/MessageController.cs b/Service/Application.Web/Controllers/Pub/MessageController.cs index 06c420a..7480ae4 100644 --- a/Service/Application.Web/Controllers/Pub/MessageController.cs +++ b/Service/Application.Web/Controllers/Pub/MessageController.cs @@ -115,6 +115,12 @@ public class MessageController : ControllerBase string userId = StateHelper.userId; int areaId = StateHelper.areaId; + var msgRole = await _userService.GetUserConfigInfo(userId, nameof(UserEnum.ConfigCode.MsgRole)); + if (msgRole != 1) + { + return PoAction.Message("消息权限已被封禁!"); + } + var toUser = await _userService.GetUserInfoByUserNo(parms.no.ToString()); if (toUser == null) { diff --git a/Service/Application.Web/Controllers/Pub/RecoverController.cs b/Service/Application.Web/Controllers/Pub/RecoverController.cs new file mode 100644 index 0000000..66bf461 --- /dev/null +++ b/Service/Application.Web/Controllers/Pub/RecoverController.cs @@ -0,0 +1,203 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Application.Web.Controllers.Pub; + +/// +/// 恢复接口 +/// +[Route("[controller]/[action]")] +[ApiController] +[Authorize] +public class RecoverController : ControllerBase +{ + private readonly IUnitUserAttrService _attrService; + private readonly IGameMapService _mapService; + + public RecoverController(IUnitUserAttrService attrService, IGameMapService mapService) + { + _attrService = attrService; + _mapService = mapService; + } + + /// + /// 恢复体力 + /// + /// + /// + [HttpGet] + public async Task RecoverBlood(int npcId) + { + string userId = StateHelper.userId; + + #region NPC验证 + + var npcInfo = await _mapService.GetNpcInfo(npcId); + if (npcInfo == null) + { + return PoAction.Message("Npc不存在!"); + } + + if (npcInfo.status != 1) + { + return PoAction.Message("Npc不存在!"); + } + + if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.RetBlood))) + { + return PoAction.Message("业务不可用!"); + } + + var onMap = await _mapService.GetUserOnMapId(userId); + if (npcInfo.mapId != onMap) + { + return PoAction.Message("Npc不存在!"); + } + + #endregion + + var userAttr = await _attrService.GetUserAttrModel(userId); + if (userAttr.blood >= userAttr.upBlood) + { + return PoAction.Message("体力满满,无需恢复!"); + } + + bool result = await _attrService.UpdateUserBlood(userId, 2, userAttr.upBlood, true); + if (result) + { + return PoAction.Ok(true); + } + else + { + return PoAction.Message("恢复失败,请稍后尝试!"); + } + } + + /// + /// 恢复士气 + /// + /// + /// + [HttpGet] + public async Task RecoverMorale(int npcId) + { + string userId = StateHelper.userId; + + #region NPC验证 + + var npcInfo = await _mapService.GetNpcInfo(npcId); + if (npcInfo == null) + { + return PoAction.Message("Npc不存在!"); + } + + if (npcInfo.status != 1) + { + return PoAction.Message("Npc不存在!"); + } + + if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.RetMorale))) + { + return PoAction.Message("业务不可用!"); + } + + var onMap = await _mapService.GetUserOnMapId(userId); + if (npcInfo.mapId != onMap) + { + return PoAction.Message("Npc不存在!"); + } + + #endregion + + if (await _attrService.CheackRecoverMorale(userId)) + { + return PoAction.Message("今天已恢复过士气啦!"); + } + + var userAttr = await _attrService.GetUserAttrModel(userId); + if (userAttr.morale >= userAttr.upMorale) + { + return PoAction.Message("士气满满,无需恢复!"); + } + + bool result = await _attrService.UpdateUserMorale(userId, 2, userAttr.upMorale); + if (result) + { + await _attrService.LockRecoverMorale(userId); + return PoAction.Ok(true); + } + else + { + return PoAction.Message("恢复失败,请稍后尝试!"); + } + } + + /// + /// 获取个人活力 + /// + /// + [HttpGet] + public async Task GetUserVigour() + { + string userId = StateHelper.userId; + var data = await _attrService.GetUserVigourInfo(userId); + return PoAction.Ok(data); + } + + /// + /// 恢复活力 + /// + /// + /// + [HttpGet] + public async Task RecoverVigour(int npcId) + { + string userId = StateHelper.userId; + + #region NPC验证 + + var npcInfo = await _mapService.GetNpcInfo(npcId); + if (npcInfo == null) + { + return PoAction.Message("Npc不存在!"); + } + + if (npcInfo.status != 1) + { + return PoAction.Message("Npc不存在!"); + } + + if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.RetVigour))) + { + return PoAction.Message("业务不可用!"); + } + + var onMap = await _mapService.GetUserOnMapId(userId); + if (npcInfo.mapId != onMap) + { + return PoAction.Message("Npc不存在!"); + } + + #endregion + + var data = await _attrService.GetUserVigourInfo(userId); + string time = TimeAssist.GetDateTimeYMDString(0); + if (data.upTime == time) + { + return PoAction.Message("今天已恢复过活力啦!"); + } + if (data.vitality >= data.upVitality) + { + return PoAction.Message("活力满满,无需恢复!"); + } + + bool result = await _attrService.UpdateUserVigour(userId, 2, (long)data.upVitality,time); + if (result) + { + return PoAction.Ok(true); + } + else + { + return PoAction.Message("恢复失败,请稍后尝试!"); + } + } +} \ No newline at end of file diff --git a/Service/Application.Web/Controllers/User/SettingController.cs b/Service/Application.Web/Controllers/User/SettingController.cs index 92e9a7a..55408d7 100644 --- a/Service/Application.Web/Controllers/User/SettingController.cs +++ b/Service/Application.Web/Controllers/User/SettingController.cs @@ -13,11 +13,15 @@ public class SettingController : ControllerBase { private readonly IUnitUserService _userService; private readonly IGameGoodsService _goodsService; + private readonly IGameEquService _equService; + private readonly IUnitUserWeight _weightService; - public SettingController(IUnitUserService userService,IGameGoodsService goodsService) + public SettingController(IUnitUserService userService,IGameGoodsService goodsService,IGameEquService equService,IUnitUserWeight weightService) { _userService = userService; _goodsService = goodsService; + _equService = equService; + _weightService = weightService; } /// @@ -190,4 +194,45 @@ public class SettingController : ControllerBase return PoAction.Message("暂无法设置!"); } } + + /// + /// 刷新/重置设置 + /// + /// + /// + [HttpGet] + public async Task RefreshSetting(int type) + { + string userId = StateHelper.userId; + if (type == 0)//刷新负重 + { + var equWeight = await _equService.GetUserEquWeightSum(userId); + var goodsWeight = await _goodsService.GetUserGoodWeightSum(userId,0); + int onWeight = equWeight + goodsWeight;//当前总占用负重 + var weightLog = await _weightService.GetUserWeightLog(userId); + int maxWeight = weightLog.Sum(it => (int)it.sum); + var weightInfo = await _weightService.GetUserWeightInfo(userId); + weightInfo.onWeight = onWeight; + weightInfo.maxWeight = maxWeight; + + var shipWeight = await _goodsService.GetUserGoodWeightSum(userId,1); + weightInfo.shipOnWeight = shipWeight; + if (await _weightService.UpdateUserWeight(weightInfo)) + { + return PoAction.Ok(true,"负重数据已刷新成功!"); + } + else + { + return PoAction.Message("负重刷新失败,请稍后尝试!"); + } + } + else if (type == 1)//刷新图标 + { + return PoAction.Ok(true, "图标刷新成功!"); + } + else + { + return PoAction.Message("无效的操作!"); + } + } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/User/UserController.cs b/Service/Application.Web/Controllers/User/UserController.cs index 7af45e7..aaff95c 100644 --- a/Service/Application.Web/Controllers/User/UserController.cs +++ b/Service/Application.Web/Controllers/User/UserController.cs @@ -84,6 +84,40 @@ public class UserController : ControllerBase var model = await UserModelTool.GetUserView(userId); return PoAction.Ok(model); } + + /// + /// 获取基础属性信息 + /// + /// + /// + [HttpGet] + public async Task GetUserBaseAttrInfo(string? no) + { + string userId = StateHelper.userId; + if (!string.IsNullOrEmpty(no)) + { + var userInfo = await _userService.GetUserInfoByUserNo(no); //基础资料 + if (userInfo == null) + { + return PoAction.Message("玩家不存在!", 102); + } + + if (userInfo.userId == userId) + { + return PoAction.Message("用户本身!", 101); + } + + if (userInfo.areaId != StateHelper.areaId) + { + return PoAction.Message("玩家不存在!", 102); + } + + userId = userInfo.userId; + } + + var model = await _attrService.GetUserAttrModel(userId); + return PoAction.Ok(model); + } /// /// 获取用户资料 diff --git a/Web/src/components/Business/GameChat.vue b/Web/src/components/Business/GameChat.vue index 7cb7319..0d33c64 100644 --- a/Web/src/components/Business/GameChat.vue +++ b/Web/src/components/Business/GameChat.vue @@ -16,7 +16,7 @@ - [删除] + [删除.封禁] @@ -68,10 +68,13 @@ const CheckRole = (type: string): boolean => { } // 1. 声明要触发的事件 -const emit = defineEmits(['delChat']) +const emit = defineEmits(['delChat','blackChat']) const DelChat = async (chatId: string) => { emit('delChat', { chatId: chatId }); } +const BlackChat = async (chatId: string) => { + emit('blackChat', { chatId: chatId }); +} \ No newline at end of file diff --git a/Web/src/components/Page/MapMenu.vue b/Web/src/components/Page/MapMenu.vue index 3cc6736..aebb50f 100644 --- a/Web/src/components/Page/MapMenu.vue +++ b/Web/src/components/Page/MapMenu.vue @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/Web/src/pages/user/user.vue b/Web/src/pages/user/user.vue index 30c7fd0..0386b00 100644 --- a/Web/src/pages/user/user.vue +++ b/Web/src/pages/user/user.vue @@ -1,6 +1,6 @@