mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2026-02-19 14:07:43 +01:00
Add UI stuff to random designs.
This commit is contained in:
parent
2a01b328e1
commit
139508917b
18 changed files with 744 additions and 117 deletions
37
Glamourer/Designs/Special/RandomDesignGenerator.cs
Normal file
37
Glamourer/Designs/Special/RandomDesignGenerator.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using OtterGui.Services;
|
||||
|
||||
namespace Glamourer.Designs.Special;
|
||||
|
||||
public class RandomDesignGenerator(DesignStorage designs, DesignFileSystem fileSystem) : IService
|
||||
{
|
||||
private readonly Random _rng = new();
|
||||
|
||||
public Design? Design(IReadOnlyList<Design> localDesigns)
|
||||
{
|
||||
if (localDesigns.Count == 0)
|
||||
return null;
|
||||
|
||||
var idx = _rng.Next(0, localDesigns.Count - 1);
|
||||
Glamourer.Log.Verbose($"[Random Design] Chose design {idx} out of {localDesigns.Count}: {localDesigns[idx].Incognito}.");
|
||||
return localDesigns[idx];
|
||||
}
|
||||
|
||||
public Design? Design()
|
||||
=> Design(designs);
|
||||
|
||||
public Design? Design(IDesignPredicate predicate)
|
||||
=> Design(predicate.Get(designs, fileSystem).ToList());
|
||||
|
||||
public Design? Design(IReadOnlyList<IDesignPredicate> predicates)
|
||||
{
|
||||
if (predicates.Count == 0)
|
||||
return Design();
|
||||
if (predicates.Count == 1)
|
||||
return Design(predicates[0]);
|
||||
|
||||
return Design(IDesignPredicate.Get(predicates, designs, fileSystem).ToList());
|
||||
}
|
||||
|
||||
public Design? Design(string restrictions)
|
||||
=> Design(RandomPredicate.GeneratePredicates(restrictions));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue