private void GetItemDefsFromGenerator(int a_generatorDef)
    {
        JSONNode item = JsonItems.GetItem(a_generatorDef);

        if (null != item)
        {
            string   text  = item["bundle"];
            string[] array = text.Split(new char[]
            {
                ';'
            });
            this.m_generatorDefIds = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                string[] array2 = array[i].Split(new char[]
                {
                    'x'
                });
                try
                {
                    this.m_generatorDefIds[i] = int.Parse(array2[0]);
                }
                catch (Exception)
                {
                }
            }
        }
    }
 private void Update()
 {
     if (this.m_gui.activeSelf)
     {
         float deltaTime = Time.deltaTime;
         if (this.m_curSpeed > 0.01f)
         {
             for (int i = 0; i < this.m_displayItems.Length; i++)
             {
                 Vector3 localPosition = this.m_displayItems[i].transform.localPosition;
                 this.m_displayItems[i].transform.localPosition += Vector3.right * deltaTime * this.m_curSpeed;
                 if (this.m_displayItems[i].transform.localPosition.x > 0.085f)
                 {
                     this.m_displayItems[i].transform.localPosition -= Vector3.right * 0.6f;
                     int a_newDefId = 0;
                     if (this.m_curSpeed < 0.2f && !this.m_setWinningItemFlag)
                     {
                         a_newDefId = this.m_itemDefToWin;
                         this.m_setWinningItemFlag = true;
                     }
                     this.ChangeItem(i, a_newDefId);
                 }
                 if (localPosition.x < 0.015f && 0.015f < this.m_displayItems[i].transform.localPosition.x && null != base.audio)
                 {
                     base.audio.Play();
                 }
             }
             if (Time.time > this.m_timeToSlowdown)
             {
                 this.m_curSpeed *= 1f - deltaTime * this.m_slowDownRate;
             }
         }
         else if (!this.m_btnClose.activeSelf)
         {
             JSONNode item = JsonItems.GetItem(this.m_itemDefToWin);
             if (null != item)
             {
                 this.m_newItemTxt.text = LNG.Get("STEAM_INV_NEW_ITEM") + "\n " + item["market_name"];
                 if (null != this.m_client)
                 {
                     this.m_client.SendChatMsg(":#~" + item["market_name"], false);
                 }
                 else
                 {
                     ComChatGUI comChatGUI = UnityEngine.Object.FindObjectOfType <ComChatGUI>();
                     comChatGUI.AddString("Ethan The just opened a case and received: \n<color=\"red\">" + item["market_name"] + "</color>");
                 }
             }
             GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(this.m_audioEffect);
             gameObject.audio.clip   = this.m_successSound;
             gameObject.audio.volume = 0.4f;
             gameObject.audio.Play();
             this.m_btnClose.SetActive(true);
         }
     }
     if (Application.isEditor && Input.GetKeyDown(KeyCode.L))
     {
         this.Showtime(20009, 1004);
     }
 }
Example #3
0
        /// <summary>
        /// This reads data from json.config and assigns the values to the variables labeled above.
        /// </summary>
        public static void ReadConfig()
        {
            JsonItems data = JsonConvert.DeserializeObject <JsonItems>(File.ReadAllText(ConfigPath));

            CurrentJsonData     = data;
            Token               = data.Token;
            Prefix              = data.Prefix;
            Version             = data.Version;
            YouTubeAPIKey       = data.YouTubeAPIKey;
            MaxUserPingCount    = data.MaxUserPingCount;
            MaxRolePingCount    = data.MaxRolePingCount;
            MinMessageTimestamp = data.MinMessageTimestamp;
            MySQL.MySQLServer   = data.MySQLServer;
            MySQL.MySQLUser     = data.MySQLUser;
            MySQL.MySQLDatabase = data.MySQLDatabase;
            MySQL.MySQLPort     = data.MySQLPort;
            MySQL.MySQLPassword = data.MySQLPassword;
            GeniusAPIKey        = data.GeniusAPIKey;
            LoggingLevel        = data.LoggingLevel;
            SupportChannelId    = data.SupportChannelId;
            SupportGuildId      = data.SupportGuildId;
            Mongoconnstr        = data.Mongoconnstr;
            StatusPageAPIKey    = data.StatusPageAPIKey;
            clientPrefix        = data.clientPrefix;
            ErrorLogChannelId   = data.ErrorLogChannelId;
            BotDirectory        = data.BotDirectory;
            WeatherAPIKey       = data.WeatherAPIKey;
            TwitchClientId      = data.TwitchClientId;
            TwitchClientSecret  = data.TwitchClientSecret;
            TwitchRedirectURL   = data.TwitchRedirectURL;

            MySQL.ConnStr = $"server={MySQL.MySQLServer};user={MySQL.MySQLUser};database={MySQL.MySQLDatabase};port={MySQL.MySQLPort};password={MySQL.MySQLPassword}"; //The connection string for the MySql server.
        }
    private void ChangeItem(int a_index, int a_newDefId = 0)
    {
        int num  = a_newDefId;
        int num2 = 0;

        UnityEngine.Random.seed = (int)(Time.time * 1000f);
        while (num == 0 && this.m_generatorDefIds != null && 0 < this.m_generatorDefIds.Length)
        {
            num = this.m_generatorDefIds[UnityEngine.Random.Range(0, this.m_generatorDefIds.Length)];
            for (int i = 0; i < this.m_displayDefIds.Length; i++)
            {
                if (num == this.m_displayDefIds[i] && 100 > num2)
                {
                    num = 0;
                    num2++;
                    break;
                }
            }
        }
        JSONNode item = JsonItems.GetItem(num);

        if (null != item && a_index < this.m_displayItems.Length && num != this.m_displayDefIds[a_index])
        {
            this.m_displayDefIds[a_index]     = num;
            this.m_displayTexts[a_index].text = string.Concat(new string[]
            {
                "<color=#",
                item["name_color"],
                ">",
                item["market_name"],
                "</color>"
            });
            this.m_displayRenderers[a_index].renderer.material.mainTexture = Resources.Load <Texture>("inventory_steam/inventory_s_" + num);
        }
    }
Example #5
0
 internal JsonItems modifyJsonData(JsonItems data, string iName, object iValue)
 {
     try
     {
         var prop = data.GetType().GetProperty(iName);
         if (prop != null)
         {
             Type   t         = Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType;
             object safeValue = (iValue == null) ? null : Convert.ChangeType(iValue, t);
             prop.SetValue(data, safeValue, null);
             return(data);
         }
         else
         {
             throw new Exception($"Could not find the config item {iName}!");
         }
     }
     catch (Exception ex)
     {
         EmbedBuilder b = new EmbedBuilder()
         {
             Color       = Color.Red,
             Title       = "Exeption!",
             Description = $"**{ex}**"
         };
         Context.Channel.SendMessageAsync("", false, b.Build());
         return(data);
     }
 }
Example #6
0
    public void ShowGui(bool a_show, int a_itemDefId = 0)
    {
        if (a_show)
        {
            JSONNode item = JsonItems.GetItem(a_itemDefId);
            if (null != item && null != this.m_itemText && null != this.m_itemRenderer)
            {
                this.m_itemText.text = string.Concat(new string[]
                {
                    "<color=#",
                    item["name_color"],
                    ">",
                    item["market_name"],
                    "</color>"
                });
                this.m_itemRenderer.renderer.material.mainTexture = Resources.Load <Texture>("inventory_steam/inventory_s_" + a_itemDefId);
            }
            base.audio.Play();
        }
        this.m_guiParent.SetActive(a_show);
        int @int = PlayerPrefs.GetInt("prefSteamDropCount", 0);

        PlayerPrefs.SetInt("prefSteamDropCount", @int + 1);
        this.m_reviewText.text = LNG.Get((@int % 2 != 1) ? "STEAM_BLUE_ICON" : "STEAM_PLEASE_REVIEW");
    }
Example #7
0
        public static void ReadConfig()
        {
            if (!Directory.Exists(MessageLogsDir))
            {
                Directory.CreateDirectory(MessageLogsDir);
            }
            if (!Directory.Exists(CommandLogsDir))
            {
                Directory.CreateDirectory(CommandLogsDir);
            }
            if (!File.Exists(aiResponsePath))
            {
                File.Create(aiResponsePath);
            }

            var data = JsonConvert.DeserializeObject <JsonItems>(File.ReadAllText(ConfigPath));

            jsonItemsList       = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText(ConfigPath));
            JsonItemsListDevOps = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText(ConfigPath));
            ConfigSettings      = JsonConvert.DeserializeObject <Dictionary <string, bool> >(File.ReadAllText(ConfigSettingsPath));
            foreach (var item in ConfigSettings)
            {
                if (item.Value == false)
                {
                    jsonItemsList.Remove(item.Key);
                }
            }

            JsonItemsListDevOps.Remove("Token");
            CurrentJsonData      = data;
            Preflix              = data.Preflix;
            WelcomeMessageChanID = data.WelcomeMessageChanID;
            WelcomeMessage       = data.WelcomeMessage;
            WelcomeMessageURL    = data.WelcomeMessageURL;
            Status                = data.Status;
            giveawayChanID        = data.giveawayChanID;
            giveawayCreatorChanId = data.giveawayCreatorChanId;
            Token                 = data.Token;
            StatsChanID           = data.StatsChanID;
            SwissGuildId          = data.SwissGuildID;
            DeveloperRoleId       = data.DeveloperRoleId;
            SwissBotDevGuildID    = data.SwissTestingGuildID;
            LogsChannelID         = data.LogsChannelID;
            DebugChanID           = data.DebugChanID;
            SubmissionChanID      = data.SubmissionChanID;
            TestingCat            = data.TestingCatigoryID;
            ModeratorRoleID       = data.ModeratorRoleID;
            MemberRoleID          = data.MemberRoleID;
            AutoSlowmodeTrigger   = data.AutoSlowmodeTrigger;
            ApiKey                = data.ApiKey;
            AutoSlowmodeToggle    = data.AutoSlowmodeToggle;
            UnverifiedRoleID      = data.UnverifiedRoleID;
            VerificationChanID    = data.VerificationChanID;
            VerificationLogChanID = data.VerificationLogChanID;
            SubmissionsLogChanID  = data.SubmissionsLogChanID;
            MilestonechanID       = data.MilestonechanID;
            BotAiChanID           = data.BotAiChanID;
            StatsTotChanID        = data.StatsTotChanID;
        }
Example #8
0
        public static void SaveConfig(JsonItems newData)
        {
            string jsonS = JsonConvert.SerializeObject(newData, Formatting.Indented);

            newData.Token = "N#########################";
            string conJson = JsonConvert.SerializeObject(newData, Formatting.Indented);

            File.WriteAllText(ConfigPath, jsonS);
            ConsoleLog("Saved New config items. here is the new JSON \n " + conJson + "\n Saving...", ConsoleColor.DarkYellow);
            ReadConfig();
        }
Example #9
0
        public JsonItems RetrieveJsonObject(int itemNumber, byte[] jsonList, int propsCount)
        {
            var item             = Decompress(jsonList);
            var finalDictionairy = DeserializeSingleObjectItem(item, itemNumber, propsCount);
            var final            = new JsonItems()
            {
                ItemNumber = itemNumber, Items = finalDictionairy
            };

            return(final);
        }
Example #10
0
 public static JSONNode GetItem(int a_id)
 {
     if (null == JsonItems.m_items)
     {
         JsonItems.Init();
     }
     if (null != JsonItems.m_items)
     {
         for (int i = 0; i < JsonItems.m_items["items"].Count; i++)
         {
             if (JsonItems.m_items["items"][i]["itemdefid"].AsInt == a_id)
             {
                 return(JsonItems.m_items["items"][i]);
             }
         }
     }
     return(null);
 }
Example #11
0
        public static void ReadConfig()
        {
            if (!Directory.Exists(MessageLogsDir))
            {
                Directory.CreateDirectory(MessageLogsDir);
            }
            if (!Directory.Exists(CommandLogsDir))
            {
                Directory.CreateDirectory(CommandLogsDir);
            }
            //if (!File.Exists(aiResponsePath)) { File.Create(aiResponsePath); }
            if (!File.Exists(CensorPath))
            {
                File.Create(CensorPath);
            }
            if (!File.Exists(Environment.CurrentDirectory + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + "AltVerifyCards.txt"))
            {
                File.Create(Environment.CurrentDirectory + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + "AltVerifyCards.txt").Close();
            }
            if (!File.Exists(HelpMessagefilepath))
            {
                File.Create(HelpMessagefilepath).Close();
            }
            if (!File.Exists(RoleCardFilepath))
            {
                File.Create(RoleCardFilepath).Close();
            }
            if (!File.Exists(SupportTicketJsonPath))
            {
                File.Create(SupportTicketJsonPath).Close();
            }
            if (!File.Exists(SnippetsFilePath))
            {
                File.Create(SnippetsFilePath).Close();
            }
            if (!File.Exists(BlockedUsersPath))
            {
                File.Create(BlockedUsersPath).Close();
            }
            var data = JsonConvert.DeserializeObject <JsonItems>(File.ReadAllText(ConfigPath));

            jsonItemsList       = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText(ConfigPath));
            JsonItemsListDevOps = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText(ConfigPath));
            ConfigSettings      = JsonConvert.DeserializeObject <Dictionary <string, bool> >(File.ReadAllText(ConfigSettingsPath));
            foreach (var item in ConfigSettings)
            {
                if (item.Value == false)
                {
                    jsonItemsList.Remove(item.Key);
                }
            }

            JsonItemsListDevOps.Remove("Token");
            CurrentJsonData             = data;
            SwissbotStateHandler.APIKey = data.StateAPIKey;
            Preflix = data.Preflix;
            WelcomeMessageChanID = data.WelcomeMessageChanID;
            WelcomeMessage       = data.WelcomeMessage;
            WelcomeMessageURL    = data.WelcomeMessageURL;
            Status                = data.Status;
            giveawayChanID        = data.giveawayChanID;
            giveawayCreatorChanId = data.giveawayCreatorChanId;
            Token                 = data.Token;
            StatsChanID           = data.StatsChanID;
            SwissGuildId          = data.SwissGuildID;
            DeveloperRoleId       = data.DeveloperRoleId;
            SwissBotDevGuildID    = data.SwissTestingGuildID;
            LogsChannelID         = data.LogsChannelID;
            DebugChanID           = data.DebugChanID;
            SubmissionChanID      = data.SubmissionChanID;
            TestingCat            = data.TestingCatigoryID;
            ModeratorRoleID       = data.ModeratorRoleID;
            MemberRoleID          = data.MemberRoleID;
            AutoSlowmodeTrigger   = data.AutoSlowmodeTrigger;
            ApiKey                = data.ApiKey;
            AutoSlowmodeToggle    = data.AutoSlowmodeToggle;
            UnverifiedRoleID      = data.UnverifiedRoleID;
            VerificationChanID    = data.VerificationChanID;
            VerificationLogChanID = data.VerificationLogChanID;
            SubmissionsLogChanID  = data.SubmissionsLogChanID;
            MilestonechanID       = data.MilestonechanID;
            BotAiChanID           = data.BotAiChanID;
            VerifyAlts            = data.VerifyAlts;
            AltVerificationHours  = data.AltVerificationHours;
            StatsTotChanID        = data.StatsTotChanID;
            MutedRoleID           = data.MutedRoleID;
            TicketCategoryID      = data.TicketCategoryID;
            SuggestionChannelID   = data.SuggestionChannelID;
            TicketSnippets        = data.TicketSnippets;
            Workers               = data.Workers.Split(' ');

            try
            {
                CensoredWords = SwissbotStateHandler.LoadObject <List <string> >("Censor.json").Result;
            }
            catch
            {
                CensoredWords = new List <string>();
            }
        }
Example #12
0
        public async Task modify(string configItem, params string[] input)
        {
            var r            = Context.Guild.GetUser(Context.Message.Author.Id).Roles;
            var adminrolepos = Context.Guild.Roles.FirstOrDefault(x => x.Id == 635039634992136204).Position;
            var rolepos      = r.FirstOrDefault(x => x.Position >= adminrolepos);

            if (rolepos != null || r.FirstOrDefault(x => x.Id == Global.DeveloperRoleId) != null)
            {
                if (input.Length == 0)
                {
                    if (configItem == "list")
                    {
                        if (Context.Guild.Id == Global.DevGuildID)
                        {
                            EmbedBuilder b = new EmbedBuilder();
                            b.Footer      = new EmbedFooterBuilder();
                            b.Footer.Text = "**Dev Config**";
                            b.Title       = "Dev Config List";
                            string list = "**Here is the current config file** \n";
                            foreach (var item in Global.JsonItemsListDevOps)
                            {
                                list += $"```json\n \"{item.Key}\" : \"{item.Value}\"```\n";
                            }
                            b.Description = list;
                            b.Color       = Color.Green;
                            b.Footer.Text = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + " ZULU";
                            await Context.Channel.SendMessageAsync("", false, b.Build());
                        }
                        else
                        {
                            if (Context.Channel.Id == 561218509342769173)
                            {
                                EmbedBuilder b = new EmbedBuilder();
                                b.Footer      = new EmbedFooterBuilder();
                                b.Footer.Text = "**Admin Config**";
                                b.Title       = "Admin Config List";
                                string list   = "**Here is the current config file, not all items are here, if you wish to view more items please contact Thomas or Swiss, because they control the config items you can modify!** \n";
                                string itemsL = "";
                                foreach (var item in Global.jsonItemsList)
                                {
                                    itemsL += $"```json\n \"{item.Key}\" : \"{item.Value}\"```\n";
                                }
                                if (itemsL == "")
                                {
                                    list = "**Sorry but there is nothing here or you do not have permission to change anything yet :/**";
                                }
                                b.Description = list + itemsL;
                                b.Color       = Color.Green;
                                b.Footer.Text = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + " ZULU";
                                await Context.Channel.SendMessageAsync("", false, b.Build());
                            }
                        }
                    }
                    else
                    {
                        await Context.Channel.SendMessageAsync($"No value was provided for the variable `{configItem}`");
                    }
                }
                else
                {
                    var    value    = string.Join(" ", input);
                    string newvalue = value;
                    if (Context.Guild.Id == Global.DevGuildID)//allow full modify
                    {
                        if (Global.JsonItemsListDevOps.Keys.Contains(configItem))
                        {
                            JsonItems data = Global.CurrentJsonData;
                            data = modifyJsonData(data, configItem, newvalue);
                            if (data.Token != null)
                            {
                                Global.SaveConfig(data);
                                await Context.Channel.SendMessageAsync($"Sucessfuly modified the config, Updated the item {configItem} with the new value of {value}");

                                EmbedBuilder b = new EmbedBuilder();
                                b.Footer      = new EmbedFooterBuilder();
                                b.Footer.Text = "**Dev Config**";
                                b.Title       = "Dev Config List";
                                string list = "**Here is the current config file** \n";
                                foreach (var item in Global.JsonItemsListDevOps)
                                {
                                    list += $"```json\n \"{item.Key}\" : \"{item.Value}\"```\n";
                                }
                                b.Description = list;
                                b.Color       = Color.Green;
                                b.Footer.Text = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + " ZULU";
                                await Context.Channel.SendMessageAsync("", false, b.Build());
                            }
                        }
                        else
                        {
                            await Context.Channel.SendMessageAsync($"Could not find the config item {configItem}! Try `{Global.Preflix}modify list` for a list of the Config!");
                        }
                    }
                    if (Context.Guild.Id == Global.GuildID)
                    {
                        if (Context.Channel.Id == 561218509342769173)//allow some modify
                        {
                            if (Global.jsonItemsList.Keys.Contains(configItem))
                            {
                                JsonItems data = Global.CurrentJsonData;
                                data = modifyJsonData(data, configItem, newvalue);
                                if (data.Token != null)
                                {
                                    Global.SaveConfig(data);
                                    await Context.Channel.SendMessageAsync($"Sucessfuly modified the config, Updated the item {configItem} with the new value of {value}");

                                    EmbedBuilder b = new EmbedBuilder();
                                    b.Footer      = new EmbedFooterBuilder();
                                    b.Footer.Text = "**Admin Config**";
                                    b.Title       = "Admin Config List";
                                    string list = "**Here is the current config file** \n";
                                    foreach (var item in Global.jsonItemsList)
                                    {
                                        list += $"```json\n \"{item.Key}\" : \"{item.Value}\"```\n";
                                    }
                                    b.Description = list;
                                    b.Color       = Color.Green;
                                    b.Footer.Text = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + " ZULU";
                                    await Context.Channel.SendMessageAsync("", false, b.Build());
                                }
                            }
                            else
                            {
                                if (Global.JsonItemsListDevOps.Keys.Contains(configItem))
                                {
                                    EmbedBuilder b = new EmbedBuilder();
                                    b.Color       = Color.Red;
                                    b.Title       = "You need Better ***PERMISSION***";
                                    b.Description = "You do not have permission to modify this item, if you think this is incorrect you can DM quin#3017 for help";

                                    await Context.Channel.SendMessageAsync("", false, b.Build());
                                }
                                else
                                {
                                    await Context.Channel.SendMessageAsync($"Could not find the config item {configItem}! Try `{Global.Preflix}modify list` for a list of the Config!");
                                }
                            }
                        }
                    }
                }
            }
        }
Example #13
0
    private void UpdateInventoryDisplay()
    {
        if (this.m_items != null)
        {
            for (int i = 0; i < this.m_items.Length; i++)
            {
                UnityEngine.Object.Destroy(this.m_items[i]);
            }
            this.m_items = null;
        }
        int num = this.m_curPage * 16;

        if (this.m_itemDetails != null && num < this.m_itemDetails.Count)
        {
            int num2 = num + 15;
            this.m_items = new GameObject[Mathf.Min(this.m_itemDetails.Count - num, 16)];
            for (int j = 0; j < this.m_itemDetails.Count; j++)
            {
                if (j >= num && j <= num2)
                {
                    int      num3 = j - num;
                    JSONNode item = JsonItems.GetItem(this.m_itemDetails[j].m_iDefinition.m_SteamItemDef);
                    if (null != item)
                    {
                        this.m_items[num3] = (GameObject)UnityEngine.Object.Instantiate(this.m_itemPrefab);
                        this.m_items[num3].transform.parent        = base.transform;
                        this.m_items[num3].transform.localPosition = new Vector3(-0.01f + (float)(num3 % 4) * 0.278f, (float)(num3 / 4) * -0.278f, -0.01f);
                        this.m_items[num3].transform.localRotation = Quaternion.identity;
                        TextMesh componentInChildren = this.m_items[num3].GetComponentInChildren <TextMesh>();
                        componentInChildren.text = string.Concat(new string[]
                        {
                            "<color=#",
                            item["name_color"],
                            ">",
                            item["market_name"],
                            "</color>"
                        });
                        MeshCollider componentInChildren2 = this.m_items[num3].GetComponentInChildren <MeshCollider>();
                        componentInChildren2.renderer.material.mainTexture = Resources.Load <Texture>("inventory_steam/inventory_s_" + this.m_itemDetails[j].m_iDefinition.m_SteamItemDef);
                        componentInChildren2.transform.name = "sii-" + j.ToString();
                    }
                }
            }
        }
        this.m_txtPage.text = string.Empty;
        int num4 = (this.m_itemDetails.Count - 1) / 16 + 1;

        if (1 < num4)
        {
            for (int k = 1; k < num4 + 1; k++)
            {
                string str = k.ToString() + " ";
                if (this.m_curPage + 1 == k)
                {
                    str = "<color=\"#ffffff\">" + str + "</color>";
                }
                if (k < 10)
                {
                    str = " " + str;
                }
                TextMesh txtPage = this.m_txtPage;
                txtPage.text += str;
            }
        }
    }