예제 #1
0
        // Upon Auto Battle clicked, run a new Auto Battle
        // Return a score after the battle end.
        private async void AutoBattleButton_Command(object sender, EventArgs e)
        {
            // Can create a new battle engine...
            var myEngine = new AutoBattleEngine();

            var result = myEngine.RunAutoBattle();

            if (result == false)
            {
                await DisplayAlert("Error", "No Characters Available", "OK");

                return;
            }

            if (myEngine.GetRoundsValue() < 1)
            {
                await DisplayAlert("Error", "No Rounds Fought", "OK");

                return;
            }

            var myResult = myEngine.GetResultsOutput();
            var myScore  = myEngine.GetScoreValue();

            var outputString = "Battle Over! Score " + myScore.ToString();

            var action = await DisplayActionSheet(outputString, "Cancel", null, "View Score");

            if (action == "View Score")
            {
                var myScoreObject = myEngine.GetScoreObject();
                await Navigation.PushAsync(new Views.Scores.ScoreDetailPage(new ScoreDetailViewModel(myScoreObject)));
            }
        }
        public void AutoBattleEngine_GetRoundsValueAtStart_Should_Pass()
        {
            // Arrange
            var startBattle = new AutoBattleEngine();
            var Expected    = 0; // 0 because it is not defined yet

            // Act
            var Actual = startBattle.GetRoundsValue();

            // Reset

            // Assert
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
        // This unit test ensures round value of -1 should return default value
        // Which is 1
        // All battle has at least 1 round
        public void AutoBattleEngine_GetRoundsValue_0_Should_Default()
        {
            MockForms.Init();
            //arrange
            AutoBattleEngine test = new AutoBattleEngine();

            test.BattleEngine.BattleScore.RoundCount = 0;
            var Expected = 1; //default value

            var Actual = test.GetRoundsValue();

            //assert
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
예제 #4
0
        // Auto Battle Starts here when this button is clicked
        private async void AutoBattleButton_Command(object sender, EventArgs e)
        {
            // Can create a new battle engine...
            var myBattleEngine = new AutoBattleEngine();

            // run auto battle
            var result = myBattleEngine.RunAutoBattle();

            if (result == false)
            {
                await DisplayAlert("Error", "No Characters Available", "OK");

                return;
            }

            if (myBattleEngine.GetRoundsValue() < 1)
            {
                await DisplayAlert("Error", "No Rounds Fought", "OK");

                return;
            }

            // output results of the game after battle is over
            var myResult = myBattleEngine.GetResultsOutput();
            var myScore  = myBattleEngine.GetScoreValue();



            var outputString = "Mellow Fox Battle Over!";

            // the pop up for either cancel or see the score details
            var action = await DisplayActionSheet(outputString,
                                                  "Cancel",
                                                  null,
                                                  "View Score Results");

            // Show the results
            if (action == "View Score Results")
            {
                var myScoreObject = myBattleEngine.GetScoreObject();
                await Navigation.PushAsync(new GameOver(new ScoreDetailViewModel(myScoreObject)));
            }
        }