Exemplo n.º 1
0
 public void refreshHuntLog(Hunt h)
 {
     if (h == null) return;
     const int maxLogLines = 250;
     int count = 0;
     logMessageCollection.Items.Clear();
     foreach (string message in h.IterateLogMessages()) {
         logMessageCollection.Items.Add(message);
         if (count++ > maxLogLines) break;
     }
 }
Exemplo n.º 2
0
 public void refreshHuntLog(Hunt h)
 {
     if (h == null) return;
     const int maxLogLines = 250;
     List<string> timestamps = h.loot.logMessages.Keys.OrderByDescending(o => o).ToList();
     int count = 0;
     logMessageCollection.Items.Clear();
     foreach (string t in timestamps) {
         List<string> strings = h.loot.logMessages[t].ToList();
         strings.Reverse();
         foreach (string str in strings) {
             logMessageCollection.Items.Add(str);
             if (count++ > maxLogLines) break;
         }
         if (count > maxLogLines) break;
     }
 }
Exemplo n.º 3
0
 public static void SetHuntTime(Hunt h, int clearMinutes)
 {
     var expInformation = GlobalDataManager.GetTotalExperience(TimestampManager.getLatestTimes(clearMinutes));
     h.totalExp = expInformation.Item1;
     h.totalTime = expInformation.Item2 * 60;
 }
Exemplo n.º 4
0
        public static void ShowLootDrops(Hunt h, string comm, string screenshot_path)
        {
            LootDropForm ldf = new LootDropForm(comm);
            ldf.hunt = h;

            ShowNotification(ldf, comm, screenshot_path);
        }
Exemplo n.º 5
0
 public static void DeleteHuntTable(Hunt hunt)
 {
     ExecuteNonQuery(String.Format("DROP TABLE IF EXISTS \"{0}\";", hunt.GetTableName()));
     ExecuteNonQuery(String.Format("DROP TABLE IF EXISTS \"{0}\";", hunt.GetWasteTableName()));
 }
Exemplo n.º 6
0
        public static Tuple<Dictionary<Creature, int>, List<Tuple<Item, int>>> GenerateLootInformation(Hunt hunt, string rawName, Creature lootCreature)
        {
            Dictionary<Creature, int> creatureKills;
            List<Tuple<Item, int>> itemDrops = new List<Tuple<Item, int>>();

            bool raw = rawName == "raw";
            bool all = raw || rawName == "all";
            List<Creature> displayedCreatures = null;
            if (!hunt.trackAllCreatures && hunt.trackedCreatures.Length > 0) {
                displayedCreatures = hunt.GetTrackedCreatures();
            } else if (SettingsManager.getSettingBool("IgnoreLowExperience")) {
                displayedCreatures = new List<Creature>();
                foreach (Creature cr in hunt.IterateCreatures()) {
                    if (cr.experience >= SettingsManager.getSettingInt("IgnoreLowExperienceValue")) {
                        displayedCreatures.Add(cr);
                    }
                }
            }

            if (lootCreature != null) {
                //the command is loot@<creature>, so we only display the kills and loot from the specified creature
                creatureKills = hunt.GetCreatureKills(lootCreature);
            } else if (displayedCreatures == null) {
                creatureKills = hunt.GetCreatureKills(); //display all creatures //loot.killCount;
            } else {
                // only display tracked creatures
                creatureKills = hunt.GetCreatureKills(displayedCreatures); // new Dictionary<Creature, int>();
            }

            // now handle item drops, gather a count for every item
            Dictionary<Item, int> itemCounts = new Dictionary<Item, int>();
            foreach (KeyValuePair<Creature, Dictionary<Item, int>> kvp in hunt.IterateLoot()) {
                if (lootCreature != null && kvp.Key != lootCreature) continue; // if lootCreature is specified, only consider loot from the specified creature
                if (displayedCreatures != null && !displayedCreatures.Contains(kvp.Key)) continue;
                foreach (KeyValuePair<Item, int> kvp2 in kvp.Value) {
                    Item item = kvp2.Key;
                    int value = kvp2.Value;
                    if (!itemCounts.ContainsKey(item)) itemCounts.Add(item, value);
                    else itemCounts[item] += value;
                }
            }

            // now we do item conversion
            long extraGold = 0;
            foreach (KeyValuePair<Item, int> kvp in itemCounts) {
                Item item = kvp.Key;
                int count = kvp.Value;
                // discard items that are set to be discarded (as long as all/raw mode is not enabled)
                if (item.discard && !all) continue;
                // convert items to gold (as long as raw mode is not enabled), always gather up all the gold coins found
                if ((!raw && item.convert_to_gold) || item.displayname == "gold coin" || item.displayname == "platinum coin" || item.displayname == "crystal coin") {
                    extraGold += item.GetMaxValue() * count;
                } else {
                    itemDrops.Add(new Tuple<Item, int>(item, count));
                }
            }

            // handle coin drops, we always convert the gold to the highest possible denomination (so if gold = 10K, we display a crystal coin)
            long currentGold = extraGold;
            if (currentGold > 10000) {
                itemDrops.Add(new Tuple<Item, int>(StorageManager.getItem("crystal coin"), (int)(currentGold / 10000)));
                currentGold = currentGold % 10000;
            }
            if (currentGold > 100) {
                itemDrops.Add(new Tuple<Item, int>(StorageManager.getItem("platinum coin"), (int)(currentGold / 100)));
                currentGold = currentGold % 100;
            }
            if (currentGold > 0) {
                itemDrops.Add(new Tuple<Item, int>(StorageManager.getItem("gold coin"), (int)(currentGold)));
            }

            // now order by value so most valuable items are placed first
            // we use a special value for the gold coins so the gold is placed together in the order crystal > platinum > gold
            // gold coins = <gold total> - 2, platinum coins = <gold total> - 1, crystal coins = <gold total>
            itemDrops = itemDrops.OrderByDescending(o => o.Item1.displayname == "gold coin" ? extraGold - 2 : (o.Item1.displayname == "platinum coin" ? extraGold - 1 : (o.Item1.displayname == "crystal coin" ? extraGold : o.Item1.GetMaxValue() * o.Item2))).ToList();
            return new Tuple<Dictionary<Creature, int>, List<Tuple<Item, int>>>(creatureKills, itemDrops);
        }
Exemplo n.º 7
0
 void loadLog(Hunt h, string logPath)
 {
     resetHunt(h);
     StreamReader streamReader = new StreamReader(logPath);
     string line;
     Dictionary<string, List<string>> logMessages = new Dictionary<string, List<string>>();
     while ((line = streamReader.ReadLine()) != null) {
         if (line.Length < 15) continue;
         string t = line.Substring(0, 5);
         if (!(isDigit(t[0]) && isDigit(t[1]) && isDigit(t[3]) && isDigit(t[4]) && t[2] == ':')) continue; //not a valid timestamp
         if (!logMessages.ContainsKey(t)) logMessages.Add(t, new List<string>());
         logMessages[t].Add(line);
     }
     ParseLootMessages(h, logMessages, null, true, true);
     LootChanged();
 }
Exemplo n.º 8
0
 public static bool HuntTableExists(Hunt h)
 {
     int value = 0;
     object result = ExecuteScalar(String.Format("SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='{0}';", h.GetTableName()));
     if (result != null && int.TryParse(result.ToString(), out value)) {
         return value != 0;
     }
     return false;
 }
Exemplo n.º 9
0
 public static SQLiteDataReader GetHuntMessages(Hunt hunt)
 {
     return(ExecuteReaderQuery(String.Format("SELECT message FROM \"{0}\" ORDER BY day, hour, minute;", hunt.GetTableName())));
 }
Exemplo n.º 10
0
 public static void InsertMessage(Hunt hunt, int stamp, int hour, int minute, string message)
 {
     SQLiteCommand command = new SQLiteCommand(String.Format("INSERT INTO \"{4}\" VALUES({0}, {1}, {2}, \"{3}\");", stamp, hour, minute, message.Replace("\"", "\\\""), hunt.GetTableName()), lootConn);
     command.ExecuteNonQuery();
 }
Exemplo n.º 11
0
 public static void CreateHuntTable(Hunt hunt)
 {
     ExecuteNonQuery(String.Format("CREATE TABLE IF NOT EXISTS \"{0}\"(day INTEGER, hour INTEGER, minute INTEGER, message STRING);", hunt.GetTableName()));
     ExecuteNonQuery(String.Format("CREATE TABLE IF NOT EXISTS \"{0}\"(itemid INTEGER, amount INTEGER);", hunt.GetWasteTableName()));
 }
Exemplo n.º 12
0
 public static void DeleteHuntTable(Hunt hunt)
 {
     ExecuteNonQuery(String.Format("DROP TABLE IF EXISTS \"{0}\";", hunt.GetTableName()));
     ExecuteNonQuery(String.Format("DROP TABLE IF EXISTS \"{0}\";", hunt.GetWasteTableName()));
 }
Exemplo n.º 13
0
        public void UpdateLootForm()
        {
            Hunt hunt = HuntManager.activeHunt;
            int  minheight, maxheight;

            ClearControlList(lootControls, out minheight, out maxheight);

            int counter;
            int y = minheight;

            if (maxheight < 0)
            {
                y = 30;
                foreach (Control c in summaryControls)
                {
                    y = Math.Max(c.Location.Y + c.Height, y);
                }
            }
            var loot = LootDropForm.GenerateLootInformation(hunt, "", null);

            totalValue = 0;
            foreach (Tuple <Item, int> tpl in loot.Item2)
            {
                totalValue += tpl.Item1.GetMaxValue() * tpl.Item2;
            }

            int maxDrops = SettingsManager.getSettingInt("SummaryMaxItemDrops");

            if (maxDrops < 0)
            {
                maxDrops = 5;
            }
            if (maxDrops > 0)
            {
                CreateHeaderLabel("Item Drops", x, ref y, lootControls);
                counter = 0;
                int width = 0;
                var items = new List <Tuple <Item, int> >();
                foreach (Tuple <Item, int> tpl in loot.Item2)
                {
                    int amount = tpl.Item2;
                    while (amount > 0)
                    {
                        int count = Math.Min(100, amount);
                        amount -= count;
                        items.Add(new Tuple <Item, int>(tpl.Item1, count));
                        width += ImageHeight + 2;
                        if (width > ImageWidth - ImageHeight)
                        {
                            CreateItemList(items, x, ref y, lootControls);
                            items.Clear();
                            width = 0;
                            if (++counter >= maxDrops)
                            {
                                break;
                            }
                        }
                    }
                }
                if (items.Count > 0)
                {
                    CreateItemList(items, x, ref y, lootControls);
                    items.Clear();
                }
            }
            int maxCreatures = SettingsManager.getSettingInt("SummaryMaxCreatures");

            if (maxCreatures < 0)
            {
                maxCreatures = 5;
            }
            if (maxCreatures > 0)
            {
                CreateHeaderLabel("Creature Kills", x, ref y, lootControls);
                counter = 0;
                foreach (Creature cr in loot.Item1.Keys.OrderByDescending(o => loot.Item1[o] * (1 + o.experience)).ToList <Creature>())
                {
                    CreateCreatureBox(cr, loot.Item1[cr], x, ref y, lootControls);
                    if (++counter >= maxCreatures)
                    {
                        break;
                    }
                }
            }
            int maxRecentDrops = SettingsManager.getSettingInt("SummaryMaxRecentDrops");

            if (maxRecentDrops < 0)
            {
                maxRecentDrops = 5;
            }
            if (maxRecentDrops > 0)
            {
                CreateHeaderLabel("Recent Drops", x, ref y, lootControls);
                var recentDrops = ScanningManager.GetRecentDrops(maxRecentDrops);
                foreach (var drops in recentDrops)
                {
                    CreateCreatureDropsBox(drops.Item1, drops.Item2, drops.Item3, x, ref y, lootControls);
                }
            }
            UpdateDamageForm();
        }
Exemplo n.º 14
0
        public static void DeleteMessagesBefore(Hunt h, int stamp, int hour, int minute)
        {
            SQLiteCommand comm = new SQLiteCommand(String.Format("DELETE FROM \"{0}\" WHERE day < {1} OR hour < {2} OR (hour == {2} AND minute < {3})", h.GetTableName(), stamp, hour, minute), lootConn);

            comm.ExecuteNonQuery();
        }
Exemplo n.º 15
0
        public static void DeleteMessage(Hunt hunt, string msg, SQLiteTransaction transaction)
        {
            SQLiteCommand command = new SQLiteCommand(String.Format("DELETE FROM \"{0}\" WHERE message=\"{1}\"", hunt.GetTableName(), msg.Replace("\"", "\\\"")), lootConn, transaction);

            command.ExecuteNonQuery();
        }
Exemplo n.º 16
0
        public static void InsertMessage(Hunt hunt, int stamp, int hour, int minute, string message)
        {
            SQLiteCommand command = new SQLiteCommand(String.Format("INSERT INTO \"{4}\" VALUES({0}, {1}, {2}, \"{3}\");", stamp, hour, minute, message.Replace("\"", "\\\""), hunt.GetTableName()), lootConn);

            command.ExecuteNonQuery();
        }
Exemplo n.º 17
0
 public static void InsertMessage(Hunt hunt, int stamp, int hour, int minute, string message)
 {
     ExecuteNonQuery(String.Format("INSERT INTO \"{4}\" VALUES({0}, {1}, {2}, \"{3}\");", stamp, hour, minute, message.Replace("\"", "\\\""), hunt.GetTableName()));
 }
Exemplo n.º 18
0
 public static SQLiteDataReader GetHuntMessages(Hunt hunt)
 {
     SQLiteCommand command = new SQLiteCommand(String.Format("SELECT message FROM \"{0}\" ORDER BY day, hour, minute;", hunt.GetTableName()), lootConn);
     return command.ExecuteReader();
 }
Exemplo n.º 19
0
 public static void DeleteMessage(Hunt hunt, string msg, SQLiteTransaction transaction)
 {
     ExecuteNonQuery(String.Format("DELETE FROM \"{0}\" WHERE message=\"{1}\"", hunt.GetTableName(), msg.Replace("\"", "\\\"")));
 }
Exemplo n.º 20
0
        void clearOldLog(Hunt h, int clearMinutes = 10)
        {
            var time = DateTime.Now;
            int hour = time.Hour;
            int minute = time.Minute;
            while (clearMinutes > 60) {
                hour--;
                clearMinutes -= 60;
            }
            if (minute >= clearMinutes) {
                minute -= clearMinutes;
            } else {
                hour--;
                minute = 60 + (minute - clearMinutes);
            }
            int stamp = getDayStamp();
            while (hour < 0) {
                hour += 24;
                stamp--;
            }

            h.loot.creatureLoot.Clear();
            h.loot.killCount.Clear();
            h.loot.logMessages.Clear();
            h.totalExp = 0;
            h.totalTime = 0;
            foreach (string t in getLatestTimes(clearMinutes)) {
                if (totalExperienceResults.ContainsKey(t)) {
                    h.totalExp += totalExperienceResults[t];
                    h.totalTime += 60;
                }
            }

            SQLiteCommand comm = new SQLiteCommand(String.Format("DELETE FROM \"{0}\" WHERE day < {1} OR hour < {2} OR (hour == {2} AND minute < {3})", h.GetTableName(), stamp, hour, minute), lootConn);
            comm.ExecuteNonQuery();

            comm = new SQLiteCommand(String.Format("SELECT message FROM \"{0}\"", h.GetTableName()), lootConn);
            SQLiteDataReader reader = comm.ExecuteReader();
            Dictionary<string, List<string>> logMessages = new Dictionary<string, List<string>>();
            while (reader.Read()) {
                string line = reader["message"].ToString();
                if (line.Length < 15) continue;
                string t = line.Substring(0, 5);
                if (!(isDigit(t[0]) && isDigit(t[1]) && isDigit(t[3]) && isDigit(t[4]) && t[2] == ':')) continue; //not a valid timestamp
                if (!logMessages.ContainsKey(t)) logMessages.Add(t, new List<string>());
                logMessages[t].Add(line);
            }
            ParseLootMessages(h, logMessages, null, false, false, true);
            LootChanged();
        }
Exemplo n.º 21
0
 public static void DeleteMessagesBefore(Hunt h, int stamp, int hour, int minute)
 {
     ExecuteNonQuery(String.Format("DELETE FROM \"{0}\" WHERE day < {1} OR hour < {2} OR (hour == {2} AND minute < {3})", h.GetTableName(), stamp, hour, minute));
 }
Exemplo n.º 22
0
        void saveLog(Hunt h, string logPath)
        {
            StreamWriter streamWriter = new StreamWriter(logPath);

            // we load the data from the database instead of from the stored dictionary so it is ordered properly
            SQLiteCommand comm = new SQLiteCommand(String.Format("SELECT message FROM \"{0}\"", h.GetTableName()), lootConn);
            SQLiteDataReader reader = comm.ExecuteReader();
            while (reader.Read()) {
                streamWriter.WriteLine(reader["message"].ToString());
            }
            streamWriter.Flush();
            streamWriter.Close();
        }
Exemplo n.º 23
0
 public static SQLiteDataReader GetUsedItems(Hunt h)
 {
     return(ExecuteReaderQuery(String.Format("SELECT itemid, amount FROM {0}", h.GetWasteTableName())));
 }
Exemplo n.º 24
0
        public static void UpdateUsedItems(Hunt h)
        {
            var usedItems = h.GetUsedItems();
            lock(lootLock) {
                foreach (var item in usedItems) {
                    int itemid = item.Item1.id;
                    int amount = item.Item2;

                    int value = 0;
                    object result = ExecuteScalar(String.Format("SELECT itemid FROM {0} WHERE itemid={1}", h.GetWasteTableName(), itemid));
                    if (result != null && int.TryParse(result.ToString(), out value)) {
                        ExecuteNonQuery(String.Format("UPDATE {0} SET amount={1} WHERE itemid={2}", h.GetWasteTableName(), amount, itemid));
                    } else {
                        ExecuteNonQuery(String.Format("INSERT INTO {0} (itemid, amount) VALUES ({1}, {2})", h.GetWasteTableName(), itemid, amount));
                    }
                }
            }
        }
Exemplo n.º 25
0
        public static bool ExecuteCommand(string command, ParseMemoryResults parseMemoryResults = null)
        {
            try {
                if (parseMemoryResults == null)
                {
                    parseMemoryResults = ScanningManager.lastResults;
                }
                string comp = command.Trim().ToLower();
                Console.WriteLine(command);
                if (comp.StartsWith("creature" + Constants.CommandSymbol))   //creature@
                {
                    string[] split     = command.Split(Constants.CommandSymbol);
                    string   parameter = split[1].Trim().ToLower();
                    Creature cr        = StorageManager.getCreature(parameter);
                    if (cr != null)
                    {
                        NotificationManager.ShowCreatureDrops(cr, command);
                    }
                    else
                    {
                        List <TibiaObject> creatures = StorageManager.searchCreature(parameter);
                        if (creatures.Count == 1)
                        {
                            NotificationManager.ShowCreatureDrops(creatures[0].AsCreature(), command);
                        }
                        else if (creatures.Count > 1)
                        {
                            NotificationManager.ShowCreatureList(creatures, "Creature List", command);
                        }
                    }
                }
                else if (comp.StartsWith("look" + Constants.CommandSymbol))     //look@
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    if (parameter == "on")
                    {
                        SettingsManager.setSetting("LookMode", "True");
                    }
                    else if (parameter == "off")
                    {
                        SettingsManager.setSetting("LookMode", "False");
                    }
                    else
                    {
                        List <string>      times = TimestampManager.getLatestTimes(5);
                        List <TibiaObject> items = new List <TibiaObject>();
                        foreach (string message in GlobalDataManager.GetLookInformation(times))
                        {
                            string itemName = Parser.parseLookItem(message).ToLower();
                            Item   item     = StorageManager.getItem(itemName);

                            if (item != null)
                            {
                                items.Add(item);
                            }
                            else
                            {
                                Creature cr = StorageManager.getCreature(itemName);
                                if (cr != null)
                                {
                                    items.Add(cr);
                                }
                            }
                        }
                        if (items.Count == 1)
                        {
                            if (items[0] is Item)
                            {
                                NotificationManager.ShowItemNotification("item" + Constants.CommandSymbol + items[0].GetName().ToLower());
                            }
                            else if (items[0] is Creature)
                            {
                                NotificationManager.ShowCreatureDrops(items[0].AsCreature(), command);
                            }
                        }
                        else if (items.Count > 1)
                        {
                            NotificationManager.ShowCreatureList(items, "Looked At Items", command);
                        }
                    }
                }
                else if (comp.StartsWith("stats" + Constants.CommandSymbol))     //stats@
                {
                    string   name = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    Creature cr   = StorageManager.getCreature(name);
                    if (cr != null)
                    {
                        NotificationManager.ShowCreatureStats(cr, command);
                    }
                }
                else if (comp.StartsWith("close" + Constants.CommandSymbol))     //close@
                                                                                 // close all notifications
                {
                    NotificationManager.ClearNotifications();
                    PopupManager.ClearSimpleNotifications();
                }
                else if (comp.StartsWith("delete" + Constants.CommandSymbol))     //delete@
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    int    killCount;
                    if (int.TryParse(parameter, out killCount))
                    {
                        HuntManager.deleteCreatureWithThreshold(killCount);
                    }
                    else
                    {
                        Creature cr = StorageManager.getCreature(parameter);
                        if (cr != null)
                        {
                            HuntManager.deleteCreatureFromLog(cr);
                        }
                    }
                }
                else if (comp.StartsWith("skin" + Constants.CommandSymbol))     //skin@
                {
                    string[] split     = command.Split(Constants.CommandSymbol);
                    string   parameter = split[1].Trim().ToLower();
                    int      count     = 1;
                    Creature cr        = StorageManager.getCreature(parameter);
                    if (cr != null)
                    {
                        if (split.Length > 2)
                        {
                            int.TryParse(split[2], out count);
                        }
                        HuntManager.InsertSkin(cr, count);
                    }
                    else
                    {
                        int.TryParse(parameter, out count);
                        // find creature with highest killcount with a skin and skin that
                        cr = HuntManager.GetHighestKillCreature(HuntManager.activeHunt);
                        if (cr != null)
                        {
                            HuntManager.InsertSkin(cr, count);
                        }
                    }
                }
                else if (comp.StartsWith("city" + Constants.CommandSymbol))     //city@
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    if (StorageManager.cityNameMap.ContainsKey(parameter))
                    {
                        City city = StorageManager.cityNameMap[parameter];
                        NotificationManager.ShowCityDisplayForm(city, command);
                    }
                }
                else if (comp.StartsWith("damage" + Constants.CommandSymbol))     //damage@
                {
                    if (parseMemoryResults != null)
                    {
                        string[] splits          = command.Split(Constants.CommandSymbol);
                        string   screenshot_path = "";
                        string   parameter       = splits[1].Trim().ToLower();
                        if (parameter == "screenshot" && splits.Length > 2)
                        {
                            parameter       = "";
                            screenshot_path = splits[2];
                        }
                        NotificationManager.ShowDamageMeter(parseMemoryResults.damagePerSecond, command, parameter, screenshot_path);
                    }
                }
                else if (comp.StartsWith("experience" + Constants.CommandSymbol))     //experience@
                {
                    if (parseMemoryResults != null)
                    {
                        NotificationManager.ShowExperienceChartNotification(command);
                    }
                }
                else if (comp.StartsWith("exp" + Constants.CommandSymbol))     //exp@
                {
                    string title = "Experience";
                    string text  = "Currently gaining " + (parseMemoryResults == null ? "unknown" : ((int)parseMemoryResults.expPerHour).ToString()) + " experience an hour.";
                    Image  image = StyleManager.GetImage("tibia.png");
                    if (!SettingsManager.getSettingBool("UseRichNotificationType"))
                    {
                        PopupManager.ShowSimpleNotification(title, text, image);
                    }
                    else
                    {
                        PopupManager.ShowSimpleNotification(new SimpleTextNotification(null, title, text));
                    }
                }
                else if (comp.StartsWith("loot" + Constants.CommandSymbol))     //loot@
                {
                    string[] splits          = command.Split(Constants.CommandSymbol);
                    string   screenshot_path = "";
                    string   parameter       = splits[1].Trim().ToLower();
                    if (parameter == "screenshot" && splits.Length > 2)
                    {
                        parameter       = "";
                        screenshot_path = splits[2];
                    }

                    Hunt currentHunt = HuntManager.activeHunt;
                    if (splits.Length >= 2 && splits[1] != "")
                    {
                        Hunt h = HuntManager.GetHunt(splits[1]);
                        if (h != null)
                        {
                            currentHunt = h;
                        }
                    }
                    // display loot notification
                    NotificationManager.ShowLootDrops(currentHunt, command, screenshot_path);
                }
                else if (comp.StartsWith("clipboard" + Constants.CommandSymbol))     //clipboard@
                // Copy loot message to the clipboard
                // clipboard@damage copies the damage information to the clipboard
                // clipboard@<creature> copies the loot of a specific creature to the clipboard
                // clipboard@ copies all loot to the clipboard
                {
                    string   creatureName = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    Creature lootCreature = null;
                    if (creatureName == "damage" && parseMemoryResults != null)
                    {
                        var    damageInformation = DamageChart.GenerateDamageInformation(parseMemoryResults.damagePerSecond, "");
                        string damageString      = "Damage Dealt: ";
                        foreach (var damage in damageInformation)
                        {
                            damageString += String.Format("{0}: {1:N1}%; ", damage.name, damage.percentage);
                        }
                        Clipboard.SetText(damageString.Substring(0, damageString.Length - 2));
                        return(true);
                    }
                    else if (creatureName != "")
                    {
                        lootCreature = StorageManager.getCreature(creatureName);
                    }

                    var tpl           = LootDropForm.GenerateLootInformation(HuntManager.activeHunt, "", lootCreature);
                    var creatureKills = tpl.Item1;
                    var itemDrops     = tpl.Item2;

                    string lootString = "";
                    if (creatureKills.Count == 1)
                    {
                        foreach (KeyValuePair <Creature, int> kvp in creatureKills)
                        {
                            lootString = "Total Loot of " + kvp.Value.ToString() + " " + kvp.Key.GetName() + (kvp.Value > 1 ? "s" : "") + ": ";
                        }
                    }
                    else
                    {
                        int totalKills = 0;
                        foreach (KeyValuePair <Creature, int> kvp in creatureKills)
                        {
                            totalKills += kvp.Value;
                        }
                        lootString = "Total Loot of " + totalKills + " Kills: ";
                    }
                    foreach (Tuple <Item, int> kvp in itemDrops)
                    {
                        lootString += kvp.Item2 + " " + kvp.Item1.displayname + (kvp.Item2 > 1 ? "s" : "") + ", ";
                    }
                    lootString = lootString.Substring(0, lootString.Length - 2) + ".";
                    Clipboard.SetText(lootString);
                }
                else if (comp.StartsWith("reset" + Constants.CommandSymbol))     //reset@
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    int    time      = 0;
                    if (parameter == "old")
                    {
                        HuntManager.clearOldLog(HuntManager.activeHunt);
                    }
                    else if (int.TryParse(parameter, out time) && time > 0)
                    {
                        HuntManager.clearOldLog(HuntManager.activeHunt, time);
                    }
                    else
                    {
                        // reset@<hunt> resets the specified hunt
                        if (parameter.Length > 0 && HuntManager.resetHunt(parameter))
                        {
                            return(true);
                        }
                        else
                        {
                            //reset@ deletes all loot from the currently active hunt
                            HuntManager.resetHunt(HuntManager.activeHunt);
                        }
                    }
                    MainForm.mainForm.refreshHunts();
                    ReadMemoryManager.ignoreStamp = TimestampManager.createStamp();
                }
                else if (comp.StartsWith("refresh" + Constants.CommandSymbol))     //refresh@
                                                                                   // refresh: refresh duration on current form, or if no current form, repeat last command without removing it from stack

                /*if (tooltipForm != null && !tooltipForm.IsDisposed) {
                 *  try {
                 *      (tooltipForm as NotificationForm).ResetTimer();
                 *  } catch {
                 *  }
                 * } else if (command_stack.Count > 0) {*/
                {
                    ExecuteCommand(NotificationManager.LastCommand().command);
                    //}
                    return(true);
                }
                else if (comp.StartsWith("switch" + Constants.CommandSymbol))     //switch@
                                                                                  // switch: switch to hunt
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    HuntManager.SwitchHunt(parameter);
                    HuntManager.SaveHunts();
                }
                else if (comp.StartsWith("item" + Constants.CommandSymbol))     //item@
                                                                                //show the item with all the NPCs that sell it
                {
                    NotificationManager.ShowItemNotification(command);
                }
                else if (comp.StartsWith("task" + Constants.CommandSymbol))     //task@
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    if (StorageManager.taskList.Keys.Contains(parameter))
                    {
                        NotificationManager.ShowCreatureList(StorageManager.taskList[parameter].ToList <TibiaObject>(), StorageManager.taskList[parameter][0].groupname, command);
                    }
                    else
                    {
                        int id = -1;
                        int.TryParse(parameter, out id);
                        List <TibiaObject> tasks = new List <TibiaObject>();
                        foreach (KeyValuePair <string, List <Task> > kvp in StorageManager.taskList)
                        {
                            foreach (Task t in kvp.Value)
                            {
                                if (id >= 0 && t.id == id)
                                {
                                    NotificationManager.ShowTaskNotification(t, command);
                                    return(true);
                                }
                                else
                                {
                                    if (t.GetName().Contains(parameter, StringComparison.OrdinalIgnoreCase))
                                    {
                                        tasks.Add(t);
                                    }
                                }
                            }
                        }
                        if (tasks.Count == 1)
                        {
                            NotificationManager.ShowTaskNotification(tasks[0] as Task, command);
                        }
                        else
                        {
                            NotificationManager.ShowCreatureList(tasks, String.Format("Tasks Containing \"{0}\"", parameter), command);
                        }
                    }
                }
                else if (comp.StartsWith("category" + Constants.CommandSymbol))     //category@
                                                                                    // list all items with the specified category
                {
                    string             parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    List <TibiaObject> items     = StorageManager.getItemsByCategory(parameter);
                    if (items.Count == 1)
                    {
                        NotificationManager.ShowItemNotification("item" + Constants.CommandSymbol + items[0].GetName().ToLower());
                    }
                    else if (items.Count > 1)
                    {
                        NotificationManager.ShowCreatureList(items, "Category: " + parameter, command, true);
                    }
                }
                else if (comp.StartsWith("hunt" + Constants.CommandSymbol))     //hunt@
                {
                    string[] splits    = command.Split(Constants.CommandSymbol);
                    string   parameter = splits[1].Trim().ToLower();
                    int      page      = 0;
                    if (splits.Length > 2 && int.TryParse(splits[2], out page))
                    {
                    }
                    if (Constants.cities.Contains(parameter))
                    {
                        List <HuntingPlace> huntingPlaces = StorageManager.getHuntsInCity(parameter);
                        NotificationManager.ShowCreatureList(huntingPlaces.ToList <TibiaObject>(), "Hunts in " + parameter, command);
                        return(true);
                    }
                    HuntingPlace h = StorageManager.getHunt(parameter);
                    if (h != null)
                    {
                        NotificationManager.ShowHuntingPlace(h, command);
                        return(true);
                    }
                    Creature cr = StorageManager.getCreature(parameter);
                    if (cr != null)
                    {
                        List <HuntingPlace> huntingPlaces = StorageManager.getHuntsForCreature(cr.id);
                        NotificationManager.ShowCreatureList(huntingPlaces.ToList <TibiaObject>(), "Hunts containing creature " + parameter.ToTitle(), command);
                        return(true);
                    }
                    int minlevel = -1, maxlevel = -1;
                    int level;
                    if (int.TryParse(parameter, out level))
                    {
                        minlevel = (int)(level * 0.8);
                        maxlevel = (int)(level * 1.2);
                    }
                    else if (parameter.Contains('-'))
                    {
                        string[] split = parameter.Split('-');
                        int.TryParse(split[0].Trim(), out minlevel);
                        int.TryParse(split[1].Trim(), out maxlevel);
                    }
                    if (minlevel >= 0 && maxlevel >= 0)
                    {
                        List <HuntingPlace> huntingPlaces = StorageManager.getHuntsForLevels(minlevel, maxlevel);
                        huntingPlaces = huntingPlaces.OrderBy(o => o.level).ToList();
                        NotificationManager.ShowCreatureList(huntingPlaces.ToList <TibiaObject>(), "Hunts between levels " + minlevel.ToString() + "-" + maxlevel.ToString(), command);
                        return(true);
                    }
                    else
                    {
                        string title;
                        List <HuntingPlace> huntList = StorageManager.searchHunt(parameter);
                        title = "Hunts Containing \"" + parameter + "\"";
                        if (huntList.Count == 1)
                        {
                            NotificationManager.ShowHuntingPlace(huntList[0], command);
                        }
                        else if (huntList.Count > 1)
                        {
                            NotificationManager.ShowCreatureList(huntList.ToList <TibiaObject>(), title, command);
                        }
                    }
                }
                else if (comp.StartsWith("npc" + Constants.CommandSymbol))     //npc@
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    NPC    npc       = StorageManager.getNPC(parameter);
                    if (npc != null)
                    {
                        NotificationManager.ShowNPCForm(npc, command);
                    }
                    else if (Constants.cities.Contains(parameter))
                    {
                        NotificationManager.ShowCreatureList(StorageManager.getNPCWithCity(parameter), "NPC List", command);
                    }
                    else
                    {
                        NotificationManager.ShowCreatureList(StorageManager.searchNPC(parameter), "NPC List", command);
                    }
                }
                else if (comp.StartsWith("savelog" + Constants.CommandSymbol))
                {
                    HuntManager.SaveLog(HuntManager.activeHunt, command.Split(Constants.CommandSymbol)[1].Trim().Replace("'", "\\'"));
                }
                else if (comp.StartsWith("loadlog" + Constants.CommandSymbol))
                {
                    HuntManager.LoadLog(HuntManager.activeHunt, command.Split(Constants.CommandSymbol)[1].Trim().Replace("'", "\\'"));
                }
                else if (comp.StartsWith("setdiscardgoldratio" + Constants.CommandSymbol))
                {
                    double val;
                    if (double.TryParse(command.Split(Constants.CommandSymbol)[1].Trim(), out val))
                    {
                        StorageManager.setGoldRatio(val);
                    }
                }
                else if (comp.StartsWith("wiki" + Constants.CommandSymbol))
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim();
                    string response  = "";
                    using (WebClient client = new WebClient()) {
                        response = client.DownloadString(String.Format("http://tibia.wikia.com/api/v1/Search/List?query={0}&limit=1&minArticleQuality=10&batch=1&namespaces=0", parameter));
                    }
                    Regex regex = new Regex("\"url\":\"([^\"]+)\"");
                    Match m     = regex.Match(response);
                    var   gr    = m.Groups[1];
                    MainForm.OpenUrl(gr.Value.Replace("\\/", "/"));
                }
                else if (comp.StartsWith("char" + Constants.CommandSymbol))
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim();
                    MainForm.OpenUrl("https://secure.tibia.com/community/?subtopic=characters&name=" + parameter);
                }
                else if (comp.StartsWith("setconvertgoldratio" + Constants.CommandSymbol))
                {
                    string   parameter = command.Split(Constants.CommandSymbol)[1].Trim();
                    string[] split     = parameter.Split('-');
                    if (split.Length < 2)
                    {
                        return(true);
                    }
                    int stackable = 0;
                    if (split[0] == "1")
                    {
                        stackable = 1;
                    }
                    double val;
                    if (double.TryParse(split[1], out val))
                    {
                        StorageManager.setConvertRatio(val, stackable == 1);
                    }
                }
                else if (comp.StartsWith("recent" + Constants.CommandSymbol) || comp.StartsWith("url" + Constants.CommandSymbol) || comp.StartsWith("last" + Constants.CommandSymbol))
                {
                    bool   url       = comp.StartsWith("url" + Constants.CommandSymbol);
                    int    type      = url ? 1 : 0;
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    if (comp.StartsWith("last" + Constants.CommandSymbol))
                    {
                        parameter = "1";
                    }
                    List <Command> command_list = GlobalDataManager.GetRecentCommands(type).Select(o => new Command()
                    {
                        player = o.Item1, command = o.Item2
                    }).ToList();
                    command_list.Reverse();
                    int number;
                    //recent@<number> opens the last <number> command, so recent@1 opens the last command
                    if (int.TryParse(parameter, out number))
                    {
                        if (number > 0 && number <= command_list.Count)
                        {
                            ListNotification.OpenCommand(command_list[number - 1].command, type);;
                            return(true);
                        }
                    }
                    else
                    {
                        //recent@<player> opens the last
                        bool found = false;
                        foreach (Command comm in command_list)
                        {
                            if (comm.player.ToLower() == parameter)
                            {
                                ListNotification.OpenCommand(command_list[number].command, type);
                                found = true;
                                break;
                            }
                        }
                        if (found)
                        {
                            return(true);
                        }
                    }
                    NotificationManager.ShowListNotification(command_list, type, command);
                }
                else if (comp.StartsWith("spell" + Constants.CommandSymbol))     // spell@
                {
                    string[] splits          = command.Split(Constants.CommandSymbol);
                    string   parameter       = splits[1].Trim().ToLower();
                    int      initialVocation = -1;
                    if (splits.Length > 2 && int.TryParse(splits[2], out initialVocation))
                    {
                    }
                    Spell spell = StorageManager.getSpell(parameter);
                    if (spell != null)
                    {
                        NotificationManager.ShowSpellNotification(spell, initialVocation, command);
                    }
                    else
                    {
                        List <TibiaObject> spellList = new List <TibiaObject>();
                        string             title;
                        if (Constants.vocations.Contains(parameter))
                        {
                            spellList = StorageManager.getSpellsForVocation(parameter);
                            title     = parameter.ToTitle() + " Spells";
                        }
                        else
                        {
                            spellList = StorageManager.searchSpell(parameter);
                            if (spellList.Count == 0)
                            {
                                spellList = StorageManager.searchSpellWords(parameter);
                            }
                            title = "Spells Containing \"" + parameter + "\"";
                        }
                        if (spellList.Count == 1)
                        {
                            NotificationManager.ShowSpellNotification(spellList[0].AsSpell(), initialVocation, command);
                        }
                        else if (spellList.Count > 1)
                        {
                            NotificationManager.ShowCreatureList(spellList, title, command);
                        }
                    }
                }
                else if (comp.StartsWith("outfit" + Constants.CommandSymbol))     // outfit@
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    Outfit outfit    = StorageManager.getOutfit(parameter);
                    if (outfit != null)
                    {
                        NotificationManager.ShowOutfitNotification(outfit, command);
                    }
                    else
                    {
                        string             title;
                        List <TibiaObject> outfitList = StorageManager.searchOutfit(parameter);
                        title = "Outfits Containing \"" + parameter + "\"";
                        if (outfitList.Count == 1)
                        {
                            NotificationManager.ShowOutfitNotification(outfitList[0].AsOutfit(), command);
                        }
                        else if (outfitList.Count > 1)
                        {
                            NotificationManager.ShowCreatureList(outfitList, title, command);
                        }
                    }
                }
                else if (comp.StartsWith("quest" + Constants.CommandSymbol))     // quest@
                {
                    string[] splits    = command.Split(Constants.CommandSymbol);
                    string   parameter = splits[1].Trim().ToLower();
                    int      page      = 0;
                    if (splits.Length > 2 && int.TryParse(splits[2], out page))
                    {
                    }
                    List <Quest> questList = new List <Quest>();
                    if (StorageManager.questNameMap.ContainsKey(parameter))
                    {
                        NotificationManager.ShowQuestNotification(StorageManager.questNameMap[parameter], command);
                    }
                    else
                    {
                        string title;
                        if (Constants.cities.Contains(parameter))
                        {
                            title = "Quests In " + parameter;
                            foreach (Quest q in StorageManager.questIdMap.Values)
                            {
                                if (q.city.ToLower() == parameter)
                                {
                                    questList.Add(q);
                                }
                            }
                        }
                        else
                        {
                            title = "Quests Containing \"" + parameter + "\"";
                            string[] splitStrings = parameter.Split(' ');
                            foreach (Quest quest in StorageManager.questIdMap.Values)
                            {
                                bool found = true;
                                foreach (string str in splitStrings)
                                {
                                    if (!quest.name.Contains(str, StringComparison.OrdinalIgnoreCase))
                                    {
                                        found = false;
                                        break;
                                    }
                                }
                                if (found)
                                {
                                    questList.Add(quest);
                                }
                            }
                        }
                        if (questList.Count == 1)
                        {
                            NotificationManager.ShowQuestNotification(questList[0], command);
                        }
                        else if (questList.Count > 1)
                        {
                            NotificationManager.ShowCreatureList(questList.ToList <TibiaObject>(), title, command);
                            //ShowQuestList(questList, title, command, page);
                        }
                    }
                }
                else if (comp.StartsWith("guide" + Constants.CommandSymbol))     // guide@
                {
                    string[] splits    = command.Split(Constants.CommandSymbol);
                    string   parameter = splits[1].Trim().ToLower();
                    int      page      = 0;
                    string   mission   = "";
                    if (splits.Length > 2 && int.TryParse(splits[2], out page))
                    {
                    }
                    if (splits.Length > 3)
                    {
                        mission = splits[3];
                    }
                    List <Quest> questList = new List <Quest>();
                    if (StorageManager.questNameMap.ContainsKey(parameter))
                    {
                        NotificationManager.ShowQuestGuideNotification(StorageManager.questNameMap[parameter], command, page, mission);
                    }
                    else
                    {
                        string title;
                        foreach (Quest quest in StorageManager.questIdMap.Values)
                        {
                            if (quest.name.Contains(parameter, StringComparison.OrdinalIgnoreCase))
                            {
                                questList.Add(quest);
                            }
                        }
                        title = "Quests Containing \"" + parameter + "\"";
                        if (questList.Count == 1)
                        {
                            NotificationManager.ShowQuestGuideNotification(questList[0], command, page, mission);
                        }
                        else if (questList.Count > 1)
                        {
                            NotificationManager.ShowCreatureList(questList.ToList <TibiaObject>(), title, command);
                        }
                    }
                }
                else if (comp.StartsWith("direction" + Constants.CommandSymbol))     // direction@
                {
                    string[] splits    = command.Split(Constants.CommandSymbol);
                    string   parameter = splits[1].Trim().ToLower();
                    int      page      = 0;
                    if (splits.Length > 2 && int.TryParse(splits[2], out page))
                    {
                    }
                    List <HuntingPlace> huntList = new List <HuntingPlace>();
                    HuntingPlace        h        = StorageManager.getHunt(parameter);
                    if (h != null)
                    {
                        NotificationManager.ShowHuntGuideNotification(h, command, page);
                    }
                    else
                    {
                        string title;
                        huntList = StorageManager.searchHunt(parameter);
                        title    = "Hunts Containing \"" + parameter + "\"";
                        if (huntList.Count == 1)
                        {
                            NotificationManager.ShowHuntGuideNotification(huntList[0], command, page);
                        }
                        else if (huntList.Count > 1)
                        {
                            NotificationManager.ShowCreatureList(huntList.ToList <TibiaObject>(), title, command);
                        }
                    }
                }
                else if (comp.StartsWith("mount" + Constants.CommandSymbol))     // mount@
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    Mount  m         = StorageManager.getMount(parameter);
                    if (m != null)
                    {
                        NotificationManager.ShowMountNotification(m, command);
                    }
                    else
                    {
                        string             title;
                        List <TibiaObject> mountList = StorageManager.searchMount(parameter);
                        title = "Mounts Containing \"" + parameter + "\"";
                        if (mountList.Count == 1)
                        {
                            NotificationManager.ShowMountNotification(mountList[0].AsMount(), command);
                        }
                        else if (mountList.Count > 1)
                        {
                            NotificationManager.ShowCreatureList(mountList, title, command);
                        }
                    }
                }
                else if (comp.StartsWith("pickup" + Constants.CommandSymbol))
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    Item   item      = StorageManager.getItem(parameter);
                    if (item != null)
                    {
                        StorageManager.setItemDiscard(item, false);
                    }
                }
                else if (comp.StartsWith("nopickup" + Constants.CommandSymbol))
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    Item   item      = StorageManager.getItem(parameter);
                    if (item != null)
                    {
                        StorageManager.setItemDiscard(item, true);
                    }
                }
                else if (comp.StartsWith("convert" + Constants.CommandSymbol))
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    Item   item      = StorageManager.getItem(parameter);
                    if (item != null)
                    {
                        StorageManager.setItemConvert(item, true);
                    }
                }
                else if (comp.StartsWith("noconvert" + Constants.CommandSymbol))
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                    Item   item      = StorageManager.getItem(parameter);
                    if (item != null)
                    {
                        StorageManager.setItemConvert(item, false);
                    }
                }
                else if (comp.StartsWith("setval" + Constants.CommandSymbol))
                {
                    string parameter = command.Split(Constants.CommandSymbol)[1].Trim();
                    if (!parameter.Contains('='))
                    {
                        return(true);
                    }
                    string[] split = parameter.Split('=');
                    string   item  = split[0].Trim().ToLower().Replace("'", "\\'");
                    long     value = 0;
                    if (long.TryParse(split[1].Trim(), out value))
                    {
                        Item it = StorageManager.getItem(split[0]);
                        if (it != null)
                        {
                            StorageManager.setItemValue(it, value);
                        }
                    }
                }
                else if (comp.StartsWith("screenshot" + Constants.CommandSymbol))
                {
                    ScreenshotManager.saveScreenshot("Screenshot", ScreenshotManager.takeScreenshot());
                }
                else
                {
                    bool found = false;
                    foreach (string city in Constants.cities)
                    {
                        if (comp.StartsWith(city + Constants.CommandSymbol))
                        {
                            string itemName = command.Split(Constants.CommandSymbol)[1].Trim().ToLower();
                            Item   item     = StorageManager.getItem(itemName);
                            if (item != null)
                            {
                                NPC npc = StorageManager.getNPCSellingItemInCity(item.id, city);
                                if (npc != null)
                                {
                                    NotificationManager.ShowNPCForm(npc, command);
                                }
                            }
                            else
                            {
                                Spell spell = StorageManager.getSpell(itemName);
                                if (spell != null)
                                {
                                    NPC npc = StorageManager.getNPCTeachingSpellInCity(spell.id, city);
                                    if (npc != null)
                                    {
                                        NotificationManager.ShowNPCForm(npc, command);
                                    }
                                }
                            }

                            found = true;
                        }
                    }
                    // else try custom commands
                    foreach (SystemCommand c in MainForm.mainForm.GetCustomCommands())
                    {
                        if (c.tibialyzer_command.Trim().Length > 0 && comp.StartsWith(c.tibialyzer_command + Constants.CommandSymbol))
                        {
                            string[] parameters           = command.Split(Constants.CommandSymbol);
                            string   systemCallParameters = c.parameters;
                            int      i = 0;
                            while (true)
                            {
                                if (systemCallParameters.Contains("{" + i.ToString() + "}"))
                                {
                                    systemCallParameters = systemCallParameters.Replace("{" + i.ToString() + "}", parameters.Length > i + 1 ? parameters[i + 1].Trim() : "");
                                }
                                else
                                {
                                    break;
                                }
                                i++;
                            }
                            ProcessStartInfo procStartInfo = new ProcessStartInfo(c.command, systemCallParameters);

                            procStartInfo.UseShellExecute = true;

                            // Do not show the cmd window to the user.
                            procStartInfo.CreateNoWindow = true;
                            procStartInfo.WindowStyle    = ProcessWindowStyle.Hidden;
                            Process.Start(procStartInfo);
                            return(true);
                        }
                    }
                    if (found)
                    {
                        return(true);
                    }
                    //if we get here we didn't find any command
                    return(false);
                }
                return(true);
            } catch (Exception e) {
                MainForm.mainForm.DisplayWarning(String.Format("Tibialyzer Exception While Processing Command \"{0}\".\nMessage: {1} ", command, e.Message));
                Console.WriteLine(e.Message);
                return(true);
            }
        }
Exemplo n.º 26
0
 public static void DeleteMessagesBefore(Hunt h, int stamp, int hour, int minute)
 {
     ExecuteNonQuery(String.Format("DELETE FROM \"{0}\" WHERE day < {1} OR hour < {2} OR (hour == {2} AND minute < {3})", h.GetTableName(), stamp, hour, minute));
 }
Exemplo n.º 27
0
        private void showAllLootButton_Click(object sender, EventArgs e)
        {
            Hunt h = MainForm.mainForm.getSelectedHunt();

            CommandManager.ExecuteCommand("loot" + Constants.CommandSymbol + (h == null ? "" : h.name));
        }
Exemplo n.º 28
0
        public static void DeleteHuntTable(Hunt hunt)
        {
            SQLiteCommand comm = new SQLiteCommand(String.Format("DROP TABLE IF EXISTS \"{0}\";", hunt.GetTableName()), lootConn);

            comm.ExecuteNonQuery();
        }
Exemplo n.º 29
0
 public static void CreateHuntTable(Hunt hunt)
 {
     SQLiteCommand command = new SQLiteCommand(String.Format("CREATE TABLE IF NOT EXISTS \"{0}\"(day INTEGER, hour INTEGER, minute INTEGER, message STRING);", hunt.GetTableName()), lootConn);
     command.ExecuteNonQuery();
 }
Exemplo n.º 30
0
 public static void SwitchHunt(string parameter)
 {
     lock (hunts) {
         foreach (Hunt h in hunts) {
             if (h.name.Contains(parameter, StringComparison.OrdinalIgnoreCase)) {
                 activeHunt = h;
                 break;
             }
         }
     }
 }
Exemplo n.º 31
0
 public static void DeleteMessage(Hunt hunt, string msg, SQLiteTransaction transaction)
 {
     SQLiteCommand command = new SQLiteCommand(String.Format("DELETE FROM \"{0}\" WHERE message=\"{1}\"", hunt.GetTableName(), msg.Replace("\"", "\\\"")), lootConn, transaction);
     command.ExecuteNonQuery();
 }
Exemplo n.º 32
0
        public static void ShowWasteForm(Hunt hunt, string command)
        {
            if (hunt == null) return;
            WasteForm f = new WasteForm();
            f.hunt = hunt;

            ShowNotification(f, command);
        }
Exemplo n.º 33
0
        public static SQLiteDataReader GetHuntMessages(Hunt hunt)
        {
            SQLiteCommand command = new SQLiteCommand(String.Format("SELECT message FROM \"{0}\" ORDER BY day, hour, minute;", hunt.GetTableName()), lootConn);

            return(command.ExecuteReader());
        }
Exemplo n.º 34
0
 public static void DeleteHuntTable(Hunt hunt)
 {
     SQLiteCommand comm = new SQLiteCommand(String.Format("DROP TABLE IF EXISTS \"{0}\";", hunt.GetTableName()), lootConn);
     comm.ExecuteNonQuery();
 }
Exemplo n.º 35
0
 public void refreshHuntLog(Hunt h)
 {
     (Tabs[3] as LogsTab).refreshHuntLog(h);
 }
Exemplo n.º 36
0
 public static void DeleteMessagesBefore(Hunt h, int stamp, int hour, int minute)
 {
     SQLiteCommand comm = new SQLiteCommand(String.Format("DELETE FROM \"{0}\" WHERE day < {1} OR hour < {2} OR (hour == {2} AND minute < {3})", h.GetTableName(), stamp, hour, minute), lootConn);
     comm.ExecuteNonQuery();
 }
Exemplo n.º 37
0
        public void UpdateLootForm()
        {
            Hunt hunt = HuntManager.activeHunt;
            int  minheight, maxheight;

            ClearControlList(lootControls, out minheight, out maxheight);

            int counter;
            int y = minheight;

            if (maxheight < 0)
            {
                y = 30;
                foreach (Control c in summaryControls)
                {
                    y = Math.Max(c.Location.Y + c.Height, y);
                }
            }
            var loot = LootDropForm.GenerateLootInformation(hunt, "", null);

            totalValue = 0;
            foreach (Tuple <Item, int> tpl in loot.Item2)
            {
                totalValue += tpl.Item1.GetMaxValue() * tpl.Item2;
            }

            averageValue = LootDropForm.GetAverageGold(loot.Item1);

            int maxDrops = SettingsManager.getSettingInt("SummaryMaxItemDrops");

            if (maxDrops < 0)
            {
                maxDrops = 5;
            }
            if (maxDrops > 0)
            {
                List <ItemRegion> region;
                int imageHeight = SettingsManager.getSettingInt("SummaryLootItemSize");
                imageHeight = imageHeight < 0 ? BlockHeight : imageHeight;

                CreateHeaderLabel("Item Drops", x, ref y, lootControls);
                counter = 0;
                bool display = true;
                int  width   = 0;
                var  items   = new List <Tuple <Item, int> >();
                foreach (Tuple <Item, int> tpl in loot.Item2)
                {
                    int amount = tpl.Item2;
                    while (amount > 0)
                    {
                        int count = Math.Min(100, amount);
                        amount -= count;
                        items.Add(new Tuple <Item, int>(tpl.Item1, count));
                        width += imageHeight + 2;
                        if (width > BlockWidth - imageHeight)
                        {
                            region = new List <ItemRegion>();
                            CreateItemList(items, x, ref y, lootControls, imageHeight, region, counter).MouseDown += OpenLootWindow;
                            lootRegions[counter] = region;
                            items.Clear();
                            width = 0;
                            if (++counter >= maxDrops)
                            {
                                display = false;
                                break;
                            }
                        }
                    }
                    if (!display)
                    {
                        break;
                    }
                }
                if (items.Count > 0)
                {
                    region = new List <ItemRegion>();
                    CreateItemList(items, x, ref y, lootControls, imageHeight, region, counter).MouseDown += OpenLootWindow;
                    lootRegions[counter] = region;
                    items.Clear();
                }
            }
            int maxCreatures = SettingsManager.getSettingInt("SummaryMaxCreatures");

            if (maxCreatures < 0)
            {
                maxCreatures = 5;
            }
            if (maxCreatures > 0)
            {
                CreateHeaderLabel("Creature Kills", x, ref y, lootControls);
                counter = 0;
                foreach (Creature cr in loot.Item1.Keys.OrderByDescending(o => loot.Item1[o] * (1 + o.experience)).ToList <Creature>())
                {
                    CreateCreatureBox(cr, loot.Item1[cr], x, ref y, lootControls);
                    if (++counter >= maxCreatures)
                    {
                        break;
                    }
                }
            }
            int maxRecentDrops = SettingsManager.getSettingInt("SummaryMaxRecentDrops");

            if (maxRecentDrops < 0)
            {
                maxRecentDrops = 5;
            }
            if (maxRecentDrops > 0)
            {
                CreateHeaderLabel("Recent Drops", x, ref y, lootControls);
                int imageHeight = SettingsManager.getSettingInt("SummaryRecentDropsItemSize");
                imageHeight = imageHeight < 0 ? BlockHeight : imageHeight;
                var recentDrops = ScanningManager.GetRecentDrops(maxRecentDrops);
                int index       = 0;
                foreach (var drops in recentDrops)
                {
                    List <ItemRegion> region = new List <ItemRegion>();
                    CreateCreatureDropsBox(drops.Item1, drops.Item2, drops.Item3, x, ref y, lootControls, imageHeight, region, index).MouseDown += OpenRecentDropsWindow;
                    recentDropsRegions[index++] = region;
                }
            }
            UpdateDamageForm();
        }
Exemplo n.º 38
0
 public static bool HuntTableExists(Hunt h)
 {
     SQLiteCommand command = new SQLiteCommand(String.Format("SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='{0}';", h.GetTableName()), lootConn);
     int value = int.Parse(command.ExecuteScalar().ToString());
     return value != 0;
 }
Exemplo n.º 39
0
        public void UpdateWasteForm()
        {
            Hunt hunt = HuntManager.activeHunt;

            int minheight, maxheight;

            ClearControlList(usedItemsControls, out minheight, out maxheight);

            int y = 30;

            foreach (Control c in damageControls.Count > 0 ? damageControls : (lootControls.Count > 0 ? lootControls : summaryControls))
            {
                y = Math.Max(c.Location.Y + c.Height, y);
            }
            totalWaste = 0;
            int maxUsedItems = SettingsManager.getSettingInt("SummaryMaxUsedItems");

            if (maxUsedItems < 0)
            {
                maxUsedItems = 5;
            }
            if (maxUsedItems > 0)
            {
                List <ItemRegion> region;
                int imageHeight = SettingsManager.getSettingInt("SummaryWasteItemSize");
                imageHeight = imageHeight < 0 ? BlockHeight : imageHeight;
                int counter = 0;
                CreateHeaderLabel("Used Items", x, ref y, usedItemsControls);
                int  width   = 0;
                var  items   = new List <Tuple <Item, int> >();
                bool display = true;
                foreach (Tuple <Item, int> tpl in HuntManager.GetUsedItems(hunt))
                {
                    int amount = tpl.Item2;
                    totalWaste += amount * tpl.Item1.GetMaxValue();
                    while (amount > 0 && display)
                    {
                        int count = Math.Min(100, amount);
                        amount -= count;
                        items.Add(new Tuple <Item, int>(tpl.Item1, count));
                        width += imageHeight + 2;
                        if (width > BlockWidth - imageHeight)
                        {
                            region = new List <ItemRegion>();
                            CreateItemList(items, x, ref y, usedItemsControls, imageHeight, region, counter).MouseDown += OpenWasteWindow;
                            wasteRegions[counter] = region;
                            items.Clear();
                            width = 0;
                            if (++counter >= maxUsedItems)
                            {
                                display = false;
                            }
                        }
                    }
                }
                if (items.Count > 0)
                {
                    region = new List <ItemRegion>();
                    CreateItemList(items, x, ref y, usedItemsControls, imageHeight, region, counter).MouseDown += OpenWasteWindow;
                    wasteRegions[counter] = region;
                    items.Clear();
                }
            }
            if (y != maxheight)
            {
                this.Size = new Size(BlockWidth + 10, y + 5);
            }
        }
Exemplo n.º 40
0
        public void addKillToHunt(Hunt h, Tuple<Creature, List<Tuple<Item, int>>> resultList, string t, string message, int stamp = 0, int hour = 0, int minute = 0, SQLiteTransaction transaction = null)
        {
            Creature cr = resultList.Item1;
            if (!h.loot.creatureLoot.ContainsKey(cr)) h.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 (!h.loot.creatureLoot[cr].ContainsKey(item)) h.loot.creatureLoot[cr].Add(item, count);
                else h.loot.creatureLoot[cr][item] += count;
            }
            if (!h.loot.killCount.ContainsKey(cr)) h.loot.killCount.Add(cr, 1);
            else h.loot.killCount[cr] += 1;

            if (!h.loot.logMessages.ContainsKey(t)) h.loot.logMessages.Add(t, new List<string>());
            h.loot.logMessages[t].Add(message);

            if (transaction != null) {
                string query = String.Format("INSERT INTO \"{4}\" VALUES({0}, {1}, {2}, \"{3}\");", stamp, hour, minute, message.Replace("\"", "\\\""), h.GetTableName());
                SQLiteCommand command = new SQLiteCommand(query, lootConn);
                command.ExecuteNonQuery();
            }
        }
Exemplo n.º 41
0
        public static Tuple <Dictionary <Creature, int>, List <Tuple <Item, int> > > GenerateLootInformation(Hunt hunt, string rawName, Creature lootCreature)
        {
            Dictionary <Creature, int> creatureKills;
            List <Tuple <Item, int> >  itemDrops = new List <Tuple <Item, int> >();

            bool            raw = rawName == "raw";
            bool            all = raw || rawName == "all";
            List <Creature> displayedCreatures = null;

            if (!hunt.trackAllCreatures && hunt.trackedCreatures.Length > 0)
            {
                displayedCreatures = hunt.GetTrackedCreatures();
            }
            else if (SettingsManager.getSettingBool("IgnoreLowExperience"))
            {
                displayedCreatures = new List <Creature>();
                foreach (Creature cr in hunt.IterateCreatures())
                {
                    if (cr.experience >= SettingsManager.getSettingInt("IgnoreLowExperienceValue"))
                    {
                        displayedCreatures.Add(cr);
                    }
                }
            }

            if (lootCreature != null)
            {
                //the command is loot@<creature>, so we only display the kills and loot from the specified creature
                creatureKills = hunt.GetCreatureKills(lootCreature);
            }
            else if (displayedCreatures == null)
            {
                creatureKills = hunt.GetCreatureKills(); //display all creatures //loot.killCount;
            }
            else
            {
                // only display tracked creatures
                creatureKills = hunt.GetCreatureKills(displayedCreatures); // new Dictionary<Creature, int>();
            }

            // now handle item drops, gather a count for every item
            Dictionary <Item, int> itemCounts = new Dictionary <Item, int>();

            foreach (KeyValuePair <Creature, Dictionary <Item, int> > kvp in hunt.IterateLoot())
            {
                if (lootCreature != null && kvp.Key != lootCreature)
                {
                    continue;                                                  // if lootCreature is specified, only consider loot from the specified creature
                }
                if (displayedCreatures != null && !displayedCreatures.Contains(kvp.Key))
                {
                    continue;
                }
                foreach (KeyValuePair <Item, int> kvp2 in kvp.Value)
                {
                    Item item  = kvp2.Key;
                    int  value = kvp2.Value;
                    if (!itemCounts.ContainsKey(item))
                    {
                        itemCounts.Add(item, value);
                    }
                    else
                    {
                        itemCounts[item] += value;
                    }
                }
            }

            // now we do item conversion
            long extraGold = 0;

            foreach (KeyValuePair <Item, int> kvp in itemCounts)
            {
                Item item  = kvp.Key;
                int  count = kvp.Value;
                // discard items that are set to be discarded (as long as all/raw mode is not enabled)
                if (item.discard && !all)
                {
                    continue;
                }
                // convert items to gold (as long as raw mode is not enabled), always gather up all the gold coins found
                if ((!raw && item.convert_to_gold) || item.displayname == "gold coin" || item.displayname == "platinum coin" || item.displayname == "crystal coin")
                {
                    extraGold += item.GetMaxValue() * count;
                }
                else
                {
                    itemDrops.Add(new Tuple <Item, int>(item, count));
                }
            }

            // handle coin drops, we always convert the gold to the highest possible denomination (so if gold = 10K, we display a crystal coin)
            long currentGold = extraGold;

            if (currentGold > 10000)
            {
                itemDrops.Add(new Tuple <Item, int>(StorageManager.getItem("crystal coin"), (int)(currentGold / 10000)));
                currentGold = currentGold % 10000;
            }
            if (currentGold > 100)
            {
                itemDrops.Add(new Tuple <Item, int>(StorageManager.getItem("platinum coin"), (int)(currentGold / 100)));
                currentGold = currentGold % 100;
            }
            if (currentGold > 0)
            {
                itemDrops.Add(new Tuple <Item, int>(StorageManager.getItem("gold coin"), (int)(currentGold)));
            }

            // now order by value so most valuable items are placed first
            // we use a special value for the gold coins so the gold is placed together in the order crystal > platinum > gold
            // gold coins = <gold total> - 2, platinum coins = <gold total> - 1, crystal coins = <gold total>
            itemDrops = itemDrops.OrderByDescending(o => o.Item1.displayname == "gold coin" ? extraGold - 2 : (o.Item1.displayname == "platinum coin" ? extraGold - 1 : (o.Item1.displayname == "crystal coin" ? extraGold : o.Item1.GetMaxValue() * o.Item2))).ToList();
            return(new Tuple <Dictionary <Creature, int>, List <Tuple <Item, int> > >(creatureKills, itemDrops));
        }
Exemplo n.º 42
0
 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 = 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;
     string huntTable = h.GetTableName();
     SQLiteCommand comm = new SQLiteCommand(String.Format("SELECT day,hour,minute,message FROM \"{0}\" WHERE message=\"{1}\"", huntTable, logMessage.Replace("\"", "\\\"")), lootConn);
     SQLiteDataReader reader = comm.ExecuteReader();
     if (reader.Read()) {
         comm = new SQLiteCommand(String.Format("DELETE FROM \"{0}\" WHERE day={1} AND hour={2} AND minute={3} AND message=\"{4}\"", huntTable, reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader["message"].ToString()), lootConn);
         comm.ExecuteNonQuery();
     }
     LootChanged();
 }
Exemplo n.º 43
0
 public static List <TibiaObject> refreshLootCreatures(Hunt h)
 {
     return(h.RefreshLootCreatures());
 }
Exemplo n.º 44
0
 void resetHunt(Hunt h)
 {
     lock (hunts) {
         h.loot.creatureLoot.Clear();
         h.loot.killCount.Clear();
         h.loot.logMessages.Clear();
         h.totalExp = 0;
         h.totalTime = 0;
     }
     string huntTable = h.GetTableName();
     SQLiteCommand comm = new SQLiteCommand(String.Format("DROP TABLE IF EXISTS \"{0}\";", huntTable), lootConn);
     comm.ExecuteNonQuery();
     comm = new SQLiteCommand(String.Format("CREATE TABLE IF NOT EXISTS \"{0}\"(day INTEGER, hour INTEGER, minute INTEGER, message STRING);", huntTable), lootConn);
     comm.ExecuteNonQuery();
     LootChanged();
 }
Exemplo n.º 45
0
        public static void Initialize()
        {
            lock (hunts) {
                //"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);

                            hunt.AddKillToHunt(resultList, t, message);
                        }
                        reader = LootDatabaseManager.GetUsedItems(hunt);
                        List <Tuple <Item, int> > usedItems = new List <Tuple <Item, int> >();
                        while (reader.Read())
                        {
                            int itemid = reader.GetInt32(0);
                            int amount = reader.GetInt32(1);
                            usedItems.Add(new Tuple <Item, int>(StorageManager.getItem(itemid), amount));
                        }
                        hunt.AddUsedItems(usedItems);
                        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);
            }
        }
Exemplo n.º 46
0
 public static SQLiteDataReader GetUsedItems(Hunt h)
 {
     return ExecuteReaderQuery(String.Format("SELECT itemid, amount FROM {0}", h.GetWasteTableName()));
 }
Exemplo n.º 47
0
 public static void SetActiveHunt(Hunt h)
 {
     lock (hunts) {
         activeHunt = h;
     }
 }
Exemplo n.º 48
0
 public static void InsertMessage(Hunt hunt, int stamp, int hour, int minute, string message)
 {
     ExecuteNonQuery(String.Format("INSERT INTO \"{4}\" VALUES({0}, {1}, {2}, \"{3}\");", stamp, hour, minute, message.Replace("\"", "\\\""), hunt.GetTableName()));
 }
Exemplo n.º 49
0
 public static Creature GetHighestKillCreature(Hunt h)
 {
     return(h.GetHighestKillCreature());
 }
Exemplo n.º 50
0
 public static void CreateHuntTable(Hunt hunt)
 {
     ExecuteNonQuery(String.Format("CREATE TABLE IF NOT EXISTS \"{0}\"(day INTEGER, hour INTEGER, minute INTEGER, message STRING);", hunt.GetTableName()));
     ExecuteNonQuery(String.Format("CREATE TABLE IF NOT EXISTS \"{0}\"(itemid INTEGER, amount INTEGER);", hunt.GetWasteTableName()));
 }
Exemplo n.º 51
0
 public static void AddSkin(Hunt h, string message, Creature cr, Item item, int count, string timestamp)
 {
     h.AddSkin(message, cr, item, count, timestamp);
 }
Exemplo n.º 52
0
 public static void DeleteMessage(Hunt hunt, string msg, SQLiteTransaction transaction)
 {
     ExecuteNonQuery(String.Format("DELETE FROM \"{0}\" WHERE message=\"{1}\"", hunt.GetTableName(), msg.Replace("\"", "\\\"")));
 }
Exemplo n.º 53
0
 public static List <Tuple <Item, int> > GetUsedItems(Hunt hunt)
 {
     return(hunt.GetUsedItems());
 }
Exemplo n.º 54
0
 public static SQLiteDataReader GetHuntMessages(Hunt hunt)
 {
     return ExecuteReaderQuery(String.Format("SELECT message FROM \"{0}\" ORDER BY day, hour, minute;", hunt.GetTableName()));
 }
Exemplo n.º 55
0
        public static void ParseLootMessages(Hunt h, Dictionary <string, List <string> > newDrops, List <Tuple <Creature, List <Tuple <Item, int> >, string> > newItems, bool commit = true, bool switchHunt = false, bool addEverything = false)
        {
            SQLiteTransaction transaction = null;

            if (commit)
            {
                transaction = LootDatabaseManager.BeginTransaction();
            }

            int stamp = TimestampManager.getDayStamp();
            Dictionary <string, List <string> > itemDrops = addEverything ? new Dictionary <string, List <string> >() : globalMessages;
            bool skipDuplicateLoot = (ProcessManager.IsFlashClient() || !SettingsManager.getSettingBool("ScanInternalTabStructure")) && SettingsManager.getSettingBool("SkipDuplicateLoot");

            // now the big one: parse the log messages and check the dropped items
            foreach (KeyValuePair <string, List <string> > kvp in newDrops)
            {
                string        t        = kvp.Key;
                List <string> itemList = skipDuplicateLoot ? kvp.Value.Distinct().ToList() : kvp.Value;
                if (!itemDrops.ContainsKey(t))
                {
                    itemDrops.Add(t, new List <string>());
                }
                if (itemList.Count > itemDrops[t].Count)
                {
                    int hour   = int.Parse(t.Substring(0, 2));
                    int minute = int.Parse(t.Substring(3, 2));
                    foreach (string message in itemList)
                    {
                        if (!itemDrops[t].Contains(message))
                        {
                            // new log message, scan it for new items
                            Tuple <Creature, List <Tuple <Item, int> > > resultList = ParseLootMessage(message);
                            if (resultList == null)
                            {
                                continue;
                            }

                            Creature cr = resultList.Item1;

                            if (switchHunt && commit)
                            {
                                h = HuntManager.CheckTrackedHunts(h, resultList, t, message, stamp, hour, minute, transaction);
                            }

                            HuntManager.AddKillToHunt(h, resultList, t, message, stamp, hour, minute, transaction);
                            if (newItems != null && MainForm.fileWriter != null && SettingsManager.getSettingBool("AutomaticallyWriteLootToFile"))
                            {
                                MainForm.fileWriter.WriteLine(message);
                                MainForm.fileWriter.Flush();
                            }

                            if (newItems != null)
                            {
                                newItems.Add(new Tuple <Creature, List <Tuple <Item, int> >, string>(resultList.Item1, resultList.Item2, message));
                            }
                        }
                        else
                        {
                            itemDrops[t].Remove(message);
                        }
                    }
                    itemDrops[t] = itemList;
                }
            }
            if (transaction != null)
            {
                transaction.Commit();
            }
        }
Exemplo n.º 56
0
        public static void ParseLootMessages(Hunt h, Dictionary<string, List<string>> newDrops, List<Tuple<Creature, List<Tuple<Item, int>>>> newItems, bool commit = true, bool switchHunt = false, bool addEverything = false)
        {
            lock (HuntManager.hunts) {

                SQLiteTransaction transaction = null;
                if (commit) {
                    transaction = LootDatabaseManager.BeginTransaction();
                }

                int stamp = TimestampManager.getDayStamp();
                Dictionary<string, List<string>> itemDrops = addEverything ? new Dictionary<string, List<string>>() : globalMessages;
                // now the big one: parse the log messages and check the dropped items
                foreach (KeyValuePair<string, List<string>> kvp in newDrops) {
                    string t = kvp.Key;
                    List<string> itemList = kvp.Value;
                    if (!itemDrops.ContainsKey(t)) {
                        itemDrops.Add(t, new List<string>());
                    }
                    if (itemList.Count > itemDrops[t].Count) {
                        int hour = int.Parse(t.Substring(0, 2));
                        int minute = int.Parse(t.Substring(3, 2));
                        foreach (string message in itemList) {
                            if (!itemDrops[t].Contains(message)) {
                                // new log message, scan it for new items
                                Tuple<Creature, List<Tuple<Item, int>>> resultList = ParseLootMessage(message);
                                if (resultList == null) continue;

                                Creature cr = resultList.Item1;

                                if (switchHunt && commit) {
                                    foreach (Hunt potentialHunt in HuntManager.hunts) {
                                        if (potentialHunt.lootCreatures.Contains(cr.GetName(), StringComparer.OrdinalIgnoreCase)) {
                                            if (potentialHunt.sideHunt) {
                                                h = potentialHunt;
                                                HuntManager.activeHunt = potentialHunt;
                                            } else if (potentialHunt.aggregateHunt && potentialHunt != h) {
                                                HuntManager.AddKillToHunt(potentialHunt, resultList, t, message, stamp, hour, minute, transaction);
                                            }
                                        }
                                    }
                                }

                                HuntManager.AddKillToHunt(h, resultList, t, message, stamp, hour, minute, transaction);
                                if (MainForm.fileWriter != null && SettingsManager.getSettingBool("AutomaticallyWriteLootToFile")) {
                                    MainForm.fileWriter.WriteLine(message);
                                    MainForm.fileWriter.Flush();
                                }

                                if (newItems != null) {
                                    newItems.Add(resultList);
                                }
                            } else {
                                itemDrops[t].Remove(message);
                            }
                        }
                        itemDrops[t] = itemList;
                    }
                }
                if (transaction != null) {
                    transaction.Commit();
                }
            }
        }
Exemplo n.º 57
0
        public static void CreateHuntTable(Hunt hunt)
        {
            SQLiteCommand command = new SQLiteCommand(String.Format("CREATE TABLE IF NOT EXISTS \"{0}\"(day INTEGER, hour INTEGER, minute INTEGER, message STRING);", hunt.GetTableName()), lootConn);

            command.ExecuteNonQuery();
        }