Exemplo n.º 1
0
 public void MoveTo(ref CardBox box, int cardIndex)
 {
     box.Add(cards[cardIndex]);
     RemoveAt(cardIndex);
     GameObject.Find(SoundPlayer.objectName).GetComponent <SoundPlayer>().PlaySE(
         SEname.Turn);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Method which determines whether the card was 'dropped' 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void DeckViewer_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetData(typeof(CardBox)) != null && this.isFull() == false)
            {

                CardBox draggedCard = (CardBox)e.Data.GetData(typeof(CardBox));


                // A logic structure which determines which panels to move the card to
                if (draggedCard != null && draggedCard.Parent.GetType() == typeof(DeckViewer))
                {
                    DeckViewer fromPanel = draggedCard.Parent as DeckViewer;
                    BoutViewer toPanel = sender as BoutViewer;

                    if (toPanel != null && fromPanel != null)
                    {
                        if (toPanel != fromPanel)
                        {
                            if(toPanel.canPlaceCard(draggedCard.Card))
                            {
                                fromPanel.RemoveCard(draggedCard.Card);
                                toPanel.AddCard(draggedCard.Card, true);
                            }
                        }
                    }

                }

            }


        }
Exemplo n.º 3
0
        /// <summary>
        /// Method that implements computer attack logic
        /// </summary>
        private void ComputerAttacks()
        {
            // If player takes the cards on the table, increase the number of cards on the table
            if (playerTakes)
            {
                numberOfCardsInPlay++;
            }

            // If number of cards on the table is less than a limit:
            if (numberOfCardsInPlay < playerHandCount * 2)
            {
                // Attempt to get a card to attack with
                PlayingCard attackCard = game.ComputerAttacks();

                // Instantiate a new CardBox object
                CardBox playCard = new CardBox(attackCard);
                playCard.FaceUp    = true;
                playCard.BackColor = Color.Transparent;

                // If computer found a card to attack with:
                if (game.ComputerFoundCard)
                {
                    UpdateLogs("Computer attacks with " + attackCard.DebugString());
                    // Remove a card from computer's hand, add it to the table
                    pnlCPUHand.Controls.RemoveAt(0);
                    pnlPlayArea.Controls.Add(playCard);
                    // Realign cards in computer's hand
                    RealignCards(pnlCPUHand);
                    // Increase the number of cards on the table
                    numberOfCardsInPlay++;
                    // Set card's location on the table
                    AddCardToPlayArea(pnlPlayArea.Controls[pnlPlayArea.Controls.Count - 1]);
                    // Add card to the list of cards in play
                    game.CardsInPlay.Add(attackCard);
                    // If player takes cards on the table, attack again
                    if (playerTakes)
                    {
                        ComputerAttacks();
                    }
                }
                // If computer didn't find a card to attack with, start a new round
                else
                {
                    if (!gameOver)
                    {
                        computerAttacks = false;
                        NewRound();
                    }
                }
            }
            // If number of cards on the table is greater than a limit, start a new round
            else
            {
                if (!gameOver)
                {
                    computerAttacks = false;
                    NewRound();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Clears and recreates the card boxes to ensure they reflect the cards object
        /// </summary>
        /// <param name="willCardsPop">If the cards will pop up when moused over</param>
        public void UpdateCardBoxes(bool willCardsPop)
        {
            this.Controls.Clear();

            for (int i = 0; i < this.cards.Count; i++)
            {
                if (IsEnemyView == true)
                {
                    standardCardSize = new Size(42, 70);
                    CardBox cardBox = new CardBox(cards[i]);
                    cardBox.Size = standardCardSize;
                    this.Controls.Add(cardBox);
                }
                else
                {
                    CardBox cardBox = new CardBox(cards[i], willCardsPop);
                    cardBox.Size = standardCardSize;
                    this.Controls.Add(cardBox);
                }
            }

            if (this.Controls.Count > 0)
            {
                this.Controls[this.Controls.Count - 1].Name = "lastCardInView";
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Method that implements computer defense logic
        /// </summary>
        private void ComputerDefends()
        {
            // If computer doesn't take cards:
            if (!game.ComputerPicksUp)
            {
                // If computer ran out of cards:
                if (game.Computer.PlayHand.Count == 0)
                {
                    NewRound();         // start a new round
                    if (!gameOver)
                    {
                        ComputerAttacks();             // computer attacks if the game isn't over
                    }
                }
                // If computer has cards:
                else
                {
                    // Attempt to get a card to defend with
                    PlayingCard defendCard = game.ComputerDefends();
                    // If computer has a card to defend with:
                    if (!game.ComputerPicksUp)
                    {
                        UpdateLogs("Computer defends with " + defendCard.DebugString()); // Update the logs file

                        numberOfCardsInPlay++;                                           // increase number of cards in play

                        // Instantiate a new CardBox object
                        CardBox newControl = new CardBox(defendCard);
                        newControl.FaceUp    = true;
                        newControl.BackColor = Color.Transparent;

                        // Add a card to the main playing area and set its location
                        pnlPlayArea.Controls.Add(newControl);
                        AddCardToPlayArea(pnlPlayArea.Controls[pnlPlayArea.Controls.Count - 1]);

                        // Remove a card from the computer's hand and realign cards
                        pnlCPUHand.Controls.RemoveAt(0);
                        RealignCards(pnlCPUHand);

                        game.CardsInPlay.Add(defendCard);   // add a card to the list of cards in play

                        // If number of cards in play is greater than a limit:
                        if (numberOfCardsInPlay >= computerHandCount * 2)
                        {
                            NewRound();         // start a new round
                            ComputerAttacks();  // computer attacks
                        }
                    }
                }
            }
            // If number of cards in play is greater than a limit:
            else if (numberOfCardsInPlay >= computerHandCount * 2 - 1)
            {
                computerAttacks = false;
                ComputerPicksUp();  // computer takes the cards on the table
                NewRound();         // start a new round
            }
            // Determine whether the game is over
            EndOfGame();
        }
Exemplo n.º 6
0
        public void StartRevisionSession_CardReadyForRevision_ReturnsSessionWithTheCard()
        {
            // Arrange
            var cardBoxSet = new CardBoxSet(
                Guid.NewGuid(),
                new CardBoxSetOwnerId(Guid.NewGuid()),
                new CardBoxSetName("Test Name"),
                new CardBoxSetLanguage("Russian", _ => true),
                new CardBoxSetLanguage("Finnish", _ => true));

            var newCardBox = new CardBox(Guid.NewGuid(), cardBoxSet.Id, new CardBoxLevel(1),
                                         new CardBoxRevisionDelay(3));

            cardBoxSet.AddCardBox(newCardBox);

            var card = new Card(Guid.NewGuid(), new CardWord("Привет"), new CardWord("Moi"));

            cardBoxSet.AddNewCard(card, new DateTimeOffset(2020, 2, 16, 0, 0, 0, TimeSpan.Zero));

            // Act
            var revision = cardBoxSet.StartRevisionSession(new DateTimeOffset(2020, 2, 20, 0, 0, 0, TimeSpan.Zero));

            // Assert
            Assert.Equal(RevisionSessionStatus.Started, revision.Status);
            Assert.Single(revision.SessionCards);
            var sessionCard = revision.SessionCards.First();

            Assert.Equal(card.Id, sessionCard.CardId);
            Assert.Equal(card.TargetLanguageWord, sessionCard.TargetLanguageWord);
            Assert.Equal(card.NativeLanguageWord, sessionCard.NativeLanguageWord);
        }
Exemplo n.º 7
0
        public void RemoveCard_PassContainedCard_CardSuccessfullyRemoved()
        {
            // Arrange
            var cardBoxSet = new CardBoxSet(
                Guid.NewGuid(),
                new CardBoxSetOwnerId(Guid.NewGuid()),
                new CardBoxSetName("Test Name"),
                new CardBoxSetLanguage("Russian", _ => true),
                new CardBoxSetLanguage("Finnish", _ => true));

            var cardBox = new CardBox(Guid.NewGuid(), cardBoxSet.Id, new CardBoxLevel(1),
                                      new CardBoxRevisionDelay(3));

            cardBoxSet.AddCardBox(cardBox);

            var card = new Card(Guid.NewGuid(), new CardWord("Привет"),
                                new CardWord("Hei"));

            cardBoxSet.AddNewCard(card);

            // Act
            cardBoxSet.RemoveCard(card.Id);

            // Assert
            Assert.Empty(cardBox.Cards);
        }
Exemplo n.º 8
0
        public void ProcessCardsFromRevisionSession_SessionNotCompleted_ThrowsRevisionSessionNotCompletedException()
        {
            // Arrange
            var cardBoxSet = new CardBoxSet(
                Guid.NewGuid(),
                new CardBoxSetOwnerId(Guid.NewGuid()),
                new CardBoxSetName("Test Name"),
                new CardBoxSetLanguage("Russian", _ => true),
                new CardBoxSetLanguage("Finnish", _ => true));
            var firstCardBox = new CardBox(Guid.NewGuid(), cardBoxSet.Id, new CardBoxLevel(1),
                                           new CardBoxRevisionDelay(3));

            cardBoxSet.AddCardBox(firstCardBox);

            var secondCardBox = new CardBox(Guid.NewGuid(), cardBoxSet.Id, new CardBoxLevel(2),
                                            new CardBoxRevisionDelay(5));

            cardBoxSet.AddCardBox(secondCardBox);

            var card = new Card(Guid.NewGuid(), new CardWord("Привет"), new CardWord("Moi"));

            cardBoxSet.AddNewCard(card, new DateTimeOffset(2020, 2, 16, 0, 0, 0, TimeSpan.Zero));

            var revisionSession = cardBoxSet.StartRevisionSession(new DateTimeOffset(2020, 2, 20, 0, 0, 0, TimeSpan.Zero));

            revisionSession.CardAnswered(card.Id, SessionCardAnswerType.TargetLanguage, "",
                                         new TestTrueCardAnswerCheckService());

            // Act & Assert
            Assert.Throws <DomainException.RevisionSessionNotCompletedException>(
                () => cardBoxSet.ProcessCardsFromRevisionSession(revisionSession,
                                                                 new DateTimeOffset(2020, 2, 20, 0, 0, 0, TimeSpan.Zero)));
        }
Exemplo n.º 9
0
        public void AddNewCard_SetWithBoxesNotContainedCard_SuccessfullyAddssCardToLowestLevelBox()
        {
            // Arrange
            var now = new DateTimeOffset(2020, 2, 20, 0, 0, 0, TimeSpan.Zero);

            var cardBoxSet = new CardBoxSet(
                Guid.NewGuid(),
                new CardBoxSetOwnerId(Guid.NewGuid()),
                new CardBoxSetName("Test Name"),
                new CardBoxSetLanguage("Russian", _ => true),
                new CardBoxSetLanguage("Finnish", _ => true));

            var firstCardBox = new CardBox(Guid.NewGuid(), cardBoxSet.Id, new CardBoxLevel(1),
                                           new CardBoxRevisionDelay(3));

            cardBoxSet.AddCardBox(firstCardBox);

            var secondCardBox = new CardBox(Guid.NewGuid(), cardBoxSet.Id, new CardBoxLevel(2),
                                            new CardBoxRevisionDelay(5));

            cardBoxSet.AddCardBox(secondCardBox);

            var card = new Card(Guid.NewGuid(), new CardWord("Привет"), new CardWord("Hei"));

            // Act
            cardBoxSet.AddNewCard(card, now);

            // Assert
            Assert.Single(firstCardBox.Cards);
            Assert.Empty(secondCardBox.Cards);
            Assert.Equal(firstCardBox.Id, card.CardBoxId);
            Assert.Equal(now, card.CardBoxChangedDate);
        }
Exemplo n.º 10
0
        /// <summary>
        /// When a CardBox is clicked, move to the opposite panel.
        /// </summary>
        void CardBox_Click(object sender, EventArgs e)
        {
            // Convert sender to a CardBox
            CardBox aCardBox = sender as CardBox;

            // If the conversion worked
            if (aCardBox != null)
            {
                // if the card is in the player panel...
                if (aCardBox.Parent == pnlPlayer1)
                {
                    pnlPlayer1.Controls.Remove(aCardBox); // Remove the card from the home panel
                    pnlMain.Controls.Add(aCardBox);       // Add the control to the play panel
                }
                else
                {   // otherwise...
                    // Remove the card from the play panel
                    pnlMain.Controls.Remove(aCardBox);
                    // Add the control to the home panel
                    pnlPlayer1.Controls.Add(aCardBox);
                }
                // Realign the cards
                RealignCards(pnlPlayer1);
                RealignCards(pnlMain);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// When a CardBox is clicked, move to the opposite panel.
        /// </summary>
        void CardBox_Click(object sender, EventArgs e)
        {
            if (playerTurn)
            {
                // Convert sender to a CardBox
                CardBox aCardBox = sender as CardBox;

                // If the conversion worked
                if (aCardBox != null)
                {
                    // If the card
                    if (aCardBox.Parent == pnlPlayerHand)
                    {
                        // Remove the card from the home panel
                        pnlPlayerHand.Controls.Remove(aCardBox);

                        // Resize the CardBox - not sure why this is needed
                        aCardBox.Size = cardSize;

                        // Add the control to the play panel
                        pnlPlayArea.Controls.Add(aCardBox);

                        // Call the opponent's method to start their turn
                        playerTurn = false;

                        // Realign the cards
                        RealignCards(pnlPlayerHand);
                        RealignCards(pnlPlayArea);

                        // AI's response
                        AITurn();
                    }
                }
            }
        }
Exemplo n.º 12
0
        public void AddCardBoxTest()
        {
            try
            {
                ErrorReporter.IsUnitTesting = true;

                UI a = new UI();

                CardBox[] controls = new CardBox[1];
                CardBox   card     = new CardBox(SomeCardGamesAPITests.TestResources.TriangleGrid, new System.Drawing.Size(10, 10), new System.Drawing.Point(100, 100));

                controls[0] = card;

                a.ConstructMe((object)new Form(), controls, true);

                if (a == null | a.Controls[0] != card)
                {
                    Assert.Fail();
                }
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        ///     Adds a card box to the set
        /// </summary>
        /// <param name="cardBox">A card box to add</param>
        /// <exception cref="DomainException.CardBoxSetIdMismatchException">
        ///     Throws if the card box's set id doesn't
        ///     match with the set's id
        /// </exception>
        /// <exception cref="DomainException.CardBoxAlreadyInSetException">
        ///     Throws if a card box with the same id is
        ///     already in the set
        /// </exception>
        /// <exception cref="DomainException.CardBoxLevelAlreadyExistException">
        ///     Throws if a card box with the same level
        ///     is already in the set
        /// </exception>
        /// <exception cref="DomainException.DecreasingRevisionDelayException">
        ///     Throws if there exists a card box in the
        ///     set with level lesser than the added card box but its revision delay is greater than the added card box has
        /// </exception>
        public void AddCardBox(CardBox cardBox)
        {
            if (cardBox.SetId != Id)
            {
                throw new DomainException.CardBoxSetIdMismatchException();
            }

            if (_cardBoxes.Count > 0)
            {
                if (_cardBoxes.Any(c => c.Id == cardBox.Id))
                {
                    throw new DomainException.CardBoxAlreadyInSetException();
                }

                if (_cardBoxes.Any(c => c.Level == cardBox.Level))
                {
                    throw new DomainException.CardBoxLevelAlreadyExistException();
                }

                if (_cardBoxes.Any(c => c.Level < cardBox.Level &&
                                   c.RevisionDelay > cardBox.RevisionDelay))
                {
                    throw new DomainException.DecreasingRevisionDelayException();
                }
            }

            _cardBoxes.Add(cardBox);
        }
Exemplo n.º 14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="theCardBox"></param>
 /// <param name="toPanel"></param>
 /// <param name="fromPanel"></param>
 private void MoveCard(CardBox theCardBox, Panel toPanel, Panel fromPanel)
 {
     toPanel.Controls.Add(theCardBox);
     fromPanel.Controls.Remove(theCardBox);
     RealignCards(toPanel);
     RealignCards(fromPanel);
 }
Exemplo n.º 15
0
        public virtual void DeckViewer_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetData(typeof(CardBox)) != null)
            {
                System.Console.WriteLine("DragDrop");
                //int cardHashCode = Convert.ToInt32(e.Data.GetData(DataFormats.Text).ToString());
                //Card draggedCard = new Card(cardHashCode);
                CardBox draggedCard = (CardBox)e.Data.GetData(typeof(CardBox));

                if (draggedCard != null && draggedCard.Parent.GetType() == typeof(DeckPileViewer))
                {
                    DeckViewer fromPanel = draggedCard.Parent as DeckPileViewer;
                    DeckViewer toPanel   = sender as DeckViewer;

                    if (toPanel != null && fromPanel != null)
                    {
                        if (toPanel != fromPanel)
                        {
                            fromPanel.RemoveCard(draggedCard.Card);
                            toPanel.AddCard(draggedCard.Card);
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
        public override void DeckViewer_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetData(typeof(CardBox)) != null && this.Controls.Count < 12)
            {
                System.Console.WriteLine("DragDrop");
                //int cardHashCode = Convert.ToInt32(e.Data.GetData(DataFormats.Text).ToString());
                //Card draggedCard = new Card(cardHashCode);
                CardBox draggedCard = (CardBox)e.Data.GetData(typeof(CardBox));

                if (draggedCard != null && draggedCard.Parent.GetType() == typeof(DeckViewer))
                {
                    DeckViewer fromPanel = draggedCard.Parent as DeckViewer;
                    BoutViewer toPanel   = sender as BoutViewer;

                    if (toPanel != null && fromPanel != null)
                    {
                        if (toPanel != fromPanel)
                        {
                            if (toPanel.canPlaceCard(draggedCard.Card))
                            {
                                fromPanel.RemoveCard(draggedCard.Card);
                                toPanel.AddCard(draggedCard.Card);
                            }
                        }
                    }
                }
                //this.AddCard(draggedCard);
                //Card newCard = (Card)draggedCard.Card.Clone();
                //(draggedCard.Parent as DeckViewer).RemoveCard(draggedCard.Card);
                //this.AddCard(newCard);
            }
        }
Exemplo n.º 17
0
    private void jumpPage(int cardId)
    {
        CardBox    desCardBox  = GameObject.Find("CardsBox").GetComponent <CardBox>();
        List <int> enableCards = desCardBox.enableCards;
        int        cardIdx     = enableCards.IndexOf(cardId);

        desCardBox.pageIdx = cardIdx / desCardBox.eachPageNum;
        desCardBox.loadCurPageCards();
    }
 public void MonochromeTest()
 {
     var wordCard = new WordCard("ABC");
     Assert.False(wordCard.Monochrome);
     var CardBox = new CardBox();
     CardBox.Items.Add(wordCard);
     Assert.False(wordCard.Monochrome);
     wordCard.IsClickable = false;
     Assert.True(wordCard.Monochrome);
 }
Exemplo n.º 19
0
 /// <summary>
 /// Initiate a card move on the start of a drag.
 /// </summary>
 private void CardBox_MouseDown(object sender, MouseEventArgs e)
 {
     // Set dragCard
     dragCard = sender as CardBox;
     // If the conversion worked
     if (dragCard != null)
     {
         // Set the data to be dragged and the allowed effect dragging will have.
         DoDragDrop(dragCard, DragDropEffects.Move);
     }
 }
Exemplo n.º 20
0
 public override void DeckViewer_DragEnter(object sender, DragEventArgs e)
 {
     if (e.Data.GetData(typeof(CardBox)) != null && this.Controls.Count < 12)
     {
         CardBox draggedCard = (CardBox)e.Data.GetData(typeof(CardBox));
         if (draggedCard.Parent.GetType() == typeof(DeckViewer) && (string)draggedCard.Parent.Tag != "enemyDeck")
         {
             e.Effect = DragDropEffects.Move;
         }
     }
 }
Exemplo n.º 21
0
        /// <summary>
        /// CardBox control shrinks to regular size when the mouse leaves.
        /// </summary>
        void CardBox_MouseLeave(object sender, EventArgs e)
        {
            // Convert sender to a CardBox
            CardBox aCardBox = sender as CardBox;

            // If the conversion worked
            if (aCardBox != null)
            {
                aCardBox.Size = regularSize; // resize the card back to regular size
                aCardBox.Top  = POP;         // move the card down to accommodate for the smaller size.
            }
        }
Exemplo n.º 22
0
        /// <summary>
        ///  CardBox controls grow in size when the mouse is over it.
        /// </summary>
        void CardBox_MouseEnter(object sender, EventArgs e)
        {
            // Convert sender to a CardBox
            CardBox aCardBox = sender as CardBox;

            // If the conversion worked
            if (aCardBox != null)
            {
                aCardBox.Size = new Size(regularSize.Width + POP, regularSize.Height + POP); // Enlarge the card for visual effect
                aCardBox.Top  = 0;                                                           // move the card to the top edge of the panel.
            }
        }
Exemplo n.º 23
0
 public bool AddChild(CardBox box)
 {
     if (Boxs.Count >= GameConfig.CardCount)
     {
         return false;
     }
     MainGameScene.ShardMainGame().CardShow.AddChild(box.ICOSprite);
     AddChild(box.Sprite);
     box.SetPoint(Boxs.Count);
     Boxs.Add(box);
     return true;
 }
Exemplo n.º 24
0
        public virtual void DeckViewer_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetData(typeof(CardBox)) != null)
            {
                CardBox draggedCard = (CardBox)e.Data.GetData(typeof(CardBox));

                if (draggedCard.Parent.GetType() == typeof(DeckPileViewer))
                {
                    e.Effect = DragDropEffects.Move;
                }
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// When a drag is dropped on a card, drop on the parent panel instead.
        /// </summary>
        void CardBox_DragDrop(object sender, DragEventArgs e)
        {
            // Convert sender to a CardBox
            CardBox aCardBox = sender as CardBox;

            // If the conversion worked
            if (aCardBox != null)
            {
                // Do the operation on the parent panel instead
                Panel_DragDrop(aCardBox.Parent, e);
            }
        }
Exemplo n.º 26
0
 public void ConstructMeTest()
 {
     try
     {
         ErrorReporter.IsUnitTesting = true;
         Form    a = this.GenerateForm(true);
         CardBox b = new CardBox(SomeCardGamesAPITests.TestResources.TriangleGrid, new System.Drawing.Size(10, 10), new System.Drawing.Point(10, 10));
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
Exemplo n.º 27
0
        public void CardBoxTest2()
        {
            try
            {
                Error.ErrorReporter.IsUnitTesting = true;

                CardBox a = new CardBox(SomeCardGamesAPITests.TestResources.TriangleGrid, new System.Drawing.Size(100, 100), new System.Drawing.Point(10, 10));
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
Exemplo n.º 28
0
        public void CardBoxTest()
        {
            try
            {
                Error.ErrorReporter.IsUnitTesting = true;

                CardBox a = new CardBox();
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
        public void GetTextsTest()
        {
            var cardBox = new CardBox() { Width = 1000, };
            var wordCard1 = new WordCard("abc") { Size = new SizeF(100, 100), };
            var wordCard2 = new WordCard("def") { Size = new SizeF(100, 100), };
            var wordCard3 = new WordCard("fg") { Size = new SizeF(100, 100), IsVisible = false, IsClickable = true, };
            var wordCard4 = new WordCard("hi") { Size = new SizeF(100, 100), IsVisible = true, IsClickable = false, };

            cardBox.Items.Add(wordCard1);
            cardBox.Items.Add(wordCard2);
            cardBox.Items.Add(wordCard3);
            cardBox.Items.Add(wordCard4);
            CollectionAssert.AreEqual(new [] { "abc", "def", "hi" }, cardBox.GetTexts());
        }
Exemplo n.º 30
0
        //点击增加卡付,显示支付方式小窗
        private void btnAdd_Click(object sender, EventArgs e)
        {
            box = new CardBox();

            //默认卡付金额,总计减去现金支付和已有卡付支付金额
            box.MoneyTotal = ZJ - Convert.ToDecimal(txtPayCash.Text == "" ? "0" : txtPayCash.Text) - CardPayed;

            //待付的金额大于0才显示卡付面板
            if (box.MoneyTotal > 0)
            {
                cardBoxShow();
                isAddorAlter = true;
            }
        }
Exemplo n.º 31
0
        /// <summary>
        /// Sets up the trump card and it's related cardbox
        /// </summary>
        /// <param name="deck"></param>
        private void SetupTrumpCard(Deck deck)
        {
            Random randomNumber = new Random();

            Card cardChosen = new Card(deck[randomNumber.Next(deck.Count)].GetHashCode());

            cdbTrumpCard          = new CardBox(cardChosen, false, Orientation.Horizontal);
            cdbTrumpCard.Name     = "cdbTrumpCard";
            cdbTrumpCard.FaceUp   = true;
            cdbTrumpCard.Size     = new Size(87, 141);
            cdbTrumpCard.Location = new Point(55, 380);
            Card.trump            = cdbTrumpCard.Card.Suit;
            this.Controls.Add(this.cdbTrumpCard);
            this.Controls["cdbTrumpCard"].BringToFront();
        }
Exemplo n.º 32
0
        //点击修改所选卡付,显示支付方式小窗
        private void btnAlter_Click(object sender, EventArgs e)
        {
            decimal moneyTotal = ZJ - Convert.ToDecimal(txtPayCash.Text == "" ? "0" : txtPayCash.Text) - CardPayed + payedCardList[cardIndex].je;


            box = new CardBox(payedCardList[cardIndex], moneyTotal);

            //修改状态
            //if (isAddorAlter)

            cardBoxShow();
            box.txtCardCash.Focus();     //获得焦点
            box.txtCardCash.SelectAll(); //全选
            isAddorAlter = false;
        }
Exemplo n.º 33
0
        public void RemoveCardBox_PassNotContainedCardBox_ThrowsCardBoxNotFoundException()
        {
            // Arrange
            var cardBoxSet = new CardBoxSet(
                Guid.NewGuid(),
                new CardBoxSetOwnerId(Guid.NewGuid()),
                new CardBoxSetName("Test Name"),
                new CardBoxSetLanguage("Russian", _ => true),
                new CardBoxSetLanguage("Finnish", _ => true));

            var cardBox = new CardBox(Guid.NewGuid(), cardBoxSet.Id, new CardBoxLevel(1),
                                      new CardBoxRevisionDelay(3));

            // Act & Assert
            Assert.Throws <DomainException.CardBoxNotFoundInSetException>(() => cardBoxSet.RemoveCardBox(cardBox.Id));
        }
        public void Test1()
        {
            var cardBox = new CardBox() { Width = 1000, };
            var wordCard1 = new WordCard("abc") { Size = new SizeF(100, 100), };
            var wordCard2 = new WordCard("def") { Size = new SizeF(100, 100), };
            var label = new EigoTestLabelItem();

            Assert.Throws<ArgumentException>(() => { cardBox.Items.Add(label); });

            cardBox.Items.Add(wordCard1);
            cardBox.Items.Add(wordCard2);

            Assert.AreEqual(0, wordCard1.Location.X);
            Assert.AreEqual(0, wordCard1.Location.Y);
            Assert.AreEqual(5 + 100 + 5 + 10, wordCard2.Location.X);
            Assert.AreEqual(0, wordCard2.Location.Y);
        }
        public void 折り返し機能のテスト()
        {
            var wordCard1 = new WordCard("a")
            {};
            var wordCard2 = new WordCard("b")
            {};
            var wordCard3 = new WordCard("c")
            {};
            foreach (var wordCard in new [] { wordCard1, wordCard2, wordCard3 })
            {
                wordCard.PaddingLeft = wordCard.PaddingTop = wordCard.PaddingRight = wordCard.PaddingBottom = 0;
                wordCard.MarginLeft = wordCard.MarginTop = wordCard.MarginRight = wordCard.MarginBottom = 0;
                wordCard.Width = 10;
                wordCard.Height = 100;
                wordCard.MarginRight = 5;
                wordCard.MarginBottom = 50;
            }
            var cardBox = new CardBox()
            {
                PaddingLeft = 0,
                PaddingTop = 0,
                PaddingRight = 0,
                PaddingBottom = 0,
                MarginLeft = 0,
                MarginTop = 0,
                MarginRight = 0,
                MarginBottom = 0,
                Width = 40, Height = 1000,
            };

            cardBox.Items.Add(wordCard1);
            cardBox.Items.Add(wordCard2);
            cardBox.Items.Add(wordCard3);

            Assert.AreEqual(0, wordCard1.Left);
            Assert.AreEqual(0, wordCard1.Top);
            Assert.AreEqual(15, wordCard2.Left);
            Assert.AreEqual(0, wordCard2.Top);
            Assert.AreEqual(0, wordCard3.Left);
            Assert.AreEqual(150, wordCard3.Top);

            cardBox.上寄せ = false;

            Assert.AreEqual(0, wordCard1.Left);
            Assert.AreEqual(700, wordCard1.Top);
            Assert.AreEqual(15, wordCard2.Left);
            Assert.AreEqual(700, wordCard2.Top);
            Assert.AreEqual(0, wordCard3.Left);
            Assert.AreEqual(850, wordCard3.Top);
        }
Exemplo n.º 36
0
        public TouchLayer()
        {
            Touch = this;
            IsTouchEnable = true;

            MGSprite nShop = MGSprite.MGSpriteWithSpriteFrameName("商店.png");
            MGSprite _nShop = MGSprite.MGSpriteWithSpriteFrameName("商店.png");
            _nShop.Scale = new Vector2(.95f, .95f);
            item = MGMenuItemSprite.itemFromNormalSprite(nShop, _nShop, null, (sender) =>
            {
                var menuitem = sender as MGMenuItemSprite;
                if (menuitem.Tag == 1)
                {
                    MGSprite sShop = MGSprite.MGSpriteWithSpriteFrameName("商店2.png");
                    MGSprite _sShop = MGSprite.MGSpriteWithSpriteFrameName("商店2.png");
                    _sShop.Scale = new Vector2(.95f, .95f);
                    menuitem.NormalImage = sShop;
                    menuitem.SelectedImage = _sShop;
                    if (ShopCallBack1 != null)
                    {
                        ShopCallBack1.Invoke(menu);
                        Istouch = false;
                        MainGameScene.ShardMainGame().CoverLayer.Visible = true;
                        //BugBtn.Visible = true;
                        MainGameLogic.SharedMainGameLogic().GamePause();
                    }
                    menuitem.Tag = 2;
                }
                else
                {
                    MGSprite shop = MGSprite.MGSpriteWithSpriteFrameName("商店.png");
                    MGSprite _shop = MGSprite.MGSpriteWithSpriteFrameName("商店.png");
                    _shop.Scale = new Vector2(.95f, .95f);
                    menuitem.NormalImage = shop;
                    menuitem.SelectedImage = _shop;
                    if (ShopCallBack2 != null)
                    {
                        Istouch = true;
                        ShopCallBack2.Invoke(menu);
                        MainGameScene.ShardMainGame().CoverLayer.Visible = false;
                        _buyBtn.Visible = false;
                        MainGameLogic.SharedMainGameLogic().GameResume();
                    }
                    menuitem.Tag = 1;
                }
            });
            item.Tag = 1;
            menu = MGMenu.menuWithItems(item);
            AddChild(menu);
            menu.Position = new Vector2(40, 500);

            nsp = MGSprite.MGSpriteWithSpriteFrameName("购买1.png");
            _nsp = MGSprite.MGSpriteWithSpriteFrameName("购买1.png");
            _nsp.Scale = new Vector2(.95f, .95f);
            ssp = MGSprite.MGSpriteWithSpriteFrameName("购买2.png");
            _ssp = MGSprite.MGSpriteWithSpriteFrameName("购买2.png");
            _ssp.Scale = new Vector2(.95f, .95f);
            _buymenu = MGMenuItemSprite.itemFromNormalSprite(nsp, _nsp, null, (sender) =>
            {
                if (_paperInfo != null)
                {
                    _paperInfo.Sprite.SetColor(255, 255, 255);
                    if (CardShowLayer.SharedCardShow().Boxs.Count < GameConfig.CardCount)
                    {
                        if (GameConfig.Money >= _paperInfo.Price)
                        {
                            if (GameConfig.ChangeMoney(-_paperInfo.Price))
                            {
                                var card = new CardBox(_paperInfo.Id);
                                card.SetPoint(new Vector2(132 + 7 * 76, 713));
                                CardShowLayer.SharedCardShow().AddChild(card);
                            }
                        }
                    }
                    _paperInfo = null;
                    _buymenu.NormalImage = nsp;
                    _buymenu.NormalImage = _nsp;
                }
            });
            _buyBtn = MGMenu.menuWithItems(_buymenu);
            AddChild(_buyBtn);
            _buyBtn.Position = new Vector2(240, 90);
            _buyBtn.Visible = false;
        }
Exemplo n.º 37
0
 public void RemoveChild(CardBox box)
 {
     MainGameScene.ShardMainGame().CardShow.RemoveChild(box.ICOSprite);
     RemoveChild(box.Sprite);
     Boxs.Remove(box);
 }