Пример #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)));
            }
        }
Пример #2
0
        // When this button is clicked, run auto battle and return results
        private async void AutoBattleButton_Command(object sender, EventArgs e)
        {
            // Can create a new battle engine...
            var myBattleEngine = new AutoBattleEngine();

            await DisplayAlert("Starting autobattle...", null, "Continue");

            // Start AutoBattle
            myBattleEngine.RunAutoBattle();

            // Display result of AutoBattle
            await DisplayAlert(null, myBattleEngine.GetResultOutput(), null, "Next");

            // String to hold score.
            var outputString = "Score: " + myBattleEngine.GetScoreValue();

            // Show player their score, and allow option to view more details.
            var action = await DisplayActionSheet(outputString, "Cancel", null, "View Score");

            // If user wants to view more score details, take them there.
            if (action == "View Score")
            {
                await Navigation.PushAsync(new ScoreDetailPage(new ScoreDetailViewModel(myBattleEngine.GetScoreObject())));
            }
        }
Пример #3
0
        public void AutoBattleEngine_GetScoreValue_Should_Pass()
        {
            var myEngine = new AutoBattleEngine();
            // No score is expected
            var Expected = 0;

            // Get score
            var Actual = myEngine.GetScoreValue();

            // Assert
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
        public void AutoBattleEngine_GetScoreValueAtStart_Should_Pass()
        {
            // Arrange (Initiate a new Auto Battle)
            var startBattle = new AutoBattleEngine();
            var Expected    = 0; // 0 is the Expected score, because game just started)

            // Act (Actual score of the battle)
            var Actual = startBattle.GetScoreValue();

            // Reset

            // Assert (Should return 0)
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Пример #5
0
        public void AutoBattleEngine_GetScoreObject_Should_Pass()
        {
            // Arrange
            var myEngine = new AutoBattleEngine();
            var Expected = 0;   // 1 because it is not defined yet

            // Act
            var Actual = myEngine.GetScoreValue();

            // Reset

            // Assert
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
        // This ensures the GetScoreValue returns a valid int
        // Any value equal or larger than 0 is acceptable
        public void AutoBattleEngine_GetScoreValue_0_Should_Pass()
        {
            MockForms.Init();
            //arrange
            AutoBattleEngine test = new AutoBattleEngine();

            test.BattleEngine.BattleScore.ScoreTotal = 0;

            var Expected = 0;

            var Actual = test.GetScoreValue();

            //assert
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Пример #7
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)));
            }
        }
Пример #8
0
        // Button Logic for AutoBattle page.
        private async void AutoBattleButton_Command(object sender, EventArgs e)
        {
            // Hold the score property to give to the score navigation later
            Score myScoreObject = new Score();

            // Can create a new battle engine...
            var myEngine = new AutoBattleEngine();


            //await Task.Run(async () =>
            //{
            var result = myEngine.ExecuteAutoBattle();

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

                return;
            }

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

                return;
            }

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

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

            myScoreObject = myEngine.GetScoreObject();
            // });

            await Navigation.PushAsync(new ScoreDetailPage(new ScoreDetailViewModel(myScoreObject)));
        }