Browse Source

Rework mining rates

Kirk Trombley 4 years ago
parent
commit
164dd16b43
1 changed files with 9 additions and 4 deletions
  1. 9 4
      src/plugins/rollcoin.py

+ 9 - 4
src/plugins/rollcoin.py

@@ -174,7 +174,9 @@ def donate(amount: Arg(0, parse_amount, "Amount should be a number or ALL or FRA
 @as_plugin
 def mine(msg: Message, 
          blockchain: Singleton(RollcoinBlockchain), 
-         wallet: Singleton(RollcoinWallet)):
+         wallet: Singleton(RollcoinWallet),
+         market_rates: Config("rollcoin.mining"),
+         market_state: Lazy(Singleton(RollcoinMarket))):
     skip = msg.raw_args is not None and msg.raw_args.strip().lower() == "skip" and msg.from_admin
 
     if skip:
@@ -230,10 +232,13 @@ def mine(msg: Message,
             if set(x for r in parsed[i:i+3] for x in r[j:j+3]) != set(range(1, 10)):
                 return "Sorry, that solution isn't valid!"
 
-    market_rate = round(abs(gauss(10, 1)), 2)
-    wallet.balance = wallet.balance + market_rate
+    zeroes = len([y for x in puzzle for y in x if y == 0])
+    difficulty = (zeroes - 10) / 4
+    market_rate = market_rates.get(market_state.get().state, 10)
+    actual_value = round(abs(gauss(market_rate + difficulty, 1)), 2)
+    wallet.balance = wallet.balance + actual_value
     blockchain.clear_puzzle()
-    return f"Looks right to me! The current market rate is {market_rate} Rollcoins per Sudoku, so that brings your balance to {wallet.balance}"
+    return f"Looks right to me! The current market rate is {actual_value} Rollcoins per Sudoku, so that brings your balance to {wallet.balance}"
 
 
 @with_help("Beg for some Rollcoins")