ParseLootMessage() public static method

public static ParseLootMessage ( string message ) : Tuple>>
message string
return Tuple>>
示例#1
0
        private void popupTestButton_Click(object sender, EventArgs e)
        {
            string message = popupTestLootBox.Text;

            if (message[5] == ':')   //if the time stamp is in the form of hh:mm: (i.e. flash client format) remove the second colon
            {
                message = message.Remove(5, 1);
            }
            var parseResult = Parser.ParseLootMessage(message);

            if (parseResult != null)
            {
                bool showNotification = PopupManager.ShowDropNotification(new Tuple <Creature, List <Tuple <Item, int> >, string>(parseResult.Item1, parseResult.Item2, message));
                if (showNotification)
                {
                    MainForm.mainForm.Invoke((MethodInvoker) delegate {
                        PopupManager.ShowSimpleNotification(new SimpleLootNotification(parseResult.Item1, parseResult.Item2, message));
                    });
                }
            }
            else
            {
                MainForm.mainForm.DisplayWarning(String.Format("Could not parse loot message: {0}", popupTestLootBox.Text));
            }
        }
示例#2
0
 private void showPopupButton_Click(object sender, EventArgs e)
 {
     if (logMessageCollection.SelectedIndex >= 0)
     {
         string message = logMessageCollection.Items[logMessageCollection.SelectedIndex].ToString();
         var    result  = Parser.ParseLootMessage(message);
         if (result != null)
         {
             PopupManager.ShowSimpleNotification(new SimpleLootNotification(result.Item1, result.Item2, message));
         }
     }
 }
示例#3
0
        public static void deleteLogMessage(Hunt h, string logMessage)
        {
            string timeStamp = logMessage.Substring(0, 5);
            bool   found     = false;

            lock (hunts) {
                if (h.loot.logMessages.ContainsKey(timeStamp))
                {
                    if (h.loot.logMessages[timeStamp].Contains(logMessage))
                    {
                        h.loot.logMessages[timeStamp].Remove(logMessage);
                        var      logMessageItems = Parser.ParseLootMessage(logMessage);
                        Creature cr = logMessageItems.Item1;
                        if (h.loot.killCount.ContainsKey(cr))
                        {
                            h.loot.killCount[cr]--;
                            if (h.loot.killCount[cr] == 0)
                            {
                                h.loot.killCount.Remove(cr);
                            }
                        }
                        foreach (Tuple <Item, int> tpl in logMessageItems.Item2)
                        {
                            if (h.loot.creatureLoot[cr].ContainsKey(tpl.Item1))
                            {
                                h.loot.creatureLoot[cr][tpl.Item1] -= tpl.Item2;
                                if (h.loot.creatureLoot[cr][tpl.Item1] <= 0)
                                {
                                    h.loot.creatureLoot[cr].Remove(tpl.Item1);
                                }
                            }
                        }
                        found = true;
                    }
                }
            }
            if (!found)
            {
                return;
            }
            LootDatabaseManager.DeleteMessage(h, logMessage, null);
            LootDatabaseManager.UpdateLoot();
        }
示例#4
0
        public bool DeleteLogMessage(string logMessage)
        {
            string timestamp = logMessage.Substring(0, 5);

            lock (huntLock) {
                if (this.loot.logMessages.ContainsKey(timestamp))
                {
                    if (this.loot.logMessages[timestamp].Contains(logMessage))
                    {
                        this.loot.logMessages[timestamp].Remove(logMessage);
                        var      logMessageItems = Parser.ParseLootMessage(logMessage);
                        Creature cr = logMessageItems.Item1;
                        if (this.loot.killCount.ContainsKey(cr))
                        {
                            this.loot.killCount[cr]--;
                            if (this.loot.killCount[cr] == 0)
                            {
                                this.loot.killCount.Remove(cr);
                            }
                        }
                        foreach (Tuple <Item, int> tpl in logMessageItems.Item2)
                        {
                            if (this.loot.creatureLoot[cr].ContainsKey(tpl.Item1))
                            {
                                this.loot.creatureLoot[cr][tpl.Item1] -= tpl.Item2;
                                if (this.loot.creatureLoot[cr][tpl.Item1] <= 0)
                                {
                                    this.loot.creatureLoot[cr].Remove(tpl.Item1);
                                }
                            }
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
示例#5
0
        public static void Initialize()
        {
            //"Name#DBTableID#Track#Time#Exp#SideHunt#AggregateHunt#ClearOnStartup#Creature#Creature#..."
            if (!SettingsManager.settingExists("Hunts"))
            {
                SettingsManager.setSetting("Hunts", new List <string>()
                {
                    "New Hunt#True#0#0#False#True"
                });
            }
            hunts.Clear();
            int        activeHuntIndex = 0, index = 0;
            List <int> dbTableIds = new List <int>();

            foreach (string str in SettingsManager.getSetting("Hunts"))
            {
                SQLiteDataReader reader;
                Hunt             hunt   = new Hunt();
                string[]         splits = str.Split('#');
                if (splits.Length >= 7)
                {
                    hunt.name = splits[0];
                    if (!int.TryParse(splits[1].Trim(), out hunt.dbtableid))
                    {
                        continue;
                    }
                    if (dbTableIds.Contains(hunt.dbtableid))
                    {
                        continue;
                    }
                    dbTableIds.Add(hunt.dbtableid);

                    hunt.totalTime         = 0;
                    hunt.trackAllCreatures = splits[2] == "True";
                    double.TryParse(splits[3], NumberStyles.Any, CultureInfo.InvariantCulture, out hunt.totalTime);
                    long.TryParse(splits[4], out hunt.totalExp);
                    hunt.sideHunt       = splits[5] == "True";
                    hunt.aggregateHunt  = splits[6] == "True";
                    hunt.clearOnStartup = splits[7] == "True";
                    hunt.temporary      = false;
                    string massiveString = "";
                    for (int i = 8; i < splits.Length; i++)
                    {
                        if (splits[i].Length > 0)
                        {
                            massiveString += splits[i] + "\n";
                        }
                    }
                    hunt.trackedCreatures = massiveString;
                    // set this hunt to the active hunt if it is the active hunt
                    if (SettingsManager.settingExists("ActiveHunt") && SettingsManager.getSettingString("ActiveHunt") == hunt.name)
                    {
                        activeHuntIndex = index;
                    }

                    refreshLootCreatures(hunt);

                    if (hunt.clearOnStartup)
                    {
                        resetHunt(hunt);
                    }

                    // create the hunt table if it does not exist
                    LootDatabaseManager.CreateHuntTable(hunt);
                    // load the data for the hunt from the database
                    reader = LootDatabaseManager.GetHuntMessages(hunt);
                    while (reader.Read())
                    {
                        string message = reader["message"].ToString();
                        Tuple <Creature, List <Tuple <Item, int> > > resultList = Parser.ParseLootMessage(message);
                        if (resultList == null)
                        {
                            continue;
                        }

                        string t = message.Substring(0, 5);
                        if (!hunt.loot.logMessages.ContainsKey(t))
                        {
                            hunt.loot.logMessages.Add(t, new List <string>());
                        }
                        hunt.loot.logMessages[t].Add(message);

                        Creature cr = resultList.Item1;
                        if (!hunt.loot.creatureLoot.ContainsKey(cr))
                        {
                            hunt.loot.creatureLoot.Add(cr, new Dictionary <Item, int>());
                        }
                        foreach (Tuple <Item, int> tpl in resultList.Item2)
                        {
                            Item item  = tpl.Item1;
                            int  count = tpl.Item2;
                            if (!hunt.loot.creatureLoot[cr].ContainsKey(item))
                            {
                                hunt.loot.creatureLoot[cr].Add(item, count);
                            }
                            else
                            {
                                hunt.loot.creatureLoot[cr][item] += count;
                            }
                        }
                        if (!hunt.loot.killCount.ContainsKey(cr))
                        {
                            hunt.loot.killCount.Add(cr, 1);
                        }
                        else
                        {
                            hunt.loot.killCount[cr] += 1;
                        }
                    }
                    hunts.Add(hunt);
                    index++;
                }
            }
            if (hunts.Count == 0)
            {
                Hunt h = new Hunt();
                h.name      = "New Hunt";
                h.dbtableid = 1;
                hunts.Add(h);
                resetHunt(h);
            }
            activeHunt = hunts[activeHuntIndex];
            MainForm.mainForm.InitializeHuntDisplay(activeHuntIndex);
        }