GS2-Grade Deploy/CDK Reference
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
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| description | string | ~ 1024 chars | Description | |||
| transactionSettingV2 | TransactionSettingV2 | Transaction 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. | ||||
| changeGradeScript | ScriptSetting | Script setting to be executed when grade changes Script Trigger Reference - changeGrade | ||||
| logSetting | LogSetting | Log Output Setting Configuration for outputting log data of grade operations to GS2-Log. By specifying a GS2-Log Namespace, API request and response logs for grade changes and rank cap updates 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::Grade::Namespace
Properties:
Name: namespace-0001
Description: null
TransactionSettingV2: null
ChangeGradeScript: 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/grade"
)
SampleStack := core.NewStack()
grade.NewNamespace(
&SampleStack,
"namespace-0001",
grade.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\Grade\Model\Namespace_(
stack: $this,
name: "namespace-0001",
options: new \Gs2Cdk\Grade\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.grade.model.Namespace(
this,
"namespace-0001",
new io.gs2.cdk.grade.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.Gs2Grade.Model.Namespace(
stack: this,
name: "namespace-0001",
options: new Gs2Cdk.Gs2Grade.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 grade from "@/gs2cdk/grade";
class SampleStack extends core.Stack
{
public constructor() {
super();
new grade.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, grade
class SampleStack(Stack):
def __init__(self):
super().__init__()
grade.Namespace(
stack=self,
name='namespace-0001',
options=grade.NamespaceOptions(
log_setting=core.LogSetting(
logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
),
),
)
print(SampleStack().yaml()) # Generate TemplateTransactionSettingV2
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 transactionenableParallelExecution: 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.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| distributorNamespaceId | string | “grn:gs2:{region}:{ownerId}:distributor:default” | ~ 1024 chars | GS2-Distributor Namespace GRN used to execute transactions | ||
| enableParallelExecution | bool | false | Whether 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.
| 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” | 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)”.
| |||||||||||
| doneTriggerScriptId | string | {doneTriggerTargetType} == “gs2_script” | ~ 1024 chars | GS2-Script script GRN
for asynchronous execution Must be specified in GRN format starting with “grn:gs2:”. * Enabled only if doneTriggerTargetType is “gs2_script” | ||||||||||
| doneTriggerQueueNamespaceId | string | {doneTriggerTargetType} == “gs2_script” | ~ 1024 chars | GS2-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.
| 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:”. |
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.
| 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 transactions atomically * Enabled only if enableAutoRun is true | ||
| transactionUseDistributor | bool | {enableAtomicCommit} == true | false | Whether to execute transactions asynchronously * Enabled only if enableAtomicCommit is true | ||
| commitScriptResultInUseDistributor | bool | {transactionUseDistributor} == true | false | Whether to execute the commit processing of the script result asynchronously * Enabled only if transactionUseDistributor is true | ||
| acquireActionUseJobQueue | bool | {enableAtomicCommit} == true | false | Whether to use GS2-JobQueue to execute the acquire action * Enabled only if enableAtomicCommit is true | ||
| enableSequentialExecution | bool | {enableAtomicCommit} == true | false | Whether to execute the actions of an atomic commit sequentially so that multiple actions may update the same row * Enabled 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 |
CurrentGradeMaster
Currently active Grade Model master data
This master data defines the Grade Model 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.
Please refer to GS2-Grade Master Data Reference for the JSON file format.
Request
Resource creation and update requests
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||
| mode | string (enum) enum { “direct”, “preUpload” } | “direct” | Update mode
| |||||||||
| settings | string | {mode} == “direct” | ✓* | ~ 5242880 bytes (5MB) | 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 | CurrentGradeMaster | Updated master data of the currently active Grade Models |
Implementation Example
Type: GS2::Grade::CurrentGradeMaster
Properties:
NamespaceName: namespace-0001
Mode: direct
Settings: {
"version": "2023-12-25",
"gradeModels": [
{
"name": "grade-0001",
"experienceModelId": "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
"gradeEntries": [
{
"rankCapValue": 50,
"propertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"gradeUpPropertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
},
{
"rankCapValue": 60,
"propertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"gradeUpPropertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
},
{
"rankCapValue": 70,
"propertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"gradeUpPropertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
},
{
"rankCapValue": 80,
"propertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"gradeUpPropertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
}
],
"metadata": "GRADE_0001",
"defaultGrades": [
{
"propertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:r-.*",
"defaultGradeValue": 2
},
{
"propertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:sr-.*",
"defaultGradeValue": 3
},
{
"propertyIdRegex": "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:ssr-.*",
"defaultGradeValue": 4
}
]
}
]
}
UploadToken: nullimport (
"github.com/gs2io/gs2-golang-cdk/core"
"github.com/gs2io/gs2-golang-cdk/grade"
"github.com/openlyinc/pointy"
)
SampleStack := core.NewStack()
grade.NewNamespace(
&SampleStack,
"namespace-0001",
grade.NamespaceOptions{},
).MasterData(
[]grade.GradeModel{
grade.NewGradeModel(
"grade-0001",
"grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
[]grade.GradeEntryModel{
grade.NewGradeEntryModel(
50,
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*",
grade.GradeEntryModelOptions{},
),
grade.NewGradeEntryModel(
60,
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*",
grade.GradeEntryModelOptions{},
),
grade.NewGradeEntryModel(
70,
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*",
grade.GradeEntryModelOptions{},
),
grade.NewGradeEntryModel(
80,
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*",
grade.GradeEntryModelOptions{},
),
},
grade.GradeModelOptions{
Metadata: pointy.String("GRADE_0001"),
DefaultGrades: []grade.DefaultGradeModel{
grade.NewDefaultGradeModel(
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:r-.*",
2,
grade.DefaultGradeModelOptions{},
),
grade.NewDefaultGradeModel(
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:sr-.*",
3,
grade.DefaultGradeModelOptions{},
),
grade.NewDefaultGradeModel(
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:ssr-.*",
4,
grade.DefaultGradeModelOptions{},
),
},
},
),
},
)
println(SampleStack.Yaml()) // Generate Templateclass SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
(new \Gs2Cdk\Grade\Model\Namespace_(
stack: $this,
name: "namespace-0001"
))->masterData(
[
new \Gs2Cdk\Grade\Model\GradeModel(
name:"grade-0001",
experienceModelId:"grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
gradeEntries:[
new \Gs2Cdk\Grade\Model\GradeEntryModel(
rankCapValue: 50,
propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
gradeUpPropertyIdRegex: 'grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',
),
new \Gs2Cdk\Grade\Model\GradeEntryModel(
rankCapValue: 60,
propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
gradeUpPropertyIdRegex: 'grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',
),
new \Gs2Cdk\Grade\Model\GradeEntryModel(
rankCapValue: 70,
propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
gradeUpPropertyIdRegex: 'grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',
),
new \Gs2Cdk\Grade\Model\GradeEntryModel(
rankCapValue: 80,
propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
gradeUpPropertyIdRegex: 'grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',
),
],
options: new \Gs2Cdk\Grade\Model\Options\GradeModelOptions(
metadata:"GRADE_0001",
defaultGrades:[
new \Gs2Cdk\Grade\Model\DefaultGradeModel(
propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:r-.*",
defaultGradeValue: 2,
),
new \Gs2Cdk\Grade\Model\DefaultGradeModel(
propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:sr-.*",
defaultGradeValue: 3,
),
new \Gs2Cdk\Grade\Model\DefaultGradeModel(
propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:ssr-.*",
defaultGradeValue: 4,
),
]
)
)
]
);
}
}
print((new SampleStack())->yaml()); // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.grade.model.Namespace(
this,
"namespace-0001"
).masterData(
Arrays.asList(
new io.gs2.cdk.grade.model.GradeModel(
"grade-0001",
"grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
Arrays.asList(
new io.gs2.cdk.grade.model.GradeEntryModel(
50L,
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
),
new io.gs2.cdk.grade.model.GradeEntryModel(
60L,
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
),
new io.gs2.cdk.grade.model.GradeEntryModel(
70L,
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
),
new io.gs2.cdk.grade.model.GradeEntryModel(
80L,
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
)
),
new io.gs2.cdk.grade.model.options.GradeModelOptions()
.withMetadata("GRADE_0001")
.withDefaultGrades(Arrays.asList(
new io.gs2.cdk.grade.model.DefaultGradeModel(
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:r-.*",
2L
),
new io.gs2.cdk.grade.model.DefaultGradeModel(
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:sr-.*",
3L
),
new io.gs2.cdk.grade.model.DefaultGradeModel(
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:ssr-.*",
4L
)
))
)
)
);
}
}
System.out.println(new SampleStack().yaml()); // Generate Templatepublic class SampleStack : Gs2Cdk.Core.Model.Stack
{
public SampleStack() {
new Gs2Cdk.Gs2Grade.Model.Namespace(
stack: this,
name: "namespace-0001"
).MasterData(
new Gs2Cdk.Gs2Grade.Model.GradeModel[] {
new Gs2Cdk.Gs2Grade.Model.GradeModel(
name: "grade-0001",
experienceModelId: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
gradeEntries: new Gs2Cdk.Gs2Grade.Model.GradeEntryModel[]
{
new Gs2Cdk.Gs2Grade.Model.GradeEntryModel(
rankCapValue: 50L,
propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
gradeUpPropertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
),
new Gs2Cdk.Gs2Grade.Model.GradeEntryModel(
rankCapValue: 60L,
propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
gradeUpPropertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
),
new Gs2Cdk.Gs2Grade.Model.GradeEntryModel(
rankCapValue: 70L,
propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
gradeUpPropertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
),
new Gs2Cdk.Gs2Grade.Model.GradeEntryModel(
rankCapValue: 80L,
propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
gradeUpPropertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
)
},
options: new Gs2Cdk.Gs2Grade.Model.Options.GradeModelOptions
{
metadata = "GRADE_0001",
defaultGrades = new Gs2Cdk.Gs2Grade.Model.DefaultGradeModel[]
{
new Gs2Cdk.Gs2Grade.Model.DefaultGradeModel(
propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:r-.*",
defaultGradeValue: 2L
),
new Gs2Cdk.Gs2Grade.Model.DefaultGradeModel(
propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:sr-.*",
defaultGradeValue: 3L
),
new Gs2Cdk.Gs2Grade.Model.DefaultGradeModel(
propertyIdRegex: "grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:ssr-.*",
defaultGradeValue: 4L
)
}
}
)
}
);
}
}
Debug.Log(new SampleStack().Yaml()); // Generate Templateimport core from "@/gs2cdk/core";
import grade from "@/gs2cdk/grade";
class SampleStack extends core.Stack
{
public constructor() {
super();
new grade.model.Namespace(
this,
"namespace-0001",
).masterData(
[
new grade.model.GradeModel(
"grade-0001",
"grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
[
new grade.model.GradeEntryModel(
50,
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
),
new grade.model.GradeEntryModel(
60,
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
),
new grade.model.GradeEntryModel(
70,
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
),
new grade.model.GradeEntryModel(
80,
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*",
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*"
),
],
{
metadata: "GRADE_0001",
defaultGrades: [
new grade.model.DefaultGradeModel(
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:r-.*",
2
),
new grade.model.DefaultGradeModel(
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:sr-.*",
3
),
new grade.model.DefaultGradeModel(
"grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:ssr-.*",
4
),
]
}
)
]
);
}
}
console.log(new SampleStack().yaml()); // Generate Template
from gs2_cdk import Stack, core, grade
class SampleStack(Stack):
def __init__(self):
super().__init__()
grade.Namespace(
stack=self,
name="namespace-0001",
).master_data(
grade_models=[
grade.GradeModel(
name='grade-0001',
experience_model_id='grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001',
grade_entries=[
grade.GradeEntryModel(
rank_cap_value=50,
property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*',
grade_up_property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',
),
grade.GradeEntryModel(
rank_cap_value=60,
property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*',
grade_up_property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',
),
grade.GradeEntryModel(
rank_cap_value=70,
property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*',
grade_up_property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',
),
grade.GradeEntryModel(
rank_cap_value=80,
property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:(.*):.*',
grade_up_property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:$1:.*',
),
],
options=grade.GradeModelOptions(
metadata = 'GRADE_0001',
default_grades = [
grade.DefaultGradeModel(
property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:r-.*',
default_grade_value=2,
),
grade.DefaultGradeModel(
property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:sr-.*',
default_grade_value=3,
),
grade.DefaultGradeModel(
property_id_regex='grn:gs2:ap-northeast-1:YourOwnerId:inventory:namespace-0001:inventory:inventory-0001:item:ssr-.*',
default_grade_value=4,
),
]
),
),
],
)
print(SampleStack().yaml()) # Generate TemplateGradeModel
Grade Model
A Grade Model is an entity that indicates the rank of characters and equipment, and allows you to set the rank cap for GS2-Experience based on the grade.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| gradeModelId | string | * | ~ 1024 chars | Grade Model GRN
* Set automatically by the server | ||
| name | string | ✓ | ~ 128 chars | Grade Model name Unique Grade Model 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. | |||
| defaultGrades | List<DefaultGradeModel> | 0 ~ 100 items | List of Default Grade Models An ordered list of default grade rules evaluated when creating a new status. Each entry defines a property ID regex pattern and the grade value to assign when matched. If no pattern matches, the default grade value of 0 is used. | |||
| experienceModelId | string | ✓ | ~ 1024 chars | GS2-Experience Experience Model GRN
The GRN of the GS2-Experience experience model to link with this grade model. When a grade value changes, the corresponding rank cap in the linked experience model is automatically updated based on the grade entry mappings. This enables grade-driven progression where higher grades unlock higher rank caps. | ||
| gradeEntries | List<GradeEntryModel> | ✓ | 1 ~ 100 items | List of Grade Entry Models The ordered list of grade entries that map each grade value to a rank cap for the linked GS2-Experience model. The index in the array corresponds to the grade value, so the first entry (index 0) defines the rank cap for grade 0, the second for grade 1, and so on. | ||
| acquireActionRates | List<AcquireActionRate> | 0 ~ 100 items | List of Reward Addition Tables A collection of named multiplier tables used to scale reward amounts based on grade. Multiple tables can be defined to apply different scaling rules to different types of rewards (e.g., experience points, currency, items). |
DefaultGradeModel
Default Grade Model
You can set the default grade value according to the match of the property ID regular expression when creating a new grade.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| propertyIdRegex | string | ✓ | ~ 1024 chars | Property ID Regex A regular expression pattern matched against the property ID of a newly created grade status. When the property ID matches this pattern, the specified default grade value is assigned as the initial grade instead of 0. Patterns are evaluated in order, and the first match is used. | ||
| defaultGradeValue | long | ✓ | 0 ~ 9223372036854775805 | Default Grade Value The initial grade value assigned to a newly created status when its property ID matches the propertyIdRegex pattern. This value determines the starting rank cap for the linked GS2-Experience model, as the grade entry at this index defines the corresponding rank cap. |
GradeEntryModel
Grade Entry Model
Defines the mapping between a grade value and a rank cap for the linked GS2-Experience model. Each entry also specifies regex patterns for matching property IDs, enabling the system to determine which resources can be used for grade-up operations and how their property IDs are transformed.
| 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. | |||
| rankCapValue | long | ✓ | 0 ~ 9223372036854775805 | Rank Cap Value The rank cap value to set in the linked GS2-Experience model when this grade is applied. When a player’s grade changes to the value corresponding to this entry, the rank cap of the associated experience status is automatically updated to this value, controlling the maximum achievable rank. | ||
| propertyIdRegex | string | ✓ | ~ 1024 chars | Property ID Regex A regular expression pattern applied to the grade status’s property ID to extract variables for grade-up matching. Capture groups (parenthesized parts) in this pattern become available as $1, $2, etc. in gradeUpPropertyIdRegex. For example, a pattern like “character-(.+)” extracts the character identifier for use in matching grade-up material property IDs. | ||
| gradeUpPropertyIdRegex | string | ✓ | ~ 1024 chars | Grade-Up Property ID Regex A regular expression pattern that identifies which resource property IDs can be consumed for grade advancement. This pattern can reference capture groups from propertyIdRegex using $1, $2, etc. For example, if propertyIdRegex extracts “sword-001” as $1, this pattern might be “grade-up-material-$1” to match materials specific to that sword. |
AcquireActionRate
Reward Addition Table
Defines a named multiplier table that scales reward amounts based on the current grade value. Each grade value maps to a multiplier applied to acquire actions in transactions, allowing higher-graded characters or equipment to receive proportionally more rewards. Supports both standard double-precision mode and big number mode for extremely large values.
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128 chars | Reward Addition Table Name A unique identifier for this multiplier table within the grade model. Referenced when applying grade-based reward scaling to specific acquire actions in transactions. | ||||||||
| mode | string (enum) enum { “double”, “big” } | “double” | Reward Addition Table Type Selects the numeric precision mode for multiplier values. double mode uses standard floating-point numbers suitable for most cases. big mode uses string-represented numbers supporting up to 1024 digits, for games requiring extremely large value calculations.
| |||||||||
| rates | List<double> | {mode} == “double” | ✓* | 1 ~ 1000 items | Multiplier List per Grade (double mode) An array of reward multipliers indexed by grade value, using double-precision floating-point numbers. The entry at index 0 is the multiplier for grade 0, index 1 for grade 1, and so on. Used when mode is set to double.* Required if mode is “double” | |||||||
| bigRates | List<string> | {mode} == “big” | ✓* | 1 ~ 1000 items | Multiplier List per Grade (big mode) An array of reward multipliers indexed by grade value, using string-represented numbers for extended precision. The entry at index 0 is the multiplier for grade 0, index 1 for grade 1, and so on. Used when mode is set to big for games requiring very large number calculations.* Required if mode is “big” |