Trading Card Game Class hierarchy (xna)
Page 1 of 111 Replies - 1418 Views - Last Post: 06 December 2011 - 07:29 AM
#1
Trading Card Game Class hierarchy (xna)
Posted 03 December 2011 - 04:19 AM
I'm trying to come up with a simple class hierarchy for a trading card game (tcg).
But immediatly it's obvious you can get stuck quite fast. This is what I have so far:
Library class (which contains a whole list of cards which the player can choose out to create his deck).
Deck class (which contains the stackable list of cards of his playable deck)
Hand class (list of playable cards + draw cards)
Card class -> now here I'm getting stuck.
Let's say you have a certain cost of an element (check Magic the Gathering). You might for example have 1*black and 2*white to play 1 specific card. Or I can create an enumeration of the elements or create a whole new element class.
But in the card class how do I create the cost for example?
Would it be wise to choose for a dictionary(int, elements)?
How to keep track and apply skills of the card?
Any opinion on how to create a turn/phase function?
thanks in advance
Muts
Replies To: Trading Card Game Class hierarchy (xna)
#2
Re: Trading Card Game Class hierarchy (xna)
Posted 03 December 2011 - 08:09 AM
The above post pretty much explains my point of view on creating a card class for gaming cards. More than likely you are going to be populating the actual cards from a database of all the cards in the collection. Each card will have different things (mana, type, tapped, etc) that is going to be pulled from the database for the specific card.
In my opinion (and please note that this might be an amateur approach to this) if you are only going to have 1 card class, then the card class should take into account everything for every card type: land, creature, spell, etc. By having varying card-type classes you will only need to support stuff in the class for the type of card you are creating, such as a Land class that supports tapping and producing land, or a Creature class that will support mana cost, tapping, and attacking.
MTG is about the only system I have played, so I would not be able to offer any advice as far as other systems. As far as your example question:
Quote
Let's say you have created a Creature class. There are 5 elements, so 5 possible color costs for those, and maybe 1 more for colorless, so 6 really. My approach would be setting up a cost property for each color (6 total), with everything being enumerated. The DB would store the cost for each card in a table. And the individual card being created would be populated with the data from the DB pertaining to the costs. I hope that makes sense:/.
#3
Re: Trading Card Game Class hierarchy (xna)
Posted 03 December 2011 - 09:11 AM
I'll be reading/replying your post probably tomorrow as I have to go in a few minutes.
#4
Re: Trading Card Game Class hierarchy (xna)
Posted 04 December 2011 - 08:02 AM
But as of now I'm working only on the Business layer... It's rather a habit
So as of now I have the following classes made:
- Player: Name, Health and Subs for whenever the health needs to be modified.
- Card: Name, desc, enums (element, Type, rarity)
- Creature inherits Card: Attack, Defence, Type=Creature
- Resource inherits Card: Type=Resource
- Deck: Name, Shuffle (Knuths algorithm), Ilist of Card, remove and add card Subs
- Hand: Ilist of Card
It's a start
Now for the problems:
I always learned to keep the classes independent of each other
So let's say I write my DrawHand Sub in the Hand-class... How would i make sure ingame the card is removed from deck and put in my hand? You can't just remove the card from the list deck (but virtually it should be)... Also would it be wise to make my Deck-class inherits IEnuremable?
How do I add skills to my card? And how to pay for it?
For example, you have a skill fire on a dragon card which cost 2 resources... How to add this to my card? Through a list? And how would you make the interaction?
The idea is to be able to upgrade cards through ingame money (not real currency). But for some the name should be renamed but just the image would be changed. How would I compare the 2 cards?
Thanks in advance
Muts
#5
Re: Trading Card Game Class hierarchy (xna)
Posted 04 December 2011 - 04:37 PM
#6
Re: Trading Card Game Class hierarchy (xna)
Posted 05 December 2011 - 07:14 AM
Recoil, on 04 December 2011 - 04:37 PM, said:
Well I was thinking about using a dictionary of (amount of mana, skill object). Problem is I'm not sure how to get the amount of mana combined with the mana type.
Also, I've been thinking and haven't yet received an answer on a post on Apphub... But my first thought was to save all the cards/skills/... in a database. Is an external database supported by xbox360? What possibilities are there to save em?
#7
Re: Trading Card Game Class hierarchy (xna)
Posted 05 December 2011 - 03:37 PM
#8
Re: Trading Card Game Class hierarchy (xna)
Posted 06 December 2011 - 12:46 AM
But how about the skills? How can I implement them?
#9
Re: Trading Card Game Class hierarchy (xna)
Posted 06 December 2011 - 06:06 AM
#10
Re: Trading Card Game Class hierarchy (xna)
Posted 06 December 2011 - 06:43 AM
#11
Re: Trading Card Game Class hierarchy (xna)
Posted 06 December 2011 - 06:58 AM
as explained before the cost can be different types of elements. so let's say the xml would be something like
<cost> <green>1</green> <red>1</red> //or <any>3</any> </cost>
#12
Re: Trading Card Game Class hierarchy (xna)
Posted 06 December 2011 - 07:29 AM
Class Cost
{
ManaType type; // Mana type required. ManaType Enum has mana types
int amount;
public Cost(ManaType mType, int mAmount)
{
type = mType;
amount = mAmount;
}
}
Then it's just a matter of adding this to each card based on the type of mana it requires and the amount. You could also do "any" as a member of the Enum and then do some logic for checking all current available mana types to see if the player has enough total mana to cast it.
EDIT: You'd also have to add the necessary calls to allow the IntermediateSerializer to serialize the data for the cost, and it would show up something like the following in the xml file inside the card tags.
<Cost>
<ManaType>Black</ManaType>
<Amount>1</Amount>
</Cost>
This post has been edited by Kilorn: 06 December 2011 - 07:32 AM
|
|

New Topic/Question
Reply


MultiQuote








|