using System.Collections.Generic;
using SepCore.Definition;
namespace SepCore.Battle
{
///
/// 玩家指令。
/// 非法指令(错误行动者、错误阵营、错误目标数量、阵亡或逃跑目标)不得消耗 MP、行动机会或随机数。
///
public sealed class BattleCommand
{
///
/// 当前获得行动机会的玩家单位。
///
public readonly int ActorUnitId;
///
/// 指令类型,对应配表 BattleActionType。
///
public readonly BattleActionType CommandType;
///
/// 攻击或技能对应的配置 ID;逃跑为 0。
///
public readonly int ActionConfigId;
///
/// 按目标类型解析后的唯一运行时目标列表。
///
public readonly IReadOnlyList TargetUnitIds;
public BattleCommand(int actorUnitId, BattleActionType commandType, int actionConfigId,
IReadOnlyList targetUnitIds)
{
ActorUnitId = actorUnitId;
CommandType = commandType;
ActionConfigId = actionConfigId;
TargetUnitIds = targetUnitIds != null ? Copy(targetUnitIds) : new int[0];
}
private static int[] Copy(IReadOnlyList source)
{
int[] copy = new int[source.Count];
for (int i = 0; i < source.Count; i++)
{
copy[i] = source[i];
}
return copy;
}
}
}