| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | // ================= OBYSTACK ================= |
| 6 | // ============================================ |
| 7 | // OBYTE STACK GAME from Whistling Frogs |
| 8 | // ============================================ |
| 9 | // First published by Crypto Girl on 21 Sep 2019 |
| 10 | // ============================================ |
| 11 | // Version: 1.0 - 8 Oct 2019 |
| 12 | // ============================================ |
| 13 | // Can be used with OBYTE STACK GAME BOT v1.0 |
| 14 | // Pairing code: |
| 15 | // [email protected]/bb-test#StackGame |
| 16 | // ============================================ |
| 17 | // The object of the game is to win the Stack. |
| 18 | // Users make bids. Min bid is 100,000 bytes. |
| 19 | // 1st bid initiates the Stack. |
| 20 | // Each subsequent bid starts the 50 sec timer. |
| 21 | // If more than 50 sec has passed since the previous |
| 22 | // bid, the (stack - commission) is shared equally |
| 23 | // between the last bidder and the 1st bidder. |
| 24 | // The new stack is initiated with the current bid. |
| 25 | // A commission of 10,000 bytes is charged on each bid. |
| 26 | // ============================================ |
| 27 | // Visit https://whistling-frogs.herokuapp.com/obyStack |
| 28 | // for a full description of the game. |
| 29 | // ============================================ |
| 30 | // |
| 31 | // setting game parameters |
| 32 | $bot_address_back = 'QUONK7CUHPTGLNTZ6JE57SDVSFVDBCMM'; |
| 33 | $commission_payout_threshold = 50000; |
| 34 | $commission = 10000; |
| 35 | $seed_amnt = 10000; |
| 36 | $min_bid_amnt = 100000; |
| 37 | $fees = 1000; |
| 38 | // setting game variables |
| 39 | $bid_amnt = trigger.output[[asset=base]]; |
| 40 | $game_finished = (trigger.initial_address == $bot_address) otherwise false; |
| 41 | if ( ($game_finished == false) AND ($bid_amnt < $min_bid_amnt) ) bounce('Your bid is too small.'); |
| 42 | $game_status = var['game_status'] otherwise 'not started'; |
| 43 | }", |
| 44 | "messages": { |
| 45 | "cases": [ |
| 46 | { |
| 47 | "if": "{$game_finished == false AND $game_status == 'not started'}", |
| 48 | "messages": [ |
| 49 | { |
| 50 | "app": "state", |
| 51 | "state": "{ |
| 52 | var['stack_amnt'] = $bid_amnt - $commission; |
| 53 | var['commission_pot'] += $commission - $fees; |
| 54 | var['author'] = trigger.initial_address; |
| 55 | var['leader'] = trigger.initial_address; |
| 56 | var['game_status'] = 'running'; |
| 57 | response['message'] = 'Thank you for playing'; |
| 58 | }" |
| 59 | } |
| 60 | ] |
| 61 | }, |
| 62 | { |
| 63 | "if": "{$game_finished == false AND $game_status == 'running'}", |
| 64 | "messages": [ |
| 65 | { |
| 66 | "app": "state", |
| 67 | "state": "{ |
| 68 | var['stack_amnt'] += ($bid_amnt - $commission); |
| 69 | var['commission_pot'] += $commission; |
| 70 | var['leader'] = trigger.initial_address; |
| 71 | response['message'] = 'Thank you for playing'; |
| 72 | }" |
| 73 | } |
| 74 | ] |
| 75 | }, |
| 76 | { |
| 77 | "if": "{$game_finished}", |
| 78 | "messages": [ |
| 79 | { |
| 80 | "app": "payment", |
| 81 | "payload": { |
| 82 | "cases": [ |
| 83 | { |
| 84 | "if": "{(var['author'] == var['leader']) AND (var['commission_pot'] >= $commission_payout_threshold)}", |
| 85 | "payload": { |
| 86 | "asset": "base", |
| 87 | "outputs": [ |
| 88 | { |
| 89 | "address": "{ var['leader'] }", |
| 90 | "amount": "{ var['stack_amnt'] }" |
| 91 | }, |
| 92 | { |
| 93 | "address": "{ $bot_address }", |
| 94 | "amount": "{ balance[base] - var['stack_amnt'] - $seed_amnt }" |
| 95 | } |
| 96 | ] |
| 97 | } |
| 98 | }, |
| 99 | { |
| 100 | "if": "{(var['author'] == var['leader']) AND (var['commission_pot'] < $commission_payout_threshold)}", |
| 101 | "payload": { |
| 102 | "asset": "base", |
| 103 | "outputs": [ |
| 104 | { |
| 105 | "address": "{ var['leader'] }", |
| 106 | "amount": "{ var['stack_amnt'] }" |
| 107 | } |
| 108 | ] |
| 109 | } |
| 110 | }, |
| 111 | { |
| 112 | "if": "{(var['author'] != var['leader']) AND (var['commission_pot'] >= $commission_payout_threshold)}", |
| 113 | "payload": { |
| 114 | "asset": "base", |
| 115 | "outputs": [ |
| 116 | { |
| 117 | "address": "{ var['author'] }", |
| 118 | "amount": "{ var['stack_amnt'] / 2 }" |
| 119 | }, |
| 120 | { |
| 121 | "address": "{ var['leader'] }", |
| 122 | "amount": "{ var['stack_amnt'] / 2 }" |
| 123 | }, |
| 124 | { |
| 125 | "address": "{ $bot_address }", |
| 126 | "amount": "{ balance[base] - var['stack_amnt'] - $seed_amnt }" |
| 127 | } |
| 128 | ] |
| 129 | } |
| 130 | }, |
| 131 | { |
| 132 | "if": "{(var['author'] != var['leader']) AND (var['commission_pot'] < $commission_payout_threshold)}", |
| 133 | "payload": { |
| 134 | "asset": "base", |
| 135 | "outputs": [ |
| 136 | { |
| 137 | "address": "{ var['author'] }", |
| 138 | "amount": "{ var['stack_amnt'] / 2 }" |
| 139 | }, |
| 140 | { |
| 141 | "address": "{ var['leader'] }", |
| 142 | "amount": "{ var['stack_amnt'] / 2 }" |
| 143 | } |
| 144 | ] |
| 145 | } |
| 146 | } |
| 147 | ] |
| 148 | } |
| 149 | }, |
| 150 | { |
| 151 | "app": "state", |
| 152 | "state": "{ // game is finished |
| 153 | var['game_status'] = 'not started'; |
| 154 | if (var['commission_pot'] >= $commission_payout_threshold) var['commission_pot'] = 0; |
| 155 | var['commission_pot'] += $bid_amnt; // add money from the bot to the commission pot |
| 156 | var['stack_amnt'] = 0; |
| 157 | var['author'] = ''; |
| 158 | var['leader'] = ''; |
| 159 | response['message'] = 'Game finished.'; |
| 160 | }" |
| 161 | } |
| 162 | ] |
| 163 | } |
| 164 | ] |
| 165 | } |
| 166 | } |
| 167 | ] |
| Message | formula { // ================= OBYSTACK ================= // ============================================ // OBYTE STACK GAME from Whistling Frogs // ============================================ // First published by Crypto Girl on 21 Sep 2019 // ============================================ // Version: 1.0 - 8 Oct 2019 // ============================================ // Can be used with OBYTE STACK GAME BOT v1.0 // Pairing code: // [email protected]/bb-test#StackGame // ============================================ // The object of the game is to win the Stack. // Users make bids. Min bid is 100,000 bytes. // 1st bid initiates the Stack. // Each subsequent bid starts the 50 sec timer. // If more than 50 sec has passed since the previous // bid, the (stack - commission) is shared equally // between the last bidder and the 1st bidder. // The new stack is initiated with the current bid. // A commission of 10,000 bytes is charged on each bid. // ============================================ // Visit https://whistling-frogs.herokuapp.com/obyStack // for a full description of the game. // ============================================ // // setting game parameters $bot_address_back = 'QUONK7CUHPTGLNTZ6JE57SDVSFVDBCMM'; $commission_payout_threshold = 50000; $commission = 10000; $seed_amnt = 10000; $min_bid_amnt = 100000; $fees = 1000; // setting game variables $bid_amnt = trigger.output[[asset=base]]; $game_finished = (trigger.initial_address == $bot_address) otherwise false; if ( ($game_finished == false) AND ($bid_amnt < $min_bid_amnt) ) bounce('Your bid is too small.'); $game_status = var['game_status'] otherwise 'not started'; } failed: booleans cannot be compared with other types |
|---|
| Message | formula { // ================= OBYSTACK ================= // ============================================ // OBYTE STACK GAME from Whistling Frogs // ============================================ // First published by Crypto Girl on 21 Sep 2019 // ============================================ // Version: 1.0 - 8 Oct 2019 // ============================================ // Can be used with OBYTE STACK GAME BOT v1.0 // Pairing code: // [email protected]/bb-test#StackGame // ============================================ // The object of the game is to win the Stack. // Users make bids. Min bid is 100,000 bytes. // 1st bid initiates the Stack. // Each subsequent bid starts the 50 sec timer. // If more than 50 sec has passed since the previous // bid, the (stack - commission) is shared equally // between the last bidder and the 1st bidder. // The new stack is initiated with the current bid. // A commission of 10,000 bytes is charged on each bid. // ============================================ // Visit https://whistling-frogs.herokuapp.com/obyStack // for a full description of the game. // ============================================ // // setting game parameters $bot_address_back = 'QUONK7CUHPTGLNTZ6JE57SDVSFVDBCMM'; $commission_payout_threshold = 50000; $commission = 10000; $seed_amnt = 10000; $min_bid_amnt = 100000; $fees = 1000; // setting game variables $bid_amnt = trigger.output[[asset=base]]; $game_finished = (trigger.initial_address == $bot_address) otherwise false; if ( ($game_finished == false) AND ($bid_amnt < $min_bid_amnt) ) bounce('Your bid is too small.'); $game_status = var['game_status'] otherwise 'not started'; } failed: booleans cannot be compared with other types |
|---|