Ejemplo n.º 1
0
        public void Cast(string casterId, ISkillNg skill, IEnumerable <string> targetsIds)
        {
            if (_hasEnded)
            {
                return;
            }

            if (_players.ContainsKey(casterId))
            {
                throw new InvalidOperationException("Caster is not in battle.");
            }

            var caster  = _players[casterId];
            var targets = new HashSet <PlayerNg>();

            foreach (var targetId in targetsIds)
            {
                if (!_players.ContainsKey(targetId))
                {
                    throw new InvalidOperationException("Target is not in battle.");
                }

                targets.Add(_players[targetId]);
            }

            caster.Cast(skill, targets);
        }
Ejemplo n.º 2
0
        public void Cast(ISkillNg skill, IEnumerable <PlayerNg> targets)
        {
            if (!CanCast(skill))
            {
                return;
            }

            _votedToEnd = false;

            skill.Cast(this, targets);
        }
Ejemplo n.º 3
0
        private bool CanCast(ISkillNg skill)
        {
            // Can't cast skills if dead.
            if (_hp == 0)
            {
                return(false);
            }

            if (_skills.Contains(skill))
            {
                return(true);
            }

            // Here can be any logic.
            // Can cast particular skills only with particular weapon.
            // Can't cast something when debuffed.
            // Can cast something that wasn't able to - when buffed.
            // Etc.

            return(false);
        }