Exemple #1
0
 public void getCard(player opponent)
 {
     while (true)
     {
         Console.WriteLine("           ------------------   ");
         Console.WriteLine("you are now " + this.hitPoint.ToString() + "/30 hit point ");
         Console.WriteLine("   your " + this.inHand.Count.ToString() + " card:");
         for (int iCard = 0; iCard < this.inHand.Count; iCard++)
         {
             string tmp = this.inHand[iCard].show();
             Console.WriteLine(iCard.ToString() + "  " + tmp);
         }
         Console.WriteLine("you have " + this.mana.ToString() + "/" + this.manasum.ToString() +
             "  mana crystal");
         Console.WriteLine("your opponent have : " + opponent.getHitPoint().ToString()+" hit point.");
         Console.WriteLine("           ------------------   ");
         Console.Write("please enter which card you want to use or you can enter 'q' to quit.\nenter a number:  ");
         string input = Console.ReadLine();
         if (input == "q")
             break;
         int index = int.Parse(input);
         if (index < 0 | index > this.inHand.Count)
             Console.WriteLine("error input index!");
         else
         {
             if (this.inHand[index].useCard(this, opponent))
                 this.inHand.RemoveAt(index);
         }
         if (opponent.getHitPoint() < 1)
         { break; }
     }
 }
Exemple #2
0
        public bool getTurn(player opponent)
        {
            bool isOver=false;
            this.pickACard();
            this.manasum +=1;
            if (this.manasum > 10)
                this.manasum = 10;
            this.mana = this.manasum;
            Console.WriteLine("Now, " + this.name + ", this is your turn.");
            this.getCard(opponent);

            if (opponent.getHitPoint() < 1)
                isOver = true;
            return isOver;
        }
Exemple #3
0
        static void Main(string[] args)
        {
            //Deck tmp=new Deck();
            player[] players=new player[2];
            //Console.WriteLine("who is the first player :");
            players[0] = new player("First");
            players[1]=new player("Second");
            int turnCount = 0;
            bool isEnd = false;
            while (true)
            {
                Console.WriteLine("************** A new turn ******************");
                player currentPlayer = players[turnCount % 2];
                player nextPlayer = players[(turnCount+1) % 2];
                if(currentPlayer.getTurn(nextPlayer))
                {

                }

                turnCount += 1;
            }
        }
Exemple #4
0
 public bool useCard(player owner, player opponent)
 {
     if (owner.manaChange(this.manaCost))
     {
         owner.hitPointChange(this.heal);
         opponent.hitPointChange(this.damage*(-1));
         if (this.isDrawCard)
             owner.pickACard();
         if (this.display != "")
         {
             Console.WriteLine(this.display);
         }
         return true;
     }
     else
     {
         Console.WriteLine("you don't have enough mana crystal!");
         return false;
     }
 }