///<summary> ///</summary> ///<param name="defendAction"></param> ///<exception cref="ApplicationException"></exception> public void SetDefendAction(DefendAction defendAction) { if (IsImmutable) { throw new ApplicationException("PendingActions must be mutable to modify actions."); } DefendAction = defendAction; }
/// <summary> /// <para> /// Method used to command a creature to begin defending against a specific /// target creature. You can only defend against one creature at a time, /// so only the final call to BeginDefending will actually be used /// in the upcoming turn. /// </para> /// <para> /// Once your creature has finished defending, the DefendCompleted event will /// be fired and your event handler will be called if you provided one. You /// can use this event to determine the results of your defense. /// </para> /// </summary> /// <param name="targetAnimal"> /// The AnimalState that represents the animal you want to defend against. /// </param> /// <exception cref="System.ArgumentNullException"> /// Thrown if the targetAnimal parameter is null. /// </exception> public void BeginDefending(AnimalState targetAnimal) { if (targetAnimal == null) { throw new ArgumentNullException("targetAnimal", "The argument 'targetAnimal' cannot be null"); } var actionID = GetNextActionID(); var action = new DefendAction(ID, actionID, targetAnimal); lock (PendingActions) { PendingActions.SetDefendAction(action); InProgressActions.SetDefendAction(action); } }
/// <internal/> public DefendCompletedEventArgs(int actionID, DefendAction action) : base(actionID, action) { }