예제 #1
0
        public void DamagePlayer(string spellName, int damage, Player player, Player target, Room room)
        {
            _writer.WriteLine(
                $"<p>Your {spellName} {_damage.DamageText(damage).Value} {target.Name} ({damage})</p>",
                player.ConnectionId);
            _writer.WriteLine(
                $"<p>{player.Name}'s {spellName} {_damage.DamageText(damage).Value} you! ({damage})</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(damage).Value} {target.Name} ({damage}))</p>",
                                  pc.ConnectionId);
            }

            target.Attributes.Attribute[EffectLocation.Hitpoints] -= damage;
            //update UI
            _updateClientUi.UpdateHP(target);
        }
예제 #2
0
        public void DisplayDamage(Player player, Player target, Room room, Item.Item weapon, int damage)
        {
            CultureInfo cc         = CultureInfo.CurrentCulture;
            var         damText    = _damage.DamageText(damage);
            var         attackType = "";

            if (weapon == null)
            {
                attackType = player.ConnectionId.Equals("mob", StringComparison.CurrentCultureIgnoreCase) ? player.DefaultAttack?.ToLower(cc): "punch";
            }
            else
            {
                attackType = Enum.GetName(typeof(Item.Item.AttackTypes), weapon.AttackType)?.ToLower(cc);
            }

            _writer.WriteLine($"<p class='combat'>Your {attackType} {damText.Value} {target.Name.ToLower(cc)}. <span class='damage'>[{damage}]</span></p>", player.ConnectionId);
            _writer.WriteLine($"<p class='combat'>{target.Name} {_formulas.TargetHealth(player, target)}</p>", player.ConnectionId);

            _writer.WriteLine($"<p>{player.Name}'s {attackType} {damText.Value} you. <span class='damage'>[{damage}]</span></p></p>", target.ConnectionId);



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

                _writer.WriteLine($"<p>{player.Name}'s {attackType} {damText.Value} {target.Name.ToLower(cc)}.</p>", pc.ConnectionId);
            }
        }
예제 #3
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);
            }
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="spell"></param>
        /// <param name="origin"></param>
        /// <param name="target"></param>
        /// <param name="room"></param>
        public void DoSpell(string spellName, Player origin, string targetName = "", Room room = null)
        {
            if (!ValidStatus(origin))
            {
                return;
            }

            var spell = FindSpell(spellName, origin);

            if (spell == null)
            {
                return;
            }

            if (!ManaCheck(spell, origin))
            {
                return;
            }


            if (SpellAffectsCharacter(spell))
            {
                Player target = null;
                target = _spellTargetCharacter.ReturnTarget(spell, targetName, room, origin);

                if (target == null)
                {
                    return;
                }

                ReciteSpellCharacter(origin, target, spell);

                var formula = spell.Damage.Roll(spell.Damage.DiceRoll, spell.Damage.DiceMinSize,
                                                spell.Damage.DiceMaxSize) + (origin.Level + 1) / 2; //+ mod



                //deduct mana
                origin.Attributes.Attribute[EffectLocation.Mana] -= spell.Cost.Table[Cost.Mana] == 0 ? 5 : spell.Cost.Table[Cost.Mana];
                _updateClientUi.UpdateMana(origin);


                // spell lag
                // add lag property to player
                // lag == spell round
                // stops spell/skill spam
                // applies after spell is cast
                // is it needed?

                // hit / miss messages

                //  _writer.WriteLine(spell.SkillStart.ToPlayer);

                if (SpellSuccess(origin, target, spell))
                {
                    var skillTarget = new SkillTarget
                    {
                        Origin = origin,
                        Target = target,
                        Room   = room,
                        Skill  = spell
                    };

                    _writer.WriteLine(
                        $"<p>Your {spell.Name} {_damage.DamageText(formula).Value} {target.Name} ({formula})</p>",
                        origin.ConnectionId);
                    _writer.WriteLine(
                        $"<p>{origin.Name}'s {spell.Name} {_damage.DamageText(formula).Value} you! ({formula})</p>",
                        target.ConnectionId);

                    // If no effect assume, negative spell and deduct HP
                    if (spell.Effect == null)
                    {
                        skillTarget.Target.Attributes.Attribute[EffectLocation.Hitpoints] -= formula;
                        //update UI
                        _updateClientUi.UpdateHP(skillTarget.Target);
                    }
                    else
                    {
                        new SpellEffect(_writer, skillTarget, formula).Type[skillTarget.Skill.Type].Invoke();
                    }
                }
                else
                {
                    var skill = origin.Skills.FirstOrDefault(x => x.SkillId.Equals(spell.Id));

                    if (skill == null)
                    {
                        return;
                    }

                    if (skill.Proficiency == 95)
                    {
                        return;
                    }

                    var increase = new Dice().Roll(1, 1, 3);

                    skill.Proficiency += increase;

                    origin.Experience            += 100;
                    origin.ExperienceToNextLevel -= 100;

                    _updateClientUi.UpdateExp(origin);

                    _writer.WriteLine(
                        $"<p class='improve'>You learn from your mistakes and gain 100 experience points.</p>",
                        origin.ConnectionId);
                    _writer.WriteLine(
                        $"<p class='improve'>Your {skill.SkillName} skill increases by {increase}%.</p>",
                        origin.ConnectionId);
                }
            }
            else
            {
                _writer.WriteLine(
                    $"<p>You cannot cast this spell upon another.</p>",
                    origin.ConnectionId);
            }
        }