How to make game item that is available in several levels?

Discuss any general programming issues here
Post Reply
Bugala
Posts: 1259
Joined: Sun Feb 14, 2010 7:11 pm

How to make game item that is available in several levels?

Post by Bugala »

I decided to ask you others if you had implemented something similar, and ask how you did it.

It is not that I cannot do this, it is just a matter of wondering what would be the best way to do this, and hence asking how others might have implemented this.

While in title I am talking of Item available in several levels, which is basically the same thing, the real example is that I am making this Card Game based Football game. Between matches there is going to be a shop to buy more cards.

However, which cards will be available to buy, would depend upon the league. As in Junior Leagues has certain cards available, while Championship Leagues has some other cards available.

Idea is that Cards have some variables in them, like could be:

Code: Select all

Card = {price=10, Name="kick", Rarity=5}
But how should I do the availability?

Like I could have:

Code: Select all

Availability="1-3"
meaning it is available from seasons 1-3 (which might be the case in most times that cards are available from certain season to certain season, not outside those boundaries.

This would however make me need to make interpreter function to interpret the "1-3" string.

To avoid interpreter part, I could instead make:

Code: Select all

AvailabilityStart=1
AvailabilityEnd=3
But I don't think that is a good thing to do, that rather take the extra hassle of interpreter function to make it otherwise clearer looking.

However, I would like to keep the options open of having non sequential seasons too, in case I decide to go different route.

Like maybe player can choose whether he in next season moves to amateur or professional league, which could mean different set of cards. In this case it might be better to use something like:

Code: Select all

Availability={1, 2, 4}
Meaning cards wouldn't be available in season 3 and 5, but seasons 1, 2, and 4 would have them.

Naturally instead of {1, 2, 4} I could use names, like {"kids leagues", "Championship League"}

This would otherwise be good, except I do dislike the idea that the code becomes messier than "1-3" for example, since say I have 100 cards, and then each of those needs to be written separately.

something like "1-3" vs {"name1", "name2", "name3"} is clearly much clearer and easier to read and upkeep.


As a last thing I am also thinking that perhaps I should even keep up the possibility that other stats could change between seasons.

Like maybe in season 2 cards rarity is rare, in third season it is common to show up.

Similarly pricing could be higher in season 2, and price lower for each following season, in that case I might even need subtables:

Code: Select all

Card = { Name="Kick", ["season1"] = {price = 10, rarity=5}, ["season2"] = {price=5, rarity=20} } 
Anyone having dealt with something like this before, and how did you solve this? Is there any neat way to get this done?
User avatar
Juan Carlos
Posts: 920
Joined: Mon Sep 06, 2010 1:02 pm

Re: How to make game item that is available in several levels?

Post by Juan Carlos »

The best option is to use a variable or array with the information of levels where the card cans to use, this information will be read for the levels to know the items availables or not to play with them.
Post Reply