Skip to content
This repository was archived by the owner on Sep 24, 2019. It is now read-only.
Thomas Couchoud edited this page Sep 24, 2019 · 9 revisions

This program not only provide the ability to generate quests. It also have an API that you can use to get informations on the quest and mark actions done.

To generate a Quest you'd have to use the class fr.polytech.di.questgenerator.QuestGenerator class or use fr.polytech.di.questgenerator.enums.Stretegies.createQuest(?) method.

The fr.polytech.di.questgenerator.QuestGenerator class also allows you to define the max depth used to generate the quests with the method setMaxDepth. You can also set the debug value with setDebug.

This interface is made to help you track the actions/quests that have been done by the user. It contains two methods:

  • actionDone(Action) that is called when an action is set as done.
  • questDone(Quest) that is called when a quest is done, which means that all its actions are marked as done.

You can add your class implementing this interface to a Quest object via the addQuestListener(QuestListener) method. You can add it at any depth of the quest but is especially interesting for the lower level. Each event will be notified in its parents listeners.

This interface is made to tell the quest what happened in the game. It is implements in the Quest object. To call it simply call the wanted method by a Quest object. These events correspond to the ActionType that can happen. Each function should be called when the corresponding event happened with the correct parameters. The Quest will then define if this event is the correct one and happened at the right time. If it's the case, it will mark the concerned action as done.

Here's a list of those methods:

  • captureEvent(object)
  • damageEvent(object)
  • defendEvent(object)
  • escortEvent(object)
  • exchangeEvent(objectGive, objectGet, pnjTo)
  • experimentEvent(object)
  • exploreEvent(object)
  • gatherEvent(object)
  • getEvent(object, from)
  • giveEvent(object, pnjTo)
  • gotoEvent(object)
  • killEvent(object)
  • learnEvent(object)
  • listenEvent(object)
  • readEvent(object)
  • repairEvent(object)
  • reportEvent(object)
  • spyEvent(object)
  • stealEvent(objectGet, from)
  • stealth(object)
  • takeEvent(objectGet, from)
  • useEvent(objectUse, on)

Each parameter is a XMLStringObjectiveElement that represent an element from the XML objective values

Those methods return a boolean indicating if an action as been marked as done or not.

Code exemples

Generating a quest:

Quest quest = QuestGenerator.createNewRandomQuest(); //Generate a random quest
Quest quest = QuestGenerator.createByMotivation(Motivations.CONQUEST); //Generate a quest within the specified motivation
Quest quest = Strategies.KNOWLEDGE_INTERVIEW.createQuest(); //Generate the specified quest

Sending events to the quest:

Quest quest = QuestGenerator.createNewRandomQuest();
quest.gotoEvent(DataHandler.getElement("pnj/being/human", "Aerys"));

Getting completion events:

Quest quest = QuestGenerator.createNewRandomQuest();
quest.addQuestListener(new QuestListener()
{
	@Override
	public void actionDone(Action action)
	{
		System.out.println("Action completed: " + action);
	}

	@Override
	public void questDone(Quest quest)
	{
		System.out.println("Quest completed: " + quest);
	}
});

Clone this wiki locally