Lots more work on implementing battling

This commit is contained in:
2024-08-10 09:44:46 +02:00
parent 554e1cf2cd
commit a049dda240
29 changed files with 1226 additions and 48 deletions

View File

@@ -0,0 +1,41 @@
using System.Diagnostics.CodeAnalysis;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Dynamic.ScriptHandling;
/// <summary>
/// Class responsible for the creation of <see cref="Script"/> instances.
/// </summary>
public class ScriptResolver
{
private Dictionary<(ScriptCategory, StringKey), Func<Script>> _scriptCtors;
/// <inheritdoc cref="ScriptResolver"/>
public ScriptResolver(Dictionary<(ScriptCategory, StringKey), Func<Script>> scriptCtors)
{
_scriptCtors = scriptCtors;
}
/// <summary>
/// Try and create a new script for the given category and key. If the script does not exist, return false.
/// </summary>
public bool TryResolve(ScriptCategory category, StringKey key, [MaybeNullWhen(false)] out Script script)
{
if (!_scriptCtors.TryGetValue((category, key), out var scriptCtor))
{
script = null;
return false;
}
script = scriptCtor();
return true;
}
/// <summary>
/// Try and resolve an item script for the given item. If the item does not have a script, return false.
/// </summary>
public bool TryResolveItemScript(IItem item, [MaybeNullWhen(false)] out Script script)
{
throw new NotImplementedException();
}
}