1212121
This commit is contained in:
@@ -14,8 +14,10 @@ public static class GoodsEnum
|
||||
Card,//附魔卡片
|
||||
Mark,//圣痕
|
||||
Pack,//宝箱
|
||||
ChoicePack,//选择宝箱
|
||||
Weight,//负重
|
||||
Exp,//经验
|
||||
State,//状态物品
|
||||
Ship,//船只
|
||||
}
|
||||
}
|
||||
@@ -32,9 +32,10 @@ public interface IGameEquService
|
||||
bool isAddAttr = false);
|
||||
|
||||
Task<List<unit_user_equ>> GetUserOnEqu(string userId);
|
||||
Task<UserAttrModel> GetUserEquAttrModel(string userId);
|
||||
Task<bool> EquOnOrDown(unit_user_equ data, int state);
|
||||
Task<List<UserEquSuit>> GetUserEquSuit(string userId);
|
||||
|
||||
Task<List<AttrItem>> GetUserEquSuitAttrInfo(string userId);
|
||||
#endregion
|
||||
|
||||
#region 觉醒相关
|
||||
|
||||
@@ -28,8 +28,4 @@ public interface IGameGoodsService
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 船只
|
||||
Task<game_ship> GetShipInfo(int shipId);
|
||||
#endregion
|
||||
}
|
||||
@@ -4,7 +4,7 @@ public interface IUnitUserAttrService
|
||||
{
|
||||
#region 个人属性
|
||||
|
||||
Task<UserAttrModel> GetUserAttrModel(string userId);
|
||||
Task<UserAttrModel> GetUserAttrModel(string userId, string scene = "Default");
|
||||
Task<unit_user_attr> GetUserAttr(string userId);
|
||||
Task<int> GetUserLev(string userId);
|
||||
#endregion
|
||||
@@ -51,5 +51,15 @@ public interface IUnitUserAttrService
|
||||
Task<unit_user_drug> GetUserDrug(string userId);
|
||||
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
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public interface IUnitUserWeight
|
||||
Task<bool> UpdateUserShipOnWeight(string userId, int op, int weight);
|
||||
Task<bool> CheakUserShipWeight(string userId, int useWeight);
|
||||
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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
var key = string.Format(UserCache.BaseCacheKeys, "EquData", "UserOnEqu");
|
||||
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);
|
||||
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)
|
||||
@@ -544,6 +581,30 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
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
|
||||
|
||||
#region 觉醒
|
||||
@@ -672,7 +733,7 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
foreach (var item in attrResult)
|
||||
{
|
||||
var onAttr = item as game_equ_attr;
|
||||
|
||||
|
||||
AttrItem temp = new AttrItem();
|
||||
temp.code = onAttr.code;
|
||||
temp.compute = onAttr.compute;
|
||||
@@ -708,7 +769,6 @@ public class GameEquService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
|
||||
|
||||
public async Task<unit_user_equ> GetUserEquAttr(unit_user_equ equ)
|
||||
{
|
||||
|
||||
return equ;
|
||||
}
|
||||
|
||||
|
||||
@@ -187,22 +187,6 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
|
||||
|
||||
#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 药品
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ public class GameTeamService(ISqlSugarClient DbClient, IRedisCache redis) : IGam
|
||||
await redis.AddHashAsync(key, userId, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
public async Task<game_team> GetTeamInfo(string teamId)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
{
|
||||
#region 个人属性
|
||||
|
||||
public async Task<UserAttrModel> GetUserAttrModel(string userId)
|
||||
public async Task<UserAttrModel> GetUserAttrModel(string userId, string scene = "Default")
|
||||
{
|
||||
UserAttrModel result = new UserAttrModel();
|
||||
result.id = userId;
|
||||
@@ -24,11 +24,149 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
result.agility = (int)unitAttr.agility;
|
||||
result.upBlood = (int)unitAttr.upBlood;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -257,10 +395,11 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
string key = string.Format(UserCache.BaseCacheKeys, "Recover:Morale", userId);
|
||||
return await redis.ExistsAsync(key);
|
||||
}
|
||||
|
||||
public async Task LockRecoverMorale(string 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 士气
|
||||
@@ -334,7 +473,7 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
|
||||
#endregion 活力
|
||||
|
||||
#region 在线时间
|
||||
#region 在线时间
|
||||
|
||||
public async Task<bool> UpdateOnLineTime(string userId, string code, int time)
|
||||
{
|
||||
@@ -347,10 +486,9 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 药品栏
|
||||
#region 药品栏
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_drug>();
|
||||
var data = await db.Queryable<unit_user_drug>().Where(it => it.userId == userId).SingleAsync();
|
||||
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;
|
||||
if (result)
|
||||
{
|
||||
await ClearUserDrug(data. userId);
|
||||
await ClearUserDrug(data.userId);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -392,4 +531,86 @@ public class UnitUserAttrService(ISqlSugarClient DbClient, IRedisCache redis) :
|
||||
}
|
||||
|
||||
#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
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit
|
||||
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();
|
||||
ship.usId = StringAssist.NewGuid;
|
||||
@@ -213,6 +213,9 @@ public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnit
|
||||
ship.name = name;
|
||||
ship.speed = speed;
|
||||
ship.weight = weight;
|
||||
ship.copper = copper;
|
||||
ship.sale = sale;
|
||||
ship.remark = remark;
|
||||
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_ship>();
|
||||
bool result = await db.Insertable(ship).ExecuteCommandAsync() > 0;
|
||||
if (result)
|
||||
|
||||
@@ -7,19 +7,19 @@ public class EquTool
|
||||
//强化
|
||||
equ = GetIntensifyAttr(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 +=
|
||||
Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.MinAtk), AttrData, (decimal)equ.minAtk));
|
||||
equ.maxAtk += Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.Atk), AttrData, (decimal)equ.maxAtk));
|
||||
Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.MinAtk), AttrData, (decimal)equ.minAtk));
|
||||
equ.maxAtk += Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Atk), AttrData, (decimal)equ.maxAtk));
|
||||
equ.maxAtk +=
|
||||
Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.MaxAtk), AttrData, (decimal)equ.minAtk));
|
||||
equ.Blood += Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.Blood), AttrData, (decimal)equ.Blood));
|
||||
Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.MaxAtk), AttrData, (decimal)equ.minAtk));
|
||||
equ.Blood += Convert.ToInt32(GameAttrTool.GetAttrItemValue(nameof(GameEnum.AttrCode.Blood), AttrData, (decimal)equ.Blood));
|
||||
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 +=
|
||||
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 +=
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class EquTool
|
||||
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>();
|
||||
//装备本身特性
|
||||
@@ -162,37 +162,5 @@ public class EquTool
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
170
Service/Application.Domain/Tool/Base/GameAttrTool.cs
Normal file
170
Service/Application.Domain/Tool/Base/GameAttrTool.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user