Example #1
0
        //internal Dictionary<ulong, ulong> aetoliaChannelIds = new Dictionary<ulong, ulong>();

        internal override void StartModule()
        {
            if (!File.Exists(fishDbPath))
            {
                Program.WriteToLog($"No fish database found.");
            }
            else
            {
                List <string> uniqueFish = new List <string>();
                JArray        fishDb     = JArray.Parse(File.ReadAllText(fishDbPath));
                foreach (JToken fish in fishDb)
                {
                    FishingHole fishHole = new FishingHole(
                        fish["name"].ToString(),
                        fish["type"].ToString(),
                        fish["rooms"].ToObject <List <string> >(),
                        fish["fish"].ToObject <List <string> >()
                        );
                    fishingHoles.Add(fishHole);
                    fishHole.holeId = fishingHoles.Count.ToString();
                    foreach (string fishName in fishHole.containsFish)
                    {
                        if (!uniqueFish.Contains(fishName))
                        {
                            uniqueFish.Add(fishName);
                        }
                    }
                }
                Program.WriteToLog($"Associated {uniqueFish.Count} fish with {fishingHoles.Count} fishing holes. Done.");
            }
        }
Example #2
0
        private bool TryAddMatch(Dictionary <FishingHole, string> matches, FishingHole fishingHole, string fishy, string searchText)
        {
            int foundAt = fishy.ToLower().IndexOf(searchText);

            if (foundAt != -1)
            {
                if (!matches.ContainsKey(fishingHole))
                {
                    matches.Add(fishingHole, $"{fishy.Substring(0, foundAt)}**{fishy.Substring(foundAt, searchText.Length)}**{fishy.Substring(foundAt + searchText.Length)}");
                }
                return(true);
            }
            return(false);
        }
Example #3
0
        internal override void StartModule()
        {
            Console.WriteLine("Loading Aetolia fish database.");
            if (!File.Exists(fishDbPath))
            {
                Console.WriteLine($"No database found, creating an empty one at {fishDbPath}.");
                SQLiteConnection.CreateFile(fishDbPath);
            }
            SQLiteConnection fishDbConnection = new SQLiteConnection($"Data Source={fishDbPath};Version=3;");

            fishDbConnection.Open();

            List <string> uniqueFish = new List <string>();
            Dictionary <string, List <string> > tmpFish = new Dictionary <string, List <string> >();
            SQLiteCommand    command = new SQLiteCommand("SELECT * FROM fish_types;", fishDbConnection);
            SQLiteDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                string fishName = reader["fishName"].ToString();
                string holeName = reader["fishingHoleName"].ToString();

                if (!uniqueFish.Contains(fishName))
                {
                    uniqueFish.Add(fishName);
                }
                if (!tmpFish.ContainsKey(holeName))
                {
                    tmpFish.Add(holeName, new List <string>());
                }
                tmpFish[holeName].Add(fishName);
            }
            command = new SQLiteCommand("SELECT * FROM fishing_holes;", fishDbConnection);
            reader  = command.ExecuteReader();
            while (reader.Read())
            {
                string      holeName = reader["fishingHoleName"].ToString();
                string      holeType = reader["fishingHoleType"].ToString();
                string      holeVnum = reader["fishingHoleVnum"].ToString();
                FishingHole fishHole = new FishingHole(holeName, holeType, holeVnum, tmpFish[holeName]);
                fishingHoles.Add(fishHole);
                fishHole.holeId = fishingHoles.Count.ToString();
            }
            Console.WriteLine($"Associated {uniqueFish.Count} fish with {fishingHoles.Count} fishing holes. Done.");
        }