|
@@ -5,7 +5,7 @@ import pickle
|
|
|
from sudoku_py import SudokuGenerator, Sudoku
|
|
|
|
|
|
from rollbot import as_plugin, with_help, as_sender_singleton, as_group_singleton, RollbotFailure
|
|
|
-from rollbot.plugins.decorators import with_startup, require_min_args, require_args
|
|
|
+from rollbot.plugins.decorators import with_startup, require_min_args, require_args, require_admin
|
|
|
from rollbot.plugins.injection import Database, Config, Arg, Singleton, Message, Lazy, Query
|
|
|
|
|
|
@as_sender_singleton
|
|
@@ -339,3 +339,18 @@ def blockchain(db: Database, wallets: Config("rollcoin.wallets")):
|
|
|
results.append((total, name, status))
|
|
|
return "\n".join(r for _, _, r in sorted(results, reverse=True))
|
|
|
|
|
|
+
|
|
|
+@with_help("Deflate the entire economy")
|
|
|
+@require_args(1, "Deflating requires exactly one argument: power of 10 to deflate by")
|
|
|
+@require_admin
|
|
|
+@as_plugin
|
|
|
+def deflate(factor: Arg(0, int, "Deflation factor must be an integer - not {}"),
|
|
|
+ wallets: Query(RollcoinWallet),
|
|
|
+ holdings: Query(RollcoinGamblingWallet)):
|
|
|
+ assert_positive(factor)
|
|
|
+ actual_factor = 10 ** -factor
|
|
|
+ for w in wallets:
|
|
|
+ w.balance = w.balance * actual_factor
|
|
|
+ for w in holdings:
|
|
|
+ w.balance = w.balance * actual_factor
|
|
|
+ return f"Done! I have deflated the entire economy by a factor of 10^{factor}"
|