Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  card game - how to find who won?  (Read 1450 times)
0 Members and 1 Guest are viewing this topic.
Offline 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


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.
Offline 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?

Offline stef569

Junior Devvie

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

Using the Vector is fine  Cool

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:

public Enum gameState  { WON, DRAW, NOWINNER}
private gameState myState;
logic() {
if oneplayerone myState = gameState. WON
else if twoplayerswon mystate = gameState.DRAW
else myState.NOWINNER
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline 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?
Offline 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):

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  

EgonOlsen (44 views)
2018-06-10 19:43:48

EgonOlsen (24 views)
2018-06-10 19:43:44

EgonOlsen (46 views)
2018-06-10 19:43:20

DesertCoockie (201 views)
2018-05-13 18:23:11

nelsongames (126 views)
2018-04-24 18:15:36

nelsongames (125 views)
2018-04-24 18:14:32

ivj94 (866 views)
2018-03-24 14:47:39

ivj94 (127 views)
2018-03-24 14:46:31

ivj94 (770 views)
2018-03-24 14:43:53

Solater (142 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!