Example #1
0
        }// end UpdateDiscardPile

        /// <summary>
        /// Calls DisplayGuiHand to update the cards displayed in all of the seven tableaus.
        /// </summary>
        private void UpdateTableauPiles()
        {
            for (int tableau = 0; tableau < NUM_OF_TABLEAU; tableau++)
            {
                DisplayGuiHand(Solitaire.GetTableau(tableau), tableauPiles[tableau], Solitaire.GetNumCardsFaceUp(tableau), tableau);
            }
        }// end UpdateTableauPiles
Example #2
0
        /// <summary>
        /// Updates the Player board table 1 with a new set of picture
        /// boxes based on the hands taken from the solitaire class
        /// </summary>
        private void UpdatePlayPiles1()
        {
            int        playPileIndex = 0;
            PictureBox pBox;
            int        revealed = Solitaire.GetRevealed()[playPileIndex];
            Hand       hand     = Solitaire.GetPlayHand(playPileIndex);
            int        handSize = hand.GetCount();

            for (int i = 0; i < handSize; i++)
            {
                Card card = hand.GetCard(i);
                pBox          = new PictureBox();
                pBox.SizeMode = PictureBoxSizeMode.AutoSize;
                pBox.Dock     = DockStyle.Fill;
                if (i < revealed)
                {
                    pBox.Image = Images.GetBackOfCardImage();
                }
                else
                {
                    pBox.Image = Images.GetCardImage(card);
                }
                PlayPilesPB1[i]        = pBox;
                PlayPilesPB1[i].Click += new EventHandler(PlayPBox1_Click);
                PlayPilesPB1[i].Tag    = Solitaire.GetPlayHand(playPileIndex).GetCard(i);
            }
        }
 public StackCommand(GameObject selectedCard, GameObject target, Vector3 originPosition)
 {
     this.selectedCard = selectedCard;
     this.target       = target;
     this.oldPosition  = originPosition;
     this.oldParent    = selectedCard.transform.parent;
     this.solitaire    = Solitaire.Instance;
 }
 public FreeCellCommand(int freeCellIndx, GameObject selectedCard, Vector3 originPosition)
 {
     this.freeCellIndx = freeCellIndx;
     this.selectedCard = selectedCard;
     this.solitaire    = Solitaire.Instance;
     this.oldPosition  = originPosition;;
     this.oldParent    = selectedCard.transform.parent;
 }
 private void UpdateSuitThree()
 {
     if (Solitaire.GetSuitThreeCount() != 0)
     {
         PictureBox cardImg = UpdateSinglePictureBox(Solitaire.GetSuitPile(3));
         SuitPile3.Image = cardImg.Image;
         SuitPile3.Tag   = cardImg.Tag;
     }
 }
 public EmptyCascadeCommand(GameObject selectedCard, GameObject emptyCascade, Vector3 originPosition)
 {
     this.selectedCard = selectedCard;
     this.emptyCascade = emptyCascade;
     this.solitaire    = Solitaire.Instance;
     //record oldposition and parent
     this.oldPosition = originPosition;
     this.oldParent   = selectedCard.transform.parent;
 }
 private void UpdateSuitTwo()
 {
     if (Solitaire.GetSuitTwoCount() != 0)
     {
         PictureBox cardImg = UpdateSinglePictureBox(Solitaire.GetSuitPile(2));
         SuitPile2.Image = cardImg.Image;
         SuitPile2.Tag   = cardImg.Tag;
     }
 }
 private void UpdateSuitFour()
 {
     if (Solitaire.GetSuitFourCount() != 0)
     {
         PictureBox cardImg = UpdateSinglePictureBox(Solitaire.GetSuitPile(4));
         SuitPile4.Image = cardImg.Image;
         SuitPile4.Tag   = cardImg.Tag;
     }
 }
 private void DiscardCard_Click(object sender, EventArgs e)
 {
     //Grabs the top card and sets it to be played
     if (Solitaire.GetDiscardCount() != 0)
     {
         PictureBox clickedCard = (PictureBox)sender;
         Card       card        = (Card)clickedCard.Tag;
         playCard(card, LOC_DISCARD);
     }
 }
Example #10
0
 public FoundationCommand(GameObject selected, Vector3 oldPosition, int foundationIndx)
 {
     this.solitaire         = Solitaire.Instance;
     this.selectedCard      = selected;
     this.oldPosition       = oldPosition;
     this.foundationIndx    = foundationIndx;
     this.oldParent         = selectedCard.transform.parent;
     this.oldFoundationFace = selected.name;
     this.newFoundationFace = solitaire.NextCardFace(oldFoundationFace);
 }
 /// <summary>
 /// Initialise Form
 /// </summary>
 public SolitaireForm()
 {
     InitializeComponent();
     Solitaire.SetUpGame();
     // Set up Image and set the Discard Pile wait for Click Event
     DrawPile.Image     = Images.GetBackOfCardImage();
     DiscardPile.Click += new EventHandler(DiscardCard_Click);
     // Update Table
     UpdateDiscard();
     UpdateAllTables();
 }
Example #12
0
 private void Awake()
 {
     if (GameManager == null)
     {
         GameManager = this;
     }
     if (GameManager != this)
     {
         Destroy(this);
     }
 }
        // Some useful function need to manipulate the card

        private void CardFlip_Click(object sender, EventArgs e)
        {
            PictureBox clickedCard = (PictureBox)sender;
            //Grabs the table number from the card to help determine which table the card is from
            int tableNum = (int)clickedCard.Tag;

            if (Solitaire.CheckTurnOver(tableNum) == true)
            {
                //resets all the table graphics
                UpdateAllTables();
            }
        }
Example #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            Solitaire s = new Solitaire(textBox3.Text);

            if (radioButton1.Checked)
            {
                textBox2.Text = s.Encrypt(textBox1.Text);
            }
            if (radioButton2.Checked)
            {
                textBox2.Text = s.Decrypt(textBox1.Text);
            }
        }
Example #15
0
    // Awake is called when the script instance is being loaded.
    void Awake()
    {
        PrintDebugMsg("Loaded.");

        if (Solitaire.singleton == null)
        {
            singleton = this;
        }
        else
        {
            PrintErrorDebugMsg("Two or more \"Solitaire\" singletons detected!");
        }
    }
Example #16
0
        private void CurrentPB_Click(object sender, EventArgs e)
        {
            bool currentlySelected = Solitaire.IsSelectedSet();

            if (currentlySelected)
            {
                MessageBox.Show(errorDiscard);
            }
            else
            {
                //draw function yet to be implemented
            }
        }
 //Method used for empty tables to play a king
 private void BlankTable_Click(object sender, EventArgs e)
 {
     if ((cardsClicked == 1) && (startCard.GetFaceValue() == FaceValue.King))
     {
         PictureBox clickedTable = (PictureBox)sender;
         int        tableNum     = (int)clickedTable.Tag;
         Solitaire.PlayKing(startCard, startLocation, tableNum);
         //resets the click count to start a new play
         cardsClicked = 0;
         //Update all graphics
         UpdateAll();
     }
 }
Example #18
0
        /// <summary>
        /// Displays the images for the Player Board 7
        /// </summary>
        private void DisplayPlayPiles7()
        {
            int playPileIndex = 6;

            PlayBoard7.Controls.Clear();
            Hand hand     = Solitaire.GetPlayHand(playPileIndex);
            int  handSize = hand.GetCount();

            for (int i = 0; i < handSize; i++)
            {
                PlayBoard7.Controls.Add(PlayPilesPB7[i]);
            }
        }
 private void UpdateDiscard()
 {
     //grab the last card (if any) and display it
     if (Solitaire.GetDiscardCount() != 0)
     {
         PictureBox cardImg = UpdateSinglePictureBox(Solitaire.GetTopDiscard());
         DiscardPile.Image = cardImg.Image;
         DiscardPile.Tag   = cardImg.Tag;
     }
     else
     {
         DiscardPile.Image = null;
     }
 }
 /// <summary>
 /// Method to move the card after check it is a valid move or not
 /// </summary>
 /// <param name="card"></param>
 /// <param name="location"></param>
 private void playCard(Card card, string location)
 {
     //If card is an ace,
     if ((card.GetFaceValue() == FaceValue.Ace) && (location != LOC_SUIT))
     {
         Solitaire.PlayAce(card, location);
         //resets click count to start new move
         cardsClicked = 0;
         UpdateAll();
     }
     else
     {
         //if this is the start of a move
         if (cardsClicked == 0)
         {
             startCard     = card;
             startLocation = location;
             cardsClicked++;
             //Else make move
         }
         else
         {
             destinationCard = card;
             destination     = location;
             //Check if move is valid, and if so make it
             if (Solitaire.MoveCard(startCard, destinationCard, startLocation, destination) == false)
             {
                 //trying to place on the discard pile
                 if (destination == LOC_DISCARD)
                 {
                     MessageBox.Show("Cannot place card onto Discard pile");
                     //other invaild move
                 }
                 else
                 {
                     MessageBox.Show("ERROR - Move not allowed - Cannot place card onto this card");
                 }
                 //check if game over
             }
             else if ((destination == LOC_SUIT) && (Solitaire.HasWon() == true))
             {
                 MessageBox.Show("Congratulations! You won the game!", "You Win!", MessageBoxButtons.OK);
                 this.Close();
             }
             //reset for next move and update graphics
             cardsClicked = 0;
             UpdateAll();
         }
     }
 }
Example #21
0
 /// <summary>
 /// Sets up the form from scratch, including the solitaire class
 /// all panels and variables
 /// </summary>
 public void setupForm()
 {
     PlayPilesPB1 = new PictureBox[maxNumberOfCards];
     PlayPilesPB2 = new PictureBox[maxNumberOfCards];
     PlayPilesPB3 = new PictureBox[maxNumberOfCards];
     PlayPilesPB4 = new PictureBox[maxNumberOfCards];
     PlayPilesPB5 = new PictureBox[maxNumberOfCards];
     PlayPilesPB6 = new PictureBox[maxNumberOfCards];
     PlayPilesPB7 = new PictureBox[maxNumberOfCards];
     DeckPB.Image = Images.GetBackOfCardImage();
     Solitaire.SetupGame();
     CurrentPB.Image = Images.GetCardImage(Solitaire.GetCurrent().GetLastCardInPile());
     RefreshScreen();
 }
Example #22
0
    // Start is called before the first frame update
    void Start()
    {
        solitaire = FindObjectOfType <Solitaire>();

        foreach (Sprite face in solitaire.cardFaces)
        {
            if (this.name == face.name)
            {
                cardFace = face;
            }
        }

        spriteRenderer = GetComponent <SpriteRenderer>();
        selectable     = GetComponent <Selectable>();
    }
Example #23
0
        }// End DisplayGuiHand

        /// <summary>
        /// Updates the cards displayed in the suit piles.
        /// </summary>
        private void UpdateSuitPiles()
        {
            for (int suitPile = 0; suitPile < NUM_OF_SUITS; suitPile++)
            {
                Card card;

                if (Solitaire.GetSuitPileCount(suitPile) != 0)
                {
                    card = Solitaire.GetLastCardSuitPile(suitPile);
                    suitPiles[suitPile].Image = Images.GetCardImage(card);

                    suitPiles[suitPile].Tag = card;
                }
            }
        }// end UpdateSuitPiles
Example #24
0
    // Start is called before the first frame update
    void Start()
    {
        selectable = false;
        List <string> deck = Solitaire.GenerateDeck();

        solitaire = FindObjectOfType <Solitaire>();
        int index = deck.IndexOf(this.name);

        this.GetComponent <SpriteRenderer>().sprite = solitaire.cards[index];
        // change the card to be selectable if it's the last in the list
        foreach (List <string> cascade in solitaire.cascades)
        {
            if (cascade.Last <string>() == this.name)
            {
                selectable = true;
                CardFace[] cardFaces = this.GetComponentsInParent <CardFace>();
                foreach (CardFace cardFace in cardFaces)
                {
                    cardFace.selectable = true;
                }
            }
        }
        names = this.name.Split(' ');
        suit  = names[0];
        if (names[1] != "J" && names[1] != "Q" && names[1] != "K" && names[1] != "A")
        {
            value = int.Parse(names[1]);
        }
        else
        {
            if (names[1] == "A")
            {
                value = 1;
            }
            if (names[1] == "J")
            {
                value = 11;
            }
            if (names[1] == "Q")
            {
                value = 12;
            }
            if (names[1] == "K")
            {
                value = 13;
            }
        }
    }
Example #25
0
        }// end UpdateTableauPiles

        /// <summary>
        /// Gets location of where Card has come from and where the user wants to place the card
        /// Calls game logic functions to attempt to place card according to user selection
        /// Updates disply on successful placement or displays error message
        /// </summary>
        /// <param name="clickedCard">Card the user has selected to move or move card to</param>
        /// <param name="location">Location from where the user selected the card</param>
        private void TryToPlayCard(Card clickedCard, string location)
        {
            // Moves card directly to 1 of the suitPiles without needing addition click
            if (clickedCard != null && clickedCard.GetFaceValue() == FaceValue.Ace && location != LOCATION_SUIT)
            {
                Solitaire.PlayAce(clickedCard, location);
                firstClick = false;

                UpdateDiscardPile();
                UpdateSuitPiles();
                UpdateTableauPiles();
            }
            else
            {
                // If start of new move
                if (firstClick == false)
                {
                    firstCard     = clickedCard;
                    startLocation = location;
                    firstClick    = true;
                    // If second click in move
                }
                else
                {
                    secondCard   = clickedCard;
                    destLocation = location;

                    // Check if valid move here
                    if (!Solitaire.TryMakeMove(firstCard, secondCard, startLocation, destLocation))
                    {
                        // Error messages for invalid moves
                        InvalidMoveError(destLocation);
                    }
                    else if (Solitaire.CheckGameVictory())
                    {
                        MessageBox.Show("Congratulations, you won!");
                    }

                    firstClick = false;

                    UpdateDiscardPile();
                    UpdateSuitPiles();
                    UpdateTableauPiles();
                }
            }
        }// end TryToPlayCard
        public JsonResult AddChains(Solitaire solitaire, ChainsGroup[] chainsGroups)
        {
            var       ids         = "";
            Solitaire solitaireIf = solitaireService.SelectSolitaire().Where(m => m.SolitaireClassID == solitaire.SolitaireClassID).FirstOrDefault();

            if (solitaireIf != null)
            {
                return(Json(""));
            }
            List <ChainsGroup> groupListToAdd = new List <ChainsGroup>();

            foreach (var item in chainsGroups)
            {
                if (item.GropCrew != null)
                {
                    groupListToAdd.Add(item);
                }
            }

            int j = chainsGroupService.AddChainsGroup(groupListToAdd);
            List <ChainsGroup> chainsGroupList = chainsGroupService.SelectChainsGroup().Where(m => m.ClassesId == solitaire.SolitaireClassID).ToList();

            foreach (var item in chainsGroupList)
            {
                ids += item.Id + ",";
            }
            solitaire.ChainsGroupIds = ids.Substring(0, ids.Length - 1);
            Solitaire solitaireModel = solitaireService.SelectSolitaire().LastOrDefault();

            if (solitaireModel != null)
            {
                solitaire.SoSortNumber = solitaireModel.SoSortNumber + 1;
            }
            else
            {
                solitaire.SoSortNumber = 1;
            }
            int i = solitaireService.AddSolitaire(solitaire);

            using (MySqlConnection conn = DapperHelper.Instance().GetConnection())
            {
                List <SoChains> list = conn.Query <SoChains>("up_ChainsTable", null).ToList();
                return(Json(list));
            }
        }
 private void UpdateTableauSeven()
 {
     if (Solitaire.GetTableCount(7) != 0)
     {
         tableau7Img = UpdateTableau(Solitaire.GetTable(7), Solitaire.GetTableCardsInPlay(7), 7);
         Tableau7.Controls.Clear();
         for (int i = 0; i < Solitaire.GetTableCount(7); i++)
         {
             Tableau7.Controls.Add(tableau7Img[i]);
         }
     }
     else
     {
         tableau7Img = SetBlankTableau(7);
         Tableau7.Controls.Clear();
         Tableau7.Controls.Add(tableau7Img[0]);
     }
 }
 private void UpdateTableauSix()
 {
     if (Solitaire.GetTableCount(6) != 0)
     {
         tableau6Img = UpdateTableau(Solitaire.GetTable(6), Solitaire.GetTableCardsInPlay(6), 6);
         Tableau6.Controls.Clear();
         for (int i = 0; i < Solitaire.GetTableCount(6); i++)
         {
             Tableau6.Controls.Add(tableau6Img[i]);
         }
     }
     else
     {
         tableau6Img = SetBlankTableau(6);
         Tableau6.Controls.Clear();
         Tableau6.Controls.Add(tableau6Img[0]);
     }
 }
 private void UpdateTableauFive()
 {
     if (Solitaire.GetTableCount(5) != 0)
     {
         tableau5Img = UpdateTableau(Solitaire.GetTable(5), Solitaire.GetTableCardsInPlay(5), 5);
         Tableau5.Controls.Clear();
         for (int i = 0; i < Solitaire.GetTableCount(5); i++)
         {
             Tableau5.Controls.Add(tableau5Img[i]);
         }
     }
     else
     {
         tableau5Img = SetBlankTableau(5);
         Tableau5.Controls.Clear();
         Tableau5.Controls.Add(tableau5Img[0]);
     }
 }
 private void UpdateTableauFour()
 {
     if (Solitaire.GetTableCount(4) != 0)
     {
         tableau4Img = UpdateTableau(Solitaire.GetTable(4), Solitaire.GetTableCardsInPlay(4), 4);
         Tableau4.Controls.Clear();
         for (int i = 0; i < Solitaire.GetTableCount(4); i++)
         {
             Tableau4.Controls.Add(tableau4Img[i]);
         }
     }
     else
     {
         tableau4Img = SetBlankTableau(4);
         Tableau4.Controls.Clear();
         Tableau4.Controls.Add(tableau4Img[0]);
     }
 }