diff --git a/Kx.SeaTime.sln.DotSettings.user b/Kx.SeaTime.sln.DotSettings.user index 5f75113..9879620 100644 --- a/Kx.SeaTime.sln.DotSettings.user +++ b/Kx.SeaTime.sln.DotSettings.user @@ -6,4 +6,5 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded \ No newline at end of file diff --git a/Service/Application.Domain.Entity/log/db/unit_user_equ_log.cs b/Service/Application.Domain.Entity/log/db/unit_user_equ_log.cs new file mode 100644 index 0000000..4e1e488 --- /dev/null +++ b/Service/Application.Domain.Entity/log/db/unit_user_equ_log.cs @@ -0,0 +1,29 @@ +using SqlSugar; +using System; + +namespace Application.Domain.Entity; + +[SplitTable(SplitType.Day)] +[SugarTable("unit_user_equ_log_{year}{month}{day}")] +[Tenant("Kg.SeaTime.Log")] +public class unit_user_equ_log +{ + [SugarColumn(IsPrimaryKey = true)] public string logId { get; set; } + + + [SugarColumn(Length = 50, IsNullable = true)] + public string? ueId { get; set; } + + public int? equId { get; set; } + + [SugarColumn(Length = 50, IsNullable = true)] + public string? code { get; set; } + + [SugarColumn(ColumnDataType = "varchar(max)", IsNullable = true, IsJson = true)] + public unit_user_equ? equData { get; set; } + + [SugarColumn(Length = 255, IsNullable = true)] + public string? remark { get; set; } + + public DateTime? addTime { 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 new file mode 100644 index 0000000..bcd638e --- /dev/null +++ b/Service/Application.Domain.Entity/model/UserAttrModel.cs @@ -0,0 +1,57 @@ +namespace Application.Domain.Entity; + + public class UserAttrModel + { + public string id { get; set; } + public int area { get; set; } + public int IsSystem { get; set; } + public int isCopy { get; set; } + public string viceId { get; set; } + public string name { get; set; } + public int figState { get; set; } + public string sex { get; set; } + public string code { get; set; } + public string remark { get; set; } + public string TmImg { get; set; } + public int lev { get; set; }//等级 + public decimal minAtk { get; set; }//最小攻击 + public decimal maxAtk { get; set; }//最大攻击 + public decimal defense { get; set; }//防御 + public decimal agility { get; set; }//敏捷 + public decimal blood { get; set; }//血量 + public decimal upBlood { get; set; }//最大血量 + public decimal morale { get; set; }//士气 + public decimal upMorale { get; set; }//最大士气 + public decimal score { get; set; }//评分 + public decimal InBlood { get; set; }//吸血 + public decimal Crit { get; set; }//暴击 + public decimal NoHarm { get; set; }//免伤 + public decimal Dodge { get; set; }//闪避 + public decimal Rebound { get; set; }//反弹 + public decimal ReboundLess { get; set; }//抗反弹 + public decimal Punish { get; set; }//制裁 + public decimal Slow { get; set; }//迟缓 + public decimal SlowLess { get; set; }//迟缓 + public decimal Poison { get; set; }//毒攻 + public decimal PoisonLess { get; set; }//抗毒攻 + public decimal Curse { get; set; }//诅咒 + public decimal CurseLess { get; set; }//抗诅咒 + public decimal Weaken { get; set; }//虚弱 + public decimal WeakenLess { get; set; }//抗虚弱 + public decimal Deadly { get; set; }//致命 + public decimal DeadlyLess { get; set; }//抗致命 + public decimal Depressed { get; set; }//消沉 + public decimal DepressedLess { get; set; }//抗消沉 + public decimal Breach { get; set; }//突破 + public decimal BreachLess { get; set; }//抗突破 + public decimal Del_Fashion { get; set; }//卸时装 + public decimal Atk_Next { get; set; }//连击 + public decimal Harm_Add { get; set; }//额外伤害 + public decimal PalsyAtk { get; set; }//麻痹 + public decimal PalsyAtkLess { get; set; }//抗麻痹 + public string atkTips { get; set; } + public string defTips { get; set; } + public string agilityTips { get; set; } + public string moraleTips { get; set; } + public string bloodTips { get; set; } + } \ No newline at end of file diff --git a/Service/Application.Domain/Config/GameConfig.cs b/Service/Application.Domain/Config/GameConfig.cs index 67100c4..93fc949 100644 --- a/Service/Application.Domain/Config/GameConfig.cs +++ b/Service/Application.Domain/Config/GameConfig.cs @@ -2,8 +2,11 @@ public static class GameConfig { + public const int GameMaxLev = 320;//最大等级 public const int OnLineTime = 30;//在线延迟时间(分钟) public const int SendChatGoodsBase = 10014;//小海螺 public const int SendChatGoodsArea = 10001;//大海螺 public const int SendChatGoodsService = 10002;//金海螺 + public const int UpLevAddWeight = 10;//升级增加负重 + public const int GameBaseVigour = 50;//初始活力 } \ No newline at end of file diff --git a/Service/Application.Domain/Enum/AccEnum.cs b/Service/Application.Domain/Enum/AccEnum.cs new file mode 100644 index 0000000..6212277 --- /dev/null +++ b/Service/Application.Domain/Enum/AccEnum.cs @@ -0,0 +1,33 @@ +namespace Application.Domain; + +public static class AccEnum +{ + public enum AccType + { + copper,//铜 + cowry,//海贝 + gold,//金 + teach,//师德 + renown,//声望 + charm,//魅力 + evil,//罪恶值 + } + public enum Name + { + 其他, + 充值, + 活动, + 推广, + 福利, + 爵位, + Npc商城, + 系统商城, + 花店 + } + + public enum Code + { + 减少, + 增加 + } +} \ No newline at end of file diff --git a/Service/Application.Domain/Enum/UserEnum.cs b/Service/Application.Domain/Enum/UserEnum.cs new file mode 100644 index 0000000..f3596d2 --- /dev/null +++ b/Service/Application.Domain/Enum/UserEnum.cs @@ -0,0 +1,9 @@ +namespace Application.Domain; + +public static class UserEnum +{ + public enum AttrCode + { + Person + } +} \ No newline at end of file diff --git a/Service/Application.Domain/Services/Interface/User/IUnitUserAccService.cs b/Service/Application.Domain/Services/Interface/User/IUnitUserAccService.cs new file mode 100644 index 0000000..12d4b9d --- /dev/null +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserAccService.cs @@ -0,0 +1,21 @@ +namespace Application.Domain; + +public interface IUnitUserAccService +{ + Task GetUserAccInfo(string userId, string accType); + + #region 账户操作 + + Task GetUserAccInfo(string userId); + + Task UpdateUserAcc(string userId, int type, string accType, long count, string name = "", + string remark = ""); + + Task UpdateUserAccBath(string userId, int type, string accType, long count, string name = "", + string remark = ""); + + Task GetUserCopperInfo(string userId); + Task UpdateUserCopper(string userId, int type, 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 713f363..ca16324 100644 --- a/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Interface/User/IUnitUserAttrService.cs @@ -2,6 +2,39 @@ public interface IUnitUserAttrService { + #region 个人属性 + + Task GetUserAttrModel(string userId); + Task GetUserAttr(string userId); + + #endregion + + #region 体力操作 + Task GetUserBlood(string userId); Task UpdateUserBlood(string userId, int op, int count, bool mustUp = false); + + #endregion + + #region 经验操作 + + Task GetUserExp(string userId); + Task UpdateUserExp(string userId, long exp, int op = 1); + + #endregion + + #region 士气操作 + + Task GetUserMorale(string userId); + Task UpdateUserMorale(string userId, int op, int count); + + #endregion + + #region 活力 + + Task GetUserVigourInfo(string userId); + Task UpdateUserVigour(string userId, int op, decimal count, string UpTime = ""); + Task UpdateUserUpVigour(string userId, decimal count); + + #endregion } \ No newline at end of file diff --git a/Service/Application.Domain/Services/Service/User/UnitUserAccService.cs b/Service/Application.Domain/Services/Service/User/UnitUserAccService.cs new file mode 100644 index 0000000..5a2cac0 --- /dev/null +++ b/Service/Application.Domain/Services/Service/User/UnitUserAccService.cs @@ -0,0 +1,137 @@ +namespace Application.Domain; + +public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : IUnitUserAccService, ITransient +{ + public async Task GetUserAccInfo(string userId, string accType) + { + long result = 0; + if (accType == AccEnum.AccType.copper.ToString()) + { + var info = await GetUserCopperInfo(userId); + result = (long)info.copper; + } + else if (accType == AccEnum.AccType.cowry.ToString()) + { + var info = await GetUserAccInfo(userId); + result = (long)info.cowry; + } + else if (accType == AccEnum.AccType.gold.ToString()) + { + var info = await GetUserAccInfo(userId); + result = (long)info.gold; + } + else if (accType == AccEnum.AccType.teach.ToString()) + { + var info = await GetUserAccInfo(userId); + result = (long)info.teach; + } + else if (accType == AccEnum.AccType.renown.ToString()) + { + var info = await GetUserAccInfo(userId); + result = (long)info.renown; + } + + return result; + } + + #region 账户操作 + + public async Task GetUserAccInfo(string userId) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(i => i.userId == userId).SingleAsync(); + } + + + public async Task UpdateUserAcc(string userId, int type, string accType, long count, string name = "", + 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(AccEnum.AccType.cowry.ToString()), it => it.cowry == it.cowry + opCount) + .SetColumnsIF(accType.Equals(AccEnum.AccType.gold.ToString()), it => it.gold == it.gold + opCount) + .SetColumnsIF(accType.Equals(AccEnum.AccType.teach.ToString()), it => it.teach == it.teach + opCount) + .SetColumnsIF(accType.Equals(AccEnum.AccType.renown.ToString()), it => it.renown == it.renown + opCount) + .Where(it => it.userId == userId).ExecuteCommandAsync() > 0; + //生成日志 + if (isOk) + { + string code = type == 0 ? nameof(AccEnum.Code.减少) : nameof(AccEnum.Code.增加); + unit_user_acc_log userAccLog = new unit_user_acc_log(); + userAccLog.accId = StringAssist.NewGuid; + userAccLog.userId = userId; + userAccLog.accType = accType; + userAccLog.code = code; + userAccLog.name = name; + userAccLog.amount = count; + userAccLog.addTime = DateTime.Now; + userAccLog.endTime = DateTime.Now.AddDays(3); + userAccLog.remark = remark; + await db.Insertable(userAccLog).ExecuteCommandAsync(); + } + + await DbClient.AsTenant().CommitTranAsync(); + } + catch + { + isOk = false; + await DbClient.AsTenant().RollbackTranAsync(); + } + + return isOk; + } + + public async Task UpdateUserAccBath(string userId, int type, string accType, long count, string name = "", + string remark = "") + { + bool result = false; + if (accType == nameof(AccEnum.AccType.copper)) + { + result = await UpdateUserCopper(userId, type, count, remark); + } + else + { + result = await UpdateUserAcc(userId, type, accType, count, name, remark); + } + + return result; + } + + + public async Task GetUserCopperInfo(string userId) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(i => i.userId == userId).SingleAsync(); + } + + public async Task UpdateUserCopper(string userId, int type, 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() + .SetColumns(it => it.copper == it.copper + 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 3021c3f..2c6c8de 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserAttrService.cs @@ -2,11 +2,62 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : IUnitUserAttrService, ITransient { + #region 个人属性 + + public async Task GetUserAttrModel(string userId) + { + UserAttrModel result = new UserAttrModel(); + result.id = userId; + var userService = App.GetService(); + var userInfo = await userService.GetUserInfoByUserId(userId); + result.viceId = userInfo.userNo; + result.name = userInfo.nick; + result.area = (int)userInfo.areaId; + result.IsSystem = (int)userInfo.isSystem; + result.sex = userInfo.sex; + result.code = nameof(UserEnum.AttrCode.Person); + var unitAttr = await GetUserAttr(userId); + result.lev = (int)unitAttr.lev; + result.minAtk = (decimal)unitAttr.minAtk; + result.maxAtk = (decimal)unitAttr.maxAtk; + result.defense = (decimal)unitAttr.defense; + result.agility = (decimal)unitAttr.agility; + result.upBlood = (decimal)unitAttr.upBlood; + result.upMorale = (decimal)unitAttr.upMorale; + result.blood = 1; + result.morale = 1; + + return result; + } + + public async Task GetUserAttr(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "UserAttr"); + var data = await redis.GetHashAsync(key, userId); + if (data == null) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(it => it.userId == userId).SingleAsync(); + await redis.AddHashAsync(key, userId, data); + } + + return data; + } + + private async Task ClearUserAttrCache(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "UserAttr"); + await redis.DelHashAsync(key, userId); + } + + #endregion + + + #region 体力操作 - #region 体力操作 public async Task GetUserBlood(string userId) { - string key = string.Format(UserCache.BaseCacheKeys, "AttrData","Blood"); + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "Blood"); var data = await redis.GetHashAsync(key, userId); if (data == null) { @@ -14,6 +65,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : data = await db.Queryable().Where(it => it.userId == userId).SingleAsync(); await redis.AddHashAsync(key, userId, data); } + return data; } @@ -21,7 +73,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : { bool result = false; unit_user_blood data = new unit_user_blood(); - string key = string.Format(UserCache.BaseCacheKeys, "AttrData","Blood"); + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "Blood"); if (op == 2) { data.userId = userId; @@ -55,8 +107,207 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : return result; } - #endregion - + + + #region 经验操作 + + public async Task GetUserExp(string userId) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + return await db.Queryable().Where(it => it.userId == userId).SingleAsync(); + } + + + public async Task UpdateUserExp(string userId, long exp, int op = 1) + { + bool result = false; + bool IsUpUserAttr = false; + try + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + await DbClient.AsTenant().BeginTranAsync(); + if (op == 0) //扣除经验 + { + result = await db.Updateable().SetColumns(it => it.exp == it.exp - exp) + .Where(it => it.userId == userId).ExecuteCommandAsync() > 0; + } + else //增加经验 + { + var MyExp = await db.Queryable().Where(it => it.userId == userId).SingleAsync(); + long onExp = (long)MyExp.exp + exp; + if (onExp < MyExp.upExp) //不足升级 + { + result = await db.Updateable().SetColumns(it => it.exp == onExp) + .Where(it => it.userId == userId).ExecuteCommandAsync() > 0; + } + else //足够升级 + { + var myAttr = await GetUserAttr(userId); + int OnLev = (int)myAttr.lev + 1; + if (OnLev <= GameConfig.GameMaxLev) + { + long upExp = onExp - (long)MyExp.upExp; + decimal nextExp = GameTool.GetUserUpExp(OnLev); + result = await db.Updateable().SetColumns(it => it.exp == upExp) + .SetColumns(it => it.upExp == nextExp).Where(it => it.userId == userId) + .ExecuteCommandAsync() > 0; + if (result) //更新成功,更新各项属性 + { + var data = GameTool.GetAttrData(OnLev); + result = await db.Updateable(data).Where(i => i.userId == userId) + .ExecuteCommandAsync() > 0; + int upVigour = GameConfig.GameBaseVigour + (OnLev * 10); + await UpdateUserUpVigour(userId, upVigour); + IsUpUserAttr = result; + } + } + else + { + decimal maxOnExp = (decimal)MyExp.upExp - 1; + if ((decimal)MyExp.exp < maxOnExp) + { + result = await db.Updateable().SetColumns(it => it.exp == maxOnExp) + .Where(it => it.userId == userId).ExecuteCommandAsync() > 0; + } + } + } + } + + await DbClient.AsTenant().CommitTranAsync(); + } + catch + { + result = false; + await DbClient.AsTenant().RollbackTranAsync(); + } + + if (result && IsUpUserAttr) + { + //增加负重 + var wightService = App.GetService(); + await wightService.UpdateUserMaxWeight(userId, 1, GameConfig.UpLevAddWeight); + await ClearUserAttrCache(userId); + } + + return result; + } + + #endregion 经验操作 + + #region 士气 + + public async Task GetUserMorale(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "Morale"); + var data = await redis.GetHashAsync(key, userId); + if (data == null) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(it => it.userId == userId).SingleAsync(); + await redis.AddHashAsync(key, userId, data); + } + + return data; + } + + public async Task UpdateUserMorale(string userId, int op, int count) + { + bool result = false; + var data = await GetUserMorale(userId); + if (op == 1) + { + data.morale += count; + } + else if (op == 2) + { + data.morale = count; + } + else + { + data.morale -= count; + } + + data.morale = data.morale < 0 ? 0 : data.morale; + + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "Morale"); + await redis.AddHashAsync(key, userId, data); + + var db = DbClient.AsTenant().GetConnectionWithAttr(); + result = await db.Updateable().SetColumns(it => it.morale == data.morale) + .Where(it => it.userId == userId).ExecuteCommandAsync() > 0; + return result; + } + + #endregion 士气 + + #region 活力 + + public async Task GetUserVigourInfo(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "Vigour"); + var data = await redis.GetHashAsync(key, userId); + if (data == null) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + data = await db.Queryable().Where(i => i.userId == userId).SingleAsync(); + if (data != null) + { + await redis.AddHashAsync(key, userId, data); + } + } + + return data; + } + + private async Task ClearUserVigourCache(string userId) + { + string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "Vigour"); + await redis.DelHashAsync(key, userId); + } + + public async Task UpdateUserVigour(string userId, int op, decimal count, string UpTime = "") + { + bool result = false; + try + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + await DbClient.AsTenant().BeginTranAsync(); + result = await db.Updateable() + .SetColumnsIF(op == 0, it => it.vitality == it.vitality - count) + .SetColumnsIF(op == 1, it => it.vitality == it.vitality + count) + .SetColumnsIF(op == 2, it => it.vitality == count) + .SetColumnsIF(!string.IsNullOrEmpty(UpTime), it => it.upTime == UpTime) + .Where(it => it.userId == userId).ExecuteCommandAsync() > 0; + await DbClient.AsTenant().CommitTranAsync(); + } + catch + { + result = false; + await DbClient.AsTenant().RollbackTranAsync(); + } + + if (result) + { + await ClearUserVigourCache(userId); + } + + return result; + } + + public async Task UpdateUserUpVigour(string userId, decimal count) + { + var db = DbClient.AsTenant().GetConnectionWithAttr(); + bool isok = await db.Updateable().SetColumns(i => i.upVitality == count) + .Where(i => i.userId == userId).ExecuteCommandAsync() > 0; + if (isok) + { + await ClearUserVigourCache(userId); + } + + return isok; + } + + #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 84446b7..471637a 100644 --- a/Service/Application.Domain/Services/Service/User/UnitUserService.cs +++ b/Service/Application.Domain/Services/Service/User/UnitUserService.cs @@ -191,8 +191,8 @@ public class UnitUserService : IUnitUserService, ITransient //注册活力 unit_user_vigour vitality = new unit_user_vigour(); vitality.userId = userId; - vitality.vitality = 50; - vitality.upVitality = 50; + vitality.vitality = GameConfig.GameBaseVigour; + vitality.upVitality = GameConfig.GameBaseVigour; vitality.upTime = TimeAssist.GetDateTimeYMDString(0); db.Insertable(vitality).AddQueue(); diff --git a/Service/Application.Domain/Tool/Base/GameTool.cs b/Service/Application.Domain/Tool/Base/GameTool.cs index bd90aba..c2842a8 100644 --- a/Service/Application.Domain/Tool/Base/GameTool.cs +++ b/Service/Application.Domain/Tool/Base/GameTool.cs @@ -18,7 +18,7 @@ public class GameTool data.agility = lev; data.upBlood = ((lev - 1) * 5) + 80; data.upMorale = 100 + (lev / 5) * 10; - data.levUpdate = TimeAssist.GetTimeStampNum; + data.levUpdate = TimeExtend.GetTimeStampSeconds; return data; } /// diff --git a/Service/Application.Web/Controllers/User/BagController.cs b/Service/Application.Web/Controllers/User/BagController.cs index 2aeadab..109c9a4 100644 --- a/Service/Application.Web/Controllers/User/BagController.cs +++ b/Service/Application.Web/Controllers/User/BagController.cs @@ -12,12 +12,15 @@ public class BagController : ControllerBase private readonly IUnitUserWeight _weightService; private readonly IGameGoodsService _goodsService; private readonly IGameEquService _equService; + private readonly IUnitUserAccService _accService; - public BagController(IUnitUserWeight weightService, IGameGoodsService goodsService, IGameEquService equService) + public BagController(IUnitUserWeight weightService, IGameGoodsService goodsService, IGameEquService equService, + IUnitUserAccService accService) { _weightService = weightService; _goodsService = goodsService; _equService = equService; + _accService = accService; } /// @@ -28,14 +31,15 @@ public class BagController : ControllerBase public async Task GetUserBagData() { string userId = StateHelper.userId; - int onWeight = 0; - int maxWeight = 0; - int gold = 0; - int cowry = 0; - long copper = 0; + + var accInfo = await _accService.GetUserAccInfo(userId); + long gold = (long)accInfo.gold; + long cowry = (long)accInfo.cowry; + + long copper = await _accService.GetUserAccInfo(userId, nameof(AccEnum.AccType.copper)); var userWeight = await _weightService.GetUserWeightInfo(userId); - onWeight = (int)userWeight.onWeight; - maxWeight = (int)userWeight.maxWeight; + int onWeight = (int)userWeight.onWeight; + int maxWeight = (int)userWeight.maxWeight; return PoAction.Ok(new { onWeight, maxWeight, cowry, gold, copper }); } diff --git a/Service/Application.Web/Controllers/User/UserController.cs b/Service/Application.Web/Controllers/User/UserController.cs new file mode 100644 index 0000000..069fb6a --- /dev/null +++ b/Service/Application.Web/Controllers/User/UserController.cs @@ -0,0 +1,83 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Application.Web.Controllers.User; + +[ApiExplorerSettings(GroupName = "User")] +[Route("User/[controller]/[action]")] +[ApiController] +[Authorize] +public class UserController : ControllerBase +{ + private readonly IUnitUserService _userService; + private readonly IUnitUserAttrService _attrService; + private readonly IUnitUserAccService _accService; + private readonly IGameMapService _mapService; + + public UserController(IUnitUserService userService, IUnitUserAttrService attrService, + IUnitUserAccService accService, IGameMapService mapService) + { + _userService = userService; + _attrService = attrService; + _accService = accService; + _mapService = mapService; + } + + + /// + /// 获取个人资料信息 + /// + /// + [HttpGet] + public async Task GetUserInfo() + { + string userId = StateHelper.userId; + var userInfo = await _userService.GetUserInfoByUserId(userId); //基础资料 + object user = new { userInfo.userNo, userInfo.nick, userInfo.sex, userInfo.sign }; + + var attrInfo = await _attrService.GetUserAttrModel(userId); //基础属性 + var expInfo = await _attrService.GetUserExp(userId); + 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 }; + object result = new { user, attr = attrInfo, exp, vigourInfo.vitality, acc }; + return PoAction.Ok(result); + } + + /// + /// 获取用户资料 + /// + /// + /// + [HttpGet] + public async Task GetHomeInfo(string? no) + { + string userId = StateHelper.userId; + var userInfo = await _userService.GetUserInfoByUserNo(no); //基础资料 + if (userInfo == null) + { + return PoAction.Message("玩家不存在!", 102); + } + + if (userInfo.userId == userId) + { + return PoAction.Message("用户本身!", 101); + } + + 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 online = await _mapService.GetUserOnMap(userInfo.userId); + int isOnline = online.upTime > TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddMinutes(GameConfig.OnLineTime)) + ? 1 + : 0; + var onMapInfo = await _mapService.GetMapInfo(online.mapId); + var onCity = await _mapService.GetCityInfo((int)onMapInfo.cityId); + string onMapName = $"{onCity.cityName}-{onMapInfo.mapName}"; + + object result = new { user, attr = new { attrInfo.lev }, acc, isOnline, onMapName }; + return PoAction.Ok(result); + } +} \ No newline at end of file diff --git a/Web/nuxt.config.ts b/Web/nuxt.config.ts index ad7069e..c4c65c8 100644 --- a/Web/nuxt.config.ts +++ b/Web/nuxt.config.ts @@ -23,7 +23,7 @@ export default defineNuxtConfig({ // 自动导入配置 - 使用完整路径 imports: { - dirs: ['stores', 'composables', 'extends', 'services/**', 'model/**'], + dirs: ['stores', 'composables', 'extends','utility‌', 'services/**', 'model/**'], }, pinia: { @@ -48,6 +48,13 @@ export default defineNuxtConfig({ '航海时代是2022年推出的一款以航海为背景的wap文字游戏,让玩家穿越到15世纪的大航海时代,了解各地不同的风土人情;淋漓尽致的演绎航海时代的血雨腥风。', }, ], + link: [ + { + rel: 'icon', + href: '/images/favicon.ico', + type: 'image/x-icon' + } + ] }, }, diff --git a/Web/public/images/favicon.ico b/Web/public/images/favicon.ico new file mode 100644 index 0000000..2c451f3 Binary files /dev/null and b/Web/public/images/favicon.ico differ diff --git a/Web/src/components/Business/GameUser.vue b/Web/src/components/Business/GameUser.vue index e9afc77..dec3b93 100644 --- a/Web/src/components/Business/GameUser.vue +++ b/Web/src/components/Business/GameUser.vue @@ -1,5 +1,5 @@ -