GS2-Exchange Script トリガー リファレンス

拡張スクリプトを呼び出すイベントトリガーのリファレンス

トリガー

exchange

交換

同期実行スクリプト

交換処理の前に、スクリプトが同期実行されます。

Request
説明
namespace Namespace ネームスペース
rateModel RateModel 交換レートモデル
userId string 交換を実行しているユーザーID
count int 交換量
config Config[] トランザクションの変数に適用する設定値
Result
必須 デフォルト 値の制限 説明
permit bool
交換を許可するか
rateMode string
“float” 倍率モード
rate float 1.0 0 ~ 1000 入手量の倍率
logRate LogRate 対数を使用した入手量補正
実装例
-- Request
local namespace = args.namespace
local rateModel = args.rateModel
local userId = args.userId
local count = args.count
local config = args.config

-- Business logic:
local permit = true
local rateMode = ""
local rate = 0
local logRate = nil

-- Result
result = {
  permit=permit,
  rateMode=rateMode,
  rate=rate,
  logRate=logRate
}

非同期実行スクリプト

交換処理の後に、スクリプトが非同期実行されます。

Request
説明
namespace Namespace ネームスペース
rateModel RateModel 交換レートモデル
userId string 交換を実行しているユーザーID
count int 交換量
config Config[] トランザクションの変数に適用する設定値
実装例
-- Request
local namespace = args.namespace
local rateModel = args.rateModel
local userId = args.userId
local count = args.count
local config = args.config

-- 非同期スクリプトは通常、API のレスポンスには影響を与えません。
-- ログ出力や分析、外部通知などに使用します。

result = {
}

incrementalExchange

交換

同期実行スクリプト

交換処理の前に、スクリプトが同期実行されます。

Request
説明
namespace Namespace ネームスペース
rateModel IncrementalRateModel 交換レートモデル
userId string 交換を実行しているユーザーID
count int 交換量
config Config[] トランザクションの変数に適用する設定値
Result
必須 デフォルト 値の制限 説明
permit bool
交換を許可するか
実装例
-- Request
local namespace = args.namespace
local rateModel = args.rateModel
local userId = args.userId
local count = args.count
local config = args.config

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}

非同期実行スクリプト

交換処理の後に、スクリプトが非同期実行されます。

Request
説明
namespace Namespace ネームスペース
rateModel IncrementalRateModel 交換レートモデル
userId string 交換を実行しているユーザーID
count int 交換量
config Config[] トランザクションの変数に適用する設定値
実装例
-- Request
local namespace = args.namespace
local rateModel = args.rateModel
local userId = args.userId
local count = args.count
local config = args.config

-- 非同期スクリプトは通常、API のレスポンスには影響を与えません。
-- ログ出力や分析、外部通知などに使用します。

result = {
}

calculateCost

コスト上昇型交換レートのためのコスト計算スクリプト

同期実行スクリプト

コスト上昇型交換レートのためのコスト計算スクリプト処理の前に、スクリプトが同期実行されます。

Request
説明
namespace Namespace ネームスペース
incrementalRateModel IncrementalRateModel コスト上昇型交換モデル
userId string ユーザーID
currentExchangeCount int 現在の交換回数
quantity int 交換数量
Result
必須 デフォルト 値の制限 説明
costMode string
“num” コスト計算方法
cost long 0 ~ 9223372036854775805 コスト
logCost LogCost 対数を使用したコスト計算結果
実装例
-- Request
local namespace = args.namespace
local incrementalRateModel = args.incrementalRateModel
local userId = args.userId
local currentExchangeCount = args.currentExchangeCount
local quantity = args.quantity

-- Business logic:
local costMode = ""
local cost = 0
local logCost = nil

-- Result
result = {
  costMode=costMode,
  cost=cost,
  logCost=logCost
}

acquireAwait

交換待機

同期実行スクリプト

交換待機処理の前に、スクリプトが同期実行されます。

Request
説明
namespace Namespace ネームスペース
rateModel RateModel 交換レートモデル
awaitModel Await 交換待機
Result
必須 デフォルト 値の制限 説明
permit bool
交換待機を許可するか
実装例
-- Request
local namespace = args.namespace
local rateModel = args.rateModel
local awaitModel = args.awaitModel

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}

非同期実行スクリプト

交換待機処理の後に、スクリプトが非同期実行されます。

Request
説明
namespace Namespace ネームスペース
rateModel RateModel 交換レートモデル
awaitModel Await 交換待機
実装例
-- Request
local namespace = args.namespace
local rateModel = args.rateModel
local awaitModel = args.awaitModel

-- 非同期スクリプトは通常、API のレスポンスには影響を与えません。
-- ログ出力や分析、外部通知などに使用します。

result = {
}