tx · 2gUwao5dwrzJgAU8UGJ53p7oJGDRo3W5QUkrbRbpPW2c 3N2iycpXC7Fomf1vYLmz9uUWwLR2ZvxRCyw: -0.00700000 Waves 2023.03.23 07:04 [2502162] smart account 3N2iycpXC7Fomf1vYLmz9uUWwLR2ZvxRCyw > SELF 0.00000000 Waves
{ "type": 13, "id": "2gUwao5dwrzJgAU8UGJ53p7oJGDRo3W5QUkrbRbpPW2c", "fee": 700000, "feeAssetId": null, "timestamp": 1679544408991, "version": 2, "chainId": 84, "sender": "3N2iycpXC7Fomf1vYLmz9uUWwLR2ZvxRCyw", "senderPublicKey": "3TJ91ZMX9cHrPAcqCiYodSdxYs8AiLNHyvRJNK1PDc6i", "proofs": [ "qwPCW4m4tYKH6tNfPnkiXqWKmyjny9ZYbVc45XFj5JxupxcAcoA6hAAADCAfcH8Qriizuaa81k33u9MivFubDdT" ], "script": "base64:BgIcCAISABIDCgEIEgUKAwEBCBIDCgEBEgASAwoBCAUABkF1cnVlcwEgOYDtDd1mVUaSfSlX4MdFqsCgGC27Z5CEtJGKkGOZYFwBCW9ubHlPd25lcgEBaQMJAAACCAUEdGhpcwVieXRlcwgIBQFpBmNhbGxlcgVieXRlcwUEdW5pdAkAAgECKU9ubHkgZGFwcCBhY2NvdW50IGNhbiBjYWxsIHRoaXMgZnVuY3Rpb24hARBnZXRBdXJ1ZXNQYXltZW50AQFpAwkAAAIJAJADAQgFAWkIcGF5bWVudHMAAAkAAgECFFBheW1lbnQgbm90IGF0dGFjaGVkBAFwCQCRAwIIBQFpCHBheW1lbnRzAAAEByRtYXRjaDAIBQFwB2Fzc2V0SWQDCQABAgUHJG1hdGNoMAIKQnl0ZVZlY3RvcgQHYXNzZXRJZAUHJG1hdGNoMAMJAAACBQdhc3NldElkBQZBdXJ1ZXMIBQFwBmFtb3VudAkAAgECIE9ubHkgYXVydWVzIGFjY2VwdGVkIGFzIHBheW1lbnQhCQACAQIgT25seSBhdXJ1ZXMgYWNjZXB0ZWQgYXMgcGF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AEHYXNzZXRJZAQFb3duZXIJARFAZXh0ck5hdGl2ZSgxMDUzKQIFBHRoaXMFB2Fzc2V0SWQDCQAAAgkA2QQBBQVvd25lcggIBQFpBmNhbGxlcgVieXRlcwQHJG1hdGNoMAkA7AcBCQDZBAEFB2Fzc2V0SWQDCQABAgUHJG1hdGNoMAIFQXNzZXQEBWFzc2V0BQckbWF0Y2gwBANrZXkJAQtnZXRBc3NldEtleQEIBQVhc3NldARuYW1lBAdhZGRyZXNzCQDYBAEICAUBaQZjYWxsZXIFYnl0ZXMECGFzc2V0Q250CQERQGV4dHJOYXRpdmUoMTA1MCkCBQR0aGlzCQCsAgIFB2FkZHJlc3MFA2tleQMJAGYCBQhhc3NldENudAAACQCUCgIJAMwIAgkBC0RlbGV0ZUVudHJ5AQUHYXNzZXRJZAkAzAgCCQEMSW50ZWdlckVudHJ5AgkArAICBQdhZGRyZXNzBQNrZXkJAGUCBQhhc3NldENudAABBQNuaWwFBHVuaXQJAAIBCQCsAgIJAKwCAgIEQWxsIAgFBWFzc2V0BG5hbWUCFSBhcmUgbG9jayBpbnNpZGUgZ2FtZQkAAgECEENhbid0IGZpbmQgYXNzZXQJAAIBAiBZb3UgYXJlIG5vdCBvd25lciBvZiB0aGlzIGFzc2V0IQBxng/X", "height": 2502162, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CJxBMuAL2KQRwrwrGw3W9AA6PpppM6jmtUv6GeUp1iwa Next: none Diff:
Old | New | Differences | |
---|---|---|---|
26 | 26 | func getAssetData (assetId) = if ((assetId == 0)) | |
27 | 27 | then $Tuple4("Miner", "Utility building that helps you to mine aurues at certain blovk height.", 30000, "__miner") | |
28 | 28 | else if ((assetId == 1)) | |
29 | - | then $Tuple4("Canon", " | |
29 | + | then $Tuple4("Canon", "Most powerful attacker building.", 25000, "_canon") | |
30 | 30 | else if ((assetId == 2)) | |
31 | - | then $Tuple4("Xbow", " | |
31 | + | then $Tuple4("Xbow", "Most fast attacker building.", 15000, "_xbow") | |
32 | 32 | else if ((assetId == 3)) | |
33 | - | then $Tuple4("Tesla", " | |
33 | + | then $Tuple4("Tesla", "Best attacker building for short range distance", 20000, "_tesla") | |
34 | 34 | else if ((assetId == 4)) | |
35 | 35 | then throw("You can't buy townhall!") | |
36 | 36 | else if ((assetId == 5)) | |
37 | - | then $Tuple4("Archer", " | |
37 | + | then $Tuple4("Archer", "They are fast runner and fast attacker.", 4500, "_archer") | |
38 | 38 | else if ((assetId == 6)) | |
39 | - | then $Tuple4("Robot", " | |
39 | + | then $Tuple4("Robot", "Most advanced attackers which drills down the buildings", 5500, "_robo") | |
40 | 40 | else if ((assetId == 7)) | |
41 | - | then $Tuple4("Valkyriee", " | |
41 | + | then $Tuple4("Valkyriee", "Most dangerous attacker.", 6000, "_valkyriee") | |
42 | 42 | else throw("Unkown assetId!") | |
43 | 43 | ||
44 | 44 | ||
119 | 119 | func buy (assetId) = { | |
120 | 120 | let address = toBase58String(i.caller.bytes) | |
121 | 121 | let auruesAmount = getAuruesPayment(i) | |
122 | - | let $ | |
123 | - | let name = $ | |
124 | - | let description = $ | |
125 | - | let price = $ | |
126 | - | let key = $ | |
122 | + | let $t070077066 = getAssetData(assetId) | |
123 | + | let name = $t070077066._1 | |
124 | + | let description = $t070077066._2 | |
125 | + | let price = $t070077066._3 | |
126 | + | let key = $t070077066._4 | |
127 | 127 | if ((auruesAmount >= price)) | |
128 | 128 | then { | |
129 | 129 | let currentCnt = getIntegerValue(this, (address + key)) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let Aurues = base58'4sUGAwEDLVm6Z3sNbLapWXtEtMkhRU8fypam9dLT4UjM' | |
5 | 5 | ||
6 | 6 | func onlyOwner (i) = if ((this.bytes == i.caller.bytes)) | |
7 | 7 | then unit | |
8 | 8 | else throw("Only dapp account can call this function!") | |
9 | 9 | ||
10 | 10 | ||
11 | 11 | func getAuruesPayment (i) = if ((size(i.payments) == 0)) | |
12 | 12 | then throw("Payment not attached") | |
13 | 13 | else { | |
14 | 14 | let p = i.payments[0] | |
15 | 15 | match p.assetId { | |
16 | 16 | case assetId: ByteVector => | |
17 | 17 | if ((assetId == Aurues)) | |
18 | 18 | then p.amount | |
19 | 19 | else throw("Only aurues accepted as payment!") | |
20 | 20 | case _ => | |
21 | 21 | throw("Only aurues accepted as payment!") | |
22 | 22 | } | |
23 | 23 | } | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func getAssetData (assetId) = if ((assetId == 0)) | |
27 | 27 | then $Tuple4("Miner", "Utility building that helps you to mine aurues at certain blovk height.", 30000, "__miner") | |
28 | 28 | else if ((assetId == 1)) | |
29 | - | then $Tuple4("Canon", " | |
29 | + | then $Tuple4("Canon", "Most powerful attacker building.", 25000, "_canon") | |
30 | 30 | else if ((assetId == 2)) | |
31 | - | then $Tuple4("Xbow", " | |
31 | + | then $Tuple4("Xbow", "Most fast attacker building.", 15000, "_xbow") | |
32 | 32 | else if ((assetId == 3)) | |
33 | - | then $Tuple4("Tesla", " | |
33 | + | then $Tuple4("Tesla", "Best attacker building for short range distance", 20000, "_tesla") | |
34 | 34 | else if ((assetId == 4)) | |
35 | 35 | then throw("You can't buy townhall!") | |
36 | 36 | else if ((assetId == 5)) | |
37 | - | then $Tuple4("Archer", " | |
37 | + | then $Tuple4("Archer", "They are fast runner and fast attacker.", 4500, "_archer") | |
38 | 38 | else if ((assetId == 6)) | |
39 | - | then $Tuple4("Robot", " | |
39 | + | then $Tuple4("Robot", "Most advanced attackers which drills down the buildings", 5500, "_robo") | |
40 | 40 | else if ((assetId == 7)) | |
41 | - | then $Tuple4("Valkyriee", " | |
41 | + | then $Tuple4("Valkyriee", "Most dangerous attacker.", 6000, "_valkyriee") | |
42 | 42 | else throw("Unkown assetId!") | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func getAssetKey (name) = if ((name == "Miner")) | |
46 | 46 | then "__miner" | |
47 | 47 | else if ((name == "Canon")) | |
48 | 48 | then "_canon" | |
49 | 49 | else if ((name == "Xbow")) | |
50 | 50 | then "_xbow" | |
51 | 51 | else if ((name == "Tesla")) | |
52 | 52 | then "_tesla" | |
53 | 53 | else if ((name == "Townhall")) | |
54 | 54 | then throw("You can't add or remove townhall!") | |
55 | 55 | else if ((name == "Archer")) | |
56 | 56 | then "_archer" | |
57 | 57 | else if ((name == "Robot")) | |
58 | 58 | then "_robo" | |
59 | 59 | else if ((name == "Valkyriee")) | |
60 | 60 | then "_valkyriee" | |
61 | 61 | else throw("Unkown Asset!") | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | @Callable(i) | |
65 | 65 | func startGame () = { | |
66 | 66 | let address = toBase58String(i.caller.bytes) | |
67 | 67 | let gameStateKey = (address + "_isStrted") | |
68 | 68 | if ((getBoolean(this, gameStateKey) == unit)) | |
69 | 69 | then { | |
70 | 70 | let userId = match getInteger(this, "userId") { | |
71 | 71 | case x: Int => | |
72 | 72 | (x + 1) | |
73 | 73 | case _ => | |
74 | 74 | 0 | |
75 | 75 | } | |
76 | 76 | let thIssue = Issue("Townhall", "HQ of your empire", 1, 0, false) | |
77 | 77 | let thAssetId = toBase58String(calculateAssetId(thIssue)) | |
78 | 78 | $Tuple2([BooleanEntry(gameStateKey, true), Reissue(Aurues, 100000, true), ScriptTransfer(i.caller, 100000, Aurues), thIssue, ScriptTransfer(i.caller, 1, calculateAssetId(thIssue)), StringEntry(thAssetId, address), IntegerEntry("userId", userId), StringEntry(toString(userId), address), IntegerEntry((address + "_townhall"), 1), IntegerEntry((address + "_townhall_placed"), 0), IntegerEntry((address + "_miner"), 0), IntegerEntry((address + "_miner_placed"), 0), IntegerEntry((address + "_canon"), 0), IntegerEntry((address + "_canon_placed"), 0), IntegerEntry((address + "_xbow"), 0), IntegerEntry((address + "_xbow_placed"), 0), IntegerEntry((address + "_tesla"), 0), IntegerEntry((address + "_tesla_placed"), 0), IntegerEntry((address + "_archer"), 0), IntegerEntry((address + "_robo"), 0), IntegerEntry((address + "_valkyriee"), 0)], unit) | |
79 | 79 | } | |
80 | 80 | else throw("Game already started!") | |
81 | 81 | } | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | ||
85 | 85 | @Callable(i) | |
86 | 86 | func saveGame (data) = { | |
87 | 87 | let thCnt = (size(split_51C(data, "buildingIndex':4")) - 1) | |
88 | 88 | let minerCnt = (size(split_51C(data, "buildingIndex':0")) - 1) | |
89 | 89 | let canonCnt = (size(split_51C(data, "buildingIndex':1")) - 1) | |
90 | 90 | let xbowCnt = (size(split_51C(data, "buildingIndex':2")) - 1) | |
91 | 91 | let teslaCnt = (size(split_51C(data, "buildingIndex':3")) - 1) | |
92 | 92 | let address = toBase58String(i.caller.bytes) | |
93 | 93 | let thAva = (getIntegerValue(this, (address + "_townhall")) + getIntegerValue(this, (address + "_townhall_placed"))) | |
94 | 94 | let minerAva = (getIntegerValue(this, (address + "_miner")) + getIntegerValue(this, (address + "_miner_placed"))) | |
95 | 95 | let canonAva = (getIntegerValue(this, (address + "_canon")) + getIntegerValue(this, (address + "_canon_placed"))) | |
96 | 96 | let xbowAva = (getIntegerValue(this, (address + "_xbow")) + getIntegerValue(this, (address + "_xbow_placed"))) | |
97 | 97 | let teslaAva = (getIntegerValue(this, (address + "_tesla")) + getIntegerValue(this, (address + "_tesla_placed"))) | |
98 | 98 | if (if (if (if (if ((thAva >= thCnt)) | |
99 | 99 | then (minerAva >= minerCnt) | |
100 | 100 | else false) | |
101 | 101 | then (canonAva >= canonCnt) | |
102 | 102 | else false) | |
103 | 103 | then (xbowAva >= xbowCnt) | |
104 | 104 | else false) | |
105 | 105 | then (teslaAva >= teslaCnt) | |
106 | 106 | else false) | |
107 | 107 | then $Tuple2([StringEntry((address + "_data"), data), IntegerEntry((address + "_townhall"), (thAva - thCnt)), IntegerEntry((address + "_townhall_placed"), thCnt), IntegerEntry((address + "_miner"), (minerAva - minerCnt)), IntegerEntry((address + "_miner_placed"), minerCnt), IntegerEntry((address + "_canon"), (canonAva - canonCnt)), IntegerEntry((address + "_canon_placed"), canonCnt), IntegerEntry((address + "_xbow"), (xbowAva - xbowCnt)), IntegerEntry((address + "_xbow_placed"), xbowCnt), IntegerEntry((address + "_tesla"), (teslaAva - teslaCnt)), IntegerEntry((address + "_tesla_placed"), teslaCnt)], unit) | |
108 | 108 | else throw("Placed more building then you owned!") | |
109 | 109 | } | |
110 | 110 | ||
111 | 111 | ||
112 | 112 | ||
113 | 113 | @Callable(i) | |
114 | 114 | func rewardWar (building,troops,opponent) = $Tuple2([Reissue(Aurues, ((building * 5000) + (troops * 2000)), true), ScriptTransfer(i.caller, (building * 5000), Aurues), ScriptTransfer(Address(fromBase58String(opponent)), (troops * 2000), Aurues)], unit) | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | ||
118 | 118 | @Callable(i) | |
119 | 119 | func buy (assetId) = { | |
120 | 120 | let address = toBase58String(i.caller.bytes) | |
121 | 121 | let auruesAmount = getAuruesPayment(i) | |
122 | - | let $ | |
123 | - | let name = $ | |
124 | - | let description = $ | |
125 | - | let price = $ | |
126 | - | let key = $ | |
122 | + | let $t070077066 = getAssetData(assetId) | |
123 | + | let name = $t070077066._1 | |
124 | + | let description = $t070077066._2 | |
125 | + | let price = $t070077066._3 | |
126 | + | let key = $t070077066._4 | |
127 | 127 | if ((auruesAmount >= price)) | |
128 | 128 | then { | |
129 | 129 | let currentCnt = getIntegerValue(this, (address + key)) | |
130 | 130 | let issue = Issue(name, description, 1, 0, false) | |
131 | 131 | let issuedAssetId = toBase58String(calculateAssetId(issue)) | |
132 | 132 | $Tuple2([issue, ScriptTransfer(i.caller, 1, calculateAssetId(issue)), Burn(Aurues, auruesAmount), IntegerEntry((address + key), (currentCnt + 1)), StringEntry(issuedAssetId, address)], unit) | |
133 | 133 | } | |
134 | 134 | else throw(("Not enough payment to buy " + name)) | |
135 | 135 | } | |
136 | 136 | ||
137 | 137 | ||
138 | 138 | ||
139 | 139 | @Callable(i) | |
140 | 140 | func addAsset () = if ((size(i.payments) == 0)) | |
141 | 141 | then throw("No NFT attached to this call!") | |
142 | 142 | else { | |
143 | 143 | let nft = i.payments[0] | |
144 | 144 | match nft.assetId { | |
145 | 145 | case assetId: ByteVector => | |
146 | 146 | match assetInfo(assetId) { | |
147 | 147 | case asset: Asset => | |
148 | 148 | if ((asset.issuer == this)) | |
149 | 149 | then if ((getString(this, toBase58String(assetId)) == unit)) | |
150 | 150 | then { | |
151 | 151 | let address = toBase58String(i.caller.bytes) | |
152 | 152 | let key = getAssetKey(asset.name) | |
153 | 153 | let assetCnt = getIntegerValue(this, (address + key)) | |
154 | 154 | $Tuple2([ScriptTransfer(Address(i.caller.bytes), 1, assetId), StringEntry(toBase58String(assetId), address), IntegerEntry((address + key), (assetCnt + 1))], unit) | |
155 | 155 | } | |
156 | 156 | else throw("Asset already added to game!") | |
157 | 157 | else throw("Wrong NFT sent!") | |
158 | 158 | case _ => | |
159 | 159 | throw("Can't find asset") | |
160 | 160 | } | |
161 | 161 | case _ => | |
162 | 162 | throw("Not able to find asset id!!") | |
163 | 163 | } | |
164 | 164 | } | |
165 | 165 | ||
166 | 166 | ||
167 | 167 | ||
168 | 168 | @Callable(i) | |
169 | 169 | func removeAsset (assetId) = { | |
170 | 170 | let owner = getStringValue(this, assetId) | |
171 | 171 | if ((fromBase58String(owner) == i.caller.bytes)) | |
172 | 172 | then match assetInfo(fromBase58String(assetId)) { | |
173 | 173 | case asset: Asset => | |
174 | 174 | let key = getAssetKey(asset.name) | |
175 | 175 | let address = toBase58String(i.caller.bytes) | |
176 | 176 | let assetCnt = getIntegerValue(this, (address + key)) | |
177 | 177 | if ((assetCnt > 0)) | |
178 | 178 | then $Tuple2([DeleteEntry(assetId), IntegerEntry((address + key), (assetCnt - 1))], unit) | |
179 | 179 | else throw((("All " + asset.name) + " are lock inside game")) | |
180 | 180 | case _ => | |
181 | 181 | throw("Can't find asset") | |
182 | 182 | } | |
183 | 183 | else throw("You are not owner of this asset!") | |
184 | 184 | } | |
185 | 185 | ||
186 | 186 |
github/deemru/w8io/026f985 42.28 ms ◑