6 | | - | let slots1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5] |
---|
7 | | - | |
---|
8 | | - | let slots2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5] |
---|
9 | | - | |
---|
10 | | - | let slots3 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5] |
---|
11 | | - | |
---|
12 | | - | func randomizer (inv) = { |
---|
13 | | - | let rand = ((((inv.transactionId + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) |
---|
14 | | - | sha256(rand) |
---|
15 | | - | } |
---|
16 | | - | |
---|
17 | | - | |
---|
18 | | - | func getSlot1 (inv) = { |
---|
19 | | - | let hash = sha256(((((inv.transactionId + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height))) |
---|
20 | | - | let index = toInt(hash) |
---|
21 | | - | slots1[(index % slotCount)] |
---|
22 | | - | } |
---|
23 | | - | |
---|
24 | | - | |
---|
25 | | - | func getSlot2 (inv) = { |
---|
26 | | - | let hash = sha256(((((inv.transactionId + lastBlock.generationSignature) + inv.callerPublicKey) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height))) |
---|
27 | | - | let index = toInt(hash) |
---|
28 | | - | slots2[(index % slotCount)] |
---|
29 | | - | } |
---|
30 | | - | |
---|
31 | | - | |
---|
32 | | - | func getSlot3 (inv) = { |
---|
33 | | - | let hash = sha256(((((inv.callerPublicKey + inv.transactionId) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height))) |
---|
34 | | - | let index = toInt(hash) |
---|
35 | | - | slots3[(index % slotCount)] |
---|
36 | | - | } |
---|
37 | | - | |
---|
38 | | - | |
---|
39 | | - | func startSpin (inv) = { |
---|
40 | | - | let MaxBet = (wavesBalance(this) / 35) |
---|
41 | | - | let payment = extract(inv.payment) |
---|
42 | | - | let slot1 = toString(getSlot1(inv)) |
---|
43 | | - | let slot2 = toString(getSlot2(inv)) |
---|
44 | | - | let slot3 = toString(getSlot3(inv)) |
---|
45 | | - | let smt1 = getSlot1(inv) |
---|
46 | | - | let smt2 = getSlot2(inv) |
---|
47 | | - | let smt3 = getSlot3(inv) |
---|
48 | | - | if (!(isDefined(inv.payment))) |
---|
49 | | - | then throw("Should be with Payment in Waves") |
---|
50 | | - | else if (isDefined(payment.assetId)) |
---|
51 | | - | then throw("Payment should be in Waves") |
---|
52 | | - | else if ((payment.amount > MaxBet)) |
---|
53 | | - | then throw(("Payment should be less than " + toString(MaxBet))) |
---|
54 | | - | else { |
---|
55 | | - | let player = toBase58String(inv.caller.bytes) |
---|
56 | | - | let randhash = randomizer(inv) |
---|
57 | | - | let timestamp = toString(lastBlock.timestamp) |
---|
58 | | - | if (if (if ((smt1 == 1)) |
---|
59 | | - | then (smt2 == 1) |
---|
60 | | - | else false) |
---|
61 | | - | then (smt3 == 1) |
---|
62 | | - | else false) |
---|
63 | | - | then ScriptResult(WriteSet([DataEntry(((((slot1 + "_") + slot2) + "_") + slot3), ((player + "_") + timestamp))]), TransferSet([ScriptTransfer(inv.caller, ((payment.amount * 190) / 100), unit)])) |
---|
64 | | - | else if (if (if ((smt1 == 2)) |
---|
65 | | - | then (smt2 == 2) |
---|
66 | | - | else false) |
---|
67 | | - | then (smt3 == 2) |
---|
68 | | - | else false) |
---|
69 | | - | then ScriptResult(WriteSet([DataEntry(((((slot1 + "_") + slot2) + "_") + slot3), ((player + "_") + timestamp))]), TransferSet([ScriptTransfer(inv.caller, ((payment.amount * 390) / 100), unit)])) |
---|
70 | | - | else if (if (if ((smt1 == 3)) |
---|
71 | | - | then (smt2 == 3) |
---|
72 | | - | else false) |
---|
73 | | - | then (smt3 == 3) |
---|
74 | | - | else false) |
---|
75 | | - | then ScriptResult(WriteSet([DataEntry(((((slot1 + "_") + slot2) + "_") + slot3), ((player + "_") + timestamp))]), TransferSet([ScriptTransfer(inv.caller, ((payment.amount * 790) / 100), unit)])) |
---|
76 | | - | else if (if (if ((smt1 == 4)) |
---|
77 | | - | then (smt2 == 4) |
---|
78 | | - | else false) |
---|
79 | | - | then (smt3 == 4) |
---|
80 | | - | else false) |
---|
81 | | - | then ScriptResult(WriteSet([DataEntry(((((slot1 + "_") + slot2) + "_") + slot3), ((player + "_") + timestamp))]), TransferSet([ScriptTransfer(inv.caller, ((payment.amount * 1590) / 100), unit)])) |
---|
82 | | - | else if (if (if ((smt1 == 5)) |
---|
83 | | - | then (smt2 == 5) |
---|
84 | | - | else false) |
---|
85 | | - | then (smt3 == 5) |
---|
86 | | - | else false) |
---|
87 | | - | then ScriptResult(WriteSet([DataEntry(((((slot1 + "_") + slot2) + "_") + slot3), ((player + "_") + timestamp))]), TransferSet([ScriptTransfer(inv.caller, ((payment.amount * 3190) / 100), unit)])) |
---|
88 | | - | else ScriptResult(WriteSet([DataEntry(((((slot1 + "_") + slot2) + "_") + slot3), ((player + "_") + timestamp))]), TransferSet(nil)) |
---|
89 | | - | } |
---|
90 | | - | } |
---|
91 | | - | |
---|
92 | | - | |
---|
93 | | - | @Callable(inv) |
---|
94 | | - | func spin () = startSpin(inv) |
---|