Example #1
0
        public bool FightInArena()
        {
            while (!Player.IsDead)                      // Exit arena if player dies
            {
                currentBattleNumber++;                  // increment battle number
                createOpponent();                      

                currentBattle = new Battle(Player, Opponent);  // creates Battle between player and current opponent
                currentBattle.DisplayContestants(Player, Opponent);  // prints player and opponent stats to console

                while (!Player.IsDead && !Opponent.IsDead)   // Continues playing battle rounds until player or opponent is dead
                {
                    currentBattle.FightRound();                     // battle rounds
                }

                logToArenaLog();                              // logs final battle stats to arena log

                if (Player.IsDead)                            // checks if player is dead before starting next battle with new opponent
                {
                    Console.WriteLine("\nYou have died.  You won {0} battles\n", Player.BattlesWon);
                    printArenaLog();                         // gives player option to print out Arena Log
                    Player.BattlesWon = 0;
                }
                else Player.BattlesWon++;                     // increments 'Battles Won' if player survived last battle

                if (!checkIfContinuePlaying(Player, currentBattle)) return false;   // check if Player wants to fight more battles in arena or quit game

                Console.Clear();
                Player.ResetPlayerStats();
                //return true;
            }
            return true;
        }
 public void TestRollIsValid()
 {
     Character pc = new Character();
     Character npc = new Character();
     Battle battle = new Battle(pc, npc);
     battle.FightRound();
     Assert.IsTrue(battle.CurrentRound.PlayerRoll <= 6 && battle.CurrentRound.PlayerRoll >= 1);
     Assert.IsTrue(battle.CurrentRound.OpponentRoll <= 6 && battle.CurrentRound.OpponentRoll >= 1);
 }
        public void TestDamageIsApplied()
        {
            Character pc = new Character("player", 10, 10);
            Character npc = new Character("opponent", 1, 10);

            Battle battle = new Battle(pc, npc);
            battle.FightRound();
            Assert.IsTrue(npc.Health < 10);
        }
        public void TestWinnerIsValid()
        {
            Character strongPC = new Character("strongPC", 10, 10);
            Character strongNPC = new Character("strongNPC", 10, 10);
            Character weakPC = new Character("weakPC", 1, 1);
            Character weakNPC = new Character("weakNPC", 1, 1);

            Battle playerWins = new Battle(strongPC, weakNPC);
            playerWins.FightRound();
            Assert.AreEqual(strongPC, playerWins.CurrentRound.Winner);

            Battle playerLoses = new Battle(weakPC, strongNPC);
            playerLoses.FightRound();
            Assert.AreEqual(strongNPC, playerLoses.CurrentRound.Winner);
        }
        public void TestDamageIsCorrect()
        {
            Character pc = new Character("player", 10, 10);
            Character npc = new Character("opponent", 1, 10);

            Battle battle = new Battle(pc, npc);
            battle.FightRound();
            Assert.AreEqual(10 - pc.Damage, npc.Health);
        }