Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to figure out the best design here, and I can see multiple approaches, but none that seems "right."

There are three relevant classes here: Base, TradingPost, and Resource. Each Base has a TradingPost which can offer various Resources depending on the Base's tech level.

Where is the right place to store the minimum tech level a base must possess to offer any given resource? A database seems like overkill. Putting it in each subclass of Resource seems wrong--that's not an intrinsic property of the Resource. Do I have a mediating class, and if so, how does it work? It's important that I not be duplicating code; that I have one place where I set the required tech level for a given item. Essentially, where does this data belong?

P.S. Feel free to change the title; I struggled to come up with one that fits.

share|improve this question
It sounds like you can just keep this as an attribute of the base: a list of resources, and a correlating list of the minimal base level before that resource appears. – ashes999 Jan 3 '13 at 16:20
up vote 1 down vote accepted

IMHO, the responsibility of managing which Resources are available in a TradingPost should be in a separate controller-like class, TradingPostController for example.

TradingPostController observes changes of Base.techLevel and updates the TradingPost's set of offered Resources accordingly. In this approach, TradingPostController will contain a mapping of tech level -> resource set.

So the sequence of events would be:

  • Tech-level of Base is increased.
  • Base fires a "tech level changed" event.
  • TradingPostController observes the event.
  • TradingPostController updates TradingPost.resources (or so).

Good luck!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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