Just an idea,
I thought it would be useful if the point system had a MAX value variable so that no viewer could earn more than a set amount of points.
Uses:
To keep things fair for new viewers
To match any kind of future integration with a website CAP (eg MyCred)
btw, here's the code for anyone who uses MyCred on their wordpress website who wants a point cap, just add to your functions.php file for your theme in use (just replace 500000000 with whatever you want your cap set at) provided that the author doesn't include this on an update sometime in the future:
/************************************************************************
* MyCred Balance Cap
*************************************************************************/
add_filter( 'mycred_add', 'enforce_points_cap', 10, 3 );
function enforce_points_cap( $reply, $request, $mycred ) {
if ( $reply !== true ) return $reply;
// Cap
$cap = 500000000;
// Get user id from the request
$user_id = (int) $request['user_id'];
// Get current balance
$current_balance = $mycred->get_users_cred( $user_id, $request['type'] );
// If we have reached the cap deny this transaction
if ( $current_balance >= $cap ) return false;
// The amount the user would gain in this transaction
$amount = $reqest['amount'];
// get what the new balance would be
$new_balance = $current_balance + $amount;
// if this bring us over the cap, only add enough to reach the cap
if ( $new_balance > $cap ) {
$over = $new_balance - $cap;
// Add points now
$mycred->update_user_balance( $user_id, $over );
// Returns "done"
return 'done';
}
// Transaction is ok, let myCRED add
return true;
}
And just because it'd be another feature that no one else is doing for their Twitch.TV chat bot loyalty point system.
DeepBot is the best Twitch.TV bot on the planet. If you landed here, you landed in the right place!