Ejemplo n.º 1
0
        public void BettingEnable(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            bool enable = false;

            if (!value.ParseBool(ref enable))
            {
                sender.SendMessage(Importance.Low, "Betting is currently: {0}", Enabled ? "enabled" : "disabled");
                return;
            }

            Enabled = enable;
            sender.SendMessage(Importance.Med, "Betting is now {0}.", Enabled ? "enabled" : "disabled");
        }
Ejemplo n.º 2
0
        void m_bot_Tick(WinterBot sender, TimeSpan timeSinceLastUpdate)
        {
            if (!IsBettingOpen)
            {
                sender.SendMessage(Importance.High, "Betting is now CLOSED.");
                CancelCallback();
                return;
            }

            if (m_bettingStarted.Elapsed().TotalSeconds >= m_time)
            {
                sender.SendMessage(Importance.High, "Betting is now CLOSED.");
                CancelCallback();
                m_state = State.WaitingResult;
            }
        }
Ejemplo n.º 3
0
        private void SendMessage(WinterBot sender, string fmt, params object[] args)
        {
            if (m_lastMessage.Elapsed().Seconds < 20)
            {
                return;
            }

            sender.SendMessage(Importance.Low, string.Format(fmt, args));
            m_lastMessage = DateTime.Now;
        }
Ejemplo n.º 4
0
        public void ListCommands(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            if (m_lastCommandList.Elapsed().TotalSeconds < 15)
            {
                WinterBotSource.Log.DenyCommand(user.Name, cmd, "time");
                return;
            }

            m_lastCommandList = DateTime.Now;
            sender.SendMessage("A full listing of user commands can be found here: " + m_http.GetUrl("commands.php"));
            m_sent.AddLast(new Tuple <string, DateTime>("commands", DateTime.Now));
        }
Ejemplo n.º 5
0
        public void Result(WinterBot sender, TwitchUser user, string cmd, string value)
        {
            if (!Enabled)
            {
                return;
            }

            if (IsBettingClosed)
            {
                sender.SendMessage(Importance.Med, "Betting is not currently open.");
                return;
            }

            Args   args   = value.ParseArguments(sender);
            string result = args.GetOneWord();

            if (string.IsNullOrWhiteSpace(result))
            {
                sender.SendMessage(Importance.Med, "Usage: '!result [player]'.");
                return;
            }
            else if (!m_betting.Contains(result))
            {
                sender.SendMessage(Importance.High, "'{0}' not a valid player, valid players: {1}", result, string.Join(", ", m_betting));
                return;
            }

            var winners = from bet in m_bets
                          where bet.Value.Item1.Equals(result, StringComparison.CurrentCultureIgnoreCase)
                          select bet;

            var losers = from bet in m_bets
                         where !bet.Value.Item1.Equals(result, StringComparison.CurrentCultureIgnoreCase)
                         select bet;


            int totalWinners = 0, totalLosers = 0;

            foreach (var winner in winners)
            {
                AddPoints(winner.Key, winner.Value.Item2);
                totalWinners++;
            }

            foreach (var loser in losers)
            {
                AddPoints(loser.Key, -loser.Value.Item2);
                totalLosers++;
            }


            Tuple <TwitchUser, int>[] t = (from bet in m_bets
                                           select new Tuple <TwitchUser, int>(bet.Key, m_points[bet.Key])).ToArray();


            lock (m_sync)
                foreach (var usr in m_bets.Keys)
                {
                    m_queue.Add(new Tuple <TwitchUser, int>(usr, m_points[usr]));
                }

            m_event.Set();


            ClearBetting();
            CancelCallback();

            sender.SendMessage(Importance.High, "Betting complete.  {0} winners and {1} losers.  Point totals can be found here: http://www.darkautumn.net/winter/chat.php?POINTS", totalWinners, totalLosers);
        }