예제 #1
0
        public static object PrintListGetItem <T>(List <T> list, PrintFunc Print)
        {
            int count;

            while (true)
            {
                count = 0;
                foreach (var thing in list)
                {
                    Print(thing, count);
                    count++;
                }

                LineHelpers.PrintLine(count + ". Exit");
                LineHelpers.PrintLine("Type the number...");
                int choice = Convert.ToInt32(Console.ReadLine());


                // if some error here count -1
                if (choice < list.Count && choice > 0 || choice == 0 && list.Count > 0)
                {
                    return(list[choice]);
                }
                // this checks if the choice is the right number or if the count is zero if the choice is zero
                if (choice == list.Count || list.Count == 0 && choice == 0)
                {
                    return(null);
                }
            }
        }
예제 #2
0
        // Simple statement for game deletion on starting a new game
        public static bool DeleteSave()
        {
            if (String.IsNullOrEmpty(File.ReadAllText(LocalSavePath)))
            {
                return(true);
            }
            LineHelpers.PrintLine("Are you sure you want to delete your save?");
            LineHelpers.PrintLine("1. Yes");
            LineHelpers.PrintLine("2. No");

            var input = LineHelpers.ReadInputNumber(new int[] { 1, 2 });

            if (input == 1)
            {
                try
                {
                    File.WriteAllText(LocalSavePath, "");
                    LineHelpers.PrintLineWithContinue("Save game deleted...");
                    return(true);
                }
                catch
                {
                    LineHelpers.PrintLineWithContinue("Error, save was not deleted...");
                    return(false);
                }
            }
            else
            {
                LineHelpers.PrintLineWithContinue("Save was not deleted...");
                return(false);
            }
        }
예제 #3
0
        public static void Spell(object item, int count)
        {
            Spell spell = item as Spell;

            LineHelpers.PrintLine(count + ". " + spell.Name);
            LineHelpers.PrintLine("  Damage: " + spell.Damage);
            LineHelpers.PrintLine("  Cost: " + spell.Cost);
        }
예제 #4
0
        public static void Consumable(object item, int count)
        {
            Consumable consumable = item as Consumable;

            LineHelpers.PrintLine(count + ". " + consumable.Name);
            LineHelpers.PrintLine("  " + consumable.Description);
            LineHelpers.PrintLine("  Cost: " + consumable.Cost);
            LineHelpers.PrintLine("  Heal: " + consumable.HealAmount);
        }
예제 #5
0
        public static void Armor(object item, int count)
        {
            Armor armor = item as Armor;

            LineHelpers.PrintLine(count + ". " + armor.Name);
            LineHelpers.PrintLine("  " + armor.Description);
            LineHelpers.PrintLine("  Armor: " + armor.ArmorRating);
            LineHelpers.PrintLine("  Cost: " + armor.Cost);
        }
예제 #6
0
        // See ListHelpers for info on implementation
        public static void Weapon(object item, int count)
        {
            Weapon weapon = item as Weapon;

            LineHelpers.PrintLine(count + ". " + weapon.Name);
            LineHelpers.PrintLine("  " + weapon.Description);
            LineHelpers.PrintLine("  Cost: " + weapon.Cost);
            LineHelpers.PrintLine("  Damage: " + weapon.MinDamage + " to " + weapon.MaxDamage);
        }
예제 #7
0
        public static void SpellsInformation(object item, int count)
        {
            Spell spell = item as Spell;

            LineHelpers.PrintLine(count + ". " + spell.Name);
            LineHelpers.PrintLine("  " + spell.Description);
            LineHelpers.PrintLine("  Damage: " + spell.Damage);
            LineHelpers.PrintLine("  Cost: " + spell.Cost);
            LineHelpers.PrintLine("  Modifier: " + spell.Modifier);
        }
예제 #8
0
 // These are the save helpers they serialize an object and print it to a file
 // Upon load they read and unserialize the object and move it to a Model that will be used to init the character
 public static bool Save(Player player)
 {
     try
     {
         string jsonToSave = JsonConvert.SerializeObject(player);
         File.WriteAllText(LocalSavePath, jsonToSave);
         LineHelpers.PrintLineWithContinue("Game saved successfully... The game will now exit.");
         return(true);
     }
     catch (Exception ex)
     {
         LineHelpers.PrintLineWithContinue("Error Message: " + ex.ToString());
         LineHelpers.PrintLineWithContinue("\nFailed to save game please try again.");
         return(false);
     }
 }