public void Cast(string casterId, int skillId, IEnumerable <string> targetIds) { lock (_lock) { var battle = _battleRepository.FindActiveFor(casterId); if (battle == null) { throw new InvalidOperationException("Active battle does not exist for caster."); } var skill = _skillRepository.Find(skillId); if (skill == null) { throw new InvalidOperationException("Skill does not exist."); } battle.Cast(casterId, skill, targetIds); _battleRepository.Save(battle); _eventDispatcher.Dispatch(battle); } }