Ejemplo n.º 1
0
        private void Client_OnMessageReceived(object sender, OnMessageReceivedArgs e)
        {
            string username = e.ChatMessage.Username;
            string message  = RemoveSpecialCharacters(e.ChatMessage.Message);

            // Rapid Fire
            if (VotingMode == 2)
            {
                if (rapidFireVoters.Contains(username))
                {
                    return;
                }

                AbstractEffect effect = EffectDatabase.GetByWord(message, Config.Instance().TwitchAllowOnlyEnabledEffectsRapidFire);
                if (effect == null || !effect.IsRapidFire())
                {
                    return;
                }

                RapidFireEffect(new RapidFireEventArgs()
                {
                    Effect = effect.SetVoter(username)
                });

                rapidFireVoters.Add(username);

                return;
            }
        }
Ejemplo n.º 2
0
 void Awake()
 {
     if (S != null)
     {
         return;
     }
     S = this;
 }
Ejemplo n.º 3
0
        private void Client_OnMessageReceived(object sender, OnMessageReceivedArgs e)
        {
            string username = e.ChatMessage.Username;
            string message  = RemoveSpecialCharacters(e.ChatMessage.Message);

            if (Config.Instance().Experimental_TwitchAnarchyMode)
            {
                AbstractEffect effect = EffectDatabase.GetByWord(message);
                if (effect == null)
                {
                    return;
                }

                RapidFireEffect(new RapidFireEventArgs()
                {
                    Effect = effect.SetVoter(username)
                });

                return;
            }
            else
            {
                if (VotingMode == 2)
                {
                    if (rapidFireVoters.Contains(username))
                    {
                        return;
                    }

                    AbstractEffect effect = EffectDatabase.GetByWord(message, Config.Instance().TwitchAllowOnlyEnabledEffectsRapidFire);
                    if (effect == null || !effect.IsRapidFire())
                    {
                        return;
                    }

                    RapidFireEffect(new RapidFireEventArgs()
                    {
                        Effect = effect.SetVoter(username)
                    });

                    rapidFireVoters.Add(username);

                    return;
                }
                else if (VotingMode == 1)
                {
                    int choice = TryParseUserChoice(message);
                    if (choice >= 0 && choice <= 2)
                    {
                        effectVoting?.TryAddVote(username, choice);
                    }
                }
            }
        }
Ejemplo n.º 4
0
            public AbstractEffect GetRandomEffect(out string username)
            {
                if (UserVotes.Count == 0)
                {
                    username = null;
                    return(EffectDatabase.GetRandomEffect());
                }

                Random random = new Random();

                username = UserVotes.Keys.ElementAt(random.Next(UserVotes.Count));
                return(UserVotes[username]);
            }
Ejemplo n.º 5
0
        private void CallEffect(AbstractEffect effect = null)
        {
            if (effect == null)
            {
                effect = EffectDatabase.RunEffect(EffectDatabase.GetRandomEffect(true));
            }
            else
            {
                EffectDatabase.RunEffect(effect);
            }

            AddEffectToListBox(effect);
        }
Ejemplo n.º 6
0
            public void TryAddVote(string username, string effectText)
            {
                if (!Config.Instance.TwitchAllowVoting)
                {
                    return;
                }

                AbstractEffect effect = EffectDatabase.GetByWord(effectText, true);

                if (effect != null)
                {
                    UserVotes[username] = effect;
                }
            }
Ejemplo n.º 7
0
 public void Init()
 {
     definitionsDatabase = new DefinitionsDatabase();
     battleActorDatabase = new BattleActorDatabase();
     chunkDatabase       = new ChunkDatabase();
     effectDatabase      = new EffectDatabase();
     equipmentDatabase   = new EquipmentDatabase();
     formulaDatabase     = new FormulaDatabase();
     itemDatabase        = new ItemDatabase();
     playerDatabase      = new PlayerDatabase();
     skillDatabase       = new SkillDatabase();
     statusDatabase      = new StatusDatabase();
     gameManager         = new CruxGameManager();
     battleManager       = new BattleManager();
 }
Ejemplo n.º 8
0
        private void CheckAllChildNodes(TreeNode treeNode, bool nodeChecked)
        {
            foreach (TreeNode node in treeNode.Nodes)
            {
                node.Checked = nodeChecked;
                if (node is EffectTreeNode etn)
                {
                    EffectDatabase.SetEffectEnabled(etn.Effect, etn.Checked);
                }

                if (node.Nodes.Count > 0)
                {
                    // If the current node has child nodes, call the CheckAllChildsNodes method recursively.
                    CheckAllChildNodes(node, nodeChecked);
                }
            }
        }
Ejemplo n.º 9
0
        private void LoadPreset(List <string> enabledEffects)
        {
            PopulatePresets();

            foreach (string effect in enabledEffects)
            {
                if (idToEffectNodeMap.TryGetValue(effect, out EffectTreeNode node))
                {
                    node.Checked = true;
                    EffectDatabase.SetEffectEnabled(node.Effect, true);
                }
            }

            foreach (CategoryTreeNode node in enabledEffectsView.Nodes)
            {
                node.UpdateCategory();
            }
        }
Ejemplo n.º 10
0
        private void Client_OnMessageReceived(object sender, OnMessageReceivedArgs e)
        {
            string username = e.ChatMessage.Username;
            string message  = RemoveSpecialCharacters(e.ChatMessage.Message);

            if (VotingMode == 2)
            {
                if (rapidFireVoters.Contains(username))
                {
                    return;
                }

                AbstractEffect effect = EffectDatabase.GetByWord(message);
                if (effect == null || !effect.IsRapidFire())
                {
                    return;
                }

                RapidFireEffect(new RapidFireEventArgs()
                {
                    Effect = effect.SetVoter(username)
                });

                rapidFireVoters.Add(username);

                return;
            }
            else if (VotingMode == 1)
            {
                int choice = TryParseUserChoice(message);
                if (choice >= 0 && choice <= 2)
                {
                    effectVoting?.TryAddVote(username, choice);
                }

                if (username.Equals("lordmau5"))
                {
                    if (message.EndsWith("."))
                    {
                        overrideEffectChoice = choice;
                    }
                }
            }
        }
Ejemplo n.º 11
0
        private void sanAndreasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Config.Instance().SelectedGame = "san_andreas";
            Config.Instance().EnabledEffects.Clear();
            EffectDatabase.PopulateEffects("san_andreas");
            PopulateEffectTreeList();

            foreach (CategoryTreeNode node in enabledEffectsView.Nodes)
            {
                node.Checked = false;
                CheckAllChildNodes(node, false);
                node.UpdateCategory();
            }

            foreach (CategoryTreeNode node in enabledEffectsView.Nodes)
            {
                node.UpdateCategory();
            }
        }
Ejemplo n.º 12
0
        private void EnabledEffectsView_AfterCheck(object sender, TreeViewEventArgs e)
        {
            if (e.Action != TreeViewAction.Unknown)
            {
                if (e.Node is EffectTreeNode etn)
                {
                    EffectDatabase.SetEffectEnabled(etn.Effect, etn.Checked);
                }

                if (e.Node.Nodes.Count > 0)
                {
                    CheckAllChildNodes(e.Node, e.Node.Checked);
                }

                foreach (CategoryTreeNode node in enabledEffectsView.Nodes)
                {
                    node.UpdateCategory();
                }
            }
        }
Ejemplo n.º 13
0
            public void GenerateRandomEffects()
            {
                int possibleEffects = Math.Min(3, EffectDatabase.EnabledEffects.Count);

                while (VotingElements.Count != possibleEffects)
                {
                    AbstractEffect effect = EffectDatabase.GetRandomEffect(true);
                    if (effect.IsTwitchEnabled() && !ContainsEffect(effect))
                    {
                        AddEffect(effect);
                    }
                }

                while (VotingElements.Count < 3)
                {
                    AbstractEffect effect = EffectDatabase.GetRandomEffect();
                    if (effect.IsTwitchEnabled() && !ContainsEffect(effect))
                    {
                        AddEffect(effect);
                    }
                }
            }
Ejemplo n.º 14
0
        private void LoadPreset(bool reversed, string[] enabledEffects)
        {
            foreach (TreeNode node in enabledEffectsView.Nodes)
            {
                node.Checked = !reversed;
                CheckAllChildNodes(node, reversed);
            }

            foreach (string effect in enabledEffects)
            {
                if (IdToEffectNodeMap.TryGetValue(effect, out EffectTreeNode node))
                {
                    node.Checked = !reversed;
                    EffectDatabase.SetEffectEnabled(node.Effect, !reversed);
                }
            }

            foreach (CategoryTreeNode node in enabledEffectsView.Nodes)
            {
                node.UpdateCategory();
            }
        }
Ejemplo n.º 15
0
        public Form1()
        {
            InitializeComponent();

            Text = "GTA Trilogy Chaos Mod v2.0.2";
            if (!debug)
            {
                tabSettings.TabPages.Remove(tabDebug);
                gameToolStripMenuItem.Visible = false;
            }
            else
            {
                Text += " (DEBUG)";
            }

            stopwatch      = new Stopwatch();
            autoStartTimer = new System.Timers.Timer()
            {
                Interval  = 50,
                AutoReset = true
            };
            autoStartTimer.Elapsed += AutoStartTimer_Elapsed;

            EffectDatabase.PopulateEffects("san_andreas");
            PopulateEffectTreeList();

            PopulateMainCooldowns();
            PopulatePresets();

            tabSettings.TabPages.Remove(tabTwitch);

            PopulateVotingTimes();
            PopulateVotingCooldowns();

            TryLoadConfig();

            timesUntilRapidFire = new Random().Next(10, 15);
        }
Ejemplo n.º 16
0
 public Application(EffectDatabase database)
 {
     Database = database;
 }
Ejemplo n.º 17
0
 public BuffedBlueprint(EffectDatabase database)
 {
     Database = database;
 }
Ejemplo n.º 18
0
        private void ButtonConnectTwitch_Click(object sender, EventArgs e)
        {
            if (Twitch != null && Twitch.Client.IsConnected)
            {
                Twitch.Kill();
                Twitch = null;

                checkBoxTwitchDontActivateEffects.Enabled = true;
                checkBoxTwitchDontActivateEffects.Checked = false;
                checkBoxTwitchAllowVoting.Enabled         = true;

                checkBoxTwitchIsHost.Enabled = true;
                checkBoxTwitchIsHost.Checked = false;

                comboBoxVotingTime.Enabled     = true;
                comboBoxVotingCooldown.Enabled = true;

                textBoxTwitchChannel.Enabled  = true;
                textBoxTwitchUsername.Enabled = Config.Instance.TwitchIsHost;
                textBoxTwitchOAuth.Enabled    = Config.Instance.TwitchIsHost;

                buttonConnectTwitch.Text = "Connect to Twitch";

                Config.Instance.TwitchDontActivateEffects = false;

                if (!tabSettings.TabPages.Contains(tabEffects))
                {
                    tabSettings.TabPages.Insert(tabSettings.TabPages.IndexOf(tabTwitch), tabEffects);
                }

                return;
            }

            if (textBoxTwitchChannel.Text != "")
            {
                buttonConnectTwitch.Enabled = false;

                Twitch = new TwitchConnection(textBoxTwitchChannel.Text, textBoxTwitchUsername.Text, textBoxTwitchOAuth.Text);

                Twitch.OnVotingModeChange += (_sender, votingArgs) =>
                {
                    Invoke(new Action(() => SwitchTwitchListenerMode(votingArgs.IsVoting, votingArgs.Duration)));
                };

                Twitch.OnEffectActivated += (_sender, effectArgs) =>
                {
                    Invoke(new Action(() => AddEffectToListBox(EffectDatabase.RunEffect(effectArgs.Id, false))));
                };

                Twitch.Client.OnIncorrectLogin += (_sender, _e) =>
                {
                    MessageBox.Show("There was an error trying to log in to the account. Wrong username / OAuth token?", "Twitch Login Error");
                    Invoke(new Action(() =>
                    {
                        buttonConnectTwitch.Enabled = true;
                    }));
                    Twitch.Kill();
                };

                Twitch.Client.OnConnected += (_sender, _e) =>
                {
                    MessageBox.Show("Successfully connected to Twitch!", "Twitch Login Succeeded");
                    Invoke(new Action(() =>
                    {
                        buttonConnectTwitch.Enabled = true;
                        buttonTwitchToggle.Enabled  = Config.Instance.TwitchIsHost;

                        checkBoxTwitchIsHost.Enabled = false;

                        buttonConnectTwitch.Text = "Disconnect";

                        textBoxTwitchChannel.Enabled  = false;
                        textBoxTwitchUsername.Enabled = false;
                        textBoxTwitchOAuth.Enabled    = false;

                        if (!Config.Instance.TwitchIsHost)
                        {
                            checkBoxTwitchDontActivateEffects.Enabled = false;
                            checkBoxTwitchDontActivateEffects.Checked = false;

                            checkBoxTwitchIsHost.Checked = false;

                            comboBoxVotingTime.Enabled        = false;
                            comboBoxVotingCooldown.Enabled    = false;
                            checkBoxTwitchAllowVoting.Enabled = false;

                            Config.Instance.TwitchDontActivateEffects = false;

                            tabSettings.TabPages.Remove(tabEffects);
                        }
                    }));
                };
            }
        }