From b582230e7e4ecf8dae39dab19d169fd7ab0ddc7d Mon Sep 17 00:00:00 2001 From: snowman1711 Date: Mon, 12 Apr 2021 22:16:56 +0530 Subject: [PATCH] added good base for currency system --- .../data_functions.cpython-38.opt-1.pyc | Bin 0 -> 1394 bytes .../__pycache__/fun.cpython-38.opt-1.pyc | Bin 0 -> 568 bytes .../Command_Objects/data_functions.py | 42 ++++++++++++++++++ .../Currency/Commands/Command_Objects/fun.py | 17 +++++++ .../chat_commands.cpython-38.opt-1.pyc | Bin 0 -> 555 bytes .../mods/Currency/Commands/chat_commands.py | 13 ++++++ dist/ba_root/mods/Currency/Data/bank.json | 12 +++++ .../ba_get_player_data.cpython-38.opt-1.pyc | Bin 0 -> 857 bytes .../bank_handler.cpython-38.opt-1.pyc | Bin 0 -> 979 bytes .../cooldown_manager.cpython-38.opt-1.pyc | Bin 0 -> 950 bytes .../Currency/Handlers/ba_get_player_data.py | 24 ++++++++++ .../mods/Currency/Handlers/bank_handler.py | 38 ++++++++++++++++ .../Currency/Handlers/cooldown_manager.py | 1 + dist/ba_root/mods/Currency/__init__.py | 14 ++++++ .../__pycache__/__init__.cpython-38.opt-1.pyc | Bin 0 -> 543 bytes 15 files changed, 161 insertions(+) create mode 100644 dist/ba_root/mods/Currency/Commands/Command_Objects/__pycache__/data_functions.cpython-38.opt-1.pyc create mode 100644 dist/ba_root/mods/Currency/Commands/Command_Objects/__pycache__/fun.cpython-38.opt-1.pyc create mode 100644 dist/ba_root/mods/Currency/Commands/Command_Objects/data_functions.py create mode 100644 dist/ba_root/mods/Currency/Commands/Command_Objects/fun.py create mode 100644 dist/ba_root/mods/Currency/Commands/__pycache__/chat_commands.cpython-38.opt-1.pyc create mode 100644 dist/ba_root/mods/Currency/Commands/chat_commands.py create mode 100644 dist/ba_root/mods/Currency/Data/bank.json create mode 100644 dist/ba_root/mods/Currency/Handlers/__pycache__/ba_get_player_data.cpython-38.opt-1.pyc create mode 100644 dist/ba_root/mods/Currency/Handlers/__pycache__/bank_handler.cpython-38.opt-1.pyc create mode 100644 dist/ba_root/mods/Currency/Handlers/__pycache__/cooldown_manager.cpython-38.opt-1.pyc create mode 100644 dist/ba_root/mods/Currency/Handlers/ba_get_player_data.py create mode 100644 dist/ba_root/mods/Currency/Handlers/bank_handler.py create mode 100644 dist/ba_root/mods/Currency/Handlers/cooldown_manager.py create mode 100644 dist/ba_root/mods/Currency/__init__.py create mode 100644 dist/ba_root/mods/Currency/__pycache__/__init__.cpython-38.opt-1.pyc diff --git a/dist/ba_root/mods/Currency/Commands/Command_Objects/__pycache__/data_functions.cpython-38.opt-1.pyc b/dist/ba_root/mods/Currency/Commands/Command_Objects/__pycache__/data_functions.cpython-38.opt-1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ceec04e966ca4c2ca76d0ede0049e7026db94201 GIT binary patch literal 1394 zcmZux&5k2A5VqaF$)q#G2mu2EwN_k$#Dv>kRtW7}_Ou8sTzqL9+nZ$Rb`Q3jVM6CZ z_R13=BslU)zH*vZ;6zm?GaCeMxm;B)cbDt?s=q0UF@f>S`fqhi$X{q2j|hw}V7i|{ zD8h-Niq(|UVP%{RYs8~rjd=`fRI?`GDaF_r^o-|&p46kS(U;WY!+HX1s78oeg`RG+D_I{AgFi7H-`9p!H+_JYi&o5!W|t<~kr&Pcy*jVtw!T6SKm@@Az? zDObXmvTYh+R4E`(in@l)JGcOOKBM6TBO2|TSZXi}C#}}zje~x2MaK;< zn@4?L{{JN+yTllEGhN=Vsu#)kqgJ-kB+FTzyTYi)ex+scSW zhsb#w(wD7mgb%UPM$Ph&c23*13i&=5v;;ja#KV~!6RSkydGU}Znsx+b3)w={!btrm zvG0KW_g8ZS9RQo_rmF>jJ^yU}v~3nIzVC#ZUv<`MBX8$dd)(cfO<6{_n30XqXhXwFiYXA~Y*Qu`kG?h+6{m0WdJAm=0!H2LLaP+n`IW8++vdU1O;B#V&3)?L`bn+)_#^+ECEloutqC; zj(ahJX5U7CcIbftlD&8rL-K`Q4psaBEQhBE%V`RAoIo8xqwh2OA$Vu!A*-O1WK{*W z5Fr9ih4__gO-T1`X0e-wq%8h<_~_7_ZplBo2l?_DbYu-ox*UkJ+FShN|J$#SxYxC~ z)wV(k@JIiRl5Jb7_Qq83#{h=e5CKp2)fp;=4B+{F)Nqlb3Lri0z6?*AR&}-h9LeFZ SVlgf01fG0&&XRnZ(|-T}JZ>rg literal 0 HcmV?d00001 diff --git a/dist/ba_root/mods/Currency/Commands/Command_Objects/__pycache__/fun.cpython-38.opt-1.pyc b/dist/ba_root/mods/Currency/Commands/Command_Objects/__pycache__/fun.cpython-38.opt-1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..51bf23904309389af9a8d356d77471d6150be283 GIT binary patch literal 568 zcmah_y-ve05Vn&vO#=ahcz~=~2oHb|qJps?RV-PGn=@&kj*IOewKES=MqVi^Qy&2a z#5tv+0}^N5pY8j;ySt5|kf1DQ=I#sqyG^#Gi^(~vK1Krs=#*px9B{#d4*1Z8py*~4 zdJw*l%z+))MehO~k|bJT4H+!Da|4jD%L_uGnwZWZChMS`l#BDV91gh=hgDkLE<((a)1<#pHF0&^CkjW zF(Z{8O-pUwi0WWbYd)`1jSsBgDHrvW84l@5dLhMl_*64U`?XTM%I9fc3W1<{6O69M z4?H(Iy|1g|*}OR{xEZZ!M?Y+lZO=hNsIsg4e+HoK49;M6gZ~pp+3KceVNnbI+xI&1 y?eqQ?bI$bS053PRb~%aH!YB{pwhv`*|AY!og@k&_*XLKCiSbU{WyofG9%QG7^adY1|mkwb`BQjGfq?D4^}g&*T&G zD{fQq3skut7Q~g#@x4c~eSGAvhll$F>u(pYzEDE`<>6&99L^Bo1W6M?G}Wx9f=(+F zOmkiI{F3OIp8qDI(CmWLi`!2XtPO0cRrk}_3fwR#tE&w2%fJ{>uHyO;FzD)fv=BRI zt84FuN~@@zrErf|lkdr_h|b#;+A+D?V?tC02- zfE#V>bSk0mOz!>=zlW9{&YBRNS1Z$)VeC~jx_Q@pbVGabV^q3Xj@}y!H_h@fqR_xv zMY#(soPNJa`_4Yii~PtEiLjC$Ap9%r>seYzsU1j}SgR73trBl`2g=XwHv=)8=1k>N e%wgI%IebC+E2Q%M;Plv=4>|8JM=ID6E%|?!Z<5^r literal 0 HcmV?d00001 diff --git a/dist/ba_root/mods/Currency/Commands/chat_commands.py b/dist/ba_root/mods/Currency/Commands/chat_commands.py new file mode 100644 index 0000000..774a20e --- /dev/null +++ b/dist/ba_root/mods/Currency/Commands/chat_commands.py @@ -0,0 +1,13 @@ +""" 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) diff --git a/dist/ba_root/mods/Currency/Data/bank.json b/dist/ba_root/mods/Currency/Data/bank.json new file mode 100644 index 0000000..c36c22b --- /dev/null +++ b/dist/ba_root/mods/Currency/Data/bank.json @@ -0,0 +1,12 @@ +{ + "None": { + "cash": 1421, + "bank_space": 100, + "bank_cash": 0 + }, + "pb-IF4VAk4a": { + "cash": 297, + "bank_space": 100, + "bank_cash": 0 + } +} \ No newline at end of file diff --git a/dist/ba_root/mods/Currency/Handlers/__pycache__/ba_get_player_data.cpython-38.opt-1.pyc b/dist/ba_root/mods/Currency/Handlers/__pycache__/ba_get_player_data.cpython-38.opt-1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a885830eef72e469ecf18fb100496a542c2b7783 GIT binary patch literal 857 zcmbV~L2uJA6vu5RUDDBYOh|}I9CF~&%Q6Xx6GDiAv{Nq?mrBTU^V}#RiPvWbsi?d0 zLEzZ0lq)B`0wO9HHLf1|fko=;p*d*gV>_$M*&r6#2oW!y3{0F<`YyO^ndVVX`0{Don*=KN;DcSE`0mqfO^Z`cL1KYNb(va_anM z)t>EOoRK@0(0A6I1&`?(@FB+m)Fgu`GJ8+kWl) zUo>Tjo(3Z?9%(C&e9iC<+*kYD9`#d>r<6NP{a=T-r5!?HJ+QP6>5n-K`RopI|CJ{X zamnN}%8ifONJ=o7l&zR6>`|_BziXx|xo1RYN#{oVx-!s|`i=L`#v~zsEaE7R{{Snf BxuO67 literal 0 HcmV?d00001 diff --git a/dist/ba_root/mods/Currency/Handlers/__pycache__/bank_handler.cpython-38.opt-1.pyc b/dist/ba_root/mods/Currency/Handlers/__pycache__/bank_handler.cpython-38.opt-1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..515810997c8cfd53962818749ab42d43c20aa9e7 GIT binary patch literal 979 zcmZWov2GJV5S_hSpU;U6289r)4vEGTIU2eM5J4zaBnXJe1((as8eek0HM@I3j-1N0 zh>kib`K4{C@(WbVo}I*kwPto^_IBpYoArlIX9Z~OADDxm9>8zsEH8?|OA@_93ZW0k z&?{J<)w|dC>fP`A!aL^|fc^tOejoY`Y+&#W`T;gEq`iqPT%kQgZx4E_r*SkC#aO68 zRc0oarH%$tMLInZQ6Wtv2T_riLOUaqD56U$54-l>cw&aKOfXj>Gg3{GN(*(m5pP#Y zi87nSuTzu8hiQ4dd8B2TF?VmVTrZqtn?!#iWnczp%&;lU*pwXyY8}}gtwg9~= zoBHy}=SzO$pYvb~41GUi46sREhP!W+t8aOh>ft3ibHzbR^f=9gZPm6rd*AbI=d&{oBe?+3)i*rDgi}YHy znItH)B(dHhO_?S>&*+QtWM07WT=!JpSjt;ha4gtxYb3EM#B=w&wEG8hZ^Q34!rNi< EFXq|Xs{jB1 literal 0 HcmV?d00001 diff --git a/dist/ba_root/mods/Currency/Handlers/__pycache__/cooldown_manager.cpython-38.opt-1.pyc b/dist/ba_root/mods/Currency/Handlers/__pycache__/cooldown_manager.cpython-38.opt-1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..31c4769a2ac80be5139102e1a9deb4de3166e9bb GIT binary patch literal 950 zcmaJ055Z&23Nhe#1Z3WUK5VZ$Fm%@b$V?xxp5&@G&jk3O7$-?)c?A}FK$W;uI z8~=e2h)e&as{*O~7gA;BPAA17WMO7kqn$VJz1t7X<_^R4Lnj~KbH;wsk3SdI*jo(q z3X^0K0yZdi7=Yx`x?uw@;f%TVBi>+rA81=I>bBNl_VKV}Baqm4<6Ognx~!)SblJvu zj$sZlNw{SR`wlC(hb3F`C5)_mtn&q~v4U{6tRNg;@C6Jp5VYFY#KOneETU4uc#UB? zm{y2=3HrqfC#?8_E#MA&X_n+G_LWKNn{^L>Vo6+qI6vscaUkPa)E0g+`K&tad8?gH zrAU-%YZZz~G>OJ8&#d9O$aeh;k%Y<^F;-Z!g&v!%dO4%rwKB(FgJq6PwMZs$lvP8O zT*UH${pxupi8Xe5Dog_$AiX!FWV3{gGMW_AUP7PpHbRcv@xzQ%Q+5XnFi{FT+LnD=f44i9MX*d literal 0 HcmV?d00001 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 new file mode 100644 index 0000000..72b083b --- /dev/null +++ b/dist/ba_root/mods/Currency/Handlers/ba_get_player_data.py @@ -0,0 +1,24 @@ +""" 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 diff --git a/dist/ba_root/mods/Currency/Handlers/bank_handler.py b/dist/ba_root/mods/Currency/Handlers/bank_handler.py new file mode 100644 index 0000000..b2b594f --- /dev/null +++ b/dist/ba_root/mods/Currency/Handlers/bank_handler.py @@ -0,0 +1,38 @@ +""" helperfunctions for save lot of lines of code """ + +import ba, _ba, json + + +bank_path = _ba.env()['python_directory_user']+'/Currency/Data/bank.json' + + + + +def open_account(accountid): + 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 get_bank_data(): + with open(bank_path, 'r') as f: + users = json.load(f) + return users + + + +def commit(data): + with open(bank_path, "w") as f: + json.dump(data, f, indent=2) + + + diff --git a/dist/ba_root/mods/Currency/Handlers/cooldown_manager.py b/dist/ba_root/mods/Currency/Handlers/cooldown_manager.py new file mode 100644 index 0000000..0bf7f0d --- /dev/null +++ b/dist/ba_root/mods/Currency/Handlers/cooldown_manager.py @@ -0,0 +1 @@ +""" 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 new file mode 100644 index 0000000..ad9c9da --- /dev/null +++ b/dist/ba_root/mods/Currency/__init__.py @@ -0,0 +1,14 @@ +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 diff --git a/dist/ba_root/mods/Currency/__pycache__/__init__.cpython-38.opt-1.pyc b/dist/ba_root/mods/Currency/__pycache__/__init__.cpython-38.opt-1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5f6f75bd53ca9e5d362405bc9b8981847cc42710 GIT binary patch literal 543 zcmYjNJ#X7E5ap3nVjH&eu?1N=bn#*por|J~mrOD7hqs!i7Ag{U7$2 zzmcE8HBt9+FTQB;K& zV!T`hZe&r#gSb8dfg$a|5YC}P?J3sNQId5g`|Exvy}ZUtm)g4VgA{Y^#j=zuZH1EP eYiB4v+$s75C)f*}AEs7Ksei_cIF8VVK7R)*OofC1 literal 0 HcmV?d00001