GS2-Limit
GS2-SDK for Game Engine のリファレンス
ゲームエンジン向けSDK
モデル
EzCounter
回数制限の現在の値
型 | 説明 | |
---|---|---|
counterId | string | カウンターGRN |
limitName | string | 回数制限モデルの名前 |
name | string | カウンターの名前 |
count | int | カウント値 |
createdAt | long | 作成日時 |
updatedAt | long | 最終更新日時 |
EzLimitModel
回数制限モデル
回数制限にはリセット間隔を設定できます。
リセット間隔は 毎日・毎週・毎月・リセットしない の4種類から選択ができます。
回数制限の最大値はマスターデータでは設定しません。
なぜなら、ステップアップガチャのような仕組みで、購入回数カウンターが 3 回未満の場合に購入できる商品。
前述の商品を購入することが出来ず、購入回数カウンターが 5 回未満の場合に購入できる商品。というようにコンテキストによって最大値を変更できるようにするためです。
型 | 説明 | |
---|---|---|
limitModelId | string | 回数制限モデルGRN |
name | string | 回数制限モデル名 |
metadata | string | メタデータ |
resetType | enum ['notReset', 'daily', 'weekly', 'monthly'] | リセットタイミング |
resetDayOfMonth | int | リセットをする日にち |
resetDayOfWeek | enum ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'] | リセットする曜日 |
resetHour | int | リセット時刻 |
メソッド
countUp
countUp
ProfilePtr = std::make_shared<gs2::ez::Profile>(
TCHAR_TO_ANSI(*ClientId),
TCHAR_TO_ANSI(*ClientSecret),
gs2::ez::Gs2BasicReopener()
);
ClientPtr = std::make_shared<gs2::ez::Client>(
*ProfilePtr
);
ProfilePtr->initialize(
[this](gs2::ez::Profile::AsyncInitializeResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
}
else
{
AccountCreate();
}
}
);
// Up to this line is the initialization process.
ClientPtr->limit.countUp(
[](gs2::ez::account::AsyncEzCountUpResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "limit.countUp failed.");
}
else
{
Item = r.getResult()->getItem();
}
},
ProfilePtr->getGs2Session(),
TCHAR_TO_ANSI("namespace1"), // namespaceName
TCHAR_TO_ANSI("daily"), // limitName
TCHAR_TO_ANSI("counter1"), // counterName
1 // countUpValue,
100 // maxValue
);
///////////////////////////////////////////////////////////////
// New Experience (Enabled UniTask)
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
#if GS2_ENABLE_UNITASK
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
#endif
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
await profile.InitializeAsync();
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
var domain = gs2.Limit.Namespace(
namespaceName: "namespace1"
).Me(
gameSession: gameSession
).Counter(
limitName: "daily",
counterName: "counter1"
);
var result = await domain.CountUpAsync(
countUpValue: 1,
maxValue: 100
);
var item = await result.ModelAsync();
}
///////////////////////////////////////////////////////////////
// Legacy Experience
///////////////////////////////////////////////////////////////
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
{
AsyncResult<object> asyncResult = null;
var current = profile.Initialize(
r => { asyncResult = r; }
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
}
var gs2 = new Gs2.Unity.Client(profile);
// Up to this line is the initialization process.
{
AsyncResult<EzCountUpResult> asyncResult = null;
var current = gs2.Limit.CountUp(
callback: r => { asyncResult = r; },
session: session,
namespaceName: "namespace1",
limitName: "daily",
counterName: "counter1",
countUpValue: 1,
maxValue: 100
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
var result = asyncResult.Result;
var item = result.Item;
}
回数制限名とカウンター名を指定してゲームプレイヤーに紐づく回数制限カウンターをカウントアップ
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32文字 | ネームスペース名 | |
limitName | string | ✓ | ~ 128文字 | 回数制限モデルの名前 | |
counterName | string | ✓ | ~ 128文字 | カウンターの名前 | |
accessToken | string | ✓ | ~ 128文字 | ユーザーID | |
countUpValue | int | ✓ | 1 | 1 ~ 2147483646 | カウントアップする量 |
maxValue | int | 1 ~ 2147483646 | カウントアップを許容する最大値 |
Result
型 | 説明 | |
---|---|---|
item | EzCounter | カウントを増やしたカウンター |
getCounter
getCounter
ProfilePtr = std::make_shared<gs2::ez::Profile>(
TCHAR_TO_ANSI(*ClientId),
TCHAR_TO_ANSI(*ClientSecret),
gs2::ez::Gs2BasicReopener()
);
ClientPtr = std::make_shared<gs2::ez::Client>(
*ProfilePtr
);
ProfilePtr->initialize(
[this](gs2::ez::Profile::AsyncInitializeResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
}
else
{
AccountCreate();
}
}
);
// Up to this line is the initialization process.
ClientPtr->limit.getCounter(
[](gs2::ez::account::AsyncEzGetCounterResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "limit.getCounter failed.");
}
else
{
Item = r.getResult()->getItem();
}
},
ProfilePtr->getGs2Session(),
TCHAR_TO_ANSI("namespace1"), // namespaceName
TCHAR_TO_ANSI("daily"), // limitName
TCHAR_TO_ANSI("counter1") // counterName
);
///////////////////////////////////////////////////////////////
// New Experience (Enabled UniTask)
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
#if GS2_ENABLE_UNITASK
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
#endif
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
await profile.InitializeAsync();
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
var domain = gs2.Limit.Namespace(
namespaceName: "namespace1"
).Me(
gameSession: gameSession
).Counter(
limitName: "daily",
counterName: "counter1"
);
var item = await domain.ModelAsync();
}
///////////////////////////////////////////////////////////////
// Legacy Experience
///////////////////////////////////////////////////////////////
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
{
AsyncResult<object> asyncResult = null;
var current = profile.Initialize(
r => { asyncResult = r; }
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
}
var gs2 = new Gs2.Unity.Client(profile);
// Up to this line is the initialization process.
{
AsyncResult<EzGetCounterResult> asyncResult = null;
var current = gs2.Limit.GetCounter(
callback: r => { asyncResult = r; },
session: session,
namespaceName: "namespace1",
limitName: "daily",
counterName: "counter1"
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
var result = asyncResult.Result;
var item = result.Item;
}
回数制限名とカウンター名を指定してゲームプレイヤーに紐づく回数制限カウンターを取得
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32文字 | ネームスペース名 | |
limitName | string | ✓ | ~ 128文字 | 回数制限モデルの名前 | |
counterName | string | ✓ | ~ 128文字 | カウンターの名前 | |
accessToken | string | ✓ | ~ 128文字 | ユーザーID |
Result
型 | 説明 | |
---|---|---|
item | EzCounter | カウンター |
listCounters
listCounters
ProfilePtr = std::make_shared<gs2::ez::Profile>(
TCHAR_TO_ANSI(*ClientId),
TCHAR_TO_ANSI(*ClientSecret),
gs2::ez::Gs2BasicReopener()
);
ClientPtr = std::make_shared<gs2::ez::Client>(
*ProfilePtr
);
ProfilePtr->initialize(
[this](gs2::ez::Profile::AsyncInitializeResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
}
else
{
AccountCreate();
}
}
);
// Up to this line is the initialization process.
ClientPtr->limit.describeCounters(
[](gs2::ez::account::AsyncEzDescribeCountersResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "limit.describeCounters failed.");
}
else
{
Items = r.getResult()->getItems();
NextPageToken = r.getResult()->getNextPageToken();
}
},
ProfilePtr->getGs2Session(),
TCHAR_TO_ANSI("namespace1"), // namespaceName
null // limit,
TCHAR_TO_ANSI("daily"), // limitName
TCHAR_TO_ANSI(null) // pageToken
);
///////////////////////////////////////////////////////////////
// New Experience (Enabled UniTask)
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
#if GS2_ENABLE_UNITASK
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
#endif
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
await profile.InitializeAsync();
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
var domain = gs2.Limit.Namespace(
namespaceName: "namespace1"
).Me(
gameSession: gameSession
);
var items = await domain.CountersAsync(
).ToListAsync();
}
///////////////////////////////////////////////////////////////
// Legacy Experience
///////////////////////////////////////////////////////////////
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
{
AsyncResult<object> asyncResult = null;
var current = profile.Initialize(
r => { asyncResult = r; }
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
}
var gs2 = new Gs2.Unity.Client(profile);
// Up to this line is the initialization process.
{
AsyncResult<EzListCountersResult> asyncResult = null;
var current = gs2.Limit.ListCounters(
callback: r => { asyncResult = r; },
session: session,
namespaceName: "namespace1",
limit: null,
limitName: "daily",
pageToken: null
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;
}
ゲームプレイヤーに紐づく回数制限カウンターの一覧を取得
回数制限名は省略可能です。
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32文字 | ネームスペース名 | |
limitName | string | ~ 128文字 | 回数制限モデルの名前 | ||
accessToken | string | ✓ | ~ 128文字 | ユーザーID | |
pageToken | string | ~ 1024文字 | データの取得を開始する位置を指定するトークン | ||
limit | int | ✓ | 30 | 1 ~ 1000 | データの取得件数 |
Result
型 | 説明 | |
---|---|---|
items | List<EzCounter> | カウンターのリスト |
nextPageToken | string | リストの続きを取得するためのページトークン |
getLimitModel
getLimitModel
ProfilePtr = std::make_shared<gs2::ez::Profile>(
TCHAR_TO_ANSI(*ClientId),
TCHAR_TO_ANSI(*ClientSecret),
gs2::ez::Gs2BasicReopener()
);
ClientPtr = std::make_shared<gs2::ez::Client>(
*ProfilePtr
);
ProfilePtr->initialize(
[this](gs2::ez::Profile::AsyncInitializeResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
}
else
{
AccountCreate();
}
}
);
// Up to this line is the initialization process.
ClientPtr->limit.getLimitModel(
[](gs2::ez::account::AsyncEzGetLimitModelResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "limit.getLimitModel failed.");
}
else
{
Item = r.getResult()->getItem();
}
},
TCHAR_TO_ANSI("namespace1"), // namespaceName
TCHAR_TO_ANSI("limit-model-0001") // limitName
);
///////////////////////////////////////////////////////////////
// New Experience (Enabled UniTask)
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
#if GS2_ENABLE_UNITASK
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
#endif
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
await profile.InitializeAsync();
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
var domain = gs2.Limit.Namespace(
namespaceName: "namespace1"
).LimitModel(
limitName: "limit-model-0001"
);
var item = await domain.ModelAsync();
}
///////////////////////////////////////////////////////////////
// Legacy Experience
///////////////////////////////////////////////////////////////
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
{
AsyncResult<object> asyncResult = null;
var current = profile.Initialize(
r => { asyncResult = r; }
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
}
var gs2 = new Gs2.Unity.Client(profile);
// Up to this line is the initialization process.
{
AsyncResult<EzGetLimitModelResult> asyncResult = null;
var current = gs2.Limit.GetLimitModel(
callback: r => { asyncResult = r; },
namespaceName: "namespace1",
limitName: "limit-model-0001"
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
var result = asyncResult.Result;
var item = result.Item;
}
回数制限名を指定して回数制限モデルを取得
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32文字 | ネームスペース名 | |
limitName | string | ✓ | ~ 128文字 | 回数制限モデル名 |
Result
型 | 説明 | |
---|---|---|
item | EzLimitModel | 回数制限モデル |
listLimitModels
listLimitModels
ProfilePtr = std::make_shared<gs2::ez::Profile>(
TCHAR_TO_ANSI(*ClientId),
TCHAR_TO_ANSI(*ClientSecret),
gs2::ez::Gs2BasicReopener()
);
ClientPtr = std::make_shared<gs2::ez::Client>(
*ProfilePtr
);
ProfilePtr->initialize(
[this](gs2::ez::Profile::AsyncInitializeResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
}
else
{
AccountCreate();
}
}
);
// Up to this line is the initialization process.
ClientPtr->limit.describeLimitModels(
[](gs2::ez::account::AsyncEzDescribeLimitModelsResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "limit.describeLimitModels failed.");
}
else
{
Items = r.getResult()->getItems();
}
},
TCHAR_TO_ANSI("namespace1") // namespaceName
);
///////////////////////////////////////////////////////////////
// New Experience (Enabled UniTask)
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
#if GS2_ENABLE_UNITASK
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
#endif
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
await profile.InitializeAsync();
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
var domain = gs2.Limit.Namespace(
namespaceName: "namespace1"
);
var items = await domain.LimitModelsAsync(
).ToListAsync();
}
///////////////////////////////////////////////////////////////
// Legacy Experience
///////////////////////////////////////////////////////////////
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
{
AsyncResult<object> asyncResult = null;
var current = profile.Initialize(
r => { asyncResult = r; }
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
}
var gs2 = new Gs2.Unity.Client(profile);
// Up to this line is the initialization process.
{
AsyncResult<EzListLimitModelsResult> asyncResult = null;
var current = gs2.Limit.ListLimitModels(
callback: r => { asyncResult = r; },
namespaceName: "namespace1"
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
var result = asyncResult.Result;
var items = result.Items;
}
回数制限モデルの一覧を取得
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32文字 | ネームスペース名 |
Result
型 | 説明 | |
---|---|---|
items | List<EzLimitModel> | 回数制限モデルのリスト |