Exemplo n.º 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;
        }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
		public void TestBattleIsValid() {
            Character pc = new Character();
            Character npc = new Character();
            Battle battle = new Battle(pc, npc);
            
            Assert.IsNotNull(battle);
            Assert.AreEqual(pc, battle.Player);
            Assert.AreEqual(npc, battle.Opponent);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 public bool checkIfContinuePlaying(Character pc, Battle battle)
 {
     Console.Write("\n\n C - Continue Playing or Q - quit ");              // check if player wants to play again or quit
     string reply = Console.ReadLine().ToLower();
     if (reply == "q")
     {
         if (!pc.IsDead)
         {
             Console.ForegroundColor = ConsoleColor.Green;
             Console.WriteLine("\nYou leave the arena Alive!  You won a total of {0} Battles\n", pc.BattlesWon);
             Console.ResetColor();
             printArenaLog();
             Console.ReadLine();
         }
         Console.Clear();
         return false;
     }
     return true;
 }