CreateHuntTable() public static method

public static CreateHuntTable ( Hunt hunt ) : void
hunt Hunt
return void
Beispiel #1
0
 public static void resetHunt(Hunt h)
 {
     h.Reset();
     LootDatabaseManager.DeleteHuntTable(h);
     LootDatabaseManager.CreateHuntTable(h);
     LootDatabaseManager.UpdateLoot();
 }
Beispiel #2
0
 public static void resetHunt(Hunt h)
 {
     lock (hunts) {
         h.loot.creatureLoot.Clear();
         h.loot.killCount.Clear();
         h.loot.logMessages.Clear();
         h.totalExp  = 0;
         h.totalTime = 0;
     }
     LootDatabaseManager.DeleteHuntTable(h);
     LootDatabaseManager.CreateHuntTable(h);
     LootDatabaseManager.UpdateLoot();
 }
Beispiel #3
0
        public static void Initialize()
        {
            //"Name#DBTableID#Track#Time#Exp#SideHunt#AggregateHunt#ClearOnStartup#Creature#Creature#..."
            if (!SettingsManager.settingExists("Hunts"))
            {
                SettingsManager.setSetting("Hunts", new List <string>()
                {
                    "New Hunt#True#0#0#False#True"
                });
            }
            hunts.Clear();
            int        activeHuntIndex = 0, index = 0;
            List <int> dbTableIds = new List <int>();

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

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

                    refreshLootCreatures(hunt);

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

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

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

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