diff --git a/src/BattleCoreRegistry.cs b/src/BattleCoreRegistry.cs
index 1195449..c202919 100644
--- a/src/BattleCoreRegistry.cs
+++ b/src/BattleCoreRegistry.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
+using Cthangover.Core.Games;
using Cthangover.Core.Utils;
namespace Cthangover.Core.Battle
@@ -16,6 +17,9 @@ namespace Cthangover.Core.Battle
///
public class BattleCoreRegistry
{
+ /// Game collection setting naming the battle core of that game.
+ public const string GameSettingKey = "battle.core";
+
/// Singleton registry instance.
public static readonly BattleCoreRegistry Instance = new();
@@ -68,15 +72,23 @@ namespace Cthangover.Core.Battle
}
///
- /// Constructs a fresh instance of the active core type. Falls
- /// back to the first registered core if no active ID was set.
- /// Throws if no cores are registered at all.
+ /// Constructs a fresh instance of the active core type. Without an
+ /// explicit battle.set_core the active game's
+ /// settings["battle.core"] decides, then the first registered
+ /// core. Throws if no cores are registered at all.
///
public IBattleCore GetActive()
{
if (_activeCoreId != null && _cores.ContainsKey(_activeCoreId))
return (IBattleCore)Activator.CreateInstance(_cores[_activeCoreId]);
+ var gameCore = ActiveGame.GetSetting(GameSettingKey);
+ if (gameCore != null && _cores.ContainsKey(gameCore))
+ {
+ _activeCoreId = gameCore;
+ return (IBattleCore)Activator.CreateInstance(_cores[gameCore]);
+ }
+
var firstId = GetFirstCoreId();
if (firstId != null)
{