Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Please let's avoid the discussion of creating/using a game framework or not.

I would like to create a small framework for card games or use one if it exists. Does anyone knows one?

Preferably written in Java or C#.

Thanks in advance,

share|improve this question
    
This is a pretty niche video game genre, I doubt that you'll find a framework specifically suited for it. Good luck though! –  Bloodyaugust Aug 3 '12 at 0:34
    
Pretty specific stuff for a framework to target. An event driven framework might be a decent fit for this style of game though? –  Layoric Aug 3 '12 at 1:32
    
There are so many card games I didn't thought it would be very specific. @Layoric what are you suggestions for an event driven framework? Something to reuse code which draw cards, create random decks, manage turns, compare cards would be beneficial for all card games. –  fabiopagoti Aug 3 '12 at 3:20
1  
The answer to your question would be Yes. They exist and people know about them. This is a what technology to use question and is off topic as defined by the FAQ. –  Byte56 Sep 25 '12 at 16:37
add comment

closed as not constructive by Byte56, Tetrad Sep 25 '12 at 16:50

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers

up vote 7 down vote accepted

For C#

I have used and really helpful the following card game framework

Microsoft has built a nice library/framework for Card Game

For Java

Both of them I used and will be helpful for you

share|improve this answer
add comment

I've never used them but you can try those:

http://code.google.com/p/wagic/

http://www.ethanwilder.com/node/23

http://gccg.sourceforge.net/

And for the future - Google really IS your friend :)

share|improve this answer
add comment

not a framework, but here's some java code that may be of use:

package sample;
import java.util.*;
enum Rank { 
    joker(new Character('*'),"Joker"),aceLow(new Character('a'),"Ace(low)"),deuce(new Character('2'),"Deuce"),trey(new Character('3'),"Trey"),four(new Character('4'),"Four"),five(new Character('5'),"Five"),six(new Character('6'),"Six"),seven(new Character('7'),"Seven"),eight(new Character('8'),"Eight"),nine(new Character('9'),"Nine"),ten(new Character('T'),"Ten"),jack(new Character('J'),"Jack"),queen(new Character('Q'),"Queen"),king(new Character('K'),"King"),aceHigh(new Character('A'),"Ace");
    Rank(final Character c,final String s) {
        this.c=c;
        this.s=s;
    }
    public static Rank fromInt(int n) {
        for(Rank r:Rank.values())
            if(r.ordinal()==n)
                return r;
        return null;
    }
    public static Rank fromCharacter(char c) {
        for(Rank r:Rank.values())
            if(r.c==c)
                return r;
        return null;
    }
    public static Rank[] fromCharacters(final String cards) {
        final Rank[] rank=new Rank[5];
        for(int i=0;i<5;i++)
            rank[i]=Rank.fromCharacter(cards.charAt(i));
        return rank;
    }
    public Character toCharacter() {
        return c;
    }
    public String toString() {
        return s;
    }
    public static String toString(final Rank[] rank) {
        String s="";
        for(Rank r:rank)
            s+=r.toCharacter();
        return s;
    }
    final Character c;
    final String s;
}
enum Suit {
    joker(new Character('*'),"Joker"),clubs(new Character('c'/* try character for a real dimond? */),"Club"),diamonds(new Character('d'),"Diamond"),hearts(new Character('h'),"Heart"),spades(new Character('s'),"Spade");
    Suit(final Character c,final String s) {
        this.c=c;
        this.s=s;
    }
    public static Suit fromCharacter(char c) {
        for(Suit s:Suit.values())
            if(s.c==c)
                return s;
        return null;
    }
    public Character toCharacter() {
        return c;
    }

    public String toString() {
        return s;
    }
    public static String toString(final Suit[] suit) {
        String s_="";
        for(Suit s:suit)
            s_+=s.toCharacter();
        return s_;
    }
    public static boolean areSuited(final Suit[] suit) {
        final int n=suit.length;
        for(int i=0;i<n-1;i++)
            if(suit[i]!=suit[i+1])
                return false;
        return true;
    }
    final Character c;
    final String s;
}
enum Card {
    joker(Rank.joker,Suit.joker),
    aceLowOfClubs(Rank.aceLow,Suit.clubs),
    aceLowOfDiamonds(Rank.aceLow,Suit.diamonds),
    aceLowOfHearts(Rank.aceLow,Suit.hearts),
    aceLowOfSpades(Rank.aceLow,Suit.spades),
    dueceOfClubs(Rank.deuce,Suit.clubs),
    dueceOfDiamonds(Rank.deuce,Suit.diamonds),
    dueceOfHearts(Rank.deuce,Suit.hearts),
    dueceOfSpades(Rank.deuce,Suit.spades),
    treyOfClubs(Rank.trey,Suit.clubs),
    treyOfDiamonds(Rank.trey,Suit.diamonds),
    treyOfHearts(Rank.trey,Suit.hearts),
    treyOfSpades(Rank.trey,Suit.spades),
    fourOfClubs(Rank.four,Suit.clubs),
    fourOfDiamonds(Rank.four,Suit.diamonds),
    fourOfHearts(Rank.four,Suit.hearts),
    fourOfSpades(Rank.four,Suit.spades),
    fiveOfClubs(Rank.five,Suit.clubs),
    fiveOfDiamonds(Rank.five,Suit.diamonds),
    fiveOfHearts(Rank.five,Suit.hearts),
    fiveOfSpades(Rank.five,Suit.spades),
    sixOfClubs(Rank.six,Suit.clubs),
    sixOfDiamonds(Rank.six,Suit.diamonds),
    sixOfHearts(Rank.six,Suit.hearts),
    sixOfSpades(Rank.six,Suit.spades),
    sevenOfClubs(Rank.seven,Suit.clubs),
    sevenOfDiamonds(Rank.seven,Suit.diamonds),
    sevenOfHearts(Rank.seven,Suit.hearts),
    sevenOfSpades(Rank.seven,Suit.spades),
    eightOfClubs(Rank.eight,Suit.clubs),
    eightOfDiamonds(Rank.eight,Suit.diamonds),
    eightOfHearts(Rank.eight,Suit.hearts),
    eightOfSpades(Rank.eight,Suit.spades),
    nineOfClubs(Rank.nine,Suit.clubs),
    nineOfDiamonds(Rank.nine,Suit.diamonds),
    nineOfHearts(Rank.nine,Suit.hearts),
    nineOfSpades(Rank.nine,Suit.spades),
    tenOfClubs(Rank.ten,Suit.clubs),
    tenOfDiamonds(Rank.ten,Suit.diamonds),
    tenOfHearts(Rank.ten,Suit.hearts),
    tenOfSpades(Rank.ten,Suit.spades),
    jackOfClubs(Rank.jack,Suit.clubs),
    jackOfDiamonds(Rank.jack,Suit.diamonds),
    jackOfHearts(Rank.jack,Suit.hearts),
    jackOfSpades(Rank.jack,Suit.spades),
    queenOfClubs(Rank.queen,Suit.clubs),
    queenOfDiamonds(Rank.queen,Suit.diamonds),
    queenOfHearts(Rank.queen,Suit.hearts),
    queenOfSpades(Rank.queen,Suit.spades),
    kingOfClubs(Rank.king,Suit.clubs),
    kingOfDiamonds(Rank.king,Suit.diamonds),
    kingOfHearts(Rank.king,Suit.hearts),
    kingOfSpades(Rank.king,Suit.spades),
    aceOfClubs(Rank.aceHigh,Suit.clubs),
    aceOfDiamonds(Rank.aceHigh,Suit.diamonds),
    aceOfHearts(Rank.aceHigh,Suit.hearts),
    aceOfSpades(Rank.aceHigh,Suit.spades);
    private Card(Rank rank,Suit suit) {
        this.rank=rank;
        this.suit=suit;
    }

    public Rank rank() {
        return rank;
    }
    public Suit suit() {
        return suit;
    }
    public String toString() {
        if(rank.equals(Rank.joker)||suit.equals(Suit.joker))
            return "Joker";
        else return rank+" of "+suit+'s';
    }
    public static String toString(final Card[] card) {
        String s=new String();
        for(int i=0;i<card.length;i++) {
            if(i>0)
                s+=", ";
            s+=card[i].toCharacters();
        }
        return s;
    }
    public String toCharacters() {
        return ""+rank().toCharacter()+suit().toCharacter();
    }
    public static Card instance(Rank rank,Suit suit) { // some hack for speed
        final int n=4*rank.ordinal()+suit.ordinal();
        //System.out.println(rank+" "+suit+" "+n);
        return element[4*rank.ordinal()+suit.ordinal()];
    }
    static Card[] create(int standards,int jokers) {
        int cards=0;
        Card card[]=new Card[standards*52+jokers];
        for(int i=0;i<standards;i++)
            for(Suit suit:EnumSet.range(Suit.clubs,Suit.spades))
                for(Rank rank:EnumSet.range(Rank.deuce,Rank.aceHigh))
                    card[cards++]=instance(rank,suit);
        for(int i=0;i<jokers;i++)
            card[cards++]=instance(Rank.joker,Suit.joker);
        return card;
    }
    private final Rank rank;
    private final Suit suit;
    private static final Card element[]={joker,joker,joker,joker,joker,aceLowOfClubs,aceLowOfDiamonds,aceLowOfHearts,aceLowOfSpades,dueceOfClubs,dueceOfDiamonds,dueceOfHearts,dueceOfSpades,treyOfClubs,treyOfDiamonds,treyOfHearts,treyOfSpades,fourOfClubs,fourOfDiamonds,fourOfHearts,fourOfSpades,fiveOfClubs,fiveOfDiamonds,fiveOfHearts,fiveOfSpades,sixOfClubs,sixOfDiamonds,sixOfHearts,sixOfSpades,sevenOfClubs,sevenOfDiamonds,sevenOfHearts,sevenOfSpades,eightOfClubs,eightOfDiamonds,eightOfHearts,eightOfSpades,nineOfClubs,nineOfDiamonds,nineOfHearts,nineOfSpades,tenOfClubs,tenOfDiamonds,tenOfHearts,tenOfSpades,jackOfClubs,jackOfDiamonds,jackOfHearts,jackOfSpades,queenOfClubs,queenOfDiamonds,queenOfHearts,queenOfSpades,kingOfClubs,kingOfDiamonds,kingOfHearts,kingOfSpades,aceOfClubs,
        aceOfDiamonds,aceOfHearts,aceOfSpades};
}
share|improve this answer
    
Just posting code is not a good answer. And it's not even commented code. –  Byte56 Sep 25 '12 at 16:39
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.