示例#1
0
        public void TestQuestSponsoring()
        {
            QuestMatch game = ScenarioCreator.GameNoDeal(2);

            game.AttachLogger(new Quest.Core.Logger("TestQuestSponsoring"));
            Player aiPlayer = game.Players[0];

            aiPlayer.Behaviour = new Strategy1();
            Player otherPlayer = game.Players[1];

            RescueTheFairMaiden quest = new RescueTheFairMaiden(game); // 3 Stages with bonus to Black Knight.

            game.CurrentStory = quest;

            // Test case where another player can win.
            //(conditions for whether or not to sponsor quest is same as strategy 2)
            otherPlayer.Rank.AddShields(21);
            Assert.IsFalse(aiPlayer.Behaviour.SponsorQuest(quest, aiPlayer.Hand));
            otherPlayer.Rank.RemoveShields(10);

            //quest cards
            Dragon      dragon      = new Dragon(game);      //50
            BlackKnight blackKnight = new BlackKnight(game); //35 (25+10)
            Mordred     mordred     = new Mordred(game);     //30
            Thieves     thieves     = new Thieves(game);     //5
            Boar        boar        = new Boar(game);        //5
            Lance       lance       = new Lance(game);       //20
            Sword       sword       = new Sword(game);       //10
            Dagger      dagger      = new Dagger(game);      //5

            aiPlayer.Hand.Add(new TestOfValor(game));
            aiPlayer.Hand.Add(boar);
            aiPlayer.Hand.Add(thieves);
            //hand: boar, thieves, testOfValor - not enough bp
            Assert.IsFalse(aiPlayer.Behaviour.SponsorQuest(quest, aiPlayer.Hand));

            aiPlayer.Hand.Add(blackKnight);
            aiPlayer.Hand.Add(lance);
            //hand: boar, thieves, test, blackknight, lance - enough bp
            Assert.IsTrue(aiPlayer.Behaviour.SponsorQuest(quest, aiPlayer.Hand));

            aiPlayer.Hand.Remove(boar);
            aiPlayer.Hand.Remove(thieves);
            aiPlayer.Hand.Remove(lance);
            aiPlayer.Hand.Add(dragon);
            //hand: black knight, test, lance, dragon - enough bp
            //(last stage dragon, 2nd stage test, first black knight (no lance))
            Assert.IsTrue(aiPlayer.Behaviour.SponsorQuest(quest, aiPlayer.Hand));
        }
示例#2
0
        public void TestQuestSponsoring()
        {
            QuestMatch game = ScenarioCreator.GameNoDeal(2);

            game.AttachLogger(new Quest.Core.Logger("TestQuestSponsoring"));
            Player aiPlayer = game.Players[0];

            aiPlayer.Behaviour = new Strategy2();
            Player winningPlayer = game.Players[1];

            RescueTheFairMaiden quest = new RescueTheFairMaiden(game); // 3 Stages with bonus to Black Knight.

            game.CurrentStory = quest;

            // Test case where another player can win.
            winningPlayer.Rank.AddShields(21);
            Assert.IsFalse(aiPlayer.Behaviour.SponsorQuest(quest, aiPlayer.Hand));
            winningPlayer.Rank.RemoveShields(10);

            // Test cards.
            Boar        boar        = new Boar(game);        // 5 BP
            Thieves     thieves     = new Thieves(game);     // 5 BP
            BlackKnight blackKnight = new BlackKnight(game); // Should be worth 35 BP, not 25.
            GreenKnight greenKnight = new GreenKnight(game);
            Mordred     mordred     = new Mordred(game);     // 30 BP.
            Lance       lance       = new Lance(game);       // +20 BP.

            // Ensure having a test card is taken into consideration for the next tests.
            aiPlayer.Hand.Add(new TestOfValor(game));

            // First case, not enough battle points in second stage, expect false.
            aiPlayer.Hand.Add(boar);
            aiPlayer.Hand.Add(thieves);
            Assert.IsFalse(aiPlayer.Behaviour.SponsorQuest(quest, aiPlayer.Hand));

            // Add weapon, expect true.
            aiPlayer.Hand.Add(lance);
            Assert.IsTrue(aiPlayer.Behaviour.SponsorQuest(quest, aiPlayer.Hand));
            aiPlayer.Hand.Remove(lance);
            aiPlayer.Hand.Remove(boar);
            aiPlayer.Hand.Remove(thieves);

            // Green knight and black knight test, black night quest bonuse should be considered, expect true.
            aiPlayer.Hand.Add(blackKnight);
            aiPlayer.Hand.Add(greenKnight);
            Assert.IsTrue(aiPlayer.Behaviour.SponsorQuest(quest, aiPlayer.Hand));
        }
示例#3
0
        public void TestQuestParticipation()
        {
            QuestMatch game = ScenarioCreator.GameNoDeal(1);

            game.AttachLogger(new Quest.Core.Logger("TestQuestParticipation"));
            Player aiPlayer = game.Players[0];

            aiPlayer.Behaviour = new Strategy2();

            RescueTheFairMaiden quest = new RescueTheFairMaiden(game); // 3 stages.

            game.CurrentStory = quest;

            // Make player knight, 10 BP.
            aiPlayer.Rank.AddShields(5);

            // Test cards.
            KingArthur  arthur      = new KingArthur(game);  // 10 BP.
            SirLancelot lancelot    = new SirLancelot(game); // 15 BP.
            SirGalahad  galahad     = new SirGalahad(game);  // 15 BP.
            Boar        boar        = new Boar(game);        // 5 BP, should be discarded.
            Thieves     thieves     = new Thieves(game);     // 5 BP, should be discarded.
            BlackKnight blackKnight = new BlackKnight(game); // 25 BP, should not be discarded.
            Excalibur   excalibur   = new Excalibur(game);   // +30 BP.
            Lance       lance       = new Lance(game);       // + 20 BP.

            // Cannot increase for all 3 stages, expect false.
            aiPlayer.Hand.Add(boar);
            aiPlayer.Hand.Add(thieves);
            aiPlayer.Hand.Add(blackKnight);
            aiPlayer.Hand.Add(arthur);
            aiPlayer.Hand.Add(lancelot);
            aiPlayer.Hand.Add(galahad);
            Assert.IsFalse(aiPlayer.Behaviour.ParticipateInQuest(quest, aiPlayer.Hand));

            // Add weapons, expect true.
            aiPlayer.Hand.Add(excalibur);
            aiPlayer.Hand.Add(lance);
            Assert.IsTrue(aiPlayer.Behaviour.ParticipateInQuest(quest, aiPlayer.Hand));

            // Remove discardable foe less than 25 BP, expect false.
            aiPlayer.Hand.Remove(boar);
            Assert.IsFalse(aiPlayer.Behaviour.ParticipateInQuest(quest, aiPlayer.Hand));
        }
示例#4
0
        /// <summary>
        /// Gets a board in the starting position.
        /// </summary>
        /// <returns></returns>
        public static Board GetStartingBoard()
        {
            var squares = new Piece[SquareNo];
            var status  = new BoardStatus();

            squares[A8] = new BlackRook();
            squares[B8] = new BlackKnight();
            squares[C8] = new BlackBishop();
            squares[D8] = new BlackQueen();
            squares[E8] = new BlackKing();
            squares[F8] = new BlackBishop();
            squares[G8] = new BlackKnight();
            squares[H8] = new BlackRook();

            for (var sqIndex = SideSquareNo; sqIndex < SideSquareNo * 2; sqIndex++)
            {
                squares[sqIndex] = new BlackPawn();
            }

            for (var sqIndex = SideSquareNo * (SideSquareNo - 2); sqIndex < SideSquareNo * (SideSquareNo - 1); sqIndex++)
            {
                squares[sqIndex] = new WhitePawn();
            }

            squares[A1] = new WhiteRook();
            squares[B1] = new WhiteKnight();
            squares[C1] = new WhiteBishop();
            squares[D1] = new WhiteQueen();
            squares[E1] = new WhiteKing();
            squares[F1] = new WhiteBishop();
            squares[G1] = new WhiteKnight();
            squares[H1] = new WhiteRook();

            status.WhiteTurn            = true;
            status.WhiteCouldCastleLong = status.WhiteCouldCastleShort = status.BlackCouldCastleLong = status.BlackCouldCastleShort = true;
            status.EnPassantTarget      = null;
            status.Ply   = 0;
            status.Moves = 1;

            return(new Board(squares, status));
        }
示例#5
0
        public void TestSetupQuest()
        {
            QuestMatch game = ScenarioCreator.GameNoDeal(1);

            game.AttachLogger(new Quest.Core.Logger("TestSetupQuest"));
            Player sponsorAI = game.Players[0];

            sponsorAI.Behaviour = new Strategy1();

            // Setup quest
            RescueTheFairMaiden quest = new RescueTheFairMaiden(game);//3 stages

            game.CurrentStory = quest;
            quest.Sponsor     = sponsorAI;

            //quest cards
            Dragon      dragon      = new Dragon(game);      //50
            BlackKnight blackKnight = new BlackKnight(game); //35 (25+10)
            Thieves     thieves     = new Thieves(game);     //5
            Boar        boar        = new Boar(game);        //5
            TestOfValor testOfValor = new TestOfValor(game);

            sponsorAI.Hand.Add(new List <Card>()
            {
                testOfValor, boar, thieves, dragon
            });

            List <AdventureCard>[] stages = sponsorAI.Behaviour.SetupQuest(quest, sponsorAI.Hand);
            Assert.AreEqual(3, stages.Length);

            //test last stage - should contain strongest foe (dragon)
            Assert.AreEqual(1, stages[2].Count);
            Assert.IsTrue(stages[2].Contains(dragon));

            //test second last stage - should contain test of valor
            Assert.AreEqual(1, stages[1].Count);
            Assert.IsTrue(stages[1].Contains(testOfValor));

            //test first stage
            Assert.AreEqual(1, stages[0].Count);
        }
示例#6
0
        public void AddEnemyToList(string enemyName)
        {
            string nameOfEnemy      = "";
            string levelOfEnemy     = "";
            string enemyPicturePath = "";
            bool   isBoss           = false;
            Enemy  enemy;

            switch (enemyName.ToLower())
            {
            case "warrior":
                Warrior warrior = new Warrior(true, _gameSessionViewModel, this);
                warrior.RemovedFromActiveEnemiesList             = false;
                _gameSessionViewModel.Player.PlayersCurrentState = Player.PlayerState.Fighting;
                warrior.AttackingPlayer = true;
                enemy = warrior;
                _gameSessionViewModel.CurrentEnemies.Add(warrior);
                nameOfEnemy           = "Warrior";
                levelOfEnemy          = "{LVL " + warrior.Level + " }";
                enemyPicturePath      = warrior.Image;
                warrior.listPlacement = getPlacementID(warrior);
                warrior.PictureSource = getPictureSource(enemyPicturePath);
                break;

            case "warrior-black":

                BlackKnight blackKnight = new BlackKnight(false, _gameSessionViewModel, this);
                _gameSessionViewModel.CurrentEnemies.Add(blackKnight);
                enemy = blackKnight;
                blackKnight.AttackingPlayer = true;
                _gameSessionViewModel.Player.PlayersCurrentState = Player.PlayerState.Fighting;
                nameOfEnemy               = blackKnight.Name;
                levelOfEnemy              = "{LVL " + blackKnight.Level + " }";
                blackKnight.IsBoss        = true;
                isBoss                    = true;
                enemyPicturePath          = blackKnight.Image;
                blackKnight.listPlacement = getPlacementID(blackKnight);
                blackKnight.PictureSource = getPictureSource(enemyPicturePath);

                break;

            case "bandit":
                Bandit bandit = new Bandit(false, _gameSessionViewModel, this);
                bandit.RemovedFromActiveEnemiesList = false;
                _gameSessionViewModel.Player.PlayersCurrentState = Player.PlayerState.Fighting;
                bandit.AttackingPlayer = true;
                enemy = bandit;
                _gameSessionViewModel.CurrentEnemies.Add(bandit);
                nameOfEnemy          = "Bandit";
                levelOfEnemy         = "{LVL " + bandit.Level + " }";
                enemyPicturePath     = bandit.Image;
                bandit.listPlacement = getPlacementID(bandit);
                bandit.PictureSource = getPictureSource(enemyPicturePath);

                break;

            case "mudcrawler":
                nameOfEnemy      = "MudCrawler";
                levelOfEnemy     = "{LVL 9}";
                enemyPicturePath = "MudCrawler.png";
                break;

            case "scuffedspider":
                nameOfEnemy      = "Spider";
                levelOfEnemy     = "{LVL 3}";
                enemyPicturePath = "scuffedspider.png";
                break;

            case "wizard":
                Wizard wizard = new Wizard(false, _gameSessionViewModel, this);
                wizard.RemovedFromActiveEnemiesList = false;
                _gameSessionViewModel.Player.PlayersCurrentState = Player.PlayerState.Fighting;
                wizard.AttackingPlayer = true;
                enemy = wizard;
                _gameSessionViewModel.CurrentEnemies.Add(wizard);
                nameOfEnemy          = "Wizard";
                levelOfEnemy         = "{LVL " + wizard.Level + " }";
                enemyPicturePath     = wizard.Image;
                wizard.listPlacement = getPlacementID(wizard);
                wizard.PictureSource = getPictureSource(enemyPicturePath);
                break;

            default:
                break;
            }
            ListBoxItem item     = new ListBoxItem();
            StackPanel  new_item = new StackPanel();

            new_item.Orientation = Orientation.Horizontal;
            Image       img      = new Image();
            BitmapImage bitImage = new BitmapImage();

            bitImage.BeginInit();

            bitImage.UriSource = new Uri("/Images/" + enemyPicturePath, UriKind.Relative);

            bitImage.EndInit();

            img.Source = bitImage;
            //
            // Flip image
            //


            EnemyPicture.Source = bitImage;

            img.Width  = 32;
            img.Height = 32;

            TextBlock entityLevel = new TextBlock();

            entityLevel.Text              = levelOfEnemy;
            entityLevel.FontWeight        = FontWeights.Bold;
            entityLevel.FontSize          = 16;
            entityLevel.VerticalAlignment = VerticalAlignment.Center;

            TextBlock entityName = new TextBlock();

            entityName.Text              = nameOfEnemy;
            entityName.FontSize          = 15.5;
            entityName.FontWeight        = FontWeights.Bold;
            entityName.VerticalAlignment = VerticalAlignment.Center;

            new_item.Children.Add(img);
            new_item.Children.Add(entityLevel);
            new_item.Children.Add(entityName);
            item.Content = new_item;
            if (!isBoss)
            {
                item.Background = Brushes.Red;
            }
            else if (isBoss == true)
            {
                item.Background = Brushes.Pink;
            }
            item.BorderBrush     = Brushes.Black;
            item.BorderThickness = new Thickness(3, 3, 3, 0);

            ActiveEnemies.Items.Add(item);
        }
示例#7
0
        static void Main(string[] args)       // Change to Main2() when testing
        {
            // ----------- INITIALIZATION -------------

            Player          p  = new Player();
            BlackKnight     bk = new BlackKnight();
            Screen          s  = new Screen(p, bk);
            CombatException e  = new CombatException(s);
            Match           m  = new Match(s);
            PlayerTurn      pt = new PlayerTurn(m, s, p, bk, e);
            EnemyTurn       et = new EnemyTurn(m, s, p, bk);

            m.SetUpFight(p, bk);   // Used for setting up opponents and Screen class for the combat

            // ------------ FIRST CHOICE --------------

            int startingChoice = 0;

            while (startingChoice != 1 && startingChoice != 2)   // Locks the player until he/she chooses a valid option
            {
                Console.Clear();

                s.Encounter();     // Make it possible to fight other opponents later

                try
                {
                    startingChoice = int.Parse(Console.ReadLine());

                    switch (startingChoice)
                    {
                    case 1:
                        Console.Clear();
                        s.PrepareFight();
                        Thread.Sleep(4000);
                        break;

                    case 2:
                        Console.Clear();
                        s.Flee();
                        break;

                    default:
                        e.InvalidChoice();
                        break;
                    }
                }
                catch
                {
                    e.InvalidChoice();
                }
            }


            // ---------------- TURNS -------------------

            while (startingChoice == 1 && m.MatchInProgress)
            {
                // ----- Player Turn -----

                pt.Turn();

                // ----- Enemy Turn -----

                et.Turn();
            }
        }