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

エンティティ

Namespace

ネームスペース

ネームスペースは一つのプロジェクトで同じサービスを異なる用途で複数利用できるようにするための仕組みです。 GS2 のサービスは基本的にネームスペースというレイヤーがあり、ネームスペースが異なれば同じサービスでもまったく別のデータ空間として取り扱われます。

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

必須デフォルト値の制限説明
namestring~ 128文字ネームスペース名
descriptionstring~ 1024文字説明文
transactionSettingTransactionSettingトランザクション設定
logSettingLogSettingログの出力設定

GetAttr

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

実装例

Type: GS2::Ranking2::Namespace
Properties:
  Name: namespace1
  Description: null
  TransactionSetting: null
  LogSetting: 
    LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace1
from gs2_cdk import Stack, core, ranking2

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        ranking2.Namespace(
            stack=self,
            name="namespace-0001",
            options=ranking2.NamespaceOptions(
                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\Ranking2\Model\Namespace_(
            stack: $this,
            name: "namespace-0001",
            options: new \Gs2Cdk\Ranking2\Model\Options\NamespaceOptions(
                logSetting: new \Gs2Cdk\Core\Model\LogSetting(
                    loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            )
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.ranking2.model.Namespace(
            this,
            "namespace-0001",
            new io.gs2.cdk.ranking2.model.options.NamespaceOptions() {
                {
                    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 ranking2 from "@/gs2cdk/ranking2";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new ranking2.model.Namespace(
            this,
            "namespace-0001",
            {
                logSetting: new core.LogSetting(
                    "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            }
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Ranking2.Model.Namespace(
            this,
            "namespace-0001",
            new Gs2Cdk.Gs2Ranking2.Model.Options.NamespaceOptions {
                logSetting = new Gs2Cdk.Core.Model.LogSetting(
                    LoggingNamespaceId = "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            }
        );
    }
}

Debug.Log(new SampleStack().Yaml());  // Generate Template

CurrentRankingMaster

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

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

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

JSONファイルの形式についてはドキュメントを参照ください。

必須デフォルト値の制限説明
namespaceNamestring~ 128文字ネームスペース名
settingsstring~ 5242880文字マスターデータ

GetAttr

説明
ItemCurrentRankingMaster更新した現在有効なランキング設定

実装例

Type: GS2::Ranking2::CurrentRankingMaster
Properties:
  NamespaceName: namespace1
  Settings: {
    "version": "2024-05-30",
    "globalRankingModels": [
      {
        "name": "ranking-0001",
        "orderDirection": "asc"
      },
      {
        "name": "ranking-0002",
        "orderDirection": "desc"
      }
    ],
    "clusterRankingModels": [
      {
        "name": "ranking-0001",
        "clusterType": "Raw",
        "orderDirection": "asc"
      },
      {
        "name": "ranking-0002",
        "clusterType": "Gs2Guild::Guild",
        "orderDirection": "desc"
      }
    ],
    "subscribeRankingModels": [
      {
        "name": "ranking-0001",
        "orderDirection": "asc"
      },
      {
        "name": "ranking-0002",
        "orderDirection": "desc"
      }
    ]
  }
from gs2_cdk import Stack, core, ranking2

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        ranking2.Namespace(
            stack=self,
            # 省略
        ).master_data(
            global_ranking_models=[
                ranking2.GlobalRankingModel(
                    name='ranking-0001',
                    order_direction='asc',
                ),
                ranking2.GlobalRankingModel(
                    name='ranking-0002',
                    order_direction='desc',
                ),
            ],
            cluster_ranking_models=[
                ranking2.ClusterRankingModel(
                    name='ranking-0001',
                    cluster_type='Raw',
                    order_direction='asc',
                ),
                ranking2.ClusterRankingModel(
                    name='ranking-0002',
                    cluster_type='Gs2Guild::Guild',
                    order_direction='desc',
                ),
            ],
            subscribe_ranking_models=[
                ranking2.SubscribeRankingModel(
                    name='ranking-0001',
                    order_direction='asc',
                ),
                ranking2.SubscribeRankingModel(
                    name='ranking-0002',
                    order_direction='desc',
                ),
            ],
        )

print(SampleStack().yaml())  # Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        (new \Gs2Cdk\Ranking2\Model\Namespace_(
            stack: $this,
            // 省略
        ))->masterData(
            [
                new \Gs2Cdk\Ranking2\Model\GlobalRankingModel(
                    name:"ranking-0001",
                    orderDirection: \Gs2Cdk\Ranking2\Model\Enums\GlobalRankingModelOrderDirection::ASC
                ),
                new \Gs2Cdk\Ranking2\Model\GlobalRankingModel(
                    name:"ranking-0002",
                    orderDirection: \Gs2Cdk\Ranking2\Model\Enums\GlobalRankingModelOrderDirection::DESC
                )
            ],
            [
                new \Gs2Cdk\Ranking2\Model\ClusterRankingModel(
                    name:"ranking-0001",
                    clusterType: \Gs2Cdk\Ranking2\Model\Enums\ClusterRankingModelClusterType::RAW,
                    orderDirection: \Gs2Cdk\Ranking2\Model\Enums\ClusterRankingModelOrderDirection::ASC
                ),
                new \Gs2Cdk\Ranking2\Model\ClusterRankingModel(
                    name:"ranking-0002",
                    clusterType: \Gs2Cdk\Ranking2\Model\Enums\ClusterRankingModelClusterType::GS2_GUILD::_GUILD,
                    orderDirection: \Gs2Cdk\Ranking2\Model\Enums\ClusterRankingModelOrderDirection::DESC
                )
            ],
            [
                new \Gs2Cdk\Ranking2\Model\SubscribeRankingModel(
                    name:"ranking-0001",
                    orderDirection: \Gs2Cdk\Ranking2\Model\Enums\SubscribeRankingModelOrderDirection::ASC
                ),
                new \Gs2Cdk\Ranking2\Model\SubscribeRankingModel(
                    name:"ranking-0002",
                    orderDirection: \Gs2Cdk\Ranking2\Model\Enums\SubscribeRankingModelOrderDirection::DESC
                )
            ]
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.ranking2.model.Namespace(
            this,
            // 省略
        ).masterData(
            Arrays.asList(
                new io.gs2.cdk.ranking2.model.GlobalRankingModel(
                    "ranking-0001",
                    Asc
                ),
                new io.gs2.cdk.ranking2.model.GlobalRankingModel(
                    "ranking-0002",
                    Desc
                )
            ),
            Arrays.asList(
                new io.gs2.cdk.ranking2.model.ClusterRankingModel(
                    "ranking-0001",
                    Raw,
                    Asc
                ),
                new io.gs2.cdk.ranking2.model.ClusterRankingModel(
                    "ranking-0002",
                    Gs2Guild::Guild,
                    Desc
                )
            ),
            Arrays.asList(
                new io.gs2.cdk.ranking2.model.SubscribeRankingModel(
                    "ranking-0001",
                    Asc
                ),
                new io.gs2.cdk.ranking2.model.SubscribeRankingModel(
                    "ranking-0002",
                    Desc
                )
            )
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
import core from "@/gs2cdk/core";
import ranking2 from "@/gs2cdk/ranking2";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new ranking2.model.Namespace(
            this,
            // 省略
        ).masterData(
            [
                new ranking2.model.GlobalRankingModel(
                    "ranking-0001",
                    ranking2.model.GlobalRankingModelOrderDirection.ASC
                ),
                new ranking2.model.GlobalRankingModel(
                    "ranking-0002",
                    ranking2.model.GlobalRankingModelOrderDirection.DESC
                )
            ],
            [
                new ranking2.model.ClusterRankingModel(
                    "ranking-0001",
                    ranking2.model.ClusterRankingModelClusterType.RAW,
                    ranking2.model.ClusterRankingModelOrderDirection.ASC
                ),
                new ranking2.model.ClusterRankingModel(
                    "ranking-0002",
                    ranking2.model.ClusterRankingModelClusterType.GS2_GUILD::_GUILD,
                    ranking2.model.ClusterRankingModelOrderDirection.DESC
                )
            ],
            [
                new ranking2.model.SubscribeRankingModel(
                    "ranking-0001",
                    ranking2.model.SubscribeRankingModelOrderDirection.ASC
                ),
                new ranking2.model.SubscribeRankingModel(
                    "ranking-0002",
                    ranking2.model.SubscribeRankingModelOrderDirection.DESC
                )
            ]
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Ranking2.Model.Namespace(
            this,
            // 省略
        ).MasterData(
            new [] {
                new Gs2Cdk.Gs2Ranking2.Model.GlobalRankingModel(
                    "ranking-0001",
                    Gs2Cdk.Gs2Ranking2.Model.Enums.GlobalRankingModelOrderDirection.Asc
                ),
                new Gs2Cdk.Gs2Ranking2.Model.GlobalRankingModel(
                    "ranking-0002",
                    Gs2Cdk.Gs2Ranking2.Model.Enums.GlobalRankingModelOrderDirection.Desc
                )
            },
            new [] {
                new Gs2Cdk.Gs2Ranking2.Model.ClusterRankingModel(
                    "ranking-0001",
                    Gs2Cdk.Gs2Ranking2.Model.Enums.ClusterRankingModelClusterType.Raw,
                    Gs2Cdk.Gs2Ranking2.Model.Enums.ClusterRankingModelOrderDirection.Asc
                ),
                new Gs2Cdk.Gs2Ranking2.Model.ClusterRankingModel(
                    "ranking-0002",
                    Gs2Cdk.Gs2Ranking2.Model.Enums.ClusterRankingModelClusterType.Gs2Guild::Guild,
                    Gs2Cdk.Gs2Ranking2.Model.Enums.ClusterRankingModelOrderDirection.Desc
                )
            },
            new [] {
                new Gs2Cdk.Gs2Ranking2.Model.SubscribeRankingModel(
                    "ranking-0001",
                    Gs2Cdk.Gs2Ranking2.Model.Enums.SubscribeRankingModelOrderDirection.Asc
                ),
                new Gs2Cdk.Gs2Ranking2.Model.SubscribeRankingModel(
                    "ranking-0002",
                    Gs2Cdk.Gs2Ranking2.Model.Enums.SubscribeRankingModelOrderDirection.Desc
                )
            }
        );
    }
}

Debug.Log(new SampleStack().Yaml());  // Generate Template

SubscribeUser

購読情報

必須デフォルト値の制限説明
rankingNamestring~ 128文字ランキング名
userIdstring~ 128文字ユーザーID
targetUserIdstring~ 128文字購読対象ユーザID

RankingReward

ランキング報酬モデル

スコアの登録期間が設定されたランキングで、登録期間外で参照期間内の時に受け取れる報酬を設定します。 繰り返し設定が有効な場合、直近に期間を終えたランキングが報酬の受け取り対象となります。

必須デフォルト値の制限説明
thresholdRankint1 ~ 1001順位閾値
metadatastring~ 1024文字メタデータ
acquireActionsList<AcquireAction>[]~ 100 itemsランキング報酬リスト

TransactionSetting

トランザクション設定

必須デフォルト値の制限説明
enableAutoRunbooltrue発行したトランザクションをサーバーサイドで自動的に実行するか
distributorNamespaceIdstring“grn:gs2:{region}:{ownerId}:distributor:default”~ 1024文字トランザクションの実行に使用する GS2-Distributor ネームスペース
queueNamespaceIdstring“grn:gs2:{region}:{ownerId}:queue:default”~ 1024文字トランザクションの実行に使用する GS2-JobQueue のネームスペース

LogSetting

ログの書き出し設定

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

必須デフォルト値の制限説明
loggingNamespaceIdstring~ 1024文字ネームスペースGRN

GitHubCheckoutSetting

GitHubからマスターデータをチェックアウトする設定

必須デフォルト値の制限説明
apiKeyIdstring~ 1024文字GitHub のAPIキーGRN
repositoryNamestring~ 1024文字リポジトリ名
sourcePathstring~ 1024文字ソースコードのファイルパス
referenceTypeenum [
“commit_hash”,
“branch”,
“tag”
]
~ 128文字コードの取得元
commitHashstring{referenceType} == “commit_hash”~ 1024文字コミットハッシュ
branchNamestring{referenceType} == “branch”~ 1024文字ブランチ名
tagNamestring{referenceType} == “tag”~ 1024文字タグ名

AcquireAction

入手アクション

必須デフォルト値の制限説明
actionenum [
"Gs2AdReward:AcquirePointByUserId",
"Gs2Dictionary:AddEntriesByUserId",
"Gs2Enchant:ReDrawBalanceParameterStatusByUserId",
"Gs2Enchant:SetBalanceParameterStatusByUserId",
"Gs2Enchant:ReDrawRarityParameterStatusByUserId",
"Gs2Enchant:AddRarityParameterStatusByUserId",
"Gs2Enchant:SetRarityParameterStatusByUserId",
"Gs2Enhance:DirectEnhanceByUserId",
"Gs2Enhance:UnleashByUserId",
"Gs2Enhance:CreateProgressByUserId",
"Gs2Exchange:ExchangeByUserId",
"Gs2Exchange:IncrementalExchangeByUserId",
"Gs2Exchange:CreateAwaitByUserId",
"Gs2Exchange:SkipByUserId",
"Gs2Experience:AddExperienceByUserId",
"Gs2Experience:SetExperienceByUserId",
"Gs2Experience:AddRankCapByUserId",
"Gs2Experience:SetRankCapByUserId",
"Gs2Experience:MultiplyAcquireActionsByUserId",
"Gs2Formation:AddMoldCapacityByUserId",
"Gs2Formation:SetMoldCapacityByUserId",
"Gs2Formation:AcquireActionsToFormProperties",
"Gs2Formation:SetFormByUserId",
"Gs2Formation:AcquireActionsToPropertyFormProperties",
"Gs2Friend:UpdateProfileByUserId",
"Gs2Grade:AddGradeByUserId",
"Gs2Grade:ApplyRankCapByUserId",
"Gs2Grade:MultiplyAcquireActionsByUserId",
"Gs2Guild:IncreaseMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Guild:SetMaximumCurrentMaximumMemberCountByGuildName",
"Gs2Idle:IncreaseMaximumIdleMinutesByUserId",
"Gs2Idle:SetMaximumIdleMinutesByUserId",
"Gs2Idle:ReceiveByUserId",
"Gs2Inbox:SendMessageByUserId",
"Gs2Inventory:AddCapacityByUserId",
"Gs2Inventory:SetCapacityByUserId",
"Gs2Inventory:AcquireItemSetByUserId",
"Gs2Inventory:AcquireItemSetWithGradeByUserId",
"Gs2Inventory:AddReferenceOfByUserId",
"Gs2Inventory:DeleteReferenceOfByUserId",
"Gs2Inventory:AcquireSimpleItemsByUserId",
"Gs2Inventory:SetSimpleItemsByUserId",
"Gs2Inventory:AcquireBigItemByUserId",
"Gs2Inventory:SetBigItemByUserId",
"Gs2JobQueue:PushByUserId",
"Gs2Limit:CountDownByUserId",
"Gs2Limit:DeleteCounterByUserId",
"Gs2LoginReward:DeleteReceiveStatusByUserId",
"Gs2LoginReward:UnmarkReceivedByUserId",
"Gs2Lottery:DrawByUserId",
"Gs2Lottery:ResetBoxByUserId",
"Gs2Mission:RevertReceiveByUserId",
"Gs2Mission:IncreaseCounterByUserId",
"Gs2Mission:SetCounterByUserId",
"Gs2Money:DepositByUserId",
"Gs2Money:RevertRecordReceipt",
"Gs2Money2:DepositByUserId",
"Gs2Quest:CreateProgressByUserId",
"Gs2Schedule:TriggerByUserId",
"Gs2SerialKey:RevertUseByUserId",
"Gs2Showcase:DecrementPurchaseCountByUserId",
"Gs2Showcase:ForceReDrawByUserId",
"Gs2SkillTree:MarkReleaseByUserId",
"Gs2Stamina:RecoverStaminaByUserId",
"Gs2Stamina:RaiseMaxValueByUserId",
"Gs2Stamina:SetMaxValueByUserId",
"Gs2Stamina:SetRecoverIntervalByUserId",
"Gs2Stamina:SetRecoverValueByUserId",
"Gs2StateMachine:StartStateMachineByUserId",
]
~ 128文字入手アクションで実行するアクションの種類
requeststring~ 1048576文字リクエストのJSON

Config

コンフィグ設定

トランザクションの変数に適用する設定値

必須デフォルト値の制限説明
keystring~ 64文字名前
valuestring~ 51200文字