From fe2696074b3c0596bc1fbcbc794a20e7a0d2df10 Mon Sep 17 00:00:00 2001 From: Putoo <290555932@qq.com> Date: Wed, 8 Jul 2026 19:13:55 +0800 Subject: [PATCH] 1212 --- .../game/user/unit_user_acc.cs | 13 +- .../game/user/unit_user_data.cs | 39 ++++ .../game/user/unit_user_temp.cs | 75 +++++++ .../model/FightRemoveData.cs | 8 + .../model/FightResultModel.cs | 4 +- .../model/GameRankModel.cs | 10 + .../model/OnHookAwardModel.cs | 10 + .../model/UserAttrModel.cs | 1 + .../BusEvents/BusEventsEnum.cs | 9 +- .../BusEvents/BusEventsSubscriber.cs | 71 ++++++- Service/Application.Domain/Enum/AccEnum.cs | 2 +- .../Application.Domain/Enum/GameChatEnum.cs | 3 +- Service/Application.Domain/Enum/GameEnum.cs | 5 + Service/Application.Domain/Enum/GoodsEnum.cs | 1 + .../Application.Domain/Enum/MessageEnum.cs | 1 + .../Handle/MessageHandle.cs | 4 + .../Interface/Business/IExchangeService.cs | 1 + .../Interface/Business/IOnHookService.cs | 1 + .../Interface/Business/IRankService.cs | 10 + .../Services/Interface/Equ/IGameEquService.cs | 8 + .../Interface/Fight/IGameFightService.cs | 4 +- .../Services/Interface/Map/IGameMapService.cs | 1 + .../Interface/Monster/IGameMonsterService.cs | 5 +- .../Interface/User/IUnitUserAccService.cs | 2 + .../Interface/User/IUnitUserAttrService.cs | 2 +- .../Service/Business/ExchangeService.cs | 11 +- .../Service/Business/GameAutoJobService.cs | 39 +++- .../Service/Business/OnHookService.cs | 76 ++++++- .../Services/Service/Business/RankService.cs | 193 ++++++++++++++++++ .../Services/Service/Chat/GameChatService.cs | 4 + .../Services/Service/Equ/GameEquService.cs | 98 ++++++++- .../Service/Fight/GameFightService.cs | 123 +++++++++-- .../Services/Service/Map/GameMapService.cs | 12 +- .../Service/Monster/GameMonsterService.cs | 53 +++++ .../Service/User/UnitUserAccService.cs | 55 ++++- .../Service/User/UnitUserAttrService.cs | 27 ++- .../Services/Service/User/UnitUserService.cs | 10 +- .../Application.Domain/Tool/Base/GameBus.cs | 4 +- .../Application.Domain/Tool/Base/GameTool.cs | 25 +++ .../Tool/Base/UserStateTool.cs | 42 ++++ .../Controllers/Login/LoginController.cs | 12 +- .../Controllers/Map/StoreController.cs | 57 ++++++ .../Controllers/Pub/FightController.cs | 79 ++++++- .../Controllers/Pub/GoodsController.cs | 17 +- .../Controllers/Pub/RankController.cs | 50 +++++ .../Controllers/User/UserController.cs | 13 +- Service/Application.Web/Program.cs | 13 +- Web/src/components/Business/GameBroadcast.vue | 2 +- Web/src/components/Business/GameEqu.vue | 7 +- Web/src/config/BaseConfig.ts | 8 +- Web/src/pages/rank/index.vue | 52 ++++- Web/src/pages/rank/info.vue | 97 +++++++++ Web/src/pages/store/sale.vue | 40 +++- Web/src/pages/user/index.vue | 2 +- Web/src/pages/user/user.vue | 22 +- Web/src/services/Index/FightService.ts | 8 + Web/src/services/Index/RankService.ts | 9 + Web/src/services/map/StoreService.ts | 8 + Web/src/utility‌/FightTool.ts | 2 +- 59 files changed, 1448 insertions(+), 112 deletions(-) create mode 100644 Service/Application.Domain.Entity/game/user/unit_user_data.cs create mode 100644 Service/Application.Domain.Entity/game/user/unit_user_temp.cs create mode 100644 Service/Application.Domain.Entity/model/FightRemoveData.cs create mode 100644 Service/Application.Domain.Entity/model/GameRankModel.cs create mode 100644 Service/Application.Domain.Entity/model/OnHookAwardModel.cs create mode 100644 Service/Application.Domain/Services/Interface/Business/IRankService.cs create mode 100644 Service/Application.Domain/Services/Service/Business/RankService.cs create mode 100644 Service/Application.Web/Controllers/Pub/RankController.cs create mode 100644 Web/src/pages/rank/info.vue create mode 100644 Web/src/services/Index/RankService.ts diff --git a/Service/Application.Domain.Entity/game/user/unit_user_acc.cs b/Service/Application.Domain.Entity/game/user/unit_user_acc.cs index 7f67896..0d1ed4c 100644 --- a/Service/Application.Domain.Entity/game/user/unit_user_acc.cs +++ b/Service/Application.Domain.Entity/game/user/unit_user_acc.cs @@ -23,17 +23,6 @@ namespace Application.Domain.Entity /// [SugarColumn(IsNullable = true)] public long? gold { get; set; } - - /// - /// 师德 - /// - [SugarColumn(IsNullable = true)] - public long? teach { get; set; } - - /// - /// 声望 - /// - [SugarColumn(IsNullable = true)] - public long? renown { get; set; } + } } diff --git a/Service/Application.Domain.Entity/game/user/unit_user_data.cs b/Service/Application.Domain.Entity/game/user/unit_user_data.cs new file mode 100644 index 0000000..d0f191d --- /dev/null +++ b/Service/Application.Domain.Entity/game/user/unit_user_data.cs @@ -0,0 +1,39 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Game")] + public class unit_user_data + { + /// + /// userId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string userId { get; set; } + + /// + /// 师德 + /// + [SugarColumn(IsNullable = true)] + public long? teach { get; set; } + + /// + /// 声望 + /// + [SugarColumn(IsNullable = true)] + public long? renown { get; set; } + + /// + /// 罪恶值 + /// + [SugarColumn(IsNullable = true)] + public long? enemy { get; set; } + + /// + /// 魅力 + /// + [SugarColumn(IsNullable = true)] + public long? charm { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/game/user/unit_user_temp.cs b/Service/Application.Domain.Entity/game/user/unit_user_temp.cs new file mode 100644 index 0000000..87cd096 --- /dev/null +++ b/Service/Application.Domain.Entity/game/user/unit_user_temp.cs @@ -0,0 +1,75 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Game")] + public class unit_user_temp + { + /// + /// userId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string userId { get; set; } + + /// + /// areaId + /// + [SugarColumn(IsNullable = true)] + public int? areaId { get; set; } + + /// + /// lev + /// + [SugarColumn(IsNullable = true)] + public int? lev { get; set; } + + /// + /// 等级更新时间 + /// + [SugarColumn(IsNullable = true)] + public long? upTime { get; set; } + + /// + /// 人品 + /// + [SugarColumn(Length = 18, IsNullable = true)] + public decimal? luck { get; set; } + + /// + /// 评分 + /// + [SugarColumn(Length = 18, IsNullable = true)] + public decimal? score { get; set; } + + /// + /// 攻击 + /// + [SugarColumn(Length = 18, IsNullable = true)] + public decimal? atk { get; set; } + + /// + /// 防御 + /// + [SugarColumn(Length = 18, IsNullable = true)] + public decimal? defense { get; set; } + + /// + /// 敏捷 + /// + [SugarColumn(Length = 18, IsNullable = true)] + public decimal? agility { get; set; } + + /// + /// 体力 + /// + [SugarColumn(Length = 18, IsNullable = true)] + public decimal? upBlood { get; set; } + + /// + /// 士气 + /// + [SugarColumn(Length = 18, IsNullable = true)] + public decimal? upMorale { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/FightRemoveData.cs b/Service/Application.Domain.Entity/model/FightRemoveData.cs new file mode 100644 index 0000000..a8fd96e --- /dev/null +++ b/Service/Application.Domain.Entity/model/FightRemoveData.cs @@ -0,0 +1,8 @@ +namespace Application.Domain.Entity; + +public class FightRemoveData +{ + public string code { get; set; } + public string par { get; set; } + public int count { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/FightResultModel.cs b/Service/Application.Domain.Entity/model/FightResultModel.cs index 35966c1..fb296fa 100644 --- a/Service/Application.Domain.Entity/model/FightResultModel.cs +++ b/Service/Application.Domain.Entity/model/FightResultModel.cs @@ -6,7 +6,7 @@ public class FightResultModel public int myHarm { get; set; } public int otHarm { get; set; } public List myStateData { get; set; } - public List myRemData { get; set; } + public List myRemData { get; set; } public List otStateData { get; set; } - public List otRemData { get; set; } + public List otRemData { get; set; } } \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/GameRankModel.cs b/Service/Application.Domain.Entity/model/GameRankModel.cs new file mode 100644 index 0000000..18ccc21 --- /dev/null +++ b/Service/Application.Domain.Entity/model/GameRankModel.cs @@ -0,0 +1,10 @@ +namespace Application.Domain.Entity; + +public class GameRankModel +{ + public string userId { get; set; } + public UserModel user { get; set; } + public string sign { get; set; } + public string par { get; set; } + +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/OnHookAwardModel.cs b/Service/Application.Domain.Entity/model/OnHookAwardModel.cs new file mode 100644 index 0000000..adea519 --- /dev/null +++ b/Service/Application.Domain.Entity/model/OnHookAwardModel.cs @@ -0,0 +1,10 @@ +namespace Application.Domain.Entity; + +public class OnHookAwardModel +{ + public string userId { get; set; } + public long exp { get; set; } + public long copper { get; set; } + public long useTime { get; set; } + public List award { 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 168e436..cde35f4 100644 --- a/Service/Application.Domain.Entity/model/UserAttrModel.cs +++ b/Service/Application.Domain.Entity/model/UserAttrModel.cs @@ -17,6 +17,7 @@ public decimal luck { get; set; }//幸运 public int weight { get; set; }//负重 public int lev { get; set; }//等级 + public long upTime { get; set; } public int minAtk { get; set; }//最小攻击 public int maxAtk { get; set; }//最大攻击 public int defense { get; set; }//防御 diff --git a/Service/Application.Domain/BusEvents/BusEventsEnum.cs b/Service/Application.Domain/BusEvents/BusEventsEnum.cs index 9891303..1f7fccf 100644 --- a/Service/Application.Domain/BusEvents/BusEventsEnum.cs +++ b/Service/Application.Domain/BusEvents/BusEventsEnum.cs @@ -10,8 +10,15 @@ namespace Application.Domain { public enum BusEventsName { - HandleOnHook,//处理挂机 PutFightAward,//战斗奖励事件 + PutOnHookAward,//发放挂机奖励 + HandleOnHook,//处理挂机 + HandleUpdateRank,//更新排名 + HandleOnlineTime,//处理在线时间 + HandleCreateMonster,//处理创建的怪物 + HandleFightData,//处理战斗日志数据 + HandleExchangeData,//处理兑换数据 + } } } \ No newline at end of file diff --git a/Service/Application.Domain/BusEvents/BusEventsSubscriber.cs b/Service/Application.Domain/BusEvents/BusEventsSubscriber.cs index 4bc67a5..44a064b 100644 --- a/Service/Application.Domain/BusEvents/BusEventsSubscriber.cs +++ b/Service/Application.Domain/BusEvents/BusEventsSubscriber.cs @@ -3,22 +3,87 @@ public class BusEventsSubscriber : IEventSubscriber { /// - /// 处理贡献提成 + /// 处理战斗结束相关(含奖励发放) /// /// - [EventSubscribe(BusEventsEnum.BusEventsName.PutFightAward, NumRetries = 0)] - public async Task HandleQueueBonus(EventHandlerExecutingContext context) + [EventSubscribe(BusEventsEnum.BusEventsName.PutFightAward, NumRetries = 0,RetryTimeout = 999999999)] + public async Task PutFightAward(EventHandlerExecutingContext context) { var data = context.GetPayload(); var fightService = App.GetService(); await fightService.HandleFight(data); } + /// + /// 发放挂机奖励 + /// + /// + [EventSubscribe(BusEventsEnum.BusEventsName.PutOnHookAward, NumRetries = 0,RetryTimeout = 999999999)] + public async Task PutOnHookAward(EventHandlerExecutingContext context) + { + var data = context.GetPayload(); + var hookService = App.GetService(); + await hookService.HandleOnHookGoods(data); + } + /// + /// 处理挂机 + /// + /// [EventSubscribe(BusEventsEnum.BusEventsName.HandleOnHook, NumRetries = 0,RetryTimeout = 999999999)] public async Task HandleOnHook(EventHandlerExecutingContext context) { var hookService = App.GetService(); await hookService.HandleHook(); } + /// + /// 处理排行榜 + /// + /// + [EventSubscribe(BusEventsEnum.BusEventsName.HandleUpdateRank, NumRetries = 0,RetryTimeout = 999999999)] + public async Task HandleUpdateRank(EventHandlerExecutingContext context) + { + var rankService = App.GetService(); + await rankService.HandleRank(); + } + /// + /// 处理在线时间 + /// + /// + [EventSubscribe(BusEventsEnum.BusEventsName.HandleOnlineTime, NumRetries = 0,RetryTimeout = 999999999)] + public async Task HandleOnlineTime(EventHandlerExecutingContext context) + { + var attrService = App.GetService(); + await attrService.HandleOnLineTimeData(); + } + /// + /// 处理生成的怪物 + /// + /// + [EventSubscribe(BusEventsEnum.BusEventsName.HandleCreateMonster, NumRetries = 0,RetryTimeout = 999999999)] + public async Task HandleCreateMonster(EventHandlerExecutingContext context) + { + var monsterService = App.GetService(); + await monsterService.HandleCreateMonster(); + } + /// + /// 处理战斗日志记录 + /// + /// + [EventSubscribe(BusEventsEnum.BusEventsName.HandleFightData, NumRetries = 0,RetryTimeout = 999999999)] + public async Task HandleFightData(EventHandlerExecutingContext context) + { + var fightService = App.GetService(); + await fightService.HandleFightData(); + } + /// + /// 处理兑换记录 + /// + /// + [EventSubscribe(BusEventsEnum.BusEventsName.HandleExchangeData, NumRetries = 0,RetryTimeout = 999999999)] + public async Task HandleExchangeData(EventHandlerExecutingContext context) + { + var exchangeService = App.GetService(); + await exchangeService.HandleExchangeLogData(); + } } } \ No newline at end of file diff --git a/Service/Application.Domain/Enum/AccEnum.cs b/Service/Application.Domain/Enum/AccEnum.cs index 6212277..d69386e 100644 --- a/Service/Application.Domain/Enum/AccEnum.cs +++ b/Service/Application.Domain/Enum/AccEnum.cs @@ -10,7 +10,7 @@ public static class AccEnum teach,//师德 renown,//声望 charm,//魅力 - evil,//罪恶值 + enemy,//罪恶值 } public enum Name { diff --git a/Service/Application.Domain/Enum/GameChatEnum.cs b/Service/Application.Domain/Enum/GameChatEnum.cs index 24fe196..0f1d63c 100644 --- a/Service/Application.Domain/Enum/GameChatEnum.cs +++ b/Service/Application.Domain/Enum/GameChatEnum.cs @@ -9,6 +9,7 @@ public static class GameChatEnum Team,//队伍 Region,//全区 Dress,//全服 - System//系统 + System,//系统 + Notice,//通知 } } \ No newline at end of file diff --git a/Service/Application.Domain/Enum/GameEnum.cs b/Service/Application.Domain/Enum/GameEnum.cs index 3a5e2f0..be6179e 100644 --- a/Service/Application.Domain/Enum/GameEnum.cs +++ b/Service/Application.Domain/Enum/GameEnum.cs @@ -10,6 +10,11 @@ public static class GameEnum public enum JobCode { OnHook,//定时任务 + UpdateRank,//更新排名 + UpdateOnlineTime,//更新在线时间 + UpdateCreateMonster,//更新创建得怪物 + UpdateFightData,//更新战斗信息 + UpdateExchangeData,//更新兑换的记录 } public enum PropCode//游戏资源编码 { diff --git a/Service/Application.Domain/Enum/GoodsEnum.cs b/Service/Application.Domain/Enum/GoodsEnum.cs index aab6b3b..0d25062 100644 --- a/Service/Application.Domain/Enum/GoodsEnum.cs +++ b/Service/Application.Domain/Enum/GoodsEnum.cs @@ -20,6 +20,7 @@ public static class GoodsEnum State,//状态物品 Ship,//船只 Practise,//修炼道具 + Durability,//负重道具 } public enum DrugCls diff --git a/Service/Application.Domain/Enum/MessageEnum.cs b/Service/Application.Domain/Enum/MessageEnum.cs index 2fd9480..1291df9 100644 --- a/Service/Application.Domain/Enum/MessageEnum.cs +++ b/Service/Application.Domain/Enum/MessageEnum.cs @@ -7,6 +7,7 @@ public static class MessageEnum Friend,//交友消息 Marry,//婚姻消息 Trade,//交易通知 + Notice,//普通通知 } public enum BroadcastCode { diff --git a/Service/Application.Domain/Handle/MessageHandle.cs b/Service/Application.Domain/Handle/MessageHandle.cs index 75758fe..a1b9dc6 100644 --- a/Service/Application.Domain/Handle/MessageHandle.cs +++ b/Service/Application.Domain/Handle/MessageHandle.cs @@ -49,6 +49,10 @@ public class MessageHandle { return new MessageHandleResult() { success = true, msg = "消息通知已处理!" }; } + else if (events.code == nameof(MessageEnum.EventCode.Notice)) + { + return new MessageHandleResult() { success = true, msg = "消息通知已处理!" }; + } return new MessageHandleResult() { success = false, msg = "暂不支持该操作处理!" }; } diff --git a/Service/Application.Domain/Services/Interface/Business/IExchangeService.cs b/Service/Application.Domain/Services/Interface/Business/IExchangeService.cs index 8dd0e95..9466d8a 100644 --- a/Service/Application.Domain/Services/Interface/Business/IExchangeService.cs +++ b/Service/Application.Domain/Services/Interface/Business/IExchangeService.cs @@ -6,4 +6,5 @@ public interface IExchangeService Task GetExchangeInfo(int exId); Task GetExchangeCount(string userId, int exId); Task AddUserExchangeLog(string userId, int exId, int count, long endTime); + Task HandleExchangeLogData(); } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Business/IOnHookService.cs b/Service/Application.Domain/Services/Interface/Business/IOnHookService.cs index 2f2dd9f..2eccc57 100644 --- a/Service/Application.Domain/Services/Interface/Business/IOnHookService.cs +++ b/Service/Application.Domain/Services/Interface/Business/IOnHookService.cs @@ -9,4 +9,5 @@ public interface IOnHookService Task StopOnHook(string userId); Task HandleHook(); + Task HandleOnHookGoods(OnHookAwardModel data); } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Business/IRankService.cs b/Service/Application.Domain/Services/Interface/Business/IRankService.cs new file mode 100644 index 0000000..c35e6b6 --- /dev/null +++ b/Service/Application.Domain/Services/Interface/Business/IRankService.cs @@ -0,0 +1,10 @@ +namespace Application.Domain; + +public interface IRankService +{ + Task GetRankUpdateTime(); + Task> GetGameRank(int type, int area, int page, int limit, RefAsync total); + Task> GetGameCopperRank(int area, int page, int limit, RefAsync total); + Task> GetGameTeachAndRenownRank(int type, int area, int page, int limit, RefAsync total); + Task HandleRank(); +} \ 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 794192a..30c993f 100644 --- a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs +++ b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs @@ -14,6 +14,7 @@ public interface IGameEquService Task> GetUserEquData(string userId, int type, string equName, int PageIndex, int PageSize, RefAsync Total, bool isRemOn = false, bool isRemLock = false); + Task> GetUserEquData(string userId, string query); Task> GetUserEquData(string userId, int equId); Task> GetUserEquData(string userId, string code, List noUeId); Task GetUserEquInfo(string ueId); @@ -62,6 +63,13 @@ public interface IGameEquService Task GetUserEquWeightSum(string userId); Task GetMakeEquByGoodsId(int goodsId); + Task RemoveUserOnEqu(string userId, string type, int count); + #endregion + + #region 耐久 + + Task UpdateUserOnEquDurability(string userId); + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs b/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs index 3101c5d..8974fe2 100644 --- a/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs +++ b/Service/Application.Domain/Services/Interface/Fight/IGameFightService.cs @@ -16,7 +16,7 @@ public interface IGameFightService string userId, long exp = 0, long copper = 0, long petExp = 0, string award = "", string pars = ""); Task SetFightWin(game_fight_data fightData, string winUser,bool setDefMap=true); - + Task HandleFightData(); #endregion #region 战斗相关 @@ -28,7 +28,7 @@ public interface IGameFightService Task GetFightGoodsInfo(string mapId, string mgId); Task RemoveFightGoods(string mapId, string mgId); Task AutoUseDrug(UserAttrModel user, game_fight_data fight); - Task HandelFightEnd(string userId, List data); + Task HandelFightEnd(string userId, List data); #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs b/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs index 236e147..b60a372 100644 --- a/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs +++ b/Service/Application.Domain/Services/Interface/Map/IGameMapService.cs @@ -20,6 +20,7 @@ public interface IGameMapService Task GetUserOnMapId(string userId); Task GetUserOnToMapInfo(string userId); Task GetUserOnMap(string userId); + Task UpdateUserOnMap(string userId); Task UpdateUserOnMap(string userId, string ip, string mapId); Task UpdateUserOnMap(unit_user_online data, string mapId); Task GetUserOnMapInfo(string userId); diff --git a/Service/Application.Domain/Services/Interface/Monster/IGameMonsterService.cs b/Service/Application.Domain/Services/Interface/Monster/IGameMonsterService.cs index b9d3c10..3b8db25 100644 --- a/Service/Application.Domain/Services/Interface/Monster/IGameMonsterService.cs +++ b/Service/Application.Domain/Services/Interface/Monster/IGameMonsterService.cs @@ -14,8 +14,11 @@ public interface IGameMonsterService int count = 1, int time = 0, string par = ""); Task GetCreateMonsterInfo(string umId); + Task RemoveCreateMonster(string umId); + Task RemoveCreateMonster(unit_user_monster data); + Task HandleCreateMonster(); Task> GetMapMonster(string userId, string mapId, string teamId); - + #endregion #region 怪物模型 diff --git a/Service/Application.Domain/Services/Interface/User/IUnitUserAccService.cs b/Service/Application.Domain/Services/Interface/User/IUnitUserAccService.cs index 12d4b9d..ede1ed4 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserAccService.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserAccService.cs @@ -16,6 +16,8 @@ public interface IUnitUserAccService Task GetUserCopperInfo(string userId); Task UpdateUserCopper(string userId, int type, long count, string remark = ""); + Task GetUserDataInfo(string userId); + Task UpdateUserData(string userId, int type, string accType, long count, string remark = ""); #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 b0aa88d..aa666cd 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs @@ -44,7 +44,7 @@ public interface IUnitUserAttrService #region 在线时间 Task UpdateOnLineTime(string userId, string code, int time); - + Task HandleOnLineTimeData(); #endregion #region 药品栏 diff --git a/Service/Application.Domain/Services/Service/Business/ExchangeService.cs b/Service/Application.Domain/Services/Service/Business/ExchangeService.cs index 58a58c8..88b8530 100644 --- a/Service/Application.Domain/Services/Service/Business/ExchangeService.cs +++ b/Service/Application.Domain/Services/Service/Business/ExchangeService.cs @@ -17,14 +17,12 @@ public class ExchangeService(ISqlSugarClient DbClient, IRedisCache redis) : IExc public async Task GetExchangeCount(string userId, int exId) { - int result = 0; - string key = $"{userId}_{exId}"; var db = DbClient.AsTenant().GetConnectionWithAttr(); return await db.Queryable().Where(it => it.userId == userId && it.exId == exId) .SumAsync(it => (int)it.count); } - public async Task AddUserExchangeLog(string userId, int exId, int count,long endTime) + public async Task AddUserExchangeLog(string userId, int exId, int count, long endTime) { game_exchange_log log = new game_exchange_log(); log.ueId = StringAssist.NewGuid; @@ -38,4 +36,11 @@ public class ExchangeService(ISqlSugarClient DbClient, IRedisCache redis) : IExc return result; } + public async Task HandleExchangeLogData() + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + await db.Deleteable().Where(it => it.endTime <= TimeExtend.GetTimeStampSeconds) + .ExecuteCommandAsync(); + } + } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Business/GameAutoJobService.cs b/Service/Application.Domain/Services/Service/Business/GameAutoJobService.cs index 9b3e04e..4a75a42 100644 --- a/Service/Application.Domain/Services/Service/Business/GameAutoJobService.cs +++ b/Service/Application.Domain/Services/Service/Business/GameAutoJobService.cs @@ -2,7 +2,8 @@ namespace Application.Domain; -public class GameAutoJobService(ISqlSugarClient DbClient, IRedisCache redis,ITimerJobManager jobManager) : IGameAutoJobService, ITransient +public class GameAutoJobService(ISqlSugarClient DbClient, IRedisCache redis, ITimerJobManager jobManager) + : IGameAutoJobService, ITransient { public async Task> GetJobData() { @@ -12,11 +13,12 @@ public class GameAutoJobService(ISqlSugarClient DbClient, IRedisCache redis,ITim public async Task GetJobInfo(string jobId) { - string key = string.Format(BaseCache.BaseCacheKey,"JobData"); + string key = string.Format(BaseCache.BaseCacheKey, "JobData"); if (await redis.HExistsHashAsync(key, jobId)) { return await redis.GetHashAsync(key, jobId); } + var db = DbClient.AsTenant().GetConnectionWithAttr(); var data = await db.Queryable().Where(it => it.jobId == jobId).SingleAsync(); await redis.AddHashAsync(key, jobId, data); @@ -53,12 +55,41 @@ public class GameAutoJobService(ISqlSugarClient DbClient, IRedisCache redis,ITim public async Task HandleJob(game_job data) { - if (data.code == nameof(GameEnum.JobCode.OnHook))//挂机 + if (data.code == nameof(GameEnum.JobCode.OnHook)) //挂机 { var _eventPublisher = App.GetService(); await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleOnHook, data)); } - + else if (data.code == nameof(GameEnum.JobCode.UpdateRank)) //更新排名 + { + var _eventPublisher = App.GetService(); + await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleUpdateRank, + data)); + } + else if (data.code == nameof(GameEnum.JobCode.UpdateOnlineTime)) //更新在线时间 + { + var _eventPublisher = App.GetService(); + await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleOnlineTime, + data)); + } + else if (data.code == nameof(GameEnum.JobCode.UpdateCreateMonster)) //更新创建得怪物 + { + var _eventPublisher = App.GetService(); + await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleCreateMonster, + data)); + } + else if (data.code == nameof(GameEnum.JobCode.UpdateFightData)) //更新战斗记录 + { + var _eventPublisher = App.GetService(); + await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleFightData, + data)); + } + else if (data.code == nameof(GameEnum.JobCode.UpdateExchangeData)) //更新兑换类记录 + { + var _eventPublisher = App.GetService(); + await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.HandleExchangeData, + data)); + } } } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Business/OnHookService.cs b/Service/Application.Domain/Services/Service/Business/OnHookService.cs index 78c49ec..2a5365f 100644 --- a/Service/Application.Domain/Services/Service/Business/OnHookService.cs +++ b/Service/Application.Domain/Services/Service/Business/OnHookService.cs @@ -111,8 +111,9 @@ public class OnHookService(ISqlSugarClient DbClient, IRedisCache redis) : IOnHoo public async Task HandleHook() { long onTime = TimeExtend.GetTimeStampSeconds; - var accService = App.GetService(); var attrService = App.GetService(); + var _eventPublisher = App.GetService(); + var db = DbClient.AsTenant().GetConnectionWithAttr(); var data = await db.Queryable().Where(it => it.status == 1).ToListAsync(); foreach (var hook in data) @@ -147,19 +148,74 @@ public class OnHookService(ISqlSugarClient DbClient, IRedisCache redis) : IOnHoo if (await UpdateOnHook(hook.userId, exp, copper)) { - if (exp > 0) + OnHookAwardModel push = new OnHookAwardModel() { - await attrService.UpdateUserExp(hook.userId, exp); - } + userId = hook.userId, + exp = exp, + copper = copper, + useTime = allTime, + award = award + + }; + + await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.PutOnHookAward, + push)); + } - if (copper > 0) - { - await accService.UpdateUserCopper(hook.userId, 1, copper, "挂机获得"); - } + } + } - if (award.Count > 0) + public async Task HandleOnHookGoods(OnHookAwardModel data) + { + var accService = App.GetService(); + var attrService = App.GetService(); + var mapService = App.GetService(); + var equService = App.GetService(); + + int onlineTime = Convert.ToInt32(data.useTime / 1000 / 60); + if (onlineTime > 0) + { + await attrService.UpdateOnLineTime(data.userId, "OnHook", onlineTime); //更新在线时间 + } + + await mapService.UpdateUserOnMap(data.userId);//更新在线 + await equService.UpdateUserOnEquDurability(data.userId);//更新耐久 + if (data.exp > 0) + { + await attrService.UpdateUserExp(data.userId, data.exp); + } + + if (data.copper > 0) + { + await accService.UpdateUserCopper(data.userId, 1, data.copper, "挂机获得"); + } + + if (data.award.Count > 0) + { + var userService = App.GetService(); + var userConfig = await userService.GetUserConfigInfo(data.userId); + if (userConfig.autoBag != 0) + { + var weightService = App.GetService(); + bool auto = true; + foreach (var item in data.award) { - await GameBus.UpdateBag(hook.userId, 1, award, "挂机获得"); + if (auto == false) + { + break; + } + else + { + if (await weightService.CheckUserWeight(data.userId, item)) + { + await GameBus.UpdateBag(data.userId, 1, item.code, item.parameter, item.count, + "挂机获得"); + } + else + { + auto = false; + } + } } } } diff --git a/Service/Application.Domain/Services/Service/Business/RankService.cs b/Service/Application.Domain/Services/Service/Business/RankService.cs new file mode 100644 index 0000000..d81ad7b --- /dev/null +++ b/Service/Application.Domain/Services/Service/Business/RankService.cs @@ -0,0 +1,193 @@ +namespace Application.Domain; + +public class RankService(ISqlSugarClient DbClient, IRedisCache redis) : IRankService, ITransient +{ + public async Task GetRankUpdateTime() + { + string key = string.Format(BaseCache.BaseCacheKey, "RankTime"); + if (await redis.ExistsAsync(key)) + { + return await redis.GetAsync(key); + } + + return "更新时间:/-/-/ 00:00:00"; + } + + private async Task SetRankUpdateTime() + { + string key = string.Format(BaseCache.BaseCacheKey, "RankTime"); + await redis.SetAsync(key, $"更新时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + } + + public async Task> GetGameRank(int type, int area, int page, int limit, RefAsync total) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable() + .WhereIF(area != 0, it => it.areaId == area) + .WhereIF(type == 0, it => it.lev > 30) + .WhereIF(type == 1, it => it.atk > 100) + .WhereIF(type == 2, it => it.defense > 100) + .WhereIF(type == 3, it => it.agility > 100) + .WhereIF(type == 4, it => it.upBlood > 100) + .WhereIF(type == 5, it => it.upMorale > 0) + .WhereIF(type == 6, it => it.luck > 0) + .WhereIF(type == 7, it => it.score > 1000) + .OrderByIF(type == 0, it => it.lev, OrderByType.Desc) + .OrderByIF(type == 0, it => it.upTime, OrderByType.Desc) + .OrderByIF(type == 1, it => it.atk, OrderByType.Desc) + .OrderByIF(type == 2, it => it.defense, OrderByType.Desc) + .OrderByIF(type == 3, it => it.agility, OrderByType.Desc) + .OrderByIF(type == 4, it => it.upBlood, OrderByType.Desc) + .OrderByIF(type == 5, it => it.upMorale, OrderByType.Desc) + .OrderByIF(type == 6, it => it.luck, OrderByType.Desc) + .OrderByIF(type == 7, it => it.score, OrderByType.Desc) + .Take(100) + .ToListAsync(); + total = data.Count; + data = PageExtend.GetPageList(data, page, limit); + List result = new List(); + foreach (var item in data) + { + GameRankModel temp = new GameRankModel(); + temp.userId = item.userId; + temp.user = await UserModelTool.GetUserView(item.userId); + temp.sign = GetRankSign(item, type); + temp.par = ""; + result.Add(temp); + } + + return result; + } + + private string GetRankSign(unit_user_temp data, int type) + { + string result = "0"; + switch (type) + { + case 0: + result = $"{Convert.ToString(data.lev)}级"; + break; + case 1: + result = Convert.ToString(data.atk); + break; + case 2: + result = Convert.ToString(data.defense); + break; + case 3: + result = Convert.ToString(data.agility); + break; + case 4: + result = Convert.ToString(data.upBlood); + break; + case 5: + result = Convert.ToString(data.upMorale); + break; + case 6: + result = (Convert.ToDecimal(data.luck) * 100).ToString("#0"); + break; + case 7: + result = Convert.ToDecimal(data.score).ToString("#0.00"); + break; + } + + return result; + } + + public async Task> GetGameCopperRank(int area, int page, int limit, RefAsync total) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().LeftJoin((uc, u) => uc.userId == u.userId) + .WhereIF(area != 0, (uc, u) => u.areaId == area) + .Where((uc, u) => uc.copper > 1000000) + .Select() + .OrderByDescending(uc => uc.copper) + .Take(100) + .ToListAsync(); + total = data.Count; + data = PageExtend.GetPageList(data, page, limit); + List result = new List(); + foreach (var item in data) + { + GameRankModel temp = new GameRankModel(); + temp.userId = item.userId; + temp.user = await UserModelTool.GetUserView(item.userId); + temp.sign = GameTool.ConvertCopperName((long)item.copper); + temp.par = ""; + result.Add(temp); + } + + return result; + } + public async Task> GetGameTeachAndRenownRank(int type, int area, int page, int limit, RefAsync total) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().LeftJoin((uc, u) => uc.userId == u.userId) + .WhereIF(area != 0, (uc, u) => u.areaId == area) + .WhereIF(type == 9, (uc, u) => uc.teach > 0) + .WhereIF(type == 10, (uc, u) => uc.renown > 0) + .WhereIF(type == 11, (uc, u) => uc.charm > 0) + .Select() + .OrderByIF(type == 9, uc => uc.teach, OrderByType.Desc) + .OrderByIF(type == 10, uc => uc.renown, OrderByType.Desc) + .OrderByIF(type == 11, uc => uc.charm, OrderByType.Desc) + .Take(100) + .ToListAsync(); + total = data.Count; + data = PageExtend.GetPageList(data, page, limit); + List result = new List(); + foreach (var item in data) + { + GameRankModel temp = new GameRankModel(); + temp.userId = item.userId; + temp.user = await UserModelTool.GetUserView(item.userId); + if (type == 9) + { + temp.sign = item.teach.ToString(); + } + else if(type==10) + { + temp.sign = item.renown.ToString(); + } + temp.par = ""; + result.Add(temp); + } + + return result; + } + public async Task HandleRank() + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + await db.Deleteable().ExecuteCommandAsync(); + + long endTime = TimeExtend.GetTimeStampBySeconds(TimeAssist.GetDateTimeYMD(0)); + var data = await db.Queryable().Where(it => it.upTime > endTime).ToListAsync(); + var attrService = App.GetService(); + List addData = new List(); + foreach (var item in data) + { + var attrInfo = await attrService.GetUserAttrModel(item.userId); + unit_user_temp temp = new unit_user_temp() + { + userId = attrInfo.id, + areaId = attrInfo.area, + lev = attrInfo.lev, + upTime = attrInfo.upTime, + luck = attrInfo.luck, + score = attrInfo.score, + atk = attrInfo.maxAtk, + defense = attrInfo.defense, + agility = attrInfo.agility, + upBlood = attrInfo.upBlood, + upMorale = attrInfo.upMorale + }; + addData.Add(temp); + } + + if (addData.Count > 0) + { + await db.Insertable(addData).ExecuteCommandAsync(); + } + + await SetRankUpdateTime(); + } +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Chat/GameChatService.cs b/Service/Application.Domain/Services/Service/Chat/GameChatService.cs index 1f03e17..80646a7 100644 --- a/Service/Application.Domain/Services/Service/Chat/GameChatService.cs +++ b/Service/Application.Domain/Services/Service/Chat/GameChatService.cs @@ -136,6 +136,10 @@ public class GameChatService : IGameChatService, ITransient case "System": chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddHours(6)); break; + case "Notice": + chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(1)); + chat.code = nameof(GameChatEnum.Code.System); + break; case "Group": chat.delTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddHours(6)); break; diff --git a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs index 47b7472..6ec3985 100644 --- a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs +++ b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs @@ -55,6 +55,15 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame .OrderByDescending(it => it.lev) .OrderByDescending(it => it.ueId).ToPageListAsync(PageIndex, PageSize, Total); } + public async Task> GetUserEquData(string userId,string query) + { + long onTime = TimeExtend.GetTimeStampSeconds; + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(it => it.userId == userId) + .WhereIF(!string.IsNullOrEmpty(query), + it => it.equName.Contains(query) || it.unitEquName.Contains(query)) + .ToListAsync(); + } public async Task> GetUserEquData(string userId, int equId) { @@ -93,7 +102,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame .ToList(); return userEqu; } - + public async Task AddUserEqu(string userId, int equId, int count, string remark) { @@ -369,6 +378,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame { return false; } + var opData = userEqu.Take(count).ToList(); return await DeductUserEqu(userId, opData, remark); } @@ -595,6 +605,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame result.AddRange(attr.AttrItem); } } + await redis.SetAsync(key, result, 300); } @@ -834,5 +845,90 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return onMakeEqu; } + public async Task RemoveUserOnEqu(string userId, string type, int count) + { + var userOnEqu = await GetUserOnEqu(userId); + userOnEqu = userOnEqu.FindAll(it => it.code == type); + if (userOnEqu.Count >= count) + { + var opEqu = userOnEqu.Take(count).ToList(); + foreach (var item in opEqu) + { + await EquOnOrDown(item, 0); + } + } + + } + #endregion + + #region 耐久 + + private async Task GetUserDurabilityTimer(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "Timer", "Durability"); + if (await redis.HExistsHashAsync(key, userId)) + { + return await redis.GetHashAsync(key, userId); + } + + long result = TimeExtend.GetTimeStampSeconds + 5 * 60; + await redis.AddHashAsync(key, userId, result); + return result; + } + + private async Task SetUserDurabilityTimer(string userId, long endTime) + { + string key = string.Format(UserCache.BaseCacheKeys, "Timer", "Durability"); + await redis.AddHashAsync(key, userId, endTime); + } + + public async Task UpdateUserOnEquDurability(string userId) + { + long onTime = TimeExtend.GetTimeStampSeconds; + long endTime = await GetUserDurabilityTimer(userId); + if (onTime > endTime) //进行耐久更新 + { + await SetUserDurabilityTimer(userId, onTime + 5 * 60); + var onEquData = await GetUserOnEqu(userId); + List noCode = new List() { "Fashion", "Decorate" }; + onEquData = onEquData.FindAll(it => it.durability > 0 && !noCode.Contains(it.code)); + if (onEquData.Count > 0) + { + var attrService = App.GetService(); + var stockDurability = await attrService.GetUserStock(userId, nameof(GameEnum.GameStockCode.Durability)); + if (stockDurability.Count > 0) + { + if (stockDurability.Any(it => it.type == nameof(GameEnum.GameStockType.Time))) + { + return; + } + + var onStock = stockDurability.Find(it => + it.type == nameof(GameEnum.GameStockType.Number) && it.sign >= onEquData.Count); + if (onStock != null) + { + onStock.sign = onStock.sign - onEquData.Count; + if (await attrService.UpdateUserStock(onStock)) + { + return; + } + } + } + + foreach (var item in onEquData) + { + item.durability = item.durability - 1; + } + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + bool result = await db.Updateable(onEquData).ExecuteCommandAsync() > 0; + if (result) + { + await ClearUserOnEqu(userId); + } + } + } + } + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/Fight/GameFightService.cs b/Service/Application.Domain/Services/Service/Fight/GameFightService.cs index 31fdbbe..7eca3ee 100644 --- a/Service/Application.Domain/Services/Service/Fight/GameFightService.cs +++ b/Service/Application.Domain/Services/Service/Fight/GameFightService.cs @@ -39,12 +39,6 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa return result; } - private async Task RemoveUserFight(string userId) - { - string key = string.Format(FightCache.FightCacheKey, "UserFight"); - bool result = await redis.AddHashAsync(key, userId, new List()); - } - #endregion #region 战斗信息 @@ -167,7 +161,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa return result; } - public async Task SetFightWin(game_fight_data fightData, string winUser,bool setDefMap=true) + public async Task SetFightWin(game_fight_data fightData, string winUser, bool setDefMap = true) { bool result = false; long okTime = TimeExtend.GetTimeStampMilliseconds; @@ -215,11 +209,10 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa nameof(UserEnum.AttrCode.Monster), winUser, fightData.userId, okTime); if (result) { - await RemoveUserFight(fightData.userId); if (setDefMap) { await UserStateTool.SetUserMapDefault(fightData.userId); - } + } } } } @@ -230,14 +223,26 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa nameof(UserEnum.AttrCode.Person), winUser, lowUser, okTime); if (result) { - await RemoveUserFight(lowUser); if (setDefMap) { await UserStateTool.SetUserMapDefault(lowUser); } + + fightData.state = 1; + fightData.winCode = nameof(UserEnum.AttrCode.Person); + fightData.winUser = winUser; + fightData.okTime = okTime; + //此处调用战斗结束相关 + var _eventPublisher = App.GetService(); + await _eventPublisher.PublishAsync(new ChannelEventSource(BusEventsEnum.BusEventsName.PutFightAward, + fightData)); } } + //更新耐久 + var equService = App.GetService(); + await equService.UpdateUserOnEquDurability(fightData.userId); + return result; } @@ -290,6 +295,49 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa return result; } + + public async Task HandleFightData() + { + long endTime = TimeExtend.GetTimeStampSeconds; + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable() + .Where(it => it.state == 0 && it.endTime < endTime) + .ToListAsync(); + List dels = data.Select(it => it.fightId).ToList(); + bool result = await db.Deleteable().Where(it => dels.Contains(it.fightId)) + .ExecuteCommandAsync() > 0; + if (result) + { + List fightIdKeys = new List(); + List monsterBloodKeys = new List(); + List fightHarmKeys = new List(); + foreach (var item in data) + { + fightIdKeys.Add(string.Format(FightCache.FightCacheKeys, "FightData:Info", item.fightId)); + fightHarmKeys.Add(string.Format(FightCache.FightCacheKeys, "FightData:Harm", item.fightId)); + if (item.code == nameof(GameEnum.FightCode.PVE)) + { + monsterBloodKeys.Add(string.Format(FightCache.FightCacheKeys, "FightData:Blood", item.keyId)); + } + } + + if (fightIdKeys.Count > 0) + { + await redis.DelAsync(fightIdKeys.ToArray()); + } + + if (monsterBloodKeys.Count > 0) + { + await redis.DelAsync(monsterBloodKeys.ToArray()); + } + + if (fightHarmKeys.Count > 0) + { + await redis.DelAsync(fightHarmKeys.ToArray()); + } + } + } + #endregion #region 战斗相关 @@ -303,7 +351,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa result = await redis.GetHashAsync(key, userId); } - if (result > 0) + if (result != 0) { await redis.AddHashAsync(key, userId, 0); } @@ -322,6 +370,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa public async Task HandleFight(game_fight_data fightData) { string winUser = fightData.winUser; + string lowUser = fightData.userId == winUser ? fightData.mainId : fightData.userId; #region 发放基础奖励 @@ -347,6 +396,40 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa } #endregion + + #region 场景处理 + + if (fightData.code == nameof(GameEnum.FightCode.PVP)) + { + var mapService = App.GetService(); + var userService = App.GetService(); + var messageService = App.GetService(); + var mapInfo = await mapService.GetMapInfo(fightData.mapId); + var cityInfo = await mapService.GetCityInfo((int)mapInfo.cityId); + var winUserInfo = await userService.GetUserInfoByUserId(winUser); + var lowUserInfo = await userService.GetUserInfoByUserId(lowUser); + + //系统广播 + string boradMsg = + $"[{UbbTool.HomeUbb(winUserInfo.userNo, winUserInfo.nick)}]在{cityInfo.cityName}·{mapInfo.mapName}击杀了[{UbbTool.HomeUbb(lowUserInfo.userNo, lowUserInfo.nick)}]!"; + await messageService.SendBroadcast("0", nameof(MessageEnum.BroadcastCode.Remind), boradMsg); + //个人通知 + var chatService = App.GetService(); + 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) + { + 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, "击杀玩家"); //加罪恶 + } + } + } + + #endregion } private async Task PutFightAwardGoods(game_fight_data fightData) @@ -492,7 +575,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa if (config[0] == fight.code || config[0] == "ALL") { decimal okLimit = Convert.ToDecimal(config[1]); - if ((Convert.ToDecimal(addBlood) / Convert.ToDecimal(user.upBlood) ) > okLimit) + if ((Convert.ToDecimal(addBlood) / Convert.ToDecimal(user.upBlood)) > okLimit) { if (item.type == "Number") { @@ -541,7 +624,7 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa } //使用普通药品 - if (addBlood > 0) + if (addBlood > 0 && (addBlood / user.upMorale / 1.0M) > 0.6M) { var unitDrug = myDrug.drug.Find(it => it.code == nameof(GoodsEnum.DrugCls.Blood) && it.count > 0); if (unitDrug != null) @@ -563,9 +646,19 @@ public class GameFightService(ISqlSugarClient DbClient, IRedisCache redis) : IGa #endregion - public async Task HandelFightEnd(string userId, List data) + public async Task HandelFightEnd(string userId, List data) { - await Task.CompletedTask; + var equService = App.GetService(); + foreach (var item in data) + { + if (item.code == "Equ") + { + await equService.RemoveUserOnEqu(userId, item.par, item.count); + } + } + + + await Task.CompletedTask; } #endregion diff --git a/Service/Application.Domain/Services/Service/Map/GameMapService.cs b/Service/Application.Domain/Services/Service/Map/GameMapService.cs index 27b9e79..a75aaa8 100644 --- a/Service/Application.Domain/Services/Service/Map/GameMapService.cs +++ b/Service/Application.Domain/Services/Service/Map/GameMapService.cs @@ -183,7 +183,17 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame isOnline = isOnline }; } - + public async Task UpdateUserOnMap(string userId) + { + unit_user_online onLine = await GetUserOnMap(userId); + onLine.upTime = TimeExtend.GetTimeStampSeconds; + string key = string.Format(UserCache.BaseCacheKey, "UserOnline"); + if (await redis.AddHashAsync(key, userId, onLine)) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + await db.Updateable(onLine).ExecuteCommandAsync(); + } + } public async Task UpdateUserOnMap(string userId, string ip, string mapId) { unit_user_online onLine = new unit_user_online(); diff --git a/Service/Application.Domain/Services/Service/Monster/GameMonsterService.cs b/Service/Application.Domain/Services/Service/Monster/GameMonsterService.cs index 83f2378..f58e2d0 100644 --- a/Service/Application.Domain/Services/Service/Monster/GameMonsterService.cs +++ b/Service/Application.Domain/Services/Service/Monster/GameMonsterService.cs @@ -123,6 +123,59 @@ public class GameMonsterService(ISqlSugarClient DbClient, IRedisCache redis) : I string key = string.Format(BaseCache.BaseCacheKeys, "MonsterData", "CreateMonsterOnMap"); await redis.DelHashAsync(key, mapId); } + + public async Task RemoveCreateMonster(string umId) + { + bool result = false; + var data = await GetCreateMonsterInfo(umId); + if (data != null) + { + result = await RemoveCreateMonster(data); + } + + return result; + } + + public async Task RemoveCreateMonster(unit_user_monster data) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + bool result = await db.Deleteable().Where(it => it.umId == data.umId).ExecuteCommandAsync()>0; + if (result) + { + await ClearCreateMonster(data.mapId); + } + + return result; + } + + public async Task HandleCreateMonster() + { + var endTime = TimeExtend.GetTimeStampSeconds; + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var data = await db.Queryable().Where(it => it.endTime < endTime).ToListAsync(); + List delIds = new List(); + List mapIds = new List(); + foreach (var item in data) + { + delIds.Add(item.umId); + if (mapIds.Any(it => it == item.mapId) == false) + { + mapIds.Add(item.mapId); + } + } + + if (delIds.Count > 0) + { + bool result = await db.Deleteable().Where(it => delIds.Contains(it.umId)) + .ExecuteCommandAsync() > 0; + if (result) + { + string key = string.Format(BaseCache.BaseCacheKeys, "MonsterData", "CreateMonsterOnMap"); + await redis.DelHashAsync(key, mapIds.ToArray()); + } + } + + } public async Task> GetMapMonster(string userId, string mapId, string teamId) { diff --git a/Service/Application.Domain/Services/Service/User/UnitUserAccService.cs b/Service/Application.Domain/Services/Service/User/UnitUserAccService.cs index 0da8637..633607f 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserAccService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserAccService.cs @@ -22,14 +22,24 @@ public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : I } else if (accType == nameof(AccEnum.AccType.teach)) { - var info = await GetUserAccInfo(userId); + var info = await GetUserDataInfo(userId); result = (long)info.teach; } else if (accType == nameof(AccEnum.AccType.renown)) { - var info = await GetUserAccInfo(userId); + var info = await GetUserDataInfo(userId); result = (long)info.renown; } + else if (accType == nameof(AccEnum.AccType.charm)) + { + var info = await GetUserDataInfo(userId); + result = (long)info.charm; + } + else if (accType == nameof(AccEnum.AccType.enemy)) + { + var info = await GetUserDataInfo(userId); + result = (long)info.enemy; + } return result; } @@ -55,8 +65,6 @@ public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : I isOk = await db.Updateable() .SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.cowry)), it => it.cowry == it.cowry + opCount) .SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.gold)), it => it.gold == it.gold + opCount) - .SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.teach)), it => it.teach == it.teach + opCount) - .SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.renown)), it => it.renown == it.renown + opCount) .Where(it => it.userId == userId).ExecuteCommandAsync() > 0; //生成日志 if (isOk) @@ -94,10 +102,14 @@ public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : I { result = await UpdateUserCopper(userId, type, count, remark); } - else + else if (accType == nameof(AccEnum.AccType.gold)||accType == nameof(AccEnum.AccType.cowry)) { result = await UpdateUserAcc(userId, type, accType, count, name, remark); } + else + { + result = await UpdateUserData(userId, type, accType, count, remark); + } return result; } @@ -138,5 +150,38 @@ public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : I return isOk; } + public async Task GetUserDataInfo(string userId) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(i => i.userId == userId).SingleAsync(); + } + + public async Task UpdateUserData(string userId, int type, string accType, long count, string remark = "") + { + bool isOk = false; + decimal opCount = type == 0 ? (0 - count) : count; + try + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + await DbClient.AsTenant().BeginTranAsync(); + + isOk = await db.Updateable() + .SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.teach)), it => it.teach == it.teach + opCount) + .SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.renown)), it => it.renown == it.renown + opCount) + .SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.charm)), it => it.charm == it.charm + opCount) + .SetColumnsIF(accType.Equals(nameof(AccEnum.AccType.enemy)), it => it.enemy == it.enemy + opCount) + .Where(it => it.userId == userId).ExecuteCommandAsync() > 0; + + await DbClient.AsTenant().CommitTranAsync(); + } + catch + { + isOk = false; + await DbClient.AsTenant().RollbackTranAsync(); + } + + return isOk; + } + #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 2a62a68..e91b73c 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs @@ -18,6 +18,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : result.code = nameof(UserEnum.AttrCode.Person); var unitAttr = await GetUserAttr(userId); result.lev = (int)unitAttr.lev; + result.upTime = (long)unitAttr.levUpdate; result.minAtk = (int)unitAttr.minAtk; result.maxAtk = (int)unitAttr.maxAtk; result.defense = (int)unitAttr.defense; @@ -489,6 +490,16 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : public async Task UpdateOnLineTime(string userId, string code, int time) { + if (code == "Default") + { + var hookService = App.GetService(); + var hookInfo = await hookService.GetUserOnHook(userId); + if (hookInfo.status == 1) + { + return true; + } + } + var db = DbClient.AsTenant().GetConnectionWithAttr(); bool result = await db.Updateable() .SetColumns(it => it.dayTime == it.dayTime + time) @@ -498,6 +509,15 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : return result; } + public async Task HandleOnLineTimeData() + { + int day = DateTime.Now.Day; + var db = DbClient.AsTenant().GetConnectionWithAttr(); + await db.Updateable().SetColumns(it => it.dayTime == 0) + .WhereIF(day == 1, it => it.monthTime == 0) + .Where(it => true).ExecuteCommandAsync(); + } + #endregion #region 药品栏 @@ -657,6 +677,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : { result.AddRange(item.attr); } + return GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.AddExp), result, 0); } @@ -766,7 +787,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : var result = await db.Updateable(data).ExecuteCommandAsync() > 0; if (result) { - await ClearUserAttrCache(data.userId); + await ClearUserStockCache(data.userId); } return result; @@ -816,6 +837,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : return result; } + public async Task AddUserLoadState(string userId, List codes) { foreach (var code in codes) @@ -851,9 +873,11 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : name = "麻痹"; break; } + await AddUserLoadState(userId, name, code); } } + public async Task RandomRemoveUserLoadState(string userId, int count) { var data = await GetUserLoadState(userId); @@ -879,7 +903,6 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "LoadState"); await redis.DelHashAsync(key, userId); } - #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/User/UnitUserService.cs b/Service/Application.Domain/Services/Service/User/UnitUserService.cs index 82203d4..7c70b8a 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserService.cs @@ -185,9 +185,15 @@ public class UnitUserService(ISqlSugarClient DbClient, IRedisCache redis) : IUni acc.userId = userId; acc.cowry = 0; acc.gold = 0; - acc.teach = 0; - acc.renown = 0; db.Insertable(acc).AddQueue(); + + unit_user_data userData = new unit_user_data(); + userData.userId = userId; + userData.teach = 0; + userData.renown = 0; + userData.charm = 0; + userData.enemy = 0; + db.Insertable(userData).AddQueue(); //注册游戏货币 unit_user_copper copper = new unit_user_copper(); copper.userId = userId; diff --git a/Service/Application.Domain/Tool/Base/GameBus.cs b/Service/Application.Domain/Tool/Base/GameBus.cs index 6f898dd..5c4d1bf 100644 --- a/Service/Application.Domain/Tool/Base/GameBus.cs +++ b/Service/Application.Domain/Tool/Base/GameBus.cs @@ -55,13 +55,13 @@ public static class GameBus else if (goodsType.Equals(nameof(GameEnum.PropCode.renown))) { var accService = App.GetService(); - isok = await accService.UpdateUserAcc(userId, operate, nameof(AccEnum.AccType.renown), count, + isok = await accService.UpdateUserAccBath(userId, operate, nameof(AccEnum.AccType.renown), count, nameof(AccEnum.Name.其他), remark); } else if (goodsType.Equals(nameof(GameEnum.PropCode.teach))) { var accService = App.GetService(); - isok = await accService.UpdateUserAcc(userId, operate, nameof(AccEnum.AccType.teach), count, + isok = await accService.UpdateUserAccBath(userId, operate, nameof(AccEnum.AccType.teach), count, nameof(AccEnum.Name.其他), remark); } else if (goodsType.Equals(nameof(GameEnum.PropCode.map))) diff --git a/Service/Application.Domain/Tool/Base/GameTool.cs b/Service/Application.Domain/Tool/Base/GameTool.cs index f9c2bb5..42e54f6 100644 --- a/Service/Application.Domain/Tool/Base/GameTool.cs +++ b/Service/Application.Domain/Tool/Base/GameTool.cs @@ -4,6 +4,31 @@ namespace Application.Domain; public class GameTool { + /// + /// 单位转换 + /// + /// + /// + public static string ConvertCopperName(long glod) + { + string result = string.Empty; + string glodStr = glod.ToString(); + int yin = 0; + int t = 0; + if (glodStr.Length > 3) + { + yin = Convert.ToInt32(glodStr.Substring(0, glodStr.Length - 3)); + t = Convert.ToInt32(glodStr.Substring(glodStr.Length - 3, 3)); + } + else + { + t = Convert.ToInt32(glod); + } + result += yin > 0 ? string.Format("{0}银", yin) : ""; + result += t > 0 ? string.Format("{0}铜", t) : ""; + result = string.IsNullOrEmpty(result) ? "0铜" : result; + return result; + } /// /// 获取等级基础属性 /// diff --git a/Service/Application.Domain/Tool/Base/UserStateTool.cs b/Service/Application.Domain/Tool/Base/UserStateTool.cs index 5c89b1e..97961b2 100644 --- a/Service/Application.Domain/Tool/Base/UserStateTool.cs +++ b/Service/Application.Domain/Tool/Base/UserStateTool.cs @@ -14,4 +14,46 @@ public static class UserStateTool var mapService = App.GetService(); await mapService.SetUserMapDefault(userId); } + + public static async Task CheckPkState(string userId, string otId, bool isEnemy, bool isAtArea) + { + bool result = true; + var _mapService = App.GetService(); + var onMapInfo = await _mapService.GetUserOnToMapInfo(userId); + if (onMapInfo.isPk == 0) + { + if (onMapInfo.retMap != onMapInfo.mapId) + { + if (isEnemy == false) + { + return false; + } + } + else + { + return false; + } + } + + var otUserOnMap = await _mapService.GetUserOnMapInfo(otId); + if (onMapInfo.mapId != otUserOnMap.mapId) + { + return false; + } + + if (otUserOnMap.isOnline == 0) + { + return false; + } + + if (onMapInfo.lookArea == 1) + { + if (isAtArea == false) + { + return false; + } + } + + return result; + } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Login/LoginController.cs b/Service/Application.Web/Controllers/Login/LoginController.cs index 306d912..6b62704 100644 --- a/Service/Application.Web/Controllers/Login/LoginController.cs +++ b/Service/Application.Web/Controllers/Login/LoginController.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; using Newtonsoft.Json; +using Photon.Core.Redis; namespace Application.Web.Controllers.Login { @@ -19,7 +20,7 @@ namespace Application.Web.Controllers.Login private readonly IUnitUserAttrService _attrService; public LoginController(IGameAccountService accountService, IAreaService areaService, - IUnitUserService userService,IUnitUserAttrService attrService) + IUnitUserService userService, IUnitUserAttrService attrService) { _accountService = accountService; _areaService = areaService; @@ -27,6 +28,7 @@ namespace Application.Web.Controllers.Login _attrService = attrService; } + /// /// 登录接口 /// @@ -273,14 +275,14 @@ namespace Application.Web.Controllers.Login loadData.Add("accId", userInfo.accId); loadData.Add("areaId", userInfo.areaId); string token = JwtHelper.CreateToken(Key, Issuer, Audience, loadData, TokenConfig.TokenTime); - + //记录在线时间 await _attrService.UpdateOnLineTime(userInfo.userId, "Default", TokenConfig.TokenTime); - + return PoAction.Ok(new { token = token, refToken = userInfo.token, userId = userInfo.userId }); } - + [HttpPost] public async Task RefreshTokenByBook([FromBody] RefreshTokenParms parms) { @@ -304,7 +306,7 @@ namespace Application.Web.Controllers.Login loadData.Add("accId", userInfo.accId); loadData.Add("areaId", userInfo.areaId); string token = JwtHelper.CreateToken(Key, Issuer, Audience, loadData, TokenConfig.TokenTime); - + return PoAction.Ok(new { token = token, refToken = userInfo.token, userId = userInfo.userId }); } diff --git a/Service/Application.Web/Controllers/Map/StoreController.cs b/Service/Application.Web/Controllers/Map/StoreController.cs index 6a4c20f..4c087a5 100644 --- a/Service/Application.Web/Controllers/Map/StoreController.cs +++ b/Service/Application.Web/Controllers/Map/StoreController.cs @@ -296,4 +296,61 @@ public class StoreController : ControllerBase } } } + + /// + /// 批量出售装备 + /// + /// + /// + /// + [HttpGet] + public async Task BathSaleEqu(int npcId, string? query) + { + if (string.IsNullOrEmpty(query)) + { + return PoAction.Message("需要筛选搜索后才可以一键出售!"); + } + + 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 (GameTool.AreaVerify(areaId, npcInfo.areaId) == false) + { + return PoAction.Message("Npc不存在!"); + } + + if (!npcInfo.bus.Any(it => it.code == nameof(GameEnum.NpcBusCode.Store))) + { + return PoAction.Message("业务不可用!"); + } + + var onMap = await _mapService.GetUserOnMapId(userId); + if (npcInfo.mapId != onMap) + { + return PoAction.Message("Npc不存在!"); + } + + var myEqu = await _equService.GetUserEquData(userId, query); + myEqu = myEqu.FindAll(it => it.isOn == 0 && it.isLock == 0 && it.intensifyLev == 0); + long getCopper = myEqu.Sum(it => (int)it.sysPrice); + if (await _equService.DeductUserEqu(userId, myEqu, "出售装备")) + { + await _accService.UpdateUserCopper(userId, 1, getCopper, "出售装备"); + return PoAction.Ok(true, $"共出售{myEqu.Count}件装备,获得{getCopper}铜贝!"); + } + else + { + return PoAction.Message("出售失败,请稍后尝试!"); + } + } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Pub/FightController.cs b/Service/Application.Web/Controllers/Pub/FightController.cs index 4020489..19f1f7f 100644 --- a/Service/Application.Web/Controllers/Pub/FightController.cs +++ b/Service/Application.Web/Controllers/Pub/FightController.cs @@ -19,10 +19,12 @@ public class FightController : ControllerBase private readonly IGameGoodsService _goodsService; private readonly IUnitUserService _userService; private readonly IOnHookService _hookService; + private readonly IUnitUserRelationService _relationService; public FightController(IGameFightService fightService, IGameMonsterService monsterService, IUnitUserAttrService attrService, IGameMapService mapService, IUnitUserAccService accService, - IGameGoodsService goodsService, IUnitUserService userService,IOnHookService hookService) + IGameGoodsService goodsService, IUnitUserService userService, IOnHookService hookService, + IUnitUserRelationService relationService) { _fightService = fightService; _monsterService = monsterService; @@ -32,6 +34,7 @@ public class FightController : ControllerBase _goodsService = goodsService; _userService = userService; _hookService = hookService; + _relationService = relationService; } /// @@ -110,6 +113,77 @@ public class FightController : ControllerBase } } + /// + /// 角色战斗生成 + /// + /// + /// + [HttpGet] + public async Task FightPerson(string? no) + { + string userId = StateHelper.userId; + var onMapInfo = await _mapService.GetUserOnToMapInfo(userId); + var otUser = await _userService.GetUserInfoByUserNo(no); + if (otUser == null) + { + return PoAction.Message("玩家不存在!"); + } + + if (onMapInfo.isPk == 0) + { + if (onMapInfo.retMap != onMapInfo.mapId) + { + if (await _relationService.CheckUserEnemy(userId, otUser.userId) == false) + { + return PoAction.Message("该场景不允许PK!"); + } + } + else + { + return PoAction.Message("该场景不允许PK!"); + } + } + + var otUserOnMap = await _mapService.GetUserOnMapInfo(otUser.userId); + if (onMapInfo.mapId != otUserOnMap.mapId) + { + return PoAction.Message("玩家不存在!"); + } + + if (otUserOnMap.isOnline == 0) + { + return PoAction.Message("玩家已下线!"); + } + + if (onMapInfo.lookArea == 1) + { + if (otUser.areaId != StateHelper.areaId) + { + return PoAction.Message("该地图不允许跨服战斗!"); + } + } + string fightId = StringAssist.NewGuid; + string areaCode = nameof(GameEnum.AreaCode.Own); + string code = nameof(GameEnum.FightCode.PVP); + string keyId = StringAssist.GetSortKey(userId,otUser.userId); + long exp = 0; + long copper = 0; + long petExp = 0; + string award = string.Empty; + string pars = ""; + bool result = await _fightService.AddFight(fightId, areaCode, keyId, otUser.userId, code, onMapInfo.code, onMapInfo.mapId, userId, exp, + copper, petExp, award, pars); + if (result) + { + await _hookService.StopOnHook(userId); + return PoAction.Ok(fightId); + } + else + { + return PoAction.Message("战斗生成错误!"); + } + } + /// /// 战斗接口 /// @@ -194,7 +268,6 @@ public class FightController : ControllerBase //结束战斗都此处直接返回 if (otAttr.blood < 1 || myAttr.blood < 1) { - await _fightService.RemoveUserFight(userId, fightId); if (otAttr.blood < 1) { await _fightService.SetFightWin(fight, userId); @@ -343,13 +416,11 @@ public class FightController : ControllerBase var fight = await _fightService.GetFightInfo(fightId); if (fight == null) { - await _fightService.RemoveUserFight(userId, fightId); return PoAction.Message("战斗不存在!"); } if (fight.state == 1) { - await _fightService.RemoveUserFight(userId, fightId); return PoAction.Message("战斗结束!"); } diff --git a/Service/Application.Web/Controllers/Pub/GoodsController.cs b/Service/Application.Web/Controllers/Pub/GoodsController.cs index 86033d6..5ad3fcf 100644 --- a/Service/Application.Web/Controllers/Pub/GoodsController.cs +++ b/Service/Application.Web/Controllers/Pub/GoodsController.cs @@ -43,7 +43,7 @@ public class GoodsController : ControllerBase int count = await _goodsService.GetUserGoodsCount(userId, goodsId); int UseState = 0; string[] ShowViewNum = ["Pack", "Weight", "State"]; //显示带数量窗口 - string[] ShowView = ["Ship","Drug"]; //显示只能使用1个的窗口 + string[] ShowView = ["Ship", "Drug", "Durability"]; //显示只能使用1个的窗口 if (ShowViewNum.Any(it => it == goodsInfo.code)) { UseState = 1; @@ -113,7 +113,7 @@ public class GoodsController : ControllerBase return PoAction.Message(ck); } } - + #endregion if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, count, "使用物品")) @@ -168,11 +168,24 @@ public class GoodsController : ControllerBase await _weightService.AddUserShip(userId, name, goodsId, speed, weight, copper, sale, remark); message = $"使用[{goodsInfo.goodsName}],获得{name}+1"; } + if (goodsInfo.code == nameof(GoodsEnum.Code.Drug)) { message = "使用成功!"; await _goodsService.UseDrug(userId, goodsId, goodsInfo.content); } + + if (goodsInfo.code == nameof(GoodsEnum.Code.Durability)) + { + message = "使用成功!"; + dynamic _drugConfig = JsonConvert.DeserializeObject(goodsInfo.content); + await _attrService.AddUserStock(userId, goodsId.ToString(), Convert.ToString(_drugConfig.name), + Convert.ToString(_drugConfig.type), + Convert.ToString(_drugConfig.code), + Convert.ToInt64(_drugConfig.num), Convert.ToString(_drugConfig.par), + Convert.ToInt32(_drugConfig.minute)); + } + return PoAction.Ok(true, message); } else diff --git a/Service/Application.Web/Controllers/Pub/RankController.cs b/Service/Application.Web/Controllers/Pub/RankController.cs new file mode 100644 index 0000000..4cf6f99 --- /dev/null +++ b/Service/Application.Web/Controllers/Pub/RankController.cs @@ -0,0 +1,50 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Application.Web.Controllers.Pub; + +/// +/// 排行接口 +/// +[Route("[controller]/[action]")] +[ApiController] +[Authorize] +public class RankController : ControllerBase +{ + private readonly IRankService _rankService; + + public RankController(IRankService rankService) + { + _rankService = rankService; + } + + /// + /// 获取排名数据 + /// + /// + /// + /// + [HttpGet] + public async Task GetRankData(int type, int page) + { + List data = new List(); + RefAsync total = 0; + string upTime = $"更新时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"; + int area = StateHelper.areaId; + if (type is >= 0 and < 8) + { + data = await _rankService.GetGameRank(type, area, page, 10, total); + upTime = await _rankService.GetRankUpdateTime(); + } + else if (type == 8) + { + data = await _rankService.GetGameCopperRank(area, page, 10, total); + } + else if (type == 9 || type == 10 || type == 11) + { + data = await _rankService.GetGameTeachAndRenownRank(type, area, page, 10, total); + } + + + return PoAction.Ok(new { upTime, data, total = total.Value }); + } +} \ 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 151d512..1549a07 100644 --- a/Service/Application.Web/Controllers/User/UserController.cs +++ b/Service/Application.Web/Controllers/User/UserController.cs @@ -54,7 +54,8 @@ public class UserController : ControllerBase object exp = new { expInfo.exp, expInfo.upExp }; var vigourInfo = await _attrService.GetUserVigourInfo(userId); var accInfo = await _accService.GetUserAccInfo(userId); - object acc = new { accInfo.gold, accInfo.cowry, accInfo.teach, accInfo.renown }; + var userDataInfo = await _accService.GetUserDataInfo(userId); + object acc = new { accInfo.gold, accInfo.cowry, userDataInfo.teach, userDataInfo.renown,userDataInfo.enemy }; var buff = await _attrService.GetUserStateData(userId, "ALL"); var stock = await _attrService.GetUserStock(userId); @@ -165,15 +166,17 @@ public class UserController : ControllerBase return PoAction.Message("用户本身!", 101); } + bool isAtArea = true; if (userInfo.areaId != StateHelper.areaId) { + isAtArea = false; return PoAction.Message("玩家不存在!", 102); } object user = new { userInfo.userNo, userInfo.nick, userInfo.sex, userInfo.sign }; var attrInfo = await _attrService.GetUserAttrModel(userInfo.userId); //基础属性 - var accInfo = await _accService.GetUserAccInfo(userInfo.userId); - object acc = new { accInfo.teach }; + var accInfo = await _accService.GetUserDataInfo(userInfo.userId); + object acc = new { accInfo.teach,accInfo.enemy }; var online = await _mapService.GetUserOnMap(userInfo.userId); int isOnline = online.upTime > @@ -189,9 +192,11 @@ public class UserController : ControllerBase var equ = await _equService.GetUserOnEqu(userInfo.userId); var suit = await _equService.GetUserEquSuit(userInfo.userId); + + var isPk = await UserStateTool.CheckPkState(userId, userInfo.userId, isEnemy, isAtArea); object result = new { - user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy, team, equ, suit + user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy, team, equ, suit,isPk }; return PoAction.Ok(result); } diff --git a/Service/Application.Web/Program.cs b/Service/Application.Web/Program.cs index df53e11..8fe578b 100644 --- a/Service/Application.Web/Program.cs +++ b/Service/Application.Web/Program.cs @@ -46,16 +46,15 @@ builder.Services.InjectJwt(builder.Configuration, new OpenApiInfo }, groups); #endregion -//自动程序 +//定时功能 +builder.Services.InjectTimer(services => +{ + services.AddTransient();//注册管理器 + services.AddSingleton(); +}); string autoConfig = builder.Configuration["AutoProgram"]!; if (autoConfig == "1") { - //定时功能 - builder.Services.InjectTimer(services => - { - services.AddTransient();//注册管理器 - services.AddSingleton(); - }); builder.Services.AddHostedService(); } diff --git a/Web/src/components/Business/GameBroadcast.vue b/Web/src/components/Business/GameBroadcast.vue index aa5778f..f1a35f5 100644 --- a/Web/src/components/Business/GameBroadcast.vue +++ b/Web/src/components/Business/GameBroadcast.vue @@ -9,7 +9,7 @@ {{ item.nick }} : - + diff --git a/Web/src/components/Business/GameEqu.vue b/Web/src/components/Business/GameEqu.vue index 67e3fdc..f36ed18 100644 --- a/Web/src/components/Business/GameEqu.vue +++ b/Web/src/components/Business/GameEqu.vue @@ -1,10 +1,9 @@ diff --git a/Web/src/pages/rank/info.vue b/Web/src/pages/rank/info.vue new file mode 100644 index 0000000..0ab6584 --- /dev/null +++ b/Web/src/pages/rank/info.vue @@ -0,0 +1,97 @@ + + \ No newline at end of file diff --git a/Web/src/pages/store/sale.vue b/Web/src/pages/store/sale.vue index 320819a..9f9a908 100644 --- a/Web/src/pages/store/sale.vue +++ b/Web/src/pages/store/sale.vue @@ -7,20 +7,20 @@
搜索内容:  - +
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}. - {{ item.equName }}({{ item.lev }}级) + {{ item.equName }}({{ item.lev }}级) [出售]
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}. - {{ item.goodsName }}({{item.count}}) + {{ item.goodsName }}({{ item.count }}) [出售]
@@ -28,16 +28,19 @@
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}. - {{ item.goodsName }}({{item.count}}) + {{ item.goodsName }}({{ item.count }}) - {{ item.goodsName }}({{item.count}}) + {{ item.goodsName }}({{ item.count }}) [出售]
暂无. +
+ ➣一键出售装备 +
@@ -85,13 +88,18 @@ const BindData = async (): Promise => { let result = await StoreService.GetNpcSale(Number(npcId), Number(type.value), serch.value, currentPage.value); if (result.code == 0) { data.value = result.data.data; - total.value = result.data.total; + total.value = result.data.total; } else { MessageExtend.ShowDialog("提示", result.msg); } }; +const refData = async () => { + currentPage.value = 1; + await BindData(); +} + /**翻页 */ const handlePageChange = async (page: number): Promise => { currentPage.value = page; @@ -131,11 +139,29 @@ const SaleOk = async (): Promise => { MessageExtend.LoadingClose(); if (result.code == 0) { showSale.value = false; - MessageExtend.Notify(result.msg,"success"); + MessageExtend.Notify(result.msg, "success"); await BindData(); } else { MessageExtend.ShowDialog("提示", result.msg); } }; + +const bathSale = async () => { + if (type.value == '0') { + MessageExtend.ShowConfirmDialogAsyc("出售装备", `您确定要出售当前装备吗?`, async () => { + let npcId = LocalStorageHelper.GetOnNpc(); + let result = await StoreService.BathSaleEqu(Number(npcId), serch.value); + if (result.code == 0) { + await BindData(); + MessageExtend.Notify(result.msg, "success"); + } + else { + MessageExtend.Notify(result.msg, "danger"); + } + + return true; + }); + } +} \ No newline at end of file diff --git a/Web/src/pages/user/index.vue b/Web/src/pages/user/index.vue index 4dbcd56..f718a28 100644 --- a/Web/src/pages/user/index.vue +++ b/Web/src/pages/user/index.vue @@ -23,7 +23,7 @@ 师德:{{ accData.teach }}
声望:{{ accData.renown }}
活力:{{ vitality }}
- 罪恶值:0
+ 罪恶值:{{ accData.enemy }}
帮派:无
---◈BUFF状态◈---
diff --git a/Web/src/pages/user/user.vue b/Web/src/pages/user/user.vue index d593b4f..b14d151 100644 --- a/Web/src/pages/user/user.vue +++ b/Web/src/pages/user/user.vue @@ -22,7 +22,7 @@ 坐骑:无
成就:
个性签名:{{ userData.sign }}
- 罪恶值:0
+ 罪恶值:{{ accData.enemy }}
师德:{{ accData.teach }}
@@ -98,6 +98,9 @@
队伍:{{ team.team.name }}
+
+ 攻击 +
\ No newline at end of file diff --git a/Web/src/services/Index/FightService.ts b/Web/src/services/Index/FightService.ts index 7555da8..9f1cabe 100644 --- a/Web/src/services/Index/FightService.ts +++ b/Web/src/services/Index/FightService.ts @@ -10,6 +10,14 @@ export class FightService { return await ApiService.Request("post", "/Fight/FightMonster", { type, monsterId, sign }); } + /** + * 角色战斗生成 + * GET /Fight/FightPerson + */ + static async FightPerson(no: string) { + return await ApiService.Request("get", "/Fight/FightPerson", { no }); + } + /** * 战斗接口 * POST /Fight/Fight diff --git a/Web/src/services/Index/RankService.ts b/Web/src/services/Index/RankService.ts new file mode 100644 index 0000000..6e6fbe0 --- /dev/null +++ b/Web/src/services/Index/RankService.ts @@ -0,0 +1,9 @@ +export class RankService { + /** + * 获取排名数据 + * GET /Rank/GetRankData + */ + static async GetRankData(type: number, page: number) { + return await ApiService.Request("get", "/Rank/GetRankData", { type, page }); + } +} \ No newline at end of file diff --git a/Web/src/services/map/StoreService.ts b/Web/src/services/map/StoreService.ts index 49299a6..62e0bde 100644 --- a/Web/src/services/map/StoreService.ts +++ b/Web/src/services/map/StoreService.ts @@ -38,4 +38,12 @@ export class StoreService { static async Sale(npcId: number, count: number, search: string, type: number, id: string) { return await ApiService.Request("post", "/Map/Store/Sale", { npcId, count, search, type, id }); } + + /** + * 批量出售装备 + * GET /Map/Store/BathSaleEqu + */ + static async BathSaleEqu(npcId: number, query: string) { + return await ApiService.Request("get", "/Map/Store/BathSaleEqu", { npcId, query }); + } } \ No newline at end of file diff --git a/Web/src/utility‌/FightTool.ts b/Web/src/utility‌/FightTool.ts index cad88d2..152910c 100644 --- a/Web/src/utility‌/FightTool.ts +++ b/Web/src/utility‌/FightTool.ts @@ -142,7 +142,7 @@ export class FightTool { if (this.randomTrigger(atkUser.del_Fashion)) { if (defUser.code == 'Person') { remData.push({ - "code": "equ", + "code": "Equ", "par": "Fashion", "count": 1 });