Exemple #1
0
 public CityServices(CharacterSuperModel characterSuperModel, ExploringServices exploringServices)
 {
     _characterSuperModel = characterSuperModel;
     _exploringServices   = exploringServices;
     _inventoryServices   = new InventoryServices(_characterSuperModel);
     _shopEquipmentList   = _inventoryServices.GetEquipment();
     _combatService       = new CombatService(_characterSuperModel);
 }
Exemple #2
0
        public CharacterSuperModel EncounterFight(CharacterSuperModel characterSuperModel)
        {
            _characterSuperModel = characterSuperModel;
            List <NPCS> NpcList     = _nPCS.GetNPCS();
            int         IDLOOKUP    = (_characterSuperModel.CharacterLevel);
            int         RandomNPCID = rnd.Next(1, (IDLOOKUP / 2) + 1);

            LookupFightByNPCID(RandomNPCID);

            Fight(_characterSuperModel, currentFlight);

            return(_characterSuperModel);
        }
Exemple #3
0
        public CharacterSuperModel ArenaFight(CharacterSuperModel characterSuperModel)
        {
            _characterSuperModel = characterSuperModel;
            _NpcList             = _nPCS.GetNPCS();

            int IDLOOKUP = ((_characterSuperModel.ArenaWins) + 15);

            if (IDLOOKUP < 21)
            {
                LookupFightByNPCID(IDLOOKUP);
                Fight(_characterSuperModel, currentFlight);
            }
            return(_characterSuperModel);
        }
Exemple #4
0
        private void Play(CharacterSuperModel character)
        {
            characterSuperModel = character;
            var counter = 0;

            if (character.CurrentLocation == "city")
            {
                counter = 1;
            }
            var keepPlaying = true;

            exploringServices = new ExploringServices(rand, characterSuperModel);
            while (keepPlaying)
            {
                keepPlaying = SetLocation(counter);
                counter    += 3;
            }
        }
Exemple #5
0
        private void LearnAttacks(CharacterSuperModel character, string guildName)
        {
            var invService  = new InventoryServices();
            var attackList  = invService.GetAttacks();
            var count       = 0;
            var correctType = AtkType.Melee;

            switch (guildName)
            {
            case "Melee":
                correctType = AtkType.Melee;
                break;

            case "Ranged":
                correctType = AtkType.Ranged;
                break;

            case "Mage":
                correctType = AtkType.Mage;
                break;
            }
            foreach (Attacks attack in attackList)
            {
                if (attack.LVToUSE <= character.CharacterLevel && attack.TypeOfAtk == correctType && (_characterSuperModel.CharacterAttacks.FirstOrDefault(a => a.ATKID == attack.ATKID) == null))
                {
                    count++;
                    character.CharacterAttacks.Add(attack);
                }
            }
            if (count != 0)
            {
                var s = "";
                if (count != 1)
                {
                    s = "s";
                }
                Console.WriteLine($"You learned {count} new attack{s}");
            }
            else
            {
                Console.WriteLine($"You are not ready to learn any new attacks yet. You can learn a new attack every 5th level.");
            }
            Console.ReadKey();
        }
Exemple #6
0
        public void SaveGame(CharacterSuperModel superModel)
        {
            StreamWriter characterFile = new StreamWriter($"./Files/Saves/Game{superModel.CharacterID}.txt");

            characterFile.Write($"CharacterID: {superModel.CharacterID},");
            characterFile.Write($"CharacterName: {superModel.CharacterName},");
            characterFile.Write($"CurrentLocation: {superModel.CurrentLocation},");
            characterFile.Write($"CharacterBaseHealth: {superModel.CharacterBaseHealth},");
            characterFile.Write($"CharacterMaxHealth: {superModel.CharacterMaxHealth},");
            characterFile.Write($"CharacterHealth: {superModel.CharacterHealth},");
            characterFile.Write($"PotionCount: {superModel.PotionCount},");
            characterFile.Write($"Gold: {superModel.Gold},");
            characterFile.Write($"CharacterLevel: {superModel.CharacterLevel},");
            characterFile.Write($"CombatStyle: {superModel.CombatStyle},");
            characterFile.Write($"IsDead: {superModel.IsDead},");

            var itemIDList = "";

            superModel.CharacterEquipment = superModel.CharacterEquipment.OrderBy(i => i.GearID).ToList();
            foreach (Equipment item in superModel.CharacterEquipment)
            {
                itemIDList += $"{item.GearID};";
            }
            characterFile.Write($"CharacterItems: {itemIDList},");

            var attackIDList = "";

            superModel.CharacterAttacks = superModel.CharacterAttacks.OrderBy(i => i.ATKID).ToList();
            foreach (Attacks attack in superModel.CharacterAttacks)
            {
                attackIDList += $"{attack.ATKID};";
            }
            characterFile.Write($"CharacterAttacks: {attackIDList},");

            characterFile.Close();
            UpdateSettings();
        }
Exemple #7
0
        private void Fight(CharacterSuperModel u, NPCS enemy)
        {
            CharacterSuperModel CurrentStatus = u;
            NPCS EnemyCurrentStatus           = enemy;
            int  yourATK = 0;

            while (CurrentStatus.CharacterHealth > 0 && EnemyCurrentStatus.HP > 0)
            {
Repeat:
                GameService.NewPage($"\n{EnemyCurrentStatus.NPCName}\n" +
                                    $"Hp:{EnemyCurrentStatus.HP}/{enemy.HP}\n\n\n\n\n" +
                                    $"{CurrentStatus.CharacterName}\n" +
                                    $"Hp: {CurrentStatus.CharacterHealth}/{CurrentStatus.CharacterMaxHealth}\n" +
                                    "[1. Attack]\n" +
                                    "[2. Drink Hp Pot]: " + (CurrentStatus.PotionCount) + " Remaining \n" +
                                    "[3. Run]\n"
                                    , "battle");
                char response = Console.ReadKey().KeyChar;

                switch (response)
                {
                case '1':
                {
                    EnemyCurrentStatus.HP -= YourAtkResult(DisplayAndPickAtkOptions(_characterSuperModel.CharacterAttacks).DMG);
                    break;
                }

                case '2':
                {
                    if (CurrentStatus.PotionCount > 0)
                    {
                        CurrentStatus.PotionCount--;
                        if (CurrentStatus.CharacterHealth != CurrentStatus.CharacterMaxHealth)
                        {
                            if ((CurrentStatus.CharacterHealth + 10) <= CurrentStatus.CharacterMaxHealth)
                            {
                                CurrentStatus.CharacterHealth += 10;
                            }
                            else
                            {
                                CurrentStatus.CharacterHealth = CurrentStatus.CharacterMaxHealth;
                            }
                            Console.WriteLine("You Feel Better.");
                        }
                        else
                        {
                            Console.WriteLine("You're already at max health.");
                            goto Repeat;
                        }
                        Console.ReadLine();
                    }
                    else
                    {
                        Console.WriteLine("You are out of Potions!");
                        Console.ReadLine();
                        goto Repeat;
                    }
                    break;
                }

                case '3':
                {
                    Console.WriteLine("You Ran...");
                    Console.ReadLine();
                    goto EndFight;
                }

                default:
                {
                    goto Repeat;
                }
                }
                if (enemy.HP >= 1)
                {
                    EnemyAtk(enemy.ATK);
                }
            }
            if (_characterSuperModel.CharacterHealth > 0)
            {
                _characterSuperModel.CharacterLevel++;
                _characterSuperModel.CharacterBaseHealth += 2;
                _characterSuperModel.CharacterMaxHealth  += 2;
                _characterSuperModel.CharacterHealth      = _characterSuperModel.CharacterMaxHealth;
                _characterSuperModel.Gold += ((enemy.ATK) * 2);
            }
            else
            {
                _characterSuperModel.IsDead = true;
            }
            EndFight :;
        }
Exemple #8
0
 public CombatService(CharacterSuperModel character)
 {
     _EquipmentList = character.CharacterEquipment;
     _AttackList    = character.CharacterAttacks;
 }
 public ExploringServices(Random rand, CharacterSuperModel characterSuperModel)
 {
     _rand = rand;
     _characterSuperModel = characterSuperModel;
     _combatService       = new CombatService(_characterSuperModel);
 }
 public VillageServices(CharacterSuperModel characterSuperModel, ExploringServices exploringServices)
 {
     _characterSuperModel = characterSuperModel;
     _exploringServices   = exploringServices;
     _inventoryServices   = new InventoryServices(_characterSuperModel);
 }
Exemple #11
0
 public static string GetCharacterStats(CharacterSuperModel currentCharacter)
 {
     return($"You are currently Level {currentCharacter.CharacterLevel}.\n" +
            $"You have {currentCharacter.CharacterHealth}/{currentCharacter.CharacterMaxHealth} HP and have {currentCharacter.Gold} Gold.\n" +
            $"You are currently focusing on {currentCharacter.CombatStyle} styled combat.");
 }
Exemple #12
0
        private void CreateNewGame()
        {
            NewPage("\nWhat's your name?", "newGame");
            string    newName;
            StyleType newCombatStyle = StyleType.Melee;

            while (true)
            {
                newName = Console.ReadLine();
                if (newName != "" && !newName.Contains(","))
                {
                    break;
                }
                else
                {
                    Console.Write("Enter valid name: ");
                }
            }

            PrintFirstStylePicker();
            var pickingStyle = true;

            while (pickingStyle)
            {
                pickingStyle = false;
                switch (ParseIntput())
                {
                case 1:
                    newCombatStyle = StyleType.Melee;
                    break;

                case 2:
                    newCombatStyle = StyleType.Ranged;
                    break;

                case 3:
                    newCombatStyle = StyleType.Mage;
                    break;

                default:
                    pickingStyle = true;
                    Console.Write("Invalid Input: ");
                    break;
                }
            }

            SaveServices.SaveGames++;
            characterSuperModel = new CharacterSuperModel
            {
                CharacterID         = SaveServices.SaveGames,
                CharacterName       = newName,
                CharacterLevel      = 1,
                CharacterBaseHealth = 10,
                CharacterHealth     = 10,
                CharacterMaxHealth  = 10,
                PotionCount         = 1,
                CombatStyle         = newCombatStyle,
            };
            characterSuperModel.CharacterAttacks.Add(new Attacks()
            {
                ATKID = 1, ATKName = "Pierce", TypeOfAtk = AtkType.Melee, DMG = 3, LVToUSE = 1
            });
            characterSuperModel.CharacterAttacks.Add(new Attacks()
            {
                ATKID = 11, ATKName = "Volley", TypeOfAtk = AtkType.Ranged, DMG = 3, LVToUSE = 1
            });
            characterSuperModel.CharacterAttacks.Add(new Attacks()
            {
                ATKID = 21, ATKName = "Mystic Shot", TypeOfAtk = AtkType.Mage, DMG = 3, LVToUSE = 1
            });

            FirstTimeStart(newName);
            saveServices.SaveGame(characterSuperModel);
            Play(characterSuperModel);
        }
 public InventoryServices(CharacterSuperModel superModel)
 {
     _characterSuperModel = superModel;
 }
Exemple #14
0
        public CharacterSuperModel LoadSave(int saveID)
        {
            var loadedSuperModel = new CharacterSuperModel();

            CreateDirectories();
            for (int i = 1; i <= SaveGames; i++)
            {
                loadedSuperModel = new CharacterSuperModel();
                if (File.Exists($"./Files/Saves/Game{i}.txt"))
                {
                    string   saveGameTraits = File.ReadAllText($"./Files/Saves/Game{i}.txt");
                    string[] loadedTraits   = saveGameTraits.Split(',');

                    foreach (string trait in loadedTraits)
                    {
                        if (trait.Contains("CharacterID:"))
                        {
                            var loadID = trait.Substring(trait.IndexOf(' ') + 1);
                            loadedSuperModel.CharacterID = int.Parse(loadID);
                        }
                        else if (trait.Contains("IsDead:"))
                        {
                            var loadIsDead = trait.Substring(trait.IndexOf(' ') + 1);
                            if (loadIsDead == "False")
                            {
                                loadedSuperModel.IsDead = false;
                            }
                            else if (loadIsDead == "True")
                            {
                                loadedSuperModel.IsDead = true;
                            }
                        }
                        else if (trait.Contains("CharacterName:"))
                        {
                            var loadCharacterName = trait.Substring(trait.IndexOf(' ') + 1);
                            loadedSuperModel.CharacterName = loadCharacterName;
                        }
                        else if (trait.Contains("CurrentLocation:"))
                        {
                            var loadCharacterLocation = trait.Substring(trait.IndexOf(' ') + 1);
                            loadedSuperModel.CurrentLocation = loadCharacterLocation;
                        }
                        else if (trait.Contains("CharacterBaseHealth:"))
                        {
                            var loadBaseHealth = trait.Substring(trait.IndexOf(' ') + 1);
                            loadedSuperModel.CharacterBaseHealth = int.Parse(loadBaseHealth);
                        }
                        else if (trait.Contains("CharacterMaxHealth:"))
                        {
                            var loadMaxHealth = trait.Substring(trait.IndexOf(' ') + 1);
                            loadedSuperModel.CharacterMaxHealth = int.Parse(loadMaxHealth);
                        }
                        else if (trait.Contains("CharacterHealth:"))
                        {
                            var loadHealth = trait.Substring(trait.IndexOf(' ') + 1);
                            loadedSuperModel.CharacterHealth = int.Parse(loadHealth);
                        }
                        else if (trait.Contains("CharacterLevel:"))
                        {
                            var loadLevel = trait.Substring(trait.IndexOf(' ') + 1);
                            loadedSuperModel.CharacterLevel = int.Parse(loadLevel);
                        }
                        else if (trait.Contains("PotionCount:"))
                        {
                            var loadPotionCount = trait.Substring(trait.IndexOf(' ') + 1);
                            loadedSuperModel.PotionCount = int.Parse(loadPotionCount);
                        }
                        else if (trait.Contains("Gold:"))
                        {
                            var loadGold = trait.Substring(trait.IndexOf(' ') + 1);
                            loadedSuperModel.Gold = int.Parse(loadGold);
                        }
                        else if (trait.Contains("CombatStyle:"))
                        {
                            var loadCombatStyle = trait.Substring(trait.IndexOf(' ') + 1);
                            switch (loadCombatStyle.ToLower())
                            {
                            case "melee":
                                loadedSuperModel.CombatStyle = StyleType.Melee;
                                break;

                            case "ranged":
                                loadedSuperModel.CombatStyle = StyleType.Ranged;
                                break;

                            case "mage":
                                loadedSuperModel.CombatStyle = StyleType.Mage;
                                break;

                            default:
                                loadedSuperModel.CombatStyle = StyleType.Melee;
                                break;
                            }
                        }
                        else if (trait.Contains("CharacterItems:"))
                        {
                            var invService = new InventoryServices();
                            var getItems   = invService.GetEquipment();

                            var      loadItemString = trait.Substring(trait.IndexOf(' ') + 1);
                            string[] loadedItemIDs  = loadItemString.Split(';');

                            foreach (string itemID in loadedItemIDs)
                            {
                                if (itemID != "")
                                {
                                    var newItem = getItems.FirstOrDefault(l => l.GearID == int.Parse(itemID));
                                    loadedSuperModel.CharacterEquipment.Add(newItem);
                                }
                            }
                        }
                        else if (trait.Contains("CharacterAttacks:"))
                        {
                            var invService = new InventoryServices();
                            var getATtacks = invService.GetAttacks();

                            var      loadAttacksString = trait.Substring(trait.IndexOf(' ') + 1);
                            string[] loadedAttackIDs   = loadAttacksString.Split(';');

                            foreach (var attackID in loadedAttackIDs)
                            {
                                if (attackID != "")
                                {
                                    var newAttack = getATtacks.FirstOrDefault(l => l.ATKID == int.Parse(attackID));
                                    loadedSuperModel.CharacterAttacks.Add(newAttack);
                                }
                            }
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Game files corrupt");
                }
                if (i == saveID)
                {
                    return(loadedSuperModel);
                }
            }

            return(loadedSuperModel);
        }
Exemple #15
0
        public void PrintSaves()
        {
            CharacterSuperModel loadedSuperModel = new CharacterSuperModel();

            CreateDirectories();
            for (int i = 1; i <= SaveGames; i++)
            {
                if (File.Exists($"./Files/Saves/Game{i}.txt"))
                {
                    string   saveGameTraits = File.ReadAllText($"./Files/Saves/Game{i}.txt");
                    string[] loadedTraits   = saveGameTraits.Split(',');

                    foreach (string trait in loadedTraits)
                    {
                        if (trait.Contains("CharacterID:"))
                        {
                            var loadID = trait.Substring(trait.IndexOf(' ') + 1);
                            loadedSuperModel.CharacterID = int.Parse(loadID);
                        }
                        else if (trait.Contains("CharacterName:"))
                        {
                            var loadCharacterName = trait.Substring(trait.IndexOf(' ') + 1);
                            loadedSuperModel.CharacterName = loadCharacterName;
                        }
                        else if (trait.Contains("CharacterLevel:"))
                        {
                            var loadCharacterLevel = trait.Substring(trait.IndexOf(' ') + 1);
                            loadedSuperModel.CharacterLevel = int.Parse(loadCharacterLevel);
                        }
                        else if (trait.Contains("CurrentLocation:"))
                        {
                            var loadCharacterLocation = trait.Substring(trait.IndexOf(' ') + 1);
                            loadedSuperModel.CurrentLocation = loadCharacterLocation;
                        }
                        else if (trait.Contains("CombatStyle:"))
                        {
                            var loadCombatStyle = trait.Substring(trait.IndexOf(' ') + 1);
                            switch (loadCombatStyle.ToLower())
                            {
                            case "melee":
                                loadedSuperModel.CombatStyle = StyleType.Melee;
                                break;

                            case "ranged":
                                loadedSuperModel.CombatStyle = StyleType.Ranged;
                                break;

                            case "mage":
                                loadedSuperModel.CombatStyle = StyleType.Mage;
                                break;

                            default:
                                loadedSuperModel.CombatStyle = StyleType.Melee;
                                break;
                            }
                        }
                    }
                    Console.WriteLine($"{loadedSuperModel.CharacterID}) {loadedSuperModel.CharacterName}, a level {loadedSuperModel.CharacterLevel} practicing {loadedSuperModel.CombatStyle} currently in the {loadedSuperModel.CurrentLocation}.");
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    Console.WriteLine($"{i}) Error loading save file.");
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
            }
            Console.WriteLine($"{SaveGames + 1}) Return to Menu");
        }