Пример #1
0
 public Card(CardNumEnum number, CardShapeEnum shape)
 {
     this.number    = number;
     this.shape     = shape;
     this.side      = CardSideEnum.DOWN;
     this.imageFace = ImageCutter.GetFaceImage(this);
     this.imageBack = ImageCutter.GetBackImage();
     this.state     = CardState.HAND;
 }
Пример #2
0
        private void ResultARound()
        {
            // Find The Strongest
            int theStrongest = this.firstPlayer;

            CardShapeEnum fShape = this.table.GetWhatOnTable(theStrongest).Shape;
            CardNumEnum   fNum   = this.table.GetWhatOnTable(theStrongest).Number;

            for (int i = 0; i < 4; i++)
            {
                if (this.table.GetWhatOnTable(i).Shape == fShape)
                {
                    CardNumEnum tempNumber = this.table.GetWhatOnTable(i).Number;
                    if (tempNumber == CardNumEnum.ACE || tempNumber > fNum)
                    {
                        fNum         = tempNumber;
                        theStrongest = i;
                        if (fNum == CardNumEnum.ACE)
                        {
                            break;
                        }
                    }
                }
            }

            // Calculate Scores
            int scoreOfThisRound = this.table.SumOfScoreCard();

            // Add scores
            if (scoreOfThisRound == 26)                 // Shoot the moon
            {
                for (int i = 0; i < 4; i++)
                {
                    if (i == theStrongest)
                    {
                        continue;
                    }
                    this.players[i].AddScore(26);
                }
            }
            else
            {
                this.players[theStrongest].AddScore(scoreOfThisRound);
            }

            // Who's Next
            this.currentPlayer = theStrongest;
        }
Пример #3
0
 // 손에서 카드를 제거(카드를 냄)
 public Card RemoveFromHand(CardShapeEnum shape, CardNumEnum num)
 {
     try
     {
         foreach (Card card in this.cardList)
         {
             if (card.Shape == shape && card.Number == num)
             {
                 Card temp = card;
                 this.cardList.Remove(card);
                 return(temp);
             }
         }
         throw new Exception("RemoveFromHand() error");
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(null);
     }
 }
Пример #4
0
        public Manager()
        {
            this.players = new Player[4];
            players[0]   = new Player("A");
            players[1]   = new Player("B");
            players[2]   = new Player("C");
            players[3]   = new Player("D");

            this.cards = new Card[4, 13];
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 13; j++)                    // 카드 생성
                {
                    CardNumEnum   num   = (CardNumEnum)((int)CardNumEnum.ACE + j);
                    CardShapeEnum shape = (CardShapeEnum)((int)CardShapeEnum.SPADE + i);
                    cards[i, j] = new Card(num, shape);
                }
            }

            this.table           = new Table();
            this.selectedExCards = new Card[4, 3];
            this.exThreads       = new Thread[4];
            this.exChecker       = false;
        }
Пример #5
0
 private bool CardRuleChecker(Card card)
 {
     // 클럽2를 내지 않은 가장 맨 처음일 때
     if (club2 == false)
     {
         if (card.Shape == CardShapeEnum.CLUB && card.Number == CardNumEnum.TWO)
         {
             club2 = true;
             return(true);
         }
         else
         {
             return(false);
         }
     }
     // 첫 턴이다
     else if (currentPlayer == firstPlayer)
     {
         // 낸 카드가 하트인가?
         if (card.Shape == CardShapeEnum.HEART)
         {
             // 하트가 깨져있다.
             if (heartBreak == true)
             {
                 return(true);
             }
             // 하트가 안 깨졌다.
             else
             {
                 Hand tHand = players[currentPlayer].PlayerHand;
                 if (tHand.CheckIfShape(CardShapeEnum.CLUB) || tHand.CheckIfShape(CardShapeEnum.DIAMOND) || tHand.CheckIfShape(CardShapeEnum.SPADE))
                 {
                     return(false);
                 }
                 else
                 {
                     heartBreak = true;
                     return(true);
                 }
             }
         }
         // 다른 모양인가?
         else
         {
             return(true);
         }
     }
     // 첫 턴이 아니다
     else
     {
         // 맨 처음에 낸 카드와 문양이 같다.
         if (table.GetWhatOnTable(firstPlayer).Shape == card.Shape)
         {
             return(true);
         }
         // 다르다
         else
         {
             CardShapeEnum tShape = table.GetWhatOnTable(firstPlayer).Shape;
             // 맨 처음에 낸 카드와 문양이 같은 게 없다
             if (players[currentPlayer].PlayerHand.CheckIfShape(tShape) == false)
             {
                 // 낸 카드가 하트다
                 if (card.Shape == CardShapeEnum.HEART)
                 {
                     heartBreak = true;
                     return(true);
                 }
                 // 낸 카드가 하트가 아니다
                 else
                 {
                     return(true);
                 }
             }
             // 문양이 같은 게 있다.
             else
             {
                 return(false);
             }
         }
     }
 }
Пример #6
0
 // 같은 모양의 카드가 있는지 체크
 public bool CheckIfShape(CardShapeEnum shape)
 {
     return(this.cardList.Exists(x => x.Shape == shape));
 }