This commit is contained in:
Putoo
2026-05-26 18:38:55 +08:00
parent 61cf882b66
commit 6b7193b4c0
33 changed files with 1021 additions and 42 deletions

View File

@@ -6,4 +6,5 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJwtSecurityTokenHandler_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003Ff9d3fc33fd2fba97d4e718534a67f1d3c61e492634cd51c4798ce5621f780f3_003FJwtSecurityTokenHandler_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASqlSetup_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F72993acb059c49dcbba437a858c0b0942000_003F46_003F2e14505d_003FSqlSetup_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AString_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F51505665371d472f8bdbc333fa4d888cf49938_003Fdf_003F23ca03dd_003FString_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATimeAssist_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa380d649d5b2495d9bfa0fa24f13662b6400_003Fe6_003F9539602d_003FTimeAssist_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATokenValidationParameters_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ffbb48859ccd84b0d884ab212a4cf9fdb5f820_003F55_003F417754e1_003FTokenValidationParameters_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>

View File

@@ -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; }
}

View File

@@ -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; }
}

View File

@@ -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;//初始活力
}

View File

@@ -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
{
,
}
}

View File

@@ -0,0 +1,9 @@
namespace Application.Domain;
public static class UserEnum
{
public enum AttrCode
{
Person
}
}

View File

@@ -0,0 +1,21 @@
namespace Application.Domain;
public interface IUnitUserAccService
{
Task<long> GetUserAccInfo(string userId, string accType);
#region
Task<unit_user_acc> GetUserAccInfo(string userId);
Task<bool> UpdateUserAcc(string userId, int type, string accType, long count, string name = "",
string remark = "");
Task<bool> UpdateUserAccBath(string userId, int type, string accType, long count, string name = "",
string remark = "");
Task<unit_user_copper> GetUserCopperInfo(string userId);
Task<bool> UpdateUserCopper(string userId, int type, long count, string remark = "");
#endregion
}

View File

@@ -2,6 +2,39 @@
public interface IUnitUserAttrService
{
#region
Task<UserAttrModel> GetUserAttrModel(string userId);
Task<unit_user_attr> GetUserAttr(string userId);
#endregion
#region
Task<unit_user_blood> GetUserBlood(string userId);
Task<bool> UpdateUserBlood(string userId, int op, int count, bool mustUp = false);
#endregion
#region
Task<unit_user_exp> GetUserExp(string userId);
Task<bool> UpdateUserExp(string userId, long exp, int op = 1);
#endregion
#region
Task<unit_user_morale> GetUserMorale(string userId);
Task<bool> UpdateUserMorale(string userId, int op, int count);
#endregion
#region
Task<unit_user_vigour> GetUserVigourInfo(string userId);
Task<bool> UpdateUserVigour(string userId, int op, decimal count, string UpTime = "");
Task<bool> UpdateUserUpVigour(string userId, decimal count);
#endregion
}

View File

@@ -0,0 +1,137 @@
namespace Application.Domain;
public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : IUnitUserAccService, ITransient
{
public async Task<long> 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<unit_user_acc> GetUserAccInfo(string userId)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_acc>();
return await db.Queryable<unit_user_acc>().Where(i => i.userId == userId).SingleAsync();
}
public async Task<bool> 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<unit_user_acc>();
await DbClient.AsTenant().BeginTranAsync();
isOk = await db.Updateable<unit_user_acc>()
.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<bool> 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<unit_user_copper> GetUserCopperInfo(string userId)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_copper>();
return await db.Queryable<unit_user_copper>().Where(i => i.userId == userId).SingleAsync();
}
public async Task<bool> 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<unit_user_copper>();
await DbClient.AsTenant().BeginTranAsync();
isOk = await db.Updateable<unit_user_copper>()
.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
}

View File

@@ -2,8 +2,59 @@
public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) : IUnitUserAttrService, ITransient
{
#region
public async Task<UserAttrModel> GetUserAttrModel(string userId)
{
UserAttrModel result = new UserAttrModel();
result.id = userId;
var userService = App.GetService<IUnitUserService>();
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<unit_user_attr> GetUserAttr(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "UserAttr");
var data = await redis.GetHashAsync<unit_user_attr>(key, userId);
if (data == null)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_attr>();
data = await db.Queryable<unit_user_attr>().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
public async Task<unit_user_blood> GetUserBlood(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "Blood");
@@ -14,6 +65,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
data = await db.Queryable<unit_user_blood>().Where(it => it.userId == userId).SingleAsync();
await redis.AddHashAsync(key, userId, data);
}
return data;
}
@@ -56,7 +108,206 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
return result;
}
#endregion
#region
public async Task<unit_user_exp> GetUserExp(string userId)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_exp>();
return await db.Queryable<unit_user_exp>().Where(it => it.userId == userId).SingleAsync();
}
public async Task<bool> UpdateUserExp(string userId, long exp, int op = 1)
{
bool result = false;
bool IsUpUserAttr = false;
try
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_exp>();
await DbClient.AsTenant().BeginTranAsync();
if (op == 0) //扣除经验
{
result = await db.Updateable<unit_user_exp>().SetColumns(it => it.exp == it.exp - exp)
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
}
else //增加经验
{
var MyExp = await db.Queryable<unit_user_exp>().Where(it => it.userId == userId).SingleAsync();
long onExp = (long)MyExp.exp + exp;
if (onExp < MyExp.upExp) //不足升级
{
result = await db.Updateable<unit_user_exp>().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<unit_user_exp>().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<unit_user_attr>(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<unit_user_exp>().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<IUnitUserWeight>();
await wightService.UpdateUserMaxWeight(userId, 1, GameConfig.UpLevAddWeight);
await ClearUserAttrCache(userId);
}
return result;
}
#endregion
#region
public async Task<unit_user_morale> GetUserMorale(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "Morale");
var data = await redis.GetHashAsync<unit_user_morale>(key, userId);
if (data == null)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_morale>();
data = await db.Queryable<unit_user_morale>().Where(it => it.userId == userId).SingleAsync();
await redis.AddHashAsync(key, userId, data);
}
return data;
}
public async Task<bool> 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<unit_user_morale>();
result = await db.Updateable<unit_user_morale>().SetColumns(it => it.morale == data.morale)
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
return result;
}
#endregion
#region
public async Task<unit_user_vigour> GetUserVigourInfo(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "Vigour");
var data = await redis.GetHashAsync<unit_user_vigour>(key, userId);
if (data == null)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_vigour>();
data = await db.Queryable<unit_user_vigour>().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<bool> UpdateUserVigour(string userId, int op, decimal count, string UpTime = "")
{
bool result = false;
try
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_vigour>();
await DbClient.AsTenant().BeginTranAsync();
result = await db.Updateable<unit_user_vigour>()
.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<bool> UpdateUserUpVigour(string userId, decimal count)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_vigour>();
bool isok = await db.Updateable<unit_user_vigour>().SetColumns(i => i.upVitality == count)
.Where(i => i.userId == userId).ExecuteCommandAsync() > 0;
if (isok)
{
await ClearUserVigourCache(userId);
}
return isok;
}
#endregion
}

View File

@@ -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();

View File

@@ -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;
}
/// <summary>

View File

@@ -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;
}
/// <summary>
@@ -28,14 +31,15 @@ public class BagController : ControllerBase
public async Task<IPoAction> 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 });
}

View File

@@ -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;
}
/// <summary>
/// 获取个人资料信息
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> 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);
}
/// <summary>
/// 获取用户资料
/// </summary>
/// <param name="no"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> 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);
}
}

View File

@@ -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'
}
]
},
},

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

View File

@@ -1,5 +1,5 @@
<template>
<Abar href="">{{data.nick}}</Abar>
<Abar :href='"/user/user?no=" +data.userNo' >{{ data.nick }}</Abar>
</template>
<script lang="ts" setup>
const props = defineProps({

View File

@@ -4,7 +4,7 @@
<div class="common">
<Abar href="/">首页</Abar>-
<Abar href="/">挂机</Abar>-
<Abar href="/treasure">聚宝盆</Abar>-
<!-- <Abar href="/treasure">聚宝盆</Abar>- -->
<a target="_blank" href="https://work.weixin.qq.com/kfid/kfc86bc348120aea3e7">反馈</a>
</div>

View File

@@ -1,17 +1,17 @@
<template>
<div class="common">
<Abar href="/">状态</Abar>.
<Abar href="/user">状态</Abar>.
<Abar href="/bag">物品</Abar>.
<Abar href="/chat">聊天</Abar>
</div>
<div class="common">
<Abar href="/">好友</Abar>.
<Abar href="/">宠物</Abar>.
<Abar href="/">队伍</Abar>
<Abar href="/friend">好友</Abar>.
<Abar href="/pet">宠物</Abar>.
<Abar href="/team">队伍</Abar>
</div>
<div class="common">
<Abar href="/">商城</Abar>.
<Abar href="/">活动</Abar>.
<Abar href="/">排行</Abar>
<Abar href="/mall">商城</Abar>.
<Abar href="/activity">活动</Abar>.
<Abar href="/rank">排行</Abar>
</div>
</template>

View File

@@ -0,0 +1,46 @@
export class LocalStorageExtend {
/**
* 设置本地存储
* @param key 键名
* @param value 值(支持任意类型:对象/数组/字符串/数字)
*/
public static Set<T>(key: string, value: T): void {
try {
const data = JSON.stringify(value);
window.localStorage.setItem(key, data);
} catch (error) {
console.error('localStorage 设置失败:', error);
}
}
/**
* 获取本地存储
* @param key 键名
* @param defaultValue 默认值(取不到时返回)
* @returns 解析后的值
*/
public static Get<T>(key: string, defaultValue?: T): T | null {
try {
const data = window.localStorage.getItem(key);
if (!data) return defaultValue ?? null;
return JSON.parse(data) as T;
} catch (error) {
console.error('localStorage 获取失败:', error);
return defaultValue ?? null;
}
}
/**
* 删除指定存储
*/
public static Remove(key: string): void {
window.localStorage.removeItem(key);
}
/**
* 清空所有存储
*/
public static Clear(): void {
window.localStorage.clear();
}
}

View File

@@ -0,0 +1,3 @@
<template>
</template>

View File

@@ -4,7 +4,7 @@
金元:{{ bagInfo.gold }}<br />
金贝:{{ bagInfo.cowry }} <br />
负重:{{ bagInfo.onWeight }}/{{ bagInfo.maxWeight }} <br />
{{ bagInfo.copper }}<br />
{{ GameTool.FormatCopper(bagInfo.copper) }}<br />
<Abar href="/">交易记录</Abar><br>
<Abar href="/">赠送记录</Abar>
</div>
@@ -49,7 +49,7 @@
<div class="common" v-if="type == '0'">
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<Abar href="">{{ item.equName }}({{item.lev}})</Abar>
<Abar :href='"/prop/goods?ue=" + item.ueId'>{{ item.equName }}({{ item.lev }})</Abar>
<span v-if="item.isOn == 1">(穿)</span>
<span v-if="item.isAppr == 0">(未鉴定)</span>
<span v-if="item.useEndTime < onTime" style="color: red;">(过期)</span>
@@ -60,19 +60,18 @@
<div class="common" v-if="type == '1'">
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<Abar href="">{{ item.goodsName }}</Abar>({{ item.count }})
<Abar :href='"/prop/goods?id=" + item.goodsId'>{{ item.goodsName }}</Abar>({{ item.count }})
</div>
</div>
<div class="common" v-if="type == '2'">
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<span v-if="item.code == 'Card'">
<Abar href="">{{ item.goodsName }}</Abar>({{ item.count }})
<Abar :href='"/prop/goods?id=" + item.goodsId'>{{ item.goodsName }}</Abar>({{ item.count }})
</span>
<span v-else>
<Abar href="">{{ item.goodsName }}</Abar>({{ item.count }})
<Abar :href='"/prop/goods?id=" + item.goodsId'>{{ item.goodsName }}</Abar>({{ item.count }})
</span>
</div>
</div>
@@ -84,6 +83,13 @@
</template>
<script setup lang="ts">
interface bagStorage {
type: string
type_ch: string
page: number
serch: string
}
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
@@ -102,6 +108,14 @@ const onTime = ref(0);
onMounted(async () => {
try {
onTime.value = TimeExtend.GetSecondStamp();
let localData = LocalStorageExtend.Get<bagStorage>("BagPageCache");
if (localData != null) {
type.value = localData.type;
type_ch.value = localData.type_ch;
currentPage.value = localData.page;
serch.value = localData.serch;
}
let result = await BagService.GetUserBagData();
if (result.code == 0) {
bagInfo.value = result.data;
@@ -118,7 +132,10 @@ const BindData = async (): Promise<void> => {
if (result.code == 0) {
data.value = result.data.data;
total.value = result.data.total;
console.log(data.value);
//存储请求参数
let addLocalData: bagStorage = { type: type.value, type_ch: type_ch.value, page: currentPage.value, serch: serch.value };
LocalStorageExtend.Set("BagPageCache", addLocalData);
}
else {
MessageExtend.ShowDialog("提示", result.msg);
@@ -129,6 +146,7 @@ const BindData = async (): Promise<void> => {
const ChangeBag = async (_type: string): Promise<void> => {
type.value = _type;
type_ch.value = '0';
serch.value='';
await BindData();
}

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1,3 @@
<template>
</template>

View File

@@ -0,0 +1,3 @@
<template>
暂未开放.
</template>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1 @@
<template></template>

View File

@@ -0,0 +1,88 @@
<template>
<div class="content">
<Abar href="">更换称号</Abar><br>
ID:{{ userData.userNo }}&nbsp;[<Abar href="">升靓号</Abar>]<br>
昵称:<Abar href="">{{ userData.nick }}</Abar><br>
性别:<Abar href="">{{ userData.sex }}</Abar><br>
<Abar>特权</Abar>:<br>
徽章:<Abar>显示</Abar><br>
社交:<Abar>未收到礼物</Abar><br>
婚姻:单身<br>
个性签名:{{ userData.sign }}.<Abar>修改</Abar><br>
宠物:暂无<br>
坐骑:<br>
成就:<Abar>展示成就</Abar><br>
等级:{{ attrData.lev }}<br>
综合战力:{{attrData.score}}<br>
经验:{{ expData.exp }}/{{ expData.upExp }}<br>
体力:{{attrData.blood}}/{{attrData.upBlood}} {{attrData.bloodTips}}<br>
攻击:{{attrData.minAtk}}-{{attrData.maxAtk}} {{attrData.atkTips}}<br>
防御:{{attrData.defense}} {{attrData.defTips}}<br>
敏捷:{{attrData.agility}} {{attrData.agilityTips}}<br>
士气:{{attrData.morale}}/{{attrData.upMorale}} {{attrData.moraleTips}}<br>
师德:{{accData.teach}}<br>
声望:{{accData.renown}}<br>
活力:{{ vitality }}<br>
罪恶值:0<br>
帮派:<br>
<!-- ---药品状态---<br>
体力宝+24370<br>
耐久包+0<br> -->
</div>
<div class="content">
<div class="item">
<Abar>装备</Abar>.
<Abar>技能</Abar>.
<Abar>特性</Abar>
</div>
<div class="item">
<Abar>帮派</Abar>.
<Abar>船队</Abar>.
<Abar>房产</Abar>
</div>
<div class="item">
<Abar>山寨</Abar>.
<Abar>交易</Abar>.
<Abar>设置</Abar>
</div>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const userData = ref<any>({});
const vitality = ref(0);
const expData = ref<any>({});
const attrData = ref<any>({});
const accData = ref<any>({});
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let result = await UserService.GetUserInfo();
if (result.code == 0) {
userData.value = result.data.user;
vitality.value = result.data.vitality;
expData.value = result.data.exp;
attrData.value = result.data.attr;
accData.value = result.data.acc;
console.log(result);
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
</script>

View File

@@ -0,0 +1,90 @@
<template>
<div class="content">
<Abar>私聊</Abar>. <Abar>送礼物</Abar>. <Abar>逗一下</Abar><br />
<Abar>拜师</Abar>. <Abar>山寨</Abar>. <Abar>送道具</Abar><br>
<Abar>加好友</Abar>. <Abar>加仇人</Abar>
</div>
<div class="content"></div>
<div class="content">
ID:{{ userData.userNo }}({{ online == 1 ? '在线' : '离线' }})<br>
昵称:{{ userData.nick }}<br>
特权:<br>
徽章:<br>
社交: 暂无<br>
婚姻:<br>
结拜:暂无<br>
宠物:暂无<br>
坐骑:<br>
成就:<br>
个性签名:{{ userData.sign }}<br>
罪恶值:0<br>
师德:{{ accData.teach }}<br>
</div>
<div class="content">
{{ attrData.lev }}{{ userData.sex }}({{ onMap }})
</div>
<div class="content">
手持: <br>
副手:<br>
头戴:<br>
身穿: <br>
腰带: <br>
脚穿: <br>
佩戴: <br>
时装:<br>
羽翼: <br>
装饰: <br>
套装: <br>
帮会: <br>
队伍:<br>
</div>
<div class="content"></div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const userData = ref<any>({});
const attrData = ref<any>({});
const accData = ref<any>({});
const online = ref(0);
const onMap = ref('');
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let no = PageExtend.QueryString("no");
let result = await UserService.GetHomeInfo(no);
if (result.code == 0) {
userData.value = result.data.user;
attrData.value = result.data.attr;
accData.value = result.data.acc;
online.value = result.data.isOnline;
onMap.value = result.data.onMapName;
console.log(result);
}
else if (result.code == 101) {
return PageExtend.Redirect("/user");
}
else if (result.code == 102) {
MessageExtend.ShowDialogEvent("提示", "玩家不存在!", () => {
return PageExtend.Redirect("/user");
}, "确认");
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
</script>

View File

@@ -0,0 +1,17 @@
export class UserService {
/**
* 获取个人资料信息
* GET /User/User/GetUserInfo
*/
static async GetUserInfo() {
return await ApiService.Request("get", "/User/User/GetUserInfo");
}
/**
* 获取用户资料
* GET /User/User/GetHomeInfo
*/
static async GetHomeInfo(no: string) {
return await ApiService.Request("get", "/User/User/GetHomeInfo", { no });
}
}

View File

@@ -0,0 +1,38 @@
export class GameTool {
/**
* 静态方法:将总铜数转换为 金/银/铜 字符串
* @param totalCopper 总铜数量
* @returns 格式化字符串1金 234银 567铜
*/
public static FormatCopper(totalCopper: number | string): string {
// 安全转为数字并取整(货币无小数)
let copper = Math.floor(Number(totalCopper) || 0);
// 处理负数
const isNegative = copper < 0;
copper = Math.abs(copper);
// 单位换算
const copperUnit = copper % 1000;
const totalSilver = Math.floor(copper / 1000);
const silverUnit = totalSilver % 1000;
const goldUnit = Math.floor(totalSilver / 1000);
// 拼接非0单位
const parts: string[] = [];
if (goldUnit > 0) parts.push(`${goldUnit}`);
if (silverUnit > 0) parts.push(`${silverUnit}`);
if (copperUnit > 0) parts.push(`${copperUnit}`);
// 空值显示 0铜
let result = parts.length > 0 ? parts.join(' ') : '0铜';
// 恢复负号
if (isNegative) {
result = `-${result}`;
}
return result;
}
}