private static string ReplaceGuildInfo(string str, Tera.Game.Messages.S_GUILD_QUEST_LIST guildquest, DiscordInfoByGuild discordInfo)
        {
            str = str.Replace("{guild_guildname}", guildquest.GuildName);
            str = str.Replace("{guild_gold}", guildquest.Gold.ToString());
            str = str.Replace("{guild_creationtime}", guildquest.GuildCreationTime.ToString(@"yyyy-MM-dd"));
            str = str.Replace("{guild_lvl}", guildquest.GuildLevel.ToString());
            str = str.Replace("{guild_master}", guildquest.GuildMaster);
            str = str.Replace("{guild_size}", guildquest.GuildSize.ToString());
            str = str.Replace("{guild_xp_to_next_level}", (guildquest.GuildXpNextLevel - guildquest.GuildXpCurrent).ToString());
            str = str.Replace("{guild_current_xp}", guildquest.GuildXpCurrent.ToString());
            str = str.Replace("{guild_next_level_xp}", guildquest.GuildXpNextLevel.ToString());
            str = str.Replace("{guild_number_accounts}", guildquest.NumberAccount.ToString());
            str = str.Replace("{guild_number_characters}", guildquest.NumberCharacters.ToString());
            str = str.Replace("{guild_number_quest_done}", guildquest.NumberQuestsDone.ToString());
            str = str.Replace("{guild_total_number_quest}", guildquest.NumberTotalDailyQuest.ToString());
            str = str.Replace("{guild_number_quest_remaining}", (guildquest.NumberTotalDailyQuest - guildquest.NumberQuestsDone).ToString());
            str = str.Replace("{gold_label}", BasicTeraData.Instance.QuestInfoDatabase.Get(20000000));
            str = str.Replace("{xp_label}", BasicTeraData.Instance.QuestInfoDatabase.Get(20000001));

            var activeQuest = ReplaceNoQuest(discordInfo.QuestNoActiveText);
            var quests = guildquest.ActiveQuests();
            if (quests.Count > 0)
            {
                var activeQuests = string.Empty;
                foreach (var quest in quests)
                {
                    activeQuests += ReplaceQuestInfo(discordInfo.QuestInfoText, quest, discordInfo);
                }
                activeQuest = activeQuests;
            }
            str = str.Replace("{active_quest}", activeQuest);
            var questList = ReplaceQuestListInfo(guildquest, discordInfo);
            str = str.Replace("{quest_list}", questList);
            return str;
        }
Exemple #2
0
        private void ParseDiscord()
        {
            var root    = _xml.Root;
            var discord = root?.Element("discord");
            var user    = discord?.Element("login");

            if (user == null)
            {
                return;
            }
            var password = discord.Element("password");

            if (password == null)
            {
                return;
            }

            DiscordPassword = password.Value;
            DiscordLogin    = user.Value;

            if (DiscordPassword == null || DiscordLogin == null)
            {
                DiscordPassword = "";
                DiscordLogin    = "";
            }

            var guilds = discord.Element("guilds");

            if (guilds == null)
            {
                return;
            }
            foreach (var guild in guilds.Elements())
            {
                ulong discordServer            = 0;
                ulong discordChannelGuildInfo  = 0;
                ulong discordChannelGuildQuest = 0;

                var server = guild.Element("server");
                if (server == null)
                {
                    return;
                }


                ulong val;
                var   parseSuccess = ulong.TryParse(server.Value, out val);
                if (parseSuccess)
                {
                    discordServer = val;
                }


                var guild_infos_channel = guild.Element("guild_infos_channel");
                if (guild_infos_channel == null)
                {
                    return;
                }

                parseSuccess = ulong.TryParse(guild_infos_channel.Value, out val);
                if (parseSuccess)
                {
                    discordChannelGuildInfo = val;
                }


                var guild_quests_channel = guild.Element("guild_quests_channel");
                if (guild_quests_channel == null)
                {
                    return;
                }

                parseSuccess = ulong.TryParse(guild_quests_channel.Value, out val);
                if (parseSuccess)
                {
                    discordChannelGuildQuest = val;
                }

                string guildInfosText      = ":dart: {guild_guildname}  :dart:\n\n{guild_master} - {guild_size}\n{gold_label}: {guild_gold}\n{xp_label} for next level: {guild_xp_to_next_level}\nCreation time: {guild_creationtime}\nQuest done status: {guild_number_quest_done}/{guild_total_number_quest}\n";
                string questInfoText       = ":dart: {quest_guildname} - {quest_type} - {quest_size} :dart:\n\nTime remaining: {quest_time_remaining}\nIs bam quest: {quest_is_bam_quest}\n{targets}\n{rewards}\n";
                string questListInfoText   = "{quest_type} - {targets}\n";
                string questListHeaderText = "----NoActiveQuest----\n\n";
                string rewardFooterText    = "";
                string rewardContentText   = "{reward_name}: {reward_amount}\n";
                string rewardHeaderText    = "---------\n";

                string targetHeaderText  = "";
                string targetContentText = "{target_name}: {target_current_count}/{target_total_count}\n";
                string targetFooterText  = "";
                string questNoActiveText = ":dart:   {guild_guildname}   :dart:\n\n{no_quest_text}\n\n{quest_list}\n";

                var guildInfosTextElement = guild.Element("guild_infos_text");
                if (guildInfosTextElement != null)
                {
                    guildInfosText = guildInfosTextElement.Value;
                }

                var questInfoTextElement = guild.Element("quest_infos_text");
                if (questInfoTextElement != null)
                {
                    questInfoText = questInfoTextElement.Value;
                }

                var questListInfoTextElement = guild.Element("quest_list_infos_text");
                if (questListInfoTextElement != null)
                {
                    questListInfoText = questListInfoTextElement.Value;
                }

                var questListHeaderTextElement = guild.Element("quest_list_infos_header_text");
                if (questListHeaderTextElement != null)
                {
                    questListHeaderText = questListHeaderTextElement.Value;
                }

                var rewardFooterTextElement = guild.Element("reward_footer_text");
                if (rewardFooterTextElement != null)
                {
                    rewardFooterText = rewardFooterTextElement.Value;
                }

                var rewardContentTextElement = guild.Element("reward_content_text");
                if (rewardContentTextElement != null)
                {
                    rewardContentText = rewardContentTextElement.Value;
                }

                var rewardHeaderTextElement = guild.Element("reward_header_text");
                if (rewardHeaderTextElement != null)
                {
                    rewardHeaderText = rewardHeaderTextElement.Value;
                }

                var targetHeaderTextElement = guild.Element("target_header_text");
                if (targetHeaderTextElement != null)
                {
                    targetHeaderText = targetHeaderTextElement.Value;
                }

                var targetContentTextElement = guild.Element("target_content_text");
                if (targetContentTextElement != null)
                {
                    targetContentText = targetContentTextElement.Value;
                }

                var targetFooterTextElement = guild.Element("target_footer_text");
                if (targetFooterTextElement != null)
                {
                    targetFooterText = targetFooterTextElement.Value;
                }

                var questNoActiveTextElement = guild.Element("no_active_quest_text");
                if (questNoActiveTextElement != null)
                {
                    questNoActiveText = questNoActiveTextElement.Value;
                }

                DiscordInfoByGuild.Add(guild.Name.ToString().ToLowerInvariant(), new DiscordInfoByGuild(
                                           discordServer,
                                           discordChannelGuildInfo,
                                           discordChannelGuildQuest,
                                           guildInfosText,
                                           questInfoText,
                                           questListInfoText,
                                           questListHeaderText,
                                           rewardFooterText,
                                           rewardContentText,
                                           rewardHeaderText,
                                           targetHeaderText,
                                           targetContentText,
                                           targetFooterText,
                                           questNoActiveText

                                           ));
            }
        }
        private static string ReplaceQuestInfo(string str, GuildQuest quest, DiscordInfoByGuild discordInfo)
        {
            str = str.Replace("{quest_guildname}", quest.GuildName);
            str = str.Replace("{quest_type}", quest.GuildQuestType1.ToString());
            str = str.Replace("{quest_size}", quest.QuestSize.ToString());
            str = str.Replace("{quest_time_remaining}", quest.TimeRemaining.ToString(@"hh\:mm\:ss"));
            var isBamQuest = false;
            foreach (var target in quest.Targets)
            {
                if (target.TotalQuest == 1)
                {
                    isBamQuest = true;
                }
            }

            str = str.Replace("{quest_is_bam_quest}", isBamQuest.ToString());

            var rewardStr = new StringBuilder();
            rewardStr.Append(discordInfo.RewardHeaderText);
            foreach (var reward in quest.Rewards)
            {
                rewardStr.Append(ReplaceRewardInfo(discordInfo.RewardContentText, reward));
            }
            rewardStr.Append(discordInfo.RewardFooterText);
            str = str.Replace("{rewards}", rewardStr.ToString());

            var targetStr = new StringBuilder();
            targetStr.Append(discordInfo.TargetHeaderText);
            foreach (var target in quest.Targets)
            {
                targetStr.Append(ReplaceTargetInfo(discordInfo.TargetContentText, quest, target));
            }
            targetStr.Append(discordInfo.TargetFooterText);
            str = str.Replace("{targets}", targetStr.ToString());

            return str;
        }
 private static string ReplaceQuestListInfo(Tera.Game.Messages.S_GUILD_QUEST_LIST guildquest, DiscordInfoByGuild discordInfo)
 {
     var str = discordInfo.QuestListHeaderText;
     var questLists = ReplaceNoQuest(discordInfo.QuestNoActiveText);
     foreach (var nonActiveQuest in guildquest.GuildQuests.Where(x =>
         (int)x.QuestSize <= (int)guildquest.GuildSize && !x.Active).OrderBy(x => x.GuildQuestType1))
     {
         str += ReplaceQuestInfo(discordInfo.QuestListInfoText, nonActiveQuest, discordInfo);
     }
     return str;
 }