GS2-Lottery Transaction Actions

Specification of verify/consume/acquire transaction actions

AcquireAction

Gs2Lottery:DrawByUserId

Execute a lottery by specifying a User ID

Performs a lottery draw for the specified user based on the lottery model configuration. The lottery supports two methods: Prize Table mode (using predefined probability tables) and Script mode (using a GS2-Script to determine prizes). In box lottery mode, drawn prizes are removed from the box and cannot be drawn again. If the box is empty, an Empty error is returned. The drawn prizes are issued as a transaction.

Whether the action allows quantity specification: YES

Whether the action is reversible: NO

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
lotteryNamestring
~ 128 charsLottery Model name
Lottery Model-specific name. Specified using alphanumeric characters, hyphen (-), underscore (_), and period (.).
userIdstring
~ 128 charsUser ID
Set #{userId} to replace the currently logged in user ID.
countint
1 ~ 1000Number of draws
configList<Config>[]0 ~ 1000 itemsSettings applied to the placeholder on the transaction
timeOffsetTokenstring~ 1024 charsTime offset token
{
    "action": "Gs2Lottery:DrawByUserId",
    "request": {
        "namespaceName": "[string]Namespace name",
        "lotteryName": "[string]Lottery Model name",
        "userId": "[string]User ID",
        "count": "[int]Number of draws",
        "config": [
            {
                "key": "[string]Name",
                "value": "[string]Value"
            }
        ],
        "timeOffsetToken": "[string]Time offset token"
    }
}
action: Gs2Lottery:DrawByUserId
request:
  namespaceName: "[string]Namespace name"
  lotteryName: "[string]Lottery Model name"
  userId: "[string]User ID"
  count: "[int]Number of draws"
  config: 
    - key: "[string]Name"
      value: "[string]Value"
  timeOffsetToken: "[string]Time offset token"
transaction.service("lottery").acquire.draw_by_user_id({
    namespaceName="[string]Namespace name",
    lotteryName="[string]Lottery Model name",
    userId="[string]User ID",
    count="[int]Number of draws",
    config={
        {
            key="[string]Name",
            value="[string]Value"
        }
    },
    timeOffsetToken="[string]Time offset token",
})

Gs2Lottery:ResetBoxByUserId

Reset box with specified user ID

Resets the specified user’s box to its initial state, returning all drawn prizes back into the box.

Whether the action allows quantity specification: NO

Whether the action is reversible: NO

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
prizeTableNamestring
~ 128 charsName of prize table
userIdstring
~ 128 charsUser ID
Set #{userId} to replace the currently logged in user ID.
timeOffsetTokenstring~ 1024 charsTime offset token
{
    "action": "Gs2Lottery:ResetBoxByUserId",
    "request": {
        "namespaceName": "[string]Namespace name",
        "prizeTableName": "[string]Name of prize table",
        "userId": "[string]User ID",
        "timeOffsetToken": "[string]Time offset token"
    }
}
action: Gs2Lottery:ResetBoxByUserId
request:
  namespaceName: "[string]Namespace name"
  prizeTableName: "[string]Name of prize table"
  userId: "[string]User ID"
  timeOffsetToken: "[string]Time offset token"
transaction.service("lottery").acquire.reset_box_by_user_id({
    namespaceName="[string]Namespace name",
    prizeTableName="[string]Name of prize table",
    userId="[string]User ID",
    timeOffsetToken="[string]Time offset token",
})