diff --git a/Service/Application.Domain.Entity/game/user/unit_user_ship.cs b/Service/Application.Domain.Entity/game/user/unit_user_ship.cs index 790a786..40df711 100644 --- a/Service/Application.Domain.Entity/game/user/unit_user_ship.cs +++ b/Service/Application.Domain.Entity/game/user/unit_user_ship.cs @@ -47,5 +47,17 @@ namespace Application.Domain.Entity /// [SugarColumn(IsNullable = true)] public int? copper { get; set; } + + /// + /// 出售价格 + /// + [SugarColumn(IsNullable = true)] + public long? sale { get; set; } + + /// + /// remark + /// + [SugarColumn(Length = 255, IsNullable = true)] + public string? remark { get; set; } } } \ No newline at end of file diff --git a/Service/Application.Domain.Entity/game/user/unit_user_state.cs b/Service/Application.Domain.Entity/game/user/unit_user_state.cs new file mode 100644 index 0000000..0474c53 --- /dev/null +++ b/Service/Application.Domain.Entity/game/user/unit_user_state.cs @@ -0,0 +1,63 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity +{ + [Tenant("Kg.SeaTime.Game")] + public class unit_user_state + { + /// + /// usId + /// + [SugarColumn(IsPrimaryKey = true, Length = 50)] + public string usId { get; set; } + + /// + /// userId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? userId { get; set; } + + /// + /// goodsId + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? goodsId { get; set; } + + /// + /// name + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? name { get; set; } + + /// + /// 场景 + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? scene { get; set; } + + /// + /// tips + /// + [SugarColumn(Length = 50, IsNullable = true)] + public string? tips { get; set; } + + /// + /// attr + /// + [SugarColumn(IsNullable = true,IsJson = true)] + public List attr { get; set; } + + /// + /// addTime + /// + [SugarColumn(IsNullable = true)] + public long? addTime { get; set; } + + /// + /// endTime + /// + [SugarColumn(IsNullable = true)] + public long? endTime { get; set; } + } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/ChoiceGoods.cs b/Service/Application.Domain.Entity/model/ChoiceGoods.cs new file mode 100644 index 0000000..cee2e53 --- /dev/null +++ b/Service/Application.Domain.Entity/model/ChoiceGoods.cs @@ -0,0 +1,8 @@ +namespace Application.Domain.Entity; + +public class ChoiceGoods +{ + public int id { get; set; } + public string name { get; set; } + public List award { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/UserEquAttrModel.cs b/Service/Application.Domain.Entity/model/UserEquAttrModel.cs new file mode 100644 index 0000000..b42b685 --- /dev/null +++ b/Service/Application.Domain.Entity/model/UserEquAttrModel.cs @@ -0,0 +1,7 @@ +namespace Application.Domain.Entity; + +public class UserEquAttrModel +{ + public UserAttrModel equ { get; set; } + public List attr { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/model/UserStateModel.cs b/Service/Application.Domain.Entity/model/UserStateModel.cs new file mode 100644 index 0000000..ddd57e2 --- /dev/null +++ b/Service/Application.Domain.Entity/model/UserStateModel.cs @@ -0,0 +1,10 @@ +namespace Application.Domain.Entity; + +public class UserStateModel +{ + public string name { get; set; } + public int time { get; set; } + public string scene { get; set; } + public string tips { get; set; } + public List attr { get; set; } +} \ No newline at end of file diff --git a/Service/Application.Domain.Entity/resource/game/game_ship.cs b/Service/Application.Domain.Entity/resource/game/game_ship.cs deleted file mode 100644 index c4554cf..0000000 --- a/Service/Application.Domain.Entity/resource/game/game_ship.cs +++ /dev/null @@ -1,75 +0,0 @@ -using SqlSugar; -using System; - -namespace Application.Domain.Entity -{ - [Tenant("Kg.SeaTime.Resource")] - public class game_ship - { - /// - /// shipId - /// - [SugarColumn(IsPrimaryKey = true, Length = 50)] - public int shipId { get; set; } - - /// - /// npc - /// - [SugarColumn(IsNullable = true)] - public int? npc { get; set; } - - /// - /// shipName - /// - [SugarColumn(Length = 50, IsNullable = true)] - public string shipName { get; set; } - - /// - /// img - /// - [SugarColumn(Length = 50, IsNullable = true)] - public string img { get; set; } - - /// - /// price - /// - [SugarColumn(Length = 18, IsNullable = true)] - public decimal? price { get; set; } - - /// - /// salePrice - /// - [SugarColumn(Length = 18, IsNullable = true)] - public decimal? salePrice { get; set; } - - /// - /// payType - /// - [SugarColumn(Length = 50, IsNullable = true)] - public string payType { get; set; } - - /// - /// weight - /// - [SugarColumn(IsNullable = true)] - public int? weight { get; set; } - - /// - /// speed - /// - [SugarColumn(IsNullable = true)] - public int? speed { get; set; } - - /// - /// neeGold - /// - [SugarColumn(IsNullable = true)] - public int? neeGold { get; set; } - - /// - /// remark - /// - [SugarColumn(Length = 50, IsNullable = true)] - public string remark { get; set; } - } -} diff --git a/Service/Application.Domain/Enum/GoodsEnum.cs b/Service/Application.Domain/Enum/GoodsEnum.cs index 60f5988..6e0a607 100644 --- a/Service/Application.Domain/Enum/GoodsEnum.cs +++ b/Service/Application.Domain/Enum/GoodsEnum.cs @@ -14,8 +14,10 @@ public static class GoodsEnum Card,//附魔卡片 Mark,//圣痕 Pack,//宝箱 + ChoicePack,//选择宝箱 Weight,//负重 Exp,//经验 State,//状态物品 + Ship,//船只 } } \ 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 0015dff..0a7913c 100644 --- a/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs +++ b/Service/Application.Domain/Services/Interface/Equ/IGameEquService.cs @@ -32,9 +32,10 @@ public interface IGameEquService bool isAddAttr = false); Task> GetUserOnEqu(string userId); + Task GetUserEquAttrModel(string userId); Task EquOnOrDown(unit_user_equ data, int state); Task> GetUserEquSuit(string userId); - + Task> GetUserEquSuitAttrInfo(string userId); #endregion #region 觉醒相关 diff --git a/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs b/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs index a537a8e..2a55a2f 100644 --- a/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs +++ b/Service/Application.Domain/Services/Interface/Goods/IGameGoodsService.cs @@ -28,8 +28,4 @@ public interface IGameGoodsService #endregion - - #region 船只 - Task GetShipInfo(int shipId); - #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 3a5456e..9eecec8 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs @@ -4,7 +4,7 @@ public interface IUnitUserAttrService { #region 个人属性 - Task GetUserAttrModel(string userId); + Task GetUserAttrModel(string userId, string scene = "Default"); Task GetUserAttr(string userId); Task GetUserLev(string userId); #endregion @@ -51,5 +51,15 @@ public interface IUnitUserAttrService Task GetUserDrug(string userId); Task UpdateUserDrug(unit_user_drug data); + #endregion + + #region 状态 + + Task> GetUserStateData(string userId, string scene = "Default"); + + Task AddUserState(string userId, string groupId, string name, string scene, string tips, + List attr, int time, int count = 1); + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs b/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs index b33d4bd..673911f 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserWeight.cs @@ -19,7 +19,7 @@ public interface IUnitUserWeight Task UpdateUserShipOnWeight(string userId, int op, int weight); Task CheakUserShipWeight(string userId, int useWeight); Task DeleteUserShip(string usId, string userId); - Task AddUserShip(string userId, string name, int goodsId, int speed, int weight); + Task AddUserShip(string userId, string name, int goodsId, int speed, int weight,int copper,long sale,string remark); #endregion diff --git a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs index 816a6b3..7af2341 100644 --- a/Service/Application.Domain/Services/Service/Equ/GameEquService.cs +++ b/Service/Application.Domain/Services/Service/Equ/GameEquService.cs @@ -447,13 +447,50 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame } } + public async Task GetUserEquAttrModel(string userId) + { + var key = string.Format(UserCache.BaseCacheKeys, "EquData", "UserOnEquAttr"); + if (await redis.HExistsHashAsync(key, userId)) + { + return await redis.GetHashAsync(key, userId); + } + + long endTime = TimeExtend.GetTimeStampSeconds; + UserAttrModel result = new UserAttrModel(); + var myEqu = await GetUserOnEqu(userId); + foreach (var equ in myEqu) + { + if (equ.durability > 0 || equ.useEndTime > endTime) + { + UserAttrModel equTemp = new UserAttrModel(); + var equAttr = EquTool.GetUserEquByIntensify(equ); + equTemp.minAtk = (int)equAttr.minAtk; + equTemp.maxAtk = (int)equAttr.maxAtk; + equTemp.defense = (int)equAttr.Defense; + equTemp.agility = (int)equAttr.Agility; + equTemp.upBlood = (int)equAttr.Blood; + equTemp.upMorale = (int)equAttr.Morale; + List equAttrData = EquTool.GetUserEquAttrData(equ); + equTemp = GameAttrTool.GetRoleAttrTempMerge(equTemp, equAttrData); + result = GameAttrTool.GetRoleAttrTempMerge(result, equTemp); + } + } + + await redis.AddHashAsync(key, userId, result); + return result; + } + private async Task ClearUserOnEqu(string userId) { var key = string.Format(UserCache.BaseCacheKeys, "EquData", "UserOnEqu"); await redis.DelHashAsync(key, userId); + key = string.Format(UserCache.BaseCacheKeys, "EquData", "UserOnEquAttr"); + await redis.DelHashAsync(key, userId); //清理套装缓存 key = string.Format(UserCache.BaseCacheKeys, "EquData:UserEquSuit", userId); await redis.DelAsync(key); + key = string.Format(UserCache.BaseCacheKeys, "EquData:UserEquSuitAttr", userId); + await redis.DelAsync(key); } public async Task EquOnOrDown(unit_user_equ data, int state) @@ -544,6 +581,30 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame return result; } + public async Task> GetUserEquSuitAttrInfo(string userId) + { + List result = new List(); + var key = string.Format(UserCache.BaseCacheKeys, "EquData:UserEquSuitAttr", userId); + if (await redis.ExistsAsync(key)) + { + result = await redis.GetAsync>(key); + } + else + { + var suitData = await GetUserEquSuit(userId); + foreach (var item in suitData) + { + foreach (var attr in item.SuitAttr) + { + result.AddRange(attr.AttrItem); + } + } + await redis.SetAsync(key, result, 300); + } + + return result; + } + #endregion #region 觉醒 @@ -672,7 +733,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame foreach (var item in attrResult) { var onAttr = item as game_equ_attr; - + AttrItem temp = new AttrItem(); temp.code = onAttr.code; temp.compute = onAttr.compute; @@ -708,7 +769,6 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame public async Task GetUserEquAttr(unit_user_equ equ) { - return equ; } diff --git a/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs b/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs index 0df52e9..36b2087 100644 --- a/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs +++ b/Service/Application.Domain/Services/Service/Goods/GameGoodsService.cs @@ -187,22 +187,6 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa #endregion - #region 船只 - public async Task GetShipInfo(int shipId) - { - string key = string.Format(BaseCache.BaseCacheKey, "ShipData"); - var data = await redis.GetHashAsync(key, shipId.ToString()); - if (data == null) - { - var db = DbClient.AsTenant().GetConnectionWithAttr(); - data = await db.Queryable().Where(it => it.shipId == shipId).SingleAsync(); - await redis.AddHashAsync(key, shipId.ToString(), data); - } - - return data; - } - #endregion - #region 药品 diff --git a/Service/Application.Domain/Services/Service/Pub/GameTeamService.cs b/Service/Application.Domain/Services/Service/Pub/GameTeamService.cs index 6ee35b2..fac0959 100644 --- a/Service/Application.Domain/Services/Service/Pub/GameTeamService.cs +++ b/Service/Application.Domain/Services/Service/Pub/GameTeamService.cs @@ -33,6 +33,7 @@ public class GameTeamService(ISqlSugarClient DbClient, IRedisCache redis) : IGam await redis.AddHashAsync(key, userId, data); return data; } + public async Task GetTeamInfo(string teamId) { diff --git a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs index 1c05567..8d8db19 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs @@ -4,7 +4,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : { #region 个人属性 - public async Task GetUserAttrModel(string userId) + public async Task GetUserAttrModel(string userId, string scene = "Default") { UserAttrModel result = new UserAttrModel(); result.id = userId; @@ -24,11 +24,149 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : 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; + List ExtendAttrData = new List(); + + #region 构造基础加层体系 + + UserAttrModel temp = new UserAttrModel(); + temp.minAtk = (int)unitAttr.minAtk; + temp.maxAtk = (int)unitAttr.maxAtk; + temp.defense = (int)unitAttr.defense; + temp.agility = (int)unitAttr.agility; + temp.upBlood = (int)unitAttr.upBlood; + temp.upMorale = (int)unitAttr.upMorale; + + var equService = App.GetService(); + var equTemp = await equService.GetUserEquAttrModel(userId); + temp = GameAttrTool.GetRoleAttrTempMerge(temp, equTemp); + //套装加层 + var suitAttr = await equService.GetUserEquSuitAttrInfo(userId); + ExtendAttrData.AddRange(suitAttr); + + #endregion + + + #region 参数 + + int minAtk = 0; + int maxAtk = 0; + int Agility = 0; + int Defense = 0; + int upBlood = 0; + int upMorale = 0; + + #endregion 参数 + + #region 队伍加层 + + var teamService = App.GetService(); + var MyTeam = await teamService.GetUserTeamInfo(userId); + if (MyTeam.state == 1) + { + int teamCount = MyTeam.user.Count(it => it.isOnline == 1); + if (teamCount > 0) + { + decimal teamAdd = 0.05m * teamCount; + teamAdd = teamAdd > 0.2m ? 0.2m : teamAdd; + minAtk += Convert.ToInt32(temp.minAtk * teamAdd); + maxAtk += Convert.ToInt32(temp.maxAtk * teamAdd); + Defense += Convert.ToInt32(temp.defense * teamAdd); + result.atkTips += $"(队+{Convert.ToInt32(teamAdd * 100)}%)"; + result.defTips += $"(队+{Convert.ToInt32(teamAdd * 100)}%)"; + } + } + + #endregion + + + #region Buff加层 + + var MyState = await GetUserStateData(userId, scene); + if (MyState.Count > 0) + { + foreach (var item in MyState) + { + minAtk += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Atk.ToString(), item.attr, + temp.minAtk)); + maxAtk += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Atk.ToString(), item.attr, + temp.maxAtk)); + Defense += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Defense.ToString(), + item.attr, temp.defense)); + Agility += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Agility.ToString(), + item.attr, temp.agility)); + upBlood += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Blood.ToString(), item.attr, + temp.upBlood)); + upMorale += Convert.ToInt32(GameAttrTool.GetAttrItemValue(GameEnum.AttrCode.Morale.ToString(), + item.attr, temp.upMorale)); + } + } + + #endregion + + #region 加层处理 + + var otTemp = GameAttrTool.GetRoleAttrTemp(temp, ExtendAttrData); + result = GameAttrTool.GetRoleAttrTempMerge(result, otTemp); //加层其他 + result = GameAttrTool.GetRoleAttrTempMerge(result, temp); //加层其他 + + result.minAtk += minAtk; + result.maxAtk += maxAtk; + result.defense += Defense; + result.agility += Agility; + result.upBlood += upBlood; + result.upMorale += upMorale; + + #endregion + + #region 数据效验 + + var userBlood = await GetUserBlood(userId); + result.blood = (int)userBlood.blood; + + //士气 + var userMorale = await GetUserMorale(userId); + result.morale = (int)userMorale.morale; + + //负面状态处理 + //result = await GameAttrTool.CheakRoleLoadBuff(result); + result = await ReviseUserRoleAttr(result); + return result; + + #endregion + + + return result; + } + + private async Task ReviseUserRoleAttr(UserAttrModel result) + { + //处理上限数据 + if (result.blood > result.upBlood) + { + result.blood = result.upBlood; + await UpdateUserBlood(result.id, 2, result.blood, true); + } + + if (result.morale > result.upMorale) + { + result.morale = result.upMorale; + await UpdateUserMorale(result.id, 2, Convert.ToInt32(result.morale)); + } + + if (result.NoHarm > 0.8M) //免伤上限 + { + result.NoHarm = 0.8M; + } + + if (result.Atk_Next > 0.3M) //连击上限 + { + result.Atk_Next = 0.3M; + } + + //评分 + decimal _score = result.maxAtk + result.defense + result.agility + result.upBlood / 3.00M + result.upMorale; + result.score = Math.Round(_score, 2); return result; } @@ -257,10 +395,11 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : 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)); + await redis.SetAsync(key, DateTime.Now, TimeAssist.GetDateTimeYMD(1)); } #endregion 士气 @@ -334,7 +473,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : #endregion 活力 - #region 在线时间 + #region 在线时间 public async Task UpdateOnLineTime(string userId, string code, int time) { @@ -347,10 +486,9 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : return result; } - #endregion - #region 药品栏 + #region 药品栏 public async Task GetUserDrug(string userId) { @@ -359,6 +497,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : { return await redis.GetHashAsync(key, userId); } + var db = DbClient.AsTenant().GetConnectionWithAttr(); var data = await db.Queryable().Where(it => it.userId == userId).SingleAsync(); if (data == null) @@ -379,7 +518,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : bool result = await db.Updateable(data).ExecuteCommandAsync() > 0; if (result) { - await ClearUserDrug(data. userId); + await ClearUserDrug(data.userId); } return result; @@ -392,4 +531,86 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : } #endregion + + #region 状态 + + private async Task> GetUserStateData(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "State"); + var data = await redis.GetHashAsync>(key, userId); + if (data == null) + { + long endTime = TimeExtend.GetTimeStampSeconds; + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(it => it.userId == userId && it.endTime > endTime) + .ToListAsync(); + await redis.AddHashAsync(key, userId, data); + } + + return data; + } + + public async Task> GetUserStateData(string userId, string scene = "Default") + { + var data = await GetUserStateData(userId); + if (scene == "ALL") + { + return data; + } + data = data.FindAll(it => it.scene == "Default" || it.scene == scene); + return data; + } + + public async Task AddUserState(string userId, string groupId, string name, string scene, string tips, + List attr, int time, int count = 1) + { + bool result = false; + long onTime = TimeExtend.GetTimeStampSeconds; + string usId = $"{userId}_{groupId}"; + var db = DbClient.AsTenant().GetConnectionWithAttr(); + var usData = await db.Queryable().Where(it => it.usId == usId).SingleAsync(); + if (usData == null) + { + usData = new unit_user_state(); + usData.usId = usId; + usData.userId = userId; + usData.goodsId = groupId; + usData.name = name; + usData.scene = scene; + usData.tips = tips; + usData.attr = attr; + usData.addTime = onTime; + usData.endTime = onTime + (time * 60 * count); + result = await db.Insertable(usData).ExecuteCommandAsync() > 0; + } + else + { + if (usData.endTime > onTime) + { + usData.endTime = usData.endTime + (time * 60 * count); + } + else + { + usData.addTime = onTime; + usData.endTime = onTime + (time * 60 * count); + } + + result = await db.Updateable(usData).ExecuteCommandAsync() > 0; + } + + if (result) + { + await ClearUserState(userId); + } + + return result; + } + + private async Task ClearUserState(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "State"); + await redis.DelHashAsync(key, userId); + } + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs b/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs index 0e2689d..278a23b 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserWeight.cs @@ -204,7 +204,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,int copper,long sale,string remark) { unit_user_ship ship = new unit_user_ship(); ship.usId = StringAssist.NewGuid; @@ -213,6 +213,9 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit ship.name = name; ship.speed = speed; ship.weight = weight; + ship.copper = copper; + ship.sale = sale; + ship.remark = remark; var db = DbClient.AsTenant().GetConnectionWithAttr(); bool result = await db.Insertable(ship).ExecuteCommandAsync() > 0; if (result) diff --git a/Service/Application.Domain/Tool/Base/EquTool.cs b/Service/Application.Domain/Tool/Base/EquTool.cs index fee78f1..e9be574 100644 --- a/Service/Application.Domain/Tool/Base/EquTool.cs +++ b/Service/Application.Domain/Tool/Base/EquTool.cs @@ -7,19 +7,19 @@ public class EquTool //强化 equ = GetIntensifyAttr(equ); List AttrData = GetUserEquAttrData(equ); - equ.minAtk += Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.Atk), AttrData, (decimal)equ.minAtk)); + equ.minAtk += Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Atk), AttrData, (decimal)equ.minAtk)); equ.minAtk += - Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.MinAtk), AttrData, (decimal)equ.minAtk)); - equ.maxAtk += Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.Atk), AttrData, (decimal)equ.maxAtk)); + Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.MinAtk), AttrData, (decimal)equ.minAtk)); + equ.maxAtk += Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Atk), AttrData, (decimal)equ.maxAtk)); equ.maxAtk += - Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.MaxAtk), AttrData, (decimal)equ.minAtk)); - equ.Blood += Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.Blood), AttrData, (decimal)equ.Blood)); + Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.MaxAtk), AttrData, (decimal)equ.minAtk)); + equ.Blood += Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Blood), AttrData, (decimal)equ.Blood)); equ.Defense += - Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.Defense), AttrData, (decimal)equ.Defense)); + Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Defense), AttrData, (decimal)equ.Defense)); equ.Agility += - Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.Agility), AttrData, (decimal)equ.Agility)); + Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Agility), AttrData, (decimal)equ.Agility)); equ.Morale += - Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.Morale), AttrData, (decimal)equ.Morale)); + Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Morale), AttrData, (decimal)equ.Morale)); return equ; } @@ -123,7 +123,7 @@ public class EquTool return Convert.ToInt32(result + onAttr); } - private static List GetUserEquAttrData(unit_user_equ equ) + public static List GetUserEquAttrData(unit_user_equ equ) { List AttrData = new List(); //装备本身特性 @@ -162,37 +162,5 @@ public class EquTool return AttrData; } - public static decimal GetAttrItemValue(string attrCode, List AttrData, decimal unit) - { - decimal result = 0.00M; - foreach (var item in AttrData) - { - if (attrCode == item.code) - { - if (string.IsNullOrEmpty(item.compute)) - { - continue; - } - - if (item.compute == nameof(GameEnum.ComputeType.Ride)) - { - result += unit * Convert.ToDecimal(item.parameter); - } - else if (item.compute == nameof(GameEnum.ComputeType.Plus)) - { - result += Convert.ToDecimal(item.parameter); - } - else if (item.compute == nameof(GameEnum.ComputeType.Reduce)) - { - result = unit - Convert.ToDecimal(item.parameter); - } - else if (item.compute == nameof(GameEnum.ComputeType.Except)) - { - result = unit / Convert.ToDecimal(item.parameter); - } - } - } - - return result; - } + } \ No newline at end of file diff --git a/Service/Application.Domain/Tool/Base/GameAttrTool.cs b/Service/Application.Domain/Tool/Base/GameAttrTool.cs new file mode 100644 index 0000000..0ac0e1e --- /dev/null +++ b/Service/Application.Domain/Tool/Base/GameAttrTool.cs @@ -0,0 +1,170 @@ +namespace Application.Domain; + +public class GameAttrTool +{ + public static UserAttrModel GetRoleAttrTemp(UserAttrModel temp, List attrData) + { + UserAttrModel result = new UserAttrModel(); + result.minAtk = + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Atk.ToString(), attrData, temp.minAtk)); + result.maxAtk = + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Atk.ToString(), attrData, temp.maxAtk)); + result.defense = + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Defense.ToString(), attrData, temp.defense)); + result.agility = + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Agility.ToString(), attrData, temp.agility)); + result.upBlood = + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Blood.ToString(), attrData, temp.upBlood)); + result.upMorale = + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Morale.ToString(), attrData, temp.upMorale)); + result.InBlood = GetAttrItemValue(GameEnum.AttrCode.InBlood.ToString(), attrData, temp.InBlood); + result.Crit = GetAttrItemValue(GameEnum.AttrCode.Crit.ToString(), attrData, temp.Crit); + result.NoHarm = GetAttrItemValue(GameEnum.AttrCode.NoHarm.ToString(), attrData, temp.NoHarm); + result.Dodge = GetAttrItemValue(GameEnum.AttrCode.Dodge.ToString(), attrData, temp.Dodge); + result.Rebound = GetAttrItemValue(GameEnum.AttrCode.Rebound.ToString(), attrData, temp.Rebound); + result.ReboundLess = + GetAttrItemValue(GameEnum.AttrCode.ReboundLess.ToString(), attrData, temp.ReboundLess); + result.Punish = GetAttrItemValue(GameEnum.AttrCode.Punish.ToString(), attrData, temp.Punish); + result.Slow = GetAttrItemValue(GameEnum.AttrCode.Slow.ToString(), attrData, temp.Slow); + result.SlowLess = GetAttrItemValue(GameEnum.AttrCode.SlowLess.ToString(), attrData, temp.SlowLess); + result.Poison = GetAttrItemValue(GameEnum.AttrCode.Poison.ToString(), attrData, temp.Poison); + result.PoisonLess = + GetAttrItemValue(GameEnum.AttrCode.PoisonLess.ToString(), attrData, temp.PoisonLess); + result.Curse = GetAttrItemValue(GameEnum.AttrCode.Curse.ToString(), attrData, temp.Curse); + result.CurseLess = GetAttrItemValue(GameEnum.AttrCode.CurseLess.ToString(), attrData, temp.CurseLess); + result.Weaken = GetAttrItemValue(GameEnum.AttrCode.Weaken.ToString(), attrData, temp.Weaken); + result.WeakenLess = + GetAttrItemValue(GameEnum.AttrCode.WeakenLess.ToString(), attrData, temp.WeakenLess); + result.Deadly = GetAttrItemValue(GameEnum.AttrCode.Deadly.ToString(), attrData, temp.Deadly); + result.DeadlyLess = + GetAttrItemValue(GameEnum.AttrCode.DeadlyLess.ToString(), attrData, temp.DeadlyLess); + result.Depressed = GetAttrItemValue(GameEnum.AttrCode.Depressed.ToString(), attrData, temp.Depressed); + result.DepressedLess = + GetAttrItemValue(GameEnum.AttrCode.DepressedLess.ToString(), attrData, temp.DepressedLess); + result.Breach = GetAttrItemValue(GameEnum.AttrCode.Breach.ToString(), attrData, temp.Breach); + result.BreachLess = + GetAttrItemValue(GameEnum.AttrCode.BreachLess.ToString(), attrData, temp.BreachLess); + result.Del_Fashion = + GetAttrItemValue(GameEnum.AttrCode.Del_Fashion.ToString(), attrData, temp.Del_Fashion); + result.Atk_Next = GetAttrItemValue(GameEnum.AttrCode.Atk_Next.ToString(), attrData, temp.Atk_Next); + result.Harm_Add = GetAttrItemValue(GameEnum.AttrCode.Harm_Add.ToString(), attrData, temp.Harm_Add); + result.PalsyAtk = GetAttrItemValue(GameEnum.AttrCode.PalsyAtk.ToString(), attrData, temp.PalsyAtk); + result.PalsyAtkLess = + GetAttrItemValue(GameEnum.AttrCode.PalsyAtkLess.ToString(), attrData, temp.PalsyAtk); + + return result; + } + + public static UserAttrModel GetRoleAttrTempMerge(UserAttrModel result, List attrData) + { + result.minAtk += + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Atk.ToString(), attrData, result.minAtk)); + result.maxAtk += + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Atk.ToString(), attrData, result.maxAtk)); + result.defense += + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Defense.ToString(), attrData, result.defense)); + result.agility += + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Agility.ToString(), attrData, result.agility)); + result.upBlood += + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Blood.ToString(), attrData, result.upBlood)); + result.upMorale += + Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Morale.ToString(), attrData, result.upMorale)); + result.InBlood += GetAttrItemValue(GameEnum.AttrCode.InBlood.ToString(), attrData, 0); + result.Crit += GetAttrItemValue(GameEnum.AttrCode.Crit.ToString(), attrData, 0); + result.NoHarm += GetAttrItemValue(GameEnum.AttrCode.NoHarm.ToString(), attrData, 0); + result.Dodge += GetAttrItemValue(GameEnum.AttrCode.Dodge.ToString(), attrData, 0); + result.Rebound += GetAttrItemValue(GameEnum.AttrCode.Rebound.ToString(), attrData, 0); + result.ReboundLess += GetAttrItemValue(GameEnum.AttrCode.ReboundLess.ToString(), attrData, 0); + result.Punish += GetAttrItemValue(GameEnum.AttrCode.Punish.ToString(), attrData, 0); + result.Slow += GetAttrItemValue(GameEnum.AttrCode.Slow.ToString(), attrData, 0); + result.SlowLess += GetAttrItemValue(GameEnum.AttrCode.SlowLess.ToString(), attrData, 0); + result.Poison += GetAttrItemValue(GameEnum.AttrCode.Poison.ToString(), attrData, 0); + result.PoisonLess += GetAttrItemValue(GameEnum.AttrCode.PoisonLess.ToString(), attrData, 0); + result.Curse += GetAttrItemValue(GameEnum.AttrCode.Curse.ToString(), attrData, 0); + result.CurseLess += GetAttrItemValue(GameEnum.AttrCode.CurseLess.ToString(), attrData, 0); + result.Weaken += GetAttrItemValue(GameEnum.AttrCode.Weaken.ToString(), attrData, 0); + result.WeakenLess += GetAttrItemValue(GameEnum.AttrCode.WeakenLess.ToString(), attrData, 0); + result.Deadly += GetAttrItemValue(GameEnum.AttrCode.Deadly.ToString(), attrData, 0); + result.DeadlyLess += GetAttrItemValue(GameEnum.AttrCode.DeadlyLess.ToString(), attrData, 0); + result.Depressed += GetAttrItemValue(GameEnum.AttrCode.Depressed.ToString(), attrData, 0); + result.DepressedLess += GetAttrItemValue(GameEnum.AttrCode.DepressedLess.ToString(), attrData, 0); + result.Breach += GetAttrItemValue(GameEnum.AttrCode.Breach.ToString(), attrData, 0); + result.BreachLess += GetAttrItemValue(GameEnum.AttrCode.BreachLess.ToString(), attrData, 0); + result.Del_Fashion += GetAttrItemValue(GameEnum.AttrCode.Del_Fashion.ToString(), attrData, 0); + result.Atk_Next += GetAttrItemValue(GameEnum.AttrCode.Atk_Next.ToString(), attrData, 0); + result.Harm_Add += GetAttrItemValue(GameEnum.AttrCode.Harm_Add.ToString(), attrData, 0); + result.PalsyAtk += GetAttrItemValue(GameEnum.AttrCode.PalsyAtk.ToString(), attrData, 0); + result.PalsyAtkLess += GetAttrItemValue(GameEnum.AttrCode.PalsyAtkLess.ToString(), attrData, 0); + + return result; + } + + public static UserAttrModel GetRoleAttrTempMerge(UserAttrModel main, UserAttrModel vice) + { + main.minAtk += vice.minAtk; + main.maxAtk += vice.maxAtk; + main.defense += vice.defense; + main.agility += vice.agility; + main.upBlood += vice.upBlood; + main.upMorale += vice.upMorale; + main.InBlood += vice.InBlood; + main.Crit += vice.Crit; + main.NoHarm += vice.NoHarm; + main.Dodge += vice.Dodge; + main.Rebound += vice.Rebound; + main.ReboundLess += vice.ReboundLess; + main.Punish += vice.Punish; + main.Slow += vice.Slow; + main.Poison += vice.Poison; + main.PoisonLess += vice.PoisonLess; + main.Curse += vice.Curse; + main.CurseLess += vice.CurseLess; + main.Weaken += vice.Weaken; + main.WeakenLess += vice.WeakenLess; + main.Deadly += vice.Deadly; + main.DeadlyLess += vice.DeadlyLess; + main.Depressed += vice.Depressed; + main.DepressedLess += vice.DepressedLess; + main.Breach += vice.Breach; + main.BreachLess += vice.BreachLess; + main.Del_Fashion += vice.Del_Fashion; + main.Atk_Next += vice.Atk_Next; + main.Harm_Add += vice.Harm_Add; + main.PalsyAtk += vice.PalsyAtk; + main.PalsyAtkLess += vice.PalsyAtkLess; + return main; + } + public static decimal GetAttrItemValue(string attrCode, List AttrData, decimal unit) + { + decimal result = 0.00M; + foreach (var item in AttrData) + { + if (attrCode == item.code) + { + if (string.IsNullOrEmpty(item.compute)) + { + continue; + } + + if (item.compute == nameof(GameEnum.ComputeType.Ride)) + { + result += unit * Convert.ToDecimal(item.parameter); + } + else if (item.compute == nameof(GameEnum.ComputeType.Plus)) + { + result += Convert.ToDecimal(item.parameter); + } + else if (item.compute == nameof(GameEnum.ComputeType.Reduce)) + { + result = unit - Convert.ToDecimal(item.parameter); + } + else if (item.compute == nameof(GameEnum.ComputeType.Except)) + { + result = unit / Convert.ToDecimal(item.parameter); + } + } + } + + 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 9d53e6e..306d912 100644 --- a/Service/Application.Web/Controllers/Login/LoginController.cs +++ b/Service/Application.Web/Controllers/Login/LoginController.cs @@ -280,6 +280,34 @@ namespace Application.Web.Controllers.Login return PoAction.Ok(new { token = token, refToken = userInfo.token, userId = userInfo.userId }); } + + [HttpPost] + public async Task RefreshTokenByBook([FromBody] RefreshTokenParms parms) + { + if (string.IsNullOrEmpty(parms.refToken)) + { + return PoAction.Message("刷新失败"); + } + + string Key = App.Configuration["JwtTokenOptions:SecurityKey"].ToString(); + string Issuer = App.Configuration["JwtTokenOptions:Issuer"].ToString(); + string Audience = App.Configuration["JwtTokenOptions:Audience"].ToString(); + + var userInfo = await _userService.GetUserInfoByToken(parms.refToken); + if (userInfo == null) + { + return PoAction.Message("刷新失败,用户不存在!"); + } + + Dictionary loadData = new Dictionary(); + loadData.Add("userId", userInfo.userId); + 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/Pub/GoodsController.cs b/Service/Application.Web/Controllers/Pub/GoodsController.cs index 88a278e..8815f20 100644 --- a/Service/Application.Web/Controllers/Pub/GoodsController.cs +++ b/Service/Application.Web/Controllers/Pub/GoodsController.cs @@ -50,6 +50,15 @@ public class GoodsController : ControllerBase case "Weight": UseState = 1; break; + case "State": + UseState = 1; + break; + case "Ship": + UseState = 2; + break; + case "ChoicePack": + UseState = 3; + break; } @@ -85,6 +94,19 @@ public class GoodsController : ControllerBase return PoAction.Message($"该物品{goodsInfo.lev}级才可使用!"); } + #region 必要判定 + + if (goodsInfo.code == nameof(GoodsEnum.Code.Ship)) + { + var myShip = await _weightService.GetUserShip(userId); + if (myShip.Count >= 5) + { + return PoAction.Message($"每人最多拥有5个船只,您已达到上限!"); + } + } + + #endregion + if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, count, "使用物品")) { string message = ""; @@ -119,6 +141,23 @@ public class GoodsController : ControllerBase } else if (goodsInfo.code == nameof(GoodsEnum.Code.State)) { + UserStateModel stateConfig = JsonConvert.DeserializeObject(goodsInfo.content); + await _attrService.AddUserState(userId, goodsInfo.goodsId.ToString(), stateConfig.name, + stateConfig.scene, stateConfig.tips, stateConfig.attr, stateConfig.time, count); + message = $"使用[{goodsInfo.goodsName}]×{count},状态时间+{stateConfig.time * count}分钟"; + } + else if (goodsInfo.code == nameof(GoodsEnum.Code.Ship)) + { + dynamic shipInfo = JsonConvert.DeserializeObject(goodsInfo.content); + string name = shipInfo.name; + int speed = shipInfo.speed; + int weight = shipInfo.weight; + int copper = shipInfo.copper; + long sale = shipInfo.sale; + string remark = shipInfo.remark; + + await _weightService.AddUserShip(userId, name, goodsId, speed, weight, copper, sale, remark); + message = $"使用[{goodsInfo.goodsName}],获得{name}+1"; } return PoAction.Ok(true, message); @@ -128,4 +167,69 @@ public class GoodsController : ControllerBase return PoAction.Message("使用失败,请稍后尝试!"); } } + + /// + /// 使用选择物品礼包 + /// + /// + /// + /// + [HttpGet] + public async Task UseChoiceGoods(int goodsId, int num) + { + string userId = StateHelper.userId; + var goodsInfo = await _goodsService.GetGoodsInfo(goodsId); + if (goodsInfo == null) + { + return PoAction.Message("物品不存在!"); + } + + var MyGoods = await _goodsService.GetUserGoodsCount(userId, goodsId); + if (MyGoods < 1) + { + return PoAction.Message("物品不足!"); + } + + var myLev = await _attrService.GetUserLev(userId); + if (myLev < (int)goodsInfo.lev) + { + return PoAction.Message($"该物品{goodsInfo.lev}级才可使用!"); + } + + if (goodsInfo.code != nameof(GoodsEnum.Code.ChoicePack)) + { + return PoAction.Message("无法使用该物品!"); + } + List choiceGoods = JsonConvert.DeserializeObject>(goodsInfo.content); + var onAward = choiceGoods.Find(it => it.id == num); + if (onAward == null) + { + return PoAction.Message("物品中不包含该选择!"); + } + + + if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, 1, "使用物品")) + { + if (await GameBus.UpdateBag(userId, 1, onAward.award, "打开礼包获取")) + { + string message = $"打开[{goodsInfo.goodsName}],获得:"; + foreach (var item in onAward.award) + { + message += $"{item.name}+{item.count},"; + } + message = message.TrimEnd(','); + + await _messageService.SendBroadcast(userId, nameof(MessageEnum.BroadcastCode.Award), message); + return PoAction.Ok(true, message); + } + else + { + return PoAction.Message("使用失败,请稍后尝试!"); + } + } + else + { + return PoAction.Message("使用失败,请稍后尝试!"); + } + } } \ No newline at end of file diff --git a/Service/Application.Web/Controllers/Pub/ShipController.cs b/Service/Application.Web/Controllers/Pub/ShipController.cs index e2fcb7c..e241a7d 100644 --- a/Service/Application.Web/Controllers/Pub/ShipController.cs +++ b/Service/Application.Web/Controllers/Pub/ShipController.cs @@ -10,14 +10,14 @@ namespace Application.Web.Controllers.Pub [Authorize] public class ShipController : ControllerBase { - private readonly IUnitUserWeight weightService; - private readonly IGameGoodsService goodsService; - private readonly IUnitUserAccService accService; - public ShipController(IUnitUserWeight _weightService, IGameGoodsService _goodsService, IUnitUserAccService _accService) + private readonly IUnitUserWeight _weightService; + private readonly IUnitUserAccService _accService; + + public ShipController(IUnitUserWeight weightService, + IUnitUserAccService accService) { - accService = _accService; - goodsService = _goodsService; - weightService = _weightService; + _accService = accService; + _weightService = weightService; } /// @@ -28,27 +28,11 @@ namespace Application.Web.Controllers.Pub public async Task GetUserShip() { string userId = StateHelper.userId; - var data = await weightService.GetUserShip(userId); + var data = await _weightService.GetUserShip(userId); //个人负重 - var weightInfo = await weightService.GetUserWeightInfo(userId); - return PoAction.Ok(new { data, weightInfo }); - } - - /// - /// 获取船只详情 - /// - /// - /// - [HttpGet] - public async Task GetShipInfo(int shipId) - { - var data = await goodsService.GetShipInfo(shipId); - if (data == null) - { - return PoAction.Message("船只详情不存在!"); - } - - return PoAction.Ok(new { data }); + var weightInfo = await _weightService.GetUserWeightInfo(userId); + var maxShipWeight = await _weightService.GetUserShipMaxWeight(userId); + return PoAction.Ok(new { data, onShip = weightInfo.shipOnWeight, maxShip = maxShipWeight }); } /// @@ -57,46 +41,25 @@ namespace Application.Web.Controllers.Pub /// /// [HttpPost] - public async Task BuyShip([FromBody] BuyShipParms parms) + public async Task SaleShip([FromBody] BuyShipParms parms) { - var userShip = await weightService.GetUserShipInfo(parms.usId); + var userShip = await _weightService.GetUserShipInfo(parms.usId); if (userShip == null) { return PoAction.Message("船只不存在!"); } + string userId = StateHelper.userId; if (userShip.userId != userId) { return PoAction.Message("船只不存在!"); } - var shipInfo = await goodsService.GetShipInfo((int)userShip.goodsId); - if (shipInfo == null) + + if (await _weightService.DeleteUserShip(userShip.usId, userId)) { - return PoAction.Message("船只信息不存在!"); - } - if (await weightService.DeleteUserShip(userShip.usId, userId)) - { - if (shipInfo.payType == AccEnum.AccType.copper.ToString()) + if (await _accService.UpdateUserCopper(userId, 1, Convert.ToInt64(userShip.sale), "出售船只获得!")) { - if (await accService.UpdateUserCopper(userId, 1, Convert.ToInt64(shipInfo.salePrice), "出售船只获得!")) - { - return PoAction.Ok(new { price = shipInfo.salePrice }); - } - else - { - return PoAction.Message("出售失败!"); - } - } - else if (shipInfo.payType == AccEnum.AccType.gold.ToString()) - { - if (await accService.UpdateUserAcc(userId, 1, AccEnum.AccType.gold.ToString(), Convert.ToInt64(shipInfo.salePrice))) - { - return PoAction.Ok(new { price = shipInfo.salePrice }); - } - else - { - return PoAction.Message("出售失败!"); - } + return PoAction.Ok(new { price = userShip.sale }); } else { @@ -109,4 +72,4 @@ namespace Application.Web.Controllers.Pub } } } -} +} \ No newline at end of file diff --git a/Service/Application.Web/Controllers/User/BagController.cs b/Service/Application.Web/Controllers/User/BagController.cs index 3d0dda9..7d8e1c2 100644 --- a/Service/Application.Web/Controllers/User/BagController.cs +++ b/Service/Application.Web/Controllers/User/BagController.cs @@ -100,6 +100,7 @@ public class BagController : ControllerBase break; case 4: code.Add(nameof(GoodsEnum.Code.Pack)); + code.Add(nameof(GoodsEnum.Code.ChoicePack)); break; case 5: code.Add(nameof(GoodsEnum.Code.Mak)); diff --git a/Service/Application.Web/Controllers/User/UserController.cs b/Service/Application.Web/Controllers/User/UserController.cs index ee8d9bf..13e7d4c 100644 --- a/Service/Application.Web/Controllers/User/UserController.cs +++ b/Service/Application.Web/Controllers/User/UserController.cs @@ -17,11 +17,12 @@ public class UserController : ControllerBase private readonly IGameChatService _chatService; private readonly IGameSkillService _skillService; private readonly IGameTeamService _teamService; + private readonly IGameEquService _equService; public UserController(IUnitUserService userService, IUnitUserAttrService attrService, IUnitUserAccService accService, IGameMapService mapService, IUnitUserRelationService relationService, IGameGoodsService goodsService, IGameChatService chatService, IGameSkillService skillService, - IGameTeamService teamService) + IGameTeamService teamService, IGameEquService equService) { _userService = userService; _attrService = attrService; @@ -32,6 +33,7 @@ public class UserController : ControllerBase _chatService = chatService; _skillService = skillService; _teamService = teamService; + _equService = equService; } @@ -52,7 +54,10 @@ public class UserController : ControllerBase var vigourInfo = await _attrService.GetUserVigourInfo(userId); var accInfo = await _accService.GetUserAccInfo(userId); object acc = new { accInfo.gold, accInfo.cowry, accInfo.teach, accInfo.renown }; - object result = new { user, attr = attrInfo, exp, vigourInfo.vitality, acc }; + + var buff = await _attrService.GetUserStateData(userId,"ALL"); + + object result = new { user, attr = attrInfo, exp, vigourInfo.vitality, acc,buff }; return PoAction.Ok(result); } @@ -165,7 +170,13 @@ public class UserController : ControllerBase bool isFriend = await _relationService.CheckIsFriend(userId, userInfo.userId); bool isEnemy = await _relationService.CheckUserEnemy(userId, userInfo.userId); var team = await _teamService.GetUserTeamInfo(userInfo.userId); - object result = new { user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy, team }; + + var equ = await _equService.GetUserOnEqu(userInfo.userId); + var suit = await _equService.GetUserEquSuit(userInfo.userId); + object result = new + { + user, attr = new { attrInfo.lev }, acc, isOnline, onMapName, isFriend, isEnemy, team, equ,suit + }; return PoAction.Ok(result); } @@ -408,7 +419,7 @@ public class UserController : ControllerBase } else { - return PoAction.Message("添加失败,请稍后尝试!"); + return PoAction.Message("添加失败,请稍后尝试!"); } } else diff --git a/Service/Application.Web/GlobalUsings.cs b/Service/Application.Web/GlobalUsings.cs index 7482651..09c4cb9 100644 --- a/Service/Application.Web/GlobalUsings.cs +++ b/Service/Application.Web/GlobalUsings.cs @@ -13,5 +13,4 @@ global using Microsoft.AspNetCore.Authorization; global using Microsoft.AspNetCore.Mvc; global using Application.Web; - \ No newline at end of file diff --git a/Web/src/extends/PageExtend.ts b/Web/src/extends/PageExtend.ts index 5acfcc1..2cde0c1 100644 --- a/Web/src/extends/PageExtend.ts +++ b/Web/src/extends/PageExtend.ts @@ -7,6 +7,10 @@ export class PageExtend { navigateTo(route, { replace: true }) } + public static GetPath(): string { + const route = useRoute() + return route.fullPath; + } public static QueryString(params: string): string { const route = useRoute() const value = route.query[params] diff --git a/Web/src/pages/prop/goods.vue b/Web/src/pages/prop/goods.vue index 60e4ed4..be500cc 100644 --- a/Web/src/pages/prop/goods.vue +++ b/Web/src/pages/prop/goods.vue @@ -23,6 +23,12 @@
使用物品
+
+ 使用物品 +
+
+ 使用物品 +
@@ -41,7 +47,7 @@ -
+
物品名称:{{ data.goodsName }}
物品数量:{{ count }}
@@ -50,6 +56,28 @@
+ + +
+ 物品名称:{{ data.goodsName }}
+ 物品数量:{{ count }}
+
+
+ +
+
+ + +
+
+
+ {{ item.id }}.{{ item.name }} + 选择 +
+
+
+
+
\ No newline at end of file diff --git a/Web/src/pages/user/index.vue b/Web/src/pages/user/index.vue index d67f512..3b08a59 100644 --- a/Web/src/pages/user/index.vue +++ b/Web/src/pages/user/index.vue @@ -25,6 +25,14 @@ 活力:{{ vitality }}
罪恶值:0
帮派:无
+
+ ---◈BUFF状态◈---
+
+ ✧{{item.name}}:{{item.tips}}(剩余{{ item.endTime - TimeExtend.GetSecondStamp() }}秒) +
+ +
+ @@ -58,6 +66,7 @@ const vitality = ref(0); const expData = ref({}); const attrData = ref({}); const accData = ref({}); +const buff = ref([]); onMounted(async () => { try { @@ -78,6 +87,7 @@ const BindData = async (): Promise => { expData.value = result.data.exp; attrData.value = result.data.attr; accData.value = result.data.acc; + buff.value = result.data.buff; console.log(result); } else { diff --git a/Web/src/pages/user/setting/index.vue b/Web/src/pages/user/setting/index.vue index 7add47e..d696e12 100644 --- a/Web/src/pages/user/setting/index.vue +++ b/Web/src/pages/user/setting/index.vue @@ -21,6 +21,9 @@
刷新图标(*更新图标数据)
+
+ ➣我的书签 +
diff --git a/Web/src/pages/user/ship/index.vue b/Web/src/pages/user/ship/index.vue index 0061996..29875c8 100644 --- a/Web/src/pages/user/ship/index.vue +++ b/Web/src/pages/user/ship/index.vue @@ -1,10 +1,10 @@