From c80841880cb1026cf1cd1c588d1b85519308b674 Mon Sep 17 00:00:00 2001 From: Putoo <290555931@qq.com> Date: Thu, 16 Jul 2026 23:24:17 +0800 Subject: [PATCH] 12121 --- .../Application.Domain/Config/GameConfig.cs | 2 +- .../Interface/User/IUnitUserAttrService.cs | 2 +- .../Service/Fight/GameFightService.cs | 20 ++++- .../Service/User/UnitUserAttrService.cs | 86 ++++++++++++++++++- .../Controllers/Map/MapController.cs | 13 ++- .../Controllers/User/RelationController.cs | 30 ++++++- Web/src/pages/user/user.vue | 2 +- 7 files changed, 143 insertions(+), 12 deletions(-) diff --git a/Service/Application.Domain/Config/GameConfig.cs b/Service/Application.Domain/Config/GameConfig.cs index 505b75c..6e39b73 100644 --- a/Service/Application.Domain/Config/GameConfig.cs +++ b/Service/Application.Domain/Config/GameConfig.cs @@ -9,7 +9,7 @@ public static class GameConfig public const int SendChatGoodsService = 10002;//金海螺 public const int UpLevAddWeight = 10;//升级增加负重 public const int GameBaseVigour = 50;//初始活力 - public const int GameRelationEnemyNeedGold = 300;//添加仇人所需金元 + public const int GameRelationEnemyNeedGold = 100;//添加仇人所需金元 public const int GameUpdateNickNeedGoods = 10018;//更新昵称所需道具 public const int GameUpdateSexNeedGoods = 10065;//更新性别所需道具 public const int GameUserFriendMaxCount = 50;//好友最大上限人数 diff --git a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs index 80a82e0..d03ff9d 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs @@ -21,7 +21,7 @@ public interface IUnitUserAttrService Task GetUserExp(string userId); Task UpdateUserExp(string userId, long exp, int op = 1); - + Task DeductUserExp(string userId, int type, long count); #endregion #region 士气操作 diff --git a/Service/Application.Domain/Services/Service/Fight/GameFightService.cs b/Service/Application.Domain/Services/Service/Fight/GameFightService.cs index a5aeb80..1d4567c 100644 --- a/Service/Application.Domain/Services/Service/Fight/GameFightService.cs +++ b/Service/Application.Domain/Services/Service/Fight/GameFightService.cs @@ -428,13 +428,27 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa string noticeMsg = $"您在{cityInfo.cityName}·{mapInfo.mapName}被[{UbbTool.HomeUbb(winUserInfo.userNo, winUserInfo.nick)}]击杀!"; await chatService.SendChat(lowUser, (int)lowUserInfo.areaId, nameof(GameChatEnum.Code.Notice), noticeMsg); - if (mapInfo.isPk == 1 && fightData.userId == winUser && fightData.scene == nameof(MapEnum.MapCode.DEF_MAP)) + + if (fightData.userId == winUser && fightData.scene == nameof(MapEnum.MapCode.DEF_MAP)) { var relationService = App.GetService(); if (await relationService.CheckUserEnemy(winUser, lowUser) == false) { - var accService = App.GetService(); - await accService.UpdateUserData(winUser, 1, nameof(AccEnum.AccType.enemy), 5, "击杀玩家"); //加罪恶 + if (mapInfo.isPk == 1) + { + var accService = App.GetService(); + await accService.UpdateUserData(winUser, 1, nameof(AccEnum.AccType.enemy), 5, + "击杀玩家"); //加罪恶 + } + } + else + { + //执行扣除经验 + var attrService = App.GetService(); + await attrService.DeductUserExp(lowUser, 1, 1); //扣除1级 + //设置回威尼斯 + await mapService.UpdateUserOnMap(lowUser, "15_27"); + } } diff --git a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs index ee39098..9b561f2 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs @@ -83,15 +83,16 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : #endregion - #region 称号加层 + #region 称号加层 + var maxNameService = App.GetService(); var userMaxName = await maxNameService.GetUserMaxNameData(userId); foreach (var maxName in userMaxName) { ExtendAttrData.AddRange(maxName.attr); } + #endregion - #region Buff加层 @@ -294,6 +295,11 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : result = await db.Updateable().SetColumns(it => it.exp == it.exp - exp) .Where(it => it.userId == userId).ExecuteCommandAsync() > 0; } + else if (op == 2) //固定经验 + { + result = await db.Updateable().SetColumns(it => it.exp == exp) + .Where(it => it.userId == userId).ExecuteCommandAsync() > 0; + } else //增加经验 { var MyExp = await db.Queryable().Where(it => it.userId == userId).SingleAsync(); @@ -354,6 +360,82 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : return result; } + public async Task DeductUserExp(string userId, int type, long count) + { + bool result = false; + var userAttr = await GetUserAttr(userId); + int OnLev = (int)userAttr.lev; + if (OnLev <= 30) + { + return; + } + + var userExp = await GetUserExp(userId); + var db = DbClient.AsTenant().GetConnectionWithAttr(); + if (type == 0) //扣除经验 + { + long sumExp = (long)userExp.exp; + while (count > 0 && OnLev > 30) + { + if (sumExp >= count) + { + count = 0; + sumExp = sumExp - count; + } + else + { + OnLev -= 1; + sumExp += GameTool.GetUserUpExp(OnLev); + } + } + + if (OnLev == 30) + { + sumExp = 0; + } + var data = GameTool.GetAttrData(OnLev); + result = await db.Updateable(data).Where(i => i.userId == userId) + .ExecuteCommandAsync() > 0; + if (result) + { + await UpdateUserExp(userId, sumExp, 2); + await ClearUserAttrCache(userId); + } + + } + else if(type==1) //扣除等级 + { + OnLev -= Convert.ToInt32(count); + var data = GameTool.GetAttrData(OnLev); + result = await db.Updateable(data).Where(i => i.userId == userId) + .ExecuteCommandAsync() > 0; + if (result) + { + if (userExp.exp > 0) + { + await UpdateUserExp(userId, 0, 2); + } + + await ClearUserAttrCache(userId); + } + } + + if (result) + { + //下装备 + var equService = App.GetService(); + var onEqu = await equService.GetUserOnEqu(userId); + onEqu = onEqu.FindAll(it => it.lev > OnLev); + if (onEqu.Count > 0) + { + foreach (var item in onEqu) + { + await equService.EquOnOrDown(item, 0); + } + } + } + } + #endregion 经验操作 #region 士气 diff --git a/Service/Application.Web/Controllers/Map/MapController.cs b/Service/Application.Web/Controllers/Map/MapController.cs index 5a4ae15..595a916 100644 --- a/Service/Application.Web/Controllers/Map/MapController.cs +++ b/Service/Application.Web/Controllers/Map/MapController.cs @@ -362,6 +362,12 @@ public class MapController : ControllerBase return PoAction.Message("城市不存在!"); } + int lev = await _attrService.GetUserLev(userId); + if (lev < 31) + { + return PoAction.Message("等级达到31级才可以传送哦!"); + } + var userWeight = await _weightService.GetUserWeightInfo(userId); if (userWeight.shipOnWeight > 0) { @@ -464,7 +470,12 @@ public class MapController : ControllerBase { return PoAction.Message("城市不存在!"); } - + + int lev = await _attrService.GetUserLev(userId); + if (lev < 31) + { + return PoAction.Message("等级达到31级才可以出海哦!"); + } var onMapInfo = await _mapService.GetMapInfo(onMap.mapId); if (onMapInfo.cityId == cityId) diff --git a/Service/Application.Web/Controllers/User/RelationController.cs b/Service/Application.Web/Controllers/User/RelationController.cs index 5146947..42afc66 100644 --- a/Service/Application.Web/Controllers/User/RelationController.cs +++ b/Service/Application.Web/Controllers/User/RelationController.cs @@ -15,14 +15,18 @@ public class RelationController : ControllerBase private readonly IUnitUserService _userService; private readonly IMessageService _messageService; private readonly IUnitUserAccService _accService; + private readonly IUnitUserAttrService _attrService; + private readonly IGameChatService _chatService; public RelationController(IUnitUserRelationService relationService, IUnitUserService userService, - IMessageService messageService, IUnitUserAccService accService) + IMessageService messageService, IUnitUserAccService accService,IUnitUserAttrService attrService,IGameChatService chatService) { _relationService = relationService; _userService = userService; _messageService = messageService; _accService = accService; + _attrService = attrService; + _chatService = chatService; } /// @@ -218,17 +222,37 @@ public class RelationController : ControllerBase return PoAction.Message("已经是仇人啦,无需重复添加!"); } + int needGold = GameConfig.GameRelationEnemyNeedGold; + int lev = await _attrService.GetUserLev(userInfo.userId); + if (lev <= 30) + { + return PoAction.Message("对方不大于30级无法添加加为仇人!"); + } + + if (lev > 120 && lev <= 220) + { + needGold = needGold * 3; + } + else if (lev > 220) + { + needGold = needGold * 5; + } + var myAcc = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.gold)); - if (myAcc < GameConfig.GameRelationEnemyNeedGold) + if (myAcc < needGold) { return PoAction.Message("您的金元不足!"); } if (await _accService.UpdateUserAcc(userId, 0, nameof(AccEnum.AccType.gold), - GameConfig.GameRelationEnemyNeedGold, nameof(AccEnum.Name.其他), "添加仇人")) + needGold, nameof(AccEnum.Name.其他), "添加仇人")) { if (await _relationService.AddUserEnemy(userId, userInfo.userId)) { + var myInfo = await _userService.GetUserInfoByUserId(userId); + string msg = $"请注意,您已被[{UbbTool.HomeUbb(myInfo.userNo, myInfo.nick)}]添加为仇人,被对方击杀将会受到严重惩罚!"; + await _chatService.SendChat(userInfo.userId, (int)userInfo.areaId, nameof(GameChatEnum.Code.Notice), msg); + return PoAction.Ok(true, "仇人添加成功!"); } else diff --git a/Web/src/pages/user/user.vue b/Web/src/pages/user/user.vue index aa583b8..9eddcec 100644 --- a/Web/src/pages/user/user.vue +++ b/Web/src/pages/user/user.vue @@ -204,7 +204,7 @@ const FriendHandle = async (): Promise => { } const AddEnemy = async (): Promise => { - MessageExtend.ShowConfirmDialogAsyc("关系操作", `您确定要添加Ta为仇人吗?(添加消耗300金元)`, async () => { + MessageExtend.ShowConfirmDialogAsyc("关系操作", `您确定要添加Ta为仇人吗?(添加仇人将会消耗金元:1-120级需要100金元,120-220级需要300金元,220级以上需要500金元)`, async () => { let no = PageExtend.QueryString("no"); let result = await RelationService.AddEnemy(no); if (result.code == 0) {