GS2-Matchmaking GS2-Deploy/CDK リファレンス

GS2-Deployのスタックを作成する際に使用するテンプレートのフォーマットと、CDKによる各種言語のテンプレート出力の実装例

エンティティ

Deloy処理で操作する対象リソース

Namespace

ネームスペース

ネームスペースは一つのプロジェクトで同じサービスを異なる用途で複数利用できるようにするための仕組みです。
GS2 の各サービスはネームスペース単位で管理されます。ネームスペースが異なれば、同じサービスでも完全に独立したデータ空間として扱われます。

そのため、各サービスの利用を開始するにあたってネームスペースを作成する必要があります。

有効化条件必須デフォルト値の制限説明
namestring
~ 128文字ネームスペース名
descriptionstring~ 1024文字説明文
transactionSettingTransactionSettingトランザクション設定
enableRatingbool
falseレーティング計算機能を使用するか
enableDisconnectDetection文字列列挙型
enum {
  “disable”,
  “enable”
}
“disable”~ 128文字マッチメイキング中プレイヤーの切断検知
定義説明
“disable”無効
“enable”有効
disconnectDetectionTimeoutSecondsint{enableDisconnectDetection} == “enable”
✓*
15 ~ 600マッチメイキング中にプレイヤーを切断と見なすまでの待機時間(秒)
※ enableDisconnectDetection が “enable” であれば 必須
createGatheringTriggerType文字列列挙型
enum {
  “none”,
  “gs2_realtime”,
  “gs2_script”
}
~ 128文字ギャザリング新規作成時のアクション
定義説明
“none”なし
“gs2_realtime”GS2-Realtime のルーム作成
“gs2_script”GS2-Script の実行
createGatheringTriggerRealtimeNamespaceIdstring{createGatheringTriggerType} == “gs2_realtime”
✓*
~ 1024文字ギャザリング作成時にルームを作成する GS2-Realtime のネームスペース
※ createGatheringTriggerType が “gs2_realtime” であれば 必須
createGatheringTriggerScriptIdstring{createGatheringTriggerType} == “gs2_script”
✓*
~ 1024文字ギャザリング作成時に実行される GS2-Script のスクリプト
※ createGatheringTriggerType が “gs2_script” であれば 必須
completeMatchmakingTriggerType文字列列挙型
enum {
  “none”,
  “gs2_realtime”,
  “gs2_script”
}
~ 128文字マッチメイキング完了時のアクション
定義説明
“none”なし
“gs2_realtime”GS2-Realtime のルーム作成
“gs2_script”GS2-Script の実行
completeMatchmakingTriggerRealtimeNamespaceIdstring{completeMatchmakingTriggerType} == “gs2_realtime”
✓*
~ 1024文字マッチメイキング完了時にルームを作成する GS2-Realtime のネームスペース
※ completeMatchmakingTriggerType が “gs2_realtime” であれば 必須
completeMatchmakingTriggerScriptIdstring{completeMatchmakingTriggerType} == “gs2_script”
✓*
~ 1024文字マッチメイキング完了時に実行される GS2-Script のスクリプト
※ completeMatchmakingTriggerType が “gs2_script” であれば 必須
enableCollaborateSeasonRating文字列列挙型
enum {
  “enable”,
  “disable”
}
“disable”~ 128文字GS2-SeasonRating との連携を有効にするか
定義説明
“enable”有効
“disable”無効
collaborateSeasonRatingNamespaceIdstring{enableCollaborateSeasonRating} == “enable”
✓*
~ 1024文字マッチメイキング完了時にセッションを作成する GS2-SeasonRating のネームスペース
※ enableCollaborateSeasonRating が “enable” であれば 必須
collaborateSeasonRatingTtlint{enableCollaborateSeasonRating} == “enable”
✓*
6060 ~ 7200GS2-SeasonRating の結果を受け付ける最大時間(秒)
※ enableCollaborateSeasonRating が “enable” であれば 必須
changeRatingScriptScriptSettingレーティング値が変化した時に実行するスクリプト
joinNotificationNotificationSettingギャザリングに新規プレイヤーが参加したときのプッシュ通知
leaveNotificationNotificationSettingギャザリングからプレイヤーが離脱したときのプッシュ通知
completeNotificationNotificationSettingマッチメイキングが完了したときのプッシュ通知
changeRatingNotificationNotificationSettingレーティングの値が変動したときのプッシュ通知
logSettingLogSettingログの出力設定

GetAttr

!GetAttrタグで取得可能なリソースの生成結果

説明
ItemNamespace作成したネームスペース

実装例

Type: GS2::Matchmaking::Namespace
Properties:
  Name: namespace-0001
  Description: null
  TransactionSetting: null
  EnableRating: true
  EnableDisconnectDetection: null
  DisconnectDetectionTimeoutSeconds: null
  CreateGatheringTriggerType: none
  CreateGatheringTriggerRealtimeNamespaceId: null
  CreateGatheringTriggerScriptId: null
  CompleteMatchmakingTriggerType: none
  CompleteMatchmakingTriggerRealtimeNamespaceId: null
  CompleteMatchmakingTriggerScriptId: null
  EnableCollaborateSeasonRating: disable
  CollaborateSeasonRatingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001
  CollaborateSeasonRatingTtl: 60
  ChangeRatingScript: null
  JoinNotification: null
  LeaveNotification: null
  CompleteNotification: null
  ChangeRatingNotification: null
  LogSetting: 
    LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/matchmaking"
    "github.com/openlyinc/pointy"
)

SampleStack := core.NewStack()
matchmaking.NewNamespace(
    &SampleStack,
    "namespace-0001",
    matchmaking.NamespaceCreateGatheringTriggerTypeNone,
    matchmaking.NamespaceCompleteMatchmakingTriggerTypeNone,
    matchmaking.NamespaceOptions{
        EnableRating: true,
        EnableCollaborateSeasonRating: matchmaking.NamespaceEnableCollaborateSeasonRatingDisable,
        CollaborateSeasonRatingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001"),
        CollaborateSeasonRatingTtl: pointy.Int32(60),
        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\Matchmaking\Model\Namespace_(
            stack: $this,
            name: "namespace-0001",
            createGatheringTriggerType: \Gs2Cdk\Matchmaking\Model\Enums\NamespaceCreateGatheringTriggerType::NONE,
            completeMatchmakingTriggerType: \Gs2Cdk\Matchmaking\Model\Enums\NamespaceCompleteMatchmakingTriggerType::NONE,
            options: new \Gs2Cdk\Matchmaking\Model\Options\NamespaceOptions(
                enableRating: True,
                enableCollaborateSeasonRating: Gs2Cdk\Matchmaking\Model\Enums\NamespaceEnableCollaborateSeasonRating::DISABLE,
                collaborateSeasonRatingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001",
                collaborateSeasonRatingTtl: 60,
                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.matchmaking.model.Namespace(
                this,
                "namespace-0001",
                io.gs2.cdk.matchmaking.model.enums.NamespaceCreateGatheringTriggerType.NONE,
                io.gs2.cdk.matchmaking.model.enums.NamespaceCompleteMatchmakingTriggerType.NONE,
                new io.gs2.cdk.matchmaking.model.options.NamespaceOptions()
                        .withEnableRating(true)
                        .withEnableCollaborateSeasonRating(io.gs2.cdk.matchmaking.model.enums.NamespaceEnableCollaborateSeasonRating.DISABLE)
                        .withCollaborateSeasonRatingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001")
                        .withCollaborateSeasonRatingTtl(60)
                        .withLogSetting(new io.gs2.cdk.core.model.LogSetting(
                            "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                        ))
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Matchmaking.Model.Namespace(
            stack: this,
            name: "namespace-0001",
            createGatheringTriggerType: Gs2Cdk.Gs2Matchmaking.Model.Enums.NamespaceCreateGatheringTriggerType.None,
            completeMatchmakingTriggerType: Gs2Cdk.Gs2Matchmaking.Model.Enums.NamespaceCompleteMatchmakingTriggerType.None,
            options: new Gs2Cdk.Gs2Matchmaking.Model.Options.NamespaceOptions
            {
                enableRating = true,
                enableCollaborateSeasonRating = Gs2Cdk.Gs2Matchmaking.Model.Enums.NamespaceEnableCollaborateSeasonRating.Disable,
                collaborateSeasonRatingNamespaceId = "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001",
                collaborateSeasonRatingTtl = 60,
                logSetting = new Gs2Cdk.Core.Model.LogSetting(
                    loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            }
        );
    }
}

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

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new matchmaking.model.Namespace(
            this,
            "namespace-0001",
            matchmaking.model.NamespaceCreateGatheringTriggerType.NONE,
            matchmaking.model.NamespaceCompleteMatchmakingTriggerType.NONE,
            {
                enableRating: true,
                enableCollaborateSeasonRating: matchmaking.model.NamespaceEnableCollaborateSeasonRating.DISABLE,
                collaborateSeasonRatingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001",
                collaborateSeasonRatingTtl: 60,
                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, matchmaking

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        matchmaking.Namespace(
            stack=self,
            name='namespace-0001',
            create_gathering_trigger_type=matchmaking.NamespaceCreateGatheringTriggerType.NONE,
            complete_matchmaking_trigger_type=matchmaking.NamespaceCompleteMatchmakingTriggerType.NONE,
            options=matchmaking.NamespaceOptions(
                enable_rating=True,
                enable_collaborate_season_rating=matchmaking.NamespaceEnableCollaborateSeasonRating.DISABLE,
                collaborate_season_rating_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001',
                collaborate_season_rating_ttl=60,
                log_setting=core.LogSetting(
                    logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
                ),
            ),
        )

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

ScriptSetting

スクリプト設定

GS2 ではマイクロサービスのイベントに関連づけて、カスタムスクリプトを実行することができます。
このモデルは、スクリプトの実行をトリガーするための設定を保持します。

スクリプトの実行方式は大きく2種類あり、それは「同期実行」と「非同期実行」です。
同期実行は、スクリプトの実行が完了するまで処理がブロックされます。
代わりに、スクリプトの実行結果を使ってAPIの実行を止めたり、APIの結果を改ざんすることができます。

一方、非同期実行ではスクリプトの完了を待つために処理がブロックされることはありません。
ただし、スクリプトの実行結果を利用して API の実行を停止したり、API の応答内容を変更することはできません。
非同期実行は API の応答フローに影響を与えないため、原則として非同期実行を推奨します。

非同期実行には実行方式が2種類あり、GS2-Script と Amazon EventBridge があります。
Amazon EventBridge を使用することで、Lua 以外の言語で処理を記述することができます。

有効化条件必須デフォルト値の制限説明
triggerScriptIdstring~ 1024文字同期実行スクリプトの GS2-Script のスクリプトGRN
「grn:gs2:」ではじまる GRN 形式のIDで指定する必要があります。
doneTriggerTargetType文字列列挙型
enum {
  “none”,
  “gs2_script”,
  “aws”
}
“none”~ 128文字非同期スクリプトの実行方法
非同期実行で使用するスクリプトの種類を指定します。
「非同期実行のスクリプトを使用しない(none)」「GS2-Scriptを使用する(gs2_script)」「Amazon EventBridgeを使用する(aws)」が選択できます。
定義説明
“none”なし
“gs2_script”GS2-Script
“aws”Amazon EventBridge
doneTriggerScriptIdstring{doneTriggerTargetType} == “gs2_script”~ 1024文字非同期実行スクリプトの GS2-Script のスクリプトGRN
「grn:gs2:」ではじまる GRN 形式のIDで指定する必要があります。

※ doneTriggerTargetType が “gs2_script” であれば有効
doneTriggerQueueNamespaceIdstring{doneTriggerTargetType} == “gs2_script”~ 1024文字非同期実行スクリプトを実行する GS2-JobQueue ネームスペースGRN
非同期実行スクリプトを直接実行するのではなく、GS2-JobQueue を経由する場合は GS2-JobQueue のネームスペースGRN を指定します。
GS2-JobQueue を利用する理由は多くはありませんので、特に理由がなければ指定する必要はありません。

※ doneTriggerTargetType が “gs2_script” であれば有効

NotificationSetting

プッシュ通知に関する設定

GS2 のマイクロサービス内で何らかのイベントが発生した際に、プッシュ通知を送信するための設定です。
ここでいうプッシュ通知は GS2-Gateway の提供する WebSocket インターフェースを経由した処理であり、スマートフォンのプッシュ通知とは性質が異なります。
たとえば、マッチメイキングが完了した時やフレンドリクエストが届いた時など、ゲームクライアントの操作とは関係なく状態が変化した際に GS2-Gateway を経由してプッシュ通知をすることで、ゲームクライアントは状態の変化を検知することができます。

GS2-Gateway のプッシュ通知は通知先のデバイスがオフラインだった時に追加の処理としてモバイルプッシュ通知を送信できます。
モバイルプッシュ通知をうまく利用すれば、マッチメイキング中にゲームを終了しても、モバイルプッシュ通知を使用してプレイヤーに通知し、ゲームに戻ってくるフローを実現できる可能性があります。

有効化条件必須デフォルト値の制限説明
gatewayNamespaceIdstring
“grn:gs2:{region}:{ownerId}:gateway:default”~ 1024文字プッシュ通知に使用する GS2-Gateway のネームスペース
「grn:gs2:」から始まる GRN 形式で GS2-Gateway のネームスペースIDを指定します。
enableTransferMobileNotificationbool?falseモバイルプッシュ通知へ転送するか
この通知を送信しようとした時、通知先のデバイスがオフラインだった場合、モバイルプッシュ通知へ転送するかどうかを指定します。
soundstring{enableTransferMobileNotification} == true~ 1024文字モバイルプッシュ通知で使用するサウンドファイル名
ここで指定したサウンドファイル名は、モバイルプッシュ通知を送信する際に使用され、特別なサウンドで通知を出すことができます。

※ enableTransferMobileNotification が true であれば有効
enable文字列列挙型
enum {
  “Enabled”,
  “Disabled”
}
“Enabled”~ 128文字プッシュ通知を有効にするか
定義説明
“Enabled”有効
“Disabled”無効

LogSetting

ログの書き出し設定

ログデータの書き出し設定を管理します。この型は、ログデータを書き出すために使用される GS2-Log 名前空間の識別子(Namespace ID)を保持します。
ログ名前空間ID(loggingNamespaceId)には、ログデータを収集し保存する GS2-Log の名前空間を、GRNの形式で指定します。
この設定をすることで、設定された名前空間内で発生したAPIリクエスト・レスポンスのログデータが、対象の GS2-Log 名前空間側へ出力されるようになります。
GS2-Log ではリアルタイムでログが提供され、システムの監視や分析、デバッグなどに利用できます。

有効化条件必須デフォルト値の制限説明
loggingNamespaceIdstring
~ 1024文字ログを出力する GS2-Log のネームスペースGRN

TransactionSetting

トランザクション設定

トランザクション設定は、トランザクションの実行方法・整合性・非同期処理・競合回避の仕組みを制御する設定です。
自動実行(AutoRun)、アトミック実行(AtomicCommit)、非同期実行(Distributor)、スクリプト結果の一括適用、JobQueue による入手アクションの非同期化などを組み合わせ、ゲームロジックに応じた堅牢なトランザクション管理を可能にします。

有効化条件必須デフォルト値の制限説明
enableAutoRunbool
false発行したトランザクションをサーバーサイドで自動的に実行するか
enableAtomicCommitbool{enableAutoRun} == true
✓*
falseトランザクションの実行をアトミックにコミットするか
※ enableAutoRun が true であれば必須
transactionUseDistributorbool{enableAtomicCommit} == true
✓*
falseトランザクションを非同期処理で実行する
※ enableAtomicCommit が true であれば必須
commitScriptResultInUseDistributorbool{transactionUseDistributor} == true
✓*
falseスクリプトの結果コミット処理を非同期処理で実行するか
※ transactionUseDistributor が true であれば必須
acquireActionUseJobQueuebool{enableAtomicCommit} == true
✓*
false入手アクションを実行する際に GS2-JobQueue を使用するか
※ enableAtomicCommit が true であれば必須
distributorNamespaceIdstring
“grn:gs2:{region}:{ownerId}:distributor:default”~ 1024文字トランザクションの実行に使用する GS2-Distributor ネームスペース
queueNamespaceIdstring
“grn:gs2:{region}:{ownerId}:queue:default”~ 1024文字トランザクションの実行に使用する GS2-JobQueue のネームスペース

CurrentModelMaster

現在有効なマスターデータ

GS2ではマスターデータの管理にJSON形式のファイルを使用します。
ファイルをアップロードすることで、実際にサーバーに設定を反映することができます。

JSONファイルを作成する方法として、マネージメントコンソール内にマスターデータエディタを提供しています。
また、よりゲームの運営に相応しいツールを作成し、適切なフォーマットのJSONファイルを書き出すことでもサービスを利用可能です。

有効化条件必須デフォルト値の制限説明
namespaceNamestring
~ 128文字ネームスペース名
mode文字列列挙型
enum {
  “direct”,
  “preUpload”
}
“direct”~ 128文字更新モード
定義説明
“direct”設定を直接更新
“preUpload”設定をアップロードしてから更新
settingsstring{mode} == “direct”
✓*
~ 5242880 バイト (5MB)マスターデータ
※ mode が “direct” であれば 必須
uploadTokenstring{mode} == “preUpload”
✓*
~ 1024文字プレアップロードで取得したトークン
※ mode が “preUpload” であれば 必須

GetAttr

!GetAttrタグで取得可能なリソースの生成結果

説明
ItemCurrentModelMaster更新した現在有効なレーティングマスター

実装例

Type: GS2::Matchmaking::CurrentModelMaster
Properties:
  NamespaceName: namespace-0001
  Mode: direct
  Settings: {
    "version": "2020-06-24",
    "ratingModels": [
      {
        "name": "rating-0001",
        "initialValue": 1500,
        "volatility": 100,
        "metadata": "RATING_0001"
      },
      {
        "name": "rating-0002",
        "initialValue": 1500,
        "volatility": 150,
        "metadata": "RATING_0002"
      }
    ],
    "seasonModels": [
      {
        "name": "season-0001",
        "maximumParticipants": 50,
        "challengePeriodEventId": "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0001"
      },
      {
        "name": "season-0002",
        "maximumParticipants": 100,
        "challengePeriodEventId": "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0002"
      }
    ]
  }
  UploadToken: null
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/matchmaking"
    "github.com/openlyinc/pointy"
)

SampleStack := core.NewStack()
matchmaking.NewNamespace(
    &SampleStack,
    "namespace-0001",
    matchmaking.NamespaceCreateGatheringTriggerTypeNone,
    matchmaking.NamespaceCompleteMatchmakingTriggerTypeNone,
    matchmaking.NamespaceOptions{},
).MasterData(
    []matchmaking.RatingModel{
        matchmaking.NewRatingModel(
            "rating-0001",
            1500,
            100,
            matchmaking.RatingModelOptions{
                Metadata: pointy.String("RATING_0001"),
            },
        ),
        matchmaking.NewRatingModel(
            "rating-0002",
            1500,
            150,
            matchmaking.RatingModelOptions{
                Metadata: pointy.String("RATING_0002"),
            },
        ),
    },
    []matchmaking.SeasonModel{
        matchmaking.NewSeasonModel(
            "season-0001",
            50,
            "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0001",
            matchmaking.SeasonModelOptions{
            },
        ),
        matchmaking.NewSeasonModel(
            "season-0002",
            100,
            "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0002",
            matchmaking.SeasonModelOptions{
            },
        ),
    },
)

println(SampleStack.Yaml())  // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        (new \Gs2Cdk\Matchmaking\Model\Namespace_(
            stack: $this,
            name: "namespace-0001",
            createGatheringTriggerType: \Gs2Cdk\Matchmaking\Model\Enums\NamespaceCreateGatheringTriggerType::NONE,
            completeMatchmakingTriggerType: \Gs2Cdk\Matchmaking\Model\Enums\NamespaceCompleteMatchmakingTriggerType::NONE
        ))->masterData(
            [
                new \Gs2Cdk\Matchmaking\Model\RatingModel(
                    name:"rating-0001",
                    initialValue:1500,
                    volatility:100,
                    options: new \Gs2Cdk\Matchmaking\Model\Options\RatingModelOptions(
                        metadata:"RATING_0001"
                    )
                ),
                new \Gs2Cdk\Matchmaking\Model\RatingModel(
                    name:"rating-0002",
                    initialValue:1500,
                    volatility:150,
                    options: new \Gs2Cdk\Matchmaking\Model\Options\RatingModelOptions(
                        metadata:"RATING_0002"
                    )
                )
            ],
            [
                new \Gs2Cdk\Matchmaking\Model\SeasonModel(
                    name:"season-0001",
                    maximumParticipants:50,
                    challengePeriodEventId:"grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0001"
                ),
                new \Gs2Cdk\Matchmaking\Model\SeasonModel(
                    name:"season-0002",
                    maximumParticipants:100,
                    challengePeriodEventId:"grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0002"
                )
            ]
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.matchmaking.model.Namespace(
            this,
            "namespace-0001",
            io.gs2.cdk.matchmaking.model.enums.NamespaceCreateGatheringTriggerType.NONE,
            io.gs2.cdk.matchmaking.model.enums.NamespaceCompleteMatchmakingTriggerType.NONE
        ).masterData(
            Arrays.asList(
                new io.gs2.cdk.matchmaking.model.RatingModel(
                    "rating-0001",
                    1500,
                    100,
                    new io.gs2.cdk.matchmaking.model.options.RatingModelOptions()
                        .withMetadata("RATING_0001")
                ),
                new io.gs2.cdk.matchmaking.model.RatingModel(
                    "rating-0002",
                    1500,
                    150,
                    new io.gs2.cdk.matchmaking.model.options.RatingModelOptions()
                        .withMetadata("RATING_0002")
                )
            ),
            Arrays.asList(
                new io.gs2.cdk.matchmaking.model.SeasonModel(
                    "season-0001",
                    50,
                    "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0001"
                ),
                new io.gs2.cdk.matchmaking.model.SeasonModel(
                    "season-0002",
                    100,
                    "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0002"
                )
            )
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Matchmaking.Model.Namespace(
            stack: this,
            name: "namespace-0001",
            createGatheringTriggerType: Gs2Cdk.Gs2Matchmaking.Model.Enums.NamespaceCreateGatheringTriggerType.None,
            completeMatchmakingTriggerType: Gs2Cdk.Gs2Matchmaking.Model.Enums.NamespaceCompleteMatchmakingTriggerType.None
        ).MasterData(
            new Gs2Cdk.Gs2Matchmaking.Model.RatingModel[] {
                new Gs2Cdk.Gs2Matchmaking.Model.RatingModel(
                    name: "rating-0001",
                    initialValue: 1500,
                    volatility: 100,
                    options: new Gs2Cdk.Gs2Matchmaking.Model.Options.RatingModelOptions
                    {
                        metadata = "RATING_0001"
                    }
                ),
                new Gs2Cdk.Gs2Matchmaking.Model.RatingModel(
                    name: "rating-0002",
                    initialValue: 1500,
                    volatility: 150,
                    options: new Gs2Cdk.Gs2Matchmaking.Model.Options.RatingModelOptions
                    {
                        metadata = "RATING_0002"
                    }
                )
            },
            new Gs2Cdk.Gs2Matchmaking.Model.SeasonModel[] {
                new Gs2Cdk.Gs2Matchmaking.Model.SeasonModel(
                    name: "season-0001",
                    maximumParticipants: 50,
                    challengePeriodEventId: "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0001"
                ),
                new Gs2Cdk.Gs2Matchmaking.Model.SeasonModel(
                    name: "season-0002",
                    maximumParticipants: 100,
                    challengePeriodEventId: "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0002"
                )
            }
        );
    }
}

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

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new matchmaking.model.Namespace(
            this,
            "namespace-0001",
            matchmaking.model.NamespaceCreateGatheringTriggerType.NONE,
            matchmaking.model.NamespaceCompleteMatchmakingTriggerType.NONE
        ).masterData(
            [
                new matchmaking.model.RatingModel(
                    "rating-0001",
                    1500,
                    100,
                    {
                        metadata: "RATING_0001"
                    }
                ),
                new matchmaking.model.RatingModel(
                    "rating-0002",
                    1500,
                    150,
                    {
                        metadata: "RATING_0002"
                    }
                )
            ],
            [
                new matchmaking.model.SeasonModel(
                    "season-0001",
                    50,
                    "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0001"
                ),
                new matchmaking.model.SeasonModel(
                    "season-0002",
                    100,
                    "grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0002"
                )
            ]
        );
    }
}

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

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        matchmaking.Namespace(
            stack=self,
            name="namespace-0001",
            create_gathering_trigger_type=matchmaking.NamespaceCreateGatheringTriggerType.NONE,
            complete_matchmaking_trigger_type=matchmaking.NamespaceCompleteMatchmakingTriggerType.NONE,
            options=matchmaking.NamespaceOptions(
                enable_rating=True,
                enable_collaborate_season_rating=matchmaking.NamespaceEnableCollaborateSeasonRating.DISABLE,
                collaborate_season_rating_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:experience:namespace-0001',
                collaborate_season_rating_ttl=60,
                log_setting=core.LogSetting(
                    logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
                ),
            ),
        ).master_data(
            rating_models=[
                matchmaking.RatingModel(
                    name='rating-0001',
                    initial_value=1500,
                    volatility=100,
                    options=matchmaking.RatingModelOptions(
                        metadata = 'RATING_0001'
                    ),
                ),
                matchmaking.RatingModel(
                    name='rating-0002',
                    initial_value=1500,
                    volatility=150,
                    options=matchmaking.RatingModelOptions(
                        metadata = 'RATING_0002'
                    ),
                ),
            ],
            season_models=[
                matchmaking.SeasonModel(
                    name='season-0001',
                    maximum_participants=50,
                    challenge_period_event_id='grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0001'
                ),
                matchmaking.SeasonModel(
                    name='season-0002',
                    maximum_participants=100,
                    challenge_period_event_id='grn:gs2:ap-northeast-1:YourOwnerId:schedule:namespace-0001:event:event-0002'
                ),
            ],
        )

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

RatingModel

レーティングモデル

GS2 ではレーティングアルゴリズムとして Glicko-2 を採用しています。
Glicko-2 には複数のパラメータがありますが、GS2-Matchmaking ではそれらを総合的に表す ボラティリティ という1つのパラメータに集約しています。
ボラティリティ は変化の大きさを表すパラメータで、値が大きいほどレーティングの値の変動量が大きくなります。

有効化条件必須デフォルト値の制限説明
ratingModelIdstring
~ 1024文字レーティングモデルGRN
namestring
~ 128文字レーティングモデル名
metadatastring~ 128文字メタデータ
initialValueint
1500100 ~ 10000レート値の初期値
volatilityint
1001 ~ 20000レート値の変動の大きさ

SeasonModel

シーズンモデル

有効化条件必須デフォルト値の制限説明
seasonModelIdstring
~ 1024文字レーティングモデルGRN
namestring
~ 128文字シーズンモデル名
metadatastring~ 128文字メタデータ
maximumParticipantsint
2 ~ 1000最大参加人数
experienceModelIdstring~ 1024文字ティアーを保持する GS2-Experience の経験値モデル
challengePeriodEventIdstring
~ 1024文字シーズンの期間を設定した GS2-Schedule イベントGRN