Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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 752 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

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.
Offline Jackal von ÖRF

Junior Member





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

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

Offline stef569

Junior Member





« 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:

1  
2  
3  
4  
5  
6  
7  
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 Member


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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (38 views)
2014-09-24 16:13:29

Pippogeek (29 views)
2014-09-24 16:12:22

Pippogeek (18 views)
2014-09-24 16:12:06

Grunnt (42 views)
2014-09-23 14:38:19

radar3301 (24 views)
2014-09-21 23:33:17

BurntPizza (61 views)
2014-09-21 02:42:18

BurntPizza (31 views)
2014-09-21 01:30:30

moogie (36 views)
2014-09-21 00:26:15

UprightPath (49 views)
2014-09-20 20:14:06

BurntPizza (53 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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
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!