profectus-docs/assets/guide_important-concepts_requirements.md.3dd98485.js

1 line
3.9 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as e,c as t,o as i,N as r}from"./chunks/framework.0799945b.js";const q=JSON.parse('{"title":"Requirements","description":"","frontmatter":{},"headers":[],"relativePath":"guide/important-concepts/requirements.md","lastUpdated":1681792472000}'),a={name:"guide/important-concepts/requirements.md"},n=r('<h1 id="requirements" tabindex="-1">Requirements <a class="header-anchor" href="#requirements" aria-label="Permalink to &quot;Requirements&quot;"></a></h1><p>The requirements system in Profectus is designed to handle various conditions that must be met before certain actions or features can be accessed by the player. These conditions can include resource amounts, completed challenges, or other milestones within the game.</p><h2 id="creating-requirements" tabindex="-1">Creating Requirements <a class="header-anchor" href="#creating-requirements" aria-label="Permalink to &quot;Creating Requirements&quot;"></a></h2><p>To create a requirement, you can use one of the provided utility functions like <a href="/api/modules/game/requirements#createcostrequirement">createCostRequirement</a>, <a href="/api/modules/game/requirements#createvisibilityrequirement">createVisibilityRequirement</a>, or <a href="/api/modules/game/requirements#createbooleanrequirement">createBooleanRequirement</a>. These functions return a <code>Requirement</code> object with specific properties that define the requirement conditions.</p><h2 id="using-requirements" tabindex="-1">Using Requirements <a class="header-anchor" href="#using-requirements" aria-label="Permalink to &quot;Using Requirements&quot;"></a></h2><p>Several features will have a <code>requirements</code> property that takes one or more requirements that must be fulfilled for a certain action to be performed with that feature.</p><p>When implementing requirements, you can use the <a href="/api/modules/game/requirements#displayrequirements">displayRequirements</a> utility. This utility is designed to give a human-readable string generated by the requirement(s) given, making it easier for players to understand the conditions needed to progress in the game. Typically features that support requirements will already use this utility internally.</p><p>You may need to &quot;pay&quot; requirements upon meeting their conditions and performing the associated action. This action typically involves spending resources or making other adjustments to the game state. The <a href="/api/modules/game/requirements#payrequirements">payRequirements</a> function simplifies this process by handling the payment for one or more requirements, considering the number of levels to pay for. Additionally, custom pay functions like <a href="/api/modules/game/requirements#paybydivision">payByDivision</a> and <a href="/api/modules/game/requirements#paybyreset">payByReset</a> can be passed into <code>createCostRequirement</code> for more specialized cases.</p><h2 id="multi-level-requirements" tabindex="-1">Multi-Level Requirements <a class="header-anchor" href="#multi-level-requirements" aria-label="Permalink to &quot;Multi-Level Requirements&quot;"></a></h2><p>Requirements can have multiple &quot;levels&quot;, which are typically used for things like multi-level challenges with scaling requirements. When checking if requirements are met, the <a href="/api/modules/game/requirements#requirementsmet">requirementsMet</a> function can be used. It accepts a single requirement or an array of requirements.</p><p>Requirements that are just on/off, such as boolean or visibility requirements, will count as infinite levels when in the same array. This allows you to combine different types of requirements in the same array and use the <a href="/api/modules/game/requirements#maxrequirementsmet">maxRequirementsMet</a> function to calculate the maximum number of levels that could be acquired with the current requirement states.</p>',11),s=[n];function o(u,m,l,c,h,d){return i(),t("div",null,s)}const f=e(a,[["render",o]]);export{q as __pageData,f as default};