GS2-Experience 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 targeted 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
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
descriptionstring~ 1024 charsDescription
transactionSettingTransactionSettingTransaction Setting
Configuration for controlling how distributed transactions are executed when processing experience operations. Supports auto-run, atomic commit, and async processing options.
rankCapScriptIdstring~ 1024 charsScript GRN to dynamically determine rank caps
changeExperienceScriptScriptSettingScript setting to be executed when experience value changes
Script Trigger Reference - changeExperience
changeRankScriptScriptSettingScript setting to be executed when rank changes
Script Trigger Reference - changeRank
changeRankCapScriptScriptSettingScript setting to be executed when the rank cap changes
Script Trigger Reference - changeRankCap
overflowExperienceScriptstring~ 1024 charsScript GRN to run when experience overflows
Script Trigger Reference - overflowExperience
logSettingLogSettingLog Output Setting
Configuration for outputting log data of experience operations to GS2-Log. By specifying a GS2-Log namespace, API request and response logs for experience value changes, rank-ups, and rank cap modifications can be collected.

GetAttr

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

TypeDescription
ItemNamespaceNamespace created

Implementation Example

Type: GS2::Experience::Namespace
Properties:
  Name: namespace-0001
  Description: null
  TransactionSetting: null
  RankCapScriptId: null
  ChangeExperienceScript: null
  ChangeRankScript: null
  ChangeRankCapScript: null
  OverflowExperienceScript: 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/experience"
)


SampleStack := core.NewStack()
experience.NewNamespace(
    &SampleStack,
    "namespace-0001",
    experience.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\Experience\Model\Namespace_(
            stack: $this,
            name: "namespace-0001",
            options: new \Gs2Cdk\Experience\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.experience.model.Namespace(
                this,
                "namespace-0001",
                new io.gs2.cdk.experience.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.Gs2Experience.Model.Namespace(
            stack: this,
            name: "namespace-0001",
            options: new Gs2Cdk.Gs2Experience.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 experience from "@/gs2cdk/experience";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new experience.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, experience

class SampleStack(Stack):

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

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

TransactionSetting

Transaction Setting

Transaction Settings control how transactions are executed, their consistency, asynchronous processing, and conflict avoidance mechanisms. Combining features like AutoRun, AtomicCommit, asynchronous execution using GS2-Distributor, batch application of script results, and asynchronous Acquire Actions via GS2-JobQueue enables robust transaction management tailored to game logic.

TypeConditionRequiredDefaultValue LimitsDescription
enableAutoRunboolfalseWhether to automatically execute issued transactions on the server side
enableAtomicCommitbool{enableAutoRun} == truefalseWhether to commit the execution of transactions atomically
* Applicable only if enableAutoRun is true
transactionUseDistributorbool{enableAtomicCommit} == truefalseWhether to execute transactions asynchronously
* Applicable only if enableAtomicCommit is true
commitScriptResultInUseDistributorbool{transactionUseDistributor} == truefalseWhether to execute the commit processing of the script result asynchronously
* Applicable only if transactionUseDistributor is true
acquireActionUseJobQueuebool{enableAtomicCommit} == truefalseWhether to use GS2-JobQueue to execute the acquire action
* Applicable 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

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. Synchronous execution blocks processing until the script has finished executing. Instead, you can use the script’s execution results to halt API execution or control the API’s response content.

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”How to execute asynchronous scripts
Specifies the type of script to use for asynchronous execution.
You can choose from “Do not use asynchronous execution (none)”, “Use GS2-Script (gs2_script)”, and “Use Amazon EventBridge (aws)”.
DefinitionDescription
“none”None
“gs2_script”GS2-Script
“aws”Amazon EventBridge
doneTriggerScriptIdstring{doneTriggerTargetType} == “gs2_script”~ 1024 charsGS2-Script script GRN for asynchronous execution
Must be specified in GRN format starting with “grn:gs2:”.
* Applicable only if doneTriggerTargetType is “gs2_script”
doneTriggerQueueNamespaceIdstring{doneTriggerTargetType} == “gs2_script”~ 1024 charsGS2-JobQueue namespace GRN to execute asynchronous execution scripts
If you want to execute asynchronous execution scripts via GS2-JobQueue instead of executing them directly, specify the GS2-JobQueue namespace GRN.
There are not many cases where GS2-JobQueue is required, so you generally do not need to specify it unless you have a specific reason.
* Applicable 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) 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:”.

CurrentExperienceMaster

Currently active Experience Model master data

This master data describes the definitions of Experience Models currently active within the namespace. GS2 uses JSON format files for managing master data. By uploading these files, the master data settings are updated on 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
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
modeString Enum
enum {
  “direct”,
  “preUpload”
}
“direct”Update mode
DefinitionDescription
“direct”Directly update master data
“preUpload”Upload master data and then update
settingsstring{mode} == “direct”
✓*
~ 5242880 charsMaster 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
ItemCurrentExperienceMasterUpdated master data of the currently active Experience Models

Implementation Example

Type: GS2::Experience::CurrentExperienceMaster
Properties:
  NamespaceName: namespace-0001
  Mode: direct
  Settings: {
    "version": "2019-01-11",
    "experienceModels": [
      {
        "name": "character_ssr",
        "defaultExperience": 0,
        "defaultRankCap": 50,
        "maxRankCap": 80,
        "rankThreshold":
          {
            "metadata": "CHARACTER",
            "values": [
              100,
              200,
              300,
              400,
              500
            ]
          },
        "metadata": "SSR"
      },
      {
        "name": "character_sr",
        "defaultExperience": 0,
        "defaultRankCap": 40,
        "maxRankCap": 70,
        "rankThreshold":
          {
            "metadata": "CHARACTER",
            "values": [
              100,
              200,
              300,
              400,
              500
            ]
          },
        "metadata": "SR"
      },
      {
        "name": "character_r",
        "defaultExperience": 0,
        "defaultRankCap": 30,
        "maxRankCap": 60,
        "rankThreshold":
          {
            "metadata": "CHARACTER",
            "values": [
              100,
              200,
              300,
              400,
              500
            ]
          },
        "metadata": "R"
      },
      {
        "name": "equipment",
        "defaultExperience": 0,
        "defaultRankCap": 30,
        "maxRankCap": 50,
        "rankThreshold":
          {
            "metadata": "EQUIPMENT",
            "values": [
              200,
              400,
              600,
              800,
              1000
            ]
          },
        "metadata": "EQUIPMENT",
        "acquireActionRates": [
          {
            "name": "rate-0001",
            "mode": "big",
            "bigRates": [
              "1",
              "10",
              "100",
              "1000",
              "10000"
            ]
          }
        ]
      },
      {
        "name": "skill",
        "defaultExperience": 0,
        "defaultRankCap": 10,
        "maxRankCap": 20,
        "rankThreshold":
          {
            "metadata": "SKILL",
            "values": [
              300,
              600,
              900,
              1200,
              1500
            ]
          },
        "metadata": "SKILL"
      }
    ]
  }
  UploadToken: null
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/experience"
    "github.com/openlyinc/pointy"
)


SampleStack := core.NewStack()
experience.NewNamespace(
    &SampleStack,
    "namespace-0001",
    experience.NamespaceOptions{},
).MasterData(
    []experience.ExperienceModel{
        experience.NewExperienceModel(
            "character_ssr",
            0,
            50,
            80,
            experience.NewThreshold(
                []int64{
                    100,
                    200,
                    300,
                    400,
                    500,
                },
                experience.ThresholdOptions{
                    Metadata: pointy.String("CHARACTER"),
                },
            ),
            experience.ExperienceModelOptions{
                Metadata: pointy.String("SSR"),
            },
        ),
        experience.NewExperienceModel(
            "character_sr",
            0,
            40,
            70,
            experience.NewThreshold(
                []int64{
                    100,
                    200,
                    300,
                    400,
                    500,
                },
                experience.ThresholdOptions{
                    Metadata: pointy.String("CHARACTER"),
                },
            ),
            experience.ExperienceModelOptions{
                Metadata: pointy.String("SR"),
            },
        ),
        experience.NewExperienceModel(
            "character_r",
            0,
            30,
            60,
            experience.NewThreshold(
                []int64{
                    100,
                    200,
                    300,
                    400,
                    500,
                },
                experience.ThresholdOptions{
                    Metadata: pointy.String("CHARACTER"),
                },
            ),
            experience.ExperienceModelOptions{
                Metadata: pointy.String("R"),
            },
        ),
        experience.NewExperienceModel(
            "equipment",
            0,
            30,
            50,
            experience.NewThreshold(
                []int64{
                    200,
                    400,
                    600,
                    800,
                    1000,
                },
                experience.ThresholdOptions{
                    Metadata: pointy.String("EQUIPMENT"),
                },
            ),
            experience.ExperienceModelOptions{
                Metadata: pointy.String("EQUIPMENT"),
                AcquireActionRates: []experience.AcquireActionRate{
                    experience.NewAcquireActionRate(
                        "rate-0001",
                        experience.AcquireActionRateModeBig,
                        experience.AcquireActionRateOptions{
                            BigRates: []string{
                                "1",
                                "10",
                                "100",
                                "1000",
                                "10000",
                            },
                        },
                    ),
                },
            },
        ),
        experience.NewExperienceModel(
            "skill",
            0,
            10,
            20,
            experience.NewThreshold(
                []int64{
                    300,
                    600,
                    900,
                    1200,
                    1500,
                },
                experience.ThresholdOptions{
                    Metadata: pointy.String("SKILL"),
                },
            ),
            experience.ExperienceModelOptions{
                Metadata: pointy.String("SKILL"),
            },
        ),
    },
)

println(SampleStack.Yaml())  // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        (new \Gs2Cdk\Experience\Model\Namespace_(
            stack: $this,
            name: "namespace-0001"
        ))->masterData(
            [
                new \Gs2Cdk\Experience\Model\ExperienceModel(
                    name:"character_ssr",
                    defaultExperience:0,
                    defaultRankCap:50,
                    maxRankCap:80,
                    rankThreshold:new \Gs2Cdk\Experience\Model\Threshold(
                        values: [
                            100,
                            200,
                            300,
                            400,
                            500,
                        ],
                        options: new \Gs2Cdk\Experience\Model\Options\ThresholdOptions(
                            metadata: "CHARACTER",
                        )
                    ),
                    options: new \Gs2Cdk\Experience\Model\Options\ExperienceModelOptions(
                        metadata:"SSR"
                    )
                ),
                new \Gs2Cdk\Experience\Model\ExperienceModel(
                    name:"character_sr",
                    defaultExperience:0,
                    defaultRankCap:40,
                    maxRankCap:70,
                    rankThreshold:new \Gs2Cdk\Experience\Model\Threshold(
                        values: [
                            100,
                            200,
                            300,
                            400,
                            500,
                        ],
                        options: new \Gs2Cdk\Experience\Model\Options\ThresholdOptions(
                            metadata: "CHARACTER",
                        )
                    ),
                    options: new \Gs2Cdk\Experience\Model\Options\ExperienceModelOptions(
                        metadata:"SR"
                    )
                ),
                new \Gs2Cdk\Experience\Model\ExperienceModel(
                    name:"character_r",
                    defaultExperience:0,
                    defaultRankCap:30,
                    maxRankCap:60,
                    rankThreshold:new \Gs2Cdk\Experience\Model\Threshold(
                        values: [
                            100,
                            200,
                            300,
                            400,
                            500,
                        ],
                        options: new \Gs2Cdk\Experience\Model\Options\ThresholdOptions(
                            metadata: "CHARACTER",
                        )
                    ),
                    options: new \Gs2Cdk\Experience\Model\Options\ExperienceModelOptions(
                        metadata:"R"
                    )
                ),
                new \Gs2Cdk\Experience\Model\ExperienceModel(
                    name:"equipment",
                    defaultExperience:0,
                    defaultRankCap:30,
                    maxRankCap:50,
                    rankThreshold:new \Gs2Cdk\Experience\Model\Threshold(
                        values: [
                            200,
                            400,
                            600,
                            800,
                            1000,
                        ],
                        options: new \Gs2Cdk\Experience\Model\Options\ThresholdOptions(
                            metadata: "EQUIPMENT",
                        )
                    ),
                    options: new \Gs2Cdk\Experience\Model\Options\ExperienceModelOptions(
                        metadata:"EQUIPMENT",
                        acquireActionRates:[
                            new \Gs2Cdk\Experience\Model\AcquireActionRate(
                                name: "rate-0001",
                                mode: Gs2Cdk\Experience\Model\Enums\AcquireActionRateMode::BIG,
                                options: new \Gs2Cdk\Experience\Model\Options\AcquireActionRateOptions(
                                    bigRates: [
                                        "1",
                                        "10",
                                        "100",
                                        "1000",
                                        "10000",
                                    ],
                                )
                            ),
                        ]
                    )
                ),
                new \Gs2Cdk\Experience\Model\ExperienceModel(
                    name:"skill",
                    defaultExperience:0,
                    defaultRankCap:10,
                    maxRankCap:20,
                    rankThreshold:new \Gs2Cdk\Experience\Model\Threshold(
                        values: [
                            300,
                            600,
                            900,
                            1200,
                            1500,
                        ],
                        options: new \Gs2Cdk\Experience\Model\Options\ThresholdOptions(
                            metadata: "SKILL",
                        )
                    ),
                    options: new \Gs2Cdk\Experience\Model\Options\ExperienceModelOptions(
                        metadata:"SKILL"
                    )
                )
            ]
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.experience.model.Namespace(
            this,
            "namespace-0001"
        ).masterData(
            Arrays.asList(
                new io.gs2.cdk.experience.model.ExperienceModel(
                    "character_ssr",
                    0L,
                    50L,
                    80L,
                    new io.gs2.cdk.experience.model.Threshold(
                        Arrays.asList(
                            100L,
                            200L,
                            300L,
                            400L,
                            500L
                        ),
                        new io.gs2.cdk.experience.model.options.ThresholdOptions()
                            .withMetadata("CHARACTER")
                    ),
                    new io.gs2.cdk.experience.model.options.ExperienceModelOptions()
                        .withMetadata("SSR")
                ),
                new io.gs2.cdk.experience.model.ExperienceModel(
                    "character_sr",
                    0L,
                    40L,
                    70L,
                    new io.gs2.cdk.experience.model.Threshold(
                        Arrays.asList(
                            100L,
                            200L,
                            300L,
                            400L,
                            500L
                        ),
                        new io.gs2.cdk.experience.model.options.ThresholdOptions()
                            .withMetadata("CHARACTER")
                    ),
                    new io.gs2.cdk.experience.model.options.ExperienceModelOptions()
                        .withMetadata("SR")
                ),
                new io.gs2.cdk.experience.model.ExperienceModel(
                    "character_r",
                    0L,
                    30L,
                    60L,
                    new io.gs2.cdk.experience.model.Threshold(
                        Arrays.asList(
                            100L,
                            200L,
                            300L,
                            400L,
                            500L
                        ),
                        new io.gs2.cdk.experience.model.options.ThresholdOptions()
                            .withMetadata("CHARACTER")
                    ),
                    new io.gs2.cdk.experience.model.options.ExperienceModelOptions()
                        .withMetadata("R")
                ),
                new io.gs2.cdk.experience.model.ExperienceModel(
                    "equipment",
                    0L,
                    30L,
                    50L,
                    new io.gs2.cdk.experience.model.Threshold(
                        Arrays.asList(
                            200L,
                            400L,
                            600L,
                            800L,
                            1000L
                        ),
                        new io.gs2.cdk.experience.model.options.ThresholdOptions()
                            .withMetadata("EQUIPMENT")
                    ),
                    new io.gs2.cdk.experience.model.options.ExperienceModelOptions()
                        .withMetadata("EQUIPMENT")
                        .withAcquireActionRates(Arrays.asList(
                            new io.gs2.cdk.experience.model.AcquireActionRate(
                                "rate-0001",
                                io.gs2.cdk.experience.model.enums.AcquireActionRateMode.BIG,
                                new io.gs2.cdk.experience.model.options.AcquireActionRateOptions()
                                    .withBigRates(Arrays.asList(
                                        "1",
                                        "10",
                                        "100",
                                        "1000",
                                        "10000"
                                    ))
                            )
                        ))
                ),
                new io.gs2.cdk.experience.model.ExperienceModel(
                    "skill",
                    0L,
                    10L,
                    20L,
                    new io.gs2.cdk.experience.model.Threshold(
                        Arrays.asList(
                            300L,
                            600L,
                            900L,
                            1200L,
                            1500L
                        ),
                        new io.gs2.cdk.experience.model.options.ThresholdOptions()
                            .withMetadata("SKILL")
                    ),
                    new io.gs2.cdk.experience.model.options.ExperienceModelOptions()
                        .withMetadata("SKILL")
                )
            )
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Experience.Model.Namespace(
            stack: this,
            name: "namespace-0001"
        ).MasterData(
            new Gs2Cdk.Gs2Experience.Model.ExperienceModel[] {
                new Gs2Cdk.Gs2Experience.Model.ExperienceModel(
                    name: "character_ssr",
                    defaultExperience: 0L,
                    defaultRankCap: 50L,
                    maxRankCap: 80L,
                    rankThreshold: new Gs2Cdk.Gs2Experience.Model.Threshold(
                        values: new long[]
                        {
                            100L,
                            200L,
                            300L,
                            400L,
                            500L,
                        },
                        options: new Gs2Cdk.Gs2Experience.Model.Options.ThresholdOptions
                        {
                            metadata = "CHARACTER"
                        }
                    ),
                    options: new Gs2Cdk.Gs2Experience.Model.Options.ExperienceModelOptions
                    {
                        metadata = "SSR"
                    }
                ),
                new Gs2Cdk.Gs2Experience.Model.ExperienceModel(
                    name: "character_sr",
                    defaultExperience: 0L,
                    defaultRankCap: 40L,
                    maxRankCap: 70L,
                    rankThreshold: new Gs2Cdk.Gs2Experience.Model.Threshold(
                        values: new long[]
                        {
                            100L,
                            200L,
                            300L,
                            400L,
                            500L,
                        },
                        options: new Gs2Cdk.Gs2Experience.Model.Options.ThresholdOptions
                        {
                            metadata = "CHARACTER"
                        }
                    ),
                    options: new Gs2Cdk.Gs2Experience.Model.Options.ExperienceModelOptions
                    {
                        metadata = "SR"
                    }
                ),
                new Gs2Cdk.Gs2Experience.Model.ExperienceModel(
                    name: "character_r",
                    defaultExperience: 0L,
                    defaultRankCap: 30L,
                    maxRankCap: 60L,
                    rankThreshold: new Gs2Cdk.Gs2Experience.Model.Threshold(
                        values: new long[]
                        {
                            100L,
                            200L,
                            300L,
                            400L,
                            500L,
                        },
                        options: new Gs2Cdk.Gs2Experience.Model.Options.ThresholdOptions
                        {
                            metadata = "CHARACTER"
                        }
                    ),
                    options: new Gs2Cdk.Gs2Experience.Model.Options.ExperienceModelOptions
                    {
                        metadata = "R"
                    }
                ),
                new Gs2Cdk.Gs2Experience.Model.ExperienceModel(
                    name: "equipment",
                    defaultExperience: 0L,
                    defaultRankCap: 30L,
                    maxRankCap: 50L,
                    rankThreshold: new Gs2Cdk.Gs2Experience.Model.Threshold(
                        values: new long[]
                        {
                            200L,
                            400L,
                            600L,
                            800L,
                            1000L,
                        },
                        options: new Gs2Cdk.Gs2Experience.Model.Options.ThresholdOptions
                        {
                            metadata = "EQUIPMENT"
                        }
                    ),
                    options: new Gs2Cdk.Gs2Experience.Model.Options.ExperienceModelOptions
                    {
                        metadata = "EQUIPMENT",
                        acquireActionRates = new Gs2Cdk.Gs2Experience.Model.AcquireActionRate[]
                        {
                            new Gs2Cdk.Gs2Experience.Model.AcquireActionRate(
                                name: "rate-0001",
                                mode: Gs2Cdk.Gs2Experience.Model.Enums.AcquireActionRateMode.Big,
                                options: new Gs2Cdk.Gs2Experience.Model.Options.AcquireActionRateOptions
                                {
                                    bigRates = new string[]
                                    {
                                        "1",
                                        "10",
                                        "100",
                                        "1000",
                                        "10000",
                                    }
                                }
                            )
                        }
                    }
                ),
                new Gs2Cdk.Gs2Experience.Model.ExperienceModel(
                    name: "skill",
                    defaultExperience: 0L,
                    defaultRankCap: 10L,
                    maxRankCap: 20L,
                    rankThreshold: new Gs2Cdk.Gs2Experience.Model.Threshold(
                        values: new long[]
                        {
                            300L,
                            600L,
                            900L,
                            1200L,
                            1500L,
                        },
                        options: new Gs2Cdk.Gs2Experience.Model.Options.ThresholdOptions
                        {
                            metadata = "SKILL"
                        }
                    ),
                    options: new Gs2Cdk.Gs2Experience.Model.Options.ExperienceModelOptions
                    {
                        metadata = "SKILL"
                    }
                )
            }
        );
    }
}

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

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new experience.model.Namespace(
            this,
            "namespace-0001",
        ).masterData(
            [
                new experience.model.ExperienceModel(
                    "character_ssr",
                    0,
                    50,
                    80,
                    new experience.model.Threshold(
                        [
                            100,
                            200,
                            300,
                            400,
                            500,
                        ],
                        {
                            metadata: "CHARACTER"
                        }
                    ),
                    {
                        metadata: "SSR"
                    }
                ),
                new experience.model.ExperienceModel(
                    "character_sr",
                    0,
                    40,
                    70,
                    new experience.model.Threshold(
                        [
                            100,
                            200,
                            300,
                            400,
                            500,
                        ],
                        {
                            metadata: "CHARACTER"
                        }
                    ),
                    {
                        metadata: "SR"
                    }
                ),
                new experience.model.ExperienceModel(
                    "character_r",
                    0,
                    30,
                    60,
                    new experience.model.Threshold(
                        [
                            100,
                            200,
                            300,
                            400,
                            500,
                        ],
                        {
                            metadata: "CHARACTER"
                        }
                    ),
                    {
                        metadata: "R"
                    }
                ),
                new experience.model.ExperienceModel(
                    "equipment",
                    0,
                    30,
                    50,
                    new experience.model.Threshold(
                        [
                            200,
                            400,
                            600,
                            800,
                            1000,
                        ],
                        {
                            metadata: "EQUIPMENT"
                        }
                    ),
                    {
                        metadata: "EQUIPMENT",
                        acquireActionRates: [
                            new experience.model.AcquireActionRate(
                                "rate-0001",
                                experience.model.AcquireActionRateMode.BIG,
                                {
                                    bigRates: [
                                        "1",
                                        "10",
                                        "100",
                                        "1000",
                                        "10000",
                                    ]
                                }
                            ),
                        ]
                    }
                ),
                new experience.model.ExperienceModel(
                    "skill",
                    0,
                    10,
                    20,
                    new experience.model.Threshold(
                        [
                            300,
                            600,
                            900,
                            1200,
                            1500,
                        ],
                        {
                            metadata: "SKILL"
                        }
                    ),
                    {
                        metadata: "SKILL"
                    }
                )
            ]
        );
    }
}

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

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        experience.Namespace(
            stack=self,
            name="namespace-0001",
        ).master_data(
            experience_models=[
                experience.ExperienceModel(
                    name='character_ssr',
                    default_experience=0,
                    default_rank_cap=50,
                    max_rank_cap=80,
                    rank_threshold=experience.Threshold(
                        values=[
                            100,
                            200,
                            300,
                            400,
                            500,
                        ],
                        options=experience.ThresholdOptions(
                            metadata='CHARACTER',
                        ),
                    ),
                    options=experience.ExperienceModelOptions(
                        metadata = 'SSR'
                    ),
                ),
                experience.ExperienceModel(
                    name='character_sr',
                    default_experience=0,
                    default_rank_cap=40,
                    max_rank_cap=70,
                    rank_threshold=experience.Threshold(
                        values=[
                            100,
                            200,
                            300,
                            400,
                            500,
                        ],
                        options=experience.ThresholdOptions(
                            metadata='CHARACTER',
                        ),
                    ),
                    options=experience.ExperienceModelOptions(
                        metadata = 'SR'
                    ),
                ),
                experience.ExperienceModel(
                    name='character_r',
                    default_experience=0,
                    default_rank_cap=30,
                    max_rank_cap=60,
                    rank_threshold=experience.Threshold(
                        values=[
                            100,
                            200,
                            300,
                            400,
                            500,
                        ],
                        options=experience.ThresholdOptions(
                            metadata='CHARACTER',
                        ),
                    ),
                    options=experience.ExperienceModelOptions(
                        metadata = 'R'
                    ),
                ),
                experience.ExperienceModel(
                    name='equipment',
                    default_experience=0,
                    default_rank_cap=30,
                    max_rank_cap=50,
                    rank_threshold=experience.Threshold(
                        values=[
                            200,
                            400,
                            600,
                            800,
                            1000,
                        ],
                        options=experience.ThresholdOptions(
                            metadata='EQUIPMENT',
                        ),
                    ),
                    options=experience.ExperienceModelOptions(
                        metadata = 'EQUIPMENT',
                        acquire_action_rates = [
                            experience.AcquireActionRate(
                                name='rate-0001',
                                mode=experience.AcquireActionRateMode.BIG,
                                options=experience.AcquireActionRateOptions(
                                    big_rates=[
                                        '1',
                                        '10',
                                        '100',
                                        '1000',
                                        '10000',
                                    ],
                                ),
                            ),
                        ]
                    ),
                ),
                experience.ExperienceModel(
                    name='skill',
                    default_experience=0,
                    default_rank_cap=10,
                    max_rank_cap=20,
                    rank_threshold=experience.Threshold(
                        values=[
                            300,
                            600,
                            900,
                            1200,
                            1500,
                        ],
                        options=experience.ThresholdOptions(
                            metadata='SKILL',
                        ),
                    ),
                    options=experience.ExperienceModelOptions(
                        metadata = 'SKILL'
                    ),
                ),
            ],
        )

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

ExperienceModel

Experience Model

Defines the rules for an experience and rank system. Sets thresholds for the experience required to rank up, as well as the default rank cap and maximum rank cap. The rank cap limits the maximum rank a status can reach, and can be raised per-status up to the maximum rank cap (e.g., through limit breaking). Optionally includes acquire action rate tables that adjust reward multipliers based on the current rank.

TypeConditionRequiredDefaultValue LimitsDescription
experienceModelIdstring
*
~ 1024 charsExperience Model GRN
* Set automatically by the server
namestring
~ 128 charsExperience Model name
Experience Model-specific 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.
defaultExperiencelong00 ~ 9223372036854775805Initial Experience Value
The experience value assigned to a newly created status. Typically set to 0 so that players start at the beginning of the progression. The initial rank is determined from this value using the rank threshold table.
defaultRankCaplong
0 ~ 9223372036854775805Initial value of rank cap
The default maximum rank that a newly created status can reach. Experience beyond this rank’s threshold is discarded or triggers an overflow script. The rank cap can be raised per-status up to maxRankCap through operations like limit breaking.
maxRankCaplong
0 ~ 9223372036854775805Maximum rank cap
The absolute upper limit for the rank cap. Even through rank cap increase operations (such as limit breaking), the rank cap cannot exceed this value. Must be greater than or equal to defaultRankCap.
rankThresholdThreshold
Rank Up Threshold
References the threshold table that defines the cumulative experience values required for each rank. The number of entries in the threshold determines the maximum possible rank, and each entry’s value specifies the experience needed to reach the next rank.
acquireActionRatesList<AcquireActionRate>0 ~ 100 itemsList of Reward addition tables
Defines rank-based multiplier tables that adjust reward quantities when the status’s rank is used as a reference. Each table maps ranks to multipliers, enabling mechanics like higher-rank characters receiving more rewards from the same actions.

Threshold

Rank Up Threshold

The Rank Up Threshold is a sequence of numbers needed to determine rank (level) from experience. If the value [10, 20] is set, experience values between 1 and 9 are rank 1, experience values between 10 and 19 are rank 2, experience values at 20 are rank 3, and no more experience values can be obtained.

TypeConditionRequiredDefaultValue LimitsDescription
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.
valuesList<long>
1 ~ 10000 itemsList of Rank Up Experience Threshold
An ordered array of cumulative experience values defining the rank progression. The number of entries determines the maximum achievable rank. For example, [10, 20] means rank 1 at 0-9 EXP, rank 2 at 10-19 EXP, and rank 3 at 20+ EXP (with no further gains possible).

AcquireActionRate

Reward Addition Table

Defines a rank-based multiplier table that adjusts reward quantities based on the status’s current rank. Each entry in the table corresponds to a rank and specifies a multiplier applied to the acquisition amount. Supports both standard double-precision values and big number string representations for large-scale calculations.

TypeConditionRequiredDefaultValue LimitsDescription
namestring
~ 128 charsReward addition table name
A unique identifier for this reward addition table. Referenced when specifying which multiplier table to apply to a particular acquire action.
modeString Enum
enum {
  “double”,
  “big”
}
“double”Reward addition table type
Selects the numeric precision for the multiplier values. Use “double” for standard floating-point numbers (up to 2^48), or “big” for string-represented numbers supporting up to 1024 digits when large-scale calculations are needed.
DefinitionDescription
“double”Floating point number less than 2^48
“big”Floating point number less than 1024 digits
ratesList<double>{mode} == “double”
✓*
1 ~ 10000 itemsAmount added per rank (multiplier)
An array of multiplier values indexed by rank. The i-th entry defines the reward multiplier applied when the status is at rank i. Used when the mode is set to “double”.
* Required if mode is “double”
bigRatesList<string>{mode} == “big”
✓*
1 ~ 10000 itemsAmount added per rank (multiplier)
An array of string-represented multiplier values indexed by rank. The i-th entry defines the reward multiplier applied when the status is at rank i. Used when the mode is set to “big” for calculations requiring large-number precision.
* Required if mode is “big”