This commit is contained in:
Putoo
2026-06-29 18:17:54 +08:00
parent e47a5a19a6
commit 93d21ba9fd
35 changed files with 1073 additions and 293 deletions

View File

@@ -47,5 +47,17 @@ namespace Application.Domain.Entity
/// </summary> /// </summary>
[SugarColumn(IsNullable = true)] [SugarColumn(IsNullable = true)]
public int? copper { get; set; } public int? copper { get; set; }
/// <summary>
/// 出售价格
/// </summary>
[SugarColumn(IsNullable = true)]
public long? sale { get; set; }
/// <summary>
/// remark
/// </summary>
[SugarColumn(Length = 255, IsNullable = true)]
public string? remark { get; set; }
} }
} }

View File

@@ -0,0 +1,63 @@
using SqlSugar;
using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Game")]
public class unit_user_state
{
/// <summary>
/// usId
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 50)]
public string usId { get; set; }
/// <summary>
/// userId
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? userId { get; set; }
/// <summary>
/// goodsId
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? goodsId { get; set; }
/// <summary>
/// name
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? name { get; set; }
/// <summary>
/// 场景
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? scene { get; set; }
/// <summary>
/// tips
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? tips { get; set; }
/// <summary>
/// attr
/// </summary>
[SugarColumn(IsNullable = true,IsJson = true)]
public List<AttrItem> attr { get; set; }
/// <summary>
/// addTime
/// </summary>
[SugarColumn(IsNullable = true)]
public long? addTime { get; set; }
/// <summary>
/// endTime
/// </summary>
[SugarColumn(IsNullable = true)]
public long? endTime { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
namespace Application.Domain.Entity;
public class ChoiceGoods
{
public int id { get; set; }
public string name { get; set; }
public List<TowerGet> award { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace Application.Domain.Entity;
public class UserEquAttrModel
{
public UserAttrModel equ { get; set; }
public List<AttrItem> attr { get; set; }
}

View File

@@ -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<AttrItem> attr { get; set; }
}

View File

@@ -1,75 +0,0 @@
using SqlSugar;
using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Resource")]
public class game_ship
{
/// <summary>
/// shipId
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 50)]
public int shipId { get; set; }
/// <summary>
/// npc
/// </summary>
[SugarColumn(IsNullable = true)]
public int? npc { get; set; }
/// <summary>
/// shipName
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string shipName { get; set; }
/// <summary>
/// img
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string img { get; set; }
/// <summary>
/// price
/// </summary>
[SugarColumn(Length = 18, IsNullable = true)]
public decimal? price { get; set; }
/// <summary>
/// salePrice
/// </summary>
[SugarColumn(Length = 18, IsNullable = true)]
public decimal? salePrice { get; set; }
/// <summary>
/// payType
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string payType { get; set; }
/// <summary>
/// weight
/// </summary>
[SugarColumn(IsNullable = true)]
public int? weight { get; set; }
/// <summary>
/// speed
/// </summary>
[SugarColumn(IsNullable = true)]
public int? speed { get; set; }
/// <summary>
/// neeGold
/// </summary>
[SugarColumn(IsNullable = true)]
public int? neeGold { get; set; }
/// <summary>
/// remark
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string remark { get; set; }
}
}

View File

@@ -14,8 +14,10 @@ public static class GoodsEnum
Card,//附魔卡片 Card,//附魔卡片
Mark,//圣痕 Mark,//圣痕
Pack,//宝箱 Pack,//宝箱
ChoicePack,//选择宝箱
Weight,//负重 Weight,//负重
Exp,//经验 Exp,//经验
State,//状态物品 State,//状态物品
Ship,//船只
} }
} }

View File

@@ -32,9 +32,10 @@ public interface IGameEquService
bool isAddAttr = false); bool isAddAttr = false);
Task<List<unit_user_equ>> GetUserOnEqu(string userId); Task<List<unit_user_equ>> GetUserOnEqu(string userId);
Task<UserAttrModel> GetUserEquAttrModel(string userId);
Task<bool> EquOnOrDown(unit_user_equ data, int state); Task<bool> EquOnOrDown(unit_user_equ data, int state);
Task<List<UserEquSuit>> GetUserEquSuit(string userId); Task<List<UserEquSuit>> GetUserEquSuit(string userId);
Task<List<AttrItem>> GetUserEquSuitAttrInfo(string userId);
#endregion #endregion
#region #region

View File

@@ -28,8 +28,4 @@ public interface IGameGoodsService
#endregion #endregion
#region
Task<game_ship> GetShipInfo(int shipId);
#endregion
} }

View File

@@ -4,7 +4,7 @@ public interface IUnitUserAttrService
{ {
#region #region
Task<UserAttrModel> GetUserAttrModel(string userId); Task<UserAttrModel> GetUserAttrModel(string userId, string scene = "Default");
Task<unit_user_attr> GetUserAttr(string userId); Task<unit_user_attr> GetUserAttr(string userId);
Task<int> GetUserLev(string userId); Task<int> GetUserLev(string userId);
#endregion #endregion
@@ -51,5 +51,15 @@ public interface IUnitUserAttrService
Task<unit_user_drug> GetUserDrug(string userId); Task<unit_user_drug> GetUserDrug(string userId);
Task<bool> UpdateUserDrug(unit_user_drug data); Task<bool> UpdateUserDrug(unit_user_drug data);
#endregion
#region
Task<List<unit_user_state>> GetUserStateData(string userId, string scene = "Default");
Task<bool> AddUserState(string userId, string groupId, string name, string scene, string tips,
List<AttrItem> attr, int time, int count = 1);
#endregion #endregion
} }

View File

@@ -19,7 +19,7 @@ public interface IUnitUserWeight
Task<bool> UpdateUserShipOnWeight(string userId, int op, int weight); Task<bool> UpdateUserShipOnWeight(string userId, int op, int weight);
Task<bool> CheakUserShipWeight(string userId, int useWeight); Task<bool> CheakUserShipWeight(string userId, int useWeight);
Task<bool> DeleteUserShip(string usId, string userId); Task<bool> DeleteUserShip(string usId, string userId);
Task<bool> AddUserShip(string userId, string name, int goodsId, int speed, int weight); Task<bool> AddUserShip(string userId, string name, int goodsId, int speed, int weight,int copper,long sale,string remark);
#endregion #endregion

View File

@@ -447,13 +447,50 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
} }
} }
public async Task<UserAttrModel> GetUserEquAttrModel(string userId)
{
var key = string.Format(UserCache.BaseCacheKeys, "EquData", "UserOnEquAttr");
if (await redis.HExistsHashAsync(key, userId))
{
return await redis.GetHashAsync<UserAttrModel>(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<AttrItem> 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) private async Task ClearUserOnEqu(string userId)
{ {
var key = string.Format(UserCache.BaseCacheKeys, "EquData", "UserOnEqu"); var key = string.Format(UserCache.BaseCacheKeys, "EquData", "UserOnEqu");
await redis.DelHashAsync(key, userId); 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); key = string.Format(UserCache.BaseCacheKeys, "EquData:UserEquSuit", userId);
await redis.DelAsync(key); await redis.DelAsync(key);
key = string.Format(UserCache.BaseCacheKeys, "EquData:UserEquSuitAttr", userId);
await redis.DelAsync(key);
} }
public async Task<bool> EquOnOrDown(unit_user_equ data, int state) public async Task<bool> EquOnOrDown(unit_user_equ data, int state)
@@ -544,6 +581,30 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
return result; return result;
} }
public async Task<List<AttrItem>> GetUserEquSuitAttrInfo(string userId)
{
List<AttrItem> result = new List<AttrItem>();
var key = string.Format(UserCache.BaseCacheKeys, "EquData:UserEquSuitAttr", userId);
if (await redis.ExistsAsync(key))
{
result = await redis.GetAsync<List<AttrItem>>(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 #endregion
#region #region
@@ -708,7 +769,6 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
public async Task<unit_user_equ> GetUserEquAttr(unit_user_equ equ) public async Task<unit_user_equ> GetUserEquAttr(unit_user_equ equ)
{ {
return equ; return equ;
} }

View File

@@ -187,22 +187,6 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
#endregion #endregion
#region
public async Task<game_ship> GetShipInfo(int shipId)
{
string key = string.Format(BaseCache.BaseCacheKey, "ShipData");
var data = await redis.GetHashAsync<game_ship>(key, shipId.ToString());
if (data == null)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<game_ship>();
data = await db.Queryable<game_ship>().Where(it => it.shipId == shipId).SingleAsync();
await redis.AddHashAsync(key, shipId.ToString(), data);
}
return data;
}
#endregion
#region #region

View File

@@ -34,6 +34,7 @@ public class GameTeamService(ISqlSugarClient DbClient, IRedisCache redis) : IGam
return data; return data;
} }
public async Task<game_team> GetTeamInfo(string teamId) public async Task<game_team> GetTeamInfo(string teamId)
{ {
string key = string.Format(UserCache.BaseCacheKeys, "TeamData", "TeamData"); string key = string.Format(UserCache.BaseCacheKeys, "TeamData", "TeamData");

View File

@@ -4,7 +4,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
{ {
#region #region
public async Task<UserAttrModel> GetUserAttrModel(string userId) public async Task<UserAttrModel> GetUserAttrModel(string userId, string scene = "Default")
{ {
UserAttrModel result = new UserAttrModel(); UserAttrModel result = new UserAttrModel();
result.id = userId; result.id = userId;
@@ -24,11 +24,149 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
result.agility = (int)unitAttr.agility; result.agility = (int)unitAttr.agility;
result.upBlood = (int)unitAttr.upBlood; result.upBlood = (int)unitAttr.upBlood;
result.upMorale = (int)unitAttr.upMorale; 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<AttrItem> ExtendAttrData = new List<AttrItem>();
#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<IGameEquService>();
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<IGameTeamService>();
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<UserAttrModel> 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; return result;
} }
@@ -257,10 +395,11 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
string key = string.Format(UserCache.BaseCacheKeys, "Recover:Morale", userId); string key = string.Format(UserCache.BaseCacheKeys, "Recover:Morale", userId);
return await redis.ExistsAsync(key); return await redis.ExistsAsync(key);
} }
public async Task LockRecoverMorale(string userId) public async Task LockRecoverMorale(string userId)
{ {
string key = string.Format(UserCache.BaseCacheKeys, "Recover:Morale", 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 #endregion
@@ -334,7 +473,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
#endregion #endregion
#region 线 #region 线
public async Task<bool> UpdateOnLineTime(string userId, string code, int time) public async Task<bool> UpdateOnLineTime(string userId, string code, int time)
{ {
@@ -347,10 +486,9 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
return result; return result;
} }
#endregion #endregion
#region #region
public async Task<unit_user_drug> GetUserDrug(string userId) public async Task<unit_user_drug> GetUserDrug(string userId)
{ {
@@ -359,6 +497,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
{ {
return await redis.GetHashAsync<unit_user_drug>(key, userId); return await redis.GetHashAsync<unit_user_drug>(key, userId);
} }
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_drug>(); var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_drug>();
var data = await db.Queryable<unit_user_drug>().Where(it => it.userId == userId).SingleAsync(); var data = await db.Queryable<unit_user_drug>().Where(it => it.userId == userId).SingleAsync();
if (data == null) if (data == null)
@@ -379,7 +518,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
bool result = await db.Updateable<unit_user_drug>(data).ExecuteCommandAsync() > 0; bool result = await db.Updateable<unit_user_drug>(data).ExecuteCommandAsync() > 0;
if (result) if (result)
{ {
await ClearUserDrug(data. userId); await ClearUserDrug(data.userId);
} }
return result; return result;
@@ -392,4 +531,86 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
} }
#endregion #endregion
#region
private async Task<List<unit_user_state>> GetUserStateData(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "AttrData", "State");
var data = await redis.GetHashAsync<List<unit_user_state>>(key, userId);
if (data == null)
{
long endTime = TimeExtend.GetTimeStampSeconds;
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_state>();
data = await db.Queryable<unit_user_state>().Where(it => it.userId == userId && it.endTime > endTime)
.ToListAsync();
await redis.AddHashAsync(key, userId, data);
}
return data;
}
public async Task<List<unit_user_state>> 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<bool> AddUserState(string userId, string groupId, string name, string scene, string tips,
List<AttrItem> attr, int time, int count = 1)
{
bool result = false;
long onTime = TimeExtend.GetTimeStampSeconds;
string usId = $"{userId}_{groupId}";
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_state>();
var usData = await db.Queryable<unit_user_state>().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
} }

View File

@@ -204,7 +204,7 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit
return result; return result;
} }
public async Task<bool> AddUserShip(string userId, string name, int goodsId, int speed, int weight) public async Task<bool> 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(); unit_user_ship ship = new unit_user_ship();
ship.usId = StringAssist.NewGuid; ship.usId = StringAssist.NewGuid;
@@ -213,6 +213,9 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit
ship.name = name; ship.name = name;
ship.speed = speed; ship.speed = speed;
ship.weight = weight; ship.weight = weight;
ship.copper = copper;
ship.sale = sale;
ship.remark = remark;
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_ship>(); var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_ship>();
bool result = await db.Insertable(ship).ExecuteCommandAsync() > 0; bool result = await db.Insertable(ship).ExecuteCommandAsync() > 0;
if (result) if (result)

View File

@@ -7,19 +7,19 @@ public class EquTool
//强化 //强化
equ = GetIntensifyAttr(equ); equ = GetIntensifyAttr(equ);
List<AttrItem> AttrData = GetUserEquAttrData(equ); List<AttrItem> 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 += equ.minAtk +=
Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.MinAtk), AttrData, (decimal)equ.minAtk)); Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.MinAtk), AttrData, (decimal)equ.minAtk));
equ.maxAtk += Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.Atk), AttrData, (decimal)equ.maxAtk)); equ.maxAtk += Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Atk), AttrData, (decimal)equ.maxAtk));
equ.maxAtk += equ.maxAtk +=
Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.MaxAtk), AttrData, (decimal)equ.minAtk)); Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.MaxAtk), AttrData, (decimal)equ.minAtk));
equ.Blood += Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.Blood), AttrData, (decimal)equ.Blood)); equ.Blood += Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Blood), AttrData, (decimal)equ.Blood));
equ.Defense += 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 += 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 += 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; return equ;
} }
@@ -123,7 +123,7 @@ public class EquTool
return Convert.ToInt32(result + onAttr); return Convert.ToInt32(result + onAttr);
} }
private static List<AttrItem> GetUserEquAttrData(unit_user_equ equ) public static List<AttrItem> GetUserEquAttrData(unit_user_equ equ)
{ {
List<AttrItem> AttrData = new List<AttrItem>(); List<AttrItem> AttrData = new List<AttrItem>();
//装备本身特性 //装备本身特性
@@ -162,37 +162,5 @@ public class EquTool
return AttrData; return AttrData;
} }
public static decimal GetAttrItemValue(string attrCode, List<AttrItem> 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;
}
} }

View File

@@ -0,0 +1,170 @@
namespace Application.Domain;
public class GameAttrTool
{
public static UserAttrModel GetRoleAttrTemp(UserAttrModel temp, List<AttrItem> 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<AttrItem> 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<AttrItem> 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;
}
}

View File

@@ -281,6 +281,34 @@ namespace Application.Web.Controllers.Login
{ token = token, refToken = userInfo.token, userId = userInfo.userId }); { token = token, refToken = userInfo.token, userId = userInfo.userId });
} }
[HttpPost]
public async Task<IPoAction> 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<string, object> loadData = new Dictionary<string, object>();
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 });
}
/// <summary> /// <summary>
/// 注册角色信息 /// 注册角色信息
/// </summary> /// </summary>

View File

@@ -50,6 +50,15 @@ public class GoodsController : ControllerBase
case "Weight": case "Weight":
UseState = 1; UseState = 1;
break; 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}级才可使用!"); 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, "使用物品")) if (await _goodsService.UpdateUserGoods(userId, 0, goodsId, count, "使用物品"))
{ {
string message = ""; string message = "";
@@ -119,6 +141,23 @@ public class GoodsController : ControllerBase
} }
else if (goodsInfo.code == nameof(GoodsEnum.Code.State)) else if (goodsInfo.code == nameof(GoodsEnum.Code.State))
{ {
UserStateModel stateConfig = JsonConvert.DeserializeObject<UserStateModel>(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<dynamic>(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); return PoAction.Ok(true, message);
@@ -128,4 +167,69 @@ public class GoodsController : ControllerBase
return PoAction.Message("使用失败,请稍后尝试!"); return PoAction.Message("使用失败,请稍后尝试!");
} }
} }
/// <summary>
/// 使用选择物品礼包
/// </summary>
/// <param name="goodsId"></param>
/// <param name="count"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> 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> choiceGoods = JsonConvert.DeserializeObject<List<ChoiceGoods>>(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("使用失败,请稍后尝试!");
}
}
} }

View File

@@ -10,14 +10,14 @@ namespace Application.Web.Controllers.Pub
[Authorize] [Authorize]
public class ShipController : ControllerBase public class ShipController : ControllerBase
{ {
private readonly IUnitUserWeight weightService; private readonly IUnitUserWeight _weightService;
private readonly IGameGoodsService goodsService; private readonly IUnitUserAccService _accService;
private readonly IUnitUserAccService accService;
public ShipController(IUnitUserWeight _weightService, IGameGoodsService _goodsService, IUnitUserAccService _accService) public ShipController(IUnitUserWeight weightService,
IUnitUserAccService accService)
{ {
accService = _accService; _accService = accService;
goodsService = _goodsService; _weightService = weightService;
weightService = _weightService;
} }
/// <summary> /// <summary>
@@ -28,27 +28,11 @@ namespace Application.Web.Controllers.Pub
public async Task<IPoAction> GetUserShip() public async Task<IPoAction> GetUserShip()
{ {
string userId = StateHelper.userId; string userId = StateHelper.userId;
var data = await weightService.GetUserShip(userId); var data = await _weightService.GetUserShip(userId);
//个人负重 //个人负重
var weightInfo = await weightService.GetUserWeightInfo(userId); var weightInfo = await _weightService.GetUserWeightInfo(userId);
return PoAction.Ok(new { data, weightInfo }); var maxShipWeight = await _weightService.GetUserShipMaxWeight(userId);
} return PoAction.Ok(new { data, onShip = weightInfo.shipOnWeight, maxShip = maxShipWeight });
/// <summary>
/// 获取船只详情
/// </summary>
/// <param name="shipId"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetShipInfo(int shipId)
{
var data = await goodsService.GetShipInfo(shipId);
if (data == null)
{
return PoAction.Message("船只详情不存在!");
}
return PoAction.Ok(new { data });
} }
/// <summary> /// <summary>
@@ -57,46 +41,25 @@ namespace Application.Web.Controllers.Pub
/// <param name="usId"></param> /// <param name="usId"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<IPoAction> BuyShip([FromBody] BuyShipParms parms) public async Task<IPoAction> SaleShip([FromBody] BuyShipParms parms)
{ {
var userShip = await weightService.GetUserShipInfo(parms.usId); var userShip = await _weightService.GetUserShipInfo(parms.usId);
if (userShip == null) if (userShip == null)
{ {
return PoAction.Message("船只不存在!"); return PoAction.Message("船只不存在!");
} }
string userId = StateHelper.userId; string userId = StateHelper.userId;
if (userShip.userId != userId) if (userShip.userId != userId)
{ {
return PoAction.Message("船只不存在!"); 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 _accService.UpdateUserCopper(userId, 1, Convert.ToInt64(userShip.sale), "出售船只获得!"))
}
if (await weightService.DeleteUserShip(userShip.usId, userId))
{
if (shipInfo.payType == AccEnum.AccType.copper.ToString())
{ {
if (await accService.UpdateUserCopper(userId, 1, Convert.ToInt64(shipInfo.salePrice), "出售船只获得!")) return PoAction.Ok(new { price = userShip.sale });
{
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("出售失败!");
}
} }
else else
{ {

View File

@@ -100,6 +100,7 @@ public class BagController : ControllerBase
break; break;
case 4: case 4:
code.Add(nameof(GoodsEnum.Code.Pack)); code.Add(nameof(GoodsEnum.Code.Pack));
code.Add(nameof(GoodsEnum.Code.ChoicePack));
break; break;
case 5: case 5:
code.Add(nameof(GoodsEnum.Code.Mak)); code.Add(nameof(GoodsEnum.Code.Mak));

View File

@@ -17,11 +17,12 @@ public class UserController : ControllerBase
private readonly IGameChatService _chatService; private readonly IGameChatService _chatService;
private readonly IGameSkillService _skillService; private readonly IGameSkillService _skillService;
private readonly IGameTeamService _teamService; private readonly IGameTeamService _teamService;
private readonly IGameEquService _equService;
public UserController(IUnitUserService userService, IUnitUserAttrService attrService, public UserController(IUnitUserService userService, IUnitUserAttrService attrService,
IUnitUserAccService accService, IGameMapService mapService, IUnitUserRelationService relationService, IUnitUserAccService accService, IGameMapService mapService, IUnitUserRelationService relationService,
IGameGoodsService goodsService, IGameChatService chatService, IGameSkillService skillService, IGameGoodsService goodsService, IGameChatService chatService, IGameSkillService skillService,
IGameTeamService teamService) IGameTeamService teamService, IGameEquService equService)
{ {
_userService = userService; _userService = userService;
_attrService = attrService; _attrService = attrService;
@@ -32,6 +33,7 @@ public class UserController : ControllerBase
_chatService = chatService; _chatService = chatService;
_skillService = skillService; _skillService = skillService;
_teamService = teamService; _teamService = teamService;
_equService = equService;
} }
@@ -52,7 +54,10 @@ public class UserController : ControllerBase
var vigourInfo = await _attrService.GetUserVigourInfo(userId); var vigourInfo = await _attrService.GetUserVigourInfo(userId);
var accInfo = await _accService.GetUserAccInfo(userId); var accInfo = await _accService.GetUserAccInfo(userId);
object acc = new { accInfo.gold, accInfo.cowry, accInfo.teach, accInfo.renown }; 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); return PoAction.Ok(result);
} }
@@ -165,7 +170,13 @@ public class UserController : ControllerBase
bool isFriend = await _relationService.CheckIsFriend(userId, userInfo.userId); bool isFriend = await _relationService.CheckIsFriend(userId, userInfo.userId);
bool isEnemy = await _relationService.CheckUserEnemy(userId, userInfo.userId); bool isEnemy = await _relationService.CheckUserEnemy(userId, userInfo.userId);
var team = await _teamService.GetUserTeamInfo(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); return PoAction.Ok(result);
} }

View File

@@ -14,4 +14,3 @@ global using Microsoft.AspNetCore.Mvc;
global using Application.Web; global using Application.Web;

View File

@@ -7,6 +7,10 @@ export class PageExtend {
navigateTo(route, { replace: true }) navigateTo(route, { replace: true })
} }
public static GetPath(): string {
const route = useRoute()
return route.fullPath;
}
public static QueryString(params: string): string { public static QueryString(params: string): string {
const route = useRoute() const route = useRoute()
const value = route.query[params] const value = route.query[params]

View File

@@ -23,6 +23,12 @@
<div class="common" v-if="useState == 1"> <div class="common" v-if="useState == 1">
<Abutton @click="showUseNumView = true">使用物品</Abutton> <Abutton @click="showUseNumView = true">使用物品</Abutton>
</div> </div>
<div class="common" v-if="useState == 2">
<Abutton @click="showUse">使用物品</Abutton>
</div>
<div class="common" v-if="useState == 3">
<Abutton @click="btnChoice">使用物品</Abutton>
</div>
</div> </div>
@@ -41,7 +47,7 @@
</GamePopup> </GamePopup>
<GamePopup v-model:show="showUseNumView" title="使用物品"> <GamePopup v-model:show="showUseNumView" title="使用物品">
<!-- 自定义内容 --> <!-- 自定义内容 -->
<div class="common"> <div class="common" style="margin-top: 10px;">
物品名称{{ data.goodsName }}<br> 物品名称{{ data.goodsName }}<br>
物品数量{{ count }}<br> 物品数量{{ count }}<br>
</div> </div>
@@ -50,6 +56,28 @@
<button class="ipt-btn" name="serch" @click="UseGoods" style="margin-top: 15px;">确认</button> <button class="ipt-btn" name="serch" @click="UseGoods" style="margin-top: 15px;">确认</button>
</div> </div>
</GamePopup> </GamePopup>
<GamePopup v-model:show="showUseView" title="使用物品">
<!-- 自定义内容 -->
<div class="common" style="margin-top: 10px;">
物品名称{{ data.goodsName }}<br>
物品数量{{ count }}<br>
</div>
<div class="common" style="text-align: center;">
<button class="ipt-btn" name="serch" @click="UseGoods" style="margin-top: 15px;">确认</button>
</div>
</GamePopup>
<GamePopup v-model:show="showChoiceView" title="选择物品" style="min-width: 60%;">
<!-- 自定义内容 -->
<div class="common" style="margin-top: 15px;">
<div class="item border-btm" v-for="item in choiceData">
<div>
{{ item.id }}.{{ item.name }}
<Abutton @click="btnChoiceOk(item.id)">选择</Abutton>
</div>
<div v-html="GameTool.GetPropHtml(item.award, 1, 2)"></div>
</div>
</div>
</GamePopup>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@@ -79,7 +107,6 @@ const BindData = async (): Promise<void> => {
data.value = result.data.goods; data.value = result.data.goods;
count.value = result.data.count; count.value = result.data.count;
useState.value = result.data.use; useState.value = result.data.use;
console.log(result);
} }
else { else {
MessageExtend.ShowDialog("提示", result.msg); MessageExtend.ShowDialog("提示", result.msg);
@@ -110,17 +137,46 @@ const AddDrugBar = async () => {
MessageExtend.ShowDialog("提示", result.msg); MessageExtend.ShowDialog("提示", result.msg);
} }
} }
const showUseView = ref(false);
const showUse = () => {
useCount.value = 1;
showUseView.value = true;
}
const showUseNumView = ref(false); const showUseNumView = ref(false);
const UseGoods = async () => { const UseGoods = async () => {
MessageExtend.LoadingToast("使用中..."); MessageExtend.LoadingToast("使用中...");
let result = await GoodsService.UseGoods(Number(goodsId),useCount.value); let result = await GoodsService.UseGoods(Number(goodsId), useCount.value);
MessageExtend.LoadingClose(); MessageExtend.LoadingClose();
if (result.code == 0) { if (result.code == 0) {
showUseNumView.value = false; showUseNumView.value = false;
showUseView.value = false;
await BindData(); await BindData();
MessageExtend.Notify(result.msg, "success",5000); MessageExtend.Notify(result.msg, "success", 5000);
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
}
const showChoiceView = ref(false);
const choiceData = ref<Array<any>>([]);
const btnChoice = () => {
choiceData.value = JSON.parse(data.value.content);
console.log(choiceData.value);
showChoiceView.value = true;
}
const btnChoiceOk = async (id: number) => {
MessageExtend.LoadingToast("使用中...");
let result = await GoodsService.UseChoiceGoods(Number(goodsId), id);
MessageExtend.LoadingClose();
if (result.code == 0) {
showChoiceView.value = false;
await BindData();
MessageExtend.Notify(result.msg, "success", 5000);
} }
else { else {
MessageExtend.ShowDialog("提示", result.msg); MessageExtend.ShowDialog("提示", result.msg);

View File

@@ -0,0 +1,79 @@
<template>
<div class="content">
我的书签
</div>
<div class="content">
当前书签地址<Abutton @click="handleCopy">复制</Abutton>
<div>
{{ url }}
</div>
</div>
<div class="content" style="font-size: 14px;;">
说明保存书签的方式有两种:<br>
1.保存本页面为书签<br>
2.复制上方地址,进行保存<br>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const url = ref('');
onMounted(async () => {
try {
url.value = window.location.href;
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async () => {
let refToken = PageExtend.QueryString("sid");
let result = await LoginService.RefreshTokenByBook(refToken, "");
if (result.code == 0) {
StateHelper.SetToken(result.data.userId, result.data.token, result.data.refToken);
}
else {
MessageExtend.ShowDialogEvent("提示", result.msg, () => {
PageExtend.RedirectTo("/");
});
}
}
// 复制方法
const handleCopy = async () => {
try {
await copy(url.value)
MessageExtend.ShowToast("复制成功!", "success");
} catch (e) {
MessageExtend.ShowToast("复制失败!", "fail")
}
}
// 兼容全浏览器复制方法
const copy = async (text: string) => {
// 1. 优先现代剪贴板API
if (navigator.clipboard && window.isSecureContext) {
try {
await navigator.clipboard.writeText(text)
return true
} catch (err) {
console.log('clipboard复制失败启用降级方案', err)
}
}
// 2. 降级创建隐藏输入框复制
const input = document.createElement('input')
input.value = text
// 移出可视区域
input.style.cssText = 'position:absolute;left:-9999px;top:-9999px;'
document.body.appendChild(input)
input.select()
document.execCommand('copy')
document.body.removeChild(input)
return true
}
</script>

View File

@@ -25,6 +25,14 @@
活力:{{ vitality }}<br> 活力:{{ vitality }}<br>
罪恶值:0<br> 罪恶值:0<br>
帮派:<br> 帮派:<br>
<div v-if="buff.length > 0">
---BUFF状态---<br>
<div v-for="item in buff">
{{item.name}}:{{item.tips}}(剩余{{ item.endTime - TimeExtend.GetSecondStamp() }})
</div>
</div>
<!-- ---药品状态---<br> <!-- ---药品状态---<br>
体力宝+24370<br> 体力宝+24370<br>
耐久包+0<br> --> 耐久包+0<br> -->
@@ -58,6 +66,7 @@ const vitality = ref(0);
const expData = ref<any>({}); const expData = ref<any>({});
const attrData = ref<any>({}); const attrData = ref<any>({});
const accData = ref<any>({}); const accData = ref<any>({});
const buff = ref<any>([]);
onMounted(async () => { onMounted(async () => {
try { try {
@@ -78,6 +87,7 @@ const BindData = async (): Promise<void> => {
expData.value = result.data.exp; expData.value = result.data.exp;
attrData.value = result.data.attr; attrData.value = result.data.attr;
accData.value = result.data.acc; accData.value = result.data.acc;
buff.value = result.data.buff;
console.log(result); console.log(result);
} }
else { else {

View File

@@ -21,6 +21,9 @@
<div class="item border-btm "> <div class="item border-btm ">
<Abutton @click="RefreshSetting(1)">刷新图标</Abutton><span style="font-size: 14px;;">(*更新图标数据)</span> <Abutton @click="RefreshSetting(1)">刷新图标</Abutton><span style="font-size: 14px;;">(*更新图标数据)</span>
</div> </div>
<div class="item border-btm ">
<Abar :href='"/user/book?sid="+StateHelper.refToken'>我的书签</Abar>
</div>
</div> </div>
</template> </template>

View File

@@ -1,10 +1,10 @@
<template> <template>
<div class="content">我的船队</div> <div class="content">我的船队</div>
<div class="content">现负重/总负重({{weight.onWeight}}/{{weight.maxWeight}}):</div> <div class="content">现负重/总负重({{weight}}/{{maxShip}}):</div>
<div class="content"> <div class="content">
<div class="item" v-for="(item,index) in data" :key="index"> <div class="item" v-for="(item,index) in data" :key="index">
{{index+1}}.<Abutton @click="showView(item)">{{item.name}}</Abutton> {{index+1}}.<Abutton @click="showView(item)">{{item.name}}</Abutton>
<Abutton @click="buyShip(item)">卖出</Abutton> <Abutton @click="saleShip(item)">卖出</Abutton>
</div> </div>
<span v-if="data.length==0">暂无船只,请通过Npc购买!</span> <span v-if="data.length==0">暂无船只,请通过Npc购买!</span>
</div> </div>
@@ -14,14 +14,15 @@
<GamePopup v-model:show="showInfo" title="【船只说明】" style="width: 50%;"> <GamePopup v-model:show="showInfo" title="【船只说明】" style="width: 50%;">
<!-- 自定义内容 --> <!-- 自定义内容 -->
<div class="content"> <div class="content">
名称:{{shipInfo.shipName}}<br> 名称:{{onShow.name}}<br>
介绍:{{shipInfo.remark}}<br> 介绍:{{onShow.remark}}<br>
载重:{{shipInfo.weight}}<br> 载重:{{onShow.weight}}<br>
卖出价格:{{shipInfo.salePrice}}{{ GameTool.GetCurrencyName(shipInfo.payType) }}<br> 卖出价格:{{GameTool.FormatCopper(onShow.sale) }}<br>
时速:{{shipInfo.speed}}<br> 时速:{{onShow.speed}}<br>
消耗:{{shipInfo.neeGold}}铜贝//百海里<br> 消耗:{{onShow.copper}}铜贝//百海里<br>
</div> </div>
</GamePopup> </GamePopup>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
definePageMeta({ definePageMeta({
@@ -30,10 +31,10 @@
}) })
const data = ref<Array<any>>([]); const data = ref<Array<any>>([]);
const weight = ref<any>({}); const weight = ref(0);
const showInfo = ref(false); const showInfo = ref(false);
const onShow = ref<any>({}); const onShow = ref<any>({});
const shipInfo = ref<any>({}); const maxShip = ref(0);
onMounted(async () => { onMounted(async () => {
try { try {
@@ -45,36 +46,26 @@
}) })
const BindData = async () => { const BindData = async () => {
let result = await ShipService.GetShipData(); let result = await ShipService.GetUserShip();
if (result.code == 0) { if (result.code == 0) {
data.value = result.data.data; data.value = result.data.data;
weight.value = result.data.weightInfo; weight.value = result.data.onShip;
maxShip.value = result.data.maxShip;
console.log(weight.value);
} }
else { else {
MessageExtend.ShowDialog("船队", result.msg); MessageExtend.ShowDialog("船队", result.msg);
} }
} }
const GetShipInfo = async (shipId : string) => {
let result = await ShipService.GetShipInfo(shipId);
if (result.code == 0) {
shipInfo.value = result.data.data;
console.log(shipInfo.value)
}
else {
MessageExtend.ShowDialog("船只详情", result.msg);
}
}
const showView = (data : any) => { const showView = (data : any) => {
GetShipInfo(data.goodsId)
showInfo.value = true; showInfo.value = true;
onShow.value = data; onShow.value = data;
} }
const buyShip = async (data : any) => { const saleShip = async (data : any) => {
MessageExtend.ShowConfirmDialogAsyc("船只操作", `您确定要出售船只吗?`, async () => { MessageExtend.ShowConfirmDialogAsyc("船只操作", `您确定要出售船只吗?`, async () => {
let result = await ShipService.BuyShip(data.usId); let result = await ShipService.SaleShip(data.usId);
if (result.code == 0) { if (result.code == 0) {
MessageExtend.Notify("出售成功,获得" + data.copper + "铜贝", "success"); MessageExtend.Notify("出售成功,获得" + data.copper + "铜贝", "success");
await BindData(); await BindData();

View File

@@ -28,28 +28,78 @@
<div class="content"> <div class="content">
{{ attrData.lev }}{{ userData.sex }}({{ onMap }}) {{ attrData.lev }}{{ userData.sex }}({{ onMap }})
</div> </div>
<div class="content"> <div>
手持: <br> <div class="content">
副手:<br> 手持:
头戴:<br> <span class="item" v-for="item in Hold">
身穿: <br> <GameEqu :equ-data="item" :show-url="true" :show-lev="1"></GameEqu>
腰带: <br> </span>
脚穿: <br> </div>
佩戴: <br> <div class="content">
时装:<br> 副手:
羽翼: <br> <span class="item" v-for="item in Vice">
装饰: <br> <GameEqu :equ-data="item" :show-url="true" :show-lev="1"></GameEqu>
套装: <br> </span>
帮会: <br> </div>
<div v-if="team.state == 1"> <div class="content">
队伍:<Abar :href='"/user/team/info?id=" + team.team.teamId'>{{ team.team.name }}</Abar> 头戴:
<span class="item" v-for="item in Head">
<GameEqu :equ-data="item" :show-url="true" :show-lev="1"></GameEqu>
</span>
</div>
<div class="content">
身穿:
<span class="item" v-for="item in Wear">
<GameEqu :equ-data="item" :show-url="true" :show-lev="1"></GameEqu>
</span>
</div>
<div class="content">
腰带:
<span class="item" v-for="item in Waist">
<GameEqu :equ-data="item" :show-url="true" :show-lev="1"></GameEqu>
</span>
</div>
<div class="content">
脚穿:
<span class="item" v-for="item in Foot">
<GameEqu :equ-data="item" :show-url="true" :show-lev="1"></GameEqu>
</span>
</div>
<div class="content">
佩戴:
<span class="item" v-for="item in Ornaments">
<GameEqu :equ-data="item" :show-url="true" :show-lev="1"></GameEqu>
</span>
</div>
<div class="content">
时装:
<span class="item" v-for="item in Fashion">
<GameEqu :equ-data="item" :show-url="true" :show-lev="1"></GameEqu>
</span>
</div>
<div class="content">
羽翼:
<span class="item" v-for="item in Wing">
<GameEqu :equ-data="item" :show-url="true" :show-lev="1"></GameEqu>
</span>
</div>
<div class="content">
装饰:
<span class="item" v-for="item in Decorate">
<GameEqu :equ-data="item" :show-url="true" :show-lev="1"></GameEqu>
</span>
</div>
<div class="content" v-if="suit.length > 0">
<div class="item" v-for="item in suit">
套装:<Abar :href='"/prop/suit?no=" + item.suitCode'>{{ item.suitName }}</Abar>
</div>
</div> </div>
</div> </div>
<div class="content"></div> <div class="content" v-if="team.state == 1">
队伍:<Abar :href='"/user/team/info?id=" + team.team.teamId'>{{ team.team.name }}</Abar>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import Team from './team/team.vue';
definePageMeta({ definePageMeta({
layout: layout.default, layout: layout.default,
@@ -63,6 +113,20 @@ const onMap = ref('');
const isFriend = ref(false); const isFriend = ref(false);
const isEnemy = ref(false); const isEnemy = ref(false);
const team = ref<any>({}); const team = ref<any>({});
/**装备定义 */
const equ = ref<Array<any>>([]);
const suit = ref<Array<any>>([]);
const Hold = ref<Array<any>>([]);
const Vice = ref<Array<any>>([]);
const Head = ref<Array<any>>([]);
const Wear = ref<Array<any>>([]);
const Waist = ref<Array<any>>([]);
const Foot = ref<Array<any>>([]);
const Ornaments = ref<Array<any>>([]);
const Fashion = ref<Array<any>>([]);
const Wing = ref<Array<any>>([]);
const Decorate = ref<Array<any>>([]);
onMounted(async () => { onMounted(async () => {
try { try {
await BindData(); await BindData();
@@ -86,7 +150,20 @@ const BindData = async (): Promise<void> => {
isFriend.value = result.data.isFriend; isFriend.value = result.data.isFriend;
isEnemy.value = result.data.isEnemy; isEnemy.value = result.data.isEnemy;
team.value = result.data.team; team.value = result.data.team;
console.log(result);
equ.value = result.data.equ;
suit.value = result.data.suit;
Hold.value = equ.value.filter(it => it.code == 'Hold');
Vice.value = equ.value.filter(it => it.code == 'Vice');
Head.value = equ.value.filter(it => it.code == 'Head');
Wear.value = equ.value.filter(it => it.code == 'Wear');
Waist.value = equ.value.filter(it => it.code == 'Waist');
Foot.value = equ.value.filter(it => it.code == 'Foot');
Ornaments.value = equ.value.filter(it => it.code == 'Ornaments');
Fashion.value = equ.value.filter(it => it.code == 'Fashion');
Wing.value = equ.value.filter(it => it.code == 'Wing');
Decorate.value = equ.value.filter(it => it.code == 'Decorate');
} }
else if (result.code == 101) { else if (result.code == 101) {
return PageExtend.RedirectTo("/user"); return PageExtend.RedirectTo("/user");

View File

@@ -15,4 +15,12 @@ export class GoodsService {
static async UseGoods(goodsId: number, count: number) { static async UseGoods(goodsId: number, count: number) {
return await ApiService.Request("get", "/Goods/UseGoods", { goodsId, count }); return await ApiService.Request("get", "/Goods/UseGoods", { goodsId, count });
} }
/**
* 使用选择物品礼包
* GET /Goods/UseChoiceGoods
*/
static async UseChoiceGoods(goodsId: number, num: number) {
return await ApiService.Request("get", "/Goods/UseChoiceGoods", { goodsId, num });
}
} }

View File

@@ -1,26 +1,18 @@
export class ShipService { export class ShipService {
/** /**
* 获取船队列表 * 获取用户船只
* GET /Ship/GetUserShip * GET /Ship/GetUserShip
*/ */
static async GetShipData() { static async GetUserShip() {
return await ApiService.Request("get", "/Ship/GetUserShip"); return await ApiService.Request("get", "/Ship/GetUserShip");
} }
/** /**
* 获取船只详情 * 出售船只
* GET /Ship/GetShipInfo * POST /Ship/SaleShip
*/ * @param usId body
static async GetShipInfo(shipId : string) { */
return await ApiService.Request("get", "/Ship/GetShipInfo", { shipId }); static async SaleShip(usId: string) {
} return await ApiService.Request("post", "/Ship/SaleShip", { usId });
}
/**
* 出售船只
* GET /Ship/BuyShip
*/
static async BuyShip(usId : string) {
return await ApiService.Request("post", "/Ship/BuyShip", { usId });
}
} }

View File

@@ -53,6 +53,16 @@ export class LoginService {
return await ApiService.Request("post", "/Login/RefreshToken", { refToken, token }); return await ApiService.Request("post", "/Login/RefreshToken", { refToken, token });
} }
/**
* RefreshTokenByBook
* POST /Login/RefreshTokenByBook
* @param refToken body
* @param token body
*/
static async RefreshTokenByBook(refToken: string, token: string) {
return await ApiService.Request("post", "/Login/RefreshTokenByBook", { refToken, token });
}
/** /**
* 注册角色信息 * 注册角色信息
* POST /Login/RegisterInfo * POST /Login/RegisterInfo

View File

@@ -87,7 +87,10 @@ export class GameTool {
data.forEach(element => { data.forEach(element => {
let num = Number(element.count) * count; let num = Number(element.count) * count;
if (type == 0) { if (type == 0) {
result += `${element.name}+${num}` result += `${element.name}+${num},`
}
else if (type == 2) {
result += `${this.GetPropUrl(element.code, element.name, element.parameter)}+${num},`
} }
else { else {
result += `<div class='n-item'>▸${this.GetPropUrl(element.code, element.name, element.parameter)}+${num}</div>`; result += `<div class='n-item'>▸${this.GetPropUrl(element.code, element.name, element.parameter)}+${num}</div>`;