Ejemplo n.º 1
0
        public bool ChooseAttackTarget(Arena.FightState state)
        {
            bool targetChosen = false;
            NewLinked<Team> targetTeams = GetTargets(state);
            NewLinked<Character> targets = new NewLinked<Character>();

            for (int i = 0; i < targetTeams.Length; i++)
                for (int x = 0; x < targetTeams.Get(i)._members.Length; x++)
                {
                    if (!targetTeams.Get(i)._members[x].IsDead)
                        targets.Add(targetTeams.Get(i)._members[x]);
                }

            MenuItem<Character>[] menuItems = MakeMenu(targets);
            for (int i = 0; i < menuItems.Length; i++)
                menuItems[i].NeedsConfirm = false;

            Console.WriteLine("Choose a target to attack:");
            Character attackTarget = Menu<Character>.ShowMenu(menuItems);

            if (attackTarget == null)
                targetChosen = false;
            else
            {
                this.Attack(attackTarget, state);
                targetChosen = true;
            }

            return targetChosen;
        }
Ejemplo n.º 2
0
        protected int CalculateHand(NewLinked<Card> hand)
        {
            Console.WriteLine("Hand contents:");
            Card curCard = null;
            int totalScore = 0;
            int cardVal = 0;

            for (int i = 0; i < hand.Length; i++)
            {
                curCard = (Card)hand.Get(i);
                cardVal = (int)curCard.Rank;
                Console.WriteLine(hand.Get(i).ToString());

                if (curCard.Rank == Rank.Ace)
                    continue;
                if (cardVal > 10)
                    cardVal = 10;
                totalScore = totalScore + cardVal;

            }

            for (int i = 0; i < hand.Length; i++)
            {
                curCard = (Card)hand.Get(i);
                cardVal = (int)curCard.Rank;
                if (curCard.Rank != Rank.Ace)
                    continue;
                if (totalScore + 11 > 21)
                    totalScore++;
                else
                    totalScore = totalScore + 11;
            }

            Console.WriteLine();
            Console.WriteLine("Hand Value is " + totalScore);
            Console.WriteLine();
            return totalScore;
        }
Ejemplo n.º 3
0
 protected void DrawCard(NewLinked<Card> hand, int drawCount)
 {
     for (int cardNum = 0; cardNum < drawCount; cardNum++)
     {
         hand.Add(_deckCards.Draw());
     }
 }
Ejemplo n.º 4
0
 MenuItem<Character>[] MakeMenu(NewLinked<Character> targets)
 {
     MenuItem<Character>[] menuItems = new MenuItem<Character>[targets.Length + 1];
     for (int i = 0; i < menuItems.Length - 1; i++)
     {
         menuItems[i] = new MenuItem<Character>();
         menuItems[i].Content = targets.Get(i);
         menuItems[i].Description = targets.Get(i).Name + ":  HP " + targets.Get(i).HP + "/" + targets.Get(i).MaxHP + ", AT " + targets.Get(i).AT;
     }
     menuItems[menuItems.Length - 1] = new MenuItem<Character>();
     menuItems[menuItems.Length - 1].Content = null;
     menuItems[menuItems.Length - 1].Description = "Go Back";
     return menuItems;
 }