예제 #1
0
        public void TestDeskCheckError()
        {
            Desk tempDesk1 = new Desk();
            int  coloum = 0, row = 0;

            for (Card.Type type = Card.Type.Diamonds; type <= Card.Type.Club; type++)
            {
                for (int i = 1; i <= 13; i++)
                {
                    tempDesk1.AddNewCardInColoum(coloum, new Card(type, (Card.Number)i));
                    coloum++;
                    if (coloum == tempDesk1.AllCardOnDesk.ColoumCard.GetLength(0))
                    {
                        row++;
                        coloum = 0;
                    }
                }
            }
            tempDesk1.CheckError();

            Card tempCard = tempDesk1.RemoveLastCardInColoum(0);

            try
            {
                tempDesk1.CheckError();
                throw new Exception("Test failed");
            }
            catch (ErrorInDeskException)
            {
            }
            tempDesk1.AllCardOnDesk.FreeCard[0] = tempCard;
            tempDesk1.CheckError();

            Desk tempDesk2 = new Desk();

            for (Card.Type type = Card.Type.Diamonds; type <= Card.Type.Spade; type++)
            {
                for (int i = 1; i <= 13; i++)
                {
                    tempDesk2.AddNewCardInColoum(coloum, new Card(type, (Card.Number)i));
                    coloum++;
                    if (coloum == tempDesk2.AllCardOnDesk.ColoumCard.GetLength(0))
                    {
                        row++;
                        coloum = 0;
                    }
                }
            }
            for (Card.Number i = Card.Number.Arch; i <= Card.Number.King; i++)
            {
                tempDesk2.AddNewCardInSortedCard(new Card(Card.Type.Club, i), true);
            }

            tempDesk2.CheckError();
        }
예제 #2
0
    /**
     *<summary> 点数割り出し関数 </summary>
     */
    int Scorecalc(List <GameObject> Hands)
    {
        int score = 0;
        int cntA  = 0;

        for (int card = 0; card < Hands.Count; card++)
        {
            Card.Number number = Hands[card].GetComponent <Card>().MyNumber;

            switch (number)
            {
            case Card.Number.A:
                score += 1;
                cntA++;
                break;

            case Card.Number._2:
            case Card.Number._3:
            case Card.Number._4:
            case Card.Number._5:
            case Card.Number._6:
            case Card.Number._7:
            case Card.Number._8:
            case Card.Number._9:
            case Card.Number._10:
                score += (int)number;
                break;

            case Card.Number.J:
            case Card.Number.Q:
            case Card.Number.K:
                score += 10;
                break;
            }
        }
        // TODO なにかしょりする

        // 「A」を持っている、かつ点数が11点以下(バーストしない)なら
        // 「A」を11点としてカウントする
        if (score <= 11 && cntA != 0)
        {
            score += 10;
        }

        return(score);
    }
예제 #3
0
        public void TestInfer_SolveColoumCardDesk()
        {
            Desk tempDesk1 = new Desk();

            for (int coloumIndex = 0; coloumIndex < 4; coloumIndex++)
            {
                for (Card.Number i = Card.Number.King; i >= Card.Number.Arch; i--)
                {
                    tempDesk1.AddNewCardInColoum(coloumIndex, new Card((Card.Type)coloumIndex + 1, i));
                }
            }

            InferManager.GetInstance().ClearInferData();
            InferManager.GetInstance().SetStartDesk(tempDesk1);
            var result = InferManager.GetInstance().StartInfer();

            if (!result.IsSolved)
            {
                throw new Exception(result.Message);
            }
        }
예제 #4
0
        public void TestCountSortedCardInColoum()
        {
            Desk tempDesk1 = new Desk();
            bool sign      = true;

            for (Card.Number i = Card.Number.King; i >= Card.Number.Arch; i--)
            {
                tempDesk1.AddNewCardInColoum(0, new Card(sign ? Card.Type.Diamonds : Card.Type.Spade, i));
                sign = !sign;
            }
            sign = false;
            for (Card.Number i = Card.Number.King; i >= Card.Number.Arch; i--)
            {
                tempDesk1.AddNewCardInColoum(1, new Card(sign ? Card.Type.Diamonds : Card.Type.Spade, i));
                sign = !sign;
            }
            sign = true;
            for (Card.Number i = Card.Number.King; i >= Card.Number.Arch; i--)
            {
                tempDesk1.AddNewCardInColoum(2, new Card(sign ? Card.Type.Heart : Card.Type.Club, i));
                sign = !sign;
            }
            sign = false;
            for (Card.Number i = Card.Number.King; i >= Card.Number.Arch; i--)
            {
                tempDesk1.AddNewCardInColoum(3, new Card(sign ? Card.Type.Heart : Card.Type.Club, i));
                sign = !sign;
            }

            for (int coloumIndex = 0; coloumIndex < 2; coloumIndex++)
            {
                if (tempDesk1.GetSortedCardCountInColoum(coloumIndex) != 12)
                {
                    throw new Exception("Test Failed");
                }
            }
        }
예제 #5
0
파일: Game.cs 프로젝트: devillh/Coinche
 public Game()
 {
     Deck      = new List <Card>();
     Players   = new List <Player>();
     Bidding   = new Bidding();
     Carpet    = new Carpet();
     CurPlayer = 0;
     CurStep   = Message.Steps.GAME;
     Round     = 0;
     MaxPlayer = 4;
     MaxRound  = 8;
     CountPlay = 0;
     for (Card.Color j = Card.Color.SPADE; j <= Card.Color.DIAMOND; j++)
     {
         for (Card.Number i = Card.Number.SEVEN; i <= Card.Number.ACE; i++)
         {
             Card card = new Card(i, j, 0);
             Deck.Add(card);
         }
     }
     Shuffle();
     Bidding.Reset();
     Carpet.Clear();
 }
 public void AddNewCardInColoum(int coloum, Card.Type type, Card.Number number)
 {
     AddNewCardInColoum(coloum, new Card(type, number));
 }
 public void AddNewCardInColoum(int coloum, Card.Type type, int numberInt)
 {
     Card.Number number = (Card.Number)numberInt;
     AddNewCardInColoum(coloum, new Card(type, number));
 }