[
"autonomous agent",
{
"init": "{
//
// ==========================================
// OBYTE STACK GAME from Whistling Frogs
// ==========================================
// Written by Crypto Girl on 21 September 2019
// ==========================================
// Version: 0.9b - 6 October 2019
// ==========================================
// Can be used with OBYTE STACK GAME BOT v0.5, Pairing code:
// A/R1S1zX9R9KzN34IA5PCUbYbRB5WEDLEdVaNo/0s/
[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 5 min 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.
// ===========================================
//
// setting game parameters
$bot_address = '4H2FOFBP7ST6BLYWHZ3GUV5PHY626AM4';
$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';
}",
"messages": [
{
"if": "{$game_finished}",
"app": "payment",
"payload": {
"cases": [
{
"if": "{(var['author'] == var['leader']) AND (var['commission_pot'] >= $commission_payout_threshold)}",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{ var['leader'] }",
"amount": "{ var['stack_amnt'] }"
},
{
"address": "{ $bot_address }",
"amount": "{ balance[base] - var['stack_amnt'] - $seed_amnt }"
}
]
}
},
{
"if": "{(var['author'] == var['leader']) AND (var['commission_pot'] < $commission_payout_threshold)}",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{ var['leader'] }",
"amount": "{ var['stack_amnt'] }"
}
]
}
},
{
"if": "{(var['author'] != var['leader']) AND (var['commission_pot'] >= $commission_payout_threshold)}",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{ var['author'] }",
"amount": "{ var['stack_amnt'] / 2 }"
},
{
"address": "{ var['leader'] }",
"amount": "{ var['stack_amnt'] / 2 }"
},
{
"address": "{ $bot_address }",
"amount": "{ balance[base] - var['stack_amnt'] - $seed_amnt }"
}
]
}
},
{
"if": "{(var['author'] != var['leader']) AND (var['commission_pot'] < $commission_payout_threshold)}",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{ var['author'] }",
"amount": "{ var['stack_amnt'] / 2 }"
},
{
"address": "{ var['leader'] }",
"amount": "{ var['stack_amnt'] / 2 }"
}
]
}
}
]
}
},
{
"app": "state",
"state": "{
// new game
if ($game_status == 'not started') {
var['stack_amnt'] = $bid_amnt - $commission;
var['commission_pot'] += $commission - $fees;
var['author'] = trigger.initial_address;
var['leader'] = trigger.initial_address;
var['game_status'] = 'running';
response['message'] = 'Thank you for playing';
}
// game is running
if ($game_status == 'running') {
var['stack_amnt'] += ($bid_amnt - $commission);
var['commission_pot'] += $commission;
var['leader'] = trigger.initial_address;
response['message'] = 'Thank you for playing';
}
// game is finished
if ($game_finished) {
var['game_status'] = 'not started';
if (var['commission_pot'] >= $commission_payout_threshold) var['commission_pot'] = 0;
var['commission_pot'] += 10000; // returning money sent by the bot
var['stack_amnt'] = 0;
var['author'] = '';
var['leader'] = '';
response['message'] = 'Game finished.';
}
}"
}
]
}
]