Quester.js
Handles quest management in a game.
by Sam Fereday
HTML
<p>
The idea of the very small library is to allow for quest progression persistence, and it should couple with another module which will return correct conversations under correct flags. The real challenge comes when we have to make both of them not be aware
of each other.
</p>
<p>
It needs to be built to completely stop mixing data with visual. The two affect each other fair enough, but our use of MVC patterns clearly outlines the need for a separation between each layer, with a series of controllers in the middle.
</p>
<p>
<em>These are all part of the miniature RPG data toolset. And should all be completely decoupled yet useable. Once done, I may convert them and stick them in the unity project.</em>
</p>
CSS
body {
font: 75%/1.4em arial;
}
JavaScript
/// Set up some data for us to use
// enums would be real useful here too.
// Quest DB (for Quester) - special db parsed in quester, contains all sorts of goodies.
// Events assume that all data within is valid somewhere. They don't care beyond that.
// Events are fired when quest is flagged complete, quester will handle this for you. You might
// wish to flag other quests complete, but a list of event types will be displayed in docs. Those
// quests events will not fire however, they will just be ticked and set in stone. You wont get rewards
// for the optional ones either, it's nothing but setting a flag.
// Quester can be called at any point through a convo, and you can flag a quest as done. So you might
// get to the end of a particular convo, complete a quest, then it'll chain a new convo after that. It's
// very similar to questers data, but we'll deal with convos later.
var questData = [{
title: "Totally unrelated quest",
id: "2a",
questGroupId: null,
questContent: {
descriptor: "Find something totally unrelated."
},
requiredForCompletion: [],
isComplete: false
}, {
title: "Quest to save a Carrot",
id: "1b",
questGroupId: null,
questContent: {
descriptor: "Find the missing Carrot."
},
requiredForCompletion: [],
isComplete: false
}, {
title: "Important quest to save a Rabbit",
id: "1a",
questGroupId: "mainStory",
questContent: {
descriptor: "Save the Rabbit."
},
groupOrder: 0,
requiredForCompletion: [],
isComplete: false
}, {
title: "Saved the Rabbit, but the Rabbit needs a carrot!",
id: "3b",
questGroupId: "mainStory",
questContent: {
descriptor: "Find the Carrot for the Rabbit."
},
groupOrder: 1,
requiredForCompletion: ["1a", "1b"],
isComplete: false
}];
/* What does quester do?
It:
- Takes data in json format that resembles a collection of quests - done
- Has knowledge of other quest data so you can complete or not depending on prerequisites - done
- Flag quests data complete or...