示例#1
0
        public void ShouldUseArticle()
        {
            var vestArticle  = MIMHelpers.FirstLetterToUpper(AvsAnLib.AvsAn.Query(vestName).Article);
            var swordArticle = MIMHelpers.FirstLetterToUpper(AvsAnLib.AvsAn.Query(swordName).Article);

            var expected = new List <string> {
                vestArticle + " " + vestName, swordArticle + " " + swordName + " x2"
            };

            Assert.That(container.List(true).ToList(), Is.EquivalentTo(expected));
        }
示例#2
0
        /// <summary>
        /// Returns a or an if name starts with a Vowel
        /// but if the object has a name it returns that.
        ///
        /// e.g an apple / Liam /
        /// </summary>
        /// <param name="objName"></param>
        ///  /// <param name="itemName"></param>
        /// <returns></returns>
        public static string ReturnName(PlayerSetup.Player player, PlayerSetup.Player target, string itemName)
        {
            try
            {
                if (player == null && target == null)
                {
                    var itemResult = AvsAnLib.AvsAn.Query(itemName).Article;


                    return(FirstLetterToUpper(itemResult + " " + itemName));
                }

                //TODO: ah a bug, if you have detects it will always say someone
                if (player.invis == true && target.DetectInvis == false ||
                    player.hidden == true && target.DetectHidden == false || Effect.HasEffect(target, Effect.Blindness(target).Name))
                {
                    return("Someone");
                }


                string name;

                if (player.KnownByName)
                {
                    name = player.Name;
                }
                else
                {
                    var result = AvsAnLib.AvsAn.Query(player.Name).Article;

                    name = Helpers.FirstLetterToUpper(result) + " " + player.Name;
                }


                return(name);
            }
            catch (Exception ex)
            {
                var log = new Error.Error
                {
                    Date         = DateTime.Now,
                    ErrorMessage = ex.InnerException.ToString(),
                    MethodName   = "return name"
                };

                Save.LogError(log);
            }
            return(string.Empty);
        }
示例#3
0
        public static IEnumerable <String> List(IEnumerable <Item.Item> items, bool article)
        {
            return(items.GroupBy(t => t.name).Select(group => new
            {
                Name = group.Key,
                Count = group.Count()
            }).OrderBy(x => x.Name).Select(x =>
            {
                var itemString = x.Name + ((x.Count > 1) ? " x" + x.Count : "");
                if (article)
                {
                    var i = items.FirstOrDefault(n => n.name.Equals(x.Name));
                    if (!i.KnownByName)
                    {
                        var result = AvsAnLib.AvsAn.Query(x.Name);
                        itemString = Helpers.FirstLetterToUpper(result.Article) + " " + itemString;
                    }
                }

                return itemString;
            }));
        }