//
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
namespace MUnique.OpenMU.GameLogic.Benchmarks.Helpers;
using Moq;
using MUnique.OpenMU.DataModel.Configuration;
using MUnique.OpenMU.DataModel.Configuration.Items;
using MUnique.OpenMU.GameLogic.Attributes;
///
/// Helper for creating test game configurations.
///
public static class GameConfigurationTestHelper
{
///
/// Creates a mock game configuration for drop generation testing.
///
/// A mock game configuration.
public static GameConfiguration Create()
{
var gameConfiguration = new Mock();
gameConfiguration.SetupAllProperties();
gameConfiguration.Object.ExcellentItemDropLevelDelta = 50;
gameConfiguration.Object.MaximumItemOptionLevelDrop = 3;
var items = CreateItems();
gameConfiguration.Setup(c => c.Items).Returns(items);
return gameConfiguration.Object;
}
private static IList CreateItems()
{
var items = new List();
var random = new Random(42);
for (byte dropLevel = 0; dropLevel <= 200; dropLevel++)
{
int itemsAtThisLevel = random.Next(5, 20);
for (int i = 0; i < itemsAtThisLevel; i++)
{
var item = new Mock();
item.SetupAllProperties();
item.Setup(d => d.PossibleItemSetGroups).Returns(new List());
item.Setup(d => d.PossibleItemOptions).Returns(CreateItemOptions(dropLevel));
item.Setup(d => d.Requirements).Returns(new List());
item.Setup(d => d.BasePowerUpAttributes).Returns(new List());
item.Setup(d => d.DropItems).Returns(new List());
item.Setup(d => d.QualifiedCharacters).Returns(new List());
item.Object.DropsFromMonsters = true;
item.Object.DropLevel = dropLevel;
item.Object.Width = (byte)(i % 4 + 1);
item.Object.Height = (byte)(i % 4 + 1);
item.Object.MaximumItemLevel = 13;
item.Object.MaximumSockets = dropLevel > 100 ? 5 : 0;
item.Object.Group = (byte)(dropLevel % 16);
item.Object.Number = (short)(i % 256);
items.Add(item.Object);
}
}
return items;
}
private static IList CreateItemOptions(byte dropLevel)
{
var options = new List();
if (dropLevel > 30)
{
var excellentOption = new Mock();
excellentOption.SetupAllProperties();
excellentOption.Setup(o => o.PossibleOptions).Returns(CreateExcellentOptions());
excellentOption.Object.AddsRandomly = true;
excellentOption.Object.AddChance = 100;
excellentOption.Object.MaximumOptionsPerItem = 6;
options.Add(excellentOption.Object);
}
if (dropLevel > 50)
{
var luckOption = new Mock();
luckOption.SetupAllProperties();
luckOption.Setup(o => o.PossibleOptions).Returns(new List());
luckOption.Object.AddsRandomly = true;
luckOption.Object.AddChance = 100;
luckOption.Object.MaximumOptionsPerItem = 1;
options.Add(luckOption.Object);
}
return options;
}
private static IList CreateExcellentOptions()
{
var options = new List();
for (int i = 0; i < 6; i++)
{
var option = new Mock();
option.SetupAllProperties();
option.Setup(o => o.LevelDependentOptions).Returns(new List());
options.Add(option.Object);
}
return options;
}
}