From eb11990da57c4ba1ed321450dce3a3d0e5b51603 Mon Sep 17 00:00:00 2001 From: wlinator Date: Thu, 22 Jun 2023 05:52:34 -0400 Subject: [PATCH] Increase BJ MP & utilize JSON BJ MP = BlackJack multiplier. It went from 1.20 to 1.50 --- config/economy.json | 6 +++--- config/json_loader.py | 7 +++++++ main.py | 3 ++- modules/gambling.py | 11 ++++------- sb_tools/economy_functions.py | 6 ++++-- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/config/economy.json b/config/economy.json index 1355b39..3a25d08 100644 --- a/config/economy.json +++ b/config/economy.json @@ -4,10 +4,10 @@ "daily_reward": 50, "blackjack": { "emotes": { - "hit_id": 1119262723285467156, - "stand_id": 1118923298298929154 + "hit": "<:hit:1119262723285467156>", + "stand": "<:stand:1118923298298929154>" }, - "reward_multiplier": 1, + "reward_multiplier": 1.5, "deck_suits": [ "♠", "♡", diff --git a/config/json_loader.py b/config/json_loader.py index 3629f9a..ca5d816 100644 --- a/config/json_loader.py +++ b/config/json_loader.py @@ -6,3 +6,10 @@ def load_strings(path="config/strings.en-US.json"): data = json.load(file) return data + + +def load_economy_config(path="config/economy.json"): + with open(path, 'r') as file: + data = json.load(file) + + return data diff --git a/main.py b/main.py index 1893f1c..818356e 100644 --- a/main.py +++ b/main.py @@ -20,8 +20,9 @@ from config import json_loader logging.basicConfig(level=logging.INFO) load_dotenv('.env') -# load all strings.en-US.json strings +# load all json strings = json_loader.load_strings() +economy_config = json_loader.load_economy_config() sbbot = discord.Bot( owner_id=os.getenv('OWNER_ID'), diff --git a/modules/gambling.py b/modules/gambling.py index 9486de9..1a1e28f 100644 --- a/modules/gambling.py +++ b/modules/gambling.py @@ -1,5 +1,4 @@ import asyncio -import json import os import random @@ -10,6 +9,7 @@ from dotenv import load_dotenv from data.BlackJackStats import BlackJackStats from data.Currency import Currency from data.SlotsStats import SlotsStats +from main import economy_config from sb_tools import economy_embeds, economy_functions, universal, interaction, embeds load_dotenv('.env') @@ -18,9 +18,6 @@ active_blackjack_games = {} special_balance_name = os.getenv("SPECIAL_BALANCE_NAME") cash_balance_name = os.getenv("CASH_BALANCE_NAME") -with open("config/economy.json") as file: - json_data = json.load(file) - class Gambling(commands.Cog): def __init__(self, sbbot): @@ -133,7 +130,7 @@ class Gambling(commands.Cog): else: # bet multiplier - payout = bet * 1.2 + payout = bet * float(economy_config["blackjack"]["reward_multiplier"]) ctx_currency.add_cash(payout) ctx_currency.push() @@ -262,8 +259,8 @@ class Gambling(commands.Cog): if view.clickedConfirm: winner = random.choice([challenger, opponent]) loser = opponent if winner == challenger else challenger - combat_message = random.choice(json_data["duel"]["combat_messages"]).format(f"**{winner.name}**", - f"**{loser.name}**") + combat_message = random.choice(economy_config["duel"]["combat_messages"]).format(f"**{winner.name}**", + f"**{loser.name}**") await ctx.respond(content=f"{combat_message}\n\n" f"{winner.mention} wins **{cash_balance_name}{bet}**\n" diff --git a/sb_tools/economy_functions.py b/sb_tools/economy_functions.py index 717d181..dfe72b8 100644 --- a/sb_tools/economy_functions.py +++ b/sb_tools/economy_functions.py @@ -1,10 +1,12 @@ import random from collections import Counter +from main import economy_config + def blackjack_get_new_deck(): - suits = ['♠', '♡', '♢', '♣'] - ranks = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'] + suits = economy_config["blackjack"]["deck_suits"] + ranks = economy_config["blackjack"]["deck_ranks"] deck = [] for suit in suits: for rank in ranks: