Java-Gaming.org Hi !
 Featured games (88) games approved by the League of Dukes Games in Showcase (681) Games in Android Showcase (196) games submitted by our members Games in WIP (744) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 card game - how to find who won?  (Read 972 times) 0 Members and 1 Guest are viewing this topic.
Javec

Senior Newbie

 « Posted 2007-11-22 21:10:37 »

I am having problem thinking of a way to determine a winner of a hand, or if its a draw.

I have a players vector which holds Player objects.

I use

for(int i=0; i<players.size(); i++) players.get(i).bet() etc to play the game

however,

how I can go through the vector and determine a winner or find out if its a draw? One way is to sort it and get the last element , but if its a draw?

Any ideas, or my players in a vector idea is rubish? I though using a vector because you never know how many players will play and if I used conditional structure it would limit it.
Jackal von ÖRF

Junior Devvie

 « Reply #1 - Posted 2007-11-22 21:23:15 »

There are quite many card games. Which one are you making?

stef569

Junior Devvie

 « Reply #2 - Posted 2007-11-22 21:24:58 »

Using the Vector is fine

You could add a Enum to an hand object and read it out?
You calculate logic so you can set a Enum state any time.

then you read out the state and you know what happend.
This code won't compile but shows what I mean:

 1  2  3  4  5  6  7 `public Enum gameState  { WON, DRAW, NOWINNER}private gameState myState;logic() {if oneplayerone myState = gameState. WONelse if twoplayerswon mystate = gameState.DRAW else myState.NOWINNER}`
Javec

Senior Newbie

 « Reply #3 - Posted 2007-11-22 21:57:12 »

I am making a random game with basic rules for now, until I have a working set.

But I have problems setting up a betting structure. I think my Table class needs revision. I could really use a card game example in java but I cant find any. Do you have any links?
alexxz4

Junior Devvie

Projects: 1

 « Reply #4 - Posted 2007-11-27 16:15:45 »

Ive been making a lot of solitaire games. Here is an example of klondike (its not multiplayer, but its a card game):
http://www.mediafire.com/?3120zx12x13

If u just say what the conditions of winning or having a draw are, its very easy to implement them.
And try not to use Vectors or classes and stuff at first. Its just easier to code it with arrays and int's, then u might decide to use objects and vectors.

[ Motherload Unlimited looking for programmers ] [ Solitaire ]
Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 CopyableCougar4 (53 views) 2016-06-25 16:56:52 Hydroque (88 views) 2016-06-22 02:17:53 SwampChicken (89 views) 2016-06-20 13:22:57 SwampChicken (91 views) 2016-06-20 13:22:49 SwampChicken (84 views) 2016-06-20 13:22:26 Hydroque (128 views) 2016-06-15 08:22:50 Hydroque (122 views) 2016-06-13 06:40:55 DarkCart (239 views) 2016-05-29 02:30:33 Hydroque (203 views) 2016-05-26 14:45:46 Mac70 (187 views) 2016-05-24 21:16:33
 Spasi 49x theagentd 45x NegativeZero 39x KaiHH 31x LiquidNitrogen 23x princec 19x CoDi^R 15x ags1 13x ra4king 13x Opiop 10x kingroka123 10x purenickery 9x Archive 8x SHC 8x Hydroque 8x czak 7x
 Making a Dynamic Plugin Systemby Hydroque2016-06-25 00:13:25Java Data structures2016-06-13 21:22:09Java Data structures2016-06-13 21:20:42FPS Camera Tutorialby Hydroque2016-05-22 05:40:58Website offering 3D Models specifically for games for freeby vusman2016-05-18 17:23:09Website offering 3D Models specifically for games for freeby vusman2016-05-09 08:50:56Website offering 3D Models specifically for games for freeby vusman2016-05-06 11:10:21Website offering 3D Models specifically for games for freeby vusman2016-04-29 12:56:17
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org