GS2-Lottery 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 Configuration for controlling how transactions are processed when executing lottery operations. Lottery draws issue transactions that grant prizes to users via acquire actions. | |||
| lotteryTriggerScriptId | string | ~ 1024 chars | GS2-Script script GRN to be called when the lottery is executed | |||
| logSetting | LogSetting | Log Output Setting Specifies the GS2-Log namespace for outputting API request and response logs of lottery operations. Useful for tracking draw results, prize distributions, and box gacha states for debugging and analytics. |
GetAttr
Resource creation results that can be retrieved using the !GetAttr tag
| Type | Description | |
|---|---|---|
| Item | Namespace | Namespace created |
Implementation Example
Type: GS2::Lottery::Namespace
Properties:
Name: namespace-0001
Description: null
TransactionSetting:
EnableAutoRun: true
QueueNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001
LotteryTriggerScriptId: 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/lottery"
"github.com/openlyinc/pointy"
)
SampleStack := core.NewStack()
lottery.NewNamespace(
&SampleStack,
"namespace-0001",
lottery.NamespaceOptions{
TransactionSetting: core.NewTransactionSetting(
core.TransactionSettingOptions{
QueueNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"),
},
),
LogSetting: &core.LogSetting{
LoggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
},
},
)
println(SampleStack.Yaml()) // Generate Templateclass SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
new \Gs2Cdk\Lottery\Model\Namespace_(
stack: $this,
name: "namespace-0001",
options: new \Gs2Cdk\Lottery\Model\Options\NamespaceOptions(
transactionSetting: new \Gs2Cdk\Core\Model\TransactionSetting(
new \Gs2Cdk\Core\Model\TransactionSettingOptions(
queueNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"
)
),
logSetting: new \Gs2Cdk\Core\Model\LogSetting(
loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
)
)
);
}
}
print((new SampleStack())->yaml()); // Generate Templateclass SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.lottery.model.Namespace(
this,
"namespace-0001",
new io.gs2.cdk.lottery.model.options.NamespaceOptions()
.withTransactionSetting(new io.gs2.cdk.core.model.TransactionSetting(
new io.gs2.cdk.core.model.options.TransactionSettingOptions()
.withQueueNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001")
))
.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.Gs2Lottery.Model.Namespace(
stack: this,
name: "namespace-0001",
options: new Gs2Cdk.Gs2Lottery.Model.Options.NamespaceOptions
{
transactionSetting = new Gs2Cdk.Core.Model.TransactionSetting(
options: new Gs2Cdk.Core.Model.TransactionSettingOptions
{
queueNamespaceId = "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"
}
),
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 lottery from "@/gs2cdk/lottery";
class SampleStack extends core.Stack
{
public constructor() {
super();
new lottery.model.Namespace(
this,
"namespace-0001",
{
transactionSetting: new core.TransactionSetting(
{
queueNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"
}
),
logSetting: new core.LogSetting(
"grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
)
}
);
}
}
console.log(new SampleStack().yaml()); // Generate Templatefrom gs2_cdk import Stack, core, lottery
class SampleStack(Stack):
def __init__(self):
super().__init__()
lottery.Namespace(
stack=self,
name='namespace-0001',
options=lottery.NamespaceOptions(
transaction_setting=core.TransactionSetting(
options=core.TransactionSettingOptions(
queue_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001',
)
),
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 |
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:”. |
CurrentLotteryMaster
Currently active Lottery Model master data
This master data describes the definitions of Lottery 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 Master Data Reference of GS2-Lottery 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 | CurrentLotteryMaster | Updated master data of the currently active Lottery Models |
Implementation Example
Type: GS2::Lottery::CurrentLotteryMaster
Properties:
NamespaceName: namespace-0001
Mode: direct
Settings: {
"version": "2019-02-21",
"lotteryModels": [
{
"name": "gacha",
"mode": "normal",
"method": "prize_table",
"metadata": "GACHA",
"prizeTableName": "gacha"
},
{
"name": "gacha_ssr",
"mode": "normal",
"method": "prize_table",
"metadata": "SSR",
"prizeTableName": "gacha-ssr"
},
{
"name": "gacha_sr",
"mode": "normal",
"method": "prize_table",
"metadata": "SR",
"prizeTableName": "gacha-sr"
},
{
"name": "gacha_r",
"mode": "normal",
"method": "prize_table",
"metadata": "R",
"prizeTableName": "gacha-r"
},
{
"name": "box",
"mode": "box",
"method": "prize_table",
"metadata": "BOX",
"prizeTableName": "box"
}
],
"prizeTables": [
{
"name": "gacha",
"prizes": [
{
"prizeId": "prize-1",
"type": "prize_table",
"prizeTableName": "gacha-ssr",
"weight": 5
},
{
"prizeId": "prize-2",
"type": "prize_table",
"prizeTableName": "gacha-sr",
"weight": 15
},
{
"prizeId": "prize-3",
"type": "prize_table",
"prizeTableName": "gacha-r",
"weight": 80
}
],
"metadata": "SSR"
},
{
"name": "gacha-ssr",
"prizes": [
{
"prizeId": "prize-4",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": {
"namespaceName": "namespace-0001",
"slot": 0,
"price": 100,
"count": 1,
"userId": "#{userId}"
}
}
],
"weight": 1
},
{
"prizeId": "prize-5",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": {
"namespaceName": "namespace-0001",
"slot": 0,
"price": 100,
"count": 1,
"userId": "#{userId}"
}
}
],
"weight": 2
},
{
"prizeId": "prize-6",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": {
"namespaceName": "namespace-0001",
"slot": 0,
"price": 100,
"count": 1,
"userId": "#{userId}"
}
}
],
"weight": 3
}
],
"metadata": "SSR"
},
{
"name": "gacha-sr",
"prizes": [
{
"prizeId": "prize-7",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": {
"namespaceName": "namespace-0001",
"slot": 0,
"price": 100,
"count": 1,
"userId": "#{userId}"
}
}
],
"weight": 10
},
{
"prizeId": "prize-8",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": {
"namespaceName": "namespace-0001",
"slot": 0,
"price": 100,
"count": 1,
"userId": "#{userId}"
}
}
],
"weight": 20
},
{
"prizeId": "prize-9",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": {
"namespaceName": "namespace-0001",
"slot": 0,
"price": 100,
"count": 1,
"userId": "#{userId}"
}
}
],
"weight": 30
}
],
"metadata": "SR"
},
{
"name": "gacha-r",
"prizes": [
{
"prizeId": "prize-10",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": {
"namespaceName": "namespace-0001",
"slot": 0,
"price": 100,
"count": 1,
"userId": "#{userId}"
}
}
],
"weight": 100
},
{
"prizeId": "prize-11",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": {
"namespaceName": "namespace-0001",
"slot": 0,
"price": 100,
"count": 1,
"userId": "#{userId}"
}
}
],
"weight": 200
},
{
"prizeId": "prize-12",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": {
"namespaceName": "namespace-0001",
"slot": 0,
"price": 100,
"count": 1,
"userId": "#{userId}"
}
}
],
"weight": 300
}
],
"metadata": "R"
},
{
"name": "box",
"prizes": [
{
"prizeId": "prize-13",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": {
"namespaceName": "namespace-0001",
"slot": 0,
"price": 100,
"count": 1,
"userId": "#{userId}"
}
}
],
"weight": 30
},
{
"prizeId": "prize-14",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": {
"namespaceName": "namespace-0001",
"slot": 0,
"price": 100,
"count": 1,
"userId": "#{userId}"
}
}
],
"weight": 20
},
{
"prizeId": "prize-15",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": {
"namespaceName": "namespace-0001",
"slot": 0,
"price": 100,
"count": 1,
"userId": "#{userId}"
}
}
],
"weight": 10
}
],
"metadata": "BOX"
}
]
}
UploadToken: nullimport (
"github.com/gs2io/gs2-golang-cdk/core"
"github.com/gs2io/gs2-golang-cdk/lottery"
"github.com/gs2io/gs2-golang-cdk/money"
"github.com/openlyinc/pointy"
)
SampleStack := core.NewStack()
lottery.NewNamespace(
&SampleStack,
"namespace-0001",
lottery.NamespaceOptions{},
).MasterData(
[]lottery.LotteryModel{
lottery.NewLotteryModel(
"gacha",
lottery.LotteryModelModeNormal,
lottery.LotteryModelMethodPrizeTable,
lottery.LotteryModelOptions{
Metadata: pointy.String("GACHA"),
PrizeTableName: pointy.String("gacha"),
},
),
lottery.NewLotteryModel(
"gacha_ssr",
lottery.LotteryModelModeNormal,
lottery.LotteryModelMethodPrizeTable,
lottery.LotteryModelOptions{
Metadata: pointy.String("SSR"),
PrizeTableName: pointy.String("gacha-ssr"),
},
),
lottery.NewLotteryModel(
"gacha_sr",
lottery.LotteryModelModeNormal,
lottery.LotteryModelMethodPrizeTable,
lottery.LotteryModelOptions{
Metadata: pointy.String("SR"),
PrizeTableName: pointy.String("gacha-sr"),
},
),
lottery.NewLotteryModel(
"gacha_r",
lottery.LotteryModelModeNormal,
lottery.LotteryModelMethodPrizeTable,
lottery.LotteryModelOptions{
Metadata: pointy.String("R"),
PrizeTableName: pointy.String("gacha-r"),
},
),
lottery.NewLotteryModel(
"box",
lottery.LotteryModelModeBox,
lottery.LotteryModelMethodPrizeTable,
lottery.LotteryModelOptions{
Metadata: pointy.String("BOX"),
PrizeTableName: pointy.String("box"),
},
),
},
[]lottery.PrizeTable{
lottery.NewPrizeTable(
"gacha",
[]lottery.Prize{
lottery.NewPrize(
"prize-1",
lottery.PrizeTypePrizeTable,
5,
lottery.PrizeOptions{
PrizeTableName: pointy.String("gacha-ssr"),
},
),
lottery.NewPrize(
"prize-2",
lottery.PrizeTypePrizeTable,
15,
lottery.PrizeOptions{
PrizeTableName: pointy.String("gacha-sr"),
},
),
lottery.NewPrize(
"prize-3",
lottery.PrizeTypePrizeTable,
80,
lottery.PrizeOptions{
PrizeTableName: pointy.String("gacha-r"),
},
),
},
lottery.PrizeTableOptions{
Metadata: pointy.String("SSR"),
},
),
lottery.NewPrizeTable(
"gacha-ssr",
[]lottery.Prize{
lottery.NewPrize(
"prize-4",
lottery.PrizeTypeAction,
1,
lottery.PrizeOptions{
AcquireActions: []core.AcquireAction{
money.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}",
),
},
},
),
lottery.NewPrize(
"prize-5",
lottery.PrizeTypeAction,
2,
lottery.PrizeOptions{
AcquireActions: []core.AcquireAction{
money.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}",
),
},
},
),
lottery.NewPrize(
"prize-6",
lottery.PrizeTypeAction,
3,
lottery.PrizeOptions{
AcquireActions: []core.AcquireAction{
money.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}",
),
},
},
),
},
lottery.PrizeTableOptions{
Metadata: pointy.String("SSR"),
},
),
lottery.NewPrizeTable(
"gacha-sr",
[]lottery.Prize{
lottery.NewPrize(
"prize-7",
lottery.PrizeTypeAction,
10,
lottery.PrizeOptions{
AcquireActions: []core.AcquireAction{
money.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}",
),
},
},
),
lottery.NewPrize(
"prize-8",
lottery.PrizeTypeAction,
20,
lottery.PrizeOptions{
AcquireActions: []core.AcquireAction{
money.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}",
),
},
},
),
lottery.NewPrize(
"prize-9",
lottery.PrizeTypeAction,
30,
lottery.PrizeOptions{
AcquireActions: []core.AcquireAction{
money.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}",
),
},
},
),
},
lottery.PrizeTableOptions{
Metadata: pointy.String("SR"),
},
),
lottery.NewPrizeTable(
"gacha-r",
[]lottery.Prize{
lottery.NewPrize(
"prize-10",
lottery.PrizeTypeAction,
100,
lottery.PrizeOptions{
AcquireActions: []core.AcquireAction{
money.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}",
),
},
},
),
lottery.NewPrize(
"prize-11",
lottery.PrizeTypeAction,
200,
lottery.PrizeOptions{
AcquireActions: []core.AcquireAction{
money.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}",
),
},
},
),
lottery.NewPrize(
"prize-12",
lottery.PrizeTypeAction,
300,
lottery.PrizeOptions{
AcquireActions: []core.AcquireAction{
money.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}",
),
},
},
),
},
lottery.PrizeTableOptions{
Metadata: pointy.String("R"),
},
),
lottery.NewPrizeTable(
"box",
[]lottery.Prize{
lottery.NewPrize(
"prize-13",
lottery.PrizeTypeAction,
30,
lottery.PrizeOptions{
AcquireActions: []core.AcquireAction{
money.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}",
),
},
},
),
lottery.NewPrize(
"prize-14",
lottery.PrizeTypeAction,
20,
lottery.PrizeOptions{
AcquireActions: []core.AcquireAction{
money.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}",
),
},
},
),
lottery.NewPrize(
"prize-15",
lottery.PrizeTypeAction,
10,
lottery.PrizeOptions{
AcquireActions: []core.AcquireAction{
money.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}",
),
},
},
),
},
lottery.PrizeTableOptions{
Metadata: pointy.String("BOX"),
},
),
},
)
println(SampleStack.Yaml()) // Generate Templateclass SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
(new \Gs2Cdk\Lottery\Model\Namespace_(
stack: $this,
name: "namespace-0001"
))->masterData(
[
new \Gs2Cdk\Lottery\Model\LotteryModel(
name:"gacha",
mode: \Gs2Cdk\Lottery\Model\Enums\LotteryModelMode::NORMAL,
method: \Gs2Cdk\Lottery\Model\Enums\LotteryModelMethod::PRIZE_TABLE,
options: new \Gs2Cdk\Lottery\Model\Options\LotteryModelOptions(
metadata:"GACHA",
prizeTableName:"gacha"
)
),
new \Gs2Cdk\Lottery\Model\LotteryModel(
name:"gacha_ssr",
mode: \Gs2Cdk\Lottery\Model\Enums\LotteryModelMode::NORMAL,
method: \Gs2Cdk\Lottery\Model\Enums\LotteryModelMethod::PRIZE_TABLE,
options: new \Gs2Cdk\Lottery\Model\Options\LotteryModelOptions(
metadata:"SSR",
prizeTableName:"gacha-ssr"
)
),
new \Gs2Cdk\Lottery\Model\LotteryModel(
name:"gacha_sr",
mode: \Gs2Cdk\Lottery\Model\Enums\LotteryModelMode::NORMAL,
method: \Gs2Cdk\Lottery\Model\Enums\LotteryModelMethod::PRIZE_TABLE,
options: new \Gs2Cdk\Lottery\Model\Options\LotteryModelOptions(
metadata:"SR",
prizeTableName:"gacha-sr"
)
),
new \Gs2Cdk\Lottery\Model\LotteryModel(
name:"gacha_r",
mode: \Gs2Cdk\Lottery\Model\Enums\LotteryModelMode::NORMAL,
method: \Gs2Cdk\Lottery\Model\Enums\LotteryModelMethod::PRIZE_TABLE,
options: new \Gs2Cdk\Lottery\Model\Options\LotteryModelOptions(
metadata:"R",
prizeTableName:"gacha-r"
)
),
new \Gs2Cdk\Lottery\Model\LotteryModel(
name:"box",
mode: \Gs2Cdk\Lottery\Model\Enums\LotteryModelMode::BOX,
method: \Gs2Cdk\Lottery\Model\Enums\LotteryModelMethod::PRIZE_TABLE,
options: new \Gs2Cdk\Lottery\Model\Options\LotteryModelOptions(
metadata:"BOX",
prizeTableName:"box"
)
)
],
[
new \Gs2Cdk\Lottery\Model\PrizeTable(
name:"gacha",
prizes:[
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-1",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::PRIZE_TABLE,
weight: 5,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
prizeTableName: "gacha-ssr",
)
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-2",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::PRIZE_TABLE,
weight: 15,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
prizeTableName: "gacha-sr",
)
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-3",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::PRIZE_TABLE,
weight: 80,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
prizeTableName: "gacha-r",
)
),
],
options: new \Gs2Cdk\Lottery\Model\Options\PrizeTableOptions(
metadata:"SSR"
)
),
new \Gs2Cdk\Lottery\Model\PrizeTable(
name:"gacha-ssr",
prizes:[
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-4",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::ACTION,
weight: 1,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
acquireActions: [
new \Gs2Cdk\Money\StampSheet\DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
),
],
)
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-5",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::ACTION,
weight: 2,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
acquireActions: [
new \Gs2Cdk\Money\StampSheet\DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
),
],
)
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-6",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::ACTION,
weight: 3,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
acquireActions: [
new \Gs2Cdk\Money\StampSheet\DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
),
],
)
),
],
options: new \Gs2Cdk\Lottery\Model\Options\PrizeTableOptions(
metadata:"SSR"
)
),
new \Gs2Cdk\Lottery\Model\PrizeTable(
name:"gacha-sr",
prizes:[
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-7",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::ACTION,
weight: 10,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
acquireActions: [
new \Gs2Cdk\Money\StampSheet\DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
),
],
)
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-8",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::ACTION,
weight: 20,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
acquireActions: [
new \Gs2Cdk\Money\StampSheet\DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
),
],
)
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-9",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::ACTION,
weight: 30,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
acquireActions: [
new \Gs2Cdk\Money\StampSheet\DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
),
],
)
),
],
options: new \Gs2Cdk\Lottery\Model\Options\PrizeTableOptions(
metadata:"SR"
)
),
new \Gs2Cdk\Lottery\Model\PrizeTable(
name:"gacha-r",
prizes:[
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-10",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::ACTION,
weight: 100,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
acquireActions: [
new \Gs2Cdk\Money\StampSheet\DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
),
],
)
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-11",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::ACTION,
weight: 200,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
acquireActions: [
new \Gs2Cdk\Money\StampSheet\DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
),
],
)
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-12",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::ACTION,
weight: 300,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
acquireActions: [
new \Gs2Cdk\Money\StampSheet\DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
),
],
)
),
],
options: new \Gs2Cdk\Lottery\Model\Options\PrizeTableOptions(
metadata:"R"
)
),
new \Gs2Cdk\Lottery\Model\PrizeTable(
name:"box",
prizes:[
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-13",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::ACTION,
weight: 30,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
acquireActions: [
new \Gs2Cdk\Money\StampSheet\DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
),
],
)
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-14",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::ACTION,
weight: 20,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
acquireActions: [
new \Gs2Cdk\Money\StampSheet\DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
),
],
)
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-15",
type: Gs2Cdk\Lottery\Model\Enums\PrizeType::ACTION,
weight: 10,
options: new \Gs2Cdk\Lottery\Model\Options\PrizeOptions(
acquireActions: [
new \Gs2Cdk\Money\StampSheet\DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
),
],
)
),
],
options: new \Gs2Cdk\Lottery\Model\Options\PrizeTableOptions(
metadata:"BOX"
)
)
]
);
}
}
print((new SampleStack())->yaml()); // Generate Templateclass SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.lottery.model.Namespace(
this,
"namespace-0001"
).masterData(
Arrays.asList(
new io.gs2.cdk.lottery.model.LotteryModel(
"gacha",
io.gs2.cdk.lottery.model.enums.LotteryModelMode.NORMAL,
io.gs2.cdk.lottery.model.enums.LotteryModelMethod.PRIZE_TABLE,
new io.gs2.cdk.lottery.model.options.LotteryModelOptions()
.withMetadata("GACHA")
.withPrizeTableName("gacha")
),
new io.gs2.cdk.lottery.model.LotteryModel(
"gacha_ssr",
io.gs2.cdk.lottery.model.enums.LotteryModelMode.NORMAL,
io.gs2.cdk.lottery.model.enums.LotteryModelMethod.PRIZE_TABLE,
new io.gs2.cdk.lottery.model.options.LotteryModelOptions()
.withMetadata("SSR")
.withPrizeTableName("gacha-ssr")
),
new io.gs2.cdk.lottery.model.LotteryModel(
"gacha_sr",
io.gs2.cdk.lottery.model.enums.LotteryModelMode.NORMAL,
io.gs2.cdk.lottery.model.enums.LotteryModelMethod.PRIZE_TABLE,
new io.gs2.cdk.lottery.model.options.LotteryModelOptions()
.withMetadata("SR")
.withPrizeTableName("gacha-sr")
),
new io.gs2.cdk.lottery.model.LotteryModel(
"gacha_r",
io.gs2.cdk.lottery.model.enums.LotteryModelMode.NORMAL,
io.gs2.cdk.lottery.model.enums.LotteryModelMethod.PRIZE_TABLE,
new io.gs2.cdk.lottery.model.options.LotteryModelOptions()
.withMetadata("R")
.withPrizeTableName("gacha-r")
),
new io.gs2.cdk.lottery.model.LotteryModel(
"box",
io.gs2.cdk.lottery.model.enums.LotteryModelMode.BOX,
io.gs2.cdk.lottery.model.enums.LotteryModelMethod.PRIZE_TABLE,
new io.gs2.cdk.lottery.model.options.LotteryModelOptions()
.withMetadata("BOX")
.withPrizeTableName("box")
)
),
Arrays.asList(
new io.gs2.cdk.lottery.model.PrizeTable(
"gacha",
Arrays.asList(
new io.gs2.cdk.lottery.model.Prize(
"prize-1",
io.gs2.cdk.lottery.model.enums.PrizeType.PRIZE_TABLE,
5,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withPrizeTableName("gacha-ssr")
),
new io.gs2.cdk.lottery.model.Prize(
"prize-2",
io.gs2.cdk.lottery.model.enums.PrizeType.PRIZE_TABLE,
15,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withPrizeTableName("gacha-sr")
),
new io.gs2.cdk.lottery.model.Prize(
"prize-3",
io.gs2.cdk.lottery.model.enums.PrizeType.PRIZE_TABLE,
80,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withPrizeTableName("gacha-r")
)
),
new io.gs2.cdk.lottery.model.options.PrizeTableOptions()
.withMetadata("SSR")
),
new io.gs2.cdk.lottery.model.PrizeTable(
"gacha-ssr",
Arrays.asList(
new io.gs2.cdk.lottery.model.Prize(
"prize-4",
io.gs2.cdk.lottery.model.enums.PrizeType.ACTION,
1,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withAcquireActions(Arrays.asList(
new io.gs2.cdk.money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100f,
1,
"#{userId}"
)
))
),
new io.gs2.cdk.lottery.model.Prize(
"prize-5",
io.gs2.cdk.lottery.model.enums.PrizeType.ACTION,
2,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withAcquireActions(Arrays.asList(
new io.gs2.cdk.money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100f,
1,
"#{userId}"
)
))
),
new io.gs2.cdk.lottery.model.Prize(
"prize-6",
io.gs2.cdk.lottery.model.enums.PrizeType.ACTION,
3,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withAcquireActions(Arrays.asList(
new io.gs2.cdk.money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100f,
1,
"#{userId}"
)
))
)
),
new io.gs2.cdk.lottery.model.options.PrizeTableOptions()
.withMetadata("SSR")
),
new io.gs2.cdk.lottery.model.PrizeTable(
"gacha-sr",
Arrays.asList(
new io.gs2.cdk.lottery.model.Prize(
"prize-7",
io.gs2.cdk.lottery.model.enums.PrizeType.ACTION,
10,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withAcquireActions(Arrays.asList(
new io.gs2.cdk.money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100f,
1,
"#{userId}"
)
))
),
new io.gs2.cdk.lottery.model.Prize(
"prize-8",
io.gs2.cdk.lottery.model.enums.PrizeType.ACTION,
20,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withAcquireActions(Arrays.asList(
new io.gs2.cdk.money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100f,
1,
"#{userId}"
)
))
),
new io.gs2.cdk.lottery.model.Prize(
"prize-9",
io.gs2.cdk.lottery.model.enums.PrizeType.ACTION,
30,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withAcquireActions(Arrays.asList(
new io.gs2.cdk.money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100f,
1,
"#{userId}"
)
))
)
),
new io.gs2.cdk.lottery.model.options.PrizeTableOptions()
.withMetadata("SR")
),
new io.gs2.cdk.lottery.model.PrizeTable(
"gacha-r",
Arrays.asList(
new io.gs2.cdk.lottery.model.Prize(
"prize-10",
io.gs2.cdk.lottery.model.enums.PrizeType.ACTION,
100,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withAcquireActions(Arrays.asList(
new io.gs2.cdk.money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100f,
1,
"#{userId}"
)
))
),
new io.gs2.cdk.lottery.model.Prize(
"prize-11",
io.gs2.cdk.lottery.model.enums.PrizeType.ACTION,
200,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withAcquireActions(Arrays.asList(
new io.gs2.cdk.money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100f,
1,
"#{userId}"
)
))
),
new io.gs2.cdk.lottery.model.Prize(
"prize-12",
io.gs2.cdk.lottery.model.enums.PrizeType.ACTION,
300,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withAcquireActions(Arrays.asList(
new io.gs2.cdk.money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100f,
1,
"#{userId}"
)
))
)
),
new io.gs2.cdk.lottery.model.options.PrizeTableOptions()
.withMetadata("R")
),
new io.gs2.cdk.lottery.model.PrizeTable(
"box",
Arrays.asList(
new io.gs2.cdk.lottery.model.Prize(
"prize-13",
io.gs2.cdk.lottery.model.enums.PrizeType.ACTION,
30,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withAcquireActions(Arrays.asList(
new io.gs2.cdk.money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100f,
1,
"#{userId}"
)
))
),
new io.gs2.cdk.lottery.model.Prize(
"prize-14",
io.gs2.cdk.lottery.model.enums.PrizeType.ACTION,
20,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withAcquireActions(Arrays.asList(
new io.gs2.cdk.money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100f,
1,
"#{userId}"
)
))
),
new io.gs2.cdk.lottery.model.Prize(
"prize-15",
io.gs2.cdk.lottery.model.enums.PrizeType.ACTION,
10,
new io.gs2.cdk.lottery.model.options.PrizeOptions()
.withAcquireActions(Arrays.asList(
new io.gs2.cdk.money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100f,
1,
"#{userId}"
)
))
)
),
new io.gs2.cdk.lottery.model.options.PrizeTableOptions()
.withMetadata("BOX")
)
)
);
}
}
System.out.println(new SampleStack().yaml()); // Generate Templatepublic class SampleStack : Gs2Cdk.Core.Model.Stack
{
public SampleStack() {
new Gs2Cdk.Gs2Lottery.Model.Namespace(
stack: this,
name: "namespace-0001"
).MasterData(
new Gs2Cdk.Gs2Lottery.Model.LotteryModel[] {
new Gs2Cdk.Gs2Lottery.Model.LotteryModel(
name: "gacha",
mode: Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMode.Normal,
method: Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMethod.PrizeTable,
options: new Gs2Cdk.Gs2Lottery.Model.Options.LotteryModelOptions
{
metadata = "GACHA",
prizeTableName = "gacha"
}
),
new Gs2Cdk.Gs2Lottery.Model.LotteryModel(
name: "gacha_ssr",
mode: Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMode.Normal,
method: Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMethod.PrizeTable,
options: new Gs2Cdk.Gs2Lottery.Model.Options.LotteryModelOptions
{
metadata = "SSR",
prizeTableName = "gacha-ssr"
}
),
new Gs2Cdk.Gs2Lottery.Model.LotteryModel(
name: "gacha_sr",
mode: Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMode.Normal,
method: Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMethod.PrizeTable,
options: new Gs2Cdk.Gs2Lottery.Model.Options.LotteryModelOptions
{
metadata = "SR",
prizeTableName = "gacha-sr"
}
),
new Gs2Cdk.Gs2Lottery.Model.LotteryModel(
name: "gacha_r",
mode: Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMode.Normal,
method: Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMethod.PrizeTable,
options: new Gs2Cdk.Gs2Lottery.Model.Options.LotteryModelOptions
{
metadata = "R",
prizeTableName = "gacha-r"
}
),
new Gs2Cdk.Gs2Lottery.Model.LotteryModel(
name: "box",
mode: Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMode.Box,
method: Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMethod.PrizeTable,
options: new Gs2Cdk.Gs2Lottery.Model.Options.LotteryModelOptions
{
metadata = "BOX",
prizeTableName = "box"
}
)
},
new Gs2Cdk.Gs2Lottery.Model.PrizeTable[] {
new Gs2Cdk.Gs2Lottery.Model.PrizeTable(
name: "gacha",
prizes: new Gs2Cdk.Gs2Lottery.Model.Prize[]
{
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-1",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.PrizeTable,
weight: 5,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
prizeTableName = "gacha-ssr"
}
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-2",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.PrizeTable,
weight: 15,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
prizeTableName = "gacha-sr"
}
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-3",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.PrizeTable,
weight: 80,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
prizeTableName = "gacha-r"
}
)
},
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeTableOptions
{
metadata = "SSR"
}
),
new Gs2Cdk.Gs2Lottery.Model.PrizeTable(
name: "gacha-ssr",
prizes: new Gs2Cdk.Gs2Lottery.Model.Prize[]
{
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-4",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.Action,
weight: 1,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
acquireActions = new Gs2Cdk.Core.Model.AcquireAction[]
{
new Gs2Cdk.Gs2Money.StampSheet.DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
)
}
}
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-5",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.Action,
weight: 2,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
acquireActions = new Gs2Cdk.Core.Model.AcquireAction[]
{
new Gs2Cdk.Gs2Money.StampSheet.DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
)
}
}
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-6",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.Action,
weight: 3,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
acquireActions = new Gs2Cdk.Core.Model.AcquireAction[]
{
new Gs2Cdk.Gs2Money.StampSheet.DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
)
}
}
)
},
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeTableOptions
{
metadata = "SSR"
}
),
new Gs2Cdk.Gs2Lottery.Model.PrizeTable(
name: "gacha-sr",
prizes: new Gs2Cdk.Gs2Lottery.Model.Prize[]
{
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-7",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.Action,
weight: 10,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
acquireActions = new Gs2Cdk.Core.Model.AcquireAction[]
{
new Gs2Cdk.Gs2Money.StampSheet.DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
)
}
}
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-8",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.Action,
weight: 20,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
acquireActions = new Gs2Cdk.Core.Model.AcquireAction[]
{
new Gs2Cdk.Gs2Money.StampSheet.DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
)
}
}
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-9",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.Action,
weight: 30,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
acquireActions = new Gs2Cdk.Core.Model.AcquireAction[]
{
new Gs2Cdk.Gs2Money.StampSheet.DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
)
}
}
)
},
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeTableOptions
{
metadata = "SR"
}
),
new Gs2Cdk.Gs2Lottery.Model.PrizeTable(
name: "gacha-r",
prizes: new Gs2Cdk.Gs2Lottery.Model.Prize[]
{
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-10",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.Action,
weight: 100,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
acquireActions = new Gs2Cdk.Core.Model.AcquireAction[]
{
new Gs2Cdk.Gs2Money.StampSheet.DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
)
}
}
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-11",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.Action,
weight: 200,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
acquireActions = new Gs2Cdk.Core.Model.AcquireAction[]
{
new Gs2Cdk.Gs2Money.StampSheet.DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
)
}
}
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-12",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.Action,
weight: 300,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
acquireActions = new Gs2Cdk.Core.Model.AcquireAction[]
{
new Gs2Cdk.Gs2Money.StampSheet.DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
)
}
}
)
},
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeTableOptions
{
metadata = "R"
}
),
new Gs2Cdk.Gs2Lottery.Model.PrizeTable(
name: "box",
prizes: new Gs2Cdk.Gs2Lottery.Model.Prize[]
{
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-13",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.Action,
weight: 30,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
acquireActions = new Gs2Cdk.Core.Model.AcquireAction[]
{
new Gs2Cdk.Gs2Money.StampSheet.DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
)
}
}
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-14",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.Action,
weight: 20,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
acquireActions = new Gs2Cdk.Core.Model.AcquireAction[]
{
new Gs2Cdk.Gs2Money.StampSheet.DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
)
}
}
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-15",
type: Gs2Cdk.Gs2Lottery.Model.Enums.PrizeType.Action,
weight: 10,
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeOptions
{
acquireActions = new Gs2Cdk.Core.Model.AcquireAction[]
{
new Gs2Cdk.Gs2Money.StampSheet.DepositByUserId(
namespaceName: "namespace-0001",
slot: 0,
price: 100,
count: 1,
userId: "#{userId}"
)
}
}
)
},
options: new Gs2Cdk.Gs2Lottery.Model.Options.PrizeTableOptions
{
metadata = "BOX"
}
)
}
);
}
}
Debug.Log(new SampleStack().Yaml()); // Generate Templateimport core from "@/gs2cdk/core";
import lottery from "@/gs2cdk/lottery";
import money from "@/gs2cdk/money";
class SampleStack extends core.Stack
{
public constructor() {
super();
new lottery.model.Namespace(
this,
"namespace-0001",
).masterData(
[
new lottery.model.LotteryModel(
"gacha",
lottery.model.LotteryModelMode.NORMAL,
lottery.model.LotteryModelMethod.PRIZE_TABLE,
{
metadata: "GACHA",
prizeTableName: "gacha"
}
),
new lottery.model.LotteryModel(
"gacha_ssr",
lottery.model.LotteryModelMode.NORMAL,
lottery.model.LotteryModelMethod.PRIZE_TABLE,
{
metadata: "SSR",
prizeTableName: "gacha-ssr"
}
),
new lottery.model.LotteryModel(
"gacha_sr",
lottery.model.LotteryModelMode.NORMAL,
lottery.model.LotteryModelMethod.PRIZE_TABLE,
{
metadata: "SR",
prizeTableName: "gacha-sr"
}
),
new lottery.model.LotteryModel(
"gacha_r",
lottery.model.LotteryModelMode.NORMAL,
lottery.model.LotteryModelMethod.PRIZE_TABLE,
{
metadata: "R",
prizeTableName: "gacha-r"
}
),
new lottery.model.LotteryModel(
"box",
lottery.model.LotteryModelMode.BOX,
lottery.model.LotteryModelMethod.PRIZE_TABLE,
{
metadata: "BOX",
prizeTableName: "box"
}
)
],
[
new lottery.model.PrizeTable(
"gacha",
[
new lottery.model.Prize(
"prize-1",
lottery.model.PrizeType.PRIZE_TABLE,
5,
{
prizeTableName: "gacha-ssr"
}
),
new lottery.model.Prize(
"prize-2",
lottery.model.PrizeType.PRIZE_TABLE,
15,
{
prizeTableName: "gacha-sr"
}
),
new lottery.model.Prize(
"prize-3",
lottery.model.PrizeType.PRIZE_TABLE,
80,
{
prizeTableName: "gacha-r"
}
),
],
{
metadata: "SSR"
}
),
new lottery.model.PrizeTable(
"gacha-ssr",
[
new lottery.model.Prize(
"prize-4",
lottery.model.PrizeType.ACTION,
1,
{
acquireActions: [
new money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}"
),
]
}
),
new lottery.model.Prize(
"prize-5",
lottery.model.PrizeType.ACTION,
2,
{
acquireActions: [
new money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}"
),
]
}
),
new lottery.model.Prize(
"prize-6",
lottery.model.PrizeType.ACTION,
3,
{
acquireActions: [
new money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}"
),
]
}
),
],
{
metadata: "SSR"
}
),
new lottery.model.PrizeTable(
"gacha-sr",
[
new lottery.model.Prize(
"prize-7",
lottery.model.PrizeType.ACTION,
10,
{
acquireActions: [
new money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}"
),
]
}
),
new lottery.model.Prize(
"prize-8",
lottery.model.PrizeType.ACTION,
20,
{
acquireActions: [
new money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}"
),
]
}
),
new lottery.model.Prize(
"prize-9",
lottery.model.PrizeType.ACTION,
30,
{
acquireActions: [
new money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}"
),
]
}
),
],
{
metadata: "SR"
}
),
new lottery.model.PrizeTable(
"gacha-r",
[
new lottery.model.Prize(
"prize-10",
lottery.model.PrizeType.ACTION,
100,
{
acquireActions: [
new money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}"
),
]
}
),
new lottery.model.Prize(
"prize-11",
lottery.model.PrizeType.ACTION,
200,
{
acquireActions: [
new money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}"
),
]
}
),
new lottery.model.Prize(
"prize-12",
lottery.model.PrizeType.ACTION,
300,
{
acquireActions: [
new money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}"
),
]
}
),
],
{
metadata: "R"
}
),
new lottery.model.PrizeTable(
"box",
[
new lottery.model.Prize(
"prize-13",
lottery.model.PrizeType.ACTION,
30,
{
acquireActions: [
new money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}"
),
]
}
),
new lottery.model.Prize(
"prize-14",
lottery.model.PrizeType.ACTION,
20,
{
acquireActions: [
new money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}"
),
]
}
),
new lottery.model.Prize(
"prize-15",
lottery.model.PrizeType.ACTION,
10,
{
acquireActions: [
new money.stampSheet.DepositByUserId(
"namespace-0001",
0,
100,
1,
"#{userId}"
),
]
}
),
],
{
metadata: "BOX"
}
)
]
);
}
}
console.log(new SampleStack().yaml()); // Generate Templatefrom gs2_cdk import Stack, core, lottery, money
class SampleStack(Stack):
def __init__(self):
super().__init__()
lottery.Namespace(
stack=self,
name="namespace-0001",
).master_data(
lottery_models=[
lottery.LotteryModel(
name='gacha',
mode=lottery.LotteryModelMode.NORMAL,
method=lottery.LotteryModelMethod.PRIZE_TABLE,
options=lottery.LotteryModelOptions(
metadata = 'GACHA',
prize_table_name = 'gacha'
),
),
lottery.LotteryModel(
name='gacha_ssr',
mode=lottery.LotteryModelMode.NORMAL,
method=lottery.LotteryModelMethod.PRIZE_TABLE,
options=lottery.LotteryModelOptions(
metadata = 'SSR',
prize_table_name = 'gacha-ssr'
),
),
lottery.LotteryModel(
name='gacha_sr',
mode=lottery.LotteryModelMode.NORMAL,
method=lottery.LotteryModelMethod.PRIZE_TABLE,
options=lottery.LotteryModelOptions(
metadata = 'SR',
prize_table_name = 'gacha-sr'
),
),
lottery.LotteryModel(
name='gacha_r',
mode=lottery.LotteryModelMode.NORMAL,
method=lottery.LotteryModelMethod.PRIZE_TABLE,
options=lottery.LotteryModelOptions(
metadata = 'R',
prize_table_name = 'gacha-r'
),
),
lottery.LotteryModel(
name='box',
mode=lottery.LotteryModelMode.BOX,
method=lottery.LotteryModelMethod.PRIZE_TABLE,
options=lottery.LotteryModelOptions(
metadata = 'BOX',
prize_table_name = 'box'
),
),
],
prize_tables=[
lottery.PrizeTable(
name='gacha',
prizes=[
lottery.Prize(
prize_id='prize-1',
type=lottery.PrizeType.PRIZE_TABLE,
weight=5,
options=lottery.PrizeOptions(
prize_table_name='gacha-ssr',
),
),
lottery.Prize(
prize_id='prize-2',
type=lottery.PrizeType.PRIZE_TABLE,
weight=15,
options=lottery.PrizeOptions(
prize_table_name='gacha-sr',
),
),
lottery.Prize(
prize_id='prize-3',
type=lottery.PrizeType.PRIZE_TABLE,
weight=80,
options=lottery.PrizeOptions(
prize_table_name='gacha-r',
),
),
],
options=lottery.PrizeTableOptions(
metadata = 'SSR'
),
),
lottery.PrizeTable(
name='gacha-ssr',
prizes=[
lottery.Prize(
prize_id='prize-4',
type=lottery.PrizeType.ACTION,
weight=1,
options=lottery.PrizeOptions(
acquire_actions=[
money.DepositByUserId(
namespace_name='namespace-0001',
slot=0,
price=100,
count=1,
user_id='#{userId}'
),
],
),
),
lottery.Prize(
prize_id='prize-5',
type=lottery.PrizeType.ACTION,
weight=2,
options=lottery.PrizeOptions(
acquire_actions=[
money.DepositByUserId(
namespace_name='namespace-0001',
slot=0,
price=100,
count=1,
user_id='#{userId}'
),
],
),
),
lottery.Prize(
prize_id='prize-6',
type=lottery.PrizeType.ACTION,
weight=3,
options=lottery.PrizeOptions(
acquire_actions=[
money.DepositByUserId(
namespace_name='namespace-0001',
slot=0,
price=100,
count=1,
user_id='#{userId}'
),
],
),
),
],
options=lottery.PrizeTableOptions(
metadata = 'SSR'
),
),
lottery.PrizeTable(
name='gacha-sr',
prizes=[
lottery.Prize(
prize_id='prize-7',
type=lottery.PrizeType.ACTION,
weight=10,
options=lottery.PrizeOptions(
acquire_actions=[
money.DepositByUserId(
namespace_name='namespace-0001',
slot=0,
price=100,
count=1,
user_id='#{userId}'
),
],
),
),
lottery.Prize(
prize_id='prize-8',
type=lottery.PrizeType.ACTION,
weight=20,
options=lottery.PrizeOptions(
acquire_actions=[
money.DepositByUserId(
namespace_name='namespace-0001',
slot=0,
price=100,
count=1,
user_id='#{userId}'
),
],
),
),
lottery.Prize(
prize_id='prize-9',
type=lottery.PrizeType.ACTION,
weight=30,
options=lottery.PrizeOptions(
acquire_actions=[
money.DepositByUserId(
namespace_name='namespace-0001',
slot=0,
price=100,
count=1,
user_id='#{userId}'
),
],
),
),
],
options=lottery.PrizeTableOptions(
metadata = 'SR'
),
),
lottery.PrizeTable(
name='gacha-r',
prizes=[
lottery.Prize(
prize_id='prize-10',
type=lottery.PrizeType.ACTION,
weight=100,
options=lottery.PrizeOptions(
acquire_actions=[
money.DepositByUserId(
namespace_name='namespace-0001',
slot=0,
price=100,
count=1,
user_id='#{userId}'
),
],
),
),
lottery.Prize(
prize_id='prize-11',
type=lottery.PrizeType.ACTION,
weight=200,
options=lottery.PrizeOptions(
acquire_actions=[
money.DepositByUserId(
namespace_name='namespace-0001',
slot=0,
price=100,
count=1,
user_id='#{userId}'
),
],
),
),
lottery.Prize(
prize_id='prize-12',
type=lottery.PrizeType.ACTION,
weight=300,
options=lottery.PrizeOptions(
acquire_actions=[
money.DepositByUserId(
namespace_name='namespace-0001',
slot=0,
price=100,
count=1,
user_id='#{userId}'
),
],
),
),
],
options=lottery.PrizeTableOptions(
metadata = 'R'
),
),
lottery.PrizeTable(
name='box',
prizes=[
lottery.Prize(
prize_id='prize-13',
type=lottery.PrizeType.ACTION,
weight=30,
options=lottery.PrizeOptions(
acquire_actions=[
money.DepositByUserId(
namespace_name='namespace-0001',
slot=0,
price=100,
count=1,
user_id='#{userId}'
),
],
),
),
lottery.Prize(
prize_id='prize-14',
type=lottery.PrizeType.ACTION,
weight=20,
options=lottery.PrizeOptions(
acquire_actions=[
money.DepositByUserId(
namespace_name='namespace-0001',
slot=0,
price=100,
count=1,
user_id='#{userId}'
),
],
),
),
lottery.Prize(
prize_id='prize-15',
type=lottery.PrizeType.ACTION,
weight=10,
options=lottery.PrizeOptions(
acquire_actions=[
money.DepositByUserId(
namespace_name='namespace-0001',
slot=0,
price=100,
count=1,
user_id='#{userId}'
),
],
),
),
],
options=lottery.PrizeTableOptions(
metadata = 'BOX'
),
),
],
)
print(SampleStack().yaml()) # Generate TemplatePrizeTable
Prize Table
A prize can either specify an acquire action directly or reference another Prize Table. By nesting Prize Tables, you can configure a two-step drawing process—for example, the first step determines the rarity such as SSR, SR, or R, and the second step selects a specific item corresponding to that rarity. This structure makes it easier to manage and adjust the overall distribution rates for each rarity in the game.
| Type | Condition | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|---|
| prizeTableId | string | * | ~ 1024 chars | Prize Table GRN * Set automatically by the server | ||
| name | string | ✓ | ~ 128 chars | Prize Table name Prize Table-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). | ||
| metadata | string | ~ 128 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. | |||
| prizes | List<Prize> | ✓ | 1 ~ 100 items | Prizes The list of prizes in this Prize Table. Each prize defines its draw weight (probability), the actions to execute when drawn, and optionally a draw limit. The actual draw probability of each prize is calculated as its weight divided by the total weight of all prizes in the table. |
Prize
Prize
A single prize entry within a Prize Table. A prize can either directly specify acquire actions (granting items, currency, etc.) or reference another Prize Table for nested drawing. Each prize has a draw weight that determines its relative probability of being drawn.
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| prizeId | string | ✓ | UUID | ~ 36 chars | Prize ID A unique identifier for this prize within the Prize Table. Used to track draw limits and as a reference when specifying failover prizes. | |||||||
| type | String Enum enum { “action”, “prize_table” } | ✓ | Prize Type Determines whether this prize directly grants rewards or delegates to another Prize Table. “action” specifies acquire actions to execute when drawn. “prize_table” references another Prize Table for a nested drawing (e.g., first draw determines rarity, second draw determines specific item).
| |||||||||
| acquireActions | List<AcquireAction> | {type} == “action” | [] | 1 ~ 100 items | Acquire Actions The list of acquire actions to execute when this prize is drawn. Multiple actions can be specified to grant several rewards at once (e.g., an item and currency together). * Applicable only if type is “action” | |||||||
| drawnLimit | int | {type} == “action” | 1 ~ 1000000 | Maximum Number of Draws The maximum number of times this prize can be drawn across all users. When the limit is reached, the failover prize (limitFailOverPrizeId) is drawn instead. Used to implement limited-quantity prizes such as jackpot items. * Applicable only if type is “action” | ||||||||
| limitFailOverPrizeId | string | {type} == “action” and {drawnLimit} > 0 | ✓* | ~ 32 chars | Limit Failover Prize ID The ID of the prize to draw instead when this prize’s draw limit (drawnLimit) has been reached. Must reference another prize within the same Prize Table. * Required if type is “action” and drawnLimit is greater than 0 | |||||||
| prizeTableName | string | {type} == “prize_table” | ✓* | ~ 128 chars | Prize Table Name The name of the Prize Table to delegate the draw to. Used when the prize type is “prize_table” for nested drawing. * Required if type is “prize_table” | |||||||
| weight | int | ✓ | 1 ~ 2147483646 | Draw Weight The relative weight of this prize in the Prize Table. The actual draw probability is calculated as this prize’s weight divided by the total weight of all prizes in the table. For example, if three prizes have weights of 70, 20, and 10, their draw probabilities are 70%, 20%, and 10% respectively. |
LotteryModel
Lottery Model
Lottery Model is an entity that defines the draw method and how to reference the draw table.
Two draw methods are available: Standard Draw, which performs draws with a fixed probability each time, and Box Draw, where a predetermined number of prizes are placed in a box, and prizes are drawn from the box one by one with each draw.
The lottery process uses a Prize Table. GS2-Script can be used to replace a part of the Prize Table with a different table when multiple drawings are performed. By using this mechanism, it is possible to apply a different Prize Table only once in a 10-round gacha.
| Type | Condition | Required | Default | Value Limits | Description | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| lotteryModelId | string | * | ~ 1024 chars | Lottery Model GRN * Set automatically by the server | ||||||||
| name | string | ✓ | ~ 128 chars | Lottery Model name Lottery Model-specific name. Specified using alphanumeric characters, hyphen (-), underscore (_), and period (.). | ||||||||
| 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. | |||||||||
| mode | String Enum enum { “normal”, “box” } | ✓ | Drawing Mode Select the prize drawing method. “normal” performs draws with a fixed probability each time (prizes can be drawn repeatedly). “box” places a predetermined number of prizes in a virtual box, and each draw removes a prize from the box (guaranteeing all prizes will eventually be drawn).
| |||||||||
| method | String Enum enum { “prize_table”, “script” } | ✓ | Lottery Method Determines how the Prize Table is referenced. “prize_table” uses a statically specified Prize Table. “script” uses GS2-Script to dynamically select the Prize Table at draw time, enabling scenarios like applying a different Prize Table for one draw in a 10-draw gacha.
| |||||||||
| prizeTableName | string | {method} == “prize_table” | ✓* | ~ 128 chars | Prize Table Name The name of the Prize Table to use for this lottery model. Required when the lottery method is “prize_table”. * Required if method is “prize_table” | |||||||
| choicePrizeTableScriptId | string | {method} == “script” | ✓* | ~ 1024 chars | GS2-Script script GRN
to determine the Prize Table Script Trigger Reference - choicePrizeTable* Required if method is “script” |
AcquireAction
Acquire Action