From 2ebe97ebcd378b25a66c315a45a3352ad43b8acc Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 11 Oct 2022 16:14:09 +0200 Subject: [PATCH] implement HYPER COIN EVENT --- coin.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/coin.rb b/coin.rb index 60b40c5..f683ac5 100644 --- a/coin.rb +++ b/coin.rb @@ -31,12 +31,14 @@ def get_coin_count(user) scoreboard[user] || 0 end -def increment_coin(user) +def increment_coin(user, amount=1) scoreboard = load_scoreboard() - coins = get_coin_count(scoreboard, user) + 1 + coins = get_coin_count(user) + amount scoreboard[user] = coins File.write(SCOREBOARD, scoreboard.to_yaml) + + return coins end def empty_coin(user) @@ -61,12 +63,17 @@ end bot.message(content: 'GET COIN' ) do |event| # update score if coin_state_active - increment_coin(event.author.id) + if(rand(100) == 47) + hyper_coin_amount = rand(100) + coins = increment_coin(event.author.id, hyper_coin_amount) + event.respond "What astounding luck!!! #{event.author.display_name}, you've just activated HYPER COIN EVENT and have received #{hyper_coin_amount} coins for a grand total of #{coins} coins!" + else + coins = increment_coin(event.author.id) + event.respond "Nice catch, #{event.author.display_name}! You have #{plural('coin', coins)} now!" + end coin_state_active = false - coins = get_coin_count(event.author.id) - event.respond "Nice catch, #{event.author.display_name}! You have #{plural('coin', coins)} now!" else event.respond "No coins for you, #{event.author.display_name}!" end