add modifier assignment priority

This commit is contained in:
AlchlcDvl authored and XtraCube committed 2024-12-21 15:16:19 -05:00
1 parent d3a815faa9
commit 5d05a07364
2 files changed
+22

No files matched your search

+15
View File
@@ -97,6 +97,21 @@ public static class ModifierManager
}
var shuffledModifiers = filteredModifiers.Randomize();
var map = new Dictionary<uint, int>();
foreach (var id in shuffledModifiers)
{
if (Activator.CreateInstance(IdToTypeModifierMap[id]) is not GameModifier mod)
{
Logger<MiraApiPlugin>.Error($"Failed to create instance of {IdToTypeModifierMap[id].Name}");
continue;
}
map[id] = mod.Priority();
}
shuffledModifiers = map.OrderByDescending(x => x.Value).Select(x => x.Key).ToList();
if (shuffledModifiers.Count > plrs.Count)
{
shuffledModifiers = shuffledModifiers.GetRange(0, plrs.Count);
+7
View File
@@ -17,6 +17,12 @@ public abstract class GameModifier : BaseModifier
/// <returns>An int value greater than or equal to zero.</returns>
public abstract int GetAmountPerGame();
/// <summary>
/// Gets the priority at which the modifier will spawn. The higher the value, the higher up on the assignment list.
/// </summary>
/// <returns>An int value greater than or equal to -1.</returns>
public virtual int Priority() => -1;
/// <summary>
/// Determines whether the modifier is valid on a role.
/// </summary>
@@ -27,6 +33,7 @@ public abstract class GameModifier : BaseModifier
/// <summary>
/// Determines whether the player won the game with this modifier.
/// </summary>
/// <param name="reason">The reason why the game ended.</param>
/// <returns>True if the player won, false if they lost. Return null to use the player's default win condition.</returns>
public virtual bool? DidWin(GameOverReason reason) => null;
}