Sign in to follow this  

Card game in java

This topic is 1950 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Would anyone like to help me make a card game in java? It's based off of an already existing card game. It's just for experience so no money will be made.

Also, not sure if this is the right section to be posted in. Please move this thread if I'm wrong :P

Edit for questions:
Would making a method for each card be the best way? There are 168 cards so it'd take some time but I can't think of another way

Share this post


Link to post
Share on other sites
Can you specify more detailed requirements for your game? Is it going to have GUI and graphical representation of each card or will it be a console game? What card game will it be based on? Will it contain multiplayer or player vs COM (or both)?

Share this post


Link to post
Share on other sites
Although i have no skill in java (only a bit in C#) i would definitely like to help you think out your concept. I would really like to hear more about the idea.

Share this post


Link to post
Share on other sites
[quote name='burnt_casadilla' timestamp='1344025247' post='4965941']
Would making a method for each card be the best way? There are 168 cards so it'd take some time but I can't think of another way
[/quote]
No, this would be horrible. It really depends on the specifics of your game, implementation, and coding style, but you would probably end up putting your cards in some sort of structure like a list, or an array, where they would each have an index. You then write a few flexible methods that can act on any given card using its index (or something like that, in Java you'd probably use the card itself instead of its index, as a class), these implement the functionality of your game.

I think if you are unable to think of another way than to duplicate code 168 times - and please don't be offended, we all started somewhere - you should probably try and get your hands dirty with common programming patterns before attempting a full-blown card game, like mini-programs such as "guess the number" or "shift a list of numbers so that every element goes down one notch and the first element goes at the end of the list" (which is actually quite instructive if you've never worked with arrays), or the Java equivalents thereof.

PS: [b]unless[/b] each card in your game happens to perform a totally different action, in which case you would of course need that many methods, but I am pretty sure this is not the case and that there is some amount of coherence (like for a solitaire game, all the cards are initially in a deck, and you pick them one by one, clearly this doesn't require more than a single "pick" method that is applicable to all the cards in the deck). Edited by Bacterius

Share this post


Link to post
Share on other sites
[quote name='burnt_casadilla' timestamp='1344091751' post='4966106']
Actually with this game, that is the case unfortunately. Each card does something different besides a few duplicate cards
[/quote]

Would this then be a traditional card game (with a deck of 52 standard playing cards) or more of a trading card game (like Magic: The Gathering)?

Share this post


Link to post
Share on other sites
i read a bit about the game and although i think it is quite interesting to make, i feel it might be somewhat difficult. would you be interested in creating a computer AI player? or create a game to play against other humans?

Share this post


Link to post
Share on other sites
well, i dont think i can help you then, since i dont have any experience in both java and networking / multiplayer.

Good luck with your efforts though!

Share this post


Link to post
Share on other sites
Looking at the card types on Wikipedia it doesn't seem too hard. But I have no experience with the rules.

Off the top of my head:

First I would make a basic Card class. This would contain only information common to all cards, and a behavior function pointer.

Then I would subclass to CardDoor and CardTreasure, because those are the two main card types in the un-expanded game.

Then I might subclass for the sub types. For instance, it says there is class cards under the Door category. You could have CardDoorRace, and it would contain information common to all Races. I'm assuming stat increases.

Any cards that have uncommon behavior can make use of their behavior function pointer to implement their own behavior.

I'll watch a youtube video and see if I can understand it better.

-edit-

So I watched and read. It doesn't look too difficult at all. Most of it, if not all, can be data driven. Just need a big switch statement for specifics. But you'd need a data file to describe all cards. Edited by Daaark

Share this post


Link to post
Share on other sites

This topic is 1950 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this