diff --git a/dist/ba_root/mods/playersData/pdata.py b/dist/ba_root/mods/playersData/pdata.py index 691a314..ba8e93a 100644 --- a/dist/ba_root/mods/playersData/pdata.py +++ b/dist/ba_root/mods/playersData/pdata.py @@ -81,11 +81,22 @@ def change_role_tag(role,tag): return "role not exists" -def commit(): +def commit(_roles): global roles + if _roles=={}: + return f=open("roles.json",'w') - json.dump(roles,f,indent=4) + json.dump(_roles,f,indent=4) f.close() + roles=_roles + +def get_role(acc_id): + global roles + _roles =roles() + for role in _roles: + if acc_id in role["ids"]: + return role + #======================= CUSTOM EFFECTS/TAGS =============== diff --git a/dist/ba_root/mods/setting.json b/dist/ba_root/mods/setting.json index 32bfb05..25a2b9d 100644 --- a/dist/ba_root/mods/setting.json +++ b/dist/ba_root/mods/setting.json @@ -4,5 +4,6 @@ "top watermark":"Welcome to server \n ip 192.168.0.1", "bottom left watermark":"join discord for fun", "center highlights":["message 1","message 2","message 3"] - } + }, + "enabletags":true } \ No newline at end of file diff --git a/dist/ba_root/mods/setting.py b/dist/ba_root/mods/setting.py index ea2f668..77cd40c 100644 --- a/dist/ba_root/mods/setting.py +++ b/dist/ba_root/mods/setting.py @@ -22,12 +22,3 @@ def sendError(msg: str, ID: int = None): else: ba.screenmessage(msg, color=(1,0,0), transient=True) -def getStats(): - try: - f = open(statsFile, 'r') - a = json.loads(f.read()) - f.close() - return a - except: - print("Stats not found") - return {} \ No newline at end of file diff --git a/dist/ba_root/mods/spaz/modifyspaz.py b/dist/ba_root/mods/spaz/modifyspaz.py deleted file mode 100644 index 3f2ff2d..0000000 --- a/dist/ba_root/mods/spaz/modifyspaz.py +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/dist/ba_root/mods/spaz/hitmessage.py b/dist/ba_root/mods/spazmod/effects.py similarity index 100% rename from dist/ba_root/mods/spaz/hitmessage.py rename to dist/ba_root/mods/spazmod/effects.py diff --git a/dist/ba_root/mods/spaz/effects/__init__.py b/dist/ba_root/mods/spazmod/effects/__init__.py similarity index 100% rename from dist/ba_root/mods/spaz/effects/__init__.py rename to dist/ba_root/mods/spazmod/effects/__init__.py diff --git a/dist/ba_root/mods/spazmod/hitmessage.py b/dist/ba_root/mods/spazmod/hitmessage.py new file mode 100644 index 0000000..e69de29 diff --git a/dist/ba_root/mods/spazmod/modifyspaz.py b/dist/ba_root/mods/spazmod/modifyspaz.py new file mode 100644 index 0000000..5b4b391 --- /dev/null +++ b/dist/ba_root/mods/spazmod/modifyspaz.py @@ -0,0 +1,21 @@ +import tag +import effects +import setting + +# all activites related to modify spaz by any how will be here +def main(node,player): + _setting=setting.get_setting() + + if _setting['enabletags']: + tag.addtag(node,player) + if _setting['enablerank']: + tag.addrank(node,player) + if _setting['enableeffects']: + effects.addeffect(node,player) + + + + + + + diff --git a/dist/ba_root/mods/spazmod/tag.py b/dist/ba_root/mods/spazmod/tag.py new file mode 100644 index 0000000..a20004a --- /dev/null +++ b/dist/ba_root/mods/spazmod/tag.py @@ -0,0 +1,68 @@ + +import pdata + +def addtag(node,player): + session_player=player.sessionplayer + account_id=session_player.get_account_id() + customtag=pdata.custom()['customtag'] + roles=pdata.roles() + role=pdata.get_role(account_id) + tag=None + if account_id in customtag: + tag=customtag[account_id] + elif role: + tag=roles[role]['tag'] + + tag(node,tag) + +def addrank(node,player): + +class tag(object): + def __init__(owner=None,tag="somthing"): + mnode = ba.newnode('math', + owner=self.node, + attrs={ + 'input1': (0, 1.4, 0), + 'operation': 'add' + }) + self.node.connectattr('torso_position', mnode, 'input2') + self.tag_text = ba.newnode('text', + owner=self.node, + attrs={ + 'text': tag, + 'in_world': True, + 'shadow': 1.0, + 'flatness': 1.0, + 'color': (1,1,1), + 'scale': 0.02, + 'h_align': 'center' + }) + mnode.connectattr('output', self.tag_text, 'position') + +class rank(object): + def __init__(owner=None,rank=1): + mnode = ba.newnode('math', + owner=self.node, + attrs={ + 'input1': (0, 1.4, 0), + 'operation': 'add' + }) + self.node.connectattr('torso_position', mnode, 'input2') + self.rank_text = ba.newnode('text', + owner=self.node, + attrs={ + 'text': str(rank), + 'in_world': True, + 'shadow': 1.0, + 'flatness': 1.0, + 'color': (1,1,1), + 'scale': 0.02, + 'h_align': 'center' + }) + mnode.connectattr('output', self.rank_text, 'position') + + + + + + diff --git a/dist/ba_root/mods/spaz/tag/__init__.py b/dist/ba_root/mods/spazmod/tag/__init__.py similarity index 100% rename from dist/ba_root/mods/spaz/tag/__init__.py rename to dist/ba_root/mods/spazmod/tag/__init__.py diff --git a/dist/ba_root/mods/stats/mystats.py b/dist/ba_root/mods/stats/mystats.py index cd4fc4a..f50c252 100644 --- a/dist/ba_root/mods/stats/mystats.py +++ b/dist/ba_root/mods/stats/mystats.py @@ -4,7 +4,7 @@ damage_data = {} mystats module for BombSquad version 1.5.29 Provides functionality for dumping player stats to disk between rounds. """ - +ranks=[] import threading,json,os,urllib.request,ba,_ba,setting from ba._activity import Activity from ba._music import setmusic, MusicType @@ -56,6 +56,7 @@ def refreshStats(): toppers = {} pStats = stats toppersIDs=[] + _ranks=[] for entry in entries: if True: rank += 1 @@ -85,6 +86,9 @@ def refreshStats(): dmg = damage_data[aid] dmg = str(str(dmg).split('.')[0] + '.' + str(dmg).split('.')[1][:3]) else: dmg = 0 + + _ranks.append(aid) + pStats[str(aid)]["rank"] = int(rank) pStats[str(aid)]["scores"] = int(scores) pStats[str(aid)]["total_damage"] += float(dmg) #not working properly @@ -110,7 +114,8 @@ def refreshStats(): ''') f.close() - + global ranks + ranks=_ranks f2 = open(statsfile, "w") f2.write(json.dumps(pStats, indent=4)) f2.close() @@ -201,4 +206,11 @@ class UpdateThread(threading.Thread): now = datetime.now() update_time = now.strftime("%S:%M:%H - %d %b %y") print(f"Added {str(len(self._account_kills))} account's stats entries. || {str(update_time)}") - refreshStats() \ No newline at end of file + refreshStats() + +def getRank(acc_id): + global ranks + if ranks==[]: + refreshStats() + if acc_id in ranks: + return ranks.index(acc_id) \ No newline at end of file