Apps Home
|
Create an App
Coinfliptest
Author:
andreas_test
Description
Source Code
Launch App
Current Users
Created by:
Andreas_Test
/* App: Coin Flip (WIP) Creator: Andreas_97 Date: 19/05/2019 Notes: For anyone that might review this code, please note that I have no prior coding experience If anyone has suggestions or improvements, please let me know */ cb.settings_choices = [ { name: 'priceTier1', type: 'int', minValue: 0, label: 'price for tier 1 bet', defaultValue: 10, }, { name: 'priceTier2', type: 'int', minValue: 0, label: 'price for tier 2 bet', defaultValue: 20, }, { name: 'priceTier3', type: 'int', minValue: 0, label: 'price for tier 3 bet', defaultValue: 30, }, { name: 'priceTier4', type: 'int', minValue: 0, label: 'price for tier 4 bet', defaultValue: 50, }, { name: 'priceTier5', type: 'int', minValue: 0, label: 'price for tier 5 bet', defaultValue: 75, }, { name: 'priceTier6', type: 'int', minValue: 0, label: 'price for tier 6 bet', defaultValue: 100, }, { name: 'minimumTriesTier1', type: 'int', maxValue: 50, label: 'Want to keep the spins rigged in your favor? set the ammount of tries before win chance is 50/50', defaultValue: 20 }, {name: 'prize1', type: 'str', label: 'Prize for winning tier 1'}, {name: 'prize2', type: 'str', label: 'Prize for winning tier 2'}, {name: 'prize3', type: 'str', label: 'Prize for winning tier 3'}, {name: 'prize4', type: 'str', label: 'Prize for winning tier 4'}, {name: 'prize5', type: 'str', label: 'Prize for winning tier 5'}, {name: 'prize6', type: 'str', label: 'Prize for winning tier 6'}, ]; var tipAmount = 0; var lastPlayer = '--'; var tipper = '--'; var lastFlip = '--'; var tryAmount = 0; var flipCounter = 0; var prizes = []; function getRandomIntInclusive(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; } cb.onTip(function(tip) { tipAmount = parseInt(tip['amount']); tipper = tip['from_user']; if (tipAmount === cb.settings.price_tier1) { cb.tipOptions(function(user) { return {options:[{label: 'Heads'}, {label: 'Tails'}], label:'What are you betting on?'}; }); if (tip['message'] == 'Heads') { if (getRandomIntInclusive(1, 100) >= (50 (minimum_tries - tryAmount))) { cb.sendNotice(' has placed their bet on Heads and thereby won cb.settings.prize1'); tryAmount = 0; } else { cb.sendNotice(' had placed their bet on Heads and thereby lost'); tryAmount += 1; } }; if (tip['message'] == 'Tails') { if (getRandomIntInclusive(1, 100) >= (50 (minimum_tries - tryAmount))) { cb.sendNotice(' has placed their bet on Tails and thereby won cb.settings.prize1'); tryAmount = 0; } else { cb.sendNotice(' had placed their bet on Tails and thereby lost') tryAmount += 1; } }; }; });
© Copyright Chaturbate 2011- 2025. All Rights Reserved.