121212
This commit is contained in:
@@ -64,6 +64,11 @@ public static class GameBus
|
||||
isok = await accService.UpdateUserAcc(userId, operate, nameof(AccEnum.AccType.teach), count,
|
||||
nameof(AccEnum.Name.其他), remark);
|
||||
}
|
||||
else if (goodsType.Equals(nameof(GameEnum.PropCode.map)))
|
||||
{
|
||||
var mapService = App.GetService<IGameMapService>();
|
||||
isok = await mapService.AddUserCityMap(userId, Convert.ToInt32(parameter));
|
||||
}
|
||||
|
||||
return isok;
|
||||
}
|
||||
@@ -338,6 +343,7 @@ public static class GameBus
|
||||
isok = false;
|
||||
}
|
||||
}
|
||||
|
||||
result.Needs.Add(item);
|
||||
}
|
||||
|
||||
@@ -351,6 +357,28 @@ public static class GameBus
|
||||
|
||||
#region 概率
|
||||
|
||||
public static RandomDataBase GetRandomByWeight(List<RandomDataBase> data)
|
||||
{
|
||||
var _randomInstance = new Random();
|
||||
if (data.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
double totalWeight = data.Sum(it => it.random);
|
||||
int rnd = _randomInstance.Next(Convert.ToInt32(totalWeight) + 1);
|
||||
double current = 0;
|
||||
foreach (var item in data)
|
||||
{
|
||||
current += item.random;
|
||||
if (rnd < current)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<TowerGet> GetRandomGoods(RandomModel random, int count = 1, int luck = 0)
|
||||
{
|
||||
List<TowerGet> result = new List<TowerGet>();
|
||||
|
||||
Reference in New Issue
Block a user