1
\$\begingroup\$

When we want to design a mission sub-system like in the The Ville or Sims Social, what kind of design pattern / idea would fit the best? There may be relation between missions (first do this then this etc...) or not. What do you think sims social or the ville or any other social games is using for this?

I'm looking for a best-practise method to contruct a mission framework for tha game. How the well-known game firms do this stuff for their large scale social facebook games?

  • Giving missions to the players and wait players to complete them. when they finished the missions, providing a method to catch this mission complete events considering large user database by not using server-side not so much to prevent high-traffic / resource consumption.

how should i design the database and server-client communication to achive this design condidering this trade-off.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ What do you mean by design pattern? in terms of code? in terms of project? The pattern used can be depend on many things,such as: What framework you are using/how much time you have/how often you update the code or if you do at all... Refine the question and i'll think you'll get more/better answers. \$\endgroup\$
    – LoveofSnow
    Jul 11, 2012 at 12:06
  • \$\begingroup\$ I'm looking for a best-practise method to contruct a mission framework for tha game. How the well-known game firms do this stuff for their large scale social facebook games? Giving missions to the players and wait players to complete them. when they finished the missions, providing a method to catch this mission complete events considering large user database by not using server-side not so much to prevent high-traffic / resource consumption. how should i design the database and server-client communication to achive this design condidering this trade-off. \$\endgroup\$ Jul 11, 2012 at 12:27
  • 2
    \$\begingroup\$ With the given information about your game it is hard to tell, what you should do, as the mission design is strongly dependent on your game logic. Also, I don't think that there is one design pattern, that fits for every case. You should look into game design itself and then design a system, that fits your needs. But in the current state, the question could be answered on a very wide scale, without even helping you. It's like if I would ask "What is the best practice for saving a game" without giving any more information. This strongly depends on your game and your architecture... \$\endgroup\$ Aug 10, 2012 at 14:44

2 Answers 2

2
\$\begingroup\$

There is not one silver bullet. You can use an event driven paradigm:

  • Whenever something happens in your game that can be relevant for a quest, raise an event.
  • Define classes for your quests with event listeners to react to these events.
  • Store the currently active quests (and their status and parameters) in a database
  • When initializing your game state, also initialize quest objects for each active quest of the player
  • Register the quest objects' event listeners at your game state object

For example:

class Character {
    function heal(amount) {
        this->hp += amount;
        event = new HealingEvent(this, amount);
        raise event;
    }
}

class PracticeYourHealingSpellQuest extends Quest (extends ActiveRecordBaseClass) {
    // property healingDone is provided by a database record
    function reactToHealingEvent(event) {
        this->healingDone += amount;
        if(this->healingDone > 1000) {
            this->state = completed;
        }
        this->update();
    }
    function registerAtCharacter(character) {
        character->onHealingEvent = this->reactToHealingEvent
    }
}

class GameController {
    function init() {
        character = DB->findMeACharacter
        quests = DB->findMeActiveQuests(character->id)
        foreach(quests as quest) {
            quest->registerAtCharacter(character);
        }
    }
}

Don't worry about database performance. Your facebook app will never have enough users playing at the same time to make this approach unviable with MySQL. (If it does, you can still use caching techniques, parallel database servers, etc.) The most important thing is to have a quest system that is flexible and that has all the quest-related code where it belongs, namely in quest classes.

\$\endgroup\$
0
\$\begingroup\$

Your question is general enough that there's probably no definitive answer to it. I think you could find the answer in the book Game Coding Complete though. It describes a process manager that allows you to chain processes together, so that once you achieve a step in a mission the next one would automatically activate. They discuss how you could even make a C# tool that would let you drag and drop to create mission trees in this manner. Might be the kind of architecture you're looking for.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .