GS2-Deploy/CDK Reference of GS2-Buff

The template format used when creating stacks with GS2-Deploy, and implementation examples of template output in various languages using CDK

Entity

Resources operated in Deloy process

Namespace

Namespace

A namespace is a mechanism that allows multiple uses of the same service for different purposes within a single project. 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.

TypeConditionRequiredDefaultValue LimitsDescription
namestring
~ 128 charsNamespace name
descriptionstring~ 1024 charsDescription
transactionSettingTransactionSettingTransaction settings
applyBuffScriptScriptSettingScript to be executed when applying buffs
logSettingLogSettingLog output settings

GetAttr

Generation results of resources that can be obtained with the !GetAttr tag

TypeDescription
ItemNamespaceNamespace created

Implementation Example

Type: GS2::Buff::Namespace
Properties:
  Name: namespace-0001
  Description: null
  TransactionSetting: null
  ApplyBuffScript: 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/buff"
    "github.com/openlyinc/pointy"
)

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

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

class SampleStack(Stack):

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

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

ScriptSetting

Script settings

In GS2, you can associate custom scripts with microservice events and execute them. This model holds the settings for triggering script execution.

There are two main ways to execute a script: synchronous execution and asynchronous execution. Synchronous execution blocks processing until the script has finished executing. Instead, you can use the script execution result to stop the execution of the API or to tamper with the result of the API.

In contrast, asynchronous execution does not block processing until the script has finished executing. Since the script result cannot be used to stop the API execution or modify the API response, asynchronous execution does not affect the API’s response flow. For this reason, asynchronous execution is generally recommended.

There are two types of asynchronous execution methods: GS2-Script and Amazon EventBridge. By using Amazon EventBridge, you can write processing in languages other than Lua.

TypeConditionRequiredDefaultValue LimitsDescription
triggerScriptIdstring~ 1024 charsScript GRN of synchronous execution script
Must be specified in GRN format starting with “grn:gs2:”.
doneTriggerTargetTypeString Enum
enum {
  “none”,
  “gs2_script”,
  “aws”
}
“none”~ 128 charsHow to execute asynchronous scripts
Specifies the type of script to use for asynchronous execution.
You can choose from “Do not use asynchronous execution scripts (none)”, “Use GS2-Script (gs2_script)”, and “Use Amazon EventBridge (aws)”.
Enumerator String DefinitionDescription
“none”None
“gs2_script”GS2-Script
“aws”Amazon EventBridge
doneTriggerScriptIdstring{doneTriggerTargetType} == “gs2_script”~ 1024 charsScript GRN of asynchronous execution script
Must be specified in GRN format starting with “grn:gs2:”.

* Enabled if doneTriggerTargetType is “gs2_script”
doneTriggerQueueNamespaceIdstring{doneTriggerTargetType} == “gs2_script”~ 1024 charsGS2-JobQueue namespace GRN to execute asynchronous execution scripts
If you want to execute asynchronous execution scripts via GS2-JobQueue instead of executing them directly, specify the GS2-JobQueue namespace GRN.
There is little reason to use GS2-JobQueue, so you don’t need to specify it unless you have a specific reason.

* Enabled if doneTriggerTargetType is “gs2_script”

LogSetting

Log Export Settings

Manages log data export settings. This type holds the GS2-Log namespace identifier (Namespace ID) used to export log data. Specify the GS2-Log namespace where log data is collected and stored in the GRN format for the Log Namespace ID (loggingNamespaceId). Configuring this setting ensures that log data for API requests and responses occurring within the specified namespace is output to the target GS2-Log namespace. GS2-Log provides real-time logs that can be used for system monitoring, analysis, and debugging.

TypeConditionRequiredDefaultValue LimitsDescription
loggingNamespaceIdstring
~ 1024 charsGS2-Log namespace GRN to output logs

TransactionSetting

Transaction settings

Transaction settings control how transactions are executed, their consistency, asynchronous processing, and conflict avoidance mechanisms. Combining features like AutoRun, AtomicCommit, Distributor, batch application of script results, and asynchronous acquisition actions via JobQueue enables robust transaction management tailored to game logic.

TypeConditionRequiredDefaultValue LimitsDescription
enableAutoRunbool
falseWhether to automatically execute issued transactions on the server side
enableAtomicCommitbool{enableAutoRun} == true
✓*
falseWhether to commit the execution of transactions atomically
* Required if enableAutoRun is true
transactionUseDistributorbool{enableAtomicCommit} == true
✓*
falseWhether to execute transactions asynchronously
* Required if enableAtomicCommit is true
commitScriptResultInUseDistributorbool{transactionUseDistributor} == true
✓*
falseWhether to execute the commit processing of the script result asynchronously
* Required if transactionUseDistributor is true
acquireActionUseJobQueuebool{enableAtomicCommit} == true
✓*
falseWhether to use GS2-JobQueue to execute the acquire action
* Required if enableAtomicCommit is true
distributorNamespaceIdstring
“grn:gs2:{region}:{ownerId}:distributor:default”~ 1024 charsGS2-Distributor namespace used for transaction execution
queueNamespaceIdstring
“grn:gs2:{region}:{ownerId}:queue:default”~ 1024 charsNamespace in GS2-JobQueue used to run the transaction

CurrentBuffMaster

Currently Available Master Data

GS2 uses JSON format files for managing master data. By uploading these files, the settings are applied 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 operating your game and export JSON files in the appropriate format.

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
modeString Enum
enum {
  “direct”,
  “preUpload”
}
“direct”~ 128 charsUpdate mode
Enumerator String DefinitionDescription
“direct”Directly update the settings
“preUpload”Upload the settings and then update
settingsstring{mode} == “direct”
✓*
~ 5242880 bytes (5MB)Master Data
* Required if mode is “direct”
uploadTokenstring{mode} == “preUpload”
✓*
~ 1024 charsToken used to reflect results after upload
* Required if mode is “preUpload”

GetAttr

Generation results of resources that can be obtained with the !GetAttr tag

TypeDescription
ItemCurrentBuffMasterUpdated currently available buff settings

Implementation Example

Type: GS2::Buff::CurrentBuffMaster
Properties:
  NamespaceName: namespace-0001
  Mode: direct
  Settings: {
    "version": "2024-04-15",
    "buffEntryModels": [
      {
        "name": "buff-0001",
        "expression": "rate_add",
        "targetType": "model",
        "priority": 1,
        "metadata": "BUFF_0001",
        "targetModel":
          {
            "targetModelName": "Gs2Experience:Status",
            "targetFieldName": "rankCapValue",
            "conditionGrns": [
              {
                "targetModelName": "Gs2Experience:ExperienceModel",
                "targetGrn": "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
              },
              {
                "targetModelName": "Gs2Experience:ExperienceModel",
                "targetGrn": "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0002"
              }
            ],
            "rate": 1.0
          }
      },
      {
        "name": "buff-0002",
        "expression": "mul",
        "targetType": "action",
        "priority": 2,
        "metadata": "BUFF_0002",
        "targetAction":
          {
            "targetActionName": "Gs2Experience:AddExperienceByUserId",
            "targetFieldName": "experienceValue",
            "conditionGrns": [
              {
                "targetModelName": "Gs2Experience:ExperienceModel",
                "targetGrn": "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
              }
            ],
            "rate": 2.0
          }
      },
      {
        "name": "buff-0003",
        "expression": "mul",
        "targetType": "model",
        "priority": 3,
        "metadata": "BUFF_0003",
        "targetModel":
          {
            "targetModelName": "Gs2Experience:Status",
            "targetFieldName": "rankCapValue",
            "conditionGrns": [
              {
                "targetModelName": "Gs2Experience:ExperienceModel",
                "targetGrn": "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"
              }
            ],
            "rate": 3.0
          }
      }
    ]
  }
  UploadToken: null
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/buff"
    "github.com/openlyinc/pointy"
)

SampleStack := core.NewStack()
buff.NewNamespace(
    &SampleStack,
    "namespace-0001",
    buff.NamespaceOptions{},
).MasterData(
    []buff.BuffEntryModel{
        buff.NewBuffEntryModel(
            "buff-0001",
            buff.BuffEntryModelExpressionRateAdd,
            buff.BuffEntryModelTargetTypeModel,
            1,
            buff.BuffEntryModelOptions{
                Metadata: pointy.String("BUFF_0001"),
                TargetModel: &buff.BuffTargetModel{
                    
                },
            },
        ),
        buff.NewBuffEntryModel(
            "buff-0002",
            buff.BuffEntryModelExpressionMul,
            buff.BuffEntryModelTargetTypeAction,
            2,
            buff.BuffEntryModelOptions{
                Metadata: pointy.String("BUFF_0002"),
                TargetAction: &buff.BuffTargetAction{
                    
                },
            },
        ),
        buff.NewBuffEntryModel(
            "buff-0003",
            buff.BuffEntryModelExpressionMul,
            buff.BuffEntryModelTargetTypeModel,
            3,
            buff.BuffEntryModelOptions{
                Metadata: pointy.String("BUFF_0003"),
                TargetModel: &buff.BuffTargetModel{
                    
                },
            },
        ),
    },
)

println(SampleStack.Yaml())  // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        (new \Gs2Cdk\Buff\Model\Namespace_(
            stack: $this,
            name: "namespace-0001"
        ))->masterData(
            [
                new \Gs2Cdk\Buff\Model\BuffEntryModel(
                    name:"buff-0001",
                    expression: \Gs2Cdk\Buff\Model\Enums\BuffEntryModelExpression::RATE_ADD,
                    targetType: \Gs2Cdk\Buff\Model\Enums\BuffEntryModelTargetType::MODEL,
                    priority:1,
                    options: new \Gs2Cdk\Buff\Model\Options\BuffEntryModelOptions(
                        metadata:"BUFF_0001",
                        targetModel:new \Gs2Cdk\Buff\Model\BuffTargetModel(
                            targetModelName: Gs2Cdk\Buff\Model\Enums\BuffTargetModelTargetModelName::GS2_EXPERIENCE_STATUS,
                            targetFieldName: "rankCapValue",
                            conditionGrns: [
                                new \Gs2Cdk\Buff\Model\BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",    
                                ),
                                new \Gs2Cdk\Buff\Model\BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0002",    
                                ),
                            ],
                            rate: 1.0,    
                        )
                    )
                ),
                new \Gs2Cdk\Buff\Model\BuffEntryModel(
                    name:"buff-0002",
                    expression: \Gs2Cdk\Buff\Model\Enums\BuffEntryModelExpression::MUL,
                    targetType: \Gs2Cdk\Buff\Model\Enums\BuffEntryModelTargetType::ACTION,
                    priority:2,
                    options: new \Gs2Cdk\Buff\Model\Options\BuffEntryModelOptions(
                        metadata:"BUFF_0002",
                        targetAction:new \Gs2Cdk\Buff\Model\BuffTargetAction(
                            targetActionName: Gs2Cdk\Buff\Model\Enums\BuffTargetActionTargetActionName::GS2_EXPERIENCE_ADD_EXPERIENCE_BY_USER_ID,
                            targetFieldName: "experienceValue",
                            conditionGrns: [
                                new \Gs2Cdk\Buff\Model\BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",    
                                ),
                            ],
                            rate: 2.0,    
                        )
                    )
                ),
                new \Gs2Cdk\Buff\Model\BuffEntryModel(
                    name:"buff-0003",
                    expression: \Gs2Cdk\Buff\Model\Enums\BuffEntryModelExpression::MUL,
                    targetType: \Gs2Cdk\Buff\Model\Enums\BuffEntryModelTargetType::MODEL,
                    priority:3,
                    options: new \Gs2Cdk\Buff\Model\Options\BuffEntryModelOptions(
                        metadata:"BUFF_0003",
                        targetModel:new \Gs2Cdk\Buff\Model\BuffTargetModel(
                            targetModelName: Gs2Cdk\Buff\Model\Enums\BuffTargetModelTargetModelName::GS2_EXPERIENCE_STATUS,
                            targetFieldName: "rankCapValue",
                            conditionGrns: [
                                new \Gs2Cdk\Buff\Model\BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",    
                                ),
                            ],
                            rate: 3.0,    
                        )
                    )
                )
            ]
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.buff.model.Namespace(
            this,
            "namespace-0001"
        ).masterData(
            Arrays.asList(
                new io.gs2.cdk.buff.model.BuffEntryModel(
                    "buff-0001",
                    io.gs2.cdk.buff.model.enums.BuffEntryModelExpression.RATE_ADD,
                    io.gs2.cdk.buff.model.enums.BuffEntryModelTargetType.MODEL,
                    1,
                    new io.gs2.cdk.buff.model.options.BuffEntryModelOptions()
                        .withMetadata("BUFF_0001")
                        .withTargetModel(new io.gs2.cdk.buff.model.BuffTargetModel(
                            io.gs2.cdk.buff.model.enums.BuffTargetModelTargetModelName.GS2_EXPERIENCE_STATUS.toString(),
                            "rankCapValue",
                            Arrays.asList(
                                new io.gs2.cdk.buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"        
                                ),
                                new io.gs2.cdk.buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0002"        
                                )
                            ),
                            1.0f        
                        ))
                ),
                new io.gs2.cdk.buff.model.BuffEntryModel(
                    "buff-0002",
                    io.gs2.cdk.buff.model.enums.BuffEntryModelExpression.MUL,
                    io.gs2.cdk.buff.model.enums.BuffEntryModelTargetType.ACTION,
                    2,
                    new io.gs2.cdk.buff.model.options.BuffEntryModelOptions()
                        .withMetadata("BUFF_0002")
                        .withTargetAction(new io.gs2.cdk.buff.model.BuffTargetAction(
                            io.gs2.cdk.buff.model.enums.BuffTargetActionTargetActionName.GS2_EXPERIENCE_ADD_EXPERIENCE_BY_USER_ID.toString(),
                            "experienceValue",
                            Arrays.asList(
                                new io.gs2.cdk.buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"        
                                )
                            ),
                            2.0f        
                        ))
                ),
                new io.gs2.cdk.buff.model.BuffEntryModel(
                    "buff-0003",
                    io.gs2.cdk.buff.model.enums.BuffEntryModelExpression.MUL,
                    io.gs2.cdk.buff.model.enums.BuffEntryModelTargetType.MODEL,
                    3,
                    new io.gs2.cdk.buff.model.options.BuffEntryModelOptions()
                        .withMetadata("BUFF_0003")
                        .withTargetModel(new io.gs2.cdk.buff.model.BuffTargetModel(
                            io.gs2.cdk.buff.model.enums.BuffTargetModelTargetModelName.GS2_EXPERIENCE_STATUS.toString(),
                            "rankCapValue",
                            Arrays.asList(
                                new io.gs2.cdk.buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"        
                                )
                            ),
                            3.0f        
                        ))
                )
            )
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Buff.Model.Namespace(
            stack: this,
            name: "namespace-0001"
        ).MasterData(
            new Gs2Cdk.Gs2Buff.Model.BuffEntryModel[] {
                new Gs2Cdk.Gs2Buff.Model.BuffEntryModel(
                    name: "buff-0001",
                    expression: Gs2Cdk.Gs2Buff.Model.Enums.BuffEntryModelExpression.RateAdd,
                    targetType: Gs2Cdk.Gs2Buff.Model.Enums.BuffEntryModelTargetType.Model,
                    priority: 1,
                    options: new Gs2Cdk.Gs2Buff.Model.Options.BuffEntryModelOptions
                    {
                        metadata = "BUFF_0001",
                        targetModel = new Gs2Cdk.Gs2Buff.Model.BuffTargetModel(
                            targetModelName: Gs2Cdk.Gs2Buff.Model.Enums.BuffTargetModelTargetModelName.Gs2ExperienceStatus,
                            targetFieldName: "rankCapValue",
                            conditionGrns: new Gs2Cdk.Gs2Buff.Model.BuffTargetGrn[]
                            {
                                new Gs2Cdk.Gs2Buff.Model.BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"    
                                ),
                                new Gs2Cdk.Gs2Buff.Model.BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0002"    
                                )
                            },
                            rate: 1.0f    
                        )
                    }
                ),
                new Gs2Cdk.Gs2Buff.Model.BuffEntryModel(
                    name: "buff-0002",
                    expression: Gs2Cdk.Gs2Buff.Model.Enums.BuffEntryModelExpression.Mul,
                    targetType: Gs2Cdk.Gs2Buff.Model.Enums.BuffEntryModelTargetType.Action,
                    priority: 2,
                    options: new Gs2Cdk.Gs2Buff.Model.Options.BuffEntryModelOptions
                    {
                        metadata = "BUFF_0002",
                        targetAction = new Gs2Cdk.Gs2Buff.Model.BuffTargetAction(
                            targetActionName: Gs2Cdk.Gs2Buff.Model.Enums.BuffTargetActionTargetActionName.Gs2ExperienceAddExperienceByUserId,
                            targetFieldName: "experienceValue",
                            conditionGrns: new Gs2Cdk.Gs2Buff.Model.BuffTargetGrn[]
                            {
                                new Gs2Cdk.Gs2Buff.Model.BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"    
                                )
                            },
                            rate: 2.0f    
                        )
                    }
                ),
                new Gs2Cdk.Gs2Buff.Model.BuffEntryModel(
                    name: "buff-0003",
                    expression: Gs2Cdk.Gs2Buff.Model.Enums.BuffEntryModelExpression.Mul,
                    targetType: Gs2Cdk.Gs2Buff.Model.Enums.BuffEntryModelTargetType.Model,
                    priority: 3,
                    options: new Gs2Cdk.Gs2Buff.Model.Options.BuffEntryModelOptions
                    {
                        metadata = "BUFF_0003",
                        targetModel = new Gs2Cdk.Gs2Buff.Model.BuffTargetModel(
                            targetModelName: Gs2Cdk.Gs2Buff.Model.Enums.BuffTargetModelTargetModelName.Gs2ExperienceStatus,
                            targetFieldName: "rankCapValue",
                            conditionGrns: new Gs2Cdk.Gs2Buff.Model.BuffTargetGrn[]
                            {
                                new Gs2Cdk.Gs2Buff.Model.BuffTargetGrn(
                                    targetModelName: "Gs2Experience:ExperienceModel",
                                    targetGrn: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"    
                                )
                            },
                            rate: 3.0f    
                        )
                    }
                )
            }
        );
    }
}

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

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new buff.model.Namespace(
            this,
            "namespace-0001",
        ).masterData(
            [
                new buff.model.BuffEntryModel(
                    "buff-0001",
                    buff.model.BuffEntryModelExpression.RATE_ADD,
                    buff.model.BuffEntryModelTargetType.MODEL,
                    1,
                    {
                        metadata: "BUFF_0001",
                        targetModel: new buff.model.BuffTargetModel(
                            buff.model.BuffTargetModelTargetModelName.GS2_EXPERIENCE_STATUS,
                            "rankCapValue",
                            [
                                new buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"        
                                ),
                                new buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0002"        
                                ),
                            ],
                            1.0        
                        )
                    }
                ),
                new buff.model.BuffEntryModel(
                    "buff-0002",
                    buff.model.BuffEntryModelExpression.MUL,
                    buff.model.BuffEntryModelTargetType.ACTION,
                    2,
                    {
                        metadata: "BUFF_0002",
                        targetAction: new buff.model.BuffTargetAction(
                            buff.model.BuffTargetActionTargetActionName.GS2_EXPERIENCE_ADD_EXPERIENCE_BY_USER_ID,
                            "experienceValue",
                            [
                                new buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"        
                                ),
                            ],
                            2.0        
                        )
                    }
                ),
                new buff.model.BuffEntryModel(
                    "buff-0003",
                    buff.model.BuffEntryModelExpression.MUL,
                    buff.model.BuffEntryModelTargetType.MODEL,
                    3,
                    {
                        metadata: "BUFF_0003",
                        targetModel: new buff.model.BuffTargetModel(
                            buff.model.BuffTargetModelTargetModelName.GS2_EXPERIENCE_STATUS,
                            "rankCapValue",
                            [
                                new buff.model.BuffTargetGrn(
                                    "Gs2Experience:ExperienceModel",
                                    "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001"        
                                ),
                            ],
                            3.0        
                        )
                    }
                )
            ]
        );
    }
}

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

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        buff.Namespace(
            stack=self,
            name="namespace-0001",
        ).master_data(
            buff_entry_models=[
                buff.BuffEntryModel(
                    name='buff-0001',
                    expression=buff.BuffEntryModelExpression.RATE_ADD,
                    target_type=buff.BuffEntryModelTargetType.MODEL,
                    priority=1,
                    options=buff.BuffEntryModelOptions(
                        metadata = 'BUFF_0001',
                        target_model = buff.BuffTargetModel(
                            target_model_name=buff.BuffTargetModelTargetModelName.GS2_EXPERIENCE_STATUS,
                            target_field_name='rankCapValue',
                            condition_grns=[
                                buff.BuffTargetGrn(
                                    target_model_name='Gs2Experience:ExperienceModel',
                                    target_grn='grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001',        
                                ),
                                buff.BuffTargetGrn(
                                    target_model_name='Gs2Experience:ExperienceModel',
                                    target_grn='grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0002',        
                                ),
                            ],
                            rate=1.0,        
                        )
                    ),
                ),
                buff.BuffEntryModel(
                    name='buff-0002',
                    expression=buff.BuffEntryModelExpression.MUL,
                    target_type=buff.BuffEntryModelTargetType.ACTION,
                    priority=2,
                    options=buff.BuffEntryModelOptions(
                        metadata = 'BUFF_0002',
                        target_action = buff.BuffTargetAction(
                            target_action_name=buff.BuffTargetActionTargetActionName.GS2_EXPERIENCE_ADD_EXPERIENCE_BY_USER_ID,
                            target_field_name='experienceValue',
                            condition_grns=[
                                buff.BuffTargetGrn(
                                    target_model_name='Gs2Experience:ExperienceModel',
                                    target_grn='grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001',        
                                ),
                            ],
                            rate=2.0,        
                        )
                    ),
                ),
                buff.BuffEntryModel(
                    name='buff-0003',
                    expression=buff.BuffEntryModelExpression.MUL,
                    target_type=buff.BuffEntryModelTargetType.MODEL,
                    priority=3,
                    options=buff.BuffEntryModelOptions(
                        metadata = 'BUFF_0003',
                        target_model = buff.BuffTargetModel(
                            target_model_name=buff.BuffTargetModelTargetModelName.GS2_EXPERIENCE_STATUS,
                            target_field_name='rankCapValue',
                            condition_grns=[
                                buff.BuffTargetGrn(
                                    target_model_name='Gs2Experience:ExperienceModel',
                                    target_grn='grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001',        
                                ),
                            ],
                            rate=3.0,        
                        )
                    ),
                ),
            ],
        )

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

BuffEntryModel

Buff Model

The amount of buff is managed by BuffEntryModel, and it is possible to associate multiple BuffEntryModels with a specific entry. The application order of BuffEntryModel is managed by the priority of BuffEntryModel, and the smaller the value of priority, the higher the priority.

Three buff application methods exist: “Rate Add”, ‘Mul’, and “Value Add”. Rate Add is an instruction that adds to the buff application rate. Mul is an instruction that multiplies the buff application rate. Value Add is an instruction that adds to the value after buff correction calculations. For example, if the default rate is 1.0 and Add 0.2 is set, the buff application rate becomes 1.2. Setting Mul 0.5 reduces the buff application rate to 0.5 times.

BuffEntryModel can be associated with events of GS2-Schedule, and it is possible to set to apply buffs only during the event holding period.

TypeConditionRequiredDefaultValue LimitsDescription
buffEntryModelIdstring
~ 1024 charsBuff entity model GRN
namestring
~ 128 charsBuff entry name
metadatastring~ 2048 charsMetadata
expressionString Enum
enum {
  “rate_add”,
  “mul”,
  “value_add”
}
~ 128 charsApplication type of buff
Enumerator String DefinitionDescription
“rate_add”Rate Add
“mul”Mul
“value_add”Value Add
targetTypeString Enum
enum {
  “model”,
  “action”
}
~ 128 charsType of target to apply buff
Enumerator String DefinitionDescription
“model”Model
“action”Action
targetModelBuffTargetModel{targetType} == “model”
✓*
Model to apply buff
* Required if targetType is “model”
targetActionBuffTargetAction{targetType} == “action”
✓*
Action to apply buff
* Required if targetType is “action”
priorityint
0 ~ 2147483646Priority of buff application
applyPeriodScheduleEventIdstring~ 1024 charsEvent holding period to apply buff

BuffTargetAction

Buff Target Action

TypeConditionRequiredDefaultValue LimitsDescription
targetActionNameString Enum
enum {
"Gs2Experience:AddExperienceByUserId",
"Gs2Experience:SubExperience",
"Gs2Experience:SubExperienceByUserId",
"Gs2Inventory:AcquireItemSetByUserId",
"Gs2Inventory:ConsumeItemSet",
"Gs2Inventory:ConsumeItemSetByUserId",
"Gs2Inventory:AcquireSimpleItemsByUserId",
"Gs2Inventory:ConsumeSimpleItems",
"Gs2Inventory:ConsumeSimpleItemsByUserId",
"Gs2Inventory:AcquireBigItemByUserId",
"Gs2Inventory:ConsumeBigItem",
"Gs2Inventory:ConsumeBigItemByUserId",
"Gs2Limit:CountUp",
"Gs2Limit:CountUpByUserId",
"Gs2Money:DepositByUserId",
"Gs2Money:Withdraw",
"Gs2Money:WithdrawByUserId",
"Gs2Money2:DepositByUserId",
"Gs2Money2:Withdraw",
"Gs2Money2:WithdrawByUserId",
"Gs2Stamina:ConsumeStamina",
"Gs2Stamina:ConsumeStaminaByUserId",
"Gs2Stamina:RecoverStaminaByUserId",
}
~ 128 charsTypes of action to apply buffs
targetFieldNamestring
~ 64 charsField name to which the buff is applied
conditionGrnsList<BuffTargetGrn>
1 ~ 10 itemsList of buff application condition GRNs
ratefloat
0 ~ 1000000Rate

BuffTargetModel

Buff Target Model

TypeConditionRequiredDefaultValue LimitsDescription
targetModelNameString Enum
enum {
"Gs2Exchange:RateModel",
"Gs2Exchange:IncrementalRateModel",
"Gs2Experience:Status",
"Gs2Formation:Mold",
"Gs2Idle:Status",
"Gs2Idle:CategoryModel",
"Gs2Inventory:Inventory",
"Gs2LoginReward:BonusModel",
"Gs2Mission:MissionTaskModel",
"Gs2Quest:QuestModel",
"Gs2Showcase:DisplayItem",
"Gs2Showcase:RandomDisplayItemModel",
"Gs2SkillTree:NodeModel",
"Gs2Stamina:Stamina",
}
~ 128 charsTypes of model to apply buffs
targetFieldNamestring
~ 64 charsField name to which the buff is applied
conditionGrnsList<BuffTargetGrn>
1 ~ 10 itemsList of buff application condition GRNs
ratefloat
0 ~ 1000000Rate

BuffTargetGrn

Buff Target GRN pattern

TypeConditionRequiredDefaultValue LimitsDescription
targetModelNamestring
~ 64 charsBuff application condition model name
targetGrnstring
~ 1024 charsBuff application condition GRN