예제 #1
0
        public static bool searchDlc(string dlcSearch, ref stdClassCSharp dlc, int indexDlc = -1)
        {
            bool response = false;

            stdClassCSharp dlcStd = stdClassCSharp.readJsonFile("dlcs.json");

            if (indexDlc >= 0)
            {
                dlc      = dlcStd[indexDlc];
                response = true;
            }
            else
            {
                for (int i = 0; i < dlcStd.toArray().Length; i++)
                {
                    if (dlcStd[i]["Titulo"].ToLower().Contains(dlcSearch.ToLower()) || dlcSearch.ToLower().Contains(dlcStd[i]["Titulo"].ToLower()))
                    {
                        response = true;
                        dlc.Add(dlcStd[i]);
                    }
                }
            }

            return(response);
        }
예제 #2
0
        /// <summary>
        /// Se encarga de buscar el nombre en la lista de updates disponibles
        /// </summary>
        /// <param name="updateSearch">Corresponde al texto con el titulo del update</param>
        /// <param name="indexUpdate"></param>
        /// <returns></returns>
        public static bool searchUpdate(string updateSearch, ref stdClassCSharp update, int indexUpdate = -1)
        {
            bool response = false;

            stdClassCSharp updatesStd = stdClassCSharp.readJsonFile("updates.json");

            if (indexUpdate >= 0)
            {
                update   = updatesStd[indexUpdate];
                response = true;
            }
            else
            {
                for (int i = 0; i < updatesStd.toArray().Length; i++)
                {
                    if (updatesStd[i]["Titulo"].ToLower().Contains(updateSearch.ToLower()))
                    {
                        response = true;
                        update.Add(updatesStd[i]);
                    }
                }
            }

            return(response);
        }
예제 #3
0
        /// <summary>
        /// Se encarga de buscar el nombre en la lista de juegos disponibles
        /// </summary>
        /// <param name="gameSearch">Corresponde al texto del juego</param>
        /// <param name="games">Parametro donde se guardará el juego encontrado</param>
        /// <returns>Regresa verdadero en caso de haber encontrado el juego</returns>
        public static bool searchGame(string gameSearch, ref stdClassCSharp games, int indexGame = -1)
        {
            bool response = false;

            stdClassCSharp gamesStd = stdClassCSharp.readJsonFile("games.json");

            if (indexGame >= 0)
            {
                games    = gamesStd[indexGame];
                response = true;
            }
            else
            {
                for (int i = 0; i < gamesStd.toArray().Length; i++)
                {
                    if (gamesStd[i]["Titulo"].ToLower().Contains(gameSearch.ToLower()))
                    {
                        response = true;
                        games.Add(gamesStd[i]);
                    }
                }
            }

            return(response);
        }
예제 #4
0
        /// <summary>
        /// Guarda los datos de juego desde un mensaje mp
        /// </summary>
        /// <param name="index">Determina el indice del juego a modificar, si es juego nuevo obtendrá -1</param>
        public static string guardarJuego(string messageGame, ref string anuncialo, int index = -1)
        {
            string         respuesta  = "Tu juego se ha agregado correctamente a la lista.";
            stdClassCSharp gamesStd   = stdClassCSharp.readJsonFile("games.json");
            stdClassCSharp updatesStd = stdClassCSharp.readJsonFile("updates.json");
            stdClassCSharp dlcStd     = stdClassCSharp.readJsonFile("dlcs.json");
            stdClassCSharp game       = new stdClassCSharp();
            stdClassCSharp update     = new stdClassCSharp();
            stdClassCSharp dlc        = new stdClassCSharp();
            stdClassCSharp gameActual = new stdClassCSharp();
            int            upateIndex = -1;
            int            dlcIndex   = -1;

            generaDatosJuego(messageGame, ref game, ref update, ref dlc);

            if (index >= 0)
            {
                respuesta = "Tu juego se ha editado correctamente";
                searchGame("", ref gameActual, index);
                if (gameActual["DlcIndex", TiposDevolver.Boleano])
                {
                    dlcIndex = gameActual["DlcIndex", TiposDevolver.Entero];
                }
                else if (gameActual["DlcIndexAnt", TiposDevolver.Boleano])
                {
                    dlcIndex = gameActual["DlcIndexAnt", TiposDevolver.Entero];
                }

                if (gameActual["UpdateIndex", TiposDevolver.Boleano])
                {
                    upateIndex = gameActual["UpdateIndex", TiposDevolver.Entero];
                }
                else if (gameActual["UpdateIndexAnt", TiposDevolver.Boleano])
                {
                    upateIndex = gameActual["UpdateIndex", TiposDevolver.Entero];
                }
            }

            gameActual = game;

            if (game["Titulo", TiposDevolver.Boleano] && game["Links", TiposDevolver.Boleano])
            {
                if (dlc["Links", TiposDevolver.Boleano])
                {
                    dlc["Titulo"]        = game["Titulo"];
                    dlc["ImagenJuego"]   = game["ImagenJuego"];
                    dlc["ImagenDiscord"] = game["ImagenDiscord"];
                    dlc["UploadBy"]      = game["UploadBy"];

                    if (dlcIndex >= 0)
                    {
                        dlcStd[dlcIndex]       = dlc;
                        gameActual["DlcIndex"] = dlcIndex;
                        if (gameActual["DlcIndexAnt", TiposDevolver.Boleano])
                        {
                            gameActual.Remove("DlcIndexAnt");
                        }
                    }
                    else
                    {
                        dlcStd.Add(dlc);
                        game["DlcIndex"] = dlcStd.toArray().Length - 1;
                    }
                }
                else if (dlcIndex >= 0)
                {
                    gameActual["DlcIndexAnt"] = dlcIndex;
                }
                if (update["Version", TiposDevolver.Boleano] && update["Links", TiposDevolver.Boleano])
                {
                    update["Titulo"]        = game["Titulo"];
                    update["ImagenJuego"]   = game["ImagenJuego"];
                    update["ImagenDiscord"] = game["ImagenDiscord"];
                    update["UploadBy"]      = game["UploadBy"];

                    if (upateIndex >= 0)
                    {
                        updatesStd[upateIndex]    = update;
                        gameActual["UpdateIndex"] = dlcIndex;
                        if (gameActual["UpdateIndexAnt", TiposDevolver.Boleano])
                        {
                            gameActual.Remove("UpdateIndexAnt");
                        }
                    }
                    else
                    {
                        updatesStd.Add(update);
                        game["UpdateIndex"] = updatesStd.toArray().Length - 1;
                    }
                }
                else if (update["Links", TiposDevolver.Boleano] && !dlc["Links", TiposDevolver.Boleano])
                {
                    if (upateIndex >= 0)
                    {
                        gameActual["UpdateIndexAnt"] = upateIndex;
                    }
                    dlc["Links"]         = update["Links"];
                    dlc["Peso"]          = update["Peso"];
                    dlc["Formato"]       = update["Formato"];
                    dlc["Titulo"]        = game["Titulo"];
                    dlc["ImagenJuego"]   = game["ImagenJuego"];
                    dlc["ImagenDiscord"] = game["ImagenDiscord"];
                    dlc["UploadBy"]      = game["UploadBy"];

                    if (dlcIndex >= 0)
                    {
                        dlcStd[dlcIndex]       = dlc;
                        gameActual["DlcIndex"] = dlcIndex;
                        if (gameActual["DlcIndexAnt", TiposDevolver.Boleano])
                        {
                            gameActual.Remove("DlcIndexAnt");
                        }
                    }
                    else
                    {
                        dlcStd.Add(dlc);
                        game["DlcIndex"] = dlcStd.toArray().Length - 1;
                    }
                }
                else if (upateIndex >= 0)
                {
                    gameActual["UpdateIndexAnt"] = upateIndex;
                }
                if (index < 0)
                {
                    gamesStd.Add(game);
                }
                else
                {
                    gamesStd[index] = game;
                }
                gamesStd.writeJsonFile("games.json");
                updatesStd.writeJsonFile("updates.json");
                dlcStd.writeJsonFile("dlcs.json");
                if (string.IsNullOrWhiteSpace(anuncialo) && index == -1)
                {
                    anuncialo = $"El juego {game["Titulo"]} ha sido agregado a mi lista de juegos solicitalo con el comando !game [juegoabuscar]";
                }
            }
            else
            {
                respuesta = "No capturaste titulo o links del juego.";
            }

            return(respuesta);
        }