tx · 2QYYTQAR5axoMyvNPMMm4PAuqWvUP8WNpfrSUZ8twTUb

3N1x2A7NumZqydu5zGntLZSMe26rcpdyoss:  -0.04000000 Waves

2020.08.26 15:44 [1149693] smart account 3N1x2A7NumZqydu5zGntLZSMe26rcpdyoss > SELF 0.00000000 Waves

{ "type": 13, "id": "2QYYTQAR5axoMyvNPMMm4PAuqWvUP8WNpfrSUZ8twTUb", "fee": 4000000, "feeAssetId": null, "timestamp": 1598445893422, "version": 1, "sender": "3N1x2A7NumZqydu5zGntLZSMe26rcpdyoss", "senderPublicKey": "7EaUr5Z6zmEQJXz7jVWXjW7xbJLakPjxFPTZFogi8wzr", "proofs": [ "pHS3aiBGn2K5g9iHSG5JRKR9w3M1xVrggdDhQrtrvkzXsnaccHLMeEoviDREe5QvCJVAxtsqkN6XJ8dCJqKmWKS" ], "script": "base64:AAIDAAAAAAAAAAQIARIAAAAAAAAAAAEAAAABaQEAAAADZm9vAAAAAAkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgIAAABMZ2FtZV8zTXY4VlVvVktldkpvZHpCSktzcUhFZHJoZURydVRlTmN5ZV8zTXJOZlhxaVNubnpRSndLMlBCRFlKRHNWU0pabmRvM0dRRgYFAAAAA25pbAAAAABHs7E+", "chainId": 84, "height": 1149693, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5tPGSMbmBTC8mGdJAMqYynkEb2iPUxeGuaXrCyvjNZVK Next: BhnK7tKoRwn3iLvA91GZRWVEiJbSWfqcjYT4soshgwVD Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-func setCoords (key,latitude,longitude) = [DataEntry(("positionLat_" + key), latitude), DataEntry(("positionLon_" + key), longitude)]
5-
6-
7-func setGameData (playerKey,opponentKey) = {
8- let gameId = ((playerKey + "_") + opponentKey)
9-[DataEntry(("gameId_" + playerKey), gameId), DataEntry(("opponent_" + playerKey), opponentKey), DataEntry(("gameId_" + opponentKey), gameId), DataEntry(("opponent_" + opponentKey), playerKey), DataEntry(("game_" + gameId), true), DataEntry(("gameTurn_" + gameId), playerKey), DataEntry(("gameWinner_" + gameId), "")]
10- }
11-
12-
13-func getGameId (key) = getStringValue(this, ("gameId_" + key))
14-
15-
16-func sin (rad) = {
17- let factor = (rad / 628318)
18- if ((0 > rad))
19- then {
20- let positive = -(rad)
21- if ((positive > 628318))
22- then {
23- let norm = (positive + (factor * 628318))
24- if ((norm > 314159))
25- then {
26- let norm2 = (norm - 314159)
27- let a = ((16 * norm2) * (314159 - norm2))
28- let b = (493480220050 - (a / 4))
29- ((a * 100000) / b)
30- }
31- else {
32- let a = ((16 * norm) * (314159 - norm))
33- let b = (493480220050 - (a / 4))
34- ((-(a) * 100000) / b)
35- }
36- }
37- else if ((positive > 314159))
38- then {
39- let norm = (positive - 314159)
40- let a = ((16 * norm) * (314159 - norm))
41- let b = (493480220050 - (a / 4))
42- ((a * 100000) / b)
43- }
44- else {
45- let a = ((16 * positive) * (314159 - positive))
46- let b = (493480220050 - (a / 4))
47- ((-(a) * 100000) / b)
48- }
49- }
50- else if ((rad > 628318))
51- then {
52- let norm = (rad - (factor * 628318))
53- if ((norm > 314159))
54- then {
55- let norm2 = (norm - 314159)
56- let a = ((16 * norm2) * (314159 - norm2))
57- let b = (493480220050 - (a / 4))
58- ((-(a) * 100000) / b)
59- }
60- else {
61- let a = ((16 * norm) * (314159 - norm))
62- let b = (493480220050 - (a / 4))
63- ((a * 100000) / b)
64- }
65- }
66- else if ((rad > 314159))
67- then {
68- let norm = (rad - 314159)
69- let a = ((16 * norm) * (314159 - norm))
70- let b = (493480220050 - (a / 4))
71- ((-(a) * 100000) / b)
72- }
73- else {
74- let a = ((16 * rad) * (314159 - rad))
75- let b = (493480220050 - (a / 4))
76- ((a * 100000) / b)
77- }
78- }
79-
80-
81-func cos (rad) = sin((157079 - rad))
82-
83-
84-func asin (x) = if (if ((-100000 > x))
85- then true
86- else (x > 100000))
87- then throw("The asin implementation is defined for x [-1,1]!")
88- else if ((0 > x))
89- then {
90- let x1 = (-1 * x)
91- let val4 = ((((((-1873 * x1) / 100000) + 7426) * x1) / 100000) - 21211)
92- let val6 = (((val4 * x1) / 100000) + 157072)
93- let root = pow((100000 - x1), 5, 5, 1, 5, HALFEVEN)
94- -((157080 - ((root * val6) / 100000)))
95- }
96- else {
97- let val2 = (((-1873 * x) / 100000) + 7426)
98- let val4 = (((val2 * x) / 100000) - 21211)
99- let val6 = (((val4 * x) / 100000) + 157072)
100- let root = pow((100000 - x), 5, 5, 1, 5, HALFEVEN)
101- (157080 - ((root * val6) / 100000))
102- }
103-
104-
105-func atan (x) = {
106- let xPow2 = ((x * x) / 100000)
107- if ((-100000 > x))
108- then (-157079 - ((x * 100000) / (xPow2 + 28000)))
109- else if ((x > 100000))
110- then (157079 - ((x * 100000) / (xPow2 + 28000)))
111- else ((x * 100000) / (100000 + ((28000 * xPow2) / 100000)))
112- }
113-
114-
115-func atan2 (y,x) = if ((x > 0))
116- then atan(((y * 100000) / x))
117- else if (if ((0 > x))
118- then (y >= 0)
119- else false)
120- then (atan(((y * 100000) / x)) + 314159)
121- else if (if ((0 > x))
122- then (0 > y)
123- else false)
124- then (atan(((y * 100000) / x)) - 314159)
125- else if (if ((x == 0))
126- then (y > 0)
127- else false)
128- then 157080
129- else if (if ((x == 0))
130- then (0 > y)
131- else false)
132- then -157080
133- else 0
134-
135-
136-func calculateShotDistance (v,pitch) = (((2 * v) * ((cos(pitch) * sin(pitch)) / 100000)) / 980665)
137-
138-
139-func gpsDistance (lat1,lon1,lat2,lon2) = {
140- let dLat = (lat1 - lat2)
141- let dLon = (lon1 - lon2)
142- let dLatSin = sin((dLat / 2))
143- let dLonSin = sin((dLon / 2))
144- let hav = ((dLatSin * dLatSin) + (((cos(lat1) * cos(lat2)) / 100000) * ((dLonSin * dLonSin) / 100000)))
145- let theta = (2 * asin(pow((hav / 1000), 7, 5, 1, 5, HALFEVEN)))
146- ((637100000000 * theta) / 100000)
147- }
148-
149-
150-func calculateImpactPosition (lat,lon,dist,yaw) = {
151- let th = (dist / 6371000)
152- let sinLat = sin(lat)
153- let cosLat = cos(lat)
154- let sinTh = sin(th)
155- let cosTh = cos(th)
156- let newLat = asin((((sinLat * cosTh) / 100000) + (((cosLat * sinTh) * cos(yaw)) / 10000000000)))
157- let newLon = (lon + atan2((((sin(yaw) * sinTh) * cosLat) / 10000000000), (cosTh - ((sinLat * sinLat) / 100000))))
158-[newLat, newLon]
159- }
160-
161-
162-func calculateShot (pitch,yaw,force,playerKey,opponentKey) = {
163- let playerLatitude = getIntegerValue(this, ("positionLat_" + playerKey))
164- let playerLongitude = getIntegerValue(this, ("positionLon_" + playerKey))
165- let opponentLatitude = getIntegerValue(this, ("positionLat_" + opponentKey))
166- let opponentLongitude = getIntegerValue(this, ("positionLon_" + opponentKey))
167- let distanceBetweenPlayers = gpsDistance(playerLatitude, playerLongitude, opponentLatitude, opponentLongitude)
168- let optimalVelocity = ((distanceBetweenPlayers * 980665) / 100000)
169- let playerShotReach = calculateShotDistance(((optimalVelocity * force) / 100000), pitch)
170- let impactPosition = calculateImpactPosition(playerLatitude, playerLongitude, playerShotReach, yaw)
171- let impactDistance = gpsDistance(impactPosition[0], impactPosition[1], opponentLatitude, opponentLongitude)
172-impactDistance :: impactPosition
173- }
174-
175-
176-func coordinatesToAngleInRad (lat1,lon1,lat2,lon2) = {
177- let dLon = (lon2 - lon1)
178- let y = ((sin(dLon) * cos(lat2)) / 100000)
179- let x = (((cos(lat1) * sin(lat2)) - (((sin(lat1) * cos(lat2)) * cos(dLon)) / 100000)) / 100000)
180- ((atan2(y, x) + 628318) % 628318)
181- }
1824
1835
1846 @Callable(i)
185-func startGame (latitude,longitude) = {
186- let asset = base58''
187- let caller = toString(i.caller)
188- let opponentLatitude = ((latitude * 1745) / 100000)
189- let opponentLongitude = ((longitude * 1745) / 100000)
190- let coordinates = setCoords(caller, opponentLatitude, opponentLongitude)
191- let openGame = getString(this, "openGame")
192- if (true)
193- then {
194- let gameId = getString(this, ("gameId_" + caller))
195- if (if ((gameId != ""))
196- then (gameId != unit)
197- else false)
198- then throw("Please finish your current game, before starting another one")
199- else if (!(isDefined(openGame)))
200- then WriteSet(DataEntry("openGame", caller) :: coordinates)
201- else if (if ((openGame == ""))
202- then true
203- else (openGame == caller))
204- then WriteSet(DataEntry("openGame", caller) :: coordinates)
205- else {
206- let playerLatitude = getIntegerValue(this, ("positionLat_" + value(openGame)))
207- let playerLongitude = getIntegerValue(this, ("positionLon_" + value(openGame)))
208- let distanceBetweenPlayers = gpsDistance(playerLatitude, playerLongitude, opponentLatitude, opponentLongitude)
209- let hash = sha256(toBytes(distanceBetweenPlayers))
210- let number = toInt(hash)
211- let offset = ((number % (628318 / 4)) - (628318 / 8))
212- let playerYaw = coordinatesToAngleInRad(playerLatitude, playerLongitude, opponentLatitude, opponentLongitude)
213- let playerOffsetYaw = (playerYaw + offset)
214- let opponentYaw = ((playerYaw + 314159) % 628318)
215- let opponentOffsetYaw = (opponentYaw + offset)
216- WriteSet([DataEntry("openGame", ""), coordinates[0], coordinates[1], DataEntry(("opponentOffsetYaw_" + caller), playerOffsetYaw), DataEntry(("opponentOffsetYaw_" + value(openGame)), opponentOffsetYaw), setGameData(value(openGame), caller)])
217- }
218- }
219- else throw("Please pay the token")
220- }
221-
222-
223-
224-@Callable(i)
225-func executeShot (pitch,yaw,force) = {
226- let asset = base58''
227- let caller = toString(i.caller)
228- let opponent = getStringValue(this, ("opponent_" + caller))
229- let gameId = getGameId(caller)
230- if ((getStringValue(this, ("gameTurn_" + gameId)) != caller))
231- then throw("Please wait for your turn.")
232- else {
233- let shotData = calculateShot(pitch, yaw, force, caller, opponent)
234- if ((1000 > shotData[0]))
235- then ScriptResult(WriteSet([DataEntry(("game_" + gameId), false), DataEntry(("gameWinner_" + gameId), caller), DataEntry(("lastShotDistance_" + gameId), shotData[0]), DataEntry(("lastShotLat_" + gameId), shotData[1]), DataEntry(("lastShotLon_" + gameId), shotData[2])]), TransferSet([ScriptTransfer(i.caller, 2, asset)]))
236- else WriteSet([DataEntry(("gameTurn_" + gameId), opponent), DataEntry(("lastShotDistance_" + gameId), shotData[0]), DataEntry(("lastShotLat_" + gameId), shotData[1]), DataEntry(("lastShotLon_" + gameId), shotData[2])])
237- }
238- }
239-
240-
241-
242-@Callable(i)
243-func faucet () = {
244- let asset = base58''
245- let caller = toString(i.caller)
246- let balance = assetBalance(i.caller, asset)
247- if ((100 > balance))
248- then TransferSet([ScriptTransfer(i.caller, 100, asset)])
249- else TransferSet(nil)
250- }
7+func foo () = WriteSet([DataEntry("game_3Mv8VUoVKevJodzBJKsqHEdrheDruTeNcye_3MrNfXqiSnnzQJwK2PBDYJDsVSJZndo3GQF", true)])
2518
2529

github/deemru/w8io/3ef1775 
50.97 ms