報酬とウォレット
サーバーが判定し、プレイヤーごとのウォレットに付与される、毎日・毎週・1 回限りの報酬です。
コードのコメントと API 名は、SDK と一致させるため英語のままにしています。
このページの内容
報酬を定義する#
報酬は報酬ページで作成します。
| フィールド | 意味 |
|---|---|
| 報酬キー | コードで使用する識別子(例: daily_coins)。 |
| 数量と通貨 | 付与する量と通貨(例: coins)。 |
| クールダウン | daily、weekly、once のいずれか。 |
| 有効 | 無効な報酬は非表示になり、受け取ることはできません。 |
報酬の一覧#
プレイヤーがログインしている場合、各報酬には claimable と next_claim_at が含まれます。
var available = await Majacloud.Rewards.ListAsync();
foreach (var reward in available.Value)
Debug.Log(reward.RewardKey + " claimable: " + reward.Claimable + " next: " + reward.NextClaimAt);var available := await Majacloud.rewards.list()
for reward in available.value:
print(reward.reward_key, " claimable: ", reward.claimable, " next: ", reward.next_claim_at)const available = await mc.rewards.list();
for (const reward of available.value) console.log(reward.reward_key, reward.claimable, reward.next_claim_at);curl https://majacloud.majanite.com/v1/rewards -H "X-Project-ID: $PROJECT_ID" -H "X-Client-Key: $CLIENT_KEY" \
-H "Authorization: Bearer $TOKEN"受け取り#
受け取りが可能かどうかはサーバーが判定し、ウォレットへの付与はアトミックに行われます。同じ期間内に 2 回目の受け取りを行うと、conflict と details.next_claim_at で失敗します。
var claim = await Majacloud.Rewards.ClaimAsync("daily_coins");
if (claim.Ok)
{
Debug.Log($"+{claim.Value.Amount} {claim.Value.Currency}, balance {claim.Value.Balance}");
}
else if (claim.Error.Code == MajacloudErrorCode.Conflict)
{
DateTime? next = claim.Error.GetDetailDateTime("next_claim_at"); // UTC
}var claim := await Majacloud.rewards.claim("daily_coins")
if claim.ok:
print("+%s %s, balance %s" % [claim.value.amount, claim.value.currency, claim.value.balance])
elif claim.error == "conflict":
print("Come back at ", claim.details.next_claim_at) # UTCconst claim = await mc.rewards.claim('daily_coins');
if (claim.ok) {
console.log(`+${claim.value.amount} ${claim.value.currency}, balance ${claim.value.balance}`);
} else if (claim.error.code === 'conflict') {
console.log('Come back at ' + claim.error.details.next_claim_at); // UTC
}curl -X POST https://majacloud.majanite.com/v1/rewards/claim -H "X-Project-ID: $PROJECT_ID" -H "X-Client-Key: $CLIENT_KEY" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" -d '{"reward_key": "daily_coins"}'ウォレット#
プレイヤーの通貨ごとの残高を読み取ります。
var wallet = await Majacloud.Rewards.GetWalletAsync();
Debug.Log("Coins: " + wallet.Value.Coins + ", gems: " + wallet.Value.Get("gems"));var wallet := await Majacloud.rewards.get_wallet()
print("Coins: ", wallet.value.get("coins", 0))const wallet = await mc.rewards.getWallet();
console.log('Coins: ' + (wallet.value.balances.coins || 0));curl https://majacloud.majanite.com/v1/wallet -H "X-Project-ID: $PROJECT_ID" -H "X-Client-Key: $CLIENT_KEY" \
-H "Authorization: Bearer $TOKEN"報酬のリセットタイミング#
デイリー報酬は 00:00 UTC から、ウィークリー報酬は月曜日の 00:00 UTC から再び受け取れます。1 回限りの報酬は二度と受け取れません。