Documentation index for AI agents

GS2-Experience Deploy/CDK 레퍼런스

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

엔티티

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

Namespace

네임스페이스

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

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

Request

리소스 생성·갱신 요청

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

GetAttr

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

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

구현 예제

Type: GS2::Experience::Namespace
Properties:
  Name: namespace-0001
  Description: null
  TransactionSetting: null
  RankCapScriptId: null
  ChangeExperienceScript: null
  ChangeRankScript: null
  ChangeRankCapScript: null
  OverflowExperienceScript: null
  LogSetting:
    LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/experience"
)


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

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

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

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

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

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

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

class SampleStack(Stack):

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

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

TransactionSetting

트랜잭션 설정

트랜잭션 설정은 트랜잭션의 실행 방법·정합성·비동기 처리·경합 회피 메커니즘을 제어하는 설정입니다.
자동 실행(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로 지정해야 합니다.

CurrentExperienceMaster

현재 활성화된 경험치 모델의 마스터 데이터

현재 네임스페이스 내에서 유효한 경험치 모델의 정의를 기술한 마스터 데이터입니다.
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 태그로 취득 가능한 리소스 생성 결과

타입설명
ItemCurrentExperienceMaster업데이트된 현재 활성화된 경험치 모델의 마스터 데이터

구현 예제

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


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

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

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

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

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

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

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

class SampleStack(Stack):

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

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

ExperienceModel

경험치 모델

경험치와 랭크 시스템의 규칙을 정의합니다. 랭크업에 필요한 경험치의 임계값, 기본 랭크 캡, 최대 랭크 캡을 설정합니다. 랭크 캡은 스테이터스가 도달할 수 있는 최대 랭크를 제한하며, 스테이터스별로 최대 랭크 캡까지 인상할 수 있습니다(예: 한계돌파). 옵션으로 현재 랭크에 따라 보상 배율을 조정하는 입수 액션 레이트 테이블을 포함할 수 있습니다.

타입활성화 조건필수기본값값 제한설명
experienceModelIdstring
~ 1024자경험치 모델 GRN
※ 서버가 자동으로 설정
namestring
~ 128자경험치 모델 이름
경험치 모델 고유 이름. 영숫자 및 -(하이픈) _(언더스코어) .(마침표)로 지정합니다.
metadatastring~ 2048자메타데이터
메타데이터에는 임의의 값을 설정할 수 있습니다.
이 값들은 GS2의 동작에는 영향을 주지 않으므로, 게임 내에서 사용하는 정보를 저장하는 용도로 사용할 수 있습니다.
defaultExperiencelong00 ~ 9223372036854775805경험치 초기값
신규 생성된 스테이터스에 할당되는 경험치입니다. 일반적으로 플레이어가 진행의 처음부터 시작하도록 0으로 설정됩니다. 초기 랭크는 이 값으로부터 랭크업 임계값 테이블을 사용하여 결정됩니다.
defaultRankCaplong
0 ~ 9223372036854775805랭크 캡 초기값
신규 생성된 스테이터스가 도달할 수 있는 기본 최대 랭크입니다. 이 랭크의 임계값을 초과한 경험치는 폐기되거나 오버플로 스크립트가 트리거됩니다. 랭크 캡은 한계돌파 등의 조작을 통해 스테이터스별로 maxRankCap까지 인상할 수 있습니다.
maxRankCaplong
0 ~ 9223372036854775805랭크 캡의 최댓값
랭크 캡의 절대적인 상한입니다. 랭크 캡 증가 조작(한계돌파 등)을 수행하더라도 랭크 캡은 이 값을 초과할 수 없습니다. defaultRankCap 이상의 값이어야 합니다.
rankThresholdThreshold
랭크업 임계값
각 랭크에 필요한 누적 경험치를 정의하는 임계값 테이블을 참조합니다. 임계값의 엔트리 수가 도달 가능한 최대 랭크를 결정하며, 각 엔트리의 값은 다음 랭크에 도달하는 데 필요한 경험치를 지정합니다.
acquireActionRatesList<AcquireActionRate>0 ~ 100 items보상 가산 테이블 목록
스테이터스의 랭크를 참조로 사용할 때 보상량을 조정하는 랭크 기반 배율 테이블을 정의합니다. 각 테이블은 랭크와 배율을 매핑하여, 동일한 액션에서도 더 높은 랭크의 캐릭터가 더 많은 보상을 받는 구조를 구현할 수 있습니다.

Threshold

랭크업 임계값

랭크업 임계값은 경험치로부터 랭크(레벨)를 결정하는 데 필요한 수열입니다.
[10, 20]이라는 값을 설정한 경우, 경험치 값이 09 사이면 랭크1, 1019 사이면 랭크2, 경험치 값이 20이면 랭크3이 되며, 그 이상 경험치를 획득할 수 없게 됩니다.

타입활성화 조건필수기본값값 제한설명
metadatastring~ 2048자메타데이터
메타데이터에는 임의의 값을 설정할 수 있습니다.
이 값들은 GS2의 동작에는 영향을 주지 않으므로, 게임 내에서 사용하는 정보를 저장하는 용도로 사용할 수 있습니다.
valuesList<long>
1 ~ 10000 items랭크업 경험치 임계값 목록
랭크 진행을 정의하는 누적 경험치의 순서가 있는 배열입니다. 항목 수가 도달 가능한 최대 랭크를 결정합니다. 예를 들어 [10, 20]인 경우, 경험치 09에서 랭크1, 1019에서 랭크2, 20 이상에서 랭크3(그 이상의 경험치 획득은 불가)이 됩니다.

AcquireActionRate

보상 가산 테이블

상태의 현재 랭크에 따라 보상량을 조정하는 랭크 기반 배율 테이블을 정의합니다. 테이블의 각 항목은 랭크에 대응하며, 입수량에 적용되는 배율을 지정합니다. 표준적인 배정밀도 부동소수점 값과, 대규모 계산용 대수 문자열 표현을 모두 지원합니다.

타입활성화 조건필수기본값값 제한설명
namestring
~ 128자보상 가산 테이블 이름
이 보상 가산 테이블의 고유 식별자입니다. 특정 입수 액션에 적용할 배율 테이블을 지정할 때 참조됩니다.
mode문자열 열거형
enum {
  “double”,
  “big”
}
“double”보상 가산 테이블의 종류
배율 값의 수치 정밀도를 선택합니다. 표준적인 부동소수점 수(2^48까지)에는 “double"을, 대규모 계산이 필요한 경우에는 1024자리까지의 문자열 표현을 지원하는 “big"을 사용합니다.
정의설명
double2^48 미만의 부동소수점 수
big문자열 표기로 1024자리 미만의 부동소수점 수
ratesList<double>{mode} == “double”
✓※
1 ~ 10000 items랭크별 가산량(배율)
랭크를 인덱스로 하는 배율 값의 배열입니다. i번째 엔트리는 스테이터스가 랭크 i일 때 적용되는 보상 배율을 정의합니다. mode가 “double"로 설정된 경우에 사용됩니다.
※ mode이(가) “double” 이면 필수
bigRatesList<string>{mode} == “big”
✓※
1 ~ 10000 items랭크별 가산량(배율)
랭크를 인덱스로 하는 문자열 표현 배율 값의 배열입니다. i번째 엔트리는 스테이터스가 랭크 i일 때 적용되는 보상 배율을 정의합니다. 대수치 정밀도가 필요한 계산에서 mode가 “big"으로 설정된 경우에 사용됩니다.
※ mode이(가) “big” 이면 필수