|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
vb card game question...please help
my question is simple but i gess it needs lots of coding...i have defined suits (S,H,C,D,AnySuit) and the game starts as AnySuit...player1 plays then second, third and forth...i have managed for all players to play a card from the same suit...i have managed for player1(human) to play differnt suit if he doesn't have any cards left from the current suit...my problems is having other players (computer) to play any card from any suit if they dont have cards from the current suit...they need to play a card of wich they have but when i do a code that will get a random card from 52 card deck then check if current player have it...if he does he will play it, if not it will random again untill it finds one...the problem is that it will random one time and wheter the player have that card or not it assumes he have it!!!! can you please try to help me...Thanx.
|
|
#2
|
|||
|
|||
|
Hi,rwahdan!Do U need a random function to generate a card number and judge 3 player who has it??If u will not,Plz say your meaning fairly!
|
|
#3
|
|||
|
|||
|
hi,
probably, if you take a look at my work you will see where the problem is...i have a rand function but everytime it gos through it, it searches for number (3)(club) only...at all time...and yes i am using randomize before the rand function....file attached. look at the function called Private Sub TakeTurn(bytPlayer As Byte) thanx. Last edited by rwahdan : December 12th, 2003 at 02:57 AM. |
|
#4
|
|||
|
|||
|
code redesign
Sounds like your generating a random card EVERY time an player needs a card and then testing to see if other players have that card and if so making another random selection.
Would it not be better, (and would overcome your problem of playing any suit) if you set up a series of arrays, one for each player & another for the deck of cards. That way you just need to test the players array for a suit to play and if the suit is not there then play any card. ie. Dim deck(3,52) as array 'column 1 records whether a card is in the deck or in a players hand ie 0=in deck number=the player number holding the card 'column 2 records the card description ie "Ace" 'column 3 records the card suit ie "Spades" or could be 1=Spades you could find a players hand by doing something like 'check the deck dim i,j as integer for i = 1 to 52 if deck(1,i) = 1 then 'player 1 is holding the card 'do something for player1 here endif etc .... next i |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > vb card game question...please help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|