4 | | - | func a (b) = (b * 100000000) |
---|
5 | | - | |
---|
6 | | - | |
---|
7 | | - | func c (d,e,f) = { |
---|
8 | | - | let g = toInt(keccak256(d.transactionId)) |
---|
9 | | - | let h = ((g % ((f - e) + 1)) + e) |
---|
10 | | - | h |
---|
11 | | - | } |
---|
12 | | - | |
---|
13 | | - | |
---|
14 | | - | func i (d) = { |
---|
15 | | - | let j = base58'3JmaWyFqWo8YSA8x3DXCBUW7veesxacvKx19dMv7wTMg' |
---|
16 | | - | if ((size(d.payments) == 0)) |
---|
17 | | - | then throw("Payment not attached") |
---|
18 | | - | else { |
---|
19 | | - | let k = d.payments[0] |
---|
20 | | - | let l = k.assetId |
---|
21 | | - | if ($isInstanceOf(l, "ByteVector")) |
---|
22 | | - | then { |
---|
23 | | - | let m = l |
---|
24 | | - | if ((m == j)) |
---|
25 | | - | then (k.amount >= a(1)) |
---|
26 | | - | else false |
---|
27 | | - | } |
---|
28 | | - | else (k.amount >= a(1)) |
---|
29 | | - | } |
---|
30 | | - | } |
---|
31 | | - | |
---|
32 | | - | |
---|
33 | | - | func n (o) = { |
---|
34 | | - | let l = o |
---|
35 | | - | if ((1 == l)) |
---|
36 | | - | then a(2) |
---|
37 | | - | else if ((5 == l)) |
---|
38 | | - | then a(1) |
---|
39 | | - | else if ((7 == l)) |
---|
40 | | - | then a(4) |
---|
41 | | - | else if ((11 == l)) |
---|
42 | | - | then a(1) |
---|
43 | | - | else 0 |
---|
| 4 | + | func a () = { |
---|
| 5 | + | let b = value(blockInfoByHeight((height - 1))) |
---|
| 6 | + | let c = sha256_16Kb(value(b.vrf)) |
---|
| 7 | + | toInt(c) |
---|
48 | | - | func gameLuckyWheel (p) = if (!(i(d))) |
---|
49 | | - | then throw("Wrong payment amount or asset") |
---|
50 | | - | else { |
---|
51 | | - | let h = c(d, 1, 12) |
---|
52 | | - | let q = n(h) |
---|
53 | | - | if ((q == a(1))) |
---|
54 | | - | then [ScriptTransfer(d.caller, q, unit), StringEntry(("game_status_" + p), "roll"), IntegerEntry(("game_" + p), q), IntegerEntry(("test_game_randomNumber_" + p), h), IntegerEntry(("test_game_winningAmount_" + p), q)] |
---|
55 | | - | else if ((q > 0)) |
---|
56 | | - | then [ScriptTransfer(d.caller, q, unit), StringEntry(("game_status_" + p), "win"), IntegerEntry(("game_" + p), q), IntegerEntry(("test_game_randomNumber_" + p), h), IntegerEntry(("test_game_winningAmount_" + p), q)] |
---|
57 | | - | else [IntegerEntry(("game_" + p), q), StringEntry(("game_status_" + p), "lose"), IntegerEntry(("test_game_randomNumber_" + p), h), IntegerEntry(("test_game_winningAmount_" + p), q)] |
---|
58 | | - | } |
---|
| 12 | + | func test7 () = { |
---|
| 13 | + | let e = toBase58String(d.caller.bytes) |
---|
| 14 | + | let f = toString(a()) |
---|
| 15 | + | $Tuple2([StringEntry("XXX", f)], 1) |
---|
| 16 | + | } |
---|