GS2-SkillTree Deploy/CDK Reference

The template format used when creating stacks with GS2-Deploy, and implementation examples of template output in various languages using CDK

Entities

Resources managed by the Deploy operation

Namespace

Namespace

A Namespace allows multiple independent instances of the same service within a single project by separating data spaces and usage contexts. Each GS2 service is managed on a per-namespace basis. Even when using the same service, if the Namespace differs, the data is treated as a completely independent data space.

Therefore, you must create a Namespace before you can start using each service.

Request

Resource creation and update requests

TypeConditionRequiredDefaultValue LimitsDescription
namestring
~ 128 charsNamespace name
Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
descriptionstring~ 1024 charsDescription
transactionSettingV2TransactionSettingV2Transaction Setting (V2)
Decides how the transactions this Namespace issues are executed. There are only two things to set: the GS2-Distributor Namespace that executes them, and whether the actions in a transaction run one at a time – so that a later action can build on what an earlier one wrote – or all at once for a shorter response time.
Set this on a new Namespace. transactionSetting, the obsolete setting it replaces, is used only while this is unset.
releaseScriptScriptSettingScript setting to be executed when a node is released
Script Trigger Reference - release
restrainScriptScriptSettingScript setting to be executed when a node is restrained
Script Trigger Reference - restrain
logSettingLogSettingLog Output Setting
Configuration for logging skill tree operations such as node releases, restrains, and resets.
When set, operation logs are output to the specified GS2-Log Namespace.

GetAttr

Resource creation results that can be retrieved using the !GetAttr tag

TypeDescription
ItemNamespaceNamespace created

Implementation Example

Type: GS2::SkillTree::Namespace
Properties:
  Name: namespace-0001
  Description: null
  TransactionSettingV2: null
  ReleaseScript: null
  RestrainScript: null
  LogSetting: 
    LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/skillTree"
)


SampleStack := core.NewStack()
skillTree.NewNamespace(
    &SampleStack,
    "namespace-0001",
    skillTree.NamespaceOptions{
        LogSetting: &core.LogSetting{
            LoggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
        },
    },
)

println(SampleStack.Yaml())  // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        new \Gs2Cdk\SkillTree\Model\Namespace_(
            stack: $this,
            name: "namespace-0001",
            options: new \Gs2Cdk\SkillTree\Model\Options\NamespaceOptions(
                logSetting: new \Gs2Cdk\Core\Model\LogSetting(
                    loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            )
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.skillTree.model.Namespace(
                this,
                "namespace-0001",
                new io.gs2.cdk.skillTree.model.options.NamespaceOptions()
                        .withLogSetting(new io.gs2.cdk.core.model.LogSetting(
                            "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                        ))
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2SkillTree.Model.Namespace(
            stack: this,
            name: "namespace-0001",
            options: new Gs2Cdk.Gs2SkillTree.Model.Options.NamespaceOptions
            {
                logSetting = new Gs2Cdk.Core.Model.LogSetting(
                    loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            }
        );
    }
}

Debug.Log(new SampleStack().Yaml());  // Generate Template
import core from "@/gs2cdk/core";
import skillTree from "@/gs2cdk/skillTree";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new skillTree.model.Namespace(
            this,
            "namespace-0001",
            {
                logSetting: new core.LogSetting(
                    "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            }
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template
from gs2_cdk import Stack, core, skill_tree

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        skill_tree.Namespace(
            stack=self,
            name='namespace-0001',
            options=skill_tree.NamespaceOptions(
                log_setting=core.LogSetting(
                    logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
                ),
            ),
        )

print(SampleStack().yaml())  # Generate Template

TransactionSettingV2

Transaction Setting (V2)

Transaction Setting (V2) decides how the transactions issued by a Namespace are executed.

There are only two things to set:

  • distributorNamespaceId: the GS2-Distributor Namespace used to execute the transaction
  • enableParallelExecution: whether the actions in a transaction run one at a time or all at once

Whichever you choose, the transaction is executed by the server the moment it is issued, and it succeeds or fails as a whole: when an action fails, the actions that already ran are undone with it and nothing is left applied. Everything else about how a transaction runs is fixed to the recommended configuration, so there is nothing else to set.

Running the actions one at a time (the default, enableParallelExecution is false) lets each action work on top of what the actions before it wrote. The actions run in verify, consume, acquire order, and this is what lets you:

  • update the same row from more than one action in a single transaction, which fails when they run all at once
  • read what an earlier action wrote, including from List and Query and from inside a nested transaction
  • use %{Gs2Xxx:ActionName.path[0].field} to feed the result of an earlier verify or consume action into the parameters of a later verify, consume or acquire action

In exchange, the response time is the sum of the time taken by each action, and a transaction may contain at most 20 actions. The order within each phase is decided by the action name and then by the target resource, so you cannot choose the execution order by rearranging the actions in the request, and execution stops at the first action that fails.

Running the actions all at once (enableParallelExecution is true) executes them in parallel against a single snapshot of the data, so the response time is that of the slowest single action and there is no limit on the number of actions.

In exchange, an action cannot see what the other actions wrote, and two actions that write the same row fail the transaction with database:transaction:same.resource (400), so choose this only when you can guarantee that no two actions in the same transaction write the same data. %{...} may reference only the results of an earlier phase (verify, then consume, then acquire); a reference to an action in the same phase is left unresolved, and a phase that contains %{...} waits for the earlier phases to complete, which lengthens the response time by that amount.

Transaction Setting is the obsolete setting that Transaction Setting (V2) replaces, kept for Namespaces created before Transaction Setting (V2) existed. It applies only while Transaction Setting (V2) is unset, and setting Transaction Setting (V2) supersedes it. Three behaviours it allowed are deliberately not offered here: executing a transaction as a client-run stamp sheet, running AutoRun asynchronously via GS2-Distributor, and folding acquire actions into GS2-JobQueue.

TypeConditionRequiredDefaultValue LimitsDescription
distributorNamespaceIdstring“grn:gs2:{region}:{ownerId}:distributor:default”~ 1024 charsGS2-Distributor Namespace GRN used to execute transactions
enableParallelExecutionboolfalseWhether to execute the actions in parallel instead of sequentially

ScriptSetting

Script Setting

In GS2, you can associate custom scripts with microservice events and execute them. This model holds the settings for triggering script execution.

There are two main ways to execute a script: synchronous execution and asynchronous execution. Because synchronous execution blocks processing until the script finishes executing, you can use the script result to stop the API execution or control the API response.

In contrast, asynchronous execution does not block processing until the script has finished executing. However, because the script result cannot be used to stop the API execution or modify the API response, asynchronous execution does not affect the API response flow and is generally recommended.

There are two types of asynchronous execution methods: GS2-Script and Amazon EventBridge. By using Amazon EventBridge, you can write processing in languages other than Lua.

TypeConditionRequiredDefaultValue LimitsDescription
triggerScriptIdstring~ 1024 charsGS2-Script script GRN executed synchronously when the API is executed
Must be specified in GRN format starting with “grn:gs2:”.
doneTriggerTargetTypestring (enum)
enum {
  “none”,
  “gs2_script”,
  “aws”
}
“none”Asynchronous script execution method
Specifies the type of script to use for asynchronous execution.
You can choose from “Do not use an asynchronous execution script (none)”, “Use GS2-Script (gs2_script)”, and “Use Amazon EventBridge (aws)”.
DefinitionDescription
noneNone
gs2_scriptGS2-Script
awsAmazon EventBridge
doneTriggerScriptIdstring{doneTriggerTargetType} == “gs2_script”~ 1024 charsGS2-Script script GRN for asynchronous execution
Must be specified in GRN format starting with “grn:gs2:”.
* Enabled only if doneTriggerTargetType is “gs2_script”
doneTriggerQueueNamespaceIdstring{doneTriggerTargetType} == “gs2_script”~ 1024 charsGS2-JobQueue Namespace GRN used to execute asynchronous scripts
If you want to execute asynchronous execution scripts via GS2-JobQueue instead of executing them directly, specify the GS2-JobQueue Namespace GRN.
GS2-JobQueue is generally not required unless you have a specific reason to use it.
* Enabled only if doneTriggerTargetType is “gs2_script”

LogSetting

Log Output Setting

Log Output Setting defines how log data is exported. This type holds the GS2-Log Namespace identifier (Namespace ID), which is used to export log data. Specify the GS2-Log Namespace where log data is collected and stored in the GRN format for the Log Namespace ID (loggingNamespaceId). Configuring this setting ensures that log data for API requests and responses occurring within the specified Namespace is output to the target GS2-Log Namespace. GS2-Log provides real-time logs that can be used for system monitoring, analysis, debugging, and other operational purposes.

TypeConditionRequiredDefaultValue LimitsDescription
loggingNamespaceIdstring
~ 1024 charsGS2-Log Namespace GRN to output logs
Must be specified in GRN format starting with “grn:gs2:”.

TransactionSetting

Transaction Setting

Transaction Setting is obsolete: Transaction Setting (V2) replaces it. It is kept for Namespaces created before Transaction Setting (V2) existed, applies only while Transaction Setting (V2) is unset, and should not be chosen for a new Namespace.

It exposes each part of transaction execution as a separate field – AutoRun, AtomicCommit, asynchronous execution using GS2-Distributor, batch application of script results, asynchronous processing of acquire actions via GS2-JobQueue, and sequential execution – so combinations other than the recommended one can be built. Transaction Setting (V2) is that recommended combination expressed as a single setting. Keep using Transaction Setting only on a Namespace that already depends on a behaviour Transaction Setting (V2) does not offer: executing a transaction as a client-run stamp sheet, running AutoRun asynchronously via GS2-Distributor, or folding acquire actions into GS2-JobQueue.

TypeConditionRequiredDefaultValue LimitsDescription
enableAutoRunboolfalseWhether to automatically execute issued transactions on the server side
enableAtomicCommitbool{enableAutoRun} == truefalseWhether to commit transactions atomically
* Enabled only if enableAutoRun is true
transactionUseDistributorbool{enableAtomicCommit} == truefalseWhether to execute transactions asynchronously
* Enabled only if enableAtomicCommit is true
commitScriptResultInUseDistributorbool{transactionUseDistributor} == truefalseWhether to execute the commit processing of the script result asynchronously
* Enabled only if transactionUseDistributor is true
acquireActionUseJobQueuebool{enableAtomicCommit} == truefalseWhether to use GS2-JobQueue to execute the acquire action
* Enabled only if enableAtomicCommit is true
enableSequentialExecutionbool{enableAtomicCommit} == truefalseWhether to execute the actions of an atomic commit sequentially so that multiple actions may update the same row
* Enabled only if enableAtomicCommit is true
distributorNamespaceIdstring“grn:gs2:{region}:{ownerId}:distributor:default”~ 1024 charsGS2-Distributor Namespace GRN used to execute transactions
queueNamespaceIdstring“grn:gs2:{region}:{ownerId}:queue:default”~ 1024 charsGS2-JobQueue Namespace GRN used to execute transactions

CurrentTreeMaster

Currently active Node Model master data

This master data defines the Node Models currently active within the Namespace. GS2 uses JSON format files for managing master data. By uploading these files, you can apply the master data to the server.

To create JSON files, GS2 provides a master data editor within the management console. Additionally, you can create tools better suited for game operations and export JSON files in the appropriate format.

Request

Resource creation and update requests

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
modestring (enum)
enum {
  “direct”,
  “preUpload”
}
“direct”Update mode
DefinitionDescription
directDirectly update master data
preUploadUpload master data and then update
settingsstring{mode} == “direct”
✓*
~ 5242880 bytes (5MB)Master Data
* Required if mode is “direct”
uploadTokenstring{mode} == “preUpload”
✓*
~ 1024 charsToken obtained by pre-upload
Used to apply the uploaded master data.
* Required if mode is “preUpload”

GetAttr

Resource creation results that can be retrieved using the !GetAttr tag

TypeDescription
ItemCurrentTreeMasterUpdated master data of the currently active Node Models

Implementation Example

Type: GS2::SkillTree::CurrentTreeMaster
Properties:
  NamespaceName: namespace-0001
  Mode: direct
  Settings: {
    "version": "2023-09-06",
    "nodeModels": [
      {
        "name": "node-0001",
        "releaseConsumeActions": [
          {
            "action": "Gs2Inventory:ConsumeItemSetByUserId",
            "request": {
              "namespaceName": "namespace-0001",
              "inventoryName": "inventory-0001",
              "itemName": "item-0001",
              "consumeCount": 1,
              "itemSetName": "#{itemSetName}",
              "userId": "#{userId}"
            }
          }
        ],
        "restrainReturnRate": 0.5,
        "metadata": "NODE-0001"
      },
      {
        "name": "node-0002",
        "releaseConsumeActions": [
          {
            "action": "Gs2Inventory:ConsumeItemSetByUserId",
            "request": {
              "namespaceName": "namespace-0001",
              "inventoryName": "inventory-0001",
              "itemName": "item-0001",
              "consumeCount": 1,
              "itemSetName": "#{itemSetName}",
              "userId": "#{userId}"
            }
          }
        ],
        "restrainReturnRate": 0.5,
        "metadata": "NODE-0002",
        "premiseNodeNames": [
          "node-0001"
        ]
      },
      {
        "name": "node-0003",
        "releaseConsumeActions": [
          {
            "action": "Gs2Inventory:ConsumeItemSetByUserId",
            "request": {
              "namespaceName": "namespace-0001",
              "inventoryName": "inventory-0001",
              "itemName": "item-0001",
              "consumeCount": 1,
              "itemSetName": "#{itemSetName}",
              "userId": "#{userId}"
            }
          },
          {
            "action": "Gs2Inventory:ConsumeItemSetByUserId",
            "request": {
              "namespaceName": "namespace-0001",
              "inventoryName": "inventory-0001",
              "itemName": "item-0001",
              "consumeCount": 1,
              "itemSetName": "#{itemSetName}",
              "userId": "#{userId}"
            }
          }
        ],
        "restrainReturnRate": 0.5,
        "metadata": "NODE-0003",
        "premiseNodeNames": [
          "node-0002"
        ]
      }
    ]
  }
  UploadToken: null
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/skillTree"
    "github.com/gs2io/gs2-golang-cdk/inventory"
    "github.com/openlyinc/pointy"
)


SampleStack := core.NewStack()
skillTree.NewNamespace(
    &SampleStack,
    "namespace-0001",
    skillTree.NamespaceOptions{},
).MasterData(
    []skillTree.NodeModel{
        skillTree.NewNodeModel(
            "node-0001",
            []core.ConsumeAction{
                inventory.ConsumeItemSetByUserId(
                    "namespace-0001",
                    "inventory-0001",
                    "item-0001",
                    1,
                    pointy.String("#{itemSetName}"),
                ),
            },
            0.5,
            skillTree.NodeModelOptions{
                Metadata: pointy.String("NODE-0001"),
            },
        ),
        skillTree.NewNodeModel(
            "node-0002",
            []core.ConsumeAction{
                inventory.ConsumeItemSetByUserId(
                    "namespace-0001",
                    "inventory-0001",
                    "item-0001",
                    1,
                    pointy.String("#{itemSetName}"),
                ),
            },
            0.5,
            skillTree.NodeModelOptions{
                Metadata: pointy.String("NODE-0002"),
                PremiseNodeNames: []string{
                    "node-0001",
                },
            },
        ),
        skillTree.NewNodeModel(
            "node-0003",
            []core.ConsumeAction{
                inventory.ConsumeItemSetByUserId(
                    "namespace-0001",
                    "inventory-0001",
                    "item-0001",
                    1,
                    pointy.String("#{itemSetName}"),
                ),
                inventory.ConsumeItemSetByUserId(
                    "namespace-0001",
                    "inventory-0001",
                    "item-0001",
                    1,
                    pointy.String("#{itemSetName}"),
                ),
            },
            0.5,
            skillTree.NodeModelOptions{
                Metadata: pointy.String("NODE-0003"),
                PremiseNodeNames: []string{
                    "node-0002",
                },
            },
        ),
    },
)

println(SampleStack.Yaml())  // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        (new \Gs2Cdk\SkillTree\Model\Namespace_(
            stack: $this,
            name: "namespace-0001"
        ))->masterData(
            [
                new \Gs2Cdk\SkillTree\Model\NodeModel(
                    name:"node-0001",
                    releaseConsumeActions:[
                        new \Gs2Cdk\Inventory\StampSheet\ConsumeItemSetByUserId(
                            namespaceName: "namespace-0001",
                            inventoryName: "inventory-0001",
                            itemName: "item-0001",
                            consumeCount: 1,
                            itemSetName: "#{itemSetName}",
                            userId: "#{userId}"
                        ),
                    ],
                    restrainReturnRate:0.5,
                    options: new \Gs2Cdk\SkillTree\Model\Options\NodeModelOptions(
                        metadata:"NODE-0001"
                    )
                ),
                new \Gs2Cdk\SkillTree\Model\NodeModel(
                    name:"node-0002",
                    releaseConsumeActions:[
                        new \Gs2Cdk\Inventory\StampSheet\ConsumeItemSetByUserId(
                            namespaceName: "namespace-0001",
                            inventoryName: "inventory-0001",
                            itemName: "item-0001",
                            consumeCount: 1,
                            itemSetName: "#{itemSetName}",
                            userId: "#{userId}"
                        ),
                    ],
                    restrainReturnRate:0.5,
                    options: new \Gs2Cdk\SkillTree\Model\Options\NodeModelOptions(
                        metadata:"NODE-0002",
                        premiseNodeNames:[
                            "node-0001",
                        ]
                    )
                ),
                new \Gs2Cdk\SkillTree\Model\NodeModel(
                    name:"node-0003",
                    releaseConsumeActions:[
                        new \Gs2Cdk\Inventory\StampSheet\ConsumeItemSetByUserId(
                            namespaceName: "namespace-0001",
                            inventoryName: "inventory-0001",
                            itemName: "item-0001",
                            consumeCount: 1,
                            itemSetName: "#{itemSetName}",
                            userId: "#{userId}"
                        ),
                        new \Gs2Cdk\Inventory\StampSheet\ConsumeItemSetByUserId(
                            namespaceName: "namespace-0001",
                            inventoryName: "inventory-0001",
                            itemName: "item-0001",
                            consumeCount: 1,
                            itemSetName: "#{itemSetName}",
                            userId: "#{userId}"
                        ),
                    ],
                    restrainReturnRate:0.5,
                    options: new \Gs2Cdk\SkillTree\Model\Options\NodeModelOptions(
                        metadata:"NODE-0003",
                        premiseNodeNames:[
                            "node-0002",
                        ]
                    )
                )
            ]
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.skillTree.model.Namespace(
            this,
            "namespace-0001"
        ).masterData(
            Arrays.asList(
                new io.gs2.cdk.skillTree.model.NodeModel(
                    "node-0001",
                    Arrays.asList(
                        new io.gs2.cdk.inventory.stampSheet.ConsumeItemSetByUserId(
                            "namespace-0001",
                            "inventory-0001",
                            "item-0001",
                            1L,
                            "#{itemSetName}",
                            "#{userId}"
                        )
                    ),
                    0.5f,
                    new io.gs2.cdk.skillTree.model.options.NodeModelOptions()
                        .withMetadata("NODE-0001")
                ),
                new io.gs2.cdk.skillTree.model.NodeModel(
                    "node-0002",
                    Arrays.asList(
                        new io.gs2.cdk.inventory.stampSheet.ConsumeItemSetByUserId(
                            "namespace-0001",
                            "inventory-0001",
                            "item-0001",
                            1L,
                            "#{itemSetName}",
                            "#{userId}"
                        )
                    ),
                    0.5f,
                    new io.gs2.cdk.skillTree.model.options.NodeModelOptions()
                        .withMetadata("NODE-0002")
                        .withPremiseNodeNames(Arrays.asList(
                            "node-0001"
                        ))
                ),
                new io.gs2.cdk.skillTree.model.NodeModel(
                    "node-0003",
                    Arrays.asList(
                        new io.gs2.cdk.inventory.stampSheet.ConsumeItemSetByUserId(
                            "namespace-0001",
                            "inventory-0001",
                            "item-0001",
                            1L,
                            "#{itemSetName}",
                            "#{userId}"
                        ),
                        new io.gs2.cdk.inventory.stampSheet.ConsumeItemSetByUserId(
                            "namespace-0001",
                            "inventory-0001",
                            "item-0001",
                            1L,
                            "#{itemSetName}",
                            "#{userId}"
                        )
                    ),
                    0.5f,
                    new io.gs2.cdk.skillTree.model.options.NodeModelOptions()
                        .withMetadata("NODE-0003")
                        .withPremiseNodeNames(Arrays.asList(
                            "node-0002"
                        ))
                )
            )
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2SkillTree.Model.Namespace(
            stack: this,
            name: "namespace-0001"
        ).MasterData(
            new Gs2Cdk.Gs2SkillTree.Model.NodeModel[] {
                new Gs2Cdk.Gs2SkillTree.Model.NodeModel(
                    name: "node-0001",
                    releaseConsumeActions: new Gs2Cdk.Core.Model.ConsumeAction[]
                    {
                        new Gs2Cdk.Gs2Inventory.StampSheet.ConsumeItemSetByUserId(
                            namespaceName: "namespace-0001",
                            inventoryName: "inventory-0001",
                            itemName: "item-0001",
                            consumeCount: 1,
                            itemSetName: "#{itemSetName}",
                            userId: "#{userId}"
                        )
                    },
                    restrainReturnRate: 0.5f,
                    options: new Gs2Cdk.Gs2SkillTree.Model.Options.NodeModelOptions
                    {
                        metadata = "NODE-0001"
                    }
                ),
                new Gs2Cdk.Gs2SkillTree.Model.NodeModel(
                    name: "node-0002",
                    releaseConsumeActions: new Gs2Cdk.Core.Model.ConsumeAction[]
                    {
                        new Gs2Cdk.Gs2Inventory.StampSheet.ConsumeItemSetByUserId(
                            namespaceName: "namespace-0001",
                            inventoryName: "inventory-0001",
                            itemName: "item-0001",
                            consumeCount: 1,
                            itemSetName: "#{itemSetName}",
                            userId: "#{userId}"
                        )
                    },
                    restrainReturnRate: 0.5f,
                    options: new Gs2Cdk.Gs2SkillTree.Model.Options.NodeModelOptions
                    {
                        metadata = "NODE-0002",
                        premiseNodeNames = new string[]
                        {
                            "node-0001"
                        }
                    }
                ),
                new Gs2Cdk.Gs2SkillTree.Model.NodeModel(
                    name: "node-0003",
                    releaseConsumeActions: new Gs2Cdk.Core.Model.ConsumeAction[]
                    {
                        new Gs2Cdk.Gs2Inventory.StampSheet.ConsumeItemSetByUserId(
                            namespaceName: "namespace-0001",
                            inventoryName: "inventory-0001",
                            itemName: "item-0001",
                            consumeCount: 1,
                            itemSetName: "#{itemSetName}",
                            userId: "#{userId}"
                        ),
                        new Gs2Cdk.Gs2Inventory.StampSheet.ConsumeItemSetByUserId(
                            namespaceName: "namespace-0001",
                            inventoryName: "inventory-0001",
                            itemName: "item-0001",
                            consumeCount: 1,
                            itemSetName: "#{itemSetName}",
                            userId: "#{userId}"
                        )
                    },
                    restrainReturnRate: 0.5f,
                    options: new Gs2Cdk.Gs2SkillTree.Model.Options.NodeModelOptions
                    {
                        metadata = "NODE-0003",
                        premiseNodeNames = new string[]
                        {
                            "node-0002"
                        }
                    }
                )
            }
        );
    }
}

Debug.Log(new SampleStack().Yaml());  // Generate Template
import core from "@/gs2cdk/core";
import skillTree from "@/gs2cdk/skillTree";
import inventory from "@/gs2cdk/inventory";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new skillTree.model.Namespace(
            this,
            "namespace-0001",
        ).masterData(
            [
                new skillTree.model.NodeModel(
                    "node-0001",
                    [
                        new inventory.stampSheet.ConsumeItemSetByUserId(
                            "namespace-0001",
                            "inventory-0001",
                            "item-0001",
                            1,
                            "#{itemSetName}",
                            null,
                            "#{userId}"
                        ),
                    ],
                    0.5,
                    {
                        metadata: "NODE-0001"
                    }
                ),
                new skillTree.model.NodeModel(
                    "node-0002",
                    [
                        new inventory.stampSheet.ConsumeItemSetByUserId(
                            "namespace-0001",
                            "inventory-0001",
                            "item-0001",
                            1,
                            "#{itemSetName}",
                            null,
                            "#{userId}"
                        ),
                    ],
                    0.5,
                    {
                        metadata: "NODE-0002",
                        premiseNodeNames: [
                            "node-0001",
                        ]
                    }
                ),
                new skillTree.model.NodeModel(
                    "node-0003",
                    [
                        new inventory.stampSheet.ConsumeItemSetByUserId(
                            "namespace-0001",
                            "inventory-0001",
                            "item-0001",
                            1,
                            "#{itemSetName}",
                            null,
                            "#{userId}"
                        ),
                        new inventory.stampSheet.ConsumeItemSetByUserId(
                            "namespace-0001",
                            "inventory-0001",
                            "item-0001",
                            1,
                            "#{itemSetName}",
                            null,
                            "#{userId}"
                        ),
                    ],
                    0.5,
                    {
                        metadata: "NODE-0003",
                        premiseNodeNames: [
                            "node-0002",
                        ]
                    }
                )
            ]
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template
from gs2_cdk import Stack, core, skill_tree, inventory

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        skill_tree.Namespace(
            stack=self,
            name="namespace-0001",
        ).master_data(
            node_models=[
                skill_tree.NodeModel(
                    name='node-0001',
                    release_consume_actions=[
                        inventory.ConsumeItemSetByUserId(
                            namespace_name='namespace-0001',
                            inventory_name='inventory-0001',
                            item_name='item-0001',
                            consume_count=1,
                            item_set_name='#{itemSetName}',
                            user_id='#{userId}'
                        ),
                    ],
                    restrain_return_rate=0.5,
                    options=skill_tree.NodeModelOptions(
                        metadata = 'NODE-0001'
                    ),
                ),
                skill_tree.NodeModel(
                    name='node-0002',
                    release_consume_actions=[
                        inventory.ConsumeItemSetByUserId(
                            namespace_name='namespace-0001',
                            inventory_name='inventory-0001',
                            item_name='item-0001',
                            consume_count=1,
                            item_set_name='#{itemSetName}',
                            user_id='#{userId}'
                        ),
                    ],
                    restrain_return_rate=0.5,
                    options=skill_tree.NodeModelOptions(
                        metadata = 'NODE-0002',
                        premise_node_names = [
                            'node-0001',
                        ]
                    ),
                ),
                skill_tree.NodeModel(
                    name='node-0003',
                    release_consume_actions=[
                        inventory.ConsumeItemSetByUserId(
                            namespace_name='namespace-0001',
                            inventory_name='inventory-0001',
                            item_name='item-0001',
                            consume_count=1,
                            item_set_name='#{itemSetName}',
                            user_id='#{userId}'
                        ),
                        inventory.ConsumeItemSetByUserId(
                            namespace_name='namespace-0001',
                            inventory_name='inventory-0001',
                            item_name='item-0001',
                            consume_count=1,
                            item_set_name='#{itemSetName}',
                            user_id='#{userId}'
                        ),
                    ],
                    restrain_return_rate=0.5,
                    options=skill_tree.NodeModelOptions(
                        metadata = 'NODE-0003',
                        premise_node_names = [
                            'node-0002',
                        ]
                    ),
                ),
            ],
        )

print(SampleStack().yaml())  # Generate Template

NodeModel

Node Model

Defines a node within the skill tree, including its unlock cost, prerequisites, and refund behavior. Each node can have verify actions (conditions to check before release), consume actions (costs to pay), and prerequisite nodes that must be released first. When a node is restrained (reverted to unreleased), the consumed resources are partially refunded based on the restrain return rate. The return acquire actions are automatically calculated from the consume actions multiplied by the restrain return rate.

TypeConditionRequiredDefaultValue LimitsDescription
nodeModelIdstring
*
~ 1024 charsNode Model GRN
* Set automatically by the server
namestring
~ 128 charsNode Model name
Unique Node Model name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
metadatastring~ 2048 charsMetadata
Arbitrary values can be set in the metadata.
Since they do not affect GS2’s behavior, they can be used to store information used in the game.
releaseVerifyActionsList<VerifyAction>[]0 ~ 10 itemsList of Release Verify Actions
List of verify actions executed before releasing this node to check whether the conditions are satisfied.
For example, can verify that the player has a certain level or possesses a specific item.
If any verify action fails, the node release is rejected. Maximum 10 actions.
releaseConsumeActionsList<ConsumeAction>[]1 ~ 10 itemsRelease Consume Actions
List of consume actions executed when releasing this node, representing the cost to unlock it.
These actions are also used to calculate the return acquire actions: each consume action is reverted at the restrain return rate when the node is restrained.
At least 1 consume action is required. Maximum 10 actions.
returnAcquireActionsList<AcquireAction>0 ~ 10 itemsReturn Acquire Actions
List of acquire actions executed when restraining (reverting) this node, representing the resources returned to the player.
This field is auto-generated from the release consume actions multiplied by the restrain return rate.
For example, if release costs 100 gold and the return rate is 0.8, restraining returns 80 gold.
Maximum 10 actions.
restrainReturnRatefloat1.00.0 ~ 1.0Restrain Return Rate
The rate at which consumed resources are refunded when this node is restrained (reverted to unreleased state).
A value of 1.0 means full refund, 0.5 means half refund, and 0.0 means no refund.
Defaults to 1.0 (full refund). Valid range: 0.0 to 1.0.
premiseNodeNamesList<string>[]0 ~ 10 itemsList of Premise Node Names
Names of other node models that must be released before this node can be unlocked.
Defines the dependency graph of the skill tree. A node cannot be released unless all its prerequisite nodes are already released.
Maximum 10 prerequisite nodes.

ConsumeAction

Consume Action

TypeConditionRequiredDefaultValue LimitsDescription
actionstring (enum)
enum {
"Gs2AdReward:ConsumePointByUserId",
"Gs2Dictionary:DeleteEntriesByUserId",
"Gs2Enhance:DeleteProgressByUserId",
"Gs2Exchange:DeleteAwaitByUserId",
"Gs2Experience:SubExperienceByUserId",
"Gs2Experience:SubRankCapByUserId",
"Gs2Formation:SubMoldCapacityByUserId",
"Gs2Grade:SubGradeByUserId",
"Gs2Guild:DecreaseMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Idle:DecreaseMaximumIdleMinutesByUserId",
"Gs2Inbox:OpenMessageByUserId",
"Gs2Inbox:DeleteMessageByUserId",
"Gs2Inventory:ConsumeItemSetByUserId",
"Gs2Inventory:ConsumeSimpleItemsByUserId",
"Gs2Inventory:ConsumeBigItemByUserId",
"Gs2JobQueue:DeleteJobByUserId",
"Gs2Limit:CountUpByUserId",
"Gs2LoginReward:MarkReceivedByUserId",
"Gs2Mission:ReceiveByUserId",
"Gs2Mission:BatchReceiveByUserId",
"Gs2Mission:DecreaseCounterByUserId",
"Gs2Mission:ResetCounterByUserId",
"Gs2Money:WithdrawByUserId",
"Gs2Money:RecordReceipt",
"Gs2Money2:WithdrawByUserId",
"Gs2Money2:VerifyReceiptByUserId",
"Gs2Quest:DeleteProgressByUserId",
"Gs2Ranking2:CreateGlobalRankingReceivedRewardByUserId",
"Gs2Ranking2:CreateClusterRankingReceivedRewardByUserId",
"Gs2Schedule:DeleteTriggerByUserId",
"Gs2SerialKey:UseByUserId",
"Gs2Showcase:IncrementPurchaseCountByUserId",
"Gs2SkillTree:MarkRestrainByUserId",
"Gs2Stamina:DecreaseMaxValueByUserId",
"Gs2Stamina:ConsumeStaminaByUserId",
}
Type of Consume Action
requeststring
~ 524288 charsJSON string of the request used when executing the action

VerifyAction

Verify Action

TypeConditionRequiredDefaultValue LimitsDescription
actionstring (enum)
enum {
"Gs2Dictionary:VerifyEntryByUserId",
"Gs2Distributor:IfExpressionByUserId",
"Gs2Distributor:AndExpressionByUserId",
"Gs2Distributor:OrExpressionByUserId",
"Gs2Enchant:VerifyRarityParameterStatusByUserId",
"Gs2Experience:VerifyRankByUserId",
"Gs2Experience:VerifyRankCapByUserId",
"Gs2Grade:VerifyGradeByUserId",
"Gs2Grade:VerifyGradeUpMaterialByUserId",
"Gs2Guild:VerifyCurrentMaximumMemberCountByGuildName",
"Gs2Guild:VerifyIncludeMemberByUserId",
"Gs2Inventory:VerifyInventoryCurrentMaxCapacityByUserId",
"Gs2Inventory:VerifyItemSetByUserId",
"Gs2Inventory:VerifyReferenceOfByUserId",
"Gs2Inventory:VerifySimpleItemByUserId",
"Gs2Inventory:VerifyBigItemByUserId",
"Gs2Limit:VerifyCounterByUserId",
"Gs2Matchmaking:VerifyIncludeParticipantByUserId",
"Gs2Mission:VerifyCompleteByUserId",
"Gs2Mission:VerifyCounterValueByUserId",
"Gs2Ranking2:VerifyGlobalRankingScoreByUserId",
"Gs2Ranking2:VerifyClusterRankingScoreByUserId",
"Gs2Ranking2:VerifySubscribeRankingScoreByUserId",
"Gs2Schedule:VerifyTriggerByUserId",
"Gs2Schedule:VerifyEventByUserId",
"Gs2SerialKey:VerifyCodeByUserId",
"Gs2Stamina:VerifyStaminaValueByUserId",
"Gs2Stamina:VerifyStaminaMaxValueByUserId",
"Gs2Stamina:VerifyStaminaRecoverIntervalMinutesByUserId",
"Gs2Stamina:VerifyStaminaRecoverValueByUserId",
"Gs2Stamina:VerifyStaminaOverflowValueByUserId",
}
Type of Verify Action
requeststring
~ 524288 charsJSON string of the request used when executing the action

AcquireAction

Acquire Action

TypeConditionRequiredDefaultValue LimitsDescription
actionstring (enum)
enum {
"Gs2AdReward:AcquirePointByUserId",
"Gs2Dictionary:AddEntriesByUserId",
"Gs2Enchant:ReDrawBalanceParameterStatusByUserId",
"Gs2Enchant:SetBalanceParameterStatusByUserId",
"Gs2Enchant:ReDrawRarityParameterStatusByUserId",
"Gs2Enchant:AddRarityParameterStatusByUserId",
"Gs2Enchant:SetRarityParameterStatusByUserId",
"Gs2Enhance:DirectEnhanceByUserId",
"Gs2Enhance:UnleashByUserId",
"Gs2Enhance:CreateProgressByUserId",
"Gs2Exchange:ExchangeByUserId",
"Gs2Exchange:IncrementalExchangeByUserId",
"Gs2Exchange:CreateAwaitByUserId",
"Gs2Exchange:AcquireForceByUserId",
"Gs2Exchange:SkipByUserId",
"Gs2Experience:AddExperienceByUserId",
"Gs2Experience:SetExperienceByUserId",
"Gs2Experience:AddRankCapByUserId",
"Gs2Experience:SetRankCapByUserId",
"Gs2Experience:MultiplyAcquireActionsByUserId",
"Gs2Formation:AddMoldCapacityByUserId",
"Gs2Formation:SetMoldCapacityByUserId",
"Gs2Formation:AcquireActionsToFormProperties",
"Gs2Formation:SetFormByUserId",
"Gs2Formation:AcquireActionsToPropertyFormProperties",
"Gs2Friend:UpdateProfileByUserId",
"Gs2Grade:AddGradeByUserId",
"Gs2Grade:ApplyRankCapByUserId",
"Gs2Grade:MultiplyAcquireActionsByUserId",
"Gs2Guild:IncreaseMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Guild:SetMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Idle:IncreaseMaximumIdleMinutesByUserId",
"Gs2Idle:SetMaximumIdleMinutesByUserId",
"Gs2Idle:ReceiveByUserId",
"Gs2Inbox:SendMessageByUserId",
"Gs2Inventory:AddCapacityByUserId",
"Gs2Inventory:SetCapacityByUserId",
"Gs2Inventory:AcquireItemSetByUserId",
"Gs2Inventory:AcquireItemSetWithGradeByUserId",
"Gs2Inventory:AddReferenceOfByUserId",
"Gs2Inventory:DeleteReferenceOfByUserId",
"Gs2Inventory:AcquireSimpleItemsByUserId",
"Gs2Inventory:SetSimpleItemsByUserId",
"Gs2Inventory:AcquireBigItemByUserId",
"Gs2Inventory:SetBigItemByUserId",
"Gs2JobQueue:PushByUserId",
"Gs2Limit:CountDownByUserId",
"Gs2Limit:DeleteCounterByUserId",
"Gs2LoginReward:DeleteReceiveStatusByUserId",
"Gs2LoginReward:UnmarkReceivedByUserId",
"Gs2Lottery:DrawByUserId",
"Gs2Lottery:ResetBoxByUserId",
"Gs2Mission:RevertReceiveByUserId",
"Gs2Mission:IncreaseCounterByUserId",
"Gs2Mission:SetCounterByUserId",
"Gs2Money:DepositByUserId",
"Gs2Money:RevertRecordReceipt",
"Gs2Money2:DepositByUserId",
"Gs2Quest:CreateProgressByUserId",
"Gs2Schedule:TriggerByUserId",
"Gs2Schedule:ExtendTriggerByUserId",
"Gs2Script:InvokeScript",
"Gs2SerialKey:RevertUseByUserId",
"Gs2SerialKey:IssueOnce",
"Gs2Showcase:DecrementPurchaseCountByUserId",
"Gs2Showcase:ForceReDrawByUserId",
"Gs2SkillTree:MarkReleaseByUserId",
"Gs2Stamina:RecoverStaminaByUserId",
"Gs2Stamina:RaiseMaxValueByUserId",
"Gs2Stamina:SetMaxValueByUserId",
"Gs2Stamina:SetRecoverIntervalByUserId",
"Gs2Stamina:SetRecoverValueByUserId",
"Gs2StateMachine:StartStateMachineByUserId",
}
Type of Acquire Action
requeststring
~ 524288 charsJSON string of the request used when executing the action