More moves implemented

This commit is contained in:
2025-02-01 15:00:22 +01:00
parent 3a75493912
commit 00fe08dcd4
50 changed files with 1146 additions and 139 deletions

View File

@@ -115,6 +115,10 @@ public interface IBattle : IScriptSource, IDeepCloneable
/// </summary>
StringKey? WeatherName { get; }
void SetTerrain(StringKey? terrainName);
StringKey? TerrainName { get; }
/// <summary>
/// Gets the turn choices of the previous turn. This is a list of lists, where each list represents the choices
/// for a single turn. The outer list is ordered from oldest to newest turn.
@@ -267,6 +271,8 @@ public class BattleImpl : ScriptSource, IBattle
return false;
var preventMove = false;
choice.RunScriptHook(script => script.PreventMoveSelection(moveChoice, ref preventMove));
if (preventMove)
return false;
}
return true;
@@ -357,6 +363,26 @@ public class BattleImpl : ScriptSource, IBattle
/// <inheritdoc />
public StringKey? WeatherName => _weatherScript.Script?.Name;
private readonly ScriptContainer _terrainScript = new();
/// <inheritdoc />
public void SetTerrain(StringKey? terrainName)
{
if (terrainName.HasValue)
{
if (!Library.ScriptResolver.TryResolve(ScriptCategory.Terrain, terrainName.Value, null, out var script))
throw new InvalidOperationException($"Terrain script {terrainName} not found.");
_terrainScript.Set(script);
}
else
{
_terrainScript.Clear();
}
}
/// <inheritdoc />
public StringKey? TerrainName => _terrainScript.Script?.Name;
private readonly List<IReadOnlyList<ITurnChoice>> _previousTurnChoices = new();
@@ -383,12 +409,13 @@ public class BattleImpl : ScriptSource, IBattle
}
/// <inheritdoc />
public override int ScriptCount => 2;
public override int ScriptCount => 3;
/// <inheritdoc />
public override void GetOwnScripts(List<IEnumerable<ScriptContainer>> scripts)
{
scripts.Add(_weatherScript);
scripts.Add(_terrainScript);
scripts.Add(Volatile);
}