111
This commit is contained in:
@@ -2,5 +2,24 @@
|
||||
|
||||
public static class EquEnum
|
||||
{
|
||||
|
||||
public enum Sex
|
||||
{
|
||||
Default,
|
||||
Boy,
|
||||
Girl
|
||||
}
|
||||
|
||||
public enum EquPlace
|
||||
{
|
||||
Mouth = 1, //嘴饰
|
||||
Hold = 1, //手持
|
||||
Vice = 1, //副手
|
||||
Head = 1, //头戴
|
||||
Wear = 1, //身穿
|
||||
Waist = 1, //腰带
|
||||
Foot = 1, //脚穿
|
||||
Ornaments = 3, //佩戴
|
||||
Fashion = 1, //时装
|
||||
Wing = 1, //羽翼
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,12 @@ public static class GameEnum
|
||||
减少,
|
||||
增加
|
||||
}
|
||||
|
||||
public enum Sex
|
||||
{
|
||||
男,
|
||||
女,
|
||||
未知
|
||||
}
|
||||
public enum NpcBusCode
|
||||
{
|
||||
RetBlood,
|
||||
|
||||
@@ -25,8 +25,9 @@ public interface IGameEquService
|
||||
|
||||
Task AddEquLog(unit_user_equ ueData, string code, string remark,
|
||||
bool isAddAttr = false);
|
||||
|
||||
|
||||
Task<List<unit_user_equ>> GetUserOnEqu(string userId);
|
||||
Task<bool> EquOnOrDown(unit_user_equ data, int state);
|
||||
#endregion
|
||||
|
||||
#region 辅助
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Application.Domain;
|
||||
using Azure.Core.Pipeline;
|
||||
|
||||
namespace Application.Domain;
|
||||
|
||||
public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGameEquService, ITransient
|
||||
{
|
||||
@@ -306,12 +308,48 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
await db.Insertable(logs).SplitTable().ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<List<unit_user_equ>> GetUserOnEqu(string userId)
|
||||
{
|
||||
var key = string.Format(UserCache.BaseCacheKeys, "EquData", "UserOnEqu");
|
||||
if (await redis.HExistsHashAsync(key, userId))
|
||||
{
|
||||
return await redis.GetHashAsync<List<unit_user_equ>>(key, userId);
|
||||
}
|
||||
else
|
||||
{
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_equ>();
|
||||
var data = await db.Queryable<unit_user_equ>().Where(it => it.userId == userId && it.isOn == 1)
|
||||
.ToListAsync();
|
||||
await redis.AddHashAsync(key, userId, data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> EquOnOrDown(unit_user_equ data, int state)
|
||||
{
|
||||
data.isOn = state;
|
||||
if (data.opTime == 0)
|
||||
{
|
||||
data.opTime = 1;
|
||||
var equInfo = await GetEquInfo((int)data.equId);
|
||||
if (equInfo.useTime > 0)
|
||||
{
|
||||
data.useEndTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays((int)equInfo.useTime)) ;
|
||||
}
|
||||
}
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_equ>();
|
||||
bool result = await db.Updateable(data).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
{
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 辅助方法
|
||||
|
||||
@@ -89,6 +89,56 @@ public class GameTool
|
||||
|
||||
return weight;
|
||||
}
|
||||
|
||||
public static int GetEquPlaceCount(string code)
|
||||
{
|
||||
int result = 0;
|
||||
switch (code)
|
||||
{
|
||||
case "Mouth":
|
||||
result = (int)EquEnum.EquPlace.Mouth;
|
||||
break;
|
||||
|
||||
case "Hold":
|
||||
result = (int)EquEnum.EquPlace.Hold;
|
||||
break;
|
||||
|
||||
case "Vice":
|
||||
result = (int)EquEnum.EquPlace.Vice;
|
||||
break;
|
||||
|
||||
case "Head":
|
||||
result = (int)EquEnum.EquPlace.Head;
|
||||
break;
|
||||
|
||||
case "Wear":
|
||||
result = (int)EquEnum.EquPlace.Wear;
|
||||
break;
|
||||
|
||||
case "Waist":
|
||||
result = (int)EquEnum.EquPlace.Waist;
|
||||
break;
|
||||
|
||||
case "Foot":
|
||||
result = (int)EquEnum.EquPlace.Foot;
|
||||
break;
|
||||
|
||||
case "Ornaments":
|
||||
result = (int)EquEnum.EquPlace.Ornaments;
|
||||
break;
|
||||
|
||||
case "Fashion":
|
||||
result = (int)EquEnum.EquPlace.Fashion;
|
||||
break;
|
||||
|
||||
case "Wing":
|
||||
result = (int)EquEnum.EquPlace.Wing;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#region 距离计算
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user