3 | | - | let redPubKey = base58'BYrrqVpD5uuz7cndnPwuUxuYFUK6Bovu6yfoV8seY6Px' |
---|
4 | | - | let greenPubKey = base58'HnSkSntD7ihFgZpLNmHgdVnVmCYxJLC96eNbubTXsWju' |
---|
5 | | - | let bluePubKey = base58'5Ak4HQK3cnkwe6XVUXwpCYeSAARwruKyAmsmegePUPvo' |
---|
6 | | - | let redAddr = Address(base58'3MyP3hrK8SBvtXtggNWdsry8KuGdrv1sFrV') |
---|
7 | | - | let greenAddr = Address(base58'3MzzYQCC8Ks86exHaWV2VpaANbNLPRDunNJ') |
---|
8 | | - | let blueAddr = Address(base58'3MuuWYr3DyjEkncbNU1tUeFbyvcyZng9gz4') |
---|
9 | | - | let contract = tx.sender |
---|
10 | | - | let redSigned = sigVerify(tx.bodyBytes, tx.proofs[0], redPubKey) |
---|
11 | | - | let greenSigned = sigVerify(tx.bodyBytes, tx.proofs[0], greenPubKey) |
---|
12 | | - | let blueSigned = sigVerify(tx.bodyBytes, tx.proofs[0], bluePubKey) |
---|
13 | | - | match tx { |
---|
14 | | - | case ttx: DataTransaction => |
---|
15 | | - | let dataSize = size(ttx.data) |
---|
16 | | - | let fromKey = ttx.data[0].key |
---|
17 | | - | let toKey = ttx.data[1].key |
---|
18 | | - | let turnToKey = ttx.data[2].key |
---|
19 | | - | let newFromUnits = ttx.data[0].value |
---|
20 | | - | let newToUnits = ttx.data[1].value |
---|
21 | | - | let turnToValue = ttx.data[2].value |
---|
22 | | - | let turnCorrect = if (if (if (if (if (if (if (if (if (if (if (if ((fromKey == "country1")) |
---|
23 | | - | then (toKey == "country2") |
---|
24 | | - | else false) |
---|
25 | | - | then true |
---|
26 | | - | else if ((fromKey == "country2")) |
---|
27 | | - | then if ((toKey == "country1")) |
---|
28 | | - | then true |
---|
29 | | - | else (toKey == "country3") |
---|
30 | | - | else false) |
---|
31 | | - | then true |
---|
32 | | - | else if ((fromKey == "country3")) |
---|
33 | | - | then if (if ((toKey == "country2")) |
---|
34 | | - | then true |
---|
35 | | - | else (toKey == "country4")) |
---|
36 | | - | then true |
---|
37 | | - | else (toKey == "country5") |
---|
38 | | - | else false) |
---|
39 | | - | then true |
---|
40 | | - | else if ((fromKey == "country4")) |
---|
41 | | - | then if ((toKey == "country3")) |
---|
42 | | - | then true |
---|
43 | | - | else (toKey == "country8") |
---|
44 | | - | else false) |
---|
45 | | - | then true |
---|
46 | | - | else if ((fromKey == "country5")) |
---|
47 | | - | then if ((toKey == "country3")) |
---|
48 | | - | then true |
---|
49 | | - | else (toKey == "country10") |
---|
50 | | - | else false) |
---|
51 | | - | then true |
---|
52 | | - | else if ((fromKey == "country6")) |
---|
53 | | - | then (toKey == "country7") |
---|
54 | | - | else false) |
---|
55 | | - | then true |
---|
56 | | - | else if ((fromKey == "country7")) |
---|
57 | | - | then if ((toKey == "country6")) |
---|
58 | | - | then true |
---|
59 | | - | else (toKey == "country8") |
---|
60 | | - | else false) |
---|
61 | | - | then true |
---|
62 | | - | else if ((fromKey == "country8")) |
---|
63 | | - | then if (if ((toKey == "country4")) |
---|
64 | | - | then true |
---|
65 | | - | else (toKey == "country7")) |
---|
66 | | - | then true |
---|
67 | | - | else (toKey == "country9") |
---|
68 | | - | else false) |
---|
69 | | - | then true |
---|
70 | | - | else if ((fromKey == "country9")) |
---|
71 | | - | then if ((toKey == "country8")) |
---|
72 | | - | then true |
---|
73 | | - | else (toKey == "country10") |
---|
74 | | - | else false) |
---|
75 | | - | then true |
---|
76 | | - | else if ((fromKey == "country10")) |
---|
77 | | - | then if (if ((toKey == "country5")) |
---|
78 | | - | then true |
---|
79 | | - | else (toKey == "country10")) |
---|
80 | | - | then true |
---|
81 | | - | else (toKey == "country11") |
---|
82 | | - | else false) |
---|
83 | | - | then true |
---|
84 | | - | else if ((fromKey == "country11")) |
---|
85 | | - | then if ((toKey == "country10")) |
---|
86 | | - | then true |
---|
87 | | - | else (toKey == "country12") |
---|
88 | | - | else false) |
---|
89 | | - | then true |
---|
90 | | - | else if ((fromKey == "country12")) |
---|
91 | | - | then (toKey == "country11") |
---|
92 | | - | else false |
---|
93 | | - | let turnFromKey = ("turn_" + fromKey) |
---|
94 | | - | let turnFromValue = extract(getInteger(contract, turnFromKey)) |
---|
95 | | - | let turnAllowed = ((height - 5) > turnFromValue) |
---|
96 | | - | let oldTurnToKey = ("turn_" + toKey) |
---|
97 | | - | let oldTurnToValue = extract(getInteger(contract, oldTurnToKey)) |
---|
98 | | - | let locked = if ((("turn_" + toKey) == turnToKey)) |
---|
99 | | - | then (turnToValue == height) |
---|
100 | | - | else false |
---|
101 | | - | let lockNotChanged = if ((("turn_" + toKey) == turnToKey)) |
---|
102 | | - | then (turnToValue == oldTurnToValue) |
---|
103 | | - | else false |
---|
104 | | - | let fromUnits = extract(getInteger(contract, fromKey)) |
---|
105 | | - | let toUnits = extract(getInteger(contract, toKey)) |
---|
106 | | - | let redAttackers = (fromUnits % 100) |
---|
107 | | - | let greenAttackers = (((fromUnits - redAttackers) % 10000) / 100) |
---|
108 | | - | let blueAttackers = (((fromUnits - (greenAttackers * 100)) - redAttackers) / 10000) |
---|
109 | | - | let redDefenders = (toUnits % 100) |
---|
110 | | - | let greenDefenders = (((toUnits - redDefenders) % 10000) / 100) |
---|
111 | | - | let blueDefenders = ((((toUnits - (greenDefenders * 100)) - redDefenders) % 1000000) / 10000) |
---|
112 | | - | let whiteDefenders = ((((toUnits - (blueDefenders * 10000)) - (greenDefenders * 100)) - redDefenders) / 1000000) |
---|
113 | | - | let countryAttackers = ((redAttackers + greenAttackers) + blueAttackers) |
---|
114 | | - | let countryDefenders = ((redDefenders + greenDefenders) + blueDefenders) |
---|
115 | | - | let unlimitedAttackers = (((redAttackers + greenAttackers) + blueAttackers) + (height - turnFromValue)) |
---|
116 | | - | let unlimitedDefenders = (((redDefenders + greenDefenders) + blueDefenders) + (height - oldTurnToValue)) |
---|
117 | | - | let attackers = if ((unlimitedAttackers >= 10)) |
---|
118 | | - | then 10 |
---|
119 | | - | else unlimitedAttackers |
---|
120 | | - | let defenders = if ((unlimitedDefenders >= 10)) |
---|
121 | | - | then 10 |
---|
122 | | - | else unlimitedDefenders |
---|
123 | | - | let king = if (if (if ((redAttackers > 0)) |
---|
124 | | - | then redSigned |
---|
125 | | - | else false) |
---|
126 | | - | then true |
---|
127 | | - | else if ((greenAttackers > 0)) |
---|
128 | | - | then greenSigned |
---|
129 | | - | else false) |
---|
130 | | - | then true |
---|
131 | | - | else if ((blueAttackers > 0)) |
---|
132 | | - | then blueSigned |
---|
133 | | - | else false |
---|
134 | | - | let multiAttackers = if ((countryAttackers > 0)) |
---|
135 | | - | then (fromUnits / countryAttackers) |
---|
136 | | - | else 0 |
---|
137 | | - | let multiDefenders = if ((countryDefenders > 0)) |
---|
138 | | - | then (toUnits / countryDefenders) |
---|
139 | | - | else 0 |
---|
140 | | - | let win = if (if (if (if (if (king) |
---|
141 | | - | then (multiAttackers != multiDefenders) |
---|
142 | | - | else false) |
---|
143 | | - | then (attackers > defenders) |
---|
144 | | - | else false) |
---|
145 | | - | then (newFromUnits == 0) |
---|
146 | | - | else false) |
---|
147 | | - | then (newToUnits == ((attackers - defenders) * multiAttackers)) |
---|
148 | | - | else false) |
---|
149 | | - | then locked |
---|
150 | | - | else false |
---|
151 | | - | let lost = if (if (if (if (if (king) |
---|
152 | | - | then (multiAttackers != multiDefenders) |
---|
153 | | - | else false) |
---|
154 | | - | then (defenders > attackers) |
---|
155 | | - | else false) |
---|
156 | | - | then (newFromUnits == 0) |
---|
157 | | - | else false) |
---|
158 | | - | then (newToUnits == ((defenders - attackers) * multiDefenders)) |
---|
159 | | - | else false) |
---|
160 | | - | then lockNotChanged |
---|
161 | | - | else false |
---|
162 | | - | let draw = if (if (if (if (if (king) |
---|
163 | | - | then (multiAttackers != multiDefenders) |
---|
164 | | - | else false) |
---|
165 | | - | then (attackers == defenders) |
---|
166 | | - | else false) |
---|
167 | | - | then (newFromUnits == 0) |
---|
168 | | - | else false) |
---|
169 | | - | then (newToUnits == (((defenders + 1) - attackers) * multiDefenders)) |
---|
170 | | - | else false) |
---|
171 | | - | then lockNotChanged |
---|
172 | | - | else false |
---|
173 | | - | let move = if (if (if (if (if (king) |
---|
174 | | - | then (multiAttackers == multiDefenders) |
---|
175 | | - | else false) |
---|
176 | | - | then (newFromUnits == 0) |
---|
177 | | - | else false) |
---|
178 | | - | then (10 >= (attackers + defenders)) |
---|
179 | | - | else false) |
---|
180 | | - | then (newToUnits == ((attackers + defenders) * multiAttackers)) |
---|
181 | | - | else false) |
---|
182 | | - | then locked |
---|
183 | | - | else false |
---|
184 | | - | if (if (if (if (if (if (win) |
---|
185 | | - | then true |
---|
186 | | - | else lost) |
---|
187 | | - | then true |
---|
188 | | - | else draw) |
---|
189 | | - | then true |
---|
190 | | - | else move) |
---|
191 | | - | then turnAllowed |
---|
192 | | - | else false) |
---|
193 | | - | then (dataSize == 3) |
---|
194 | | - | else false) |
---|
195 | | - | then true |
---|
196 | | - | else (dataSize == 12) |
---|
197 | | - | case ntx: TransferTransaction => |
---|
198 | | - | true |
---|
199 | | - | case _ => |
---|
200 | | - | true |
---|
201 | | - | } |
---|
| 3 | + | let PubKey1 = base58'854p8BYzrj6yBPRPmfQur3oF1Rjc1AJ548qRp5FT5kDa' |
---|
| 4 | + | let PubKey2 = base58'DKGFPozLrsiR8NM4NJzqQaBYC8NyGYjuw2hDYicQVjco' |
---|
| 5 | + | let sig1 = if (sigVerify(tx.bodyBytes, tx.proofs[0], PubKey1)) |
---|
| 6 | + | then 1 |
---|
| 7 | + | else 0 |
---|
| 8 | + | let sig2 = if (sigVerify(tx.bodyBytes, tx.proofs[1], PubKey2)) |
---|
| 9 | + | then 1 |
---|
| 10 | + | else 0 |
---|
| 11 | + | ((sig1 + sig2) > 0) |
---|