More moves implemented
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ public class BattleChoiceQueue : IDeepCloneable
|
||||
{
|
||||
private readonly ITurnChoice?[] _choices;
|
||||
private int _currentIndex;
|
||||
public ITurnChoice? LastRanChoice { get; private set; }
|
||||
|
||||
/// <inheritdoc cref="BattleChoiceQueue"/>
|
||||
public BattleChoiceQueue(ITurnChoice[] choices)
|
||||
@@ -36,6 +37,7 @@ public class BattleChoiceQueue : IDeepCloneable
|
||||
var choice = _choices[_currentIndex];
|
||||
_choices[_currentIndex] = null;
|
||||
_currentIndex++;
|
||||
LastRanChoice = choice;
|
||||
return choice;
|
||||
}
|
||||
|
||||
@@ -99,4 +101,6 @@ public class BattleChoiceQueue : IDeepCloneable
|
||||
}
|
||||
|
||||
internal IReadOnlyList<ITurnChoice?> GetChoices() => _choices;
|
||||
|
||||
public ITurnChoice? Where(Func<ITurnChoice, bool> predicate) => _choices.WhereNotNull().FirstOrDefault(predicate);
|
||||
}
|
||||
@@ -36,7 +36,8 @@ internal static class MoveTurnExecutor
|
||||
|
||||
var targetType = moveData.Target;
|
||||
var targets = TargetResolver.ResolveTargets(battle, moveChoice.TargetSide, moveChoice.TargetPosition, targetType);
|
||||
|
||||
moveChoice.RunScriptHook(x => x.ChangeTargets(moveChoice, ref targets));
|
||||
|
||||
byte numberOfHits = 1;
|
||||
moveChoice.RunScriptHook(x => x.ChangeNumberOfHits(moveChoice, ref numberOfHits));
|
||||
if (numberOfHits == 0)
|
||||
@@ -152,8 +153,11 @@ internal static class MoveTurnExecutor
|
||||
|
||||
var blockIncomingHit = false;
|
||||
target.RunScriptHook(x => x.BlockIncomingHit(executingMove, target, hitIndex, ref blockIncomingHit));
|
||||
executingMove.RunScriptHook(x => x.BlockOutgoingHit(executingMove, target, hitIndex, ref blockIncomingHit));
|
||||
if (blockIncomingHit)
|
||||
break;
|
||||
if (executingMove.GetHitData(target, hitIndex).HasFailed)
|
||||
break;
|
||||
if (useMove.Category == MoveCategory.Status)
|
||||
{
|
||||
var secondaryEffect = useMove.SecondaryEffect;
|
||||
|
||||
@@ -34,6 +34,8 @@ public interface IMoveChoice : ITurnChoice
|
||||
ScriptContainer Script { get; set; }
|
||||
|
||||
Dictionary<StringKey, object?>? AdditionalData { get; }
|
||||
|
||||
IScriptSet Volatile { get; }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IMoveChoice"/>
|
||||
@@ -76,10 +78,17 @@ public class MoveChoice : TurnChoice, IMoveChoice
|
||||
public Dictionary<StringKey, object?>? AdditionalData { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int ScriptCount => 1 + User.ScriptCount;
|
||||
public IScriptSet Volatile { get; } = new ScriptSet();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void GetOwnScripts(List<IEnumerable<ScriptContainer>> scripts) => scripts.Add(Script);
|
||||
public override int ScriptCount => 2 + User.ScriptCount;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void GetOwnScripts(List<IEnumerable<ScriptContainer>> scripts)
|
||||
{
|
||||
scripts.Add(Volatile);
|
||||
scripts.Add(Script);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void CollectScripts(List<IEnumerable<ScriptContainer>> scripts)
|
||||
|
||||
Reference in New Issue
Block a user