Give me a head start please!
-
Please bear with me!
I am super newby to Qt, QML and C++ (and OO in general)I want to develop a general card game suit of classes, for instance for the (derived) games of bridge, "Belote" or poker.
Base class (Card) will be a card, with attributes suit (Clubs - Spades) and rank (2 - Ace, I don't think about jokers right now, but suggestions are welcome!).
For some games, ranks may be different, for instance, the Ace may rank as lowest (as in Ace-2-3), highest (as in Q-K-Ace), or even both.
How do I deal with that, keeping things as general as possible (Ace can have only 1 id, but many different meanings)?Trump J(ack) may be the absolute highest card, followed by trump 9, etc... (see https://en.wikipedia.org/wiki/Belote)
Many card games, all different rules...I want to make a class CardDeck that defines the range of Card to be used, so for Bridge it will be 52 cards, suits Club to Spade, range 2 to Ace(highest)
For "Belote" it will be suits Club to Spade, range 7 to Ace(highest),
Other games may have suits Club to Spades with range Ace(lowest) to Ace(highest)...The thing is:
- Cards can have different views (for instance: QString as in "C4", HTML as in "<♣4>", or an image...)
A card may be shown as:
- Text literal ("C4")
- HTML (♣4)
You get my drift...
Now how do I start to set this up, with remark that all should be accesible by both C++ (which will probably handle the data and model) and QML (which will probaly handle views)?
I have read all the stories, but get lost ...
-
@peteritv said in Give me a head start please!:
Please bear with me!
I am super newby to Qt, QML and C++ (and OO in general)I want to develop a general card game suit of classes, for instance for the (derived) games of bridge, "Belote" or poker.
Base class (Card) will be a card, with attributes suit (Clubs - Spades) and rank (2 - Ace, I don't think about jokers right now, but suggestions are welcome!).
For some games, ranks may be different, for instance, the Ace may rank as lowest (as in Ace-2-3), highest (as in Q-K-Ace), or even both.
How do I deal with that, keeping things as general as possible (Ace can have only 1 id, but many different meanings)?Trump J(ack) may be the absolute highest card, followed by trump 9, etc... (see https://en.wikipedia.org/wiki/Belote)
Many card games, all different rules...I want to make a class CardDeck that defines the range of Card to be used, so for Bridge it will be 52 cards, suits Club to Spade, range 2 to Ace(highest)
For "Belote" it will be suits Club to Spade, range 7 to Ace(highest),
Other games may have suits Club to Spades with range Ace(lowest) to Ace(highest)...The thing is:
- Cards can have different views (for instance: QString as in "C4", HTML as in "<♣4>", or an image...)
A card may be shown as:
- Text literal ("C4")
- HTML (♣4)
You get my drift...
Now how do I start to set this up, with remark that all should be accesible by both C++ (which will probably handle the data and model) and QML (which will probaly handle views)?
I have read all the stories, but get lost ...
Even: some games may rank a specific card to be highest (e.g. Q of spades) and next in line second ( e.g. J of clubs)
How to deal with that? -
@peteritv said in Give me a head start please!:
@peteritv said in Give me a head start please!:
Please bear with me!
I am super newby to Qt, QML and C++ (and OO in general)I want to develop a general card game suit of classes, for instance for the (derived) games of bridge, "Belote" or poker.
Base class (Card) will be a card, with attributes suit (Clubs - Spades) and rank (2 - Ace, I don't think about jokers right now, but suggestions are welcome!).
For some games, ranks may be different, for instance, the Ace may rank as lowest (as in Ace-2-3), highest (as in Q-K-Ace), or even both.
How do I deal with that, keeping things as general as possible (Ace can have only 1 id, but many different meanings)?Trump J(ack) may be the absolute highest card, followed by trump 9, etc... (see https://en.wikipedia.org/wiki/Belote)
Many card games, all different rules...I want to make a class CardDeck that defines the range of Card to be used, so for Bridge it will be 52 cards, suits Club to Spade, range 2 to Ace(highest)
For "Belote" it will be suits Club to Spade, range 7 to Ace(highest),
Other games may have suits Club to Spades with range Ace(lowest) to Ace(highest)...The thing is:
- Cards can have different views (for instance: QString as in "C4", HTML as in "<♣4>", or an image...)
A card may be shown as:
- Text literal ("C4")
- HTML (♣4)
You get my drift...
Now how do I start to set this up, with remark that all should be accesible by both C++ (which will probably handle the data and model) and QML (which will probaly handle views)?
I have read all the stories, but get lost ...
Even: some games may rank a specific card to be highest (e.g. Q of spades) and next in line second ( e.g. J of clubs)
How to deal with that?OK, In a trump game, there is a natural order (cardStart to cardEnd) with possibly a enum or so that defines things.
The highest order wins the trick. -
@peteritv said in Give me a head start please!:
@peteritv said in Give me a head start please!:
Please bear with me!
I am super newby to Qt, QML and C++ (and OO in general)I want to develop a general card game suit of classes, for instance for the (derived) games of bridge, "Belote" or poker.
Base class (Card) will be a card, with attributes suit (Clubs - Spades) and rank (2 - Ace, I don't think about jokers right now, but suggestions are welcome!).
For some games, ranks may be different, for instance, the Ace may rank as lowest (as in Ace-2-3), highest (as in Q-K-Ace), or even both.
How do I deal with that, keeping things as general as possible (Ace can have only 1 id, but many different meanings)?Trump J(ack) may be the absolute highest card, followed by trump 9, etc... (see https://en.wikipedia.org/wiki/Belote)
Many card games, all different rules...I want to make a class CardDeck that defines the range of Card to be used, so for Bridge it will be 52 cards, suits Club to Spade, range 2 to Ace(highest)
For "Belote" it will be suits Club to Spade, range 7 to Ace(highest),
Other games may have suits Club to Spades with range Ace(lowest) to Ace(highest)...The thing is:
- Cards can have different views (for instance: QString as in "C4", HTML as in "<♣4>", or an image...)
A card may be shown as:
- Text literal ("C4")
- HTML (♣4)
You get my drift...
Now how do I start to set this up, with remark that all should be accesible by both C++ (which will probably handle the data and model) and QML (which will probaly handle views)?
I have read all the stories, but get lost ...
Even: some games may rank a specific card to be highest (e.g. Q of spades) and next in line second ( e.g. J of clubs)
How to deal with that?Last 2 examples where just card values, NOT card ranks...
If a player takes a trick, and Q of spades happens to be among the cards played, then some extra actions should be possible
-
-
@peteritv said in Give me a head start please!:
@peteritv said in Give me a head start please!:
I get lost in all the tal about QAbstract* and QItem* talk
Can Someone please advise me how to start, with in mind that every change (every card played) should be kept in a database?
I started out with:
Class Card{
<some_enum> suit;
<some_enum> rank;
}Everything should be acessible to C=++:
So is it better to write this in QML?
-
@SGaist Hi SGaist, KPatience shows promise, but does not explain anything, right? :(
I need to find a way to tell the system to when to print a Card as PDF (for example, using the HTML view), or to put it on screen using the picture view.
Sorry I am such a beginner...
-
Something like QPdfWriter ?
-
@peteritv said in Give me a head start please!:
@peteritv
For example:In a PDF I want to display how a game was played, using something like:
"Trick 1: ♠5 ♣4 ♥6 ♠8""
Trick was won by ♠8While in the mean time, with the same setup, on screen the correct images (pixmap 100x150 or so) of the cards are shown.
-
@peteritv
I will have something like a "Trick" Class, that shows what 4 cards (4 players) are being played onScreen...
It will show images of the 4 cards involved into specific "Seats".So suppose Players "North", "East", "South" and "West",
When a Card is played, onscreen I want to see the image (CA.png for club ace), but in PDF I want to see <♣A>It will show images of the cards being played (the pixmaps), and when I want to document, I want to show the HTML view
-
@peteritv Let me alloborate further: My object "Card" may have many representations... On screen it will be a pixmap (Club Ace will be represented by CA.png), but for a document it will be represented by the HTML value "♣A" or maybe even "CA"
Now I not really that newby that doesn't know the difference, I just don't know how things like that work in Qt.
And Preferrably is such a way that QML knows about it too. -
@peteritv said in Give me a head start please!:
@peteritv Let me alloborate further: My object "Card" may have many representations... On screen it will be a pixmap (Club Ace will be represented by CA.png), but for a document it will be represented by the HTML value "♣A" or maybe even "CA"
Now I not really that newby that doesn't know the difference, I just don't know how things like that work in Qt.
And Preferrably is such a way that QML knows about it too.So suppose I have a Class "Card" with attributes "int Suit" and "int Rank".
Simple class right?How do I expose views that show the onScreen , onPDF, etc variants?
-
@peteritv said in Give me a head start please!:
@peteritv said in Give me a head start please!:
@peteritv Let me alloborate further: My object "Card" may have many representations... On screen it will be a pixmap (Club Ace will be represented by CA.png), but for a document it will be represented by the HTML value "♣A" or maybe even "CA"
Now I not really that newby that doesn't know the difference, I just don't know how things like that work in Qt.
And Preferrably is such a way that QML knows about it too.So suppose I have a Class "Card" with attributes "int Suit" and "int Rank".
Simple class right?How do I expose views that show the onScreen , onPDF, etc variants?
So I have some kind of list of "Cards"
Preferrably some kind of sorting on it...And a player plays a card...
-
@peteritv said in Give me a head start please!:
@peteritv said in Give me a head start please!:
@peteritv said in Give me a head start please!:
@peteritv Let me alloborate further: My object "Card" may have many representations... On screen it will be a pixmap (Club Ace will be represented by CA.png), but for a document it will be represented by the HTML value "♣A" or maybe even "CA"
Now I not really that newby that doesn't know the difference, I just don't know how things like that work in Qt.
And Preferrably is such a way that QML knows about it too.So suppose I have a Class "Card" with attributes "int Suit" and "int Rank".
Simple class right?How do I expose views that show the onScreen , onPDF, etc variants?
So I have some kind of list of "Cards"
Preferrably some kind of sorting on it...And a player plays a card...
For the game of "Bridge"
Let's say we have 4 players: "North", "East", "South" and "West"How do I define that so that QML knows about it?
-
@peteritv said in Give me a head start please!:
@peteritv said in Give me a head start please!:
@peteritv said in Give me a head start please!:
@peteritv said in Give me a head start please!:
@peteritv Let me alloborate further: My object "Card" may have many representations... On screen it will be a pixmap (Club Ace will be represented by CA.png), but for a document it will be represented by the HTML value "♣A" or maybe even "CA"
Now I not really that newby that doesn't know the difference, I just don't know how things like that work in Qt.
And Preferrably is such a way that QML knows about it too.So suppose I have a Class "Card" with attributes "int Suit" and "int Rank".
Simple class right?How do I expose views that show the onScreen , onPDF, etc variants?
So I have some kind of list of "Cards"
Preferrably some kind of sorting on it...And a player plays a card...
For the game of "Bridge"
Let's say we have 4 players: "North", "East", "South" and "West"How do I define that so that QML knows about it?
But to start with:
How do I know what "Game" to start with?A "CardGame" may be a local thing, may be referenced by a Single person or an onLine thing....
Let's focus on "CardGame" being a local thing.
And let's say that "Bridge" is our focus of cardgames.
"Bridge" has rules:
For instance:
Ace is highest
2 is lowest
Trump is highestI think that summons up the ruler of a "Bridge" trick,
right?So: If not trumped, Ace is highest
But if Trumped: