Exemplo n.º 1
0
        public void about(userEntry commandUser, string argumentString)
        {
            string counterName;
            string argument;

            if (getSimpleArgs(argumentString, out counterName, out argument) >= 1)
            {
                counterEntry curCount = checkCreateEntry(counterName, false);

                if (curCount != null)
                {
                    if (!string.IsNullOrEmpty(curCount.Description))
                    {
                        m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterDescriptionDisplay"), curCount.Name, curCount.Description));
                    }
                    else
                    {
                        m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterDescriptionUpdateFailEmpty"), curCount.Name));
                    }
                }
                else
                {
                    m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterFailNotFound"), counterName));
                }
            }
            else
            {
                m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterNotSpecified"));
            }
        }
Exemplo n.º 2
0
        public void setOwner(userEntry commandUser, string argumentString)
        {
            string counterName;
            string argument;
            uint   argCount = getSimpleArgs(argumentString, out counterName, out argument);

            if (argCount >= 1)
            {
                if (argCount == 2)
                {
                    counterEntry curCount = checkCreateEntry(counterName);

                    curCount.Owner = argument;
                    m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterOwnerSetSuccess"), curCount.Name, argument));
                }
                else
                {
                    m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterOwnerSetFailEmpty"));
                }
            }
            else
            {
                m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterNotSpecified"));
            }
        }
Exemplo n.º 3
0
        public void remove(userEntry commandUser, string argumentString)
        {
            string countName;
            int    countValue;
            uint   argCount = getModifyArgs(argumentString, out countName, out countValue);

            if (argCount >= 1)
            {
                counterEntry curCounter = checkCreateEntry(countName);

                if (argCount == 1)
                {
                    countValue = curCounter.Count - 1;
                }
                else
                {
                    countValue = curCounter.Count - countValue;
                }

                setValue(commandUser, countName + " " + countValue, "remove");
            }
            else
            {
                m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterNotSpecified"));
            }
        }
Exemplo n.º 4
0
        public void describe(userEntry commandUser, string argumentString)
        {
            string counterName;
            string argument;
            uint   argCount = getSimpleArgs(argumentString, out counterName, out argument);

            if (argCount >= 1)
            {
                if (argCount == 2)
                {
                    counterEntry curCount = checkCreateEntry(counterName);

                    if (curCount.describe(argument))
                    {
                        m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterDescriptionUpdateSuccess"), curCount.Name));
                    }
                }
                else
                {
                    m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterDescriptionUpdateFailEmpty"));
                }
            }
            else
            {
                m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterNotSpecified"));
            }
        }
Exemplo n.º 5
0
        private void setValue(userEntry commandUser, string argumentString, string commandName = "set")
        {
            string countName;
            int    countValue;
            uint   argCount = getModifyArgs(argumentString, out countName, out countValue);

            if (argCount >= 1)
            {
                if (argCount == 1)
                {
                    m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterValueSetEmpty"));
                }

                counterEntry curCounter = checkCreateEntry(countName);

                if (curCounter.Owner == null || curCounter.Owner.ToLower() == commandUser.Nickname.ToLower())
                {
                    if (curCounter.set(countValue))
                    {
                        m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterValueSet"), curCounter.Name, curCounter.Count, curCounter.Game));
                    }
                }
                else
                {
                    m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterValueSetFailOwner"), commandName, curCounter.Owner, curCounter.Name));
                }
            }
            else
            {
                m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterNotSpecified"));
            }
        }
Exemplo n.º 6
0
        public counterEntry checkCreateEntry(string name, bool doCreate = true, string specificGame = null)
        {
            string gameString = (specificGame != null) ? specificGame : getGameString();

            if (gameString != GAME_NOGAME)
            {
                checkInitializeList(gameString);
            }

            counterEntry newCounter = tryLoadEntry(name);

            if (newCounter != null)
            {
                return(newCounter);
            }
            else if (doCreate)
            {
                newCounter = new counterEntry(name, gameString, m_BotBrain, true, false);
                if (newCounter.Initialized)
                {
                    m_Entries[gameString][name] = newCounter;
                    return(newCounter);
                }
            }

            return(null);
        }
Exemplo n.º 7
0
        private counterEntry tryLoadEntry(string name, string specificGame = null)
        {
            string gameString = (specificGame != null) ? specificGame : getGameString();

            if (m_Entries[gameString].ContainsKey(name))
            {
                return(m_Entries[gameString][name]);
            }
            if (gameString != GAME_NOGAME && m_Entries[GAME_NOGAME].ContainsKey(name))
            {
                return(m_Entries[GAME_NOGAME][name]);
            }

            counterEntry loadedEntry = new counterEntry(name, gameString, m_BotBrain, false);

            if (!loadedEntry.Initialized && gameString != GAME_NOGAME)
            {
                loadedEntry = new counterEntry(name, GAME_NOGAME, m_BotBrain, false);
            }

            if (loadedEntry.Initialized)
            {
                m_Entries[loadedEntry.Game][loadedEntry.Name] = loadedEntry;
                return(loadedEntry);
            }

            return(null);
        }
Exemplo n.º 8
0
        public void clearOwner(userEntry commandUser, string argumentString)
        {
            string counterName;
            string argument;
            uint   argCount = getSimpleArgs(argumentString, out counterName, out argument);

            if (!string.IsNullOrEmpty(argumentString))
            {
                counterEntry curCount = checkCreateEntry(argumentString, false);

                curCount.Owner = null;
                m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterOwnerClear"), curCount.Name));
            }
            else
            {
                m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterNotSpecified"));
            }
        }
Exemplo n.º 9
0
        public void delete(userEntry commandUser, string argumentString)
        {
            string countName;
            int    countValue;
            uint   argCount = getModifyArgs(argumentString, out countName, out countValue);

            if (argCount == 1)
            {
                counterEntry curCounter = checkCreateEntry(countName, false);
                string       useGame    = getGameString();

                if (curCounter == null && useGame != GAME_NOGAME)
                {
                    useGame    = GAME_NOGAME;
                    curCounter = checkCreateEntry(countName, false, useGame);
                }

                if (curCounter != null)
                {
                    string name = curCounter.Name;
                    string game = curCounter.Game;

                    if (curCounter.delete())
                    {
                        m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterRemoveSuccess"), name, game));
                        m_Entries[game].Remove(name);
                    }
                }
                else
                {
                    m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterFailNotFound"), countName));
                }
            }
            else
            {
                m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterNotSpecified"));
            }
        }
Exemplo n.º 10
0
        public void display(userEntry commandUser, string argumentString)
        {
            string counterName;
            string argument;

            if (getSimpleArgs(argumentString, out counterName, out argument) >= 1)
            {
                counterEntry curCount = checkCreateEntry(counterName, false);

                if (curCount != null)
                {
                    m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterDisplay"), curCount.Name, curCount.Count, curCount.Game));
                }
                else
                {
                    m_BotBrain.sendDefaultChannelMessage(string.Format(m_BotBrain.localizer.getString("counterFailNotFound"), argumentString));
                }
            }
            else
            {
                m_BotBrain.sendDefaultChannelMessage(m_BotBrain.localizer.getString("counterNotSpecified"));
            }
        }