Hey guys,
I made some good progress today on the quest system. The encounter mechanics work already, so I started implementing quest mechanics. A quest is a series of encounters.
To create a linear quest from existing encounters, you can currently write this:
trap = TrapEncounter()
trap.difficulty = 5
quest = BaseQuest()
quest.add_encounter("quest", "always", "trap1", trap)
quest.add_encounter("trap1", "always", "trap2", trap)
quest.add_encounter("trap2", "always", "trap3", trap)
A quest like this will require the questing characters to master the encounters trap1, trap2 and trap3.
However, I decided the most natural way to represent a quest is a tree of encounters. This means there are branches, more than one way to complete a quest and different encounters along the way, depending on how the previous encounters in the quest turned out. To create a branched quest, you could write:
quest = BaseQuest()
quest.add_encounter("quest", "always", "trap1", trap)
quest.add_encounter("trap1", "success", "trap2", trap)
quest.add_encounter("trap1", "failure", "trap3", trap)
quest.add_encounter("trap3", "always", "trap4", trap)
In this quest, the characters first have to face trap1. If they succeed, they have to face trap 2. If they failed in the trap1 encounter, they have to face trap3 and trap 4.
To implement the tree structure, I used well-established code: the element tree API. This means it will be very easy to load quest definitons from XML in the future. The above quest in XML looks like this:
<?xml version="1.0" ?>
<quest>
<trap1 if="always">
<trap2 if="success"/>
<trap3 if="failure">
<trap4 if="always"/>
</trap3>
</trap1>
</quest>
I'm pretty happy how this turned out. IMHO it is a powerful, flexibel system and especially using it should be quite simple. What do you guys think? Questions? Did I miss something?