14 | | - | func isPaymentOk (i) = { |
---|
15 | | - | let acceptableAssetId = base58'3JmaWyFqWo8YSA8x3DXCBUW7veesxacvKx19dMv7wTMg' |
---|
16 | | - | if ((size(i.payments) == 0)) |
---|
17 | | - | then throw("Payment not attached") |
---|
18 | | - | else { |
---|
19 | | - | let p = i.payments[0] |
---|
20 | | - | match p.assetId { |
---|
21 | | - | case assetId: ByteVector => |
---|
22 | | - | if ((assetId == acceptableAssetId)) |
---|
23 | | - | then (p.amount >= numToWaves(1)) |
---|
24 | | - | else false |
---|
25 | | - | case _ => |
---|
26 | | - | (p.amount >= numToWaves(1)) |
---|
27 | | - | } |
---|
28 | | - | } |
---|
| 11 | + | @Callable(i) |
---|
| 12 | + | func test7 () = { |
---|
| 13 | + | let address = toBase58String(i.caller.bytes) |
---|
| 14 | + | let r = toString(getRandomNumber()) |
---|
| 15 | + | $Tuple2([StringEntry("XXX", r)], 1) |
---|
30 | | - | |
---|
31 | | - | |
---|
32 | | - | func gameLuckyWheelWhatUserWon (value) = match value { |
---|
33 | | - | case _ => |
---|
34 | | - | if ((1 == $match0)) |
---|
35 | | - | then numToWaves(2) |
---|
36 | | - | else if ((5 == $match0)) |
---|
37 | | - | then numToWaves(1) |
---|
38 | | - | else if ((7 == $match0)) |
---|
39 | | - | then numToWaves(4) |
---|
40 | | - | else if ((11 == $match0)) |
---|
41 | | - | then numToWaves(1) |
---|
42 | | - | else 0 |
---|
43 | | - | } |
---|
44 | | - | |
---|
45 | | - | |
---|
46 | | - | @Callable(i) |
---|
47 | | - | func gameLuckyWheel (id) = if (!(isPaymentOk(i))) |
---|
48 | | - | then throw("Wrong payment amount or asset") |
---|
49 | | - | else { |
---|
50 | | - | let randomNumber = generateRandomNumber(i, 1, 12) |
---|
51 | | - | let winningAmount = gameLuckyWheelWhatUserWon(randomNumber) |
---|
52 | | - | if ((winningAmount == numToWaves(1))) |
---|
53 | | - | then [ScriptTransfer(i.caller, winningAmount, unit), StringEntry(("game_status_" + id), "roll"), IntegerEntry(("game_" + id), winningAmount), IntegerEntry(("test_game_randomNumber_" + id), randomNumber), IntegerEntry(("test_game_winningAmount_" + id), winningAmount)] |
---|
54 | | - | else if ((winningAmount > 0)) |
---|
55 | | - | then [ScriptTransfer(i.caller, winningAmount, unit), StringEntry(("game_status_" + id), "win"), IntegerEntry(("game_" + id), winningAmount), IntegerEntry(("test_game_randomNumber_" + id), randomNumber), IntegerEntry(("test_game_winningAmount_" + id), winningAmount)] |
---|
56 | | - | else [IntegerEntry(("game_" + id), winningAmount), StringEntry(("game_status_" + id), "lose"), IntegerEntry(("test_game_randomNumber_" + id), randomNumber), IntegerEntry(("test_game_winningAmount_" + id), winningAmount)] |
---|
57 | | - | } |
---|