GS2-Experience Deploy/CDK Reference
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
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| description | string | ~ 1024 chars | Description | |||
| transactionSetting | TransactionSetting | Transaction Setting Configuration for controlling how distributed transactions are executed when processing experience operations. Supports auto-run, atomic commit, and async processing options. | ||||
| rankCapScriptId | string | ~ 1024 chars | Script GRN to dynamically determine rank caps | |||
| changeExperienceScript | ScriptSetting | Script setting to be executed when experience value changes Script Trigger Reference - changeExperience | ||||
| changeRankScript | ScriptSetting | Script setting to be executed when rank changes Script Trigger Reference - changeRank | ||||
| changeRankCapScript | ScriptSetting | Script setting to be executed when the rank cap changes Script Trigger Reference - changeRankCap | ||||
| overflowExperienceScript | string | ~ 1024 chars | Script GRN to run when experience overflows Script Trigger Reference - overflowExperience | |||
| logSetting | LogSetting | Log 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
| Type | Description | |
|---|---|---|
| Item | Namespace | Namespace 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-0001import (
"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 Templateclass 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 Templateclass 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 Templatepublic 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 Templateimport 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 Templatefrom 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 TemplateTransactionSetting
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.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| enableAutoRun | bool | false | Whether to automatically execute issued transactions on the server side | |||
| enableAtomicCommit | bool | {enableAutoRun} == true | false | Whether to commit the execution of transactions atomically * Applicable only if enableAutoRun is true | ||
| transactionUseDistributor | bool | {enableAtomicCommit} == true | false | Whether to execute transactions asynchronously * Applicable only if enableAtomicCommit is true | ||
| commitScriptResultInUseDistributor | bool | {transactionUseDistributor} == true | false | Whether to execute the commit processing of the script result asynchronously * Applicable only if transactionUseDistributor is true | ||
| acquireActionUseJobQueue | bool | {enableAtomicCommit} == true | false | Whether to use GS2-JobQueue to execute the acquire action * Applicable only if enableAtomicCommit is true | ||
| distributorNamespaceId | string | “grn:gs2:{region}:{ownerId}:distributor:default” | ~ 1024 chars | GS2-Distributor Namespace GRN used to execute transactions | ||
| queueNamespaceId | string | “grn:gs2:{region}:{ownerId}:queue:default” | ~ 1024 chars | GS2-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.
| Type | Condition | Required | Default | Value Limits | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| triggerScriptId | string | ~ 1024 chars | GS2-Script script GRN
executed synchronously when the API is executed Must be specified in GRN format starting with “grn:gs2:”. | |||||||||||
| doneTriggerTargetType | String 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)”.
| |||||||||||
| doneTriggerScriptId | string | {doneTriggerTargetType} == “gs2_script” | ~ 1024 chars | GS2-Script script GRN
for asynchronous execution Must be specified in GRN format starting with “grn:gs2:”. * Applicable only if doneTriggerTargetType is “gs2_script” | ||||||||||
| doneTriggerQueueNamespaceId | string | {doneTriggerTargetType} == “gs2_script” | ~ 1024 chars | GS2-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.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| loggingNamespaceId | string | ✓ | ~ 1024 chars | GS2-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.
Note
Please refer to Master Data Reference of GS2-Experience for the JSON file format.Request
Resource creation and update requests
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||
| mode | String Enum enum { “direct”, “preUpload” } | “direct” | Update mode
| |||||||||
| settings | string | {mode} == “direct” | ✓* | ~ 5242880 chars | Master Data * Required if mode is “direct” | |||||||
| uploadToken | string | {mode} == “preUpload” | ✓* | ~ 1024 chars | Token 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
| Type | Description | |
|---|---|---|
| Item | CurrentExperienceMaster | Updated 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: nullimport (
"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 Templateclass 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 Templateclass 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 Templatepublic 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 Templateimport 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 Templatefrom 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 TemplateExperienceModel
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.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| experienceModelId | string | * | ~ 1024 chars | Experience Model GRN * Set automatically by the server | ||
| name | string | ✓ | ~ 128 chars | Experience Model name Experience Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| metadata | string | ~ 2048 chars | Metadata 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. | |||
| defaultExperience | long | 0 | 0 ~ 9223372036854775805 | Initial 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. | ||
| defaultRankCap | long | ✓ | 0 ~ 9223372036854775805 | Initial 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. | ||
| maxRankCap | long | ✓ | 0 ~ 9223372036854775805 | Maximum 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. | ||
| rankThreshold | Threshold | ✓ | 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. | |||
| acquireActionRates | List<AcquireActionRate> | 0 ~ 100 items | List 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.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| metadata | string | ~ 2048 chars | Metadata 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. | |||
| values | List<long> | ✓ | 1 ~ 10000 items | List 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.
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128 chars | Reward addition table name A unique identifier for this reward addition table. Referenced when specifying which multiplier table to apply to a particular acquire action. | ||||||||
| mode | String 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.
| |||||||||
| rates | List<double> | {mode} == “double” | ✓* | 1 ~ 10000 items | Amount 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” | |||||||
| bigRates | List<string> | {mode} == “big” | ✓* | 1 ~ 10000 items | Amount 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” |