6 lines
6.7 KiB
JavaScript
6 lines
6.7 KiB
JavaScript
import{_ as e,c as s,o as t,N as a}from"./chunks/framework.0799945b.js";const y=JSON.parse('{"title":"Requirements","description":"","frontmatter":{},"headers":[],"relativePath":"guide/important-concepts/requirements.md","lastUpdated":1684302845000}'),n={name:"guide/important-concepts/requirements.md"},r=a(`<h1 id="requirements" tabindex="-1">Requirements <a class="header-anchor" href="#requirements" aria-label="Permalink to "Requirements""></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 "Creating Requirements""></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><p>Cost requirements are probably the most common requirement you'll be using. For something with multiple levels, like repeatables, you'll typically want to use a formula for the cost instead of a function, and the input to the formula will be the repeatable's <code>amount</code> property. Typically that means the code will look like this:</p><div class="language-ts"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#82AAFF;">createRepeatable</span><span style="color:#A6ACCD;">(</span><span style="color:#A6ACCD;font-style:italic;">repeatable</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">=></span><span style="color:#A6ACCD;"> (</span><span style="color:#89DDFF;">{</span></span>
|
||
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">requirements</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">createCostRequirement</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">()</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">=></span><span style="color:#A6ACCD;"> (</span><span style="color:#89DDFF;">{</span></span>
|
||
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">resource</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> points</span><span style="color:#89DDFF;">,</span></span>
|
||
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">cost</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> Formula</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">variable</span><span style="color:#A6ACCD;">(repeatable</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">amount)</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">add</span><span style="color:#A6ACCD;">(</span><span style="color:#F78C6C;">1</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">times</span><span style="color:#A6ACCD;">(</span><span style="color:#F78C6C;">100</span><span style="color:#A6ACCD;">)</span></span>
|
||
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">))</span></span>
|
||
<span class="line"><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">))</span><span style="color:#89DDFF;">;</span></span></code></pre></div><p>Important to note here is the parameter added to the <code>createRepeatable</code>'s options function. That is a reference to the repeatable being created, so you can access it's <code>amount</code> property in the formula.</p><h2 id="using-requirements" tabindex="-1">Using Requirements <a class="header-anchor" href="#using-requirements" aria-label="Permalink to "Using Requirements""></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 "pay" 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 "Multi-Level Requirements""></a></h2><p>Requirements can have multiple "levels", 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>`,14),o=[r];function i(l,p,c,u,m,h){return t(),s("div",null,o)}const q=e(n,[["render",i]]);export{y as __pageData,q as default};
|