# Quests

## Functions and Methods

### InitQuests

Initializes the local state of quests functionality. Should be called after player ID is available.&#x20;

```
var paramsForQuestsPersonalization = new Dictionary<string, object>
{
    // Optional params go here
};
Kibotu.InitQuests(paramsForQuestsPersonalization);
```

### TriggerQuestState

Handles the triggered event, which could involve progressing an active quest or starting a new one.

```
var paramsForQuestsPersonalization = new Dictionary<string, object>
{
    // Optional params go here
};
Kibotu.TriggerQuestState("GameWin", paramsForQuestsPersonalization);
```

### TriggetQuestUI

Manages the visual communication of the quest's state to the player. If it returns true, then there is new information to be shown to the player.

```
var paramsForQuestsPersonalization = new Dictionary<string, object>
{
    // Optional params go here
};
if (Kibotu.TriggerQuestUI("Main_AutoShowPopup", paramsForQuestsPersonalization))
{
    QuestModal.ShowPopup(Kibotu.GetActiveQuest());
}
```

### GetActiveQuest

Returns a [KibotuQuest object](#kibotuquest) that contains comprehensive data to be communicated to the player.

### onQuestRewardAction

To be executed when the player acknowledges that they won the quest.

```
Kibotu.onQuestRewardAction(currentQuest.Id);
```

### KibotuQuest.GetPrize

Returns a string that is the prize identifier when the player wins it.

### KibotuQuestGraphics.GetGraphic

Returns [KibotuQuestGraphic](#kibotuquestgraphic) based on the quest's state.

```
var graphic = quest.Graphics.GetGraphic(currentQuest.Progress.Status);
await mainImage.SetImageAsync(graphic.Background);
await topBannerImage.SetImageAsync(graphic.TitleImage);
```

## Models

### KibotuQuest

```
public string Id;
public string Title;
public string Enabled;
[CanBeNull] public KibotuQuestProgress Progress;
public KibotuQuestProgressMilestone[] Milestones;
public List<string> CountryCodes;
public KibotuQuestGraphics Graphics;
public KibotuQuestTriggers Triggers;
public string CollectibleIconImage;

public int TotalSteps;
public JObject TargetFilter;
public DateTime from;
public DateTime to;
```

### KibotuQuestProgress

```
public string CurrentState;
public int CurrentStep = 0;
public EnumQuestStates Status;

public enum EnumQuestStates
{
    Welcome,
    Progress,
    Won,
    Lost
}
```

### KibotuQuestProgressMilestone

```
public int Order;
public string PrizeTitle;
public string PrizeImage;
public string PrizeSku;
public int Goal;
public string GoalImage;
```

### KibotuQuestGraphics

```
public KibotuQuestGraphic Welcome;
public KibotuQuestGraphic Progress;
public KibotuQuestGraphic Lost;
public KibotuQuestGraphic Won;
```

### KibotuQuestGraphic

```
public string Background;
public string TitleImage;
```

### KibotuQuestTriggers

```
public KibotuQuestTriggerEvents State;
public KibotuQuestTriggerEvents UI;
```

### KibotuQuestTriggerEvents

```
public List<KibotuQuestEvent> Welcome;
public List<KibotuQuestEvent> Progress;
public List<KibotuQuestEvent> Finish;
```

### KibotuQuestEvent

```
public string EventName;
public string EventValue;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kibotu.ai/unity-sdk/quests.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
