Narusan
Narusan

Reputation: 502

iPhone Card Game Deck Generator

I am trying to program an iPhone App that will create a card set of 10 cards.

The total deck includes about 100 cards with different properties: Each card has a name, a suit and a cost. For an example:

card.name = "Test"
card.cost = 2
card.suit = "BasicSet"

Let's suppose there are 4 "Sets"* with 20 cards each. I want the user to be able to select the suit themselves, because most of the suits come from extension sets.

To make it more balanced, I will also decide a maximum and minimum amount of cards with a specific cost (the cost ranging from 2 - 6).

In the end, there will be 2 functions. One function that selects all valid cards (from the available card suits) and another that picks 10 cards at random (taking into account the cost).

What is the easiest way to implement the cards? Defining the class card and implementing the 100 cards? Or creating 3 arrays with name, cost and origin where one card has the same index in all 3 arrays?

Help would be appreciated?

EDIT:
Each Suit contains unique cards. So if my suits are diamond, spade and so on, there will only be a diamond king, but no spade king. Just an example how it could look like:

Suit Basic {
name=Village, cost=2
name=City, cost=3
name=NewYork, cost=6
}

Suit Advanced {
name=Tree, cost=4
name=Forest, cost=5
}

Suit Special {
name=Cocktail, cost=2
name=OrangeJuice, cost=4
}

Upvotes: 0

Views: 115

Answers (1)

Evgen Bodunov
Evgen Bodunov

Reputation: 5946

One class Card could store all necessary information and functions for basic operations. When Card class is ready, you could create objects of that class with your data parsed from plist or any other format. It's not really necessary to hardcode your data inside the app.

Upvotes: 4

Related Questions