GS2-Buff Deploy/CDK Reference
Entities
Resources targeted by the Deploy operation
Namespace
Namespace
A Namespace allows multiple independent instances of the same service within a single project by separating data spaces and usage contexts. Each GS2 service is managed on a per-namespace basis. Even when using the same service, if the Namespace differs, the data is treated as a completely independent data space.
Therefore, you must create a Namespace before you can start using each service.
Request
Resource creation and update requests
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| name | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| description | string | ~ 1024 chars | Description | |||
| transactionSetting | TransactionSetting | Transaction Setting | ||||
| applyBuffScript | ScriptSetting | Script setting to be executed when applying buffs Script Trigger Reference - apply | ||||
| logSetting | LogSetting | Log Output Setting |
GetAttr
Resource creation results that can be retrieved using the !GetAttr tag
| Type | Description | |
|---|---|---|
| Item | Namespace | Namespace 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-0001import (
"github.com/gs2io/gs2-golang-cdk/core"
"github.com/gs2io/gs2-golang-cdk/buff"
)
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 Templatepublic 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 Templateimport 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 TemplateTransactionSetting
Transaction Setting
Transaction Setting controls how transactions are executed, including their consistency, asynchronous processing, and conflict avoidance mechanisms. Combining features like AutoRun, AtomicCommit, asynchronous execution using GS2-Distributor, batch application of script results, and asynchronous Acquire Actions via GS2-JobQueue enables robust transaction management tailored to game logic.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| enableAutoRun | bool | false | Whether to automatically execute issued transactions on the server side | |||
| enableAtomicCommit | bool | {enableAutoRun} == true | false | Whether to commit the execution of transactions atomically * Applicable only if enableAutoRun is true | ||
| transactionUseDistributor | bool | {enableAtomicCommit} == true | false | Whether to execute transactions asynchronously * Applicable only if enableAtomicCommit is true | ||
| commitScriptResultInUseDistributor | bool | {transactionUseDistributor} == true | false | Whether to execute the commit processing of the script result asynchronously * Applicable only if transactionUseDistributor is true | ||
| acquireActionUseJobQueue | bool | {enableAtomicCommit} == true | false | Whether to use GS2-JobQueue to execute the acquire action * Applicable only if enableAtomicCommit is true | ||
| distributorNamespaceId | string | “grn:gs2:{region}:{ownerId}:distributor:default” | ~ 1024 chars | GS2-Distributor Namespace GRN used to execute transactions | ||
| queueNamespaceId | string | “grn:gs2:{region}:{ownerId}:queue:default” | ~ 1024 chars | GS2-JobQueue Namespace GRN used to execute transactions |
ScriptSetting
Script Setting
In GS2, you can associate custom scripts with microservice events and execute them. This model holds the settings for triggering script execution.
There are two main ways to execute a script: synchronous execution and asynchronous execution. Synchronous execution blocks processing until the script has finished executing. Instead, you can use the script’s execution results to halt API execution or control the API’s response content.
In contrast, asynchronous execution does not block processing until the script has finished executing. However, because the script result cannot be used to stop the API execution or modify the API response, asynchronous execution does not affect the API response flow and is generally recommended.
There are two types of asynchronous execution methods: GS2-Script and Amazon EventBridge. By using Amazon EventBridge, you can write processing in languages other than Lua.
| Type | Condition | Required | Default | Value Limits | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| triggerScriptId | string | ~ 1024 chars | GS2-Script script GRN
executed synchronously when the API is executed Must be specified in GRN format starting with “grn:gs2:”. | |||||||||||
| doneTriggerTargetType | String Enum enum { “none”, “gs2_script”, “aws” } | “none” | How to execute asynchronous scripts Specifies the type of script to use for asynchronous execution. You can choose from “Do not use asynchronous execution (none)”, “Use GS2-Script (gs2_script)”, and “Use Amazon EventBridge (aws)”.
| |||||||||||
| doneTriggerScriptId | string | {doneTriggerTargetType} == “gs2_script” | ~ 1024 chars | GS2-Script script GRN
for asynchronous execution Must be specified in GRN format starting with “grn:gs2:”. * Applicable only if doneTriggerTargetType is “gs2_script” | ||||||||||
| doneTriggerQueueNamespaceId | string | {doneTriggerTargetType} == “gs2_script” | ~ 1024 chars | GS2-JobQueue Namespace GRN
to execute asynchronous execution scripts If you want to execute asynchronous execution scripts via GS2-JobQueue instead of executing them directly, specify the GS2-JobQueue Namespace GRN. There are not many cases where GS2-JobQueue is required, so you generally do not need to specify it unless you have a specific reason. * Applicable only if doneTriggerTargetType is “gs2_script” |
LogSetting
Log Output Setting
Log Output Setting defines how log data is exported. This type holds the GS2-Log Namespace identifier (Namespace ID) used to export log data. Specify the GS2-Log Namespace where log data is collected and stored in the GRN format for the Log Namespace ID (loggingNamespaceId). Configuring this setting ensures that log data for API requests and responses occurring within the specified Namespace is output to the target GS2-Log namespace. GS2-Log provides real-time logs that can be used for system monitoring, analysis, debugging, and other operational purposes.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| loggingNamespaceId | string | ✓ | ~ 1024 chars | GS2-Log Namespace GRN
to output logs Must be specified in GRN format starting with “grn:gs2:”. |
CurrentBuffMaster
Master data of the currently active Buff Entry Models
This master data describes the definitions of Buff Entry Models currently active within the namespace. GS2 uses JSON format files for managing master data. By uploading these files, the master data settings are updated on the server.
To create JSON files, GS2 provides a master data editor within the management console. Additionally, you can create tools better suited for game operations and export JSON files in the appropriate format.
Note
Please refer to GS2-Buff Master Data Reference for the JSON file format.Request
Resource creation and update requests
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceName | string | ✓ | ~ 128 chars | Namespace name Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||
| mode | String Enum enum { “direct”, “preUpload” } | “direct” | Update mode
| |||||||||
| settings | string | {mode} == “direct” | ✓* | ~ 5242880 chars | Master Data * Required if mode is “direct” | |||||||
| uploadToken | string | {mode} == “preUpload” | ✓* | ~ 1024 chars | Token obtained by pre-upload Used to apply the uploaded master data. * Required if mode is “preUpload” |
GetAttr
Resource creation results that can be retrieved using the !GetAttr tag
| Type | Description | |
|---|---|---|
| Item | CurrentBuffMaster | Updated master data of the currently active Buff Entry Models |
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: nullimport (
"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{
TargetModelName: string(buff.BuffTargetModelTargetModelNameGs2ExperienceStatus),
TargetFieldName: "rankCapValue",
ConditionGrns: []buff.BuffTargetGrn{
buff.NewBuffTargetGrn(
"Gs2Experience:ExperienceModel",
"grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
buff.BuffTargetGrnOptions{},
),
buff.NewBuffTargetGrn(
"Gs2Experience:ExperienceModel",
"grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0002",
buff.BuffTargetGrnOptions{},
),
},
Rate: 1.0,
},
},
),
buff.NewBuffEntryModel(
"buff-0002",
buff.BuffEntryModelExpressionMul,
buff.BuffEntryModelTargetTypeAction,
2,
buff.BuffEntryModelOptions{
Metadata: pointy.String("BUFF_0002"),
TargetAction: &buff.BuffTargetAction{
TargetActionName: string(buff.BuffTargetActionTargetActionNameGs2ExperienceAddExperienceByUserId),
TargetFieldName: "experienceValue",
ConditionGrns: []buff.BuffTargetGrn{
buff.NewBuffTargetGrn(
"Gs2Experience:ExperienceModel",
"grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
buff.BuffTargetGrnOptions{},
),
},
Rate: 2.0,
},
},
),
buff.NewBuffEntryModel(
"buff-0003",
buff.BuffEntryModelExpressionMul,
buff.BuffEntryModelTargetTypeModel,
3,
buff.BuffEntryModelOptions{
Metadata: pointy.String("BUFF_0003"),
TargetModel: &buff.BuffTargetModel{
TargetModelName: string(buff.BuffTargetModelTargetModelNameGs2ExperienceStatus),
TargetFieldName: "rankCapValue",
ConditionGrns: []buff.BuffTargetGrn{
buff.NewBuffTargetGrn(
"Gs2Experience:ExperienceModel",
"grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001:model:experience-0001",
buff.BuffTargetGrnOptions{},
),
},
Rate: 3.0,
},
},
),
},
)
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 Templatepublic 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 Templateimport 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 TemplateBuffEntryModel
Buff Entry Model
The amount of buff is managed by BuffEntryModels, and it is possible to associate multiple BuffEntryModels with a specific target 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.
| Type | Condition | Required | Default | Value Limits | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| buffEntryModelId | string | * | ~ 1024 chars | Buff Entry Model GRN * Set automatically by the server | ||||||||||
| name | string | ✓ | ~ 128 chars | Buff Entry Model name Buff Entry Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||||||||||
| metadata | string | ~ 2048 chars | Metadata Arbitrary values can be set in the metadata. Since they do not affect GS2’s behavior, they can be used to store information used in the game. | |||||||||||
| expression | String Enum enum { “rate_add”, “mul”, “value_add” } | ✓ | Application type of buff
| |||||||||||
| targetType | String Enum enum { “model”, “action” } | ✓ | Type of target to apply buff
| |||||||||||
| targetModel | BuffTargetModel | {targetType} == “model” | ✓* | Model to apply buff * Required if targetType is “model” | ||||||||||
| targetAction | BuffTargetAction | {targetType} == “action” | ✓* | Action to apply buff * Required if targetType is “action” | ||||||||||
| priority | int | ✓ | 0 ~ 2147483646 | Priority of buff application | ||||||||||
| applyPeriodScheduleEventId | string | ~ 1024 chars | Event holding period GRN to apply buff |
BuffTargetModel
Buff Target Model
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| targetModelName | String 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", } | ✓ | Types of model to apply buffs | |||
| targetFieldName | string | ✓ | ~ 64 chars | Field name to which the buff is applied | ||
| conditionGrns | List<BuffTargetGrn> | ✓ | 1 ~ 10 items | List of buff application condition GRNs | ||
| rate | float | ✓ | 0 ~ 1000000 | Adjustment rate |
BuffTargetAction
Buff Target Action
BuffTargetGrn
GRN pattern that defines the resources used as conditions for applying buffs
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| targetModelName | string | ✓ | ~ 64 chars | Buff application condition model name | ||
| targetGrn | string | ✓ | ~ 1024 chars | Buff application condition GRN |