111
This commit is contained in:
@@ -2,5 +2,24 @@
|
|||||||
|
|
||||||
public static class EquEnum
|
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
|
public enum NpcBusCode
|
||||||
{
|
{
|
||||||
RetBlood,
|
RetBlood,
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ public interface IGameEquService
|
|||||||
Task AddEquLog(unit_user_equ ueData, string code, string remark,
|
Task AddEquLog(unit_user_equ ueData, string code, string remark,
|
||||||
bool isAddAttr = false);
|
bool isAddAttr = false);
|
||||||
|
|
||||||
|
Task<List<unit_user_equ>> GetUserOnEqu(string userId);
|
||||||
|
Task<bool> EquOnOrDown(unit_user_equ data, int state);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 辅助
|
#region 辅助
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace Application.Domain;
|
using Azure.Core.Pipeline;
|
||||||
|
|
||||||
|
namespace Application.Domain;
|
||||||
|
|
||||||
public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGameEquService, ITransient
|
public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGameEquService, ITransient
|
||||||
{
|
{
|
||||||
@@ -306,7 +308,43 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
|||||||
await db.Insertable(logs).SplitTable().ExecuteCommandAsync();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,56 @@ public class GameTool
|
|||||||
|
|
||||||
return weight;
|
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 距离计算
|
#region 距离计算
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -11,10 +11,14 @@ namespace Application.Web.Controllers.Pub;
|
|||||||
public class EquController : ControllerBase
|
public class EquController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IGameEquService _equService;
|
private readonly IGameEquService _equService;
|
||||||
|
private readonly IUnitUserAttrService _attrService;
|
||||||
|
private readonly IUnitUserService _userService;
|
||||||
|
|
||||||
public EquController(IGameEquService equService)
|
public EquController(IGameEquService equService, IUnitUserAttrService attrService, IUnitUserService userService)
|
||||||
{
|
{
|
||||||
_equService = equService;
|
_equService = equService;
|
||||||
|
_attrService = attrService;
|
||||||
|
_userService = userService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -65,7 +69,7 @@ public class EquController : ControllerBase
|
|||||||
user = await UserModelTool.GetUserView(ueInfo.owerId);
|
user = await UserModelTool.GetUserView(ueInfo.owerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return PoAction.Ok(new { equ = equInfo, suit, equData = ueInfo,user });
|
return PoAction.Ok(new { equ = equInfo, suit, equData = ueInfo, user });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -99,10 +103,12 @@ public class EquController : ControllerBase
|
|||||||
{
|
{
|
||||||
return PoAction.Message("装备不存在!");
|
return PoAction.Message("装备不存在!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (equInfo.userId != userId)
|
if (equInfo.userId != userId)
|
||||||
{
|
{
|
||||||
return PoAction.Message("装备不存在!");
|
return PoAction.Message("装备不存在!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (equInfo.isAppr == 0)
|
if (equInfo.isAppr == 0)
|
||||||
{
|
{
|
||||||
return PoAction.Message("装备未鉴定!");
|
return PoAction.Message("装备未鉴定!");
|
||||||
@@ -129,8 +135,117 @@ public class EquController : ControllerBase
|
|||||||
/// <param name="ueId"></param>
|
/// <param name="ueId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IPoAction> DownOrUpEqu(string ueId)
|
public async Task<IPoAction> DownOrUpEqu(string ueId, string? de)
|
||||||
{
|
{
|
||||||
return PoAction.Ok(true);
|
string userId = StateHelper.userId;
|
||||||
|
var equInfo = await _equService.GetUserEquInfo(ueId);
|
||||||
|
if (equInfo == null)
|
||||||
|
{
|
||||||
|
return PoAction.Message("装备不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (equInfo.userId != userId)
|
||||||
|
{
|
||||||
|
return PoAction.Message("装备不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (equInfo.isOn == 0) //穿装
|
||||||
|
{
|
||||||
|
if (equInfo.isAppr == 0)
|
||||||
|
{
|
||||||
|
return PoAction.Message("装备未鉴定!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (equInfo.useEndTime < TimeExtend.GetTimeStampSeconds)
|
||||||
|
{
|
||||||
|
return PoAction.Message("装备已过期!");
|
||||||
|
}
|
||||||
|
|
||||||
|
int myLev = await _attrService.GetUserLev(userId);
|
||||||
|
if (equInfo.lev > myLev)
|
||||||
|
{
|
||||||
|
return PoAction.Message($"等级达到{equInfo.lev}级可穿戴!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (equInfo.sex != nameof(EquEnum.Sex.Default))
|
||||||
|
{
|
||||||
|
var userInfo = await _userService.GetUserInfoByUserId(userId);
|
||||||
|
string needSex = equInfo.sex == nameof(EquEnum.Sex.Girl)
|
||||||
|
? nameof(GameEnum.Sex.女)
|
||||||
|
: nameof(GameEnum.Sex.男);
|
||||||
|
if (userInfo.sex != needSex)
|
||||||
|
{
|
||||||
|
return PoAction.Message($"该装备只允许{needSex}性角色穿戴!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var userOnEqu = await _equService.GetUserOnEqu(userId);
|
||||||
|
if (equInfo.canEqualUp > 0)
|
||||||
|
{
|
||||||
|
int onCount = userOnEqu.Count(it => it.equId == equInfo.equId);
|
||||||
|
if (onCount >= equInfo.canEqualUp)
|
||||||
|
{
|
||||||
|
return PoAction.Message($"该装备最多穿戴{equInfo.canEqualUp}件!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool isOk = true;
|
||||||
|
if (string.IsNullOrEmpty(de))
|
||||||
|
{
|
||||||
|
int MaxCount = GameTool.GetEquPlaceCount(equInfo.code);
|
||||||
|
int OnCount = userOnEqu.Count(it => it.code == equInfo.code) + 1;
|
||||||
|
if (OnCount > MaxCount)
|
||||||
|
{
|
||||||
|
return PoAction.Message($"该部位装备最多穿戴{MaxCount}件!", 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var DownOnEqu = await _equService.GetUserEquInfo(de);
|
||||||
|
if (DownOnEqu == null)
|
||||||
|
{
|
||||||
|
return PoAction.Message("装备不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userOnEqu.Any(it => it.ueId == de) == false)
|
||||||
|
{
|
||||||
|
return PoAction.Message("装备未穿戴!");
|
||||||
|
}
|
||||||
|
if (DownOnEqu.code != equInfo.code)
|
||||||
|
{
|
||||||
|
return PoAction.Message("装备部位不一致!");
|
||||||
|
}
|
||||||
|
|
||||||
|
isOk = await _equService.EquOnOrDown(DownOnEqu, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isOk)
|
||||||
|
{
|
||||||
|
bool result = await _equService.EquOnOrDown(equInfo, 1);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
return PoAction.Ok(true, "穿装成功!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("穿装失败,请稍后尝试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("穿装失败,请稍后尝试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else //卸装
|
||||||
|
{
|
||||||
|
bool result = await _equService.EquOnOrDown(equInfo, 0);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
return PoAction.Ok(true, "卸装成功!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return PoAction.Message("卸装失败,请稍后尝试");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="common" v-if="myUserId == equData.userId && equData.isAppr == 1">
|
<div class="common" v-if="myUserId == equData.userId && equData.isAppr == 1">
|
||||||
<span>
|
<span>
|
||||||
◈<Abutton @click="UpOrDownEqu">穿戴装备</Abutton><br>
|
◈<Abutton @click="UpOrDownEqu">{{equData.isOn==1?"卸下装备":"穿戴装备"}}</Abutton><br>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
◈<Abutton>洗练</Abutton><br>
|
◈<Abutton>洗练</Abutton><br>
|
||||||
@@ -188,7 +188,16 @@ const BindData = async (): Promise<void> => {
|
|||||||
|
|
||||||
/**穿/卸装备 */
|
/**穿/卸装备 */
|
||||||
const UpOrDownEqu = async () => {
|
const UpOrDownEqu = async () => {
|
||||||
alert(ueId);
|
MessageExtend.LoadingToast("操作中...");
|
||||||
|
let result = await EquService.DownOrUpEqu(ueId,"");
|
||||||
|
MessageExtend.LoadingClose();
|
||||||
|
if (result.code == 0) {
|
||||||
|
await BindData();
|
||||||
|
MessageExtend.Notify(result.msg, "success");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageExtend.ShowDialog("穿/卸装备", result.msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**绑定装备 */
|
/**绑定装备 */
|
||||||
|
|||||||
@@ -1 +1,37 @@
|
|||||||
<template></template>
|
<template>
|
||||||
|
<div class="content">
|
||||||
|
手持: <Abutton>[+]</Abutton>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
副手: <Abutton>[+]</Abutton>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
头戴: <Abutton>[+]</Abutton>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
身穿: <Abutton>[+]</Abutton>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
腰带: <Abutton>[+]</Abutton>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
脚穿: <Abutton>[+]</Abutton>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
佩戴: <Abutton>[+]</Abutton>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
时装: <Abutton>[+]</Abutton>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
羽翼: <Abutton>[+]</Abutton>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
装饰: <Abutton>[+]</Abutton>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<Abar href="/">我的九宫牌</Abar><br>
|
||||||
|
<Abar href="/">我的圣痕</Abar><br>
|
||||||
|
<Abar href="/user/bag">装备物品</Abar>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -27,7 +27,7 @@ export class EquService {
|
|||||||
* 穿/卸装备
|
* 穿/卸装备
|
||||||
* GET /Equ/DownOrUpEqu
|
* GET /Equ/DownOrUpEqu
|
||||||
*/
|
*/
|
||||||
static async DownOrUpEqu(ueId: string) {
|
static async DownOrUpEqu(ueId: string, de: string) {
|
||||||
return await ApiService.Request("get", "/Equ/DownOrUpEqu", { ueId });
|
return await ApiService.Request("get", "/Equ/DownOrUpEqu", { ueId, de });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user