Beispiel #1
0
 public static void NoSaveFilesFound()
 {
     Console.WriteLine("No save files found. Starting new game...");
     CMethods.SmartSleep(100);
     CMethods.PrintDivider();
     UnitManager.CreatePlayer();
 }
        public override void UseMagic(PlayableCharacter user, bool is_battle)
        {
            SpendMana(user);
            Unit target = user.CurrentTarget;

            Console.WriteLine($"{user.Name} is making a move!\n");
            Console.WriteLine($"{user.Name} is preparing to cast {SpellName}...");
            SoundManager.ability_cast.SmartPlay();
            CMethods.SmartSleep(750);

            if (target == user)
            {
                Console.WriteLine($"{user.Name} raises their stats using the power of {SpellName}!");
            }

            else
            {
                Console.WriteLine($"{user.Name} raises {target.Name}'s stats using the power of {SpellName}!");
            }

            SoundManager.buff_spell.SmartPlay();

            // We write to TempStats instead of the player's actual stats so that the changes will
            // not persist after battle
            target.TempStats[Stat] = (int)(target.TempStats[Stat] * (1 + IncreaseAmount));
        }
        public override void UseMagic(PlayableCharacter user, bool is_battle)
        {
            SpendMana(user);
            Unit   target = user.CurrentTarget;
            Random rng    = new Random();

            Console.WriteLine($"{user.Name} is making a move!\n");
            Console.WriteLine($"{user.Name} attempts to summon a powerful spell...");

            SoundManager.magic_attack.SmartPlay();
            CMethods.SmartSleep(750);

            int attack_damage = UnitManager.CalculateDamage(user, target, CEnums.DamageType.magical, spell_power: SpellPower);

            if (target.Evasion < rng.Next(0, 512))
            {
                SoundManager.enemy_hit.SmartPlay();
                target.HP -= attack_damage;
                Console.WriteLine($"{user.Name}'s attack connects with the {target.Name}, dealing {attack_damage} damage!");
            }

            else
            {
                SoundManager.attack_miss.SmartPlay();
                Console.WriteLine($"The {target.Name} narrowly dodges {user.Name}'s spell!");
            }
        }
        public static bool RunAway(Unit runner, List <Monster> monster_list)
        {
            Random rng = new Random();

            Console.WriteLine($"{runner.Name} is making a move!\n");
            Console.WriteLine($"Your party tries to make a run for it...");
            CMethods.SmartSleep(750);

            int chance;

            // Running has a 30% chance of success if the runner is paralyzed, regardless of
            if (runner.HasStatus(CEnums.Status.paralyzation))
            {
                chance = 30;
            }

            // Running has a 70% chance of success if the runner:
            //     1. Has a higher speed than the fastest monster, but a lower evasion than the most evasive monster
            //     2. Has a higher evasion than the most evasive monster, but a lower speed than the fastest monster
            else if ((runner.Speed > monster_list.Select(x => x.Speed).Max()) != (runner.Evasion > monster_list.Select(x => x.Evasion).Max()))
            {
                chance = 70;
            }

            // Running has an 90% chance of success if the runner is both:
            //    1. Faster than the fastest monster
            //    2. More evasive than the most evasive monster
            else if ((runner.Speed > monster_list.Select(x => x.Speed).Max()) && (runner.Evasion > monster_list.Select(x => x.Evasion).Max()))
            {
                chance = 90;
            }

            // In all other scenarios, running has a 50% chance to succeed
            else
            {
                chance = 50;
            }

            if (rng.Next(0, 100) < chance)
            {
                SoundManager.buff_spell.SmartPlay();
                Console.WriteLine("Your party managed to escape!");
                CMethods.PressAnyKeyToContinue();

                return(true);
            }

            else
            {
                SoundManager.debuff.SmartPlay();
                Console.WriteLine("Your party's escape attempt failed!");
                return(false);
            }
        }
        public override void UseMagic(PlayableCharacter user, bool is_battle)
        {
            SpendMana(user);
            Unit target = user.CurrentTarget;

            int total_heal;

            if (HealthIncreaseFlat < target.MaxHP * HealthIncreasePercent)
            {
                total_heal = (int)((target.MaxHP * HealthIncreasePercent) + user.Attributes[CEnums.PlayerAttribute.wisdom]);
            }

            else
            {
                total_heal = HealthIncreaseFlat + user.Attributes[CEnums.PlayerAttribute.wisdom];
            }

            target.HP += total_heal;
            target.FixAllStats();

            if (is_battle)
            {
                Console.WriteLine($"{user.Name} is making a move!\n");
                Console.WriteLine($"{user.Name} is preparing to cast {SpellName}...");

                SoundManager.ability_cast.SmartPlay();
                CMethods.SmartSleep(750);

                Console.WriteLine($"Using {SpellName}, {target.Name} is healed by {total_heal} HP!");
                SoundManager.magic_healing.SmartPlay();
            }

            else
            {
                CMethods.PrintDivider();

                Console.WriteLine($"Using {SpellName}, {target.Name} is healed by {total_heal} HP!");
                SoundManager.magic_healing.SmartPlay();
                CMethods.PressAnyKeyToContinue();

                CMethods.PrintDivider();
            }
        }
Beispiel #6
0
        public static void WouldYouLikeToSave()
        {
            while (true)
            {
                string yes_no = CMethods.SingleCharInput("Do you wish to save your progress? | [Y]es or [N]o: ").ToLower();

                if (CMethods.IsYesString(yes_no))
                {
                    Console.WriteLine("Saving...");
                    CMethods.SmartSleep(100);
                    SaveTheGame();
                    Console.WriteLine("Game has been saved!");
                    CMethods.PressAnyKeyToContinue();

                    return;
                }

                else if (CMethods.IsNoString(yes_no))
                {
                    return;
                }
            }
        }
        public static void BattleSystem(bool is_bossfight)
        {
            Random rng = new Random();

            TileManager.GetCellList();

            List <Monster> monster_list = new List <Monster>()
            {
                UnitManager.GenerateMonster()
            };
            List <PlayableCharacter> active_pcus = UnitManager.GetActivePCUs();

            turn_counter = 0;

            // 67% chance to add a second monster
            if (rng.Next(0, 100) > 33)
            {
                monster_list.Add(UnitManager.GenerateMonster());

                // 34% chance to add a third monster if a second monster was already added
                if (rng.Next(0, 100) > 66)
                {
                    monster_list.Add(UnitManager.GenerateMonster());
                }
            }

            if (is_bossfight)
            {
                Console.WriteLine($"The legendary {monster_list[0].Name} has awoken!");
                SoundManager.battle_music.PlayLooping();
            }

            else
            {
                if (monster_list.Count == 1)
                {
                    Console.WriteLine($"A {monster_list[0].Name} suddenly appeared out of nowhere!");
                }

                else if (monster_list.Count == 2)
                {
                    Console.WriteLine($"A {monster_list[0].Name} and 1 other monster suddenly appeared out of nowhere!");
                }

                else if (monster_list.Count > 2)
                {
                    Console.WriteLine($"A {monster_list[0].Name} and {monster_list.Count - 1} other monsters suddenly appeared out of nowhere!");
                }

                SoundManager.battle_music.PlayLooping();
            }

            CMethods.SmartSleep(1000);

            // Create a temporary copy of all of the player's stats. These copies are what will be modified in-battle by
            // spells, abilities, etc. so that they will return to normal after battle (although they in fact were never
            // touched to begin with)
            active_pcus.ForEach(x => x.SetTempStats());

            // While all active party members are alive, continue the battle
            while (monster_list.Any(x => x.HP > 0) && active_pcus.Any(x => x.HP > 0))
            {
                turn_counter++;

                List <Unit> speed_list = new List <Unit>();
                active_pcus.ForEach(x => speed_list.Add(x));
                monster_list.ForEach(x => speed_list.Add(x));

                // Display the stats for every battle participant
                DisplayBattleStats(active_pcus, monster_list);

                // Iterate through each active players
                foreach (PlayableCharacter character in UnitManager.GetAliveActivePCUs())
                {
                    if (0 < character.HP && character.HP <= character.MaxHP * 0.20)
                    {
                        Console.WriteLine($"Warning: {character.Name}'s HP is low, heal as soon as possible!");
                        SoundManager.health_low.SmartPlay();
                        CMethods.SmartSleep(1333);
                    }

                    character.PlayerChoice(monster_list);

                    if (character != UnitManager.GetAliveActivePCUs().Last())
                    {
                        CMethods.PrintDivider();
                    }
                }

                // Iterate through each unit in the battle from fastest to slowest
                foreach (Unit unit in speed_list)
                {
                    if (unit.IsAlive())
                    {
                        if (monster_list.All(x => x.HP <= 0) || active_pcus.All(x => x.HP <= 0))
                        {
                            break;
                        }

                        CMethods.PrintDivider();

                        // Leave the battle if the player runs away
                        if (unit is PlayableCharacter)
                        {
                            PlayableCharacter pcu = unit as PlayableCharacter;
                            if (pcu.PlayerExecuteMove(monster_list) == "ran")
                            {
                                return;
                            }
                        }

                        else if (unit is Monster)
                        {
                            Monster monster = unit as Monster;
                            monster.MonsterExecuteMove();
                        }
                    }

                    // If any unit died on this turn, set their health to 0 and set their status as 'dead'
                    foreach (Unit other_unit in speed_list)
                    {
                        if (other_unit is PlayableCharacter && other_unit.HP <= 0 && other_unit.IsAlive())
                        {
                            other_unit.FixAllStats();
                            CMethods.SmartSleep(250);
                            SoundManager.ally_death.SmartPlay();

                            Console.WriteLine($"\n{other_unit.Name} has fallen to the monsters!");
                        }

                        else if (other_unit is Monster && other_unit.HP <= 0 && other_unit.IsAlive())
                        {
                            other_unit.FixAllStats();
                            CMethods.SmartSleep(250);
                            SoundManager.enemy_death.SmartPlay();

                            Console.WriteLine($"\nThe {other_unit.Name} was defeated by your party!");
                        }
                    }

                    if (monster_list.Any(x => x.HP > 0) && unit.HP > 0)
                    {
                        CMethods.PressAnyKeyToContinue();
                    }
                }
            }

            // Determine the results of the battle and react accordingly
            AfterBattle(active_pcus, monster_list, is_bossfight);
        }
Beispiel #8
0
        public static void LoadTheGame()
        {
            // File.Exists(path);
            Console.WriteLine("Searching for existing save files...");
            CMethods.SmartSleep(100);

            if (!Directory.Exists(base_dir))
            {
                NoSaveFilesFound();
                return;
            }

            Dictionary <string, List <string> > save_files = new Dictionary <string, List <string> >();
            List <string> save_file_components             = new List <string>()
            {
                sav_gems,
                sav_equipment,
                sav_inventory,
                sav_boss_flags,
                sav_game_info,
                sav_dialogue_flags,
                sav_chests,
                sav_player,
                sav_solou,
                sav_chili,
                sav_chyme,
                sav_parsto,
                sav_adorine,
                sav_storm,
                sav_kaltoh
            };

            foreach (string path in Directory.GetDirectories(base_dir))
            {
                if (save_file_components.All(x => File.Exists($"{path}/{x}")))
                {
                    // ...then set the dictionary key equal to the newly-formatted save file names
                    string folder_name = path.Split('\\').Last();
                    save_files[folder_name] = save_file_components.Select(x => $"{base_dir}/{folder_name}/{x}").ToList();
                }
            }

            if (save_files.Count == 0)
            {
                NoSaveFilesFound();
                return;
            }

            CMethods.PrintDivider();
            Console.WriteLine($"Found {save_files.Count} existing save files: ");

            // Print the list of save files
            int counter = 0;

            foreach (string folder in save_files.Keys)
            {
                Console.WriteLine($"      [{counter + 1}] {folder}");
                counter++;
            }

            while (true)
            {
                string chosen = CMethods.FlexibleInput("Input [#] (or type [c]reate new): ", save_files.Count);

                try
                {
                    adventure_name = save_files.Keys.ToList()[int.Parse(chosen) - 1];
                }

                catch (Exception ex) when(ex is FormatException || ex is ArgumentOutOfRangeException)
                {
                    // Let the player create a new save file
                    if (chosen.StartsWith("c"))
                    {
                        CMethods.PrintDivider();
                        UnitManager.CreatePlayer();
                        return;
                    }

                    continue;
                }

                CMethods.PrintDivider();
                Console.WriteLine($"Loading Save File: '{adventure_name}'...");
                CMethods.SmartSleep(100);
                JSONDeserializer.DeserializeEverything();
                Console.WriteLine("Game loaded!");

                return;
            }
        }