School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,033 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,256 people online right now. Registration is fast and FREE... Join Now!




Updating playing cards on the form

 

Updating playing cards on the form

s20610639

14 Oct, 2009 - 03:34 AM
Post #1

New D.I.C Head
*

Joined: 21 Apr, 2009
Posts: 31



Thanked: 1 times
My Contributions
Am designing a network card game. i have this method
CODE
public void AddCardToPile(int c, int index)
        {
            PictureBox[] pbCapturedPiles = { pictureBox41, pictureBox42, pictureBox43, pictureBox44 };
            this.SuspendLayout();
            Card.Card pcard = cc.FromIntToCard(c);

            pcard.Location = pbCapturedPiles[index].Location;
            pcard.Size = new System.Drawing.Size(55, 75);
            this.Controls.Add(pcard);
            this.ResumeLayout();
        }
this method is called twice first for the card that you are capturing then for the capturing with. Moves them to a picture box for your captured cards. Problem it only redraws the one you were capturing with only. and leaves another copy of it on the table as well as the one you were suppose to b capturing is also not moved.
the above method is called from this method
CODE
public void AddToCaptured()
        {
            Card.Card c;
            Point p = new Point(xIndex, yIndex);
            c = (Card.Card)this.GetChildAtPoint(p);
            //c.Location = pbPlayingCard.Location;

            bl.DeleteOneGameTableCard(myGame.GameID, cc.CreateIntegerCard(someCard));
            bl.AddToCapturedPile(username, myGame.GameID, cc.CreateIntegerCard(c), (int)bl.GetTotalCapturedCards(username));
            DrawCardAtPile(cc.CreateIntegerCard(c), 0);
            bl.AddToCapturedPile(username, myGame.GameID, cc.CreateIntegerCard(someCard), (int)bl.GetTotalCapturedCards(username));
            
            DrawCardAtPile(cc.CreateIntegerCard(someCard), 0);

            myGame.SetWhosTurn(username);
            
        }


User is offlineProfile CardPM
+Quote Post


Aeternalis

RE: Updating Playing Cards On The Form

14 Oct, 2009 - 10:15 AM
Post #2

D.I.C Regular
***

Joined: 13 Jul, 2009
Posts: 273



Thanked: 25 times
My Contributions
The best advice I can give to you is to either post more of the code and hopefully someone will take the time to wade through it, or set breakpoints in your code and since you know what SHOULD be happening.. step through it until you see where the code departs from what should be happening.

One of the design practices people try to follow is writing clear, concise code with variables that are named by their function. Unfortunately you have not followed that practice here in your code and with it being very complex code, it makes it nearly impossible for others to figure out what the code is doing. It may be possible to figure it out if you provide a larger view of the picture, but the two functions you have provided here do not give me enough insight into the working of your software to try to debug.

Setting breakpoints and checking the variables contents would seem to be your best bet.

Another thing.. the problem doesnt seem to be an error in your code.. but perhaps an omission in your code... you say it leaves a card on the table when it shouldn't.. my advice is to locate where you are removing that card.. and set a breakpoint and walk through that part of the code. My guess is that you either won't be able to find the actual removal of the card..(it doesn't exist forgot to put it in) or there is a logical structure error causing your code to go around it instead of executing it. ( an if check with a = instead of == will do that).

good luck debugging
hope you find it.

Aet

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 08:36AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month