Trigger Reference of GS2-Exchange Script
Reference for event triggers that call extended scripts, as defined in GS2-Exchange
exchange
Event trigger to call GS2-Script before Exchange.
Request
| Type | Description |
---|
namespace | Namespace | Namespace |
rateModel | RateModel | Exchange rate model |
userId | string | User ID performing the exchange |
count | int | Exchanging volume |
config | Config[] | Set values to be applied to transaction variables |
Result
| Type | Require | Default | Limitation | Description |
---|
permit | bool | ✓ | | | Allow exchange |
rateMode | string | ✓ | “float” | ~ 128 chars | Rate mode |
rate | float | | 1.0 | ~ 1000 | Acquisition quantity rate |
logRate | LogRate | | | | Logarithmic acquisition correction |
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
userId = args.userId
count = args.count
config = args.config
result = {
permit=permit,
rateMode=rateMode,
rate=rate,
logRate=logRate
}
exchangeDone
GS2-Script called after Exchange.
Request
| Type | Description |
---|
namespace | Namespace | Namespace |
rateModel | RateModel | Exchange rate model |
userId | string | User ID performing the exchange |
count | int | Exchanging volume |
config | Config[] | Set values to be applied to transaction variables |
Result
| Type | Require | Default | Limitation | Description |
---|
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
userId = args.userId
count = args.count
config = args.config
result = {
}
incrementalExchange
Event trigger to call GS2-Script before Exchange.
Request
| Type | Description |
---|
namespace | Namespace | Namespace |
rateModel | IncrementalRateModel | Exchange rate model |
userId | string | User ID performing the exchange |
count | int | Exchanging volume |
config | Config[] | Set values to be applied to transaction variables |
Result
| Type | Require | Default | Limitation | Description |
---|
permit | bool | ✓ | | | Allow exchange |
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
userId = args.userId
count = args.count
config = args.config
result = {
permit=permit
}
incrementalExchangeDone
GS2-Script called after Exchange.
Request
| Type | Description |
---|
namespace | Namespace | Namespace |
rateModel | IncrementalRateModel | Exchange rate model |
userId | string | User ID performing the exchange |
count | int | Exchanging volume |
config | Config[] | Set values to be applied to transaction variables |
Result
| Type | Require | Default | Limitation | Description |
---|
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
userId = args.userId
count = args.count
config = args.config
result = {
}
calculateCost
Event trigger to call GS2-Script when Costing Scripts for Cost Increase Type Exchange Rate.
Request
| Type | Description |
---|
namespace | Namespace | Namespace |
incrementalRateModel | IncrementalRateModel | Cost increase type exchange rate model |
currentExchangeCount | int | Current number of exchange counts |
quantity | int | Exchange Quantity |
Result
| Type | Require | Default | Limitation | Description |
---|
costMode | string | ✓ | “num” | ~ 128 chars | Cost calculation method |
cost | long | | | ~ 9223372036854775805 | Cost |
logCost | LogCost | | | | Cost calculation result using logarithm |
Implementation Example
namespace = args.namespace
incrementalRateModel = args.incrementalRateModel
currentExchangeCount = args.currentExchangeCount
quantity = args.quantity
result = {
costMode=costMode,
cost=cost,
logCost=logCost
}