7 | | - | func e (f,g) = { |
---|
8 | | - | let h = ((f + "_") + g) |
---|
9 | | - | [DataEntry(("gameId_" + f), h), DataEntry(("opponent_" + f), g), DataEntry(("gameId_" + g), h), DataEntry(("opponent_" + g), f), DataEntry(("game_" + h), true), DataEntry(("gameTurn_" + h), f), DataEntry(("gameWinner_" + h), "")] |
---|
10 | | - | } |
---|
11 | | - | |
---|
12 | | - | |
---|
13 | | - | func i (b) = getStringValue(this, ("gameId_" + b)) |
---|
14 | | - | |
---|
15 | | - | |
---|
16 | | - | func j (k) = { |
---|
17 | | - | let l = (k / 628318) |
---|
18 | | - | if ((0 > k)) |
---|
19 | | - | then { |
---|
20 | | - | let m = -(k) |
---|
21 | | - | if ((m > 628318)) |
---|
22 | | - | then { |
---|
23 | | - | let n = (m + (l * 628318)) |
---|
24 | | - | if ((n > 314159)) |
---|
25 | | - | then { |
---|
26 | | - | let o = (n - 314159) |
---|
27 | | - | let p = ((16 * o) * (314159 - o)) |
---|
28 | | - | let q = (493480220050 - (p / 4)) |
---|
29 | | - | ((p * 100000) / q) |
---|
30 | | - | } |
---|
31 | | - | else { |
---|
32 | | - | let p = ((16 * n) * (314159 - n)) |
---|
33 | | - | let q = (493480220050 - (p / 4)) |
---|
34 | | - | ((-(p) * 100000) / q) |
---|
35 | | - | } |
---|
36 | | - | } |
---|
37 | | - | else if ((m > 314159)) |
---|
38 | | - | then { |
---|
39 | | - | let n = (m - 314159) |
---|
40 | | - | let p = ((16 * n) * (314159 - n)) |
---|
41 | | - | let q = (493480220050 - (p / 4)) |
---|
42 | | - | ((p * 100000) / q) |
---|
43 | | - | } |
---|
44 | | - | else { |
---|
45 | | - | let p = ((16 * m) * (314159 - m)) |
---|
46 | | - | let q = (493480220050 - (p / 4)) |
---|
47 | | - | ((-(p) * 100000) / q) |
---|
48 | | - | } |
---|
49 | | - | } |
---|
50 | | - | else if ((k > 628318)) |
---|
51 | | - | then { |
---|
52 | | - | let n = (k - (l * 628318)) |
---|
53 | | - | if ((n > 314159)) |
---|
54 | | - | then { |
---|
55 | | - | let o = (n - 314159) |
---|
56 | | - | let p = ((16 * o) * (314159 - o)) |
---|
57 | | - | let q = (493480220050 - (p / 4)) |
---|
58 | | - | ((-(p) * 100000) / q) |
---|
59 | | - | } |
---|
60 | | - | else { |
---|
61 | | - | let p = ((16 * n) * (314159 - n)) |
---|
62 | | - | let q = (493480220050 - (p / 4)) |
---|
63 | | - | ((p * 100000) / q) |
---|
64 | | - | } |
---|
65 | | - | } |
---|
66 | | - | else if ((k > 314159)) |
---|
67 | | - | then { |
---|
68 | | - | let n = (k - 314159) |
---|
69 | | - | let p = ((16 * n) * (314159 - n)) |
---|
70 | | - | let q = (493480220050 - (p / 4)) |
---|
71 | | - | ((-(p) * 100000) / q) |
---|
72 | | - | } |
---|
73 | | - | else { |
---|
74 | | - | let p = ((16 * k) * (314159 - k)) |
---|
75 | | - | let q = (493480220050 - (p / 4)) |
---|
76 | | - | ((p * 100000) / q) |
---|
77 | | - | } |
---|
78 | | - | } |
---|
79 | | - | |
---|
80 | | - | |
---|
81 | | - | func r (k) = j((157079 - k)) |
---|
82 | | - | |
---|
83 | | - | |
---|
84 | | - | func s (t) = if (if ((-100000 > t)) |
---|
85 | | - | then true |
---|
86 | | - | else (t > 100000)) |
---|
87 | | - | then throw("The asin implementation is defined for x [-1,1]!") |
---|
88 | | - | else if ((0 > t)) |
---|
89 | | - | then { |
---|
90 | | - | let u = (-1 * t) |
---|
91 | | - | let v = ((((((-1873 * u) / 100000) + 7426) * u) / 100000) - 21211) |
---|
92 | | - | let w = (((v * u) / 100000) + 157072) |
---|
93 | | - | let x = pow((100000 - u), 5, 5, 1, 5, HALFEVEN) |
---|
94 | | - | -((157080 - ((x * w) / 100000))) |
---|
95 | | - | } |
---|
96 | | - | else { |
---|
97 | | - | let y = (((-1873 * t) / 100000) + 7426) |
---|
98 | | - | let v = (((y * t) / 100000) - 21211) |
---|
99 | | - | let w = (((v * t) / 100000) + 157072) |
---|
100 | | - | let x = pow((100000 - t), 5, 5, 1, 5, HALFEVEN) |
---|
101 | | - | (157080 - ((x * w) / 100000)) |
---|
102 | | - | } |
---|
103 | | - | |
---|
104 | | - | |
---|
105 | | - | func z (t) = { |
---|
106 | | - | let A = ((t * t) / 100000) |
---|
107 | | - | if ((-100000 > t)) |
---|
108 | | - | then (-157079 - ((t * 100000) / (A + 28000))) |
---|
109 | | - | else if ((t > 100000)) |
---|
110 | | - | then (157079 - ((t * 100000) / (A + 28000))) |
---|
111 | | - | else ((t * 100000) / (100000 + ((28000 * A) / 100000))) |
---|
112 | | - | } |
---|
113 | | - | |
---|
114 | | - | |
---|
115 | | - | func B (C,t) = if ((t > 0)) |
---|
116 | | - | then z(((C * 100000) / t)) |
---|
117 | | - | else if (if ((0 > t)) |
---|
118 | | - | then (C >= 0) |
---|
119 | | - | else false) |
---|
120 | | - | then (z(((C * 100000) / t)) + 314159) |
---|
121 | | - | else if (if ((0 > t)) |
---|
122 | | - | then (0 > C) |
---|
123 | | - | else false) |
---|
124 | | - | then (z(((C * 100000) / t)) - 314159) |
---|
125 | | - | else if (if ((t == 0)) |
---|
126 | | - | then (C > 0) |
---|
127 | | - | else false) |
---|
128 | | - | then 157080 |
---|
129 | | - | else if (if ((t == 0)) |
---|
130 | | - | then (0 > C) |
---|
131 | | - | else false) |
---|
132 | | - | then -157080 |
---|
133 | | - | else 0 |
---|
134 | | - | |
---|
135 | | - | |
---|
136 | | - | func D (E,F) = (((2 * E) * ((r(F) * j(F)) / 100000)) / 980665) |
---|
137 | | - | |
---|
138 | | - | |
---|
139 | | - | func G (H,I,J,K) = { |
---|
140 | | - | let L = (H - J) |
---|
141 | | - | let M = (I - K) |
---|
142 | | - | let N = j((L / 2)) |
---|
143 | | - | let O = j((M / 2)) |
---|
144 | | - | let P = ((N * N) + (((r(H) * r(J)) / 100000) * ((O * O) / 100000))) |
---|
145 | | - | let Q = (2 * s(pow((P / 1000), 7, 5, 1, 5, HALFEVEN))) |
---|
146 | | - | ((637100000000 * Q) / 100000) |
---|
147 | | - | } |
---|
148 | | - | |
---|
149 | | - | |
---|
150 | | - | func R (S,T,U,V) = { |
---|
151 | | - | let W = (U / 6371000) |
---|
152 | | - | let X = j(S) |
---|
153 | | - | let Y = r(S) |
---|
154 | | - | let Z = j(W) |
---|
155 | | - | let aa = r(W) |
---|
156 | | - | let ab = s((((X * aa) / 100000) + (((Y * Z) * r(V)) / 10000000000))) |
---|
157 | | - | let ac = (T + B((((j(V) * Z) * Y) / 10000000000), (aa - ((X * X) / 100000)))) |
---|
158 | | - | [ab, ac] |
---|
159 | | - | } |
---|
160 | | - | |
---|
161 | | - | |
---|
162 | | - | func ad (F,V,ae,f,g) = { |
---|
163 | | - | let af = getIntegerValue(this, ("positionLat_" + f)) |
---|
164 | | - | let ag = getIntegerValue(this, ("positionLon_" + f)) |
---|
165 | | - | let ah = getIntegerValue(this, ("positionLat_" + g)) |
---|
166 | | - | let ai = getIntegerValue(this, ("positionLon_" + g)) |
---|
167 | | - | let aj = G(af, ag, ah, ai) |
---|
168 | | - | let ak = ((aj * 980665) / 100000) |
---|
169 | | - | let al = D(((ak * ae) / 100000), F) |
---|
170 | | - | let am = R(af, ag, al, V) |
---|
171 | | - | let an = G(am[0], am[1], ah, ai) |
---|
172 | | - | an :: am |
---|
173 | | - | } |
---|
174 | | - | |
---|
175 | | - | |
---|
176 | | - | func ao (H,I,J,K) = { |
---|
177 | | - | let M = (K - I) |
---|
178 | | - | let C = ((j(M) * r(J)) / 100000) |
---|
179 | | - | let t = (((r(H) * j(J)) - (((j(H) * r(J)) * r(M)) / 100000)) / 100000) |
---|
180 | | - | ((B(C, t) + 628318) % 628318) |
---|
181 | | - | } |
---|
182 | | - | |
---|
183 | | - | |
---|
184 | | - | @Callable(ap) |
---|
185 | | - | func startGame (c,d) = { |
---|
186 | | - | let aq = base58'' |
---|
187 | | - | let ar = toString(ap.caller) |
---|
188 | | - | let ah = ((c * 1745) / 100000) |
---|
189 | | - | let ai = ((d * 1745) / 100000) |
---|
190 | | - | let as = a(ar, ah, ai) |
---|
191 | | - | let at = getString(this, "openGame") |
---|
192 | | - | if (true) |
---|
193 | | - | then { |
---|
194 | | - | let h = getString(this, ("gameId_" + ar)) |
---|
195 | | - | if (if ((h != "")) |
---|
196 | | - | then (h != unit) |
---|
197 | | - | else false) |
---|
198 | | - | then throw("Please finish your current game, before starting another one") |
---|
199 | | - | else if (!(isDefined(at))) |
---|
200 | | - | then WriteSet(DataEntry("openGame", ar) :: as) |
---|
201 | | - | else if (if ((at == "")) |
---|
202 | | - | then true |
---|
203 | | - | else (at == ar)) |
---|
204 | | - | then WriteSet(DataEntry("openGame", ar) :: as) |
---|
205 | | - | else { |
---|
206 | | - | let af = getIntegerValue(this, ("positionLat_" + value(at))) |
---|
207 | | - | let ag = getIntegerValue(this, ("positionLon_" + value(at))) |
---|
208 | | - | let aj = G(af, ag, ah, ai) |
---|
209 | | - | let au = sha256(toBytes(aj)) |
---|
210 | | - | let av = toInt(au) |
---|
211 | | - | let aw = ((av % (628318 / 4)) - (628318 / 8)) |
---|
212 | | - | let ax = ao(af, ag, ah, ai) |
---|
213 | | - | let ay = (ax + aw) |
---|
214 | | - | let az = ((ax + 314159) % 628318) |
---|
215 | | - | let aA = (az + aw) |
---|
216 | | - | WriteSet([DataEntry("openGame", ""), as[0], as[1], DataEntry(("opponentOffsetYaw_" + ar), ay), DataEntry(("opponentOffsetYaw_" + value(at)), aA), e(value(at), ar)]) |
---|
217 | | - | } |
---|
218 | | - | } |
---|
219 | | - | else throw("Please pay the token") |
---|
220 | | - | } |
---|
221 | | - | |
---|
222 | | - | |
---|
223 | | - | |
---|
224 | | - | @Callable(ap) |
---|
225 | | - | func executeShot (F,V,ae) = { |
---|
226 | | - | let aq = base58'' |
---|
227 | | - | let ar = toString(ap.caller) |
---|
228 | | - | let aB = getStringValue(this, ("opponent_" + ar)) |
---|
229 | | - | let h = i(ar) |
---|
230 | | - | if ((getStringValue(this, ("gameTurn_" + h)) != ar)) |
---|
231 | | - | then throw("Please wait for your turn.") |
---|
232 | | - | else { |
---|
233 | | - | let aC = ad(F, V, ae, ar, aB) |
---|
234 | | - | if ((1000 > aC[0])) |
---|
235 | | - | then ScriptResult(WriteSet([DataEntry(("game_" + h), false), DataEntry(("gameWinner_" + h), ar), DataEntry(("lastShotDistance_" + h), aC[0]), DataEntry(("lastShotLat_" + h), aC[1]), DataEntry(("lastShotLon_" + h), aC[2])]), TransferSet([ScriptTransfer(ap.caller, 2, aq)])) |
---|
236 | | - | else WriteSet([DataEntry(("gameTurn_" + h), aB), DataEntry(("lastShotDistance_" + h), aC[0]), DataEntry(("lastShotLat_" + h), aC[1]), DataEntry(("lastShotLon_" + h), aC[2])]) |
---|
237 | | - | } |
---|
238 | | - | } |
---|
239 | | - | |
---|
240 | | - | |
---|
241 | | - | |
---|
242 | | - | @Callable(ap) |
---|
243 | | - | func faucet () = { |
---|
244 | | - | let aq = base58'' |
---|
245 | | - | let ar = toString(ap.caller) |
---|
246 | | - | let aD = assetBalance(ap.caller, aq) |
---|
247 | | - | if ((100 > aD)) |
---|
248 | | - | then TransferSet([ScriptTransfer(ap.caller, 100, aq)]) |
---|
249 | | - | else TransferSet(nil) |
---|
250 | | - | } |
---|
| 6 | + | @Callable(a) |
---|
| 7 | + | func foo () = WriteSet([DataEntry("game_3Mv8VUoVKevJodzBJKsqHEdrheDruTeNcye_3MrNfXqiSnnzQJwK2PBDYJDsVSJZndo3GQF", true)]) |
---|