Пример #1
0
        public void DamagePlayer(string spellName, int damage, Player player, Player target, Room room)
        {
            if (_fight.IsTargetAlive(target))
            {
                var totalDam = _fight.CalculateSkillDamage(player, target, damage);

                _writer.WriteLine(
                    $"<p>Your {spellName} {_damage.DamageText(totalDam).Value} {target.Name}  <span class='damage'>[{damage}]</span></p>",
                    player.ConnectionId);
                _writer.WriteLine(
                    $"<p>{player.Name}'s {spellName} {_damage.DamageText(totalDam).Value} you!  <span class='damage'>[{damage}]</span></p>",
                    target.ConnectionId);

                foreach (var pc in room.Players)
                {
                    if (pc.ConnectionId.Equals(player.ConnectionId) ||
                        pc.ConnectionId.Equals(target.ConnectionId))
                    {
                        continue;
                    }

                    _writer.WriteLine(
                        $"<p>{player.Name}'s {spellName} {_damage.DamageText(totalDam).Value} {target.Name}  <span class='damage'>[{damage}]</span></p>",
                        pc.ConnectionId);
                }

                target.Attributes.Attribute[EffectLocation.Hitpoints] -= totalDam;

                if (!_fight.IsTargetAlive(target))
                {
                    _fight.TargetKilled(player, target, room);

                    _updateClientUi.UpdateHP(target);
                    return;
                    //TODO: create corpse, refactor fight method from combat.cs
                }

                //update UI
                _updateClientUi.UpdateHP(target);

                _fight.AddCharToCombat(target);
                _fight.AddCharToCombat(player);
            }
        }