Exemplo n.º 1
0
        public int Disarm(Player player, Player target, Room room, string obj)
        {
            if (string.IsNullOrEmpty(player.Target))
            {
                _writer.WriteLine("You are not fighting anyone.", player.ConnectionId);

                return(0);
            }

            if (player.Equipped.Wielded == null)
            {
                _writer.WriteLine("You must wield a weapon to disarm.", player.ConnectionId);

                return(0);
            }

            if (target.Equipped.Wielded == null)
            {
                _writer.WriteLine("Your opponent is not wielding a weapon.", player.ConnectionId);

                return(0);
            }

            var playerWeaponSkill = Helpers.GetWeaponSkill(player.Equipped.Wielded, player);

            var targetWeaponSkill = Helpers.GetWeaponSkill(target.Equipped.Wielded, target);

            var playerSkillOfTargetsWeapon = Helpers.GetWeaponSkill(target.Equipped.Wielded, player);

            var chance = playerWeaponSkill;

            chance += (playerSkillOfTargetsWeapon - targetWeaponSkill) / 2;

            /* dex vs. strength */
            chance += player.Attributes.Attribute[EffectLocation.Dexterity];
            chance -= target.Attributes.Attribute[EffectLocation.Strength];

            chance += (player.Level - target.Level) * 2;
            if (player.Affects.Haste)
            {
                chance += 10;
            }

            if (target.Affects.Haste)
            {
                chance -= 25;
            }

            var hasGrip = target.Skills.FirstOrDefault(x =>
                                                       x.SkillName.Equals("grip", StringComparison.CurrentCultureIgnoreCase));

            var gripChance = _dice.Roll(1, 1, 100);

            if (hasGrip != null)
            {
                if (gripChance <= hasGrip.Proficiency)
                {
                    chance -= 20;
                }
                else
                {
                    _gain.GainSkillExperience(target, hasGrip.Level * 100, hasGrip, _dice.Roll(1, 1, 5));
                }
            }

            if (_dice.Roll(1, 1, 100) < chance)
            {
                if ((target.Equipped.Wielded.ItemFlag & Item.Item.ItemFlags.Noremove) != 0)
                {
                    var skillMessageNoRemove = new SkillMessage()
                    {
                        Hit =
                        {
                            ToPlayer = $"{target.Name}'s weapon won't budge!",
                            ToRoom   = $"{player.Name} tries to disarm {target.Name}, but fails.",
                            ToTarget = $"{player.Name} tries to disarm you, but your weapon won't budge!"
                        }
                    };

                    _skillManager.EmoteAction(player, target, room, skillMessageNoRemove);
                    return(0);
                }

                var skillMessage = new SkillMessage()
                {
                    Hit =
                    {
                        ToPlayer = $"You disarm {target.Name}!",
                        ToRoom   = $"{player.Name} disarms {target.Name}!",
                        ToTarget = $"{player.Name} DISARMS you and sends your weapon flying!"
                    }
                };

                _skillManager.EmoteAction(player, target, room, skillMessage);

                room.Items.Add(target.Equipped.Wielded);
                target.Equipped.Wielded = null;
            }
            else
            {
                var skillMessage = new SkillMessage()
                {
                    Hit =
                    {
                        ToPlayer = $"You fail to disarm {target.Name}.",
                        ToRoom   = $"{player.Name} tries to disarm {target.Name}, but fails.",
                        ToTarget = $"{player.Name} tries to disarm you, but fails."
                    }
                };

                _skillManager.EmoteAction(player, target, room, skillMessage);
            }

            player.Lag += 1;

            return(0);
        }
Exemplo n.º 2
0
        public void LookObject(string target, Room room, Player player)
        {
            if (player.Status == CharacterStatus.Status.Sleeping)
            {
                _writeToClient.WriteLine("You can't do that while asleep.", player.ConnectionId);
                return;
            }
            var isDark    = RoomIsDark(room, player);
            var nthTarget = Helpers.findNth(target);

            var item      = Helpers.findRoomObject(nthTarget, room) ?? Helpers.findObjectInInventory(nthTarget, player);
            var character = Helpers.FindMob(nthTarget, room) ?? Helpers.FindPlayer(nthTarget, room);


            RoomObject roomObjects = null;

            if (room.RoomObjects.Count >= 1 && room.RoomObjects[0].Name != null)
            {
                roomObjects =
                    room.RoomObjects.FirstOrDefault(x =>
                                                    x.Name.Contains(target, StringComparison.CurrentCultureIgnoreCase));
            }

            if (target.Equals("self", StringComparison.CurrentCultureIgnoreCase))
            {
                character = player;
            }


            if (item == null && character == null && roomObjects == null)
            {
                _writeToClient.WriteLine("<p>You don't see that here.", player.ConnectionId);
                return;
            }

            if (item != null && character == null)
            {
                _writeToClient.WriteLine($"<p  class='{(isDark ? "room-dark" : "")}'>{item.Description.Look}", player.ConnectionId);

                // display item stats via lore
                var hasLore = Helpers.FindSkill("lore", player);

                if (hasLore != null)
                {
                    var success = LoreSuccess(hasLore.Proficiency ?? 0);

                    if (success)
                    {
                        DoLore(item, player);
                    }
                    else
                    {
                        _gain.GainSkillExperience(player, hasLore.Level * 100, hasLore, _dice.Roll(1, 1, 5));
                    }
                }

                if (item.Container != null && !item.Container.CanOpen && item.Container.Items.Any())
                {
                    _writeToClient.WriteLine($"<p  class='{(isDark ? "room-dark" : "")}'>{item.Name} contains:", player.ConnectionId);

                    var listOfContainerItems = new StringBuilder();
                    foreach (var containerItem in item.Container.Items.List())
                    {
                        listOfContainerItems.Append($"<p class='{(isDark ? "room-dark" : "")}'>{containerItem.Name.Replace(" lies here.", "")}</p>");
                    }

                    _writeToClient.WriteLine(listOfContainerItems.ToString(), player.ConnectionId);
                }

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

                    _writeToClient.WriteLine($"<p>{player.Name} looks at {item.Name.ToLower()}.</p>", pc.ConnectionId);
                }
                return;
            }
            //for player?
            if (roomObjects != null && character == null)
            {
                _writeToClient.WriteLine($"<p class='{(isDark ? "room-dark" : "")}'>{roomObjects.Look}", player.ConnectionId);

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

                    _writeToClient.WriteLine($"<p>{player.Name} looks at {roomObjects.Name.ToLower()}.</p>", pc.ConnectionId);
                }

                return;
            }

            if (character == null)
            {
                _writeToClient.WriteLine("<p>You don't see them here.", player.ConnectionId);
                return;
            }



            var sb = new StringBuilder();

            if (character.ConnectionId != "mob")
            {
                sb.Append(
                    $"<table class='char-look'><tr><td><span class='cell-title'>Eyes:</span> {character.Eyes}</td><td><span class='cell-title'>Hair:</span> {character.HairColour}</td></tr>");
                sb.Append(
                    $"<tr><td><span class='cell-title'>Skin:</span> {character.Skin}</td><td><span class='cell-title'>Hair Length:</span> {character.HairLength}</td></tr>");
                sb.Append(
                    $"<tr><td><span class='cell-title'>Build:</span> {character.Build}</td><td><span class='cell-title'>Hair Texture:</span> {character.HairTexture}</td></tr>");
                sb.Append(
                    $"<tr><td><span class='cell-title'>Face:</span> {character.Face}</td><td><span class='cell-title'>Hair Facial:</span> {character.FacialHair}</td></tr><table>");
            }


            var status = Enum.GetName(typeof(CharacterStatus.Status), player.Status);

            var statusText = String.Empty;

            if (status.Equals("fighting", StringComparison.CurrentCultureIgnoreCase))
            {
                statusText = $"fighting {(character.Target.Equals(player.Name) ? "YOU!" : character.Target)}.";
            }
            else
            {
                statusText = $"{Enum.GetName(typeof(CharacterStatus.Status), player.Status)}.";

                statusText = statusText.ToLower();
            }
            var displayEquipment = new StringBuilder();

            displayEquipment.Append("<p>They are using:</p>")
            .Append("<table>");

            if (character.Equipped.Light != null)
            {
                displayEquipment.Append("<tr><td style='width:175px;' class=\"cell-title\" title='Worn as light'>").Append("&lt;used as light&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Light?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.Finger != null)
            {
                displayEquipment.Append("<tr><td class=\"cell-title\" title='Worn on finger'>").Append(" &lt;worn on finger&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Finger?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.Finger2 != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Worn on finger'>").Append(" &lt;worn on finger&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Finger2?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.Neck != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Worn around neck'>").Append(" &lt;worn around neck&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Neck?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.Neck2 != null)
            {
                displayEquipment.Append("<tr><td class=\"cell-title\" title='Worn around neck'>").Append(" &lt;worn around neck&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Neck2?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.Face != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Worn on face'>").Append(" &lt;worn on face&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Face?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.Head != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Worn on head'>").Append(" &lt;worn on head&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Head?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.Torso != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Worn on torso'>").Append(" &lt;worn on torso&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Torso?.Name ?? "(nothing)").Append("</td></tr>");
            }
            if (character.Equipped.Legs != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Worn on legs'>").Append(" &lt;worn on legs&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Legs?.Name ?? "(nothing)").Append("</td></tr>");
            }
            if (character.Equipped.Feet != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Worn on feet'>").Append(" &lt;worn on feet&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Feet?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.Hands != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Worn on hands'>").Append(" &lt;worn on hands&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Hands?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.Arms != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Worn on arms'>").Append(" &lt;worn on arms&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Arms?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.AboutBody != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Worn about body'>").Append(" &lt;worn about body&gt;").Append("</td>").Append("<td>").Append(character.Equipped.AboutBody?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.Waist != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Worn on waist'>").Append(" &lt;worn about waist&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Waist?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.Wrist != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Worn on wrist'>").Append(" &lt;worn around wrist&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Wrist?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.Wrist2 != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Worn on wrist'>").Append(" &lt;worn around wrist&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Wrist2?.Name ?? "(nothing)").Append("</td></tr>");
            }


            if (character.Equipped.Wielded != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='worn as weapon'>").Append(" &lt;wielded&gt;").Append("</td>").Append("<td>")
                .Append(character.Equipped.Wielded?.Name ?? "(nothing)").Append("</td></tr>");
            }


            if (character.Equipped.Secondary != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='worn as weapon'>").Append(" &lt;secondary&gt;").Append("</td>").Append("<td>")
                .Append(character.Equipped.Secondary?.Name ?? "(nothing)").Append("</td></tr>");
            }


            if (character.Equipped.Shield != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Worn as shield'>").Append(" &lt;worn as shield&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Shield?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.Held != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Held'>").Append(" &lt;Held&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Held?.Name ?? "(nothing)").Append("</td></tr>");
            }

            if (character.Equipped.Floating != null)
            {
                displayEquipment.Append("<tr><td  class=\"cell-title\" title='Floating Nearby'>").Append(" &lt;Floating nearby&gt;").Append("</td>").Append("<td>").Append(character.Equipped.Floating?.Name ?? "(nothing)").Append("</td></tr>").Append("</table");
            }

            if (character.Equipped.Light == null && character.Equipped.Finger == null && character.Equipped.Finger2 == null && character.Equipped.Neck == null && character.Equipped.Neck2 == null &&
                character.Equipped.Face == null && character.Equipped.Head == null && character.Equipped.Torso == null && character.Equipped.Legs == null && character.Equipped.Feet == null &&
                character.Equipped.Hands == null && character.Equipped.Arms == null && character.Equipped.AboutBody == null && character.Equipped.Waist == null && character.Equipped.Wrist == null &&
                character.Equipped.Wrist2 == null && character.Equipped.Wielded == null && character.Equipped.Secondary == null && character.Equipped.Shield == null && character.Equipped.Held == null &&
                character.Equipped.Held == null && character.Equipped.Floating == null)
            {
                displayEquipment.Append("</table").Append("<p>Nothing.</p>");
            }



            _writeToClient.WriteLine($"{sb}<p class='{(isDark ? "room-dark" : "")}'>{character.Description} <br/>{character.Name} {_formulas.TargetHealth(player, character)} and is {statusText}<br/> {displayEquipment}", player.ConnectionId);



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

                _writeToClient.WriteLine($"<p>{player.Name} looks at {character.Name.ToLower()}.</p>", pc.ConnectionId);
            }



            //if (item.ItemType == Item.Item.ItemTypes.Container)
            //{
            //  LookInContainer(target, room, player);
            //}
        }