diff --git a/dist/ba_root/mods/Currency/Commands/Command_Objects/data_functions.py b/dist/ba_root/mods/Currency/Commands/Command_Objects/data_functions.py deleted file mode 100644 index c2c9a50..0000000 --- a/dist/ba_root/mods/Currency/Commands/Command_Objects/data_functions.py +++ /dev/null @@ -1,64 +0,0 @@ -""" store functions executed when chat command are called """ -import ba, _ba, json, random - -from Currency.Handlers.bank_handler import * -from Currency.Handlers.ba_get_player_data import * -#from Currency.Handlers.cooldown_manager import * -from Currency.Handlers.CLstr import CLstr, Errorstr -from .fun import get_random_donator, get_random_cash - - - - - -def balance_call(userid : str, clientid : int): - open_account(userid) - - users = get_bank_data() - name = client_to_name(clientid) - - PlayerData = get_player_data(userid) - - balance = CLstr("English", "balance").format(str(name), str(PlayerData[0]), str(PlayerData[1]), str(PlayerData[2])) - send(balance, clientid) - - - - -def beg_call(userid : str, clientid : int): - open_account(userid) - earned = get_random_cash() - - update_bank(userid, earned, "cash", type_only=True) - cash = get_player_data(userid)[0] - donator = get_random_donator() - - send(CLstr("English", "beg").format(donator, earned, cash), clientid) - - - - -def withdraw_call(userid : str, args : int, clientid : int): - open_account(userid) - withd = int(args[0]) - - if cheack_withd(userid, withd, clientid): - return - - update_bank(userid, withd) - - send(CLstr("English", "withdraw").format(withd), clientid) - - - - -def deposit_call(userid : str, args : int, clientid : int): - open_account(userid) - dep = int(args[0]) - - if cheack_cash_and_space(userid, dep, clientid): - return - - update_bank(userid, dep, "bank") - - send(CLstr("English", "deposit").format(dep), clientid) \ No newline at end of file diff --git a/dist/ba_root/mods/Currency/Commands/Command_Objects/fun.py b/dist/ba_root/mods/Currency/Commands/Command_Objects/fun.py deleted file mode 100644 index f98a4ce..0000000 --- a/dist/ba_root/mods/Currency/Commands/Command_Objects/fun.py +++ /dev/null @@ -1,17 +0,0 @@ -import random - -donators_list = [ -'Eggs broke and', -'pranav', -'your mom', -'saitama', -'one simp', -'idiot', -'mr smoothy' -] - -def get_random_donator(): - return random.choice(donators_list) - -def get_random_cash(): - return random.randrange(80) diff --git a/dist/ba_root/mods/Currency/Commands/chat_commands.py b/dist/ba_root/mods/Currency/Commands/chat_commands.py deleted file mode 100644 index e05b3d5..0000000 --- a/dist/ba_root/mods/Currency/Commands/chat_commands.py +++ /dev/null @@ -1,20 +0,0 @@ -""" check given command and executive the the cmd function from data functions""" - -import ba, _ba -from .Command_Objects.data_functions import * - - -def on_command(cmd, args, accountid, clientid): - - if cmd in ['coins', 'bal', 'balance', 'me']: - balance_call(accountid, clientid) - - elif cmd == 'beg': - beg_call(accountid, clientid) - - elif cmd in ['with', 'withdraw']: - withdraw_call(accountid, args, clientid) - - elif cmd in ['dep', 'deposite']: - deposit_call(accountid, args, clientid) - diff --git a/dist/ba_root/mods/Currency/Data/bank.json b/dist/ba_root/mods/Currency/Data/bank.json deleted file mode 100644 index 565c4f0..0000000 --- a/dist/ba_root/mods/Currency/Data/bank.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "None": { - "cash": 3402, - "bank_space": 100, - "bank_cash": 10 - }, - "pb-IF4VAk4a": { - "cash": 0, - "bank_space": 100, - "bank_cash": 0 - } -} \ No newline at end of file diff --git a/dist/ba_root/mods/Currency/Data/textes.json b/dist/ba_root/mods/Currency/Data/textes.json deleted file mode 100644 index d755262..0000000 --- a/dist/ba_root/mods/Currency/Data/textes.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "English": { - "errors":{ - "short_space":"You don't have that much space", - "short_ammount":"You don't have that much cash", - "short_bank_cash":"you don't have that much money in bank", - "bank_space_error":"get space in bank first" - }, - "balance": "|| {} | Cash - {} | Bank- {}/{} ||", - "beg":"{} gave you {} now you have {} coins", - "deposit":"deposited {}", - "withdraw": "withdrew {}" - } -} \ No newline at end of file diff --git a/dist/ba_root/mods/Currency/Handlers/CLstr.py b/dist/ba_root/mods/Currency/Handlers/CLstr.py deleted file mode 100644 index 5aacba2..0000000 --- a/dist/ba_root/mods/Currency/Handlers/CLstr.py +++ /dev/null @@ -1,18 +0,0 @@ -import ba, _ba, json - -textes_path = _ba.env()['python_directory_user']+'/Currency/Data/textes.json' - - -def CLstr(language, text): - with open(textes_path, 'r') as f: - textes = json.load(f) - text = textes[language][text] - return text - - -def Errorstr(language, text): - with open(textes_path, 'r') as f: - textes = json.load(f) - t = textes[language]["errors"][text] - return t - diff --git a/dist/ba_root/mods/Currency/Handlers/ba_get_player_data.py b/dist/ba_root/mods/Currency/Handlers/ba_get_player_data.py deleted file mode 100644 index e7a4596..0000000 --- a/dist/ba_root/mods/Currency/Handlers/ba_get_player_data.py +++ /dev/null @@ -1,38 +0,0 @@ -""" retruns information of given user using client_id """ -import ba, _ba - -def client_to_account(client_id): - rost = _ba.get_game_roster() - for i in rost: - if i['client_id'] == client_id: - return i['account_id'] - return None - -def client_to_name(client_id): - rost = _ba.get_game_roster() - for i in rost: - if i['client_id'] == client_id: - return i['players'][0]['name_full'] - return None - - -def client_to_display_string(client_id): - rost = _ba.get_game_roster() - for i in rost: - if i['client_id'] == client_id: - return i['display_string'] - return None - - -def send(msg, clientid): - _ba.chatmessage(str(msg), clients=[clientid]) - _ba.screenmessage(str(msg), transient=True, clients=[clientid]) - - - -def senderror(msg, clientid): - _ba.chatmessage(str(msg), clients=[clientid], sender_override = "Use[server]") - _ba.screenmessage("Use[server] " + str(msg), transient=True, clients=[clientid]) - - - diff --git a/dist/ba_root/mods/Currency/Handlers/bank_handler.py b/dist/ba_root/mods/Currency/Handlers/bank_handler.py deleted file mode 100644 index ad61bc9..0000000 --- a/dist/ba_root/mods/Currency/Handlers/bank_handler.py +++ /dev/null @@ -1,105 +0,0 @@ -""" helperfunctions for save lot of lines of code """ -import ba, _ba, json -from .ba_get_player_data import send -from .CLstr import Errorstr - -bank_path = _ba.env()['python_directory_user']+'/Currency/Data/bank.json' - - - -def get_bank_data(): - with open(bank_path, 'r') as f: - users = json.load(f) - return users - - - -def get_player_data(accountid : str): - users = get_bank_data() - - cash = users[str(accountid)]["cash"] - bank_space = users[str(accountid)]["bank_space"] - bank_cash = users[str(accountid)]["bank_cash"] - - PlayerData = cash, bank_cash, bank_space - - return PlayerData - - - -def commit(data): - with open(bank_path, "w") as f: - json.dump(data, f, indent=2) - - - -def open_account(accountid : str): - users = get_bank_data() - - if str(accountid) in users: - return False - else: - users[str(accountid)] = {} - users[str(accountid)]["cash"] = 0 - users[str(accountid)]["bank_space"] = 100 - users[str(accountid)]["bank_cash"] = 0 - commit(users) - return True - - - -def update_bank(userid, ammount : int=0, type="cash", type_only=False): - users = get_bank_data() - - if type == "cash": - users[str(userid)]["cash"] += ammount - if type_only: - commit(users) - return - users[str(userid)]["bank_cash"] -= ammount - - commit(users) - - if type == "bank": - users[str(userid)]["cash"] -= ammount - if type_only: - commit(users) - return - users[str(userid)]["bank_cash"] += ammount - - commit(users) - - - -def cheack_cash_and_space(userid, ammount : int, clientid : int): - users = get_bank_data() - - cash_amt = users[str(userid)]["cash"] - bank_cash = users[str(userid)]["bank_cash"] - bank_space = users[str(userid)]["bank_space"] - - - if bank_space < ammount: - send(Errorstr("English", "short_space"), clientid) - return True - - if bank_space < bank_cash + ammount: - send(Errorstr("English", "bank_space_error"), clientid) - return True - - if cash_amt < ammount: - send(Errorstr("English", "short_ammount"), clientid) - return True - - - -def cheack_withd(userid, ammount : int, clientid : int): - users = get_bank_data() - bank_cash = users[str(userid)]["bank_cash"] - - if bank_cash < ammount: - send(Errorstr("English", "short_bank_cash"), clientid) - return True - - - diff --git a/dist/ba_root/mods/Currency/Handlers/cooldown_manager.py b/dist/ba_root/mods/Currency/Handlers/cooldown_manager.py deleted file mode 100644 index 0bf7f0d..0000000 --- a/dist/ba_root/mods/Currency/Handlers/cooldown_manager.py +++ /dev/null @@ -1 +0,0 @@ -""" cooldown manager """" \ No newline at end of file diff --git a/dist/ba_root/mods/Currency/__init__.py b/dist/ba_root/mods/Currency/__init__.py deleted file mode 100644 index ad9c9da..0000000 --- a/dist/ba_root/mods/Currency/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -from .Commands import chat_commands -from .Handlers.ba_get_player_data import client_to_account - - - -def main(msg, client_id): - command = msg.split(" ")[0] - - if command.startswith("."): - command = command.split(".")[1] - arguments = msg.split(" ")[1:] - accountid = client_to_account(client_id) - - chat_commands.on_command(command, arguments, accountid, client_id) \ No newline at end of file