Documentation index for AI agents

GS2-Grade Deploy/CDK 레퍼런스

GS2-Deploy의 스택을 생성할 때 사용하는 템플릿 포맷과, CDK를 이용한 각종 언어의 템플릿 출력 구현 예제

엔티티

Deploy 처리에서 조작 대상이 되는 리소스

Namespace

네임스페이스

네임스페이스는 하나의 프로젝트 내에서 동일한 서비스를 서로 다른 용도로 여러 개 이용하기 위한 엔티티입니다.
GS2의 각 서비스는 네임스페이스 단위로 관리됩니다. 네임스페이스가 다르면 동일한 서비스라도 완전히 독립된 데이터 공간으로 취급됩니다.

따라서 각 서비스의 이용을 시작하려면 먼저 네임스페이스를 생성해야 합니다.

Request

리소스 생성·갱신 요청

타입활성화 조건필수기본값값 제한설명
namestring
~ 128자네임스페이스 이름
네임스페이스 고유의 이름. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다.
descriptionstring~ 1024자설명문
transactionSettingTransactionSetting트랜잭션 설정
그레이드 조작 시 분산 트랜잭션의 실행 방법을 제어하는 설정입니다. 자동 실행, 원자적 커밋, 비동기 처리 등의 옵션을 지원합니다.
changeGradeScriptScriptSetting그레이드가 변화했을 때 실행할 스크립트 설정
Script 트리거 레퍼런스 - changeGrade
logSettingLogSetting로그 출력 설정
그레이드 조작의 로그 데이터를 GS2-Log에 출력하기 위한 설정입니다. GS2-Log의 네임스페이스를 지정함으로써, 그레이드 변경 및 랭크 캡 업데이트에 대한 API 요청·응답 로그를 수집할 수 있습니다.

GetAttr

!GetAttr 태그로 취득 가능한 리소스 생성 결과

타입설명
ItemNamespace생성한 네임스페이스

구현 예제

Type: GS2::Grade::Namespace
Properties:
  Name: namespace-0001
  Description: null
  TransactionSetting: null
  ChangeGradeScript: 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/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 Template
class 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 Template
public 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 Template
import 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 Template

TransactionSetting

트랜잭션 설정

트랜잭션 설정은 트랜잭션의 실행 방법·정합성·비동기 처리·충돌 회피 메커니즘을 제어하는 설정입니다.
자동 실행(AutoRun), 원자적 실행(AtomicCommit), GS2-Distributor를 이용한 비동기 실행, 스크립트 결과의 일괄 적용, GS2-JobQueue를 통한 입수 액션의 비동기화 등을 조합하여 게임 로직에 맞는 견고한 트랜잭션 관리를 가능하게 합니다.

타입활성화 조건필수기본값값 제한설명
enableAutoRunboolfalse발행한 트랜잭션을 서버 사이드에서 자동으로 실행할지 여부
enableAtomicCommitbool{enableAutoRun} == truefalse트랜잭션의 실행을 원자적으로 커밋할지 여부
※ enableAutoRun이(가) true 이면 활성화
transactionUseDistributorbool{enableAtomicCommit} == truefalse트랜잭션을 비동기 처리로 실행할지 여부
※ enableAtomicCommit이(가) true 이면 활성화
commitScriptResultInUseDistributorbool{transactionUseDistributor} == truefalse스크립트의 결과 커밋 처리를 비동기 처리로 실행할지 여부
※ transactionUseDistributor이(가) true 이면 활성화
acquireActionUseJobQueuebool{enableAtomicCommit} == truefalse입수 액션을 실행할 때 GS2-JobQueue를 사용할지 여부
※ enableAtomicCommit이(가) true 이면 활성화
distributorNamespaceIdstring“grn:gs2:{region}:{ownerId}:distributor:default”~ 1024자트랜잭션 실행에 사용하는 GS2-Distributor 네임스페이스 GRN
queueNamespaceIdstring“grn:gs2:{region}:{ownerId}:queue:default”~ 1024자트랜잭션 실행에 사용하는 GS2-JobQueue의 네임스페이스 GRN

ScriptSetting

스크립트 설정

GS2에서는 마이크로서비스의 이벤트에 연결하여 커스텀 스크립트를 실행할 수 있습니다.
이 모델은 스크립트 실행을 트리거하기 위한 설정을 보유합니다.

스크립트 실행 방식은 크게 두 가지로, 바로 “동기 실행"과 “비동기 실행"입니다.
동기 실행은 스크립트 실행이 완료될 때까지 처리가 블록됩니다.
대신 스크립트 실행 결과를 이용하여 API 실행을 중단시키거나 API 응답 내용을 제어할 수 있습니다.

한편, 비동기 실행에서는 스크립트 완료를 기다리기 위해 처리가 블록되는 일이 없습니다.
다만 스크립트 실행 결과를 이용하여 API 실행을 중단하거나 API 응답 내용을 변경할 수는 없습니다.
비동기 실행은 API의 응답 흐름에 영향을 주지 않으므로 원칙적으로 비동기 실행을 권장합니다.

비동기 실행에는 실행 방식이 두 가지 있으며, GS2-Script와 Amazon EventBridge가 있습니다.
Amazon EventBridge를 사용함으로써 Lua 이외의 언어로 처리를 작성할 수 있습니다.

타입활성화 조건필수기본값값 제한설명
triggerScriptIdstring~ 1024자API 실행 시 동기적으로 실행되는 GS2-Script의 스크립트 GRN
“grn:gs2:“로 시작하는 GRN 형식의 ID로 지정해야 합니다.
doneTriggerTargetType문자열 열거형
enum {
  “none”,
  “gs2_script”,
  “aws”
}
“none”비동기 스크립트의 실행 방법
비동기 실행에서 사용할 스크립트의 종류를 지정합니다.
“비동기 실행의 스크립트를 사용하지 않음(none)”, “GS2-Script를 사용함(gs2_script)”, “Amazon EventBridge를 사용함(aws)” 중에서 선택할 수 있습니다.
정의설명
none없음
gs2_scriptGS2-Script
awsAmazon EventBridge
doneTriggerScriptIdstring{doneTriggerTargetType} == “gs2_script”~ 1024자비동기 실행할 GS2-Script 스크립트 GRN
“grn:gs2:“로 시작하는 GRN 형식의 ID로 지정해야 합니다.
※ doneTriggerTargetType이(가) “gs2_script” 이면 활성화
doneTriggerQueueNamespaceIdstring{doneTriggerTargetType} == “gs2_script”~ 1024자비동기 실행 스크립트를 실행하는 GS2-JobQueue 네임스페이스 GRN
비동기 실행 스크립트를 직접 실행하지 않고 GS2-JobQueue를 경유하는 경우 GS2-JobQueue의 네임스페이스GRN을 지정합니다.
GS2-JobQueue를 이용해야 할 이유는 많지 않으므로, 특별한 이유가 없다면 지정할 필요는 없습니다.
※ doneTriggerTargetType이(가) “gs2_script” 이면 활성화

LogSetting

로그 출력 설정

로그 데이터의 출력 설정을 관리합니다. 이 타입은 로그 데이터를 기록하는 데 사용되는 GS2-Log 네임스페이스의 식별자(Namespace ID)를 보유합니다.
로그 네임스페이스ID(loggingNamespaceId)에는 로그 데이터를 수집하여 저장하는 GS2-Log의 네임스페이스를 GRN 형식으로 지정합니다.
이 설정을 하면 설정된 네임스페이스 내에서 발생한 API 요청·응답의 로그 데이터가 대상 GS2-Log 네임스페이스 쪽으로 출력됩니다.
GS2-Log에서는 실시간으로 로그가 제공되어 시스템 모니터링, 분석, 디버깅 등에 이용할 수 있습니다.

타입활성화 조건필수기본값값 제한설명
loggingNamespaceIdstring
~ 1024자로그를 출력할 GS2-Log의 네임스페이스 GRN
“grn:gs2:“로 시작하는 GRN 형식의 ID로 지정해야 합니다.

CurrentGradeMaster

현재 활성화된 그레이드 모델 마스터 데이터

현재 네임스페이스 내에서 유효한 그레이드 모델의 정의를 기술한 마스터 데이터입니다.
GS2에서는 마스터 데이터 관리에 JSON 형식의 파일을 사용합니다.
파일을 업로드함으로써 실제로 서버에 설정을 반영할 수 있습니다.

JSON 파일을 작성하는 방법으로, 매니지먼트 콘솔 내에 마스터 데이터 에디터를 제공하고 있습니다.
또한 게임 운영에 더 적합한 도구를 직접 제작하여 적절한 형식의 JSON 파일을 출력하는 방식으로도 서비스를 이용할 수 있습니다.

Request

리소스 생성·갱신 요청

타입활성화 조건필수기본값값 제한설명
namespaceNamestring
~ 128자네임스페이스 이름
네임스페이스 고유의 이름. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다.
mode문자열 열거형
enum {
  “direct”,
  “preUpload”
}
“direct”업데이트 모드
정의설명
direct마스터 데이터를 직접 업데이트
preUpload마스터 데이터를 업로드한 후 업데이트
settingsstring{mode} == “direct”
✓※
~ 5242880 바이트 (5MB)마스터 데이터
※ mode이(가) “direct” 이면 필수
uploadTokenstring{mode} == “preUpload”
✓※
~ 1024자사전 업로드로 획득한 토큰
업로드한 마스터 데이터를 적용하기 위해 사용됩니다.
※ mode이(가) “preUpload” 이면 필수

GetAttr

!GetAttr 태그로 취득 가능한 리소스 생성 결과

타입설명
ItemCurrentGradeMaster업데이트된 현재 활성화된 그레이드 모델의 마스터 데이터

구현 예제

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: null
import (
    "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 Template
class 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 Template
public 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 Template
import 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 Template

GradeModel

그레이드 모델

그레이드 모델이란 캐릭터나 장비의 랭크를 나타내는 엔티티로, 그레이드에 따라 GS2-Experience의 랭크 캡을 설정할 수 있습니다.

타입활성화 조건필수기본값값 제한설명
gradeModelIdstring
~ 1024자그레이드 모델 GRN
※ 서버가 자동으로 설정
namestring
~ 128자그레이드 모델 이름
그레이드 모델 고유의 이름. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다.
metadatastring~ 2048자메타데이터
메타데이터에는 임의의 값을 설정할 수 있습니다.
이 값들은 GS2의 동작에는 영향을 주지 않으므로, 게임 내에서 사용하는 정보를 저장하는 용도로 사용할 수 있습니다.
defaultGradesList<DefaultGradeModel>0 ~ 100 items기본 그레이드 모델 리스트
신규 스테이터스 작성 시 평가되는 기본 그레이드 규칙의 순서가 있는 리스트입니다. 각 항목은 프로퍼티 ID의 정규 표현식 패턴과, 매칭된 경우 할당할 그레이드 값을 정의합니다. 어떤 패턴에도 매칭되지 않으면 기본 그레이드 값 0이 사용됩니다.
experienceModelIdstring
~ 1024자GS2-Experience 경험치 모델 GRN
이 그레이드 모델과 연동시킬 GS2-Experience의 경험치 모델의 GRN입니다. 그레이드 값이 변경되면, 그레이드 엔트리의 매핑에 기반하여 연동된 경험치 모델의 랭크 캡이 자동으로 업데이트됩니다. 이를 통해 높은 그레이드가 더 높은 랭크 캡을 해제하는 그레이드 기반 성장을 구현할 수 있습니다.
gradeEntriesList<GradeEntryModel>
1 ~ 100 items그레이드 엔트리 모델 리스트
각 그레이드 값을 연동된 GS2-Experience 모델의 랭크 캡에 매핑하는 그레이드 엔트리의 순서가 있는 리스트입니다. 배열의 인덱스가 그레이드 값에 대응하므로, 첫 번째 항목(인덱스 0)이 그레이드 0의 랭크 캡을, 두 번째 항목이 그레이드 1의 랭크 캡을 정의합니다.
acquireActionRatesList<AcquireActionRate>0 ~ 100 items보상 가산 테이블 리스트
그레이드를 기반으로 보상량을 스케일링하기 위한 이름이 지정된 배율 테이블의 컬렉션입니다. 여러 테이블을 정의하여 서로 다른 종류의 보상(예: 경험치, 통화, 아이템)에 다른 스케일링 규칙을 적용할 수 있습니다.

DefaultGradeModel

기본 그레이드 모델

그레이드를 새로 생성할 때 프로퍼티 ID의 정규 표현식과의 매칭에 따라 기본 그레이드 값을 설정할 수 있습니다.

타입활성화 조건필수기본값값 제한설명
propertyIdRegexstring
~ 1024자프로퍼티 ID 정규 표현식
새로 생성된 그레이드 스테이터스의 프로퍼티 ID에 대해 매칭되는 정규 표현식 패턴입니다. 프로퍼티 ID가 이 패턴에 매칭되면, 0 대신 지정된 기본 그레이드 값이 초기 그레이드로 할당됩니다. 패턴은 순서대로 평가되며, 처음 매칭된 것이 사용됩니다.
defaultGradeValuelong
0 ~ 9223372036854775805기본 그레이드 값
프로퍼티 ID가 propertyIdRegex 패턴에 매칭된 경우 새로 생성된 스테이터스에 할당되는 초기 그레이드 값입니다. 이 인덱스의 그레이드 엔트리가 대응하는 랭크 캡을 정의하므로, 이 값이 연동된 GS2-Experience 모델의 시작 랭크 캡을 결정합니다.

GradeEntryModel

그레이드 엔트리 모델

그레이드 값과 연동된 GS2-Experience 모델의 랭크 캡 간의 매핑을 정의합니다. 각 항목은 프로퍼티 ID 매칭에 사용되는 정규 표현식 패턴도 지정하여, 그레이드업 조작에 사용할 수 있는 리소스와 그 프로퍼티 ID의 변환 방법을 결정합니다.

타입활성화 조건필수기본값값 제한설명
metadatastring~ 2048자메타데이터
메타데이터에는 임의의 값을 설정할 수 있습니다.
이 값들은 GS2의 동작에는 영향을 주지 않으므로, 게임 내에서 사용하는 정보를 저장하는 용도로 사용할 수 있습니다.
rankCapValuelong
0 ~ 9223372036854775805랭크 캡 값
이 그레이드가 적용되었을 때 연동된 GS2-Experience 모델에 설정할 랭크 캡 값입니다. 플레이어의 그레이드가 이 항목에 대응하는 값으로 변경되면, 관련된 경험치 스테이터스의 랭크 캡이 이 값으로 자동 업데이트되어 도달 가능한 최대 랭크가 제어됩니다.
propertyIdRegexstring
~ 1024자프로퍼티 ID 정규 표현식
그레이드업 매칭용 변수를 추출하기 위해 그레이드 스테이터스의 프로퍼티 ID에 적용되는 정규 표현식 패턴입니다. 이 패턴 내의 캡처 그룹(괄호로 둘러싸인 부분)은 gradeUpPropertyIdRegex에서 $1, $2 등으로 사용할 수 있습니다. 예를 들어 “character-(.+)“와 같은 패턴은 캐릭터 식별자를 추출하여 그레이드업 소재의 프로퍼티 ID 매칭에 사용합니다.
gradeUpPropertyIdRegexstring
~ 1024자그레이드업용 프로퍼티 ID 정규 표현식
그레이드 승급을 위해 소비할 수 있는 리소스의 프로퍼티 ID를 특정하는 정규 표현식 패턴입니다. 이 패턴은 propertyIdRegex의 캡처 그룹을 $1, $2 등으로 참조할 수 있습니다. 예를 들어 propertyIdRegex에서 “sword-001"을 $1로 추출한 경우, 이 패턴을 “grade-up-material-$1"로 설정하면 해당 검에 고유한 소재를 매칭시킬 수 있습니다.

AcquireActionRate

보상 가산 테이블

현재 그레이드 값을 기준으로 보상량을 조정하는 이름이 지정된 배율 테이블을 정의합니다. 각 그레이드 값은 트랜잭션의 입수 액션에 적용되는 배율에 매핑되며, 그레이드가 높은 캐릭터나 장비일수록 더 많은 보상을 받을 수 있습니다. 표준적인 배정밀도 부동소수점수 모드와, 매우 큰 값에 대응하는 빅 넘버 모드를 모두 지원합니다.

타입활성화 조건필수기본값값 제한설명
namestring
~ 128자보상 가산 테이블 이름
그레이드 모델 내에서 이 배율 테이블을 고유하게 식별하는 이름입니다. 트랜잭션의 특정 입수 액션에 그레이드 기반 보상 스케일링을 적용할 때 참조됩니다.
mode문자열 열거형
enum {
  “double”,
  “big”
}
“double”보상 가산 테이블 종류
배율 값의 수치 정밀도 모드를 선택합니다. “double” 모드는 대부분의 경우에 적합한 표준 부동소수점수를 사용합니다. “big” 모드는 최대 1024자리까지의 문자열 표현 숫자를 사용하여, 매우 큰 값 계산이 필요한 게임에 대응합니다.
정의설명
double2^48 미만의 부동소수점 수
big문자열 표기로 1024자리 미만의 부동소수점 수
ratesList<double>{mode} == “double”
✓※
1 ~ 1000 items그레이드별 배율 리스트 (double 모드)
그레이드 값으로 인덱싱된 보상 배율의 배열로, 배정밀도 부동소수점수를 사용합니다. 인덱스 0의 항목이 그레이드 0의 배율, 인덱스 1이 그레이드 1의 배율이 됩니다. mode가 “double"로 설정된 경우에 사용됩니다.
※ mode이(가) “double” 이면 필수
bigRatesList<string>{mode} == “big”
✓※
1 ~ 1000 items그레이드별 배율 리스트 (big 모드)
그레이드 값으로 인덱싱된 보상 배율의 배열로, 확장된 정밀도를 위해 문자열 표현 숫자를 사용합니다. 인덱스 0의 항목이 그레이드 0의 배율, 인덱스 1이 그레이드 1의 배율이 됩니다. 매우 큰 수치 계산이 필요한 게임을 위해 mode가 “big"으로 설정된 경우에 사용됩니다.
※ mode이(가) “big” 이면 필수