GS2-Lottery GS2-Deploy/CDK リファレンス
エンティティ
Namespace
ネームスペース
ネームスペースは一つのプロジェクトで同じサービスを異なる用途で複数利用できるようにするための仕組みです。
GS2 のサービスは基本的にネームスペースというレイヤーがあり、ネームスペースが異なれば同じサービスでもまったく別のデータ空間として取り扱われます。
そのため、各サービスの利用を開始するにあたってネームスペースを作成する必要があります。
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
name | string | ✓ | ~ 128文字 | ネームスペース名 | |
description | string | ~ 1024文字 | 説明文 | ||
transactionSetting | TransactionSetting | ✓ | トランザクション設定 | ||
lotteryTriggerScriptId | string | ~ 1024文字 | 抽選を実行した際に呼び出される GS2-Script のスクリプト | ||
choicePrizeTableScriptId | string | ~ 1024文字 | 抽選確率テーブルを動的に決定するための GS2-Script のスクリプト | ||
logSetting | LogSetting | ログの出力設定 |
GetAttr
型 | 説明 | |
---|---|---|
Item | Namespace | 作成したネームスペース |
実装例
Type: GS2::Lottery::Namespace
Properties:
Name: namespace1
Description: null
TransactionSetting:
EnableAutoRun: false
QueueNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001
KeyId: grn:gs2:ap-northeast-1:YourOwnerId:key:namespace1:key:key-0001
LotteryTriggerScriptId: null
ChoicePrizeTableScriptId: null
LogSetting:
LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1
from 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(
queue_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001',
options=core.TransactionSettingOptions(
key_id='grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001',
)
),
log_setting=core.LogSetting(
logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
),
),
)
print(SampleStack().yaml()) # Generate Template
class 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(
enableAutoRun: True,
queueNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001",
options: new \Gs2Cdk\Core\Model\Options\TransactionSettingOptions(
keyId: "grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001"
)
),
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.lottery.model.Namespace(
this,
"namespace-0001",
new io.gs2.cdk.lottery.model.options.NamespaceOptions() {
{
transactionSetting = new io.gs2.cdk.core.model.TransactionSetting(){
{
queueNamespaceId = "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001";
},
new io.gs2.cdk.core.model.options.TransactionSettingOptions(
"grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001"
)
);
logSetting = new io.gs2.cdk.core.model.LogSetting(
loggingNamespaceId = "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
);
}
}
);
}
}
System.out.println(new SampleStack().yaml()); // Generate Template
import 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(
,
"grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001",
{
"grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001"
}
),
logSetting: new core.LogSetting(
"grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
)
}
);
}
}
console.log(new SampleStack().yaml()); // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
public SampleStack() {
new Gs2Cdk.Gs2Lottery.Model.Namespace(
this,
"namespace-0001",
new Gs2Cdk.Gs2Lottery.Model.Options.NamespaceOptions {
transactionSetting = new Gs2Cdk.Core.Model.TransactionSetting(
new Gs2Cdk.Core.Model.Options.TransactionSettingOptions {
queueNamespaceId = "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"
},
new Gs2Cdk.Core.Model.Options.TransactionSettingOptions(
KeyId = "grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001"
}
),
logSetting = new Gs2Cdk.Core.Model.LogSetting(
LoggingNamespaceId = "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
)
}
);
}
}
Debug.Log(new SampleStack().Yaml()); // Generate Template
CurrentLotteryMaster
現在有効なマスターデータ
GS2ではマスターデータの管理にJSON形式のファイルを使用します。
ファイルをアップロードすることで、実際にサーバーに設定を反映することができます。
JSONファイルを作成する方法として、マネージメントコンソール上でのマスターデータエディタを提供していますが
よりゲームの運営に相応しいツールを作成し、適切なフォーマットのJSONファイルを書き出すことでもサービスを利用可能です。
Note
JSONファイルの形式については GS2-Lottery マスターデータリファレンス をご参照ください。型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 128文字 | ネームスペース名 | |
settings | string | ✓ | ~ 5242880文字 | マスターデータ |
GetAttr
型 | 説明 | |
---|---|---|
Item | CurrentLotteryMaster | 更新した現在有効な抽選設定 |
実装例
Type: GS2::Lottery::CurrentLotteryMaster
Properties:
NamespaceName: namespace1
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": "{\"count\": 1}"
}
],
"weight": 1
},
{
"prizeId": "prize-5",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": "{\"count\": 1}"
}
],
"weight": 2
},
{
"prizeId": "prize-6",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": "{\"count\": 1}"
}
],
"weight": 3
}
],
"metadata": "SSR"
},
{
"name": "gacha-sr",
"prizes": [
{
"prizeId": "prize-7",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": "{\"count\": 1}"
}
],
"weight": 10
},
{
"prizeId": "prize-8",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": "{\"count\": 1}"
}
],
"weight": 20
},
{
"prizeId": "prize-9",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": "{\"count\": 1}"
}
],
"weight": 30
}
],
"metadata": "SR"
},
{
"name": "gacha-r",
"prizes": [
{
"prizeId": "prize-10",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": "{\"count\": 1}"
}
],
"weight": 100
},
{
"prizeId": "prize-11",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": "{\"count\": 1}"
}
],
"weight": 200
},
{
"prizeId": "prize-12",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": "{\"count\": 1}"
}
],
"weight": 300
}
],
"metadata": "R"
},
{
"name": "box",
"prizes": [
{
"prizeId": "prize-13",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": "{\"count\": 1}"
}
],
"weight": 30
},
{
"prizeId": "prize-14",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": "{\"count\": 1}"
}
],
"weight": 20
},
{
"prizeId": "prize-15",
"type": "action",
"acquireActions": [
{
"action": "Gs2Money:DepositByUserId",
"request": "{\"count\": 1}"
}
],
"weight": 10
}
],
"metadata": "BOX"
}
]
}
from gs2_cdk import Stack, core, lottery
class SampleStack(Stack):
def __init__(self):
super().__init__()
lottery.Namespace(
stack=self,
# 省略
).master_data(
lottery_models=[
lottery.LotteryModel(
name='gacha',
mode='normal',
method='prize_table',
options=lottery.LotteryModelOptions(
metadata='GACHA',
prize_table_name='gacha',
),
),
lottery.LotteryModel(
name='gacha_ssr',
mode='normal',
method='prize_table',
options=lottery.LotteryModelOptions(
metadata='SSR',
prize_table_name='gacha-ssr',
),
),
lottery.LotteryModel(
name='gacha_sr',
mode='normal',
method='prize_table',
options=lottery.LotteryModelOptions(
metadata='SR',
prize_table_name='gacha-sr',
),
),
lottery.LotteryModel(
name='gacha_r',
mode='normal',
method='prize_table',
options=lottery.LotteryModelOptions(
metadata='R',
prize_table_name='gacha-r',
),
),
lottery.LotteryModel(
name='box',
mode='box',
method='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='prize_table',
prize_table_name='gacha-ssr',
weight=5
),
lottery.Prize(
prize_id='prize-2',
type='prize_table',
prize_table_name='gacha-sr',
weight=15
),
lottery.Prize(
prize_id='prize-3',
type='prize_table',
prize_table_name='gacha-r',
weight=80
),
],
options=lottery.PrizeTableOptions(
metadata='SSR',
),
),
lottery.PrizeTable(
name='gacha-ssr',
prizes=[
lottery.Prize(
prize_id='prize-4',
type='action',
acquire_actions=[
lottery.AcquireAction(
action='Gs2Money:DepositByUserId',
request='{"count": 1}'
)
],
weight=1
),
lottery.Prize(
prize_id='prize-5',
type='action',
acquire_actions=[
lottery.AcquireAction(
action='Gs2Money:DepositByUserId',
request='{"count": 1}'
)
],
weight=2
),
lottery.Prize(
prize_id='prize-6',
type='action',
acquire_actions=[
lottery.AcquireAction(
action='Gs2Money:DepositByUserId',
request='{"count": 1}'
)
],
weight=3
),
],
options=lottery.PrizeTableOptions(
metadata='SSR',
),
),
lottery.PrizeTable(
name='gacha-sr',
prizes=[
lottery.Prize(
prize_id='prize-7',
type='action',
acquire_actions=[
lottery.AcquireAction(
action='Gs2Money:DepositByUserId',
request='{"count": 1}'
)
],
weight=10
),
lottery.Prize(
prize_id='prize-8',
type='action',
acquire_actions=[
lottery.AcquireAction(
action='Gs2Money:DepositByUserId',
request='{"count": 1}'
)
],
weight=20
),
lottery.Prize(
prize_id='prize-9',
type='action',
acquire_actions=[
lottery.AcquireAction(
action='Gs2Money:DepositByUserId',
request='{"count": 1}'
)
],
weight=30
),
],
options=lottery.PrizeTableOptions(
metadata='SR',
),
),
lottery.PrizeTable(
name='gacha-r',
prizes=[
lottery.Prize(
prize_id='prize-10',
type='action',
acquire_actions=[
lottery.AcquireAction(
action='Gs2Money:DepositByUserId',
request='{"count": 1}'
)
],
weight=100
),
lottery.Prize(
prize_id='prize-11',
type='action',
acquire_actions=[
lottery.AcquireAction(
action='Gs2Money:DepositByUserId',
request='{"count": 1}'
)
],
weight=200
),
lottery.Prize(
prize_id='prize-12',
type='action',
acquire_actions=[
lottery.AcquireAction(
action='Gs2Money:DepositByUserId',
request='{"count": 1}'
)
],
weight=300
),
],
options=lottery.PrizeTableOptions(
metadata='R',
),
),
lottery.PrizeTable(
name='box',
prizes=[
lottery.Prize(
prize_id='prize-13',
type='action',
acquire_actions=[
lottery.AcquireAction(
action='Gs2Money:DepositByUserId',
request='{"count": 1}'
)
],
weight=30
),
lottery.Prize(
prize_id='prize-14',
type='action',
acquire_actions=[
lottery.AcquireAction(
action='Gs2Money:DepositByUserId',
request='{"count": 1}'
)
],
weight=20
),
lottery.Prize(
prize_id='prize-15',
type='action',
acquire_actions=[
lottery.AcquireAction(
action='Gs2Money:DepositByUserId',
request='{"count": 1}'
)
],
weight=10
),
],
options=lottery.PrizeTableOptions(
metadata='BOX',
),
),
],
)
print(SampleStack().yaml()) # Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
(new \Gs2Cdk\Lottery\Model\Namespace_(
stack: $this,
// 省略
))->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: "prize_table",
prizeTableName: "gacha-ssr",
weight: 5
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-2",
type: "prize_table",
prizeTableName: "gacha-sr",
weight: 15
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-3",
type: "prize_table",
prizeTableName: "gacha-r",
weight: 80
),
],
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: "action",
acquireActions: [
new \Gs2Cdk\Core\Model\AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
],
weight: 1
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-5",
type: "action",
acquireActions: [
new \Gs2Cdk\Core\Model\AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
],
weight: 2
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-6",
type: "action",
acquireActions: [
new \Gs2Cdk\Core\Model\AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
],
weight: 3
),
],
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: "action",
acquireActions: [
new \Gs2Cdk\Core\Model\AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
],
weight: 10
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-8",
type: "action",
acquireActions: [
new \Gs2Cdk\Core\Model\AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
],
weight: 20
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-9",
type: "action",
acquireActions: [
new \Gs2Cdk\Core\Model\AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
],
weight: 30
),
],
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: "action",
acquireActions: [
new \Gs2Cdk\Core\Model\AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
],
weight: 100
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-11",
type: "action",
acquireActions: [
new \Gs2Cdk\Core\Model\AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
],
weight: 200
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-12",
type: "action",
acquireActions: [
new \Gs2Cdk\Core\Model\AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
],
weight: 300
),
],
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: "action",
acquireActions: [
new \Gs2Cdk\Core\Model\AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
],
weight: 30
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-14",
type: "action",
acquireActions: [
new \Gs2Cdk\Core\Model\AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
],
weight: 20
),
new \Gs2Cdk\Lottery\Model\Prize(
prizeId: "prize-15",
type: "action",
acquireActions: [
new \Gs2Cdk\Core\Model\AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
],
weight: 10
),
],
options: new \Gs2Cdk\Lottery\Model\Options\PrizeTableOptions(
metadata:"BOX"
)
)
]
);
}
}
print((new SampleStack())->yaml()); // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.lottery.model.Namespace(
this,
// 省略
).masterData(
Arrays.asList(
new io.gs2.cdk.lottery.model.LotteryModel(
"gacha",
Normal,
PrizeTable,
new io.gs2.cdk.lottery.model.options.LotteryModelOptions() {
{
metadata: "GACHA";
prizeTableName: "gacha";
}
}
),
new io.gs2.cdk.lottery.model.LotteryModel(
"gacha_ssr",
Normal,
PrizeTable,
new io.gs2.cdk.lottery.model.options.LotteryModelOptions() {
{
metadata: "SSR";
prizeTableName: "gacha-ssr";
}
}
),
new io.gs2.cdk.lottery.model.LotteryModel(
"gacha_sr",
Normal,
PrizeTable,
new io.gs2.cdk.lottery.model.options.LotteryModelOptions() {
{
metadata: "SR";
prizeTableName: "gacha-sr";
}
}
),
new io.gs2.cdk.lottery.model.LotteryModel(
"gacha_r",
Normal,
PrizeTable,
new io.gs2.cdk.lottery.model.options.LotteryModelOptions() {
{
metadata: "R";
prizeTableName: "gacha-r";
}
}
),
new io.gs2.cdk.lottery.model.LotteryModel(
"box",
Box,
PrizeTable,
new io.gs2.cdk.lottery.model.options.LotteryModelOptions() {
{
metadata: "BOX";
prizeTableName: "box";
}
}
)
),
Arrays.asList(
new io.gs2.cdk.lottery.model.PrizeTable(
"gacha",
Arrays.asList(
new io.gs2.cdk.lottery.model.Prize(
"prize-1",
"prize_table",
"gacha-ssr",
5
),
new io.gs2.cdk.lottery.model.Prize(
"prize-2",
"prize_table",
"gacha-sr",
15
),
new io.gs2.cdk.lottery.model.Prize(
"prize-3",
"prize_table",
"gacha-r",
80
)
),
new io.gs2.cdk.lottery.model.options.PrizeTableOptions() {
{
metadata: "SSR";
}
}
),
new io.gs2.cdk.lottery.model.PrizeTable(
"gacha-ssr",
Arrays.asList(
new io.gs2.cdk.lottery.model.Prize(
"prize-4",
"action",
Arrays.asList(
new io.gs2.cdk.core.acquire_action(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
),
1
),
new io.gs2.cdk.lottery.model.Prize(
"prize-5",
"action",
Arrays.asList(
new io.gs2.cdk.core.acquire_action(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
),
2
),
new io.gs2.cdk.lottery.model.Prize(
"prize-6",
"action",
Arrays.asList(
new io.gs2.cdk.core.acquire_action(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
),
3
)
),
new io.gs2.cdk.lottery.model.options.PrizeTableOptions() {
{
metadata: "SSR";
}
}
),
new io.gs2.cdk.lottery.model.PrizeTable(
"gacha-sr",
Arrays.asList(
new io.gs2.cdk.lottery.model.Prize(
"prize-7",
"action",
Arrays.asList(
new io.gs2.cdk.core.acquire_action(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
),
10
),
new io.gs2.cdk.lottery.model.Prize(
"prize-8",
"action",
Arrays.asList(
new io.gs2.cdk.core.acquire_action(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
),
20
),
new io.gs2.cdk.lottery.model.Prize(
"prize-9",
"action",
Arrays.asList(
new io.gs2.cdk.core.acquire_action(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
),
30
)
),
new io.gs2.cdk.lottery.model.options.PrizeTableOptions() {
{
metadata: "SR";
}
}
),
new io.gs2.cdk.lottery.model.PrizeTable(
"gacha-r",
Arrays.asList(
new io.gs2.cdk.lottery.model.Prize(
"prize-10",
"action",
Arrays.asList(
new io.gs2.cdk.core.acquire_action(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
),
100
),
new io.gs2.cdk.lottery.model.Prize(
"prize-11",
"action",
Arrays.asList(
new io.gs2.cdk.core.acquire_action(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
),
200
),
new io.gs2.cdk.lottery.model.Prize(
"prize-12",
"action",
Arrays.asList(
new io.gs2.cdk.core.acquire_action(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
),
300
)
),
new io.gs2.cdk.lottery.model.options.PrizeTableOptions() {
{
metadata: "R";
}
}
),
new io.gs2.cdk.lottery.model.PrizeTable(
"box",
Arrays.asList(
new io.gs2.cdk.lottery.model.Prize(
"prize-13",
"action",
Arrays.asList(
new io.gs2.cdk.core.acquire_action(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
),
30
),
new io.gs2.cdk.lottery.model.Prize(
"prize-14",
"action",
Arrays.asList(
new io.gs2.cdk.core.acquire_action(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
),
20
),
new io.gs2.cdk.lottery.model.Prize(
"prize-15",
"action",
Arrays.asList(
new io.gs2.cdk.core.acquire_action(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
),
10
)
),
new io.gs2.cdk.lottery.model.options.PrizeTableOptions() {
{
metadata: "BOX";
}
}
)
)
);
}
}
System.out.println(new SampleStack().yaml()); // Generate Template
import core from "@/gs2cdk/core";
import lottery from "@/gs2cdk/lottery";
class SampleStack extends core.Stack
{
public constructor() {
super();
new lottery.model.Namespace(
this,
// 省略
).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",
"prize_table",
"gacha-ssr",
5
),
new lottery.model.Prize(
"prize-2",
"prize_table",
"gacha-sr",
15
),
new lottery.model.Prize(
"prize-3",
"prize_table",
"gacha-r",
80
),
],
{
metadata: "SSR"
}
),
new lottery.model.PrizeTable(
"gacha-ssr",
[
new lottery.model.Prize(
"prize-4",
"action",
new AcquireAction[
new AcquireAction(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
],
1
),
new lottery.model.Prize(
"prize-5",
"action",
new AcquireAction[
new AcquireAction(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
],
2
),
new lottery.model.Prize(
"prize-6",
"action",
new AcquireAction[
new AcquireAction(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
],
3
),
],
{
metadata: "SSR"
}
),
new lottery.model.PrizeTable(
"gacha-sr",
[
new lottery.model.Prize(
"prize-7",
"action",
new AcquireAction[
new AcquireAction(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
],
10
),
new lottery.model.Prize(
"prize-8",
"action",
new AcquireAction[
new AcquireAction(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
],
20
),
new lottery.model.Prize(
"prize-9",
"action",
new AcquireAction[
new AcquireAction(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
],
30
),
],
{
metadata: "SR"
}
),
new lottery.model.PrizeTable(
"gacha-r",
[
new lottery.model.Prize(
"prize-10",
"action",
new AcquireAction[
new AcquireAction(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
],
100
),
new lottery.model.Prize(
"prize-11",
"action",
new AcquireAction[
new AcquireAction(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
],
200
),
new lottery.model.Prize(
"prize-12",
"action",
new AcquireAction[
new AcquireAction(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
],
300
),
],
{
metadata: "R"
}
),
new lottery.model.PrizeTable(
"box",
[
new lottery.model.Prize(
"prize-13",
"action",
new AcquireAction[
new AcquireAction(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
],
30
),
new lottery.model.Prize(
"prize-14",
"action",
new AcquireAction[
new AcquireAction(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
],
20
),
new lottery.model.Prize(
"prize-15",
"action",
new AcquireAction[
new AcquireAction(
"Gs2Money:DepositByUserId",
"{\"count\": 1}"
)
],
10
),
],
{
metadata: "BOX"
}
)
]
);
}
}
console.log(new SampleStack().yaml()); // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
public SampleStack() {
new Gs2Cdk.Gs2Lottery.Model.Namespace(
this,
// 省略
).MasterData(
new [] {
new Gs2Cdk.Gs2Lottery.Model.LotteryModel(
"gacha",
Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMode.Normal,
Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMethod.PrizeTable,
new Gs2Cdk.Gs2Lottery.Model.Options.LotteryModelOptions {
metadata = "GACHA",
prizeTableName = "gacha"
}
),
new Gs2Cdk.Gs2Lottery.Model.LotteryModel(
"gacha_ssr",
Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMode.Normal,
Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMethod.PrizeTable,
new Gs2Cdk.Gs2Lottery.Model.Options.LotteryModelOptions {
metadata = "SSR",
prizeTableName = "gacha-ssr"
}
),
new Gs2Cdk.Gs2Lottery.Model.LotteryModel(
"gacha_sr",
Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMode.Normal,
Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMethod.PrizeTable,
new Gs2Cdk.Gs2Lottery.Model.Options.LotteryModelOptions {
metadata = "SR",
prizeTableName = "gacha-sr"
}
),
new Gs2Cdk.Gs2Lottery.Model.LotteryModel(
"gacha_r",
Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMode.Normal,
Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMethod.PrizeTable,
new Gs2Cdk.Gs2Lottery.Model.Options.LotteryModelOptions {
metadata = "R",
prizeTableName = "gacha-r"
}
),
new Gs2Cdk.Gs2Lottery.Model.LotteryModel(
"box",
Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMode.Box,
Gs2Cdk.Gs2Lottery.Model.Enums.LotteryModelMethod.PrizeTable,
new Gs2Cdk.Gs2Lottery.Model.Options.LotteryModelOptions {
metadata = "BOX",
prizeTableName = "box"
}
)
},
new [] {
new Gs2Cdk.Gs2Lottery.Model.PrizeTable(
"gacha",
new Gs2Cdk.Gs2Lottery.Model.Prize[] {
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-1",
type: "prize_table",
prizeTableName: "gacha-ssr",
weight: 5
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-2",
type: "prize_table",
prizeTableName: "gacha-sr",
weight: 15
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-3",
type: "prize_table",
prizeTableName: "gacha-r",
weight: 80
),
},
new Gs2Cdk.Gs2Lottery.Model.Options.PrizeTableOptions {
metadata = "SSR"
}
),
new Gs2Cdk.Gs2Lottery.Model.PrizeTable(
"gacha-ssr",
new Gs2Cdk.Gs2Lottery.Model.Prize[] {
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-4",
type: "action",
acquireActions: new Gs2Cdk.Core.Model.AcquireAction[] {
new Gs2Cdk.Core.Model.AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
},
weight: 1
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-5",
type: "action",
acquireActions: new Gs2Cdk.Core.Model.AcquireAction[] {
new Gs2Cdk.Core.Model.AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
},
weight: 2
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-6",
type: "action",
acquireActions: new Gs2Cdk.Core.Model.AcquireAction[] {
new Gs2Cdk.Core.Model.AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
},
weight: 3
),
},
new Gs2Cdk.Gs2Lottery.Model.Options.PrizeTableOptions {
metadata = "SSR"
}
),
new Gs2Cdk.Gs2Lottery.Model.PrizeTable(
"gacha-sr",
new Gs2Cdk.Gs2Lottery.Model.Prize[] {
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-7",
type: "action",
acquireActions: new Gs2Cdk.Core.Model.AcquireAction[] {
new Gs2Cdk.Core.Model.AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
},
weight: 10
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-8",
type: "action",
acquireActions: new Gs2Cdk.Core.Model.AcquireAction[] {
new Gs2Cdk.Core.Model.AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
},
weight: 20
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-9",
type: "action",
acquireActions: new Gs2Cdk.Core.Model.AcquireAction[] {
new Gs2Cdk.Core.Model.AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
},
weight: 30
),
},
new Gs2Cdk.Gs2Lottery.Model.Options.PrizeTableOptions {
metadata = "SR"
}
),
new Gs2Cdk.Gs2Lottery.Model.PrizeTable(
"gacha-r",
new Gs2Cdk.Gs2Lottery.Model.Prize[] {
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-10",
type: "action",
acquireActions: new Gs2Cdk.Core.Model.AcquireAction[] {
new Gs2Cdk.Core.Model.AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
},
weight: 100
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-11",
type: "action",
acquireActions: new Gs2Cdk.Core.Model.AcquireAction[] {
new Gs2Cdk.Core.Model.AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
},
weight: 200
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-12",
type: "action",
acquireActions: new Gs2Cdk.Core.Model.AcquireAction[] {
new Gs2Cdk.Core.Model.AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
},
weight: 300
),
},
new Gs2Cdk.Gs2Lottery.Model.Options.PrizeTableOptions {
metadata = "R"
}
),
new Gs2Cdk.Gs2Lottery.Model.PrizeTable(
"box",
new Gs2Cdk.Gs2Lottery.Model.Prize[] {
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-13",
type: "action",
acquireActions: new Gs2Cdk.Core.Model.AcquireAction[] {
new Gs2Cdk.Core.Model.AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
},
weight: 30
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-14",
type: "action",
acquireActions: new Gs2Cdk.Core.Model.AcquireAction[] {
new Gs2Cdk.Core.Model.AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
},
weight: 20
),
new Gs2Cdk.Gs2Lottery.Model.Prize(
prizeId: "prize-15",
type: "action",
acquireActions: new Gs2Cdk.Core.Model.AcquireAction[] {
new Gs2Cdk.Core.Model.AcquireAction(
action: "Gs2Money:DepositByUserId",
request: "{\"count\": 1}"
)
},
weight: 10
),
},
new Gs2Cdk.Gs2Lottery.Model.Options.PrizeTableOptions {
metadata = "BOX"
}
)
}
);
}
}
Debug.Log(new SampleStack().Yaml()); // Generate Template
Probability
排出確率
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
prize | DrawnPrize | ✓ | 景品の種類 | ||
rate | float | ✓ | ~ 1.0 | 排出確率(0.0〜1.0) |
Prize
景品
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
prizeId | string | ✓ | UUID | ~ 36文字 | 景品ID |
type | enum { “action”, “prize_table” } | ✓ | ~ 128文字 | 景品の種類 | |
acquireActions | List<AcquireAction> | {type} == “action” | [] | 1 ~ 100 items | 景品の入手アクションリスト |
drawnLimit | int | {type} == “action” | 1 ~ 100000 | 最大排出数 | |
limitFailOverPrizeId | string | {type} == “action” and {drawnLimit} > 0 | ~ 32文字 | 最大排出数に達していた時に代わりに排出する景品ID | |
prizeTableName | string | {type} == “prize_table” | ~ 128文字 | 排出確率テーブルの名前 | |
weight | int | ✓ | 1 ~ 2147483646 | 排出重み |
type に指定する列挙型の定義
定義 | 説明 |
---|---|
action | 景品の入手アクション |
prize_table | 更に抽選テーブルを指定して再抽選 |
DrawnPrize
景品の種類
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
prizeId | string | ✓ | ~ 36文字 | 景品ID | |
acquireActions | List<AcquireAction> | ~ 100 items | 入手アクションのリスト |
BoxItem
ボックスから取り出したアイテム
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
prizeId | string | ✓ | ~ 128文字 | 景品ID | |
acquireActions | List<AcquireAction> | ~ 100 items | 入手アクションのリスト | ||
remaining | int | ✓ | ~ 2147483646 | 残り数量 | |
initial | int | ✓ | ~ 2147483646 | 初期数量 |
AcquireAction
入手アクション
Config
コンフィグ設定
トランザクションの変数に適用する設定値
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
key | string | ✓ | ~ 64文字 | 名前 | |
value | string | ~ 51200文字 | 値 |
GitHubCheckoutSetting
GitHubからマスターデータをチェックアウトする設定
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
apiKeyId | string | ✓ | ~ 1024文字 | GitHub のAPIキーGRN | |
repositoryName | string | ✓ | ~ 1024文字 | リポジトリ名 | |
sourcePath | string | ✓ | ~ 1024文字 | ソースコードのファイルパス | |
referenceType | enum { “commit_hash”, “branch”, “tag” } | ✓ | ~ 128文字 | コードの取得元 | |
commitHash | string | {referenceType} == “commit_hash” | ~ 1024文字 | コミットハッシュ | |
branchName | string | {referenceType} == “branch” | ~ 1024文字 | ブランチ名 | |
tagName | string | {referenceType} == “tag” | ~ 1024文字 | タグ名 |
referenceType に指定する列挙型の定義
定義 | 説明 |
---|---|
commit_hash | コミットハッシュ |
branch | ブランチ |
tag | タグ |
LogSetting
ログの書き出し設定
ログデータの書き出し設定を管理します。この型は、ログデータを書き出すために使用されるログ名前空間の識別子(Namespace ID)を保持します。
ログ名前空間IDは、ログデータを集約し、保存する対象の GS2-Log の名前空間を指定します。
この設定を通じて、この名前空間以下のAPIリクエスト・レスポンスログデータが対象の GS2-Log へ出力されるようになります。
GS2-Log にはリアルタイムでログが提供され、システムの監視や分析、デバッグなどに利用できます。
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
loggingNamespaceId | string | ✓ | ~ 1024文字 | ネームスペースGRN |
TransactionSetting
トランザクション設定
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
enableAutoRun | bool | ✓ | false | 発行したトランザクションをサーバーサイドで自動的に実行するか | |
distributorNamespaceId | string | ✓ | “grn:gs2:{region}:{ownerId}:distributor:default” | ~ 1024文字 | トランザクションの実行に使用する GS2-Distributor ネームスペース |
queueNamespaceId | string | ✓ | “grn:gs2:{region}:{ownerId}:queue:default” | ~ 1024文字 | トランザクションの実行に使用する GS2-JobQueue のネームスペース |