1212
This commit is contained in:
@@ -52,6 +52,16 @@ public class GameAttrTool
|
||||
result.PalsyAtk = GetAttrItemValue(GameEnum.AttrCode.PalsyAtk.ToString(), attrData, temp.PalsyAtk);
|
||||
result.PalsyAtkLess =
|
||||
GetAttrItemValue(GameEnum.AttrCode.PalsyAtkLess.ToString(), attrData, temp.PalsyAtk);
|
||||
|
||||
result.addExp =
|
||||
GetAttrItemValue(nameof(GameEnum.AttrCode.AddExp), attrData, temp.addExp);
|
||||
result.addGold =
|
||||
GetAttrItemValue(nameof(GameEnum.AttrCode.AddGold), attrData, temp.addGold);
|
||||
result.burst =
|
||||
GetAttrItemValue(nameof(GameEnum.AttrCode.Burst), attrData, temp.burst);
|
||||
result.luck =
|
||||
GetAttrItemValue(nameof(GameEnum.AttrCode.Luck), attrData, temp.luck);
|
||||
result.weight = Convert.ToInt32(GetAttrItemValue(nameof(GameEnum.AttrCode.Weight), attrData, temp.weight));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -96,6 +106,12 @@ public class GameAttrTool
|
||||
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);
|
||||
|
||||
result.addExp += GetAttrItemValue(GameEnum.AttrCode.AddExp.ToString(), attrData, 0);
|
||||
result.addGold += GetAttrItemValue(GameEnum.AttrCode.AddGold.ToString(), attrData, 0);
|
||||
result.burst += GetAttrItemValue(GameEnum.AttrCode.Burst.ToString(), attrData, 0);
|
||||
result.luck += GetAttrItemValue(GameEnum.AttrCode.Luck.ToString(), attrData, 0);
|
||||
result.weight += Convert.ToInt32(GetAttrItemValue(GameEnum.AttrCode.Weight.ToString(), attrData, 0)) ;
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -133,6 +149,12 @@ public class GameAttrTool
|
||||
main.Harm_Add += vice.Harm_Add;
|
||||
main.PalsyAtk += vice.PalsyAtk;
|
||||
main.PalsyAtkLess += vice.PalsyAtkLess;
|
||||
|
||||
main.addExp += vice.addExp;
|
||||
main.addGold += vice.addGold;
|
||||
main.burst += vice.burst;
|
||||
main.luck += vice.luck;
|
||||
main.weight += vice.weight;
|
||||
return main;
|
||||
}
|
||||
|
||||
|
||||
@@ -380,7 +380,7 @@ public static class GameBus
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<TowerGet> GetRandomGoods(RandomModel random, int count = 1, int luck = 0)
|
||||
public static List<TowerGet> GetRandomGoods(RandomModel random, int count = 1, decimal luck = 0)
|
||||
{
|
||||
List<TowerGet> result = new List<TowerGet>();
|
||||
for (int i = 0; i < count; i++)
|
||||
@@ -419,11 +419,11 @@ public static class GameBus
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<RandomData> RandomHandleByWeight(RandomModel random, int luck = 0)
|
||||
private static List<RandomData> RandomHandleByWeight(RandomModel random, decimal luck = 0)
|
||||
{
|
||||
var _randomInstance = new Random();
|
||||
List<RandomData> result = new List<RandomData>();
|
||||
int empty = random.empty - luck;
|
||||
int empty = random.empty - Convert.ToInt32(luck * 100);
|
||||
if (_randomInstance.Next(0, 100) < empty)
|
||||
{
|
||||
return result;
|
||||
@@ -450,11 +450,11 @@ public static class GameBus
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<RandomData> RandomHandleByChance(RandomModel random, int luck = 0)
|
||||
private static List<RandomData> RandomHandleByChance(RandomModel random, decimal luck = 0)
|
||||
{
|
||||
var _randomInstance = new Random();
|
||||
List<RandomData> result = new List<RandomData>();
|
||||
int empty = random.empty - luck;
|
||||
int empty = random.empty;
|
||||
if (_randomInstance.Next(0, 100) < empty)
|
||||
{
|
||||
return result;
|
||||
@@ -468,7 +468,7 @@ public static class GameBus
|
||||
foreach (var item in random.data)
|
||||
{
|
||||
double rnd = _randomInstance.NextDouble();
|
||||
double okChance = item.chance / 100;
|
||||
double okChance = (item.chance / 100) * (1.0 + Convert.ToDouble(luck));
|
||||
if (rnd < okChance)
|
||||
{
|
||||
result.Add(item);
|
||||
|
||||
47
Service/Application.Domain/Tool/Base/UserKeyTool.cs
Normal file
47
Service/Application.Domain/Tool/Base/UserKeyTool.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
namespace Application.Domain;
|
||||
|
||||
public static class UserKeyTool
|
||||
{
|
||||
public static async Task<string> GetThickenData(string userId, params string[] data)
|
||||
{
|
||||
string key = await GetUserKey(userId);
|
||||
return GetThickenDataByUserKey(key, data);
|
||||
}
|
||||
|
||||
public static string GetThickenDataByUserKey(string key, params string[] data)
|
||||
{
|
||||
string _data = string.Join("", data);
|
||||
return EncryptAssist.Md5Encryption($"{key}_{_data}").ToLower();
|
||||
}
|
||||
|
||||
|
||||
public static async Task<bool> CheckUserThickenData(string userId, string sign, params string[] data)
|
||||
{
|
||||
string key = await GetUserKey(userId);
|
||||
string _sign = GetThickenDataByUserKey(key, data);
|
||||
await ResetUserKey(userId);
|
||||
return sign.ToLower() == _sign;
|
||||
}
|
||||
|
||||
public static async Task<string> GetUserKey(string userId)
|
||||
{
|
||||
var key = string.Format(UserCache.BaseCacheKey, "UserKey");
|
||||
var redis = App.GetService<IRedisCache>();
|
||||
if (await redis.HExistsHashAsync(key, userId))
|
||||
{
|
||||
return await redis.GetHashAsync<string>(key, userId);
|
||||
}
|
||||
|
||||
string data = StringAssist.RandomString(12);
|
||||
await redis.AddHashAsync(key, userId, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
private static async Task ResetUserKey(string userId)
|
||||
{
|
||||
string data = StringAssist.RandomString(12);
|
||||
var key = string.Format(UserCache.BaseCacheKey, "UserKey");
|
||||
var redis = App.GetService<IRedisCache>();
|
||||
await redis.AddHashAsync(key, userId, data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user