fix: Cleans up code with feeding pets and adds batch coin flips random check (#1717)
This commit is contained in:
parent
183f6fa4ac
commit
29ea813242
5 changed files with 186 additions and 128 deletions
|
|
@ -30,34 +30,38 @@ public enum ImageType
|
|||
|
||||
public class ImageTypeInfo
|
||||
{
|
||||
private static readonly ImageTypeInfo[] m_Table =
|
||||
{
|
||||
new(9734, typeof(Betrayer), 75, 45),
|
||||
new(9735, typeof(Bogling), 75, 45),
|
||||
new(9736, typeof(BogThing), 60, 47),
|
||||
new(9615, typeof(Gazer), 75, 45),
|
||||
new(9743, typeof(Beetle), 60, 55),
|
||||
new(9667, typeof(GiantBlackWidow), 55, 52),
|
||||
new(9657, typeof(Scorpion), 65, 47),
|
||||
new(9758, typeof(JukaMage), 75, 45),
|
||||
new(9759, typeof(JukaWarrior), 75, 45),
|
||||
new(9636, typeof(Lich), 75, 45),
|
||||
new(9756, typeof(MeerMage), 75, 45),
|
||||
new(9757, typeof(MeerWarrior), 75, 45),
|
||||
new(9638, typeof(Mongbat), 70, 50),
|
||||
new(9639, typeof(Mummy), 75, 45),
|
||||
new(9654, typeof(Pixie), 75, 45),
|
||||
new(9747, typeof(PlagueBeast), 60, 45),
|
||||
new(9750, typeof(SandVortex), 60, 43),
|
||||
new(9614, typeof(StoneGargoyle), 75, 45),
|
||||
new(9753, typeof(SwampDragon), 50, 55),
|
||||
new(8448, typeof(Wisp), 75, 45),
|
||||
new(9746, typeof(Juggernaut), 55, 38)
|
||||
};
|
||||
private static readonly ImageTypeInfo[] _table =
|
||||
[
|
||||
new ImageTypeInfo(9734, typeof(Betrayer), ImageType.Betrayer, 75, 45),
|
||||
new ImageTypeInfo(9735, typeof(Bogling), ImageType.Bogling, 75, 45),
|
||||
new ImageTypeInfo(9736, typeof(BogThing), ImageType.BogThing, 60, 47),
|
||||
new ImageTypeInfo(9615, typeof(Gazer), ImageType.Gazer, 75, 45),
|
||||
new ImageTypeInfo(9743, typeof(Beetle), ImageType.Beetle, 60, 55),
|
||||
new ImageTypeInfo(9667, typeof(GiantBlackWidow), ImageType.GiantBlackWidow, 55, 52),
|
||||
new ImageTypeInfo(9657, typeof(Scorpion), ImageType.Scorpion, 65, 47),
|
||||
new ImageTypeInfo(9758, typeof(JukaMage), ImageType.JukaMage, 75, 45),
|
||||
new ImageTypeInfo(9759, typeof(JukaWarrior), ImageType.JukaWarrior, 75, 45),
|
||||
new ImageTypeInfo(9636, typeof(Lich), ImageType.Lich, 75, 45),
|
||||
new ImageTypeInfo(9756, typeof(MeerMage), ImageType.MeerMage, 75, 45),
|
||||
new ImageTypeInfo(9757, typeof(MeerWarrior), ImageType.MeerWarrior, 75, 45),
|
||||
new ImageTypeInfo(9638, typeof(Mongbat), ImageType.Mongbat, 70, 50),
|
||||
new ImageTypeInfo(9639, typeof(Mummy), ImageType.Mummy, 75, 45),
|
||||
new ImageTypeInfo(9654, typeof(Pixie), ImageType.Pixie, 75, 45),
|
||||
new ImageTypeInfo(9747, typeof(PlagueBeast), ImageType.PlagueBeast, 60, 45),
|
||||
new ImageTypeInfo(9750, typeof(SandVortex), ImageType.SandVortex, 60, 43),
|
||||
new ImageTypeInfo(9614, typeof(StoneGargoyle), ImageType.StoneGargoyle, 75, 45),
|
||||
new ImageTypeInfo(9753, typeof(SwampDragon), ImageType.SwampDragon, 50, 55),
|
||||
new ImageTypeInfo(8448, typeof(Wisp), ImageType.Wisp, 75, 45),
|
||||
new ImageTypeInfo(9746, typeof(Juggernaut), ImageType.Juggernaut, 55, 38)
|
||||
];
|
||||
|
||||
public ImageTypeInfo(int figurine, Type type, int x, int y)
|
||||
// Used for sampling
|
||||
private static readonly ImageTypeInfo[] _shuffleTable = (ImageTypeInfo[])_table.Clone();
|
||||
|
||||
public ImageTypeInfo(int figurine, Type type, ImageType image, int x, int y)
|
||||
{
|
||||
Figurine = figurine;
|
||||
Image = image;
|
||||
Type = type;
|
||||
X = x;
|
||||
Y = y;
|
||||
|
|
@ -65,6 +69,8 @@ public class ImageTypeInfo
|
|||
|
||||
public int Figurine { get; }
|
||||
|
||||
public ImageType Image { get; }
|
||||
|
||||
public Type Type { get; }
|
||||
|
||||
public int Name => Figurine < 0x4000 ? 1020000 + Figurine : 1078872 + Figurine;
|
||||
|
|
@ -74,7 +80,7 @@ public class ImageTypeInfo
|
|||
public static ImageTypeInfo Get(ImageType image)
|
||||
{
|
||||
var index = (int)image;
|
||||
return m_Table[index >= 0 && index < m_Table.Length ? index : 0];
|
||||
return _table[index >= 0 && index < _table.Length ? index : 0];
|
||||
}
|
||||
|
||||
public static ImageType[] RandomList(int count)
|
||||
|
|
@ -84,21 +90,14 @@ public class ImageTypeInfo
|
|||
return Array.Empty<ImageType>();
|
||||
}
|
||||
|
||||
var length = m_Table.Length;
|
||||
Span<bool> list = stackalloc bool[length];
|
||||
list.Clear();
|
||||
|
||||
_shuffleTable.Shuffle();
|
||||
var imageTypes = new ImageType[count];
|
||||
|
||||
var i = 0;
|
||||
do
|
||||
var minCount = Math.Min(count, _shuffleTable.Length);
|
||||
for (var i = 0; i < minCount; i++)
|
||||
{
|
||||
var rand = Utility.Random(length);
|
||||
if (!(list[rand] && (list[rand] = true)))
|
||||
{
|
||||
imageTypes[i++] = (ImageType)rand;
|
||||
}
|
||||
} while (i < count);
|
||||
imageTypes[i] = _shuffleTable[i].Image;
|
||||
}
|
||||
|
||||
return imageTypes;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue