private void ExecuteRestorePrecentageStatus(RestorePercentageStatus status, Team team) { foreach (IFighter fighter in team.Fighters) { ExecuteRestorePrecentageStatus(status, fighter); } }
public override bool AreEqual(Status status) { bool areEqual = false; RestorePercentageStatus restoreStatus = status as RestorePercentageStatus; if (restoreStatus != null) { areEqual = Math.Abs(restoreStatus.Percentage - Percentage) < .01; } return(areEqual); }
private void ExecuteTurnEndStatus(Status status, object sender) { RestorePercentageStatus restoreStatus = status as RestorePercentageStatus; if (restoreStatus != null) { Team senderAsTeam = sender as Team; IFighter senderAsFighter = sender as IFighter; if (senderAsTeam != null) { ExecuteRestorePrecentageStatus(restoreStatus, senderAsTeam); } else if (senderAsFighter != null) { ExecuteRestorePrecentageStatus(restoreStatus, senderAsFighter); } } }
private void ExecuteRestorePrecentageStatus(RestorePercentageStatus status, IFighter fighter) { if (fighter == null) { throw new ArgumentException("RestorePercentageStatus somehow given to something that is not an IFighter!"); } int restoreAmount; switch (status.RestorationType) { case RestorationType.Health: restoreAmount = (int)(fighter.MaxHealth * status.Percentage); fighter.Heal(restoreAmount); break; case RestorationType.Mana: restoreAmount = (int)(fighter.MaxMana * status.Percentage); fighter.RestoreMana(restoreAmount); break; } }