Ejemplo n.º 1
0
        public void NewPlayer()
        {
            existent = false;

            Name     = "STATIC";
            Age      = Random.Next(16, 24);
            LifeTime = 1;
            LongLife = 0;
            Race     = "humano";
            Class    = "";
            St       = 5;
            In       = 4;
            Rs       = 3;
            Cr       = 2;

            Crit = 1;

            cure     = false;
            fury     = false;
            meditate = false;
            vampire  = false;
            Hp       = new int[] { 24, 24 };
            Mana     = new int[] { 7, 7 };
            Xp       = new int[] { 0, 4 };

            Lvl = 1;

            bool   invalidName;
            string newName;
            Menu   CreatePlayerMenu = new Menu(5, true);

            do
            {
                Console.Clear();
                Boxy NameBoxy = new Boxy("Introduce el nombre de tu personaje", 2, 0, 5, true);
                newName = NameBoxy.ReadLine(20);
                NameBoxy.Erase();
                if (newName.Length <= 0)
                {
                    NameBoxy = new Boxy("Tienes que introducir un nombre ._.", 1, 0, 5, true);
                    Console.ReadKey();
                    invalidName = true;
                }
                else if (Program.SuccesfulConnection && SavedGames.CheckPlayerName(newName))
                {
                    NameBoxy = new Boxy("Ya existe una partida guardada con este nombre", 1, 0, 5, true);
                    Console.ReadKey();
                    invalidName = true;
                }
                else
                {
                    invalidName = false;
                }
            } while (invalidName);

            this.Name = newName;
            switch (CreatePlayerMenu.Read(new string[] { "ella", "él", "elle" }, "Con qué pronombre prefieres que se refieran a ti?", 20))
            {
            case 0:
                this.Gender = "f";
                break;

            case 1:
                this.Gender = "m";
                break;

            case 2:
                this.Gender = "n";
                break;
            }
            Console.Clear();

            this.Race = Program.Races.NewRace(this.Gender);

            Boxy Message = new Boxy(22, 0, true, BackStory());

            Console.ReadKey();
            Console.Clear();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            //while (1 < 2)
            //{
            //    Console.WriteLine(FantasyGen.Fantastic());
            //    Console.ReadKey();
            //}

            //Connection to database
            //INSERT HERE YOUR DATABASE PATH
            SavedGames.Connect("THIS-PC\\SQLEXPRESS");


            Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight);

            //Preset
            string msg = null;

            //Game Bucle
            while (1 < 2)
            {
                //First of all - Loading savedgames list
                List <Game> Games = new List <Game>();


                try
                {
                    Games = SavedGames.GetAll();
                    SuccesfulConnection = true;
                }
                catch
                {
                    Boxy dBError = new Boxy(22, 13, 0, true, "No se ha podido conectar con la base de datos. Las funciones de carga y de guardado no estarán disponibles");
                    Console.ReadKey();
                    Console.Clear();
                }

                //StartMenu - false load, true new Player
                if (StartMenu(Games))
                {
                    Inventory = new Inventory();
                    Gea       = new World();

                    //Creating new player
                    Player.NewPlayer();
                }

                //Once the player is created or loaded, we refresh the statics
                Mob          = new Mob(Gea.corruption);
                PlayerStatus = new PlayerStatus(15, 3);
                gameover     = false;

                //Gameplay
                while (!gameover)
                {
                    //Pre-turn
                    PlayerStatus.Refresh();

                    //Setting world corruption
                    if (!loot)
                    {
                        if (Random.Next(1, 4) == 4)
                        {
                            Gea.corruption++;
                        }
                    }
                    else
                    {
                        loot = false;
                        if (Random.Next(1, 4) <= 3)
                        {
                            Gea.corruption++;
                        }
                    }

                    //Setting starting turn msg
                    switch (lastAct)
                    {
                    case "born":
                        msg = "Amanece un hermoso día.";
                        break;

                    case "fight":
                        msg = "Menuda carnicería!";
                        break;

                    case "camp":
                        msg = "Amanece un hermoso día.";
                        break;

                    case "dialogue":
                        msg = "Menudo combate dialéctico!";
                        break;

                    case "runaway":
                        msg = "Por los pelos!";
                        break;
                    }


                    //Turn Itself
                    if (!Journey.Direction(msg))
                    {
                        gameover = true;
                    }
                    else
                    {
                        if (Encounter())
                        {
                            Combat();
                        }

                        Gea.months += Random.Next(1, 4);
                    }



                    //End of turn checkout


                    while (Gea.months >= 12)
                    {
                        Gea.months -= 12;
                        Gea.age++;
                        Player.Age++;
                    }
                }

                if (Player.Hp[0] <= 0)
                {
                    Console.Clear();
                    Graphics.Death(5);
                    SavedGames.DeleteCurrentGame();
                    Console.ReadKey();
                }

                Console.Clear();
            }
        }
Ejemplo n.º 3
0
        //true if new game, false if loaded
        static bool StartMenu(List <Game> Games)
        {
            Graphics.Title(1);
            Menu StartMenu = new Menu(12, true);
            bool exit      = false;
            bool output    = true;

            while (!exit)
            {
                StartMenu.Erase();
                switch (StartMenu.Read(new string[] { "Nueva partida", "Cargar Partida", "Salón de la Fama", "Conectar BDD local", "Salir" }, "Hola!", 18))
                {
                case 0:
                    exit   = true;
                    output = true;
                    break;

                case 1:
                    exit   = SavedGames.LoadMenu(Games);
                    output = false;
                    break;

                case 2:
                    Boxy noMsn = new Boxy(12, 0, true, "Esta función se encuentra en desarrollo");
                    Console.ReadKey();
                    noMsn.Erase();
                    break;

                case 3:
                    Boxy   NameBoxy = new Boxy("Introduce la dirección de la BDD (ejemplo 'THIS-PC\\SQLEXPRESS'", 2, 0, 5, true);
                    string url      = Console.ReadLine();
                    SavedGames.Connect(url);

                    try
                    {
                        Games = SavedGames.GetAll();
                        SuccesfulConnection = true;
                        Boxy dBError = new Boxy(22, 13, 0, true, "Conectado a la base de datos con éxito!");
                        Console.ReadKey();
                        dBError.Erase();
                    }
                    catch
                    {
                        Boxy dBError = new Boxy(22, 13, 0, true, "No se ha podido conectar con la base de datos. Las funciones de carga y de guardado no estarán disponibles");
                        Console.ReadKey();
                        Console.Clear();
                        dBError.Erase();
                    }

                    NameBoxy.Erase();
                    break;

                case 4:
                    Console.Clear();
                    Boxy thanks = new Boxy(12, 0, true, "Gracias por jugar :')");
                    Console.ReadKey();
                    Environment.Exit(0);
                    break;
                }
            }

            Console.Clear();
            return(output);
        }
Ejemplo n.º 4
0
        //TRue if game keeps going, false if returning to main menu
        public bool Direction(string txt)
        {
            Menu DirectionMenu = new Menu(3, true);

            switch (DirectionMenu.Read(new string[] { "Norte", "Sur", "Este", "Oeste", "(Guardar y salir)" }, $"{txt}¿Hacia dónde quieres ir?", 20))
            {
            case 0:
                DirectionMenu.Erase();
                Boxy Northy = new Boxy("Te diriges hacia el Norte...", 1, 0, 5, true);
                Console.ReadKey();
                Northy.Erase();
                return(true);

                break;

            case 1:
                DirectionMenu.Erase();
                Boxy Southy = new Boxy("Te diriges hacia el Sur...", 1, 0, 5, true);
                Console.ReadKey();
                Southy.Erase();
                return(true);

                break;

            case 2:
                DirectionMenu.Erase();
                Boxy Easty = new Boxy("Te diriges hacia el Este...", 1, 0, 5, true);
                Console.ReadKey();
                Easty.Erase();
                return(true);

                break;

            case 3:
                DirectionMenu.Erase();
                Boxy Westy = new Boxy("Te diriges hacia el Oeste...", 1, 0, 5, true);
                Console.ReadKey();
                Westy.Erase();
                return(true);

                break;

            case 4:
                //Save and Go
                if (Program.SuccesfulConnection)
                {
                    if (!Program.Player.existent)
                    {
                        SavedGames.SaveNew();
                        Boxy Save = new Boxy("Se ha guardado una nueva partida", 1, 0, 5, true);
                        Console.ReadKey();
                        Console.Clear();
                        return(false);
                    }
                    else
                    {
                        SavedGames.Rewrite();
                        Boxy Rewrite = new Boxy("Se han sobreescrito los datos guardados", 1, 0, 5, true);
                        Console.ReadKey();
                        Console.Clear();
                        return(false);
                    }
                }
                else
                {
                    System.Threading.Thread.Sleep(2000);
                    Boxy Rewrite = new Boxy("No se ha podido conectar con la base de datos :S", 1, 0, 5, true);
                    Console.ReadKey();
                    Console.Clear();
                    return(true);
                }
                break;
            }

            return(false);
        }