Пример #1
0
        public string GiveSupporterAchievement(Session session, string[] parms)
        {
            bool            help       = false;
            string          playerName = string.Empty;
            AchievementTier?tier       = null;

            try
            {
                var p = new OptionSet
                {
                    { "?|help|h", v => help = true },
                    { "p=|player=", v => playerName = v.TrimMatchingQuotes() },
                    { "tier=", v => tier = EnumExtension.Parse <AchievementTier>(v.TrimMatchingQuotes()) },
                };
                p.Parse(parms);
            }
            catch (Exception)
            {
                help = true;
            }

            if (help ||
                string.IsNullOrEmpty(playerName) ||
                !tier.HasValue)
            {
                return(String.Format("givesupporterachievement --player=player --tier={0}",
                                     String.Join("|", Enum.GetNames(typeof(AchievementTier)))));
            }

            var type        = "SUPPORTER";
            var icon        = "coins";
            var title       = "Supporter";
            var description = "Helped Improve Tribal Hero";

            ApiResponse <dynamic> response = ApiCaller.GiveAchievement(playerName, tier.Value, type, icon, title, description);

            if (response.Success)
            {
                uint playerId;
                if (world.FindPlayerId(playerName, out playerId))
                {
                    IPlayer player;
                    locker.Lock(playerId, out player).Do(() =>
                    {
                        chat.SendSystemChat("ACHIEVEMENT_NOTIFICATION", playerId.ToString(CultureInfo.InvariantCulture), player.Name, tier.ToString().ToLowerInvariant());

                        player.SendSystemMessage(null, "Achievement", "Hello, I've given you an achievement for supporting us. Your money will help us improve and cover the operating costs of the game. Make sure to refresh the game to see your new achievement. Thanks for your help!");
                    });
                }
            }

            return(response.Success ? "OK!" : response.AllErrorMessages);
        }
Пример #2
0
        public string GiveAchievement(Session session, String[] parms)
        {
            bool            help        = false;
            string          playerName  = string.Empty;
            string          icon        = string.Empty;
            string          title       = string.Empty;
            string          type        = string.Empty;
            string          description = string.Empty;
            AchievementTier?tier        = null;

            try
            {
                var p = new OptionSet
                {
                    { "?|help|h", v => help = true },
                    { "p=|player=", v => playerName = v.TrimMatchingQuotes() },
                    { "title=", v => title = v.TrimMatchingQuotes() },
                    { "description=", v => description = v.TrimMatchingQuotes() },
                    { "icon=", v => icon = v.TrimMatchingQuotes() },
                    { "type=", v => type = v.TrimMatchingQuotes() },
                    { "tier=", v => tier = EnumExtension.Parse <AchievementTier>(v.TrimMatchingQuotes()) },
                };
                p.Parse(parms);
            }
            catch (Exception)
            {
                help = true;
            }

            if (help ||
                string.IsNullOrEmpty(playerName) ||
                string.IsNullOrEmpty(icon) ||
                string.IsNullOrEmpty(title) ||
                string.IsNullOrEmpty(description) ||
                string.IsNullOrEmpty(type) ||
                tier == null ||
                !tier.HasValue)
            {
                return(String.Format("giveachievement --player=player --type=type --tier={0} --icon=icon --title=title --description=description",
                                     String.Join("|", Enum.GetNames(typeof(AchievementTier)))));
            }

            ApiResponse <dynamic> response = ApiCaller.GiveAchievement(playerName, tier.Value, type, icon, title, description);

            return(response.Success ? "OK!" : response.AllErrorMessages);
        }