Exemple #1
0
 public Round(Character pc, Character npc, ArenaModifier arenaModifier, BattleLog battleLog)
 {
     this.pc            = pc;
     this.npc           = npc;
     this.arenaModifier = arenaModifier;
     this.battleLog     = battleLog;
     dice = new Dice();
 }
Exemple #2
0
        internal void DoCombat()
        {
            Console.Clear();
            Character     opponent;
            Character     pc = player.PlayerCharacter;
            bool          characterIsAlive = true;
            bool          doCombat         = true;
            bool          fleeCombat       = false;
            Round         round;
            Random        rand = new Random();
            ConsoleKey    key;
            ArenaModifier arenaModifier_bad = new ArenaModifier(ArenaModifier.Affects.All)
            {
                AffectDescription = "It's very dusty!",
                Modifier          = -5,
                AffectTitle       = "Duststorm"
            };
            ArenaModifier arenaModifier_good = new ArenaModifier(ArenaModifier.Affects.All)
            {
                AffectDescription = "It's very loud but inspiring!",
                Modifier          = 5,
                AffectTitle       = "Cheering crowd"
            };
            ArenaModifier arenaModifier;


            while (characterIsAlive && doCombat)
            {
                opponent = CreateOpponent();

                Console.WriteLine($"Your opponent is {opponent.Name}");
                Console.WriteLine("Stats: \n" +
                                  $"Health: {opponent.Health}\n" +
                                  $"Strenght: {opponent.Strenght}\n" +
                                  $"Defence: {opponent.Defense}\n" +
                                  $"Initiative: {opponent.Initiative}");
                opponentIsAlive = true;
                Console.WriteLine("COMMENCE BATTLE!");

                if (showHelpFirstTime)
                {
                    Console.WriteLine("(You can flee a battle by pressing [F])");
                    showHelpFirstTime = false;
                }

                if (rand.Next(100) < 40)
                {
                    arenaModifier = arenaModifier_bad;
                }
                else
                {
                    arenaModifier = arenaModifier_good;
                }

                Console.ReadLine();
                Console.WriteLine($"{arenaModifier.AffectTitle} is affecting the arena! {arenaModifier.AffectDescription}\n" +
                                  $"Modifier: {arenaModifier.Modifier} to {arenaModifier.AffectsArena}");

                battleLog.AddToLog($"A battle begins between {pc.Name} and {opponent.Name}!");

                while (opponentIsAlive && characterIsAlive && !fleeCombat)
                {
                    round = new Round(pc, opponent, arenaModifier, battleLog);
                    round.BeginRound();

                    if (opponent.Health <= 0)
                    {
                        opponentIsAlive = false;
                    }

                    if (pc.Health <= 0)
                    {
                        characterIsAlive = false;
                    }

                    key        = Console.ReadKey(true).Key;
                    fleeCombat = key == ConsoleKey.F && opponentIsAlive && characterIsAlive;
                }

                if (fleeCombat)
                {
                    Console.WriteLine($"{pc.Name} shamefully fled the combat...");
                    battleLog.AddToLog($"{pc.Name} ran away from {opponent.Name}...");
                    doCombat = false;
                }

                if (!opponentIsAlive)
                {
                    Console.WriteLine("VICTORIUS!\n");
                    player.AddDefeatedOpponent((NonPlayerCharacter)opponent);
                    player.PlayerCharacter.Victories++;
                    Random r = new Random();

                    int coins = r.Next(1, 5);
                    Console.WriteLine($"You've earned {coins} coins for {pc.Name} victory over {opponent.Name}!");
                    player.Coins += coins;

                    battleLog.AddToLog($"{pc.Name} was victorius in battle against {opponent.Name}!");

                    doCombat = false;
                }

                if (!characterIsAlive)
                {
                    Console.WriteLine("DEFEAT!\n");
                    battleLog.AddToLog($"{pc.Name} was defeated by {opponent.Name} and only withered bones remains now...");

                    player.PlayerCharacter.IsDefeated = true;
                }
            }
        }